# BNPL integration for Markets
One of the use cases of serviceX is BNPL Gateway.
This page is for Markets to integrate the BNPL Gateway.
If you have not set up a Market yet, please refer to Integration guide.
# Flow
After users have finished the BNPL transaction, you will receive a webhook event regarding the order status. You will just need to process the order status on your system.
Once you have finished setting up a Market, what you need to do is
- Create an order for BNPL
- Handle webhook events
# Create an order
Every BNPL transaction should be associated with an order. You need to generate a new order object on your backend. You will obtain order ID, so you can check the order status afterwards.
WARNING
Please ensure you keep Order ID in your system because it is necessary when the transaction is completed.
# Sandbox
[POST] https://sandbox-api.credify.dev/v1/bnpl-consumers/orders
# Production
[POST] https://api.credify.one/v1/bnpl-consumers/orders
Request header:
- "Authorization": YOUR_TEMPORARY_TOKEN
This is a sample JSON object that is to be sent in a request body.
{
"reference_id": "string",
"total_amount": {
"value": "120000",
"currency": "VND"
},
"order_lines": [
{
"name": "Soda",
"reference_id": "string",
"image_url": "string",
"product_url": "string",
"quantity": 12,
"unit_price": {
"value": "10000",
"currency": "VND"
},
"subtotal": {
"value": "120000",
"currency": "VND"
},
"measument_unit": "EACH"
}
],
"payment_recipient": {
"name": "string",
"number": "string",
"branch": "string",
"bank": "string"
}
}
reference_id: string
- ID that you want to use in your platform to look up the order
total_amount: object
value
is a string value that represents price.currency
isVND
/USD
/JPY
(currently, onlyVND
is available)
order_lines: array<object>
name
is item's namereference_id
is ID that you use in your platform to represent the item (optional)image_url
is image URL to the item (optional)product_url
is detail URL to the item (optional)quantity
is the number of itemsunit_price
is how much the item costs per unit (e.g. 1 item, 1 kg)subtotal
is how much the item costsmeasurement_unit
is how to measure the item
payment_recipient: object
name
is a recipient's namenumber
is a recipient's bank account numberbranch
is a recipient's bank branchbank
is a recipient's bank name
# Implementation with SDK
- Node.js
- Java
- .NET
const { Credify } = require("@credify/nodejs");
// You obtain these on the serviceX dashboard.
const signingPrivateKey = `-----BEGIN PRIVATE KEY-----
your private key...
-----END PRIVATE KEY-----`;
const apiKey = "YOUR_API_KEY";
const referenceId = req.body.reference_id;
const totalAmount = req.body.total_amount;
const orderLines = req.body.order_lines;
const paymentRecipient = req.body.payment_recipient;
// This is a sample. It should use `async`
const credify = await Credify.create(signingPrivateKey, apiKey, { mode: "sandbox" });
// This is a sample. It should use `async`
const data = await credify.bnpl.createOrder(
referenceId,
totalAmount,
orderLines,
paymentRecipient
);
# Handle webhook events
Once BNPL transaction is completed, you will receive a webhook event from Credify, so you can update the purchase status to completed
. This webhook event has Authorization header to prove it is coming from the Credify server. You can verify the access token with Token Introspection API or SDK.
This webhook event contains BNPL order ID that you are supposed to keep in your cache or storage.