Postman Integration
REPLACE EXAMPLE CREDENTIALS
The code examples below use placeholder credentials. You MUST replace them with your actual values from the merchant portal:
PSTG6ELOB2YXKO4ZHRQ6NKTSBY→ Your actual API KeyMpkvVlXvYTZVPPJ0LReNA-g_yC7V7foe4UAj7tgWJSM→ Your actual API Secret1000→ Your actual Merchant ID (in the URL path)
Setup Steps
- Create a new request in Postman
- Set the request method and URL
- Configure the request body (for POST requests)
- Add a pre-request script to calculate the signature
Request Body Setup (Create Order)
Before adding the pre-request script, you need to configure the request body in Postman:
Step 1: Configure URL
Method: POSTURL: https://api.paystablecoin.global/api/v1/merchants/{merchantId}/orders
Replace {merchantId} with your actual Merchant ID (e.g., 1002)
Step 2: Configure Body
- In Postman, click on the Body tab
- Select raw format
- Select JSON from the dropdown menu
- Enter the following example:
{
"merchantOrderId": "TEST_ORDER_{{$timestamp}}",
"orderAmount": {
"value": "99.99",
"currency": "USD"
},
"expiresAt": "2025-12-31T23:59:59Z",
"returnUrl": "https://yoursite.com/payment/success",
"paymentMethod": {
"supportedCurrencies": ["USDT", "USDC"],
"preferredChain": "TRON"
}
}POSTMAN VARIABLES
You can use {{$timestamp}} in Postman to auto-generate unique order IDs. Postman will replace this with the current Unix timestamp.
REQUIRED FIELDS
The following fields are required for order creation:
merchantOrderId- Your unique order IDorderAmount- Amount object withvalueandcurrencyexpiresAt- Order expiration time (UTC, ISO 8601 format)returnUrl- Customer redirect URL after payment
Optional fields:
description- Order descriptioncallbackUrl- Server-to-server webhook URLcustomer- Customer informationitems- Line itemsmetadata- Custom metadata
See API Reference for all available fields.
Step 3: Add Pre-request Script
Now that your request body is configured, add the pre-request script below to automatically calculate the signature.
Pre-request Script for POST Requests (Create Order)
// Configuration
const apiKey = 'PSTG6ELOB2YXKO4ZHRQ6NKTSBY';
const secretKey = 'MpkvVlXvYTZVPPJ0LReNA-g_yC7V7foe4UAj7tgWJSM';
// Generate timestamp (milliseconds)
const timestamp = Date.now().toString();
// Get request details
const method = pm.request.method;
const url = pm.request.url.toString();
const urlObj = new URL(url);
const path = urlObj.pathname;
// Get request body and replace Postman variables
let body = pm.request.body.raw;
// Replace {{$timestamp}} with actual value BEFORE signing
body = body.replace(/\{\{\$timestamp\}\}/g, timestamp);
// Minify JSON (remove extra spaces)
body = JSON.stringify(JSON.parse(body));
// Update the request body
pm.request.body.raw = body;
// Calculate request body hash (SHA256)
const bodyHash = CryptoJS.SHA256(body).toString(CryptoJS.enc.Base64);
// Build signature string
const signatureParts = [timestamp, method, path, bodyHash];
const stringToSign = signatureParts.join('\n');
console.log('=== Signature Calculation ===');
console.log('Timestamp:', timestamp);
console.log('Method:', method);
console.log('Path:', path);
console.log('Body Hash:', bodyHash);
console.log('String to Sign:', stringToSign.replace(/\n/g, ' | '));
// Calculate HMAC-SHA256 signature
const signature = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(stringToSign, secretKey));
console.log('Signature:', signature);
// Set request headers
pm.request.headers.add({
key: 'Content-Type',
value: 'application/json'
});
pm.request.headers.add({
key: 'X-Api-Key',
value: apiKey
});
pm.request.headers.add({
key: 'X-Timestamp',
value: timestamp
});
pm.request.headers.add({
key: 'X-Signature',
value: signature
});Query Order Setup
For querying orders, the setup is simpler since GET requests don't have a request body.
Step 1: Configure URL
Method: GETURL: https://api.paystablecoin.global/api/v1/merchants/{merchantId}/orders/{merchantOrderId}
Replace:
{merchantId}with your Merchant ID (e.g.,1002){merchantOrderId}with the order ID you want to query (e.g.,TEST_ORDER_123)
Step 2: No Body Required
GET requests don't need a request body. Leave the Body tab empty or select none.
Step 3: Add Pre-request Script
Pre-request Script for GET Requests (Query Order)
// Configuration
const apiKey = 'PSTG6ELOB2YXKO4ZHRQ6NKTSBY';
const secretKey = 'MpkvVlXvYTZVPPJ0LReNA-g_yC7V7foe4UAj7tgWJSM';
// Generate timestamp (milliseconds)
const timestamp = Date.now().toString();
// Get request details
const method = pm.request.method;
const url = pm.request.url.toString();
const urlObj = new URL(url);
const path = urlObj.pathname;
// Build signature string (GET requests have no body)
const signatureParts = [timestamp, method, path];
const stringToSign = signatureParts.join('\n');
console.log('=== Signature Calculation ===');
console.log('Timestamp:', timestamp);
console.log('Method:', method);
console.log('Path:', path);
console.log('String to Sign:', stringToSign.replace(/\n/g, ' | '));
// Calculate HMAC-SHA256 signature
const signature = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(stringToSign, secretKey));
console.log('Signature:', signature);
// Set request headers
pm.request.headers.add({
key: 'X-Api-Key',
value: apiKey
});
pm.request.headers.add({
key: 'X-Timestamp',
value: timestamp
});
pm.request.headers.add({
key: 'X-Signature',
value: signature
});Complete Example: Create Your First Order
Follow these steps to create your first order using Postman:
1. Create New Request
- Open Postman
- Click New → HTTP Request
- Name it "Create Order"
2. Configure Request
- Method:
POST - URL:
https://api.paystablecoin.global/api/v1/merchants/1002/orders(Replace1002with your Merchant ID)
3. Add Request Body
- Go to Body tab
- Select raw and JSON
- Paste this example:
{
"merchantOrderId": "MY_ORDER_{{$timestamp}}",
"orderAmount": {
"value": "99.99",
"currency": "USD"
},
"expiresAt": "2025-12-31T23:59:59Z",
"returnUrl": "https://yoursite.com/payment/success",
"paymentMethod": {
"supportedCurrencies": ["USDT", "USDC"],
"preferredChain": "TRON"
}
}4. Add Pre-request Script
- Go to Pre-request Script tab
- Paste the POST pre-request script from above
- Update
apiKeyandsecretKeywith your actual credentials
5. Send Request
Click Send. You should receive a response like:
{
"code": "00000",
"message": "Success",
"data": {
"orderId": "20251202000100100000030000000139",
"merchantId": "1002",
"merchantOrderId": "MY_ORDER_1764662113279",
"status": "INIT",
"checkoutUrl": "https://checkout.paystablecoin.global/...",
"createdAt": "2025-12-02T15:55:14Z",
"expiresAt": "2025-12-31T23:59:59Z",
"orderAmount": {
"value": "99.99",
"currency": "USD"
}
}
}SUCCESS!
If you see "code": "00000" and "status": "INIT", your order was created successfully! You can use the checkoutUrl to complete the payment.
Troubleshooting
Common Errors
Error: "Invalid signature"
- Check that your
apiKeyandsecretKeyare correct - Ensure the JSON body has no extra spaces (Postman should handle this automatically)
- Verify your system time is synchronized
Error: "Invalid or expired timestamp"
- Your computer clock may be out of sync
- Timestamp must be within ±5 minutes of server time
Error: "Missing required field: expiresAt"
- Make sure your request body includes all required fields
- Check for typos in field names
Error: "Invalid parameter: merchantId"
- Verify you're using the correct Merchant ID in the URL
- Check that the Merchant ID matches your credentials
Related Documentation
- Signature Algorithm - Learn signature calculation principles
- Important Notes - Check JSON format requirements