Integration Flow
This integration flow is specific to E-Commerce payment flow using direct integration using Laybuy API.
Flow description
Create Order
- From the checkout process on the Merchant Site, the customer chooses to pay with Laybuy.
- The Merchant Server creates a new Laybuy order by making a request to the Laybuy API (
api/order/create
) and passing the order details.- If the request fails, an error is displayed on the Merchant Site.
- If the request is successful, the Laybuy API returns a payment token and the payment URL. The
token
can be stored by the Merchant Server, and the customer is redirected to the payment URL to begin the payment process.
Customer Onboarding and Payment authorization
- The customer proceeds through the Signup/Login process on the Laybuy by Klarna Payment site.
- If Klarna Signup/Login process is successful and approved then customer needs to authorize the payment by clicking 'Pay by Klarna', once done customer is redirected back to the return URL on Merchant site.
- If the payment authorization fails, an error is displayed on the Merchant Site.
- If the payment authorization is successful, the customer is redirected to the return URL on the Merchant Site. Merchant needs to complete/finalize the payment and order creation process.
Confirm Order
- The Merchant Server confirms the payment by making a request to the Laybuy API (
api/order/confirm
)- If the payment fails, an error is displayed on the Merchant Site.
- If the payment is successful, the customer’s payment card is charged. Laybuy API returns the Klarna OrderId. The Merchant Site shows the order confirmation page with Klarna order details.
Notifications and Session Expiry
- The customer receives a payment confirmation email or notification.
- If the customer takes too long to complete any step, the session is expired.
API End Points
Production
https://api.laybuy.com/
Sandbox
https://sandbox-api.laybuy.com/
Authentication
The Laybuy API uses Basic Authentication, where the username is your merchant ID and the password is your API key. These details are available from the Klarna Merchant dashboard.
curl 'https://api.laybuy.com/order/create' -u '{merchantId}:{apiKey}'
<? $authHeader = 'Authorization: Basic ' . base64_encode($merchantId . ':' . $apiKey); ?>
Requests
The Laybuy Merchant API is REST-based.
Accepts and returns only JSON data.
All communication must be completed securely using HTTPS