wl-online-payments-direct / sdk-client-js

Other
3 stars 2 forks source link

Google pay in shop website checkout #8

Open martinwronski opened 1 month ago

martinwronski commented 1 month ago

Hi

Can you provide example how to add Google pay to shop website? We have tried to follow documentation but can not make it work. https://docs.direct.worldline-solutions.com/en/payment-methods-and-features/payment-methods/google-pay#owncheckoutpage Code we try to run:

<script src="https://myhummy.draftstudio.pl/js/addons/myhummy/wordline/onlinepayments-sdk-client-js.umd.js"></script>
<script>
      const sessionDetails = {  // from https://docs.direct.worldline-solutions.com/en/api-reference#tag/Sessions/operation/CreateSessionApi
          "clientSessionId": "d67b78d0a1cc48fe82513381d1c471f0",
          "customerId": "d6384bf5bf4643849a6c33846b44d2b6",
          "clientApiUrl": "https://payment.preprod.direct.ingenico.com",
          "assetUrl": "https://assets.test.cdn.v-psp.com/s2s/3bf0399c7ed78692aac3"
      };
      const session = new window.onlinepaymentssdk.Session(sessionDetails);
      let paymentDetails =
      {
         amountOfMoney: {
           amount: 123, // Total amount in the smallest denominator of the currency
           currencyCode: 'DKK' // ISO 4217 currency code
         },
         "totalAmount" : 123,
         "countryCode" : "DK",
         "locale" : "en_EN",
         "isRecurring" : false,
         "currency" : "DKK"
      };
      let paymentProductSpecificInputs = {
        googlePay: {
          merchantId: 'BCR2DN4TW7EMZRCR',
          merchantName: 'worldlineingenicoogone',
          gatewayMerchantId: 'TESTmyhummyDI'
        }
      };

    session
      .getPaymentProduct(320, paymentDetails, paymentProductSpecificInputs)
      .then((paymentProduct) => {
        console.log(paymentProduct);
        session.getPaymentProductRequest().setPaymentProduct(paymentProduct);
      })
      .catch((error) => {
        console.log('getPaymentProduct error');
        console.log(error);      // <-- Error: failed to retrieve Payment Product
      });
</script>

In console we get error: XHR GET https://payment.preprod.direct.ingenico.com/client/v1/1c7dbb6bdb834998900e15b991ef38da/products/320?countryCode=DK&isRecurring=false&amount=123&currencyCode=DKK&locale=en_EN&cacheBust=1716809858227 [HTTP/1.1 500 Internal Server Error 77ms]

{"errorId":"bf725add-35d8-4b46-80b3-b96e98da4782","errors":[{"errorCode":"20001101","category":"DIRECT_PLATFORM_ERROR","code":"9999","httpStatusCode":500,"id":"UNKNOWN_SERVER_ERROR","message":"UNKNOWN_SERVER_ERROR","retriable":false}]}

Regards Martin

worldline-direct-support-team commented 1 month ago

Hi Martin,

Thank you for reaching out and the provided information. We will look into this and get back to you soon once we know more.

Kind regards, Worldline support team

martinwronski commented 1 month ago

Hi any progress? Regards martin

worldline-direct-support-team commented 1 month ago

Hi Martin,

Thank you for your patience. We have done some investigation, but were not able to reproduce the issue.

We noticed some improvements that could be made to your code. Since your code was taken from the documentation, we will of course update our documentation accordingly and we apologize for the inconsistencies. Could you please make the following changes?

You might also want to verify in the Merchant Portal whether GooglePay is currently active for you. You can see this by logging in to the Merchant Portal and navigating to the 'Configuration' -> 'Payment Methods' tab. When using the new Merchant Portal, you will need to navigate to the 'Business' -> 'Payment Methods' tab.

For further support we kindly suggest submitting a request through our Contact Form on our Documentation portal. Our support team is readily available to assist you in resolving the issue and answer any questions you may have specifically related to the API.

We appreciate your feedback and apologise for any inconvenience this issue may have caused.

Kind regards, Worldline Support Team

martinwronski commented 1 month ago

Hi

worldline-direct-support-team commented 1 month ago

Hello Martin,

Thank you for this. We are taking this information into our investigation. With the updates in the Fiddle snippet that you shared, do you still experience the same 500 error when making a payment product request for Google Pay?

Kind regards, Worldline Support Team

martinwronski commented 1 month ago

yes in shop checkout there is still 500 Internal Server Error https://payment.preprod.direct.ingenico.com/client/v1/155ca41120954d2c9f808bd7330b534d/products/320?countryCode=DK&isRecurring=false&amount=123&currencyCode=DKK&locale=en_EN&cacheBust=1717762999423

I added fresh session data here so I guess it is easier to work on this JS fiddle https://jsfiddle.net/martinwronski/nk5rudbg/5/

still I am getting error in browser console Error: failed to retrieve Payment Product ui PublicKeyResponse.ts:9 getPaymentProduct C2SCommunicator.ts:308 promise callback*getPaymentProduct C2SCommunicator.ts:303 getPaymentProduct Session.ts:83 getPaymentProduct Session.ts:91

(index):125
martinwronski commented 1 month ago

Hi Our problem is still not resolved. Can you provide us a link to documentation so we could check things on our end? Which JS library should be use in out shop checkout(html code)?