Adyen / adyen-react-native

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

Google Pay: #361

Closed gunnartorfis closed 8 months ago

gunnartorfis commented 8 months ago

Describe the bug When calling start("googlepay"), I get a crash from within BaseComponentFragment's hide function. From the looks of it, it seems unable to find a fragment by tag. I'm not sure why hide is being called straight from start() so I am kind of lost.

Expected behavior The Google Pay sheet should appear.

Screenshots Screenshot_20240205-162113

Smartphone (please complete the following information):

Additional context I've gone through the Android Google Pay setup:

descorp commented 8 months ago

Hey @gunnartorfis

From the looks of it, it seems unable to find a fragment by tag.

This is the side-effect indeed - I'll add safe check #362

I'm not sure why hide is being called straight from start() so I am kind of lost.

This is a pickle. SDK does not normally call hide. I assume that there was an exception (probably in checkConfiguration) and your code caught it and called hide.

Could this be the case?

gunnartorfis commented 8 months ago

This is a pickle. SDK does not normally call hide. I assume that there was an exception (probably in checkConfiguration) and your code caught it and called hide.

We're only calling hide when we get error responses from our API, so I doubt it 🤔 Would be interested to check out the #362 patch - are there plans to publish beta 2 soon?

descorp commented 8 months ago

@gunnartorfis

Do you see anything in Metro or Android studio logs? You can also enable verboseLogs

  analytics: {
    verboseLogs: true,
  },
gunnartorfis commented 8 months ago

Hey @descorp I just noticed that we hadn't declared "googlepay" in the paymentMethods array - I assumed it would be enough to declare it within the config object.

It looks like that fixes my issue 🙏 Thanks for the help.

gunnartorfis commented 8 months ago

@descorp is it possible to render just the standalone Google Pay button using this package? We're using the component integration and need to render and call start("googlepay") upon onPress on some Google Pay button.

descorp commented 8 months ago

Hey @gunnartorfis

Not yet. For now ApplePay and GooglePay are simply glorify "instant" payments. We will look into adding full scale "GPayButton" view after stable v2 release.

Not sure if there is any useful React Native plugins out there to render GPay button.. Fun fact: The GooglePay team was also not eager to take up the "Button" challenge.

gunnartorfis commented 8 months ago

Oh well, thanks a lot! I'll just render some SVG/PNG then 😄

gunnartorfis commented 8 months ago

I am getting an error when trying to pay with GooglePay though. Let me know if I should create a new issue or just keep talking here @descorp

The error is Invalid PayWithGoogle Token (validation: 5_202) I was getting that error on web when I hadn't configured gatewayMerchantId and merchantId but I have already configured that on the RN side.

We are taking a brief shortcut into the paymentMethods and are hard-coding it for the time being. We are proxying the Adyen API and not making requests directly from the app. The googlepay entry is however the same as the API returns it from Adyen.

// paymentMethods={..}
{
  type: "googlepay",
  name: "Google Pay",
  configuration: {
    merchantName: "Noona",
    merchantId: "12345678901234567890",
    gatewayMerchantId: "NoonaLabsEhfECOM",
  },
}
// config={...}
{
googlepay:
    Platform.OS === "android"
      ? {
          merchantAccount: "12345678901234567890",
          allowedCardNetworks: ["Visa", "Mastercard"],
          allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
          googlePayEnvironment: GooglePayEnvironment.Test (3)
        }
      : undefined,
}

Do you see anything wrong with this config? Or any other ideas?

descorp commented 8 months ago

Hey @gunnartorfis

The error is Invalid PayWithGoogle Token (validation: 5_202)

Here is 5_202 error code page.

I can only suggest to revisit GooglePay setup guideline. If still no luck - please reach out to Adyen Support.


As a side note:

1) you don't need platform check once channel is set correctly - /paymentMethod API response would not contain Google Pay / Apple Pay for iOS and Android respectively. 2) /paymentMethod API response usually contains everything you might need for a basic GooglePay payment, and in my experience - no extra configuration is necessary:

gunnartorfis commented 8 months ago

Thanks a lot 🙌

gunnartorfis commented 8 months ago

I solved it by removing the configuration entirely from the config object 🤔 now it is just coming from the paymentMethods response.