mkharibalaji / react-native-adyen-payment

React Native Adyen Payment
https://mkharibalaji.github.io/react-native-adyen-payment/
MIT License
35 stars 35 forks source link

Adyen Error on paymentMethod #38

Open mickadoua opened 3 years ago

mickadoua commented 3 years ago

hello I followed the documentation but i have an error send by the adyen backend with an android phone only

{"status":400,"errorCode":"702","message":"Field \u0027additionalData\u0027 expected to be a Structure but is an Array","errorType":"validation"}

I compare the Payload send from ios and android and found a difference

on android

{
    "additionalData": {},
    "allowedPaymentMethods": [],
    "amount": {
        "currency": "EUR",
        "value": 1500
    },
    "blockedPaymentMethods": [],
    "channel": "Android",
    "countryCode": "FR",
    "merchantAccount": "XXXXX",
    "shopperLocale": "fr-FR",
    "shopperReference": "XXXX"
}

on ios

{
    "countryCode": "FR",
    "shopperReference": "XXX",
    "merchantAccount": "XXXX",
    "amount": {
        "value": 1500,
        "currency": "EUR"
    },
    "shopperLocale": "fr_FR",
    "channel": "iOS"
}

the Logic seems different between the ios / android on Ios AdyenPayment.swift:58

        if(additionalData != nil){
            let allow3DS2 : Bool = (additionalData?["allow3DS2"] != nil) ? additionalData?["allow3DS2"] as! Bool : false
            let executeThreeD : Bool = (additionalData?["executeThreeD"] != nil) ? additionalData?["executeThreeD"] as! Bool : false
            PaymentsData.additionalData = ["allow3DS2":  allow3DS2,"executeThreeD":executeThreeD]
        }

on Android

                val addt_data_obj : JSONObject = if(detailsResponse.has("additionalData"))  detailsResponse.getJSONObject("additionalData") else JSONObject()

                message.put("resultCode", detailsResponse.getString("resultCode"))
                message.put("merchantReference", detailsResponse.getString("merchantReference"))
                message.put("pspReference", detailsResponse.getString("pspReference"))
                message.put("additionalData", addt_data_obj)

on android the additionalData is not inside a condition.

here my javascript

 paymentDetail = {
  amount: {
    value: amount, //In Multiples of hundred
    currency: 'EUR',
  },
  reference: 'FakeRef', 
  shopperReference: 'xxx',
  shopperEmail: 'xxx',
  channel: Platform.OS === 'ios' ? 'iOS' : 'Android',
  countryCode: app.country.toUpperCase(),
  shopperLocale: 'FR_fr',
  merchantAccount: environment.ADYEN_MERCHANT_ACCOUNT,
  returnUrl:
    Platform.OS === 'ios'
      ? `${environment.PACKAGE_NAME.ios}://`
      : `adyencheckout://${environment.PACKAGE_NAME.android}`,
  additionalData: {
    allow3DS2: true,
    executeThreeD: true,
  }, 

The additionalData variable is present here.

i have 2 questions.

1) Why additionalData is present on my configuration and not send to /paymentMethods on IOS devices

2) Why additionalData is empty on android ?

thanks