Split Settlements Integration Steps for Custom Checkout
Follow the below steps to integrate Split Settlements with Pine Labs Online custom checkout APIs in your application.
📘 Note
- Ensure you store your Client ID and Secret in your Backend securely.
- Integrate our APIs on your backend system.
- We strictly recommend not to call our APIs from the frontend.
- Failure to adhere to the above guidelines may result in legal implications. In such cases, you will be held responsible for any damage or loss arising from non-compliance.
1. [Prerequisite] Generate Token
Integrate our Generate Token API in your backend servers to generate the access token. Use the token generated to authenticate Pine Labs Online APIs.
Below are the sample requests and response for the Generate Token API.
curl --location 'https://pluraluat.v2.pinepg.in/api/auth/v1/token' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--data '
{
"client_id": "a17ce30e-f88e-4f81-ada1-c3b4909ed232",
"client_secret": "fgwei7egyhuggwp39w8rh",
"grant_type": "client_credentials"
}
'
Refer to our Generate Token API documentation to learn more.
2. Create Order
To create an Order, use our Create Order API, for authentication use the generated access token in the headers of the API request.
Below are the sample requests and response for a Create Order API.
curl --location 'https://pluraluat.v2.pinepg.in/api/pay/v1/orders' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' \
--header 'Content-Type: application/json' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'accept: application/json' \
--data '
{
"merchant_order_reference":"1578609owyihy",
"order_amount":{
"value":50000,
"currency":"INR"
},
"pre_auth":false,
"allowed_payment_methods":[
"CARD",
"UPI",
"NETBANKING",
"POINTS",
"WALLET"
],
"purchase_details":{
"customer":{
"email_id":"kevin.bob@example.com",
"first_name":"Kevin",
"last_name":"Bob",
"customer_id":"192212",
"mobile_number":"9876543210",
"country_code": "91",
"billing_address": {
"address1": "10 Downing Street Westminster London",
"address2": "Oxford Street Westminster London",
"address3": "Baker Street Westminster London",
"pincode": "51524036",
"city": "Westminster",
"state": "Westminster",
"country": "London",,
"full_name": "Kevin Bob",
"adddress_type": "Home",
"address_category": "billing"
},
"shipping_address": {
"address1": "10 Downing Street Westminster London",
"address2": "Oxford Street Westminster London",
"address3": "Baker Street Westminster London",
"pincode": "51524036",
"city": "Westminster",
"state": "Westminster",
"country": "London",,
"full_name": "Kevin Bob",
"adddress_type": "Home",
"address_category": "shipping"
}
},
"merchant_metadata":{
"key1":"DD",
"key2":"XOF"
},
"split_info":{
"split_type":"AMOUNT",
"split_details":[
{
"split_merchant_id":"1324",
"merchant_settlement_reference":"kshjhfk",
"amount":{
"value":30000,
"currency":"INR"
},
"on_hold":true
},
{
"split_merchant_id":"1233",
"amount":{
"value":20000,
"currency":"INR"
},
"on_hold":false
}
]
}
}
}
'
Refer to our Create Order API documentation to learn more.
3. Create Payment
To create a payment, use our Create Payment API, use the order_id returned in the response of a Create Order API to link the payment against an order.
Below are the sample requests and sample response for Card Payment API.
curl --location 'https://pluraluat.v2.pinepg.in/api/pay/v1/orders/{order_id}/payments' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' \
--header 'Content-Type: application/json' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'accept: application/json' \
--data '
{
"payments": [
{
"merchant_payment_reference": "008cf04b-a770-4777-854e-b1e6c1230609",
"payment_method": "CARD",
"payment_amount": {
"value": 1100,
"currency": "INR"
},
"payment_option": {
"card_details": {
"name": "Anil Reddy",
"card_number": "4111111111111111",
"cvv": "272",
"expiry_month": "04",
"expiry_year": "2029",
"registered_mobile_number": "9876543210"
}
}
}
]
}
'
Refer to our Create Payment API documentation to learn more.
📘 Note:
- To manage settlements effectively, use the Release Settlement API to hold or release settlements for an order based on your requirements.
- You can only Release a Settlement when the order status is
PROCESSED.
4. Manage Settlement
4.1. Release Settlement
Use this API to initiate a full or partial settlement against an order.
❗️ Important:
- For partial settlements, specify the desired settlement amount in the
release_amountobject.- When settling partial payment, you must also initiate a refund request for the remaining amount, setting the status flag to
DO_NOT_RECOVERas only single partial settlement is allowed on a split.- To refund the partially/full settled split amount, initiate a refund request with the status flag set to
Blank.
Below is a sample requests and response for Release Settlement API.
curl --request PATCH \
--url https://pluraluat.v2.pinepg.in/api/pay/v1/orders/orderId/settlementId/settlementId/release \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' \
--header 'Content-Type: application/json' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'accept: application/json' \
--data '
{
"release_amount": {
"value": 20000,
"currency": "INR"
}
}
'
Refer to our Release Settlement API documentation to learn more.
4.2. Cancel Settlement
Use this API to cancel a settlement against an order.
Below is a sample requests and response for Cancel Settlement API.
curl --request PATCH \
--url https://pluraluat.v2.pinepg.in/api/pay/v1/orders/orderId/settlementId/settlementId/cancel \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' \
--header 'Content-Type: application/json' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'accept: application/json'
Refer to our Cancel Settlement API documentation to learn more.
📘 Note:
- To refund the full split amount, it is mandatory to call the Create Refund API. This request should include the details of the cancelled split and set the status parameter to
DO_NOT_RECOVER.
4.3. Create Refund
Use this API to initiate a refund against a split settlement order.
Below is a sample requests and response for Create Refund API.
curl --request POST \
--url https://pluraluat.v2.pinepg.in/api/pay/v1/refunds/{order_id} \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' \
--header 'Content-Type: application/json' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'accept: application/json' \
--data '
{
"merchant_order_reference": "692dc197-9264-45e6-bb74-95f2cc8608f8",
"order_amount": {
"value": "21000",
"currency": "INR"
},
"merchant_metadata": {
"key1": "DD",
"key2": "XOF"
},
"split_info": {
"split_type": "AMOUNT",
"split_details": [
{
"parent_order_split_settlement_id": "v1-250513063000-aa-UBAnaE-ss-g",
"split_merchant_id": 117320,
"merchant_settlement_reference": "692dc197-9264-45e6-bb74-95f2cc8608f9",
"amount": {
"value": "20000",
"currency": "INR"
},
"status": "DO_NOT_RECOVER"
}
]
}
}
'
Refer to our Create Refund API documentation to learn more.
5. Handle Payment
In create payment API response we return a challenge_url, use this challenge url to navigate your customers to the checkout page to accept payment.
📘 Note:
- On successful payment we send the webhook event
ORDER_AUTHORIZEDand the status of the payment is updated toauthorized.- You can capture or cancel an order only when the order status is
authorized.
5.1 Store Payment Details on Your Server
On a successful and failed payment, we return the following fields to the return url.
- We recommend you to store the payment details on your server.
- You must validate the authenticity of the payment details returned. You can authenticate by verifying the signature.
{
"order_id": "v1-4405071524-aa-qlAtAf",
"payment_status": "AUTHORIZED",
"signature": "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
}
5.2 Verify Payment Signature
Ensure you follow this as a mandatory step to verify the authenticity of the details returned to the checkout form for successful payments.
Follow the below steps to verify the signature.
- Create a signature on your server using the following parameters using the SHA256 algorithm.
order_id: Unique Identifier generated for an order request on Pine Labs Online database.payment_status: Payment status.error_code: Short code for the error returned.error_message: Corresponding error message for the code.secret_key: The Onboarding team has provided you with this information as part of the onboarding process.
Use the below sample code to construct HashMap signature using the SHA256 algorithm.
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class hash {
public static void main(String[] args) {
// Test the GenerateHash method
String input = "<string>";
String secretKey = "<secret_key>"; // Example key in hex
String hash = GenerateHash(input, secretKey);
System.out.println("Generated Hash: " + hash);
}
public static String GenerateHash(String input, String strSecretKey) {
String strHash = "";
try {
if (!isValidString(input) || !isValidString(strSecretKey)) {
return strHash;
}
byte[] convertedHashKey = new byte[strSecretKey.length() / 2];
for (int i = 0; i < strSecretKey.length() / 2; i++) {
convertedHashKey[i] =
(byte)Integer.parseInt(strSecretKey.substring(i * 2, (i*2)+2),16); //hexNumber radix
}
strHash = hmacDigest(input.toString(), convertedHashKey,
"HmacSHA256");
} catch (Exception ex) {
strHash = "";
}
return strHash.toUpperCase();
}
private static String hmacDigest(String msg, byte[] keyString, String algo) {
String digest = null;
try {
SecretKeySpec key = new SecretKeySpec(keyString, algo);
Mac mac = Mac.getInstance(algo);
mac.init(key);
byte[] bytes = mac.doFinal(msg.getBytes("UTF-8"));
StringBuffer hash = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
String hex = Integer.toHexString(0xFF & bytes[i]);
if (hex.length() == 1) {
hash.append('0');
}
hash.append(hex);
}
digest = hash.toString();
} catch (UnsupportedEncodingException e) {
// logger.error("Exception occured in hashing the pine payment gateway request"+e);
} catch (InvalidKeyException e) {
// logger.error("Exception occured in hashing the pine payment gateway request"+e);
} catch (NoSuchAlgorithmException e) {
// logger.error("Exception occured in hashing the pine payment gateway request"+e);
}
return digest;
}
public static boolean isValidString(String str){
if(str != null && !"".equals(str.trim())){
return true;
}
return false;
}
}
📘 Note:
To create a request string, format the key-value pairs of data returned to the return URL. The pairs are separated by
&and arranged in ascending order based on a lexicographical comparison of the keys.
Shown below is a example to create a request string.
"key1=value1&key2=value2", ["order_id=random_order_id&status=AUTHORIZED"]
- If the signature generated on your server matches the Pine Labs Online signature returned in the return URL, it confirms that the payment details are from Pine Labs Online.
- Capture the status returned on your database. Once the payment status is
AUTHORIZEDyou can either capture or cancel an order.
To Know Your Payment Status
To check your payment status, you can either rely on Webhook events or use our Get Orders APIs for real-time updates.
- Webhook Notification: We send Webhook notifications on the successful payment or any changes to the payments object. Refer to our Webhooks documentation to learn more.
- Get Orders API: Use our Get Orders API to know the real time status of the payment. Refer to our Manage Orders documentation to learn more.
Refunds
Pine Labs Online processes refund directly to the customer's original payment method to prevent chargebacks.
Refer to our Refunds documentation to learn more.
