OPay Authorize and Capture Payment API
In this page, you will learn how to use Authorize and Capture Payment API, you can make authorize payment first, then you can capture the authorized payment later
- Collect your client's payment Information.
- Trigger Authorize The Payment API and query order status
- Trigger Capture The Authorized Payment
- After payment successfully, redirect your client to successful page
1.Authorize The Payment
To test your Authorize The Payment API, you need to request using the POST method in our sandbox environment.
-Here is the request URL:
-Once you have a fully tested payment flow and you are ready for production, use the following production API endpoint URL instead
-Request Parameters:
- Header: Authorization(API Calls Signature), MerchantId
- Json object containing the transaction information:
HTTP POST parameters
-Here is a detailed description for the parameters you need to complete the POST request:
-An example of Authorize The Payment request for is as follows :
Authorize The Payment Response
-Response Parameters:
the parameters contained in the response received whenever you call payment API as a JSON Object.
-Here is a detailed description for the parameters received in the response:
Parameter | type | Description | example | |
---|---|---|---|---|
reference | String |
The unique merchant payment order number. | 202111300001 | |
orderNo | String |
OPay transaction number | 211130148131809099 | |
nextAction | ||||
actionType | String |
Next action type, enum[REDIRECT_3DS] | REDIRECT_3DS | |
redirectUrl | String |
3ds redirect url. | https://sandboxapi.opaycheckout.com/api/v1/international/transaction/3ds/e9f25ec9bd4139329aaa9ab784775220aed5ca97f9021578df2ab4287e0f8175 | |
status | String |
Order status | PENDING | |
amount JSON Object |
||||
total | Long |
Transaction amount | 1000 (cent unit) | |
currency | String |
Currency type | EGP | |
vat JSON Object |
||||
total | Long |
Value Added Tax Amount | 0 | |
currency | String |
Currency type | EGP | |
isAuthorised | Boolean |
If the payment order has been authorised, there will be an isAuthorised parameter in the response, its value is true or false. | true or false | |
isCaptured | Boolean |
If the payment order has been captured, there will be an isCaptured parameter in the response, its value is true or false. | true or false | |
isVoided | Boolean |
If the payment order has been voided, there will be an isVoided parameter in the response, its value is true or false. | true or false | |
failureCode | String |
Fail error code. | Payment fail error code, not blank when status [FAIL/CLOSE] | |
failureReason | String |
Fail error message. | Payment fail error message, not blank when status [FAIL/CLOSE] |
-Response Parameters:
the parameters contained in the response received whenever you call payment API as a JSON Object.
-Here is a detailed description for the parameters received in the response:
Parameter | type | Description | example | |
---|---|---|---|---|
reference | String |
The unique merchant payment order number. | 202111300001 | |
orderNo | String |
OPay transaction number | 211130148131809099 | |
status | String |
Order status | PENDING | |
amount JSON Object |
||||
total | Long |
Transaction amount | 1000 (cent unit) | |
currency | String |
Currency type | EGP | |
vat JSON Object |
||||
total | Long |
Value Added Tax Amount | 0 | |
currency | String |
Currency type | EGP | |
isAuthorised | Boolean |
If the payment order has been authorised, there will be an isAuthorised parameter in the response, its value is true or false. | true or false | |
isCaptured | Boolean |
If the payment order has been captured, there will be an isCaptured parameter in the response, its value is true or false. | true or false | |
isVoided | Boolean |
If the payment order has been voided, there will be an isVoided parameter in the response, its value is true or false. | true or false | |
failureCode | String |
Fail error code. | Payment fail error code, not blank when status [FAIL/CLOSE] | |
failureReason | String |
Fail error message. | Payment fail error message, not blank when status [FAIL/CLOSE] |
2.Capture The Authorized Payment API
To test your Capture The Authorized Payment API, you need to request using the POST method in our sandbox environment.
-Here is the request URL:
-Once you have a fully tested payment flow and you are ready for production, use the following production API endpoint URL instead
-Request Parameters:
- Header: Authorization(API Calls Signature), MerchantId
- Json object containing the transaction information:
HTTP POST parameters
-Here is a detailed description for the parameters you need to complete the POST request:
-An example of Capture The Authorized Payment request is as follows :
Capture the Authorized Payment Response
-Response Parameters:
the parameters contained in the response received whenever you call the Pickup Goods payment API as a JSON Object.
-Here is a detailed description for the parameters received in the response:
Parameter | type | Description | example | |
---|---|---|---|---|
reference | String |
The unique merchant payment order number. | 202111300001 | |
orderNo | String |
OPay transaction number | 211130148131809099 | |
status | String |
Order status | PENDING | |
amount JSON Object |
||||
total | Long |
Transaction amount | 1000 (cent unit) | |
currency | String |
Currency type | EGP | |
authoriseAmount JSON Object |
||||
total | Long |
Authorize amount | 1000 (cent unit) | |
currency | String |
Currency type | EGP | |
isAuthorised | Boolean |
If the payment order has been authorised, there will be an isAuthorised parameter in the response, its value is true or false. | true or false | |
isCaptured | Boolean |
If the payment order has been captured, there will be an isCaptured parameter in the response, its value is true or false. | true or false | |
isVoided | Boolean |
If the payment order has been voided, there will be an isVoided parameter in the response, its value is true or false. | true or false | |
failureCode | String |
Fail error code. | Payment fail error code, not blank when status [FAIL/CLOSE] | |
failureReason | String |
Fail error message. | Payment fail error message, not blank when status [FAIL/CLOSE] |
3.Void Payment Authentication API
To test your Void Payment Authentication API, you need to request using the POST method in our sandbox environment.
-Here is the request URL:
Once you are ready for production, you should use the following production API endpoint URL instead
- Header: Authorization(API Calls Signature), MerchantId
- Json object containing the transaction information:
HTTP POST Parameters
Detailed description of the parameters that you need to incorporate into your POST request are given in the table below.
-An example of Void Payment Authentication for is as follows :
Void Payment Authentication Response
-Response Parameters:
the parameters contained in the response received whenever you call the payment API as a JSON Object.
-Here is a detailed description for the parameters received in the response:
Parameter | type | Description | example | |
---|---|---|---|---|
reference | String |
The unique merchant payment order number. | 202111300001 | |
orderNo | String |
OPay transaction number | 211130148131809099 | |
status | String |
Order status | PENDING | |
amount JSON Object |
||||
total | Long |
Transaction amount | 1000 (cent unit) | |
currency | String |
Currency type | EGP | |
authoriseAmount JSON Object |
||||
total | Long |
Authorize amount | 1000 (cent unit) | |
currency | String |
Currency type | EGP | |
isAuthorised | Boolean |
If the payment order has been authorised, there will be an isAuthorised parameter in the response, its value is true or false. | true or false | |
isCaptured | Boolean |
If the payment order has been captured, there will be an isCaptured parameter in the response, its value is true or false. | true or false | |
isVoided | Boolean |
If the payment order has been voided, there will be an isVoided parameter in the response, its value is true or false. | true or false | |
failureCode | String |
Fail error code. | Payment fail error code, not blank when status [FAIL/CLOSE] | |
failureReason | String |
Fail error message. | Payment fail error message, not blank when status [FAIL/CLOSE] |
Error Handling
After submitting an API call to OPay, you receive a response back to inform you that
your request was received and processed. A successful OPay API should return a status code 00
,
meanwhile, in a situation where any payment processing error occurred, you will receive an error code with a
message to describe the reason of the error. A sample error response can be found below.
Depending on the HTTP status code of the response, you should build some logic to handle any errors that a request or the system may return. A list of possible potential error codes that you may receive can be found below. A full list of all possible error codes can be found in the Error Codes section.
Error Code | Error Message |
---|---|
02000 | authentication failed. |
02001 | request parameters not valid. |
02002 | merchant not configured with this function. |
02003 | payMethod not support. |
02004 | the payment reference already exists. |
02007 | merchant not available. |
50003 | service not available, please try again. |
05023 | The %s parameter is required |
05056 | The value of enable3DS must be true |