API: No Charge has been made to a certain customer

30 views
Skip to first unread message

ejay.o...@momentummedia.com.au

unread,
Oct 6, 2017, 7:31:50 AM10/6/17
to Stripe API Discussion
Hi Stripe Team,

I'm testing creating customer with a certain balance and its working fine, but when i tested the "charge" function and used the customer id as reference, It has no error.

But as a I retrieve the customer, there are no amount that has been deducted.

NOTE: I'm just using test developer token.

Here are my codes:

For Creating a customer:

                    $customer = \Stripe\Customer::create(array(
  "description" => "testing customer",
  "source" => $data->source, // obtained with Stripe.js
  "account_balance" => 100000
));

For charging:

                                 $charge = \Stripe\Charge::create(array(
"amount" => 20000,
"currency" => $currency,
//"source" => $data->source,
"customer" => $customer->id,
"description" => "Charge for " . $email
));

For retrieving:

$customer = \Stripe\Customer::retrieve($customer->id);

Hope you can help me with this. 

Thanks,

Ejay

Remi J.

unread,
Oct 6, 2017, 7:36:26 AM10/6/17
to api-d...@lists.stripe.com
Hi Ejay,

The account balance on the customer is never taken into account when you create a Charge via the API [1]. You explicitly pass the amount and the currency for the Charge and that's why we deduct from the customer's source directly.

The account balance is only taken into account for Subscriptions and Invoices. This means that if you subscribe someone to a $10 monthly plan and they have an account balance set to -750 (-$7.5), we will deduct this amount from the first invoice and only charge them $2.5. Future invoices would be for the expected $10 as the balance reached 0 at that point. 

If you want to "change" the amount charged on one-time charges, it's something you need to handle in your own code. You would explicitly pass a small `amount` when creating the Charge in that case.

I hope this explains the situation!
Best,
Remi


--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss+unsubscribe@lists.stripe.com.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at https://groups.google.com/a/lists.stripe.com/group/api-discuss/.

Reply all
Reply to author
Forward
0 new messages