Create Payments Using OPay Cashier
Throughout this page, you will learn how to create payments using our OPay Cashier plugin. In this page you will learn how to:
- Collect your client's order information.
- Trigger OPay Cashier API with your collected order information.
- Handling OPay Cashier API Response.
- Redirect your client to OPay Cashier Checkout Page.
- Handling OPay Cashier Checkout Page Returned Payment Processing Information.
Collect your Client's Order Information
Once your client's order is ready, you will need to present your own payment details form. This form should collect:
- Client Information: Name, Phone, E-mail, Shipping Address.
- Order Information: Product, Quantity, Unit Price, Order Amount.
Once you have collected the required information, pass them to your server so your application can trigger OPay Cashier Plugin.
OPay Cashier Create Payment
To get started with OPay Cashier, you need to call the create cashier payment API. In case you are still in development phase, you will need to call create cashier payment API using POST method at the following staging endpoint API point URL
Once you have a fully tested payment flow and you are ready for production, you should use the following production API endpoint URL instead
Cashier Create Payment API HTTP POST Parameters
Your request should contain:- Header:
- Bearer PublicKey: Your OPay merchant account Public Key.
- merchant ID: Your OPay account merchant ID.
- Json object containing the payment information:
Detailed description of the parameters that you need to incorporate into your POST request are given in the table below.
An example call of cashier create payment with an amount of 4EGP is given below.
OPay Cashier Response
Sample Response
the parameters contained in the response received whenever you call OPay Cashier Create API as a JSON Object.
Sample OPay Cashier Create API Response
Response Parameters Description
Parameter | type | Description | example | |
---|---|---|---|---|
reference | String |
Unique merchant payment order number. | 937102167 | |
orderNo | String |
Unique Opay payment order number. | 211009140896593010 | |
cashierUrl | String |
OPay Cashier URl generated for your client's current transaction. | https://sandboxcashier.opaycheckout.com/apiCashier/redirect/payment/checkout?orderToken=TOKEN.546f3b0405b447be8198691999f56788 |
|
status | enum |
[INITIAL, PENDING, SUCCESS, FAIL, CLOSE] | SUCCESS | |
amount | ||||
total | Integer |
amount(cent unit). | 400 | |
currency | String |
currency type.See full list here | EGP | |
vat | ||||
total | Integer |
amount(cent unit). | 10 | |
currency | String |
currency type.See full list here | EGP |
Redirect Client to Cashier URL
Once you received the response of the cashier create payment API, your next action is to redirect your
client to the cashierUrl
received within the API response. Once you redirect your client, the cashier
page will be ready for your client to complete the payment.

If you've left the payMethod
key blank in your request, your client will have the options to pay using:
- MasterCard, VISA, or MEEZA cards.
- Obtain a reference number and pay at any POS of our OPay retail network.
Otherwise, if you have designated a specific payMethod
, only the designated payment method will be available to your client to use.
Payment Processing Information
If your client has completed the payment at the generated cashierUrl
,
he will be redirected to the returnUrl
sent with your request, otherwise,
if he decided to cancel the payment, he will be redirected to cancelUrl
.
You will receive the payment processing information on the callbackUrl
provided with your API request.
A callback object is sent in JSON and similar to what you would expect in response to a typical API request.
Below is the body of a callback.
Callback Parameters Description
Parameter | type | Description | |
---|---|---|---|
payload | |||
country | String |
Transaction belongs country. | |
fee | String |
Transaction fee Amount. | |
displayedFailure | String |
Transaction reason for failure. | |
reference | String |
Partner transaction number. | |
updated_at | String |
Transaction update time. | |
currency | String |
Transaction currency. | |
refunded | String |
Is the transaction a refund type (true false). | |
timestamp | String |
Transaction time. | |
amount | String |
Transaction Amount. | |
transactionId | String |
Opay transaction number(orderNo). | |
payChannel | String |
Payment MethodsSee available options here | |
status | enum |
[PENDING, SUCCESS, FAIL, CLOSE] | |
sha512 | String |
Which is essentially a HMac-SHA3-512 signature of the callback payload. Signed using your Secret Key. See here | |
type | enum |
[transaction-status,refund-status] |
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 params not valid. |
02003 | payMethod not support. |
02004 | the payment reference(merchant order number) already exists. |
02002 | merchant not configured with this function. |
02007 | merchant not available. |
50003 | service not available, please try again. |