Search Documentation
Search across all documentation pages, APIs and guides.
API Implementation
This guide walks you through the process of implementing our payment system using the REST APIs. We'll cover the steps from creating items to processing payments.
Implementation Steps
Create Items (Optional)
If you want to associate specific items with your payment request:- Use the Create Item API to create items in the system
- Store the returned
item_idfor use in payment requests - You can verify the item creation using the Get Item API
- Items can be updated later using the Update Item API if needed
Generate Hash Key
Before creating a payment request, you need to generate a hash key:- Concatenate the following values in order:
app_id + currency + amount + <<YOUR HASH SALT>> - Apply SHA-256 algorithm to the concatenated string
- Use the resulting hash string in your payment request
Example hash generation:
Input string: "80NR1189D04CD635D8ACDLKR100.00XXXHASHSALTXXX"Hash result: "126ff89348d80fb91ec4f25c2bd55e2f71d8f3986da9470eabe28b2f8becf21a"- Concatenate the following values in order:
Create Payment Request
To initiate a payment transaction:- Use the Create Transaction API
- Include the
item_idsin the request if you want to associate specific items - The API will return a payment URL that you can use to redirect customers to the payment gateway
Track Payment Status
To monitor the payment status:- Use the Get Transaction API to check the payment status
- Poll this endpoint periodically to track the payment completion
Callback Response
Set up your system to receive transaction status updates:- Update your callback URL in the APP section of the Onepay portal
- Your endpoint should be configured to accept POST requests with JSON payloads
- After transaction completion, Onepay will send a callback with transaction details
Sample callback payload:
{"transaction_id": "WQBV118E584C83CBA50C6","status": 1,"status_message": "SUCCESS","additional_data": ""}Use this callback data for logging, verification, and updating transaction status in your system.
Make sure to handle all possible response codes and implement proper error handling as described in the Error Handling section.
On This Page