wl-online-payments-direct / sdk-java

Other
3 stars 1 forks source link

CreatePayment is giving error while using JavaScript and Java sdk #5

Closed kurianjerin closed 4 months ago

kurianjerin commented 4 months ago

Hello,

We are using the JavaScript SDK and Java SDK together in our solution. In the client we use JavaScript SDK(https://docs.direct.worldline-solutions.com/en/integration/how-to-integrate/client-sdks/javascript#encryptandtransferpaymentdata) and in our server application we use Java SDK(https://docs.direct.worldline-solutions.com/en/integration/how-to-integrate/server-sdks/java)

If you look at the JavaScript sdk page at number "6. finalise Transaction" it is mentioned that we need to send encrypted data to our server and call the "Create Payment" request. For this "Create Payment" request we used the Java sdk to implement since it is readily available with the JAVA sdk.

Here is how we created the paymentRequest. Please see the mocked code below.

//Java code. Please assume that we receive the encryptedCustomerInput to our server
CreatePaymentRequest createPaymentRequest = new CreatePaymentRequest();
createPaymentRequest.setEncryptedCustomerInput(...encryptedCustomerInput..);//Setting the encryptedCustomerInput passed from client application to the createPaymentRequest request
createPaymentRequest.setOrder(....order....); //Setting order information
MerchantClientInterface merchantClient = ...getMerchantClient()...//Here we initialized the worldline client and merchant interface mentioned in the JAVA sdk
CreatePaymentResponse createPaymentResponse = merchantClient.payments().createPayment(createPaymentRequest);

This call is returning the following exception

"the Online Payments platform returned an incorrect request error response; statusCode=400; responseBody='{"errorId":"b3b7153a-b948-45a3-81b9-a7d7dc3c366b","errors":[{"errorCode":"30001131","category":"DIRECT_PLATFORM_ERROR","code":"1099","httpStatusCode":400,"id":"INVALID_VALUE","message":"INVALID_VALUE","propertyName":"SpecificInput","retriable":false},{"errorCode":"50001111","category":"PAYMENT_PLATFORM_ERROR","code":"20000000","httpStatusCode":400,"id":"PARAMETER_NOT_FOUND_IN_REQUEST","message":"PARAMETER_NOT_FOUND_IN_REQUEST","propertyName":"cardPaymentMethodSpecificInput.card.cardholderName","retriable":false}]}'"

We were following the "Create Payment" api documentation here(https://docs.direct.worldline-solutions.com/en/api-reference#tag/Payments/operation/CreatePaymentApi)

Can you please help with this issue and the following queries?

  1. In our use-case if we use client and server sdks what are the required parameters to be passed to create a payment in the request body? If we pass "encryptedCustomerInput" do we need to pass the rest of the fields mentioned in the api?
  2. Does the Java SDK can be used in the server side for this use-case or should we implement http calls ourself for WorldLine apis?

Thanks

worldline-direct-support-team commented 4 months ago

Hello kurianjerin,

Thank you for questions! Please see hereby our answers:

  1. If you pass “encryptedCustomerInput”, you do not need to provide the fields that are already in there. Specifically, if you use the JavaScript SDK to set the payment product, and customer-entered payment details on the “PaymentRequest” before encryption, you will not need to provide a “card” object in the API. 
The error you receive indicates that “cardHolderName” is missing. You should verify that you request this field from your users, and set it before encryption. (See “5. Encrypt and transfer payment data” of the JavaScript SDK documentation for more details.)
  2. You can definitely use the Java SDK to make the final Create Payment call. There is no need to implement your own http call.

Hopefully this will help you to resolve your issue!

Kind regards, Worldline Support

kurianjerin commented 4 months ago

@worldline-direct-support-team @worldline-dev-team Thank you for the reply :) The error has gone after providing the "cardHolderName".

We are using the test data from here. https://docs.direct.worldline-solutions.com/en/integration/how-to-integrate/test-cases/index

We get the following error on calling the create payment. com.onlinepayments.DeclinedPaymentException: declined payment '4235923286_0' with status 'REJECTED'; statusCode=500; responseBody='{"errorId":"56f20960-8dfe-4c9b-aeec-39029fbea40c","errors":[{"errorCode":"60001057","category":"DIRECT_PLATFORM_ERROR","code":"9999","httpStatusCode":500,"id":"UNKNOWN_SERVER_ERROR","message":"UNKNOWN_SERVER_ERROR","retriable":false}],"paymentResult":{"creationOutput":{},"payment":{"paymentOutput":{"amountOfMoney":{"amount":1302,"currencyCode":"EUR"},"references":{"merchantReference":"fjgdfjgldfgdfklgdfg"},"acquiredAmount":{"amount":0,"currencyCode":"EUR"},"customer":{"device":{"ipAddressCountryCode":"99"}},"cardPaymentMethodSpecificOutput":{"paymentProductId":1,"card":{"cardNumber":"12313123123","expiryDate":"1125","bin":"13123123","countryCode":"IN"},"fraudResults":{"fraudServiceResult":"no-advice","cvvResult":"P"},"threeDSecureResults":{"eci":"7","xid":"sadasdasdasd"},"acquirerInformation":{"name":"ACQUIRER"}},"paymentMethod":"card"},"status":"REJECTED","statusOutput":{"errors":[{"errorCode":"60001057","category":"DIRECT_PLATFORM_ERROR","code":"9999","httpStatusCode":500,"id":"UNKNOWN_SERVER_ERROR","message":"UNKNOWN_SERVER_ERROR","retriable":false}],"isCancellable":false,"statusCategory":"UNSUCCESSFUL","statusCode":2,"isAuthorized":false,"isRefundable":false},"id":"4235923286_0"}}}'

From the above response we had a look at the following "payment" object. It is saying that status "REJECTED" with "statusCategory" as "UNSUCCESSFUL" and "statusCode" as "2". With these information if we look at the page https://docs.direct.worldline-solutions.com/en/integration/api-developer-guide/statuses#understandnumericstatuscodes it is found that the issue relies on "Authorization declined" . As per our reading from this page https://docs.direct.worldline-solutions.com/en/security-and-risk-management/3d-secure/ if the create-payment requires a 3D secure and SCA it will return an "merchantAction" in CreatePaymentResponse. But unfortunately we are getting exception instead of the response. Could you please help with this?

"status": "REJECTED",
      "statusOutput": {
        "errors": [
          {
            "errorCode": "60001057",
            "category": "DIRECT_PLATFORM_ERROR",
            "code": "9999",
            "httpStatusCode": 500,
            "id": "UNKNOWN_SERVER_ERROR",
            "message": "UNKNOWN_SERVER_ERROR",
            "retriable": false
          }
        ],
        "isCancellable": false,
        "statusCategory": "UNSUCCESSFUL",
        "statusCode": 2,
        "isAuthorized": false,
        "isRefundable": false
      }
worldline-direct-support-team commented 4 months ago

Hello kurianjerin,

Happy to hear that your initial issue was resolved!

As for the issue with rejected authorization we would kindly ask you to submit a request through our contact form on the Documentation Portal. Our support team there is readily available to assist you in resolving the issue and answer any questions you may have specifically related to rejected transactions.

Kind regards, Worldline Support Team

kurianjerin commented 4 months ago

@worldline-direct-support-team Thanks. I did that.