thephpleague / omnipay-stripe

Stripe driver for the Omnipay PHP payment processing library
MIT License
185 stars 168 forks source link

3DS - Create card issue with isRedirect() #191

Closed AntoineLemaire closed 4 years ago

AntoineLemaire commented 4 years ago

Hi there I'm facing a issue when creating a card from a source.

I get the source from javascript :

var stripe = Stripe('pk_test_xxxxxxxxxxxxxxxxxxxxx');
stripe.createSource({
    type: 'card',
    token: 'tok_visa',
}).then(function(result) {
    // get source from result json
});

image

Then I use the gateway to create a card

$response = $gateway->createCard([
    'customerReference' => 'cus_Hv3tbgOGRgmaur',
    'source'            => 'src_1HLDkmELCR82aCU0aKqaFWIL',
])->send();

As response, I got that image

The data['card']['three_d_secure'] is optional, but I don't have any data['redirect']['url']

So if I do

if ($response->isSuccessful()) {
    // Response is not successful, because of isRedirect() === true (because of cardCan3DS() === true)
} else if($response->isRedirect()) {
    $response->redirect(); // Will fail, because redirect Url is null
} else {
    // 
}

If I remove the isRedirect() condition inside isSuccessful(), my card is well created and I can attach it to my user without any issue

image

Am I doing something wrong?

domis86 commented 4 years ago
stripe.createSource({

Lets see docs about this method https://stripe.com/docs/js/tokens_sources/create_source - they link to https://stripe.com/docs/api#sources , and there there is link to https://stripe.com/docs/sources :

As of September 2019, a regulation called Strong Customer Authentication (SCA) requires businesses in Europe to request additional authentication for online payments. Businesses in Europe must start building their Stripe integrations with the Payment Intents and Payment Methods APIs instead of the Sources API to be ready for these rule changes.

As you see the "Sources API" in Stripe is deprecated - you should use Payment Intents (so "3D Secure 2") instead.

AntoineLemaire commented 4 years ago

Thanks you @domis86 for showing me that ! The project was created before in 2018 and we never migrate. I'm gonna have a look about that, thanks for helping me!