Dhara
Dhara

Reputation: 1481

Stripe: How to migrate from Charge API to PaymentIntent API in php

I have used stripe in my one of the projects. I am taking card details from the user and the following code is for payment.

\Stripe\Stripe::setApiKey('KEY');

$token = \Stripe\Token::create([
        "card" => [
        "number"    => $paymentModel['number'],
        "exp_month" => $paymentModel['expire_month'],
        "exp_year"  => $paymentModel['expire_year'],
        "cvc"       => $paymentModel['card_cvc'],
        "name"      => $userName
      ]]);

 $customer   = \Stripe\Customer::create([
    'email'  => $email,
    'source' => $token['id'],
    ]);

$charge   = \Stripe\Charge::create([
   'amount'      => $chargeableAmount,
   'currency'    => 'usd',
   'description' => "Purchase User",
   'customer'    => $customerId,
]);

I got a notification for "Update your integration now for SCA". So I found that I should use PaymentIntent for card payments. I am really confused about these things. The document is confusing and it says so many things so I cannot understand what change I should do to migrate. There is no proper document which describe steps to migrate from Charge API to Payment Intent API.

Can anyone guide me?

Upvotes: 2

Views: 1414

Answers (2)

Rajesh
Rajesh

Reputation: 303

You can refer the below article to integrate SCA on your payment solution

3DS supported Stripe.js Integration with Chargebee APIs

Chargebee has PHP demo application in github which will help you to understand better.

Upvotes: 0

taintedzodiac
taintedzodiac

Reputation: 2906

You can follow Stripe's Migration Guide, under "Migrate your integration that saves cards on Customer objects" and the "Saving cards after a payment" tab. The text there also includes notes on how to handle Authentication under SCA with handleCardPayment on the front end.

Upvotes: 3

Related Questions