Reputation: 726
It is possible in stripe payment gateway?
we will using stripe for payment,firstly i am creating token.
$result = Stripe_Token::create(
array(
"card" => array(
"name" => $user['name'],
"number" => base64decrypt($user['card_number']),
"exp_month" => $user['month'],
"exp_year" => $user['year'],
"cvc" => base64decrypt($user['cvc_number'])
)
)
);
after using token create customer save card.
$customer = \Stripe\Customer::create(array(
"card" => $token,
"description" => "New customer",
"email" => $users->email
)
);
and after create charge.
$charge = \Stripe\Charge::create(
array('card' => $token->token,
'amount' => $token->amount * 100,
'currency' => 'usd',
)
);
but i can't find save multiple card in single customer. please help me.
Upvotes: 3
Views: 1360
Reputation: 17503
First, you should never create tokens server-side in production. In order to be eligible for PCI SAQ A, you must create the card tokens client-side, using Checkout or Stripe.js.
Once you receive the token on your server, you can use it in a few different manners:
you can use it to directly create a charge, without using customer objects at all, by passing the token ID ("tok_..."
) in the source
parameter. In this case the card information will be "lost" and you'll need to collect the information again and create a new token to charge this card again in the future.
you can use it to create a new customer.
you can use it to add a card to an existing customer.
When creating charges with customer objects, you need to pass the customer's ID ("cus_..."
) in the customer
parameter. If you don't pass a source
parameter, then the customer's default card will be used. If you want to charge a non-default card, then in addition to the customer
parameter, you'll also need to pass the card's ID ("card_..."
) in the source
parameter.
Cf. this StackOverflow answer.
Upvotes: 4