JavaScript SDK unreliable redirect using "Sofortüberweisung" Klarna payment provider
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Paypal subscription Api in REST APIs
- Selected Shipping Method amount not updating to cart for card payment in SDKs
- ExpressCheckout to REST API - Is Partner Program Now Required to Host Simple 3rd Party Transactions? in REST APIs
- Are there any restrictions to charge using only html, vanilla javascript and php with rest api? in REST APIs
- Disable shipping address in Pay with Credit or Debit card button integration in SDKs