globalpayments / php-sdk

GNU General Public License v2.0
49 stars 66 forks source link

400 Error - Format of one or more Data Elements is Invalid #56

Closed philipbelcher closed 4 years ago

philipbelcher commented 4 years ago

Hi guys I'm trying to implement 3DSecure V2 and when I'm trying to execute the initiateAuthentication method I am getting an Error (Status Code: 400 - Format of one or more Data Elements is Invalid according to the Specification) but unfortunately there's no more detail about what the culprit is.

I'm following the docs here - https://developer.globalpay.com/api/3d-secure-two and I'm currently on version 1.3.3

  1. Are you able to advise on common incorrect formats for Data Elements? (I've already seen the issues around strange characters in customerEmail and cardholderName character length and have accounted for them)

  2. Do you receive this error if you're not supplying all the mandatory 3ds2 fields or is this solely about the formatting of one of them I've already supplied?

Here is my ThreeDSecure object before it gets executed in the initiateAuthentication method for reference: Thanks


   "accountAgeIndicator":null,
   "accountChangeDate":null,
   "accountCreateDate":null,
   "accountChangeIndicator":null,
   "addressMatchIndicator":null,
   "amount":30,
   "applicationId":null,
   "authenticationSource":"BROWSER",
   "authenticationRequestType":"PAYMENT_TRANSACTION",
   "billingAddress":{
      "type":null,
      "streetAddress1":"Address line 1",
      "streetAddress2":"Address line 2",
      "streetAddress3":"Address line 3",
      "city":"city",
      "province":null,
      "state":null,
      "postalCode":"POSTCODE",
      "country":"United Kingdom",
      "countryCode":826
   },
   "browserData":{
      "acceptHeader":"text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/avif,image\/webp,image\/apng,*\/*;q=0.8,application\/signed-exchange;v=b3;q=0.9",
      "colorDepth":"TWENTY_FOUR_BITS",
      "ipAddress":"192.168.128.1",
      "javaEnabled":true,
      "javaScriptEnabled":true,
      "language":"en",
      "screenHeight":"1080",
      "screenWidth":"1920",
      "challengWindowSize":"FULL_SCREEN",
      "timeZone":"0",
      "userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/86.0.4240.80 Safari\/537.36"
   },
   "currency":"GBP",
   "customerAccountId":null,
   "customerAuthenticationData":null,
   "customerAuthenticationMethod":null,
   "customerAuthenticationTimestamp":null,
   "customerEmail":"mytestemail@gmail.com",
   "deliveryEmail":null,
   "deliveryTimeframe":null,
   "encodedData":null,
   "ephemeralPublicKey":null,
   "giftCardCount":null,
   "giftCardCurrency":null,
   "giftCardAmount":null,
   "homeCountryCode":null,
   "homeNumber":null,
   "maxNumberOfInstallments":null,
   "maximumTimeout":null,
   "merchantData":null,
   "messageCategory":"PAYMENT_AUTHENTICATION",
   "merchantInitiatedRequestType":null,
   "messageVersion":null,
   "methodUrlCompletion":"YES",
   "mobileCountryCode":"44",
   "mobileNumber":"07777777777",
   "numberOfAddCardAttemptsInLast24Hours":null,
   "numberOfPurchasesInLastSixMonths":null,
   "numberOfTransactionsInLast24Hours":null,
   "numberOfTransactionsInLastYear":null,
   "orderCreateDate":"2020-10-19 11:57:05",
   "orderId":"GBCV4RV5-1603105083",
   "orderTransactionType":null,
   "passwordChangeDate":null,
   "passwordChangeIndicator":null,
   "paymentAccountCreateDate":null,
   "paymentAgeIndicator":null,
   "payerAuthenticationResponse":null,
   "paymentMethod":{
      "number":"4263970000005262",
      "expMonth":"03",
      "expYear":"2023",
      "cvn":"123",
      "cvnPresenceIndicator":4,
      "cardHolderName":"Test Card",
      "cardPresent":false,
      "readerPresent":false,
      "encryptionData":null,
      "paymentMethodType":1,
      "token":null,
      "mobileType":null,
      "threeDSecure":{
         "acsTransactionId":null,
         "acsEndVersion":null,
         "acsStartVersion":null,
         "algorithm":null,
         "authenticationSource":null,
         "authenticationType":null,
         "authenticationValue":null,
         "cardHolderResponseInfo":null,
         "cavv":null,
         "challengeMandated":null,
         "criticalityIndicator":null,
         "directoryServerTransactionId":null,
         "directoryServerEndVersion":null,
         "directoryServerStartVersion":null,
         "eci":null,
         "enrolled":null,
         "issuerAcsUrl":null,
         "messageCategory":null,
         "messageExtensionId":null,
         "messageExtensionName":null,
         "messageVersion":null,
         "payerAuthenticationRequest":null,
         "paymentDataSource":null,
         "paymentDataType":"3DSecure",
         "sdkInterface":null,
         "sdkUiType":null,
         "serverTransactionId":"a-real-server-transaction-id",
         "status":null,
         "statusReason":null,
         "xid":null
      },
      "cardType":"Visa",
      "isFleet":null
   },
   "preOrderAvailabilityDate":null,
   "preOrderIndicator":null,
   "previousSuspiciousActivity":null,
   "priorAuthenticationData":null,
   "priorAuthenticationMethod":null,
   "priorAuthenticationTransactionId":null,
   "priorAuthenticationTimestamp":null,
   "recurringAuthorizationExpiryDate":null,
   "recurringAuthorizationFrequency":null,
   "referenceNumber":null,
   "reorderIndicator":null,
   "sdkInterface":null,
   "sdkTransactionId":null,
   "sdkUiTypes":null,
   "shippingAddress":{
      "type":null,
      "streetAddress1":"Address",
      "streetAddress2":"Line 2",
      "streetAddress3":"Line 3",
      "city":"city",
      "province":null,
      "state":null,
      "postalCode":"POSTCODE",
      "country":"England",
      "countryCode":826
   },
   "shippingAddressCreateDate":null,
   "shippingAddressUsageIndicator":null,
   "shippingMethod":null,
   "shippingNameMatchesCardHolderName":null,
   "threeDSecure":null,
   "transactionType":268435456,
   "transactionModifier":0,
   "workCountryCode":null,
   "workNumber":null
}```
unfulvio commented 4 years ago

@philipbelcher I'm having a similar issue and haven't figured out how to pin down the exact data element that is invalid - could you kindly let me know how you did you sort your issue? much appreciated

philipbelcher commented 4 years ago

@philipbelcher I'm having a similar issue and haven't figured out how to pin down the exact data element that is invalid - could you kindly let me know how you did you sort your issue? much appreciated

Hi @unfulvio ! I ended up adding a log inside RestGateway.php to debug - it seemed that the detailed part of the error message (which included what exact data elements were invalid) wasn't getting surfaced, so logging the entire $parsed response revealed additional information. Hope this helps you!

unfulvio commented 4 years ago

oh wow thanks @philipbelcher that's a really good idea, I'm gonna try that I was wondering why the API didn't return a more detailed error in fact thank you so much

philipbelcher commented 4 years ago

Best of luck matey!

unfulvio commented 4 years ago

thank you so much! that did the trick! I wish it was less obscure