API Documentation - Merchant Integration
BapokPay provides hosted payment request creation, payment method discovery, request status checks, balance summaries, and signed webhook callbacks for merchant-side reconciliation.
Overview
BapokPay is an assisted bank-transfer payment gateway. Your system creates a payment request, redirects the customer to a hosted payment page, and waits for verification. The customer pays using UPI, IMPS, or RTGS, submits the UTR/reference number, and the transaction is reviewed by authorized staff.
Once the transaction is approved, rejected, or failed, BapokPay sends a webhook to your configured endpoint. Your system can also poll status APIs when needed.
Payment links are single-use. After a customer submits UTR/details, the payment page is locked and cannot be opened or shared again.
- Merchant checks active payment methods.
- Merchant creates a payment request.
- Merchant redirects customer to returned payment URL.
- Customer pays and submits UTR.
- Staff verifies the transaction.
- BapokPay sends webhook to merchant.
- Merchant marks order as paid, rejected, or failed.
Base URL
Authentication
Every API request must include both the API key and API secret issued to the merchant. These credentials identify the merchant and protect the API from unauthorized order creation or status access.
cURL Example
| X-Api-Key | Merchant public API key. |
| X-Api-Secret | Merchant private API secret. Do not expose this in frontend code. |
Fetch Active Payment Methods
Use this endpoint before creating a payment request if your checkout needs to show only currently available methods. A method is returned only when it is active and mapped to an active collection route.
Create Payment Request
This endpoint creates a hosted payment page. Store the returned payment_id and request_ref in your order table. The returned payment_url should be shown to or redirected for the customer.
If the same merchant sends the same order_id again, the existing payment request is returned instead of creating a duplicate.
If payment_expires_at is omitted, the link expires 24 hours after creation. Once UTR is submitted, the link is considered used even if staff review is still pending.
Request Body Fields
| order_id | Required. Unique merchant order ID. |
| amount | Required. Amount to be collected. |
| customer_id | Optional merchant customer ID. |
| customer_name | Customer name shown on payment page. |
| customer_email | Customer email shown on payment page. |
| customer_mobile | Customer mobile shown on payment page. |
| return_url | URL where customer is redirected after UTR submission. |
| failure_url | Reserved for failure/cancel flows. |
| payment_method | Optional preferred method: UPI, IMPS, or RTGS. |
| payment_expires_at | Optional expiry date/time in YYYY-MM-DD HH:MM:SS format. Defaults to 24 hours from creation. |
Request Body
Response
Create And Send Payment Link
Use this endpoint when you want BapokPay to optionally send the payment link email using platform SMTP. Send send_email: true to email the customer from BapokPay, or send_email: false when your own system will share the returned payment_url.
Request Body
Response
Payment Origins
Every transaction carries payment_origin so merchants and operators can identify how the payment request was created.
| pg | Payment request created from merchant checkout/API flow. |
| payment_link | Payment request created as a direct payment link. |
More origins can be added later through the normalized payment_origins table.
Customer Redirect
Redirect the customer to payment_url. The hosted page displays the amount, merchant, customer/order details, and payment instructions.
For UPI, the page displays a self-hosted QR code using the NPCI UPI URI format and UPI ID. For IMPS/RTGS, it displays account name, bank name, account number, and IFSC.
After payment, the customer submits the UTR. Duplicate UTR values are rejected. After successful UTR submission, the same payment page URL becomes unavailable.
| UPI / IMPS | 12-16 digits only. |
| RTGS | 22-character alphanumeric UTR starting with 4-letter bank code. |
Status APIs
Use status APIs to poll payment state if your system does not rely only on webhook callbacks. You can check by payment_id or request_ref.
Response
Balance Summary
This endpoint returns approved/settled collection summaries for the merchant. Use it for merchant dashboards, reconciliation, and settlement planning.
| start_date | Optional. Filter start datetime. |
| end_date | Optional. Filter end datetime. |
| type | consolidated or daily. |
Request Body
Response
Metadata / Allowed Values
Returns normalized status and option values from the database so merchant systems can avoid hardcoded status confusion.
Webhook
BapokPay sends a webhook when a submitted payment is approved, rejected, or failed by an authorized reviewer. Your system should verify the signature before updating the order.
Headers
Payload
Verification
- Read the raw JSON body exactly as received.
- Read X-BapokPay-Webhook-Timestamp.
- Build the string: timestamp + "." + raw_json_payload.
- Generate HMAC SHA-256 using your webhook secret.
- Prefix with sha256=.
- Compare with X-BapokPay-Webhook-Signature.
Webhook retries reuse the same event ID, timestamp, payload, and signature. Retry actions are stored in the audit trail.
Settlements & Payouts
Settlements and payouts are managed in the BapokPay portal for reconciliation. These are operational records and do not change the merchant payment API identifiers.
| Settlement Reference | Unique internal reference such as SET202606101030001234. |
| Payout Reference | Unique payout/bank reference entered by the platform team or generated by the system. |
| Mapping | One payout can clear multiple locked settlements. The portal shows which settlement was cleared in which payout. |
| When payout status is paid, BapokPay sends the merchant a payout email with settlement references covered. |
Security Notes
- Never expose API secret or webhook secret in frontend code.
- Verify every webhook signature before provisioning an order.
- Reject old webhook timestamps to reduce replay risk.
- Use merchant IP/domain whitelisting where possible.
- Treat duplicate UTR as suspicious and do not provision twice.
- All API attempts are logged, including invalid credentials and blocked IP/domain attempts.
- API errors stay JSON for integrations. Browser/payment-page errors are shown as branded HTML pages.
Status Values
| Received | Payment request has been created and customer action is pending. |
| Pending Verification | Customer submitted UTR/proof and review is pending. |
| Approved | Payment has been verified and accepted. |
| Rejected | Payment was reviewed and rejected. |
| Failed | Payment failed or was manually failed. |
| Settled | Payment has been included in a locked settlement. |