sumup / sumup-ecom-php-sdk

SumUp eCom PHP SDK
Other
41 stars 18 forks source link

Most transactions fails when using sdk or REST API v0.2 #39

Open multikitty opened 1 year ago

multikitty commented 1 year ago

I created checkout page using Payment Widget sdk like the following:

<div id="sumup-card">

<script src="https://gateway.sumup.com/gateway/ecom/card/v2/sdk.js"></script>
<script>
var sumupcard = SumUpCard.mount({
    checkoutId: checkoutId,
    showAmount: true,
    showFooter: true,
    locale: "de-DE",
    onResponse: function(type, body) {
        if (type=="success") {
            console.log(body);
        }
    },
});
</script>

When I click the submit button, the request is sent to https://api.sumup.com/v0.2/checkouts/:id image Transactions almost always fail. Most transactions fail. I wonder if v0.2 is the reason. So I tried to process checkouts via REST API v0.2 instead of v0.1. The result is same as sdk. But the transactions always succeed via v0.1. Who can let me know the url of sumup-card widget sdk file using v0.1 if it exist?

cristianoliveira commented 1 year ago

Hello there, @multikitty thanks for reporting.

The usage of v0.2 API may not be the issue with the failed payments. This version has been used since 2020 :)

Here is a working example of an app for reference: https://github.com/cristianoliveira/nextjs-sumup-payments-starter

And here is where the SDK is used: https://github.com/cristianoliveira/nextjs-sumup-payments-starter/blob/main/components/PaymentWidget.tsx#L18

multikitty commented 1 year ago

Thanks for your response.

        onResponse: function (type: string, body: { status: string }) {
          if (type === 'success' && body.status === 'PAID') {
            onSuccess({ message: 'Thanks! 🎉' });
          }

          if (type === 'success' && body.status === 'FAILED') {
            onError({
              message:
                'Something went wrong with the payment. Check your info and try again.',
            });
          }

          if (type === 'fail') {
            onError({
              message:
                'Something went wrong with our system. See console logs for details.',
            });
          }

          console.log('Type', type);
          console.log('Body', body);
        },

In my case, the response -> (type === 'success' && body.status === 'FAILED') (almost always) Payload information are always same, but sometimes body.status === 'PAID' and almost body.status === 'FAILED'. Could you tell me about this reason? Regards