OPay Cashier Reversal Status
Stay informed with the status of the requested and processed reversal payments using OPay Cashier Reversal Status API.
Cashier Reversal Status
you can get the status of a requested reversal payment by using the Cashier Reversal Status API.
For calling the API using the POST method you can use these endpoints URL:
-In case you are still in the developing phase, use the following staging API endpoint URL
https://testapi.opaycheckout.com/api/v1/international/transaction/reversal/status
-Once you have a fully tested payment flow and you are ready for production, Use the following production API endpoint URL instead
https://liveapi.opaycheckout.com/api/v1/international/transaction/reversal/status
-Request Parameters:
- Header: Bearer Signature and merchant ID
- Json object containing the transaction information:
Authorization: Bearer {signature}
MerchantId : 256612345678901
{
"reference": "12312321324",
"reversalNo": "10343543543532432"
}
HTTP POST Parameters
-Here is a detailed description for the parameters you need to complete the POST request:
-An example call of Cashier Reversal Status API is as follows :
function Cashier(transaction_data) {
const PaymentData = {
reference: transaction_data.reference,
reversalNo : transaction_data.reversalNo,
};
const response = await fetch('https://testapi.opaycheckout.com/api/v1/international/transaction/reversal/status ', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization' : 'Bearer {signature}',
'MerchantId' : '256612345678901'
},
body: JSON.stringify(PaymentData),
});
// Return and display the result of the charge.
return response.json();
}
$reference = '12312321324';
$reversalNo = '11212134400034123';
$httpClient = new \GuzzleHttp\Client(); // guzzle 6.3
$response = $httpClient->request('POST', 'https://testapi.opaycheckout.com/api/v1/international/transaction/reversal/status ', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' : 'Bearer {signature}',
'MerchantId' : '256612345678901'
],
'body' => json_encode( [
'reference' => $reference,
'reversalNo' => $orderNo,
] , true)
]);
$response = json_decode($response->getBody()->getContents(), true);
$paymentStatus = $response['type']; // get response values
# importing the requests library
import requests
# CashierAPI Endpoint
URL = "https://testapi.opaycheckout.com/api/v1/international/transaction/reversal/status "
# defining a params dict for the parameters to be sent to the API
PaymentData = {
'reference' : '12312321324',
'reversalNo' : '11212134400034123',
}
# Prepare Headers
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization': 'Bearer Public Key',
'MerchantId' : '256612345678901'
}
# sending post request and saving the response as response object
status_request = requests.post(url = URL, params = json.dumps(PaymentData))
# extracting data in json format
status_response = status_request.json()
function Cashier() {
axios.post('https://testapi.opaycheckout.com/api/v1/international/transaction/reversal/status ', {
headers : {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization': 'Bearer {signature}',
'MerchantId' : '256612345678901'
},
{
'reference' : '12312321324',
'reversalNo' : '10343543543532432',
}
})
.then(response => {
// Get Response Contents
let type = response.data.type;
let paymentStatus = response.data.paymentStatus;
//
})
.catch(error => {
console.log(error.response.data)
})
}
$ curl https://testapi.opaycheckout.com/api/v1/international/transaction/reversal/status \
-H "content-type: application/json , Authorization: Bearer {signature} , MerchantId: 256612345678901" \
-X POST \
-d "{
'reference' : '12312321324',
'reversalNo' : '10343543543532432',
}"
URL url = new URL ("https://testapi.opaycheckout.com/api/v1/international/transaction/reversal/status ");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json; utf-8");
con.setRequestProperty("Authorization", "Bearer {signature}");
con.setRequestProperty("MerchantId", "256612345678901");
con.setDoOutput(true);
String jsonInputString = "{
'reference' : '12312321324',
'reversalNo' : '10343543543532432'
}";
try(OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
try(BufferedReader br = new BufferedReader(
new InputStreamReader(con.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using Newtonsoft.Json;
namespace OPayRequest
{
public class Program
{
static void Main(string[] args)
{
PostJson("https://testapi.opaycheckout.com/api/v1/international/transaction/reversal/status ", new opay_request
{
reference = '12312321324',
reversalNo = '10343543543532432',
});
}
private static void PostJson(string uri, opay_request postParameters)
{
string postData = JsonConvert.SerializeObject(postParameters);
byte[] bytes = Encoding.UTF8.GetBytes(postData);
var httpWebRequest = (HttpWebRequest) WebRequest.Create(uri);
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = bytes.Length;
httpWebRequest.ContentType = "text/json";
using (Stream requestStream = httpWebRequest.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Count());
}
var httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse();
if (httpWebResponse.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("GET failed. Received HTTP {0}", httpWebResponse.StatusCode);
throw new ApplicationException(message);
}
}
}
public class opay_request
{
public string reference { get; set; }
public string reversalNo { get; set; }
}
}
Cashier Reversal Status Response
-Response Parameters:
The parameters contained in the response received whenever you call the Transaction Create API as a JSON Object.
{
"code": "00000",
"message": "SUCCESSFUL",
"data": {
"reference": "test_123456",
"originalReference": "1001000001",
"orderNo": "10212100000034000",
"reversalNo": "11212134400034123",
"status": "INITIAL"
}
}
-Here is a detailed description for the parameters received in the response:
Parameter | type | Description | example |
---|---|---|---|
reference | String |
reference Id. | 1001000 |
originalReference | String |
original order originalReference id. | 1001000001 |
orderNo | String |
original order id. | 10212100000034000 |
reversalNo | String |
Reversal order number. | 11212134400034123 |
status | String |
INITIAL:initial PENDING:pending SUCCESS:success FAIL:fail CLOSE:close | "INITIAL" |
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.
{
"code": "20000",
"message": "Duplicate merchant order number",
"data": null
}
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.
Error Code | Error Message |
---|---|
09 | Time out. |
90 | System failure. |
91 | Refund error, please try again later. |
96 | Search order error, please try again later. |
97 | Create checkout session failed. |
98 | Invalid request header with requestId. |
99 | Request channel parameters are not valid. |
20000 | Duplicate merchant order number. |