JavaScript SDK unreliable redirect using "Sofortüberweisung" Klarna payment provider

greynoO
Contributor
Contributor

Hello,

we Integrated Paypal on a customer's webshop by implementing "Paypal Checkout" using the JavaScript SDK and REST API:

 

 

 

 

$(function () {
    paypal.Marks({
        fundingSource: "<%= SessionHandler.PayPalCheckout.PaymentOption %>"
    }).render('.value.payment');

    paypal.Buttons({
        fundingSource: "<%= SessionHandler.PayPalCheckout.PaymentOption %>",
        createOrder() {
            return fetch("CreateOrder.ashx", {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                },
            }).then((response) => {
                return new Promise((resolve) => response.json()
                    .then((json) => resolve({
                        status: response.status,
                        ok: response.ok,
                        json,
                    })));
            }).then((response) => {
                // do redirect based on status code
            }
            )
        },
        onApprove(data) {
            return fetch("CapturePayment.ashx", {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                    orderId: data.orderID
                }),
            }).then((response) => {
                // do redirect based on status code
            });

        },
        onCancel(data, actions) {
            // delete order
        },
        onError(err) {
            // handle error
        },
        onInit(data, actions) {
            // init
        },
    }).render(".confirm-order");
});

 

 

 

 

Unfortunately we sometimes encounter a problem using "Sofortüberweisung" (German payment provider by Klarna) where a customer does not get redirected back to the webshop (message says that you get redirected but nothing happens). If the customer closes the popup window manually the createOrder handler returns an error status code (or the onError handler gets triggered, not sure).

 

Sofortüberweisung/Klarna refunds the money later because the payment does not get captured (onApprove handler is never called).

It seems like that this is a problem independent from our implementation because the popup does not get closed automatically during the process. Or how could be debug this?

 

Thank you and greetings from Berlin.

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.