Adyen / adyen-react-native

Adyen React Native
https://docs.adyen.com/checkout
MIT License
44 stars 32 forks source link

Callback onAdditionalDetails not called when using DropIn #214

Closed EvertV closed 1 year ago

EvertV commented 1 year ago

Describe the bug When using Components to add paymentMethodType bcmc_mobile_app, I get error Required field 'paymentData' is not provided on callback onAdditionalDetails. In the documentation it says that I should receive paymentData on POST /payments. But I don't get anything there, even after adding threeDSPaymentData to the response on our back-end (using "@adyen/api-library": "^13.1.2").

Here's some logs

 LOG  users/me/payments?channel=Android 200 0.51s
 LOG  onSubmit {"paymentMethod": {"type": "bcmc_mobile_app"}, "returnUrl": "adyenreactnative://com.gopoppy.app", "storePaymentMethod": false}
 LOG  POST users/me/payments 201 0.33s
 LOG  {"action": {"method": "GET", "paymentMethodType": "bcmc_mobile_app", "type": "redirect", "url": "https://checkoutshopper-live.adyen.com/checkoutshopper/checkoutPaymentRedirect?redirectData=..."}, "resultCode": "RedirectShopper"}
 LOG  onAdditionalDetails {"details": {"redirectResult": "X3XtfGC7!H4sIAAAA...."}}
 LOG  POST users/me/payments/details 400 1.13s
 LOG  {
  "status": 400,
  "data": {
    "message": "HTTP Exception: 422. : Required field 'paymentData' is not provided.",
    "data": {},
    "key": "HTTP Exception: 422. : Required field 'paymentData' is not provided."
  },
  "line": 19260,
  "column": 61,
  "sourceURL": "http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.gopoppy.app&modulesOnly=false&runModule=true"
}

On back-end side when calling checkout.payments, with request:

checkout.payments({
    merchantAccount: `${process.env.ADYEN_MERCHANT}`,
    amount: { currency: EURO, value: amount },
    paymentMethod: cardDetails,
    reference: transactionReference,
    channel,
    shopperReference,
    shopperEmail,
    telephoneNumber,
    shopperIP,
    enableRecurring: true,
    enableOneClick: false,
    shopperInteraction: PaymentRequest.ShopperInteractionEnum.Ecommerce,
    recurringProcessingModel:
      PaymentRequest.RecurringProcessingModelEnum.Subscription,
    returnUrl: `${returnUrl}`,
    additionalData: {
      allow3DS2: "true",
      "riskdata.riskProfileReference": "2519...."
    }
  })

And this is the response :

PaymentResponse {
  action: {
    paymentMethodType: 'bcmc_mobile_app',
    url: 'https://checkoutshopper-test.adyen.com/checkoutshopper/checkoutPaymentRedirect?redirectData=X3XtfGC7%21H4sIAAAAA...',
    method: 'GET',
    type: 'redirect'
  },
  additionalData: undefined,
  amount: undefined,
  donationToken: undefined,
  fraudResult: undefined,
  merchantReference: undefined,
  order: undefined,
  paymentMethod: undefined,
  pspReference: undefined,
  refusalReason: undefined,
  refusalReasonCode: undefined,
  resultCode: 'RedirectShopper',
  threeDS2ResponseData: undefined,
  threeDS2Result: undefined,
  threeDSPaymentData: undefined
}

When using DropIn, callback onAdditionalDetails doesn't seem to get called and continues works without error, but the payment method does not seem to get saved.

Logs when using DropIn:

 LOG  users/me/payments?channel=Android 200 0.40s
 LOG  onSubmit {"amount": {"currency": "EUR", "value": 2}, "paymentMethod": {"type": "bcmc_mobile_app"}, "returnUrl": "adyencheckout://com.gopoppy.app", "storePaymentMethod": false}
 LOG  POST users/me/payments 201 0.20s
 LOG  POST /payments result {"action": {"method": "GET", "paymentMethodType": "bcmc_mobile_app", "type": "redirect", "url": "https://checkoutshopper-live.adyen.com/checkoutshopper/checkoutPaymentRedirect?redirectData=X3XtfGC7%21H4sIAAA..."}, "resultCode": "RedirectShopper"}

For non-3DS payment methods, like credit card, it's working fine. We didn't have this issue on BETA-7, but started happening since we upgraded to latest (RC-2).

To Reproduce Steps to reproduce the behavior:

  1. Add payment method bcmc_mobile_app using Components
  2. Do the 3DS successful payment *(of 0.02 euros in this case)
  3. Back to the app, and Error 422. : Required field 'paymentData' is not provided. appears, after the onAdditionalDetails callback, which calls /payments/details
  4. Payment method does not get stored correctly

Same when using DropIn, but onAdditionalDetails callback does not get called, so no error. But also payment method does not get stored here.

Expected behavior Payment method bcmc_mobile_app should get correctly stored when coming back to the app and calling onAdditionalDetails.

Smartphone (please complete the following information):

Additional context When using BETA-7, I have these logs and the payment data gets saved correctly in our database (using the same back-end endpoints here).

LOG  users/me/payments?channel=Android 200 0.39s
 LOG  didSubmit {"amount": {"currency": "EUR", "value": 2}, "paymentMethod": {"type": "bcmc_mobile_app"}, "returnUrl": "adyencheckout://com.gopoppy.app", "storePaymentMethod": false}
 LOG  users/me/payments 201 2.61s
 LOG  didSubmit result {"action": {"method": "GET", "paymentMethodType": "bcmc_mobile_app", "type": "redirect", "url": "https://checkoutshopper-live.adyen.com/checkoutshopper/checkoutPaymentRedirect?redirectData=X3XtfGC7%21H4sIAAAAAAA..."}, "resultCode": "RedirectShopper"}
 LOG  didProvide {"details": {"redirectResult": "X3XtfGC7!H4sIAAAAA..."}}
 LOG  users/me/payments/details 201 0.44s
EvertV commented 1 year ago

Looks like I was passing the wrong data in the body of my users/me/payments/details 🤦

While making the changes and refactoring a bit, I ended up sending the details inside details, so it couldn't find the correct data.

But it looks like the type of data (PaymentMethodData) seems to be incorrect, since it looks like this:

{"details": {"redirectResult": "X3XtfGC7!H4sIAAAA...."}}

and not like this

export interface PaymentMethodData {
  paymentMethod: {
    type: string;
    [key: string]: any;
    checkoutAttemptId?: string;
  };
  browserInfo?: {
    userAgent: string;
  };
}

So my mistake was that I was sending this body to the endpoint

{"details": {"details": {"redirectResult": "X3XtfGC7!H4sIAAAA...."}}}

All good now! But maybe look at the type of data on method onAdditionalDetails @descorp ?

EvertV commented 1 year ago

Looks like I closed the issue too fast. onAdditionalDetails is not being called when using DropIn, but it's called when using Components. So bcmc_mobile_app cannot be set up with DropIn, since it needs onAdditionalDetails to be called.

0xClpz commented 1 year ago

Hello! We have a very similar setup on our side and we can't get onAdditionalDetails to be called when using bcmc_mobile_app either, it works fine with credit cards though.

descorp commented 1 year ago

Hey @EvertV @0xClpz

This is an issue on Android or both?

EvertV commented 1 year ago

@descorp I only tested Android, not sure for iOS right now

0xClpz commented 1 year ago

On my side this was an iOS issue, did not test it on android

descorp commented 1 year ago

hm.. 🤔

this could be issue on issuer side or this flow is somehow not yet supported. Will run tests locally and get back to you

descorp commented 1 year ago

It is working for me though

This is the tricky part. It could be one/small number of many issuers that acting unexpectedly.

EvertV commented 1 year ago

It was working well on beta-7 (with dropIn). We rolled out our app with the latest version now (using only components).

We're getting reports from users that cannot add payment method bcmc_mobile_app. When looking in the logs, it seems that onAdditionalDetails is not being called. It is working for me though, maybe it's specific issuers? I'm using the BNP Paribas Fortis app, but a client using the same bank app has this issue. In the logs I see that onAdditionalDetails is not being called, in Adyen everything is fine, the payment happens.

descorp commented 1 year ago

I'm using the BNP Paribas Fortis app, but a client using the same bank app

Maybe different version of issuer app? Or Web/Mobile flow?

@EvertV could you reach out to Adyen Support Team and provide them with PSP reference for your successful and shopper's unsuccessful transactions?

"PSP reference" could be found in your CA portal or in the header of network call.

EvertV commented 1 year ago

Done! Ticket ID #3988635 (in case it's relevant for you as well).

FYI: Turns out the issue was existing on beta-7 already

descorp commented 1 year ago

Great thanks @EvertV 💚 We will investigate from our side!

EvertV commented 1 year ago

@descorp I feel like this issue can be closed, since it got a bit messy to know what the issue exactly is (my bad). Should I open a new issue with the information mentioned in the support ticket #3988635 (successful payment without onAdditionalDetails called)?

descorp commented 1 year ago

This would be helpful to focus on one thing and consolidate our findings Thanks @EvertV

EvertV commented 1 year ago

Will do! See https://github.com/Adyen/adyen-react-native/issues/249