Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe charge multiple times

Using Stripe.js, I get a card token that I can then use to charge via:

Stripe::Charge.create(
  :amount => 400,
  :currency => "usd",
  :card => "tok_103rC02eZvKYlo2C2RD5docg", # obtained with Stripe.js,
  :metadata => {'order_id' => '6735'}
)

Can I use the same card token multiple times to charge the customer or is it 1 token/charge and any subsequent charge, I will have to grab a new token?

like image 969
0xSina Avatar asked Apr 15 '14 23:04

0xSina


People also ask

How many times will Stripe retry a payment?

Retrying card issuer declines If your integration has retry logic in place to retry declined charges, be aware that card networks have rules in place for how many times you can reattempt a single charge. We recommend you not retry charges more than four times.

Does Stripe automatically retry failed payments?

Recurring charges When payments fail, Stripe retries them using the Smart Retries feature. This automatically re-attempts payment when cards are declined according to your Dashboard settings.

Does Stripe support recurring payments?

Stripe Billing is the fastest way for your business to bill customers with subscriptions or invoices. Capture more revenue, support new products or business models, and accept recurring payments globally.

Does Stripe automatically charge for subscription?

Have Stripe automatically charge a customer's stored payment method. Stripe can automatically attempt to pay an invoice if the customer has a payment method on file. You can choose to automatically charge a customer when you're creating an invoice or through the API.


2 Answers

Good question! When you use the token in that manner, it's immediately consumed, so it can't be used again. However, you can instead provide that token as the card argument when creating a Customer object in Stripe. Then you can perform multiple charges against that Customer.

  • https://stripe.com/docs/api#create_customer

Hope that helps. Larry

PS I work on Support at Stripe.

like image 107
Larry Ullman Avatar answered Oct 10 '22 14:10

Larry Ullman


There are two thing. One is token and one is card id. Token can be used one time. Also it has some time limit to use. Card id we get after save the card to cloud. We can use card id multiple time. Token gets generate through Public key. and this can not be use again. So You can use card id for payment multiple time

require_once APPPATH . 'libraries/Stripe.php';
Stripe::setApiKey("***********************"); //Put here your secrect key

//Add card and get token id.

$tokenDetail = Stripe_Token::create(array(
"currency" => "USD",
"card" => array(
"number" => '********', //$credit_card_number,
"exp_month" => '**', //$exp_date_month,
"exp_year" => '**', //$exp_date_year,
"cvc" => '***'//$cvv_number
)
));


$token = $tokenDetail->id;
Stripe::setApiKey("*********************"); ////Put here your secrect key

// Get card id by creating a Customer.
$customer = Stripe_Customer::create(array(
"source" => $tokenDetail->id,
"description" => "For testing purpose",
)
);  

$response = Stripe_Charge::create(array(
"amount" => 100,
"currency" => "usd",
"customer" => $customer->id // obtained with Stripe.js
));
like image 41
Manraj Avatar answered Oct 10 '22 16:10

Manraj