I store card information in database e.g card-id card_***** and customer id cus_**** on customer first payment for use it later on. user choose his card e.g in form of radio button visa****4242 and charge takes with card id or customer id. now i am using stripe modal box for payment. every payment new customer and card id create . how do i charge with card id or customer id on second payment ? here is my stripe code
$customer =Stripe_Customer::create(array(
'email' => $_SESSION['userEmail'],));
$charge = Stripe_Charge::create(array(
"amount" => $amount_cents,"currency" => "usd","source" =>
$_POST['stripeToken'],"description" => $description,
));
Possible this question may duplicate.But i can not find best answer .
Once you create a customer you can charge their default card with:
\Stripe\Charge::create(array(
"amount" => $amount_cents,
"currency" => "usd",
"customer" => $customer
));
If the customer has more than one card and you want to charge a card that isn't the default card, you have to pass in the customer and card id (when the card has already been saved to the customer):
\Stripe\Charge::create(array(
"amount" => $amount_cents,
"currency" => "usd",
"customer" => $customer,
"source" => $card_id
));
You can read more about this in Stripe's API docs:
https://stripe.com/docs/api/php#create_charge-source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With