Test the complete payment lifecycle — create payments, query status, process refunds. See exact request/response payloads for every API endpoint.
sp_itOrld7Rm0SGjkqg_VSEXBtZXqi8T26-pMPfpUCxUQosec_lLao-1-yDLmV81YjExxgR00a8o7FgJ8-HLSJj9Od4hYSQUA102https://staging-sb-merchant-api.sabpaisa.inThe Secret Key is used to generate the request checksum (HMAC-SHA256) and to verify webhook signatures. Always compute the checksum server-side — never expose the secret key in client code.
/api/v2/payments1{
2 "merchantId": "SQUA102",
3 "merchantTxnId": "ORDER_20260625_091",
4 "amount": 50000,
5 "currency": "INR",
6 "returnUrl": "https://yoursite.com/payment/return",
7 "customerName": "Bhargav",
8 "customerEmail": "[email protected]",
9 "customerPhone": "9876543210",
10 "description": "Order #12345",
11 "timestamp": 1782373527,
12 "checksum": "computing…"
13}1curl -X POST 'https://staging-sb-merchant-api.sabpaisa.in/api/v2/payments' \
2 -H 'X-Api-Key: sp_itOrld7Rm0SGjkqg_VSEXBtZXqi8T26-pMPfpUCxUQo' \
3 -H 'Content-Type: application/json' \
4 -d '{
5 "merchantId": "SQUA102",
6 "merchantTxnId": "ORDER_20260625_091",
7 "amount": 50000,
8 "currency": "INR",
9 "returnUrl": "https://yoursite.com/payment/return",
10 "customerName": "Bhargav",
11 "customerEmail": "[email protected]",
12 "customerPhone": "9876543210",
13 "description": "Order #12345",
14 "timestamp": 1782373527,
15 "checksum": "computing…"
16}'Complete, runnable server-side code using the sandbox credentials — it generates the HMAC-SHA256 checksum and calls POST /api/v2/payments. Use the tabs to switch language.
1// SabPaisa PG 3.0 — Create Payment (Node.js 18+, no dependencies)
2const crypto = require('crypto');
3
4const API_KEY = 'sp_itOrld7Rm0SGjkqg_VSEXBtZXqi8T26-pMPfpUCxUQo';
5const SECRET_KEY = 'sec_lLao-1-yDLmV81YjExxgR00a8o7FgJ8-HLSJj9Od4hY';
6const MERCHANT_ID = 'SQUA102';
7const BASE_URL = 'https://staging-sb-merchant-api.sabpaisa.in';
8
9async function createPayment() {
10 const merchantTxnId = 'ORDER_' + Date.now();
11 const amount = 50000; // paise (50000 = Rs 500.00)
12 const currency = 'INR';
13 const timestamp = Math.floor(Date.now() / 1000);
14
15 // 1) Checksum = HMAC-SHA256(secret, merchantId|merchantTxnId|amount|currency|timestamp)
16 const message = MERCHANT_ID + '|' + merchantTxnId + '|' + amount + '|' + currency + '|' + timestamp;
17 const checksum = crypto.createHmac('sha256', SECRET_KEY).update(message).digest('hex');
18
19 // 2) POST the payment request
20 const res = await fetch(BASE_URL + '/api/v2/payments', {
21 method: 'POST',
22 headers: { 'X-Api-Key': API_KEY, 'Content-Type': 'application/json' },
23 body: JSON.stringify({
24 merchantId: MERCHANT_ID, merchantTxnId, amount, currency, timestamp, checksum,
25 customerName: 'Bhargav',
26 customerEmail: '[email protected]',
27 customerPhone: '9876543210',
28 returnUrl: 'https://yoursite.com/payment/return',
29 }),
30 });
31
32 const data = await res.json();
33 console.log('Redirect customer to:', data.checkoutUrl);
34 return data;
35}
36
37createPayment().catch(console.error);1# SabPaisa PG 3.0 — Create Payment (Python 3, pip install requests)
2import time, hmac, hashlib, requests
3
4API_KEY = 'sp_itOrld7Rm0SGjkqg_VSEXBtZXqi8T26-pMPfpUCxUQo'
5SECRET_KEY = 'sec_lLao-1-yDLmV81YjExxgR00a8o7FgJ8-HLSJj9Od4hY'
6MERCHANT_ID = 'SQUA102'
7BASE_URL = 'https://staging-sb-merchant-api.sabpaisa.in'
8
9def create_payment():
10 merchant_txn_id = f'ORDER_{int(time.time() * 1000)}'
11 amount = 50000 # paise (50000 = Rs 500.00)
12 currency = 'INR'
13 timestamp = int(time.time())
14
15 # 1) Checksum = HMAC-SHA256(secret, merchantId|merchantTxnId|amount|currency|timestamp)
16 message = f'{MERCHANT_ID}|{merchant_txn_id}|{amount}|{currency}|{timestamp}'
17 checksum = hmac.new(SECRET_KEY.encode(), message.encode(), hashlib.sha256).hexdigest()
18
19 # 2) POST the payment request
20 res = requests.post(
21 f'{BASE_URL}/api/v2/payments',
22 headers={'X-Api-Key': API_KEY, 'Content-Type': 'application/json'},
23 json={
24 'merchantId': MERCHANT_ID, 'merchantTxnId': merchant_txn_id,
25 'amount': amount, 'currency': currency,
26 'timestamp': timestamp, 'checksum': checksum,
27 'customerName': 'Bhargav',
28 'customerEmail': '[email protected]',
29 'customerPhone': '9876543210',
30 'returnUrl': 'https://yoursite.com/payment/return',
31 },
32 )
33 data = res.json()
34 print('Redirect customer to:', data['checkoutUrl'])
35 return data
36
37create_payment()1// SabPaisa PG 3.0 — Create Payment (Java 11+, java.net.http)
2import javax.crypto.Mac;
3import javax.crypto.spec.SecretKeySpec;
4import java.net.URI;
5import java.net.http.*;
6import java.nio.charset.StandardCharsets;
7
8public class CreatePayment {
9 static final String API_KEY = "sp_itOrld7Rm0SGjkqg_VSEXBtZXqi8T26-pMPfpUCxUQo";
10 static final String SECRET_KEY = "sec_lLao-1-yDLmV81YjExxgR00a8o7FgJ8-HLSJj9Od4hY";
11 static final String MERCHANT_ID = "SQUA102";
12 static final String BASE_URL = "https://staging-sb-merchant-api.sabpaisa.in";
13
14 static String hmacHex(String key, String msg) throws Exception {
15 Mac mac = Mac.getInstance("HmacSHA256");
16 mac.init(new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
17 byte[] h = mac.doFinal(msg.getBytes(StandardCharsets.UTF_8));
18 StringBuilder sb = new StringBuilder();
19 for (byte b : h) sb.append(String.format("%02x", b));
20 return sb.toString();
21 }
22
23 public static void main(String[] args) throws Exception {
24 String merchantTxnId = "ORDER_" + System.currentTimeMillis();
25 long amount = 50000; // paise (50000 = Rs 500.00)
26 String currency = "INR";
27 long timestamp = System.currentTimeMillis() / 1000;
28
29 // 1) Checksum = HMAC-SHA256(secret, merchantId|merchantTxnId|amount|currency|timestamp)
30 String message = MERCHANT_ID + "|" + merchantTxnId + "|" + amount + "|" + currency + "|" + timestamp;
31 String checksum = hmacHex(SECRET_KEY, message);
32
33 // 2) POST the payment request
34 String body = String.format(
35 "{\"merchantId\":\"%s\",\"merchantTxnId\":\"%s\",\"amount\":%d," +
36 "\"currency\":\"%s\",\"timestamp\":%d,\"checksum\":\"%s\"," +
37 "\"customerName\":\"Bhargav\",\"customerEmail\":\"[email protected]\"," +
38 "\"customerPhone\":\"9876543210\",\"returnUrl\":\"https://yoursite.com/payment/return\"}",
39 MERCHANT_ID, merchantTxnId, amount, currency, timestamp, checksum);
40
41 HttpResponse<String> res = HttpClient.newHttpClient().send(
42 HttpRequest.newBuilder(URI.create(BASE_URL + "/api/v2/payments"))
43 .header("X-Api-Key", API_KEY)
44 .header("Content-Type", "application/json")
45 .POST(HttpRequest.BodyPublishers.ofString(body)).build(),
46 HttpResponse.BodyHandlers.ofString());
47
48 System.out.println(res.body()); // contains checkoutUrl
49 }
50}1<?php
2// SabPaisa PG 3.0 — Create Payment (PHP 7+, curl)
3$API_KEY = 'sp_itOrld7Rm0SGjkqg_VSEXBtZXqi8T26-pMPfpUCxUQo';
4$SECRET_KEY = 'sec_lLao-1-yDLmV81YjExxgR00a8o7FgJ8-HLSJj9Od4hY';
5$MERCHANT_ID = 'SQUA102';
6$BASE_URL = 'https://staging-sb-merchant-api.sabpaisa.in';
7
8$merchantTxnId = 'ORDER_' . round(microtime(true) * 1000);
9$amount = 50000; // paise (50000 = Rs 500.00)
10$currency = 'INR';
11$timestamp = time();
12
13// 1) Checksum = HMAC-SHA256(secret, merchantId|merchantTxnId|amount|currency|timestamp)
14$message = "$MERCHANT_ID|$merchantTxnId|$amount|$currency|$timestamp";
15$checksum = hash_hmac('sha256', $message, $SECRET_KEY);
16
17// 2) POST the payment request
18$ch = curl_init("$BASE_URL/api/v2/payments");
19curl_setopt_array($ch, [
20 CURLOPT_POST => true,
21 CURLOPT_RETURNTRANSFER => true,
22 CURLOPT_HTTPHEADER => ['X-Api-Key: ' . $API_KEY, 'Content-Type: application/json'],
23 CURLOPT_POSTFIELDS => json_encode([
24 'merchantId' => $MERCHANT_ID,
25 'merchantTxnId' => $merchantTxnId,
26 'amount' => $amount,
27 'currency' => $currency,
28 'timestamp' => $timestamp,
29 'checksum' => $checksum,
30 'customerName' => 'Bhargav',
31 'customerEmail' => '[email protected]',
32 'customerPhone' => '9876543210',
33 'returnUrl' => 'https://yoursite.com/payment/return',
34 ]),
35]);
36$data = json_decode(curl_exec($ch), true);
37curl_close($ch);
38
39echo 'Redirect customer to: ' . $data['checkoutUrl'];Use these test credentials in the staging environment. No real money is charged.
4111 1111 1111 1111Visa5500 0000 0000 0004Mastercard4000 0000 0000 0002Visa5105 1051 0510 5100Mastercard123 | Expiry: Any future datesuccess@upiSuccessfailure@upiFailedtimeout@upiTimeout123456 (for test transactions)testuser | Password: testpass