Desktop/Mobile Website Browser - Laybuy by Klarna
This guide is only applicable if you process Laybuy by Klarna transaction via the Airwallex Payment API API.
You can use your existing Laybuy integration to continue processing Laybuy by Klarna. Please refer to the Laybuy by Klarna migration guide if you wish to re-use your existing integration.
Accept Laybuy by Klarna payments on your website by redirecting the shopper to Laybuy/Klarna.
Step 1. Initialize a Payment Intent
Create a Payment Intent with the Create a Payment Intent API API.
You are strongly suggested to send any available order.shipping
to increase the success rate of Laybuy by Klarna payments.
POST /api/v1/pa/payment_intents/create
Step 2. Redirect to Laybuy by Klarna to complete payment
When a shopper selects to pay with Laybuy by Klarna on your desktop/mobile browser, call the Confirm a Payment Intent API API to get a redirect URL.
You are strongly suggested to send the shopper billing information payment_method.laybuy.billing
to increase the success rate of Laybuy by Klarna payments.
POST /api/v1/pa/payment_intents/{id}/confirm
By default, Laybuy by Klarna transactions require manual capture to reduce dispute from unfulfilled orders. If your business model fulfills the product/service at the time of payment such as intangible goods, you may opt to enable auto-capture by passing the optional auto_capture
parameter.
You will get a response similar to the following.
You should redirect the shopper to the Laybuy by Klarna page with the next_action.url
returned in the confirm Payment Intent response. Shoppers will be able to continue to complete the payment on that page.
Step 3. Query the payment result status
To get the payment result, we suggest you poll the status of the Payment Intent via the Retrieve a Payment Intent API API. You may start polling the Payment Intent status after the shopper is redirected back to your website, i.e., the return_url
passed when creating the Payment Intent.
GET /api/v1/pa/payment_intents/{id}
In addition, Airwallex will notify you of the payment result asynchronously via the webhooks. Please refer to the webhook documentation to set up your webhook accordingly. Although subscribing to webhook events is optional, it is recommended to subscribe to the payment_intent.requires_capture
webhook which indicates that the shopper has paid the order, and the payment_intent.succeeded
webhook which indicates that the payment intent is fulfilled.
For auto capture payments (the
payment_method_options.laybuy.auto_capture
is set totrue
), you will receive thepayment_intent.succeeded webhook
if you registered which indicates that the payment intent is fulfilled.For manual capture payments, you will receive
payment_intent.requires_capture
webhook if you registered, and this indicates the shopper has paid the order. you can refer to Step 4 below to capture this payment.
Step 4. Manual capture Laybuy by Klarna payment
After you ship your products to the shopper, you can call the Capture a PaymentIntent API API to capture the payments. Note that partial capture is supported. If you perform partial capture, the remaining amount will be returned to the shopper immediately.
You must capture Laybuy by Klarna payments within 28 days after authorization. You can do this through Webapp or API call. If an authorized payment is not captured within 28 days, the transaction itself will expire.
Please do not capture the payments before you fulfill your products as this may raise the likelihood of shopper dispute.
POST /api/v1/pa/payment_intents/{id}/capture
You will get a response similar to the following.
Step 5. Update shipping information (Optional)
After the payment has been authorized and you have fulfilled your products to the shopper, you can update the shipping information of your delivery via the Update a Payment Intent API API.
The following fields will be displayed in the shopper’s Laybuy/Klarna app:
- Shipping Company
- Tracking Number
- Tracking URL
To ensure that the shipping information appears in the shopper's Laybuy/Klarna app, one of the following conditions must be fulfilled:
Provide the shipping company and tracking number. The name of the shipping company should match one of the values listed in the
SHIPPING_COMPANY
column of the Klarna carrier partner list .Provide the tracking URL, where the shopper can access a web-based package tracking platform and directly view their shipping information.
If one Laybuy by Klarna transaction has multiple associated tracking number, you can call the API multiple times to append additional shipping information.
POST /api/v1/pa/payment_intents/{id}/update
You will get a response similar to the following: