{"info":{"_postman_id":"b9c347a0-29e7-4d0b-b794-17bbafefe9ea","name":"Payment APIs","description":"<html><head></head><body><p>Live payment APIs for creating, tracking, and cancelling payments</p>\n<ul>\n<li><p><code>x-id</code>: The merchant’s private <code>Secret key</code> issued via the management panel</p>\n</li>\n<li><p><code>x-signature</code>: HMAC signature for request verification. Generated using your merchant secret key and request payload.</p>\n</li>\n</ul>\n<hr>\n<h1 id=\"payment-env\">Payment Env</h1>\n<h6 id=\"the-payment-environment-is-determined-automatically-by-your-credentials\">The payment environment is determined automatically by your credentials.</h6>\n<ul>\n<li><p>If you use <code>v1/payment/rest/live</code> → requests are processed in <strong>live</strong> mode (Provide your live and secret)</p>\n</li>\n<li><p>If you use <code>v1/payment/rest/test</code> → requests are processed in <strong>Test</strong> mode (Provide your test private and secret)</p>\n</li>\n</ul>\n<h1 id=\"env-variables-for-postman\">Env variables (For postman)</h1>\n<p>Create a Postman <strong>environment</strong> (e.g., Rasedi Env) with the following <strong>minimal variables</strong>:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th><strong>Variable Name</strong></th>\n<th><strong>Description</strong></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>x_id</td>\n<td>Your merchant secret key from the Rasedi management panel</td>\n</tr>\n<tr>\n<td>private_key</td>\n<td>Your private key in PEM format</td>\n</tr>\n<tr>\n<td>x_signature</td>\n<td>Auto-generated by pre-request scripts</td>\n</tr>\n<tr>\n<td>reference_code</td>\n<td>Auto-generated after creating a payment; used in status/cancel requests</td>\n</tr>\n</tbody>\n</table>\n</div><blockquote>\n<p><em><strong>Note:</strong></em> <em>Users only need to set x_id and private_key. The scripts handle the rest automatically.</em> </p>\n</blockquote>\n<h1 id=\"if-you-dont-want-to-generate-the-x-signature-manually\">‌<strong>If you don’t want to generate the x-signature manually</strong></h1>\n<p>You can use a <strong>Postman pre-request script</strong> to handle it for you automatically.</p>\n<ol>\n<li><p><strong>Set environment variables</strong>:</p>\n<ul>\n<li><p>x_id → your merchant secret key from the management panel</p>\n</li>\n<li><p>private_key → your private key (PEM format)</p>\n</li>\n</ul>\n</li>\n<li><p><strong>Pre-request script</strong> will:</p>\n<ul>\n<li><p>Generate the x-signature for each request</p>\n</li>\n<li><p>Use the current request method and relative URL</p>\n</li>\n<li><p>Base64-encode the signature</p>\n</li>\n</ul>\n</li>\n<li><p><strong>Add headers to your request</strong>:</p>\n<ul>\n<li><p>x-id: Your secret key</p>\n</li>\n<li><p>x-signature: {{x_signature}} (generated automatically by the pre-request script)</p>\n</li>\n</ul>\n</li>\n</ol>\n<p>This way, every request is signed correctly without manual computation.</p>\n<h1 id=\"x-signature-generation-if-you-want-to-do-it-yourself\">🔐 x-signature Generation (If you want to do it yourself)</h1>\n<p>To authenticate requests, each API call <strong>must include a valid x-signature header</strong>.<br><strong>How x-signature is created</strong><br>The signature is generated by <strong>signing a raw string with your private key</strong>, then encoding the result in Base64.<br>*<em>Raw string format</em><em>*</em></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;METHOD&gt; || &lt;SECRET&gt; || &lt;RELATIVE_URL&gt;\n\n</code></pre><p>Example</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>POST || sk_live_xxx || /v1/payment/rest/live/init\n\n</code></pre><ul>\n<li><p>METHOD → HTTP method (GET, POST, …)</p>\n</li>\n<li><p>SECRET → your merchant secret key</p>\n</li>\n<li><p>RELATIVE_URL → path only (no domain, no query params)</p>\n</li>\n</ul>\n<h1 id=\"signing-algorithm\"><strong>Signing algorithm</strong></h1>\n<ul>\n<li><p>Algorithm: <strong>RSA (PKCS#1)</strong></p>\n</li>\n<li><p>Encoding: <strong>Base64</strong></p>\n</li>\n<li><p><strong>Key:</strong> Your <code>Secret key</code> that you got from the panel</p>\n</li>\n<li><p>Passphrase: <strong>Your secret key</strong></p>\n</li>\n</ul>\n<h4 id=\"reference-nodejs\"><strong>Reference (Node.js)</strong></h4>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">import { sign } from \"crypto\";\nfunction generateXSignature({\n  method,\n  secret,\n  relativeUrl,\n  privateKeyPem,\n}) {\n  if (!privateKeyPem) {\n    throw new Error(\"privateKeyPem is undefined\");\n  }\n  const rawSign = `${method} || ${secret} || ${relativeUrl}`;\n  const bufSign = Buffer.from(rawSign, \"utf-8\");\n  const signature = sign(null, bufSign, {\n    key: privateKeyPem,\n    passphrase: secret,\n  });\n  return signature.toString(\"base64\");\n}\n// 🔴 HARDCODE TEMPORARILY (for debugging)\nconst PRIVATE_KEY = `\n-----BEGIN ENCRYPTED PRIVATE KEY-----\nMIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQI...\n-----END ENCRYPTED PRIVATE KEY-----\n`;\nconst sig = generateXSignature({\n  method: \"POST\",\n  secret: \"sk_live_xxx\", // * Secret that you got from your panel \n  relativeUrl: \"/v1/payment/rest/live/create\",\n  privateKeyPem: PRIVATE_KEY,\n});\nconsole.log(sig);\n\n</code></pre>\n<h3 id=\"using-the-signature-in-api-requests\"><strong>Using the Signature in API Requests</strong></h3>\n<p>Use the generated signature as the value of the <strong>x-signature</strong> header when calling the APIs.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"Payment Env","slug":"payment-env"},{"content":"Env variables (For postman)","slug":"env-variables-for-postman"},{"content":"‌If you don’t want to generate the x-signature manually","slug":"if-you-dont-want-to-generate-the-x-signature-manually"},{"content":"🔐 x-signature Generation (If you want to do it yourself)","slug":"x-signature-generation-if-you-want-to-do-it-yourself"},{"content":"Signing algorithm","slug":"signing-algorithm"}],"owner":"52657755","collectionId":"b9c347a0-29e7-4d0b-b794-17bbafefe9ea","publishedId":"2sBXcGDKeT","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"0118d9"},"publishDate":"2026-02-25T07:15:12.000Z"},"item":[{"name":"Create Payment","event":[{"listen":"prerequest","script":{"id":"d4ae6566-6027-4835-b865-7b8a6ad208fb","exec":["// ----- INPUTS -----","const method = pm.request.method;","const secret = pm.environment.get(\"x_id\");","const url = pm.request.url;","const relativeUrl = \"/\" + url.path.join(\"/\");","","if (!secret) throw new Error(\"x_id (merchant secret) not set in environment variables\");","const PRIVATE_KEY_PEM = pm.environment.get(\"private_key\");","if (!PRIVATE_KEY_PEM) throw new Error(\"Private key not set in environment variables\");","","// ----- HELPERS -----","function pemToArrayBuffer(pem) {","    const b64 = pem","        .replace(/-----BEGIN PRIVATE KEY-----/, \"\")","        .replace(/-----END PRIVATE KEY-----/, \"\")","        .replace(/\\s+/g, \"\");","    const binary = atob(b64);","    const bytes = new Uint8Array(binary.length);","    for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);","    return bytes.buffer;","}","","// ----- SIGNING -----","(async () => {","    const rawSign = `${method} || ${secret} || ${relativeUrl}`;","    const data = new TextEncoder().encode(rawSign);","","    // Import Ed25519 private key","    const privateKey = await crypto.subtle.importKey(","        \"pkcs8\",","        pemToArrayBuffer(PRIVATE_KEY_PEM),","        { name: \"Ed25519\" },","        false,","        [\"sign\"]","    );","","    // Sign the data","    const signature = await crypto.subtle.sign(\"Ed25519\", privateKey, data);","","    // Convert to Base64","    const base64Signature = btoa(String.fromCharCode(...new Uint8Array(signature)));","","    // Store in environment variable","    pm.environment.set(\"x_signature\", base64Signature);","    console.log(\"X-Signature:\", base64Signature);","})();"],"type":"text/javascript","packages":{},"requests":{}}},{"listen":"test","script":{"id":"819d741d-1a37-4466-8569-d07af5743cbb","exec":["// Parse response JSON first","const response = pm.response.json();","","// Get reference code","const referenceCode = response.referenceCode;","","if (!referenceCode) {","    throw new Error(\"reference_code not found in response\");","}","","// Set environment variable","pm.environment.set(\"reference_code\", referenceCode);"],"type":"text/javascript","packages":{},"requests":{}}}],"id":"14debf60-9232-4d34-89dd-cdf199317062","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"x-signature","value":"{{x_signature}}","description":"<p>HMAC signature for request authentication (Auto generated using a script)</p>\n"},{"key":"x-id","value":"YOUR_API_KEY","description":"<p>API identifier for merchant authentication</p>\n"}],"body":{"mode":"raw","raw":"{\n    \"amount\": \"150000\",\n    \"gateways\": [\n        \"FAST_PAY\",\n        \"FIB\",\n        \"ZAIN\",\n        \"ASIA_PAY\",\n        \"NASS_WALLET\",\n        \"CREDIT_CARD\"\n    ],\n    \"title\": \"Order #1241\",\n    \"description\": \"Payment for premium subscription\",\n    \"collectFeeFromCustomer\": true,\n    \"collectCustomerEmail\": true,\n    \"collectCustomerPhoneNumber\": false,\n    \"redirectUrl\": \"https://merchant.com/payment/success\",\n    \"callbackUrl\": \"https://merchant.com/api/payment/callback\",\n    \"allowPromoCode\": true\n}","options":{"raw":{"language":"json"}}},"url":"https://api.rasedi.com/v1/payment/rest/live/create","description":"<h1 id=\"create-payment-api\">Create Payment API</h1>\n<h2 id=\"overview\">Overview</h2>\n<p>This endpoint creates a new payment request in the Rasedi payment system. It generates a payment link that can be shared with customers to collect payments through various payment gateways. The API supports multiple payment methods and provides flexible configuration options for fee collection, customer data collection, and payment flow customization.</p>\n<hr />\n<h2 id=\"authentication\">Authentication</h2>\n<p>This API uses a custom authentication mechanism with two required headers:</p>\n<h3 id=\"headers\">Headers</h3>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Header</th>\n<th>Type</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>x-signature</code></td>\n<td>string</td>\n<td><strong>Required.</strong> HMAC signature for request verification. Generated using your merchant secret key and request payload.</td>\n</tr>\n<tr>\n<td><code>x-id</code></td>\n<td>string</td>\n<td><strong>Required. Your unique Secret key that you got from your panel</strong></td>\n</tr>\n<tr>\n<td><code>Content-Type</code></td>\n<td>string</td>\n<td><strong>Required.</strong> Must be <code>application/json</code></td>\n</tr>\n</tbody>\n</table>\n</div><h3 id=\"request-body-json\">Request Body (JSON)</h3>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Type</th>\n<th>Required</th>\n<th>Description</th>\n<th>Example</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>amount</code></td>\n<td>string</td>\n<td><strong>Yes</strong></td>\n<td>Payment amount</td>\n<td><code>\"150000\"</code></td>\n</tr>\n<tr>\n<td><code>gateways</code></td>\n<td>array</td>\n<td><strong>Yes</strong></td>\n<td>Array of payment gateway codes to enable for this payment. At least one gateway must be specified.</td>\n<td><code>[\"FAST_PAY\", \"FIB\",\"ZAIN\",\"NASS_WALLET\",\"ASIA_PAY\",\"CREDIT_CARD\"]</code></td>\n</tr>\n<tr>\n<td><code>title</code></td>\n<td>string</td>\n<td><strong>Yes</strong></td>\n<td>Short title for the payment. Displayed to the customer on the payment page. Max 100 characters.</td>\n<td><code>\"Order #1241\"</code></td>\n</tr>\n<tr>\n<td><code>description</code></td>\n<td>string</td>\n<td><strong>Yes</strong></td>\n<td>Detailed description of the payment. Helps customers understand what they're paying for. Max 500 characters.</td>\n<td><code>\"Payment for premium subscription\"</code></td>\n</tr>\n<tr>\n<td><code>collectFeeFromCustomer</code></td>\n<td>boolean</td>\n<td><strong>Yes</strong></td>\n<td>If <code>true</code>, payment gateway fees are added to the customer's total. If <code>false</code>, fees are deducted from the merchant's received amount.</td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td><code>collectCustomerEmail</code></td>\n<td>boolean</td>\n<td><strong>Yes</strong></td>\n<td>If <code>true</code>, customer must provide their email address during payment.</td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td><code>collectCustomerPhoneNumber</code></td>\n<td>boolean</td>\n<td><strong>Yes</strong></td>\n<td>If <code>true</code>, customer must provide their phone number during payment.</td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td><code>redirectUrl</code></td>\n<td>string</td>\n<td><strong>Yes</strong></td>\n<td>URL where customers are redirected after successful payment. Must be a valid HTTPS URL.</td>\n<td><code>\"https://merchant.com/payment/success\"</code></td>\n</tr>\n<tr>\n<td><code>callbackUrl</code></td>\n<td>string</td>\n<td><strong>Yes</strong></td>\n<td>Webhook URL where payment status updates are sent. Must be a valid HTTPS URL that can receive POST requests.</td>\n<td><code>\"https://merchant.com/api/payment/callback\"</code></td>\n</tr>\n<tr>\n<td><code>allowPromoCode</code></td>\n<td>boolean</td>\n<td><strong>Yes</strong></td>\n<td>If <code>true</code>, customers can apply promotional discount codes during checkout.</td>\n<td><code>true</code></td>\n</tr>\n</tbody>\n</table>\n</div><h3 id=\"available-payment-gateways\">Available Payment Gateways</h3>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Gateway Code</th>\n<th>Description</th>\n<th>Currency</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>FAST_PAY</code></td>\n<td>FastPay digital wallet</td>\n<td>IQD</td>\n</tr>\n<tr>\n<td><code>FIB</code></td>\n<td>First Iraqi Bank</td>\n<td>IQD</td>\n</tr>\n<tr>\n<td><code>ZAIN</code></td>\n<td>Zain Cash mobile wallet</td>\n<td>IQD</td>\n</tr>\n<tr>\n<td><code>ASIA_PAY</code></td>\n<td>Asia Hawala payment gateway</td>\n<td>IQD</td>\n</tr>\n<tr>\n<td><code>NASS_WALLET</code></td>\n<td>Nass digital wallet</td>\n<td>IQD</td>\n</tr>\n<tr>\n<td><code>CREDIT_CARD</code></td>\n<td>International credit/debit cards</td>\n<td>IQD</td>\n</tr>\n</tbody>\n</table>\n</div><hr />\n<h2 id=\"response-structure\">Response Structure</h2>\n<h3 id=\"success-response-200-ok\">Success Response (200 OK)</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"referenceCode\": \"7676c702-a2a7-4996-baf3-09a8d012ed09\",\n    \"amount\": \"150000\",\n    \"paidVia\": null,\n    \"paidAt\": null,\n    \"redirectUrl\": \"https://pay.pallawan.com/pay/live/7676c702-a2a7-4996-baf3-09a8d012ed09\",\n    \"status\": \"PENDING\",\n    \"payoutAmount\": null\n}\n\n</code></pre>\n<h3 id=\"response-fields\">Response Fields</h3>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Type</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>referenceCode</code></td>\n<td>string</td>\n<td>Human-readable reference code for tracking</td>\n</tr>\n<tr>\n<td><code>amount</code></td>\n<td>string</td>\n<td>Payment amount</td>\n</tr>\n<tr>\n<td><code>paidAt</code></td>\n<td>Date</td>\n<td>null</td>\n</tr>\n<tr>\n<td><code>redirectUrl</code></td>\n<td>string</td>\n<td>The payment url</td>\n</tr>\n</tbody>\n</table>\n</div><hr />\n<h2 id=\"error-handling\">Error Handling</h2>\n<h3 id=\"common-error-codes\">Common Error Codes</h3>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Status Code</th>\n<th>Error Code</th>\n<th>Description</th>\n<th>Solution</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>400</code></td>\n<td><code>INVALID_AMOUNT</code></td>\n<td>Amount is invalid or below minimum</td>\n<td>Ensure amount is a positive number in smallest currency unit</td>\n</tr>\n<tr>\n<td><code>400</code></td>\n<td><code>INVALID_GATEWAY</code></td>\n<td>One or more gateway codes are invalid</td>\n<td>Use only supported gateway codes from the list above</td>\n</tr>\n<tr>\n<td><code>400</code></td>\n<td><code>MISSING_REQUIRED_FIELD</code></td>\n<td>Required field is missing from request</td>\n<td>Check all required fields are included</td>\n</tr>\n<tr>\n<td><code>401</code></td>\n<td><code>INVALID_SIGNATURE</code></td>\n<td>x-signature verification failed</td>\n<td>Regenerate signature using correct secret key and request body</td>\n</tr>\n<tr>\n<td><code>401</code></td>\n<td><code>INVALID_CREDENTIALS</code></td>\n<td>x-id or API key is invalid</td>\n<td>Verify your merchant credentials</td>\n</tr>\n<tr>\n<td><code>403</code></td>\n<td><code>GATEWAY_NOT_ENABLED</code></td>\n<td>Requested gateway is not enabled for your account</td>\n<td>Contact support to enable the gateway</td>\n</tr>\n<tr>\n<td><code>403</code></td>\n<td><code>INSUFFICIENT_PERMISSIONS</code></td>\n<td>API key lacks required permissions</td>\n<td>Use an API key with payment creation permissions</td>\n</tr>\n<tr>\n<td><code>422</code></td>\n<td><code>INVALID_URL</code></td>\n<td>redirectUrl or callbackUrl is malformed</td>\n<td>Ensure URLs are valid HTTPS endpoints</td>\n</tr>\n<tr>\n<td><code>429</code></td>\n<td><code>RATE_LIMIT_EXCEEDED</code></td>\n<td>Too many requests in short period</td>\n<td>Implement exponential backoff and retry logic</td>\n</tr>\n<tr>\n<td><code>500</code></td>\n<td><code>INTERNAL_ERROR</code></td>\n<td>Server error occurred</td>\n<td>Retry the request after a few seconds</td>\n</tr>\n</tbody>\n</table>\n</div><h3 id=\"error-response-format\">Error Response Format</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"statusCode\":400,\n    \"messages\":[\"amount must be a valid price.\"]\n}\n\n</code></pre>\n<hr />\n<h2 id=\"usage-notes\">Usage Notes</h2>\n<h3 id=\"important-considerations\">Important Considerations</h3>\n<ol>\n<li><p><strong>Amount Format</strong>: Always send amounts in the smallest currency unit. For IQD (Iraqi Dinar), multiply the amount by 100. Example: 1,500 IQD = \"150000\"</p>\n</li>\n<li><p><strong>Signature Security</strong>: Never expose your merchant secret key in client-side code. Generate signatures on your backend server.</p>\n</li>\n<li><p><strong>Callback URL</strong>: Your callback endpoint must:</p>\n<ul>\n<li><p>Accept POST requests with JSON payload</p>\n</li>\n<li><p>Respond with 200 OK status within 5 seconds</p>\n</li>\n<li><p>Verify the callback signature to ensure authenticity</p>\n</li>\n<li><p>Be publicly accessible (not localhost)</p>\n</li>\n</ul>\n</li>\n<li><p><strong>Payment Link Expiration</strong>: Payment links expire after 24 hours by default. Expired links cannot be used for payment.</p>\n</li>\n<li><p><strong>Gateway Availability</strong>: Gateway availability may vary by region and time. Always handle cases where a gateway might be temporarily unavailable.</p>\n</li>\n<li><p><strong>Fee Collection</strong>: When <code>collectFeeFromCustomer</code> is <code>true</code>, the customer sees the total amount including fees. When <code>false</code>, you receive the amount minus gateway fees.</p>\n</li>\n<li><p><strong>Idempotency</strong>: To prevent duplicate payments, implement idempotency on your side by tracking payment creation requests.</p>\n</li>\n<li><p><strong>Testing</strong>: Use the test environment with test credentials before going live. Test gateway codes may differ from production.</p>\n</li>\n</ol>\n<h3 id=\"best-practices\">Best Practices</h3>\n<ul>\n<li><p><strong>Validate Input</strong>: Validate all input data before sending to the API</p>\n</li>\n<li><p><strong>Handle Errors Gracefully</strong>: Implement proper error handling and user-friendly error messages</p>\n</li>\n<li><p><strong>Log Requests</strong>: Log all API requests and responses for debugging and audit purposes</p>\n</li>\n<li><p><strong>Monitor Callbacks</strong>: Set up monitoring for your callback endpoint to ensure you receive payment updates</p>\n</li>\n<li><p><strong>Secure Storage</strong>: Store payment IDs and reference codes securely in your database</p>\n</li>\n<li><p><strong>Customer Communication</strong>: Send payment links via secure channels (email, SMS, in-app notification)</p>\n</li>\n</ul>\n<hr />\n<h2 id=\"example-request\">Example Request</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-bash\">curl -X POST https://api.rasedi.com/v1/payment/rest/live/create \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-signature: a1b2c3d4e5f6...\" \\\n  -H \"x-id: merchant_12345\" \\\n  -d '{\n    \"amount\": \"150000\",\n    \"gateways\": [\"FAST_PAY\", \"FIB\"],\n    \"title\": \"Order #1241\",\n    \"description\": \"Payment for premium subscription\",\n    \"collectFeeFromCustomer\": true,\n    \"collectCustomerEmail\": true,\n    \"collectCustomerPhoneNumber\": false,\n    \"redirectUrl\": \"https://merchant.com/payment/success\",\n    \"callbackUrl\": \"https://merchant.com/api/payment/callback\",\n    \"allowPromoCode\": true\n  }'\n\n</code></pre>\n<hr />\n<h1 id=\"webhook-callback-structure\">Webhook Callback Structure</h1>\n<p>When payment status changes, a POST request is sent to your <code>callbackUrl</code>:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"referenceCode\": \"ref-292929\",\n    \"status\": \"PAID\",\n    \"payoutAmount\": \"15000\",\n}\n\n</code></pre>\n<p>Statuses will be:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-typescript\">export enum EXTERNAL_PAYMENT_STATUS {\n  PENDING = \"PENDING\",\n  PAID = \"PAID\",\n  CANCELED = \"CANCELED\",\n  FAILED = \"FAILED\",\n  TIMED_OUT = \"TIMED_OUT\",\n}\n\n</code></pre>\n","urlObject":{"protocol":"https","path":["v1","payment","rest","live","create"],"host":["api","rasedi","com"],"query":[],"variable":[]}},"response":[{"id":"11e4b3f6-e01f-4a19-8d7c-30a9fd54edfc","name":"Success - Payment Created","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"x-signature","value":"uzunsVZ5Xbn0PGkoqzudTRmXrBwb8guvEcbjkRm03IDbZdn3DjAX3Y7z0dxe1a/7zak9XSSLwNMyqKSu0H6WBg==","description":"HMAC signature for request authentication"},{"key":"x-id","value":"live_laisWit7zi3zBLMPQM0dg-BFrZBpOdPUanjVy0AvKGK3lwLfT_aDpFOyfGZJ70_4pl1FBk_YC_DVVG1mLtI5CYAQ","description":"API identifier for merchant authentication"}],"body":{"mode":"raw","raw":"{\n  \"amount\": \"150000\",\n  \"gateways\": [\"FAST_PAY\"],\n  \"title\": \"Order #1241\",\n  \"description\": \"Payment for premium subscription\",\n  \"collectFeeFromCustomer\": true,\n  \"collectCustomerEmail\": true,\n  \"collectCustomerPhoneNumber\": false,\n  \"redirectUrl\": \"https://merchant.com/payment/success\",\n  \"callbackUrl\": \"https://merchant.com/api/payment/callback\",\n  \"allowPromoCode\": true\n}","options":{"raw":{"language":"json"}}},"url":"{{payment_base_url}}/v1/payment/rest/live/create"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json","description":"","enabled":true},{"key":"x-signature","value":"uzunsVZ5Xbn0PGkoqzudTRmXrBwb8guvEcbjkRm03IDbZdn3DjAX3Y7z0dxe1a/7zak9XSSLwNMyqKSu0H6WBg==","description":"HMAC signature for request authentication","enabled":true},{"key":"x-id","value":"live_laisWit7zi3zBLMPQM0dg-BFrZBpOdPUanjVy0AvKGK3lwLfT_aDpFOyfGZJ70_4pl1FBk_YC_DVVG1mLtI5CYAQ","description":"API identifier for merchant authentication","enabled":true}],"cookie":[],"responseTime":null,"body":"{\"referenceCode\":\"563feb52-8cb3-415a-8ae3-148712938fdb\",\"amount\":\"150000\",\"paidVia\":null,\"paidAt\":null,\"redirectUrl\":\"https://pay.pallawan.com/pay/live/563feb52-8cb3-415a-8ae3-148712938fdb\",\"status\":\"PENDING\",\"payoutAmount\":null}"},{"id":"c5b5082c-25b8-4ab9-a4db-a3a49c32cb12","name":"Error - Bad Request (Validation Errors)","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"x-signature","value":"uzunsVZ5Xbn0PGkoqzudTRmXrBwb8guvEcbjkRm03IDbZdn3DjAX3Y7z0dxe1a/7zak9XSSLwNMyqKSu0H6WBg==","description":"HMAC signature for request authentication"},{"key":"x-id","value":"live_laisWit7zi3zBLMPQM0dg-BFrZBpOdPUanjVy0AvKGK3lwLfT_aDpFOyfGZJ70_4pl1FBk_YC_DVVG1mLtI5CYAQ","description":"API identifier for merchant authentication"}],"body":{"mode":"raw","raw":"{}","options":{"raw":{"language":"json"}}},"url":"{{payment_base_url}}v1/payment/rest/live/create"},"status":"Bad Request","code":400,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json","description":"","enabled":true},{"key":"x-signature","value":"uzunsVZ5Xbn0PGkoqzudTRmXrBwb8guvEcbjkRm03IDbZdn3DjAX3Y7z0dxe1a/7zak9XSSLwNMyqKSu0H6WBg==","description":"HMAC signature for request authentication","enabled":true},{"key":"x-id","value":"live_laisWit7zi3zBLMPQM0dg-BFrZBpOdPUanjVy0AvKGK3lwLfT_aDpFOyfGZJ70_4pl1FBk_YC_DVVG1mLtI5CYAQ","description":"API identifier for merchant authentication","enabled":true}],"cookie":[],"responseTime":null,"body":"{\"statusCode\":400,\"messages\":[\"amount must be a valid price.\",\"gateways must be a valid enum, FIB,ZAIN,ASIA_PAY,FAST_PAY,NASS_WALLET,CREDIT_CARD \",\"title must be shorter than or equal to 63 characters\",\"title must be a string, validator\",\"description must be shorter than or equal to 255 characters\",\"description must be a string, validator\",\"collectFeeFromCustomer must be a boolean\",\"collectCustomerEmail must be a boolean\",\"collectCustomerPhoneNumber must be a boolean\",\"redirectUrl must be a URL\",\"callbackUrl must be a URL\"]}"}],"_postman_id":"14debf60-9232-4d34-89dd-cdf199317062"},{"name":"Get Payment Status","event":[{"listen":"prerequest","script":{"exec":["const method = pm.request.method;","const secret = pm.environment.get(\"x_id\");","const url = pm.request.url;","","if (!secret) throw new Error(\"x_id not set\");","const PRIVATE_KEY_PEM = pm.environment.get(\"private_key\");","if (!PRIVATE_KEY_PEM) throw new Error(\"private_key not set\");","","// Build relative URL","let relativeUrl = \"/\" + url.path.join(\"/\");","// Replace any {{env}} variables","relativeUrl = relativeUrl.replace(/\\{\\{(.+?)\\}\\}/g, (_, varName) => {","    const val = pm.environment.get(varName);","    if (!val) throw new Error(`Environment variable ${varName} not found`);","    return val;","});","","","","// ----- HELPERS -----","function pemToArrayBuffer(pem) {","    const b64 = pem","        .replace(/-----BEGIN PRIVATE KEY-----/, \"\")","        .replace(/-----END PRIVATE KEY-----/, \"\")","        .replace(/\\s+/g, \"\");","    const binary = atob(b64);","    const bytes = new Uint8Array(binary.length);","    for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);","    return bytes.buffer;","}","","// ----- SIGNING -----","(async () => {","    const rawSign = `${method} || ${secret} || ${relativeUrl}`;","    console.log(rawSign)","    const data = new TextEncoder().encode(rawSign);","","    // Import Ed25519 private key","    const privateKey = await crypto.subtle.importKey(","        \"pkcs8\",","        pemToArrayBuffer(PRIVATE_KEY_PEM),","        { name: \"Ed25519\" },","        false,","        [\"sign\"]","    );","","    // Sign the data","    const signature = await crypto.subtle.sign(\"Ed25519\", privateKey, data);","","    // Convert to Base64","    const base64Signature = btoa(String.fromCharCode(...new Uint8Array(signature)));","","    // Store in environment variable","    pm.environment.set(\"x_signature\", base64Signature);","    console.log(\"X-Signature:\", base64Signature);","})();"],"type":"text/javascript","packages":{},"requests":{},"id":"5348cd8c-93a6-4863-9f77-357d3fb0a166"}}],"id":"35a9186d-f545-43fd-89fb-a4a96c2aebec","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"},{"key":"x-signature","value":"{{x_signature}}"},{"key":"x-id","value":"YOUR_API_KEY"}],"url":"https://api.rasedi.com/v1/payment/rest/live/status/{{reference_code}}","description":"<h1 id=\"get-payment-status\">Get Payment Status</h1>\n<h2 id=\"overview\">Overview</h2>\n<p>This endpoint retrieves the current status of a payment transaction using a unique reference code. It allows merchants to track and verify payment states in real-time.</p>\n<h2 id=\"endpoint\">Endpoint</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>GET https://api.rasedi.com/v1/payment/rest/live/status/PAY_XXXXXX\n\n</code></pre><h2 id=\"path-variables\">Path Variables</h2>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Parameter</th>\n<th>Type</th>\n<th>Required</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>referenceCode</code></td>\n<td>string</td>\n<td>Yes</td>\n<td>The unique reference code assigned to the payment transaction when it was created. This identifier is used to retrieve the specific payment's status.</td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"headers\">Headers</h2>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Header</th>\n<th>Type</th>\n<th>Required</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>Content-Type</code></td>\n<td>string</td>\n<td>Yes</td>\n<td>Must be set to <code>application/json</code> to indicate the expected response format.</td>\n</tr>\n<tr>\n<td><code>x-signature</code></td>\n<td>string</td>\n<td>Yes</td>\n<td>A cryptographic signature used to verify the authenticity of the request. This is typically generated using your merchant secret key and request parameters to ensure the request hasn't been tampered with.</td>\n</tr>\n<tr>\n<td><code>x-id</code></td>\n<td>string</td>\n<td><strong>Yes</strong></td>\n<td><strong>Required. Your unique Secret key that you got from your panel</strong></td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"authentication--security\">Authentication &amp; Security</h2>\n<p>This endpoint uses a combination of authentication mechanisms:</p>\n<ol>\n<li><p><strong>Merchant Identification</strong>: The <code>x-id</code> header identifies your merchant account</p>\n</li>\n<li><p><strong>Request Signing</strong>: The <code>x-signature</code> header provides request integrity verification</p>\n<ul>\n<li><p>The signature should be generated using HMAC-SHA256 or similar cryptographic algorithm</p>\n</li>\n<li><p>Include relevant request parameters (reference code, timestamp, etc.) in the signature calculation</p>\n</li>\n<li><p>Consult the Pallawan API documentation for the exact signature generation algorithm</p>\n</li>\n</ul>\n</li>\n</ol>\n<p><strong>Security Best Practices:</strong></p>\n<ul>\n<li><p>Store your merchant secret key securely (use environment variables)</p>\n</li>\n<li><p>Never expose your <code>x-id</code> or signature generation logic in client-side code</p>\n</li>\n<li><p>Implement request timeout handling</p>\n</li>\n<li><p>Use HTTPS for all API communications (enforced by the endpoint)</p>\n</li>\n</ul>\n<h2 id=\"response\">Response</h2>\n<h3 id=\"success-response-200-ok\">Success Response (200 OK)</h3>\n<p>The endpoint returns the current payment status along with transaction details.</p>\n<p><strong>Possible Payment Statuses:</strong></p>\n<ul>\n<li><p>PENDING - Payment has been initiated but not yet completed</p>\n</li>\n<li><p>PAID - Payment was successfully processed</p>\n</li>\n<li><p>FAILED - Payment processing failed</p>\n</li>\n<li><p>CANCELED - Payment was cancelled by the user or merchant</p>\n</li>\n<li><p>TIMED_OUT - Payment link timed out</p>\n</li>\n</ul>\n<h3 id=\"error-responses\">Error Responses</h3>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Status Code</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>400 Bad Request</code></td>\n<td>Invalid reference code format or missing required parameters</td>\n</tr>\n<tr>\n<td><code>401 Unauthorized</code></td>\n<td>Invalid or missing authentication credentials (<code>x-id</code> or <code>x-signature</code>)</td>\n</tr>\n<tr>\n<td><code>403 Forbidden</code></td>\n<td>Valid credentials but insufficient permissions to access this payment</td>\n</tr>\n<tr>\n<td><code>404 Not Found</code></td>\n<td>No payment found with the provided reference code</td>\n</tr>\n<tr>\n<td><code>429 Too Many Requests</code></td>\n<td>Rate limit exceeded, retry after a delay</td>\n</tr>\n<tr>\n<td><code>500 Internal Server Error</code></td>\n<td>Server-side error, contact support if persistent</td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"use-cases\">Use Cases</h2>\n<ul>\n<li><p><strong>Order Confirmation</strong>: Check payment status before fulfilling an order</p>\n</li>\n<li><p><strong>Webhook Verification</strong>: Verify webhook notifications by querying the actual payment status</p>\n</li>\n<li><p><strong>Customer Support</strong>: Look up payment status when handling customer inquiries</p>\n</li>\n<li><p><strong>Reconciliation</strong>: Verify payment states during financial reconciliation processes</p>\n</li>\n<li><p><strong>Polling</strong>: Periodically check status for payments awaiting completion (implement exponential backoff)</p>\n</li>\n</ul>\n<h2 id=\"example-usage\">Example Usage</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">// Example: Checking payment status\nconst referenceCode = \"PAY-123456789\";\nconst merchantId = \"your-secret-key\";\nconst signature = generateSignature(referenceCode); // Your signature generation function\nconst response = await fetch(`https://api.rasedi.com/v1/payment/rest/live/status/${referenceCode}`, {\n  method: 'GET',\n  headers: {\n    'Content-Type': 'application/json',\n    'x-id': merchantId,\n    'x-signature': signature\n  }\n});\nconst paymentStatus = await response.json();\nconsole.log('Payment Status:', paymentStatus);\n\n</code></pre>\n<h2 id=\"notes\">Notes</h2>\n<ul>\n<li><p>Reference codes are unique and case-sensitive</p>\n</li>\n<li><p>Status updates may have a slight delay (typically &lt; 30 seconds)</p>\n</li>\n<li><p>Implement proper error handling for all possible response codes</p>\n</li>\n<li><p>Consider caching successful status checks to reduce API calls</p>\n</li>\n<li><p>For real-time updates, consider using webhooks instead of polling</p>\n</li>\n</ul>\n","urlObject":{"protocol":"https","path":["v1","payment","rest","live","status","{{reference_code}}"],"host":["api","rasedi","com"],"query":[],"variable":[]}},"response":[],"_postman_id":"35a9186d-f545-43fd-89fb-a4a96c2aebec"},{"name":"Cancel Payment","event":[{"listen":"test","script":{"id":"68c170b2-709c-40b4-a8ff-21c2d8cddd38","exec":[""],"type":"text/javascript","packages":{},"requests":{}}},{"listen":"prerequest","script":{"id":"70880239-57db-45da-8934-14bb7141b261","exec":["const method = pm.request.method;","const secret = pm.environment.get(\"x_id\");","const url = pm.request.url;","","if (!secret) throw new Error(\"x_id not set\");","const PRIVATE_KEY_PEM = pm.environment.get(\"private_key\");","if (!PRIVATE_KEY_PEM) throw new Error(\"private_key not set\");","","// Build relative URL","let relativeUrl = \"/\" + url.path.join(\"/\");","// Replace any {{env}} variables","relativeUrl = relativeUrl.replace(/\\{\\{(.+?)\\}\\}/g, (_, varName) => {","    const val = pm.environment.get(varName);","    if (!val) throw new Error(`Environment variable ${varName} not found`);","    return val;","});","","","// ----- HELPERS -----","function pemToArrayBuffer(pem) {","    const b64 = pem","        .replace(/-----BEGIN PRIVATE KEY-----/, \"\")","        .replace(/-----END PRIVATE KEY-----/, \"\")","        .replace(/\\s+/g, \"\");","    const binary = atob(b64);","    const bytes = new Uint8Array(binary.length);","    for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);","    return bytes.buffer;","}","","// ----- SIGNING -----","(async () => {","    const rawSign = `${method} || ${secret} || ${relativeUrl}`;","    const data = new TextEncoder().encode(rawSign);","","    // Import Ed25519 private key","    const privateKey = await crypto.subtle.importKey(","        \"pkcs8\",","        pemToArrayBuffer(PRIVATE_KEY_PEM),","        { name: \"Ed25519\" },","        false,","        [\"sign\"]","    );","","    // Sign the data","    const signature = await crypto.subtle.sign(\"Ed25519\", privateKey, data);","","    // Convert to Base64","    const base64Signature = btoa(String.fromCharCode(...new Uint8Array(signature)));","","    // Store in environment variable","    pm.environment.set(\"x_signature\", base64Signature);","    console.log(\"X-Signature:\", base64Signature);","})();"],"type":"text/javascript","packages":{},"requests":{}}}],"id":"c11307e9-56d6-415d-96a4-e39033966f88","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"PATCH","header":[{"key":"x-id","value":"YOUR_API_KEY","type":"text"},{"key":"x-signature","value":"{{x_signature}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"}],"url":"https://api.rasedi.com/v1/payment/rest/live/cancel/{{reference_code}}","description":"<h1 id=\"cancel-payment\">Cancel Payment</h1>\n<p>This endpoint cancels an existing payment transaction using its unique reference code.</p>\n<h2 id=\"request-details\">Request Details</h2>\n<p><strong>Method:</strong> <code>PATCH</code></p>\n<p><strong>Endpoint:</strong> <code>https://api.rasedi.com/v1/payment/rest/live/cancel/PAY_XXXXXX</code></p>\n<h2 id=\"path-variables\">Path Variables</h2>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Variable</th>\n<th>Type</th>\n<th>Required</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>referenceCode</code></td>\n<td>string</td>\n<td>Yes</td>\n<td>The unique reference code of the payment transaction to be cancelled</td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"headers\">Headers</h2>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Header</th>\n<th>Type</th>\n<th>Required</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>x-id</code></td>\n<td>string</td>\n<td>Yes</td>\n<td>Your secret key you got from you panel</td>\n</tr>\n<tr>\n<td><code>x-signature</code></td>\n<td>string</td>\n<td>Yes</td>\n<td>Request signature for authentication and integrity verification</td>\n</tr>\n<tr>\n<td><code>Content-Type</code></td>\n<td>string</td>\n<td>Yes</td>\n<td>Must be set to <code>application/json</code></td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"request-body\">Request Body</h2>\n<p>This endpoint does not require a request body.</p>\n<h2 id=\"authentication--security\">Authentication &amp; Security</h2>\n<p>This endpoint uses a signature-based authentication mechanism:</p>\n<ul>\n<li><p>The <code>x-id</code> is Client secret key that you got from your panel</p>\n</li>\n<li><p>The <code>x-signature</code> header contains a cryptographic signature to verify the request authenticity and prevent tampering</p>\n</li>\n<li><p>Ensure both credentials are kept secure and never exposed in client-side code</p>\n</li>\n</ul>\n<h2 id=\"response\">Response</h2>\n<h3 id=\"success-response-200-ok\">Success Response (200 OK)</h3>\n<p>The payment has been successfully cancelled. The response will contain the updated payment status.</p>\n<h3 id=\"error-responses\">Error Responses</h3>\n<ul>\n<li><p><strong>400 Bad Request</strong> - Invalid reference code or payment cannot be cancelled (e.g., already completed or refunded)</p>\n</li>\n<li><p><strong>401 Unauthorized</strong> - Invalid or missing authentication credentials (x-id or x-signature)</p>\n</li>\n<li><p><strong>404 Not Found</strong> - Payment with the specified reference code does not exist</p>\n</li>\n<li><p><strong>500 Internal Server Error</strong> - Server-side error occurred while processing the cancellation</p>\n</li>\n</ul>\n<h2 id=\"use-cases\">Use Cases</h2>\n<ul>\n<li><p>Cancel a payment before it is processed</p>\n</li>\n<li><p>Handle user-initiated cancellation requests</p>\n</li>\n<li><p>Implement timeout-based automatic cancellations</p>\n</li>\n<li><p>Rollback failed or incomplete transactions</p>\n</li>\n</ul>\n<h2 id=\"notes\">Notes</h2>\n<ul>\n<li><p>Payment cancellation may only be possible within a specific time window or payment state</p>\n</li>\n<li><p>Once a payment is successfully processed or settled, cancellation may not be available (refund may be required instead)</p>\n</li>\n<li><p>Always verify the payment status before attempting cancellation</p>\n</li>\n</ul>\n","urlObject":{"protocol":"https","path":["v1","payment","rest","live","cancel","{{reference_code}}"],"host":["api","rasedi","com"],"query":[],"variable":[]}},"response":[],"_postman_id":"c11307e9-56d6-415d-96a4-e39033966f88"}],"event":[{"listen":"prerequest","script":{"id":"380abd0d-de7f-4751-aa26-8e5ff0332f8a","type":"text/javascript","packages":{},"requests":{},"exec":[""]}},{"listen":"test","script":{"id":"d82dde42-8366-47ec-9c99-6d6b439f53ff","type":"text/javascript","packages":{},"requests":{},"exec":[""]}}],"variable":[{"key":"base_url","value":"https://api.yourdomain.com"},{"key":"x_id","value":"YOUR_API_KEY"},{"key":"referenceCode","value":"PAY_XXXXXX"},{"key":"private_key","value":""}]}