5. Refund Request
API to request the refund for the paid transactions.
API Endpoints
Production Base URL /api/GenToken/Refund
Sandbox Base URL /api/GenToken/Refund
Sample Request & Response
{
"merchantCode":"xxxxx",
"authKey":"xxxxxxxxx",
"ReferenceID":"(15 digit number passing during the payment creation)",
"hash":"ComputedHash(To be calculated as described below)",
"Amount":1,
"Description":"optional",
"RequestedBy":"optional"
}
{
"errorCode": 0 is Success 1 is Failed,
"errorMessgae": "Message",
"Result":
{
"IsRefunded":"1 is refunded | 2 is under process | 0 is rejected"
}
}
Hash Creation
Use the below string format to generate an hash value using Hashing Key.
Amount + AuthenticationKey + MerchantCode + ReferenceID
Response Parameters
Parameters
Data Type
Description
errorCode
Integer
1 is success 0 is failed
errorMessage
String
result -> IsRefunded
Integer
1 is refunded | 2 is under process | 0 is rejected
Merchant will receive an email from Og regarding the updates(under process, cancelled and refunded) of refund.
Sample Code to post data
public async Task> RefundPayment(RefundPaymentRequest obj)
{
Output dto = new Output();
var url = {Provided End Point};
var client = new HttpClient();
client.BaseAddress = new Uri(url);
try
{
obj.hash = ComputeHash(obj);
var resultser = JsonConvert.SerializeObject(obj);
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
var response = client.PostAsJsonAsync(url, obj).Result;
if (response.IsSuccessStatusCode)
{
var ss = response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject>(ss.Result);
dto = result;
}
else
{
var ss = response.Content.ReadAsStringAsync();
var resps = ss.Result.ToString();
}
}
catch (HttpRequestException ex)
{
}
return dto;
}
Class SurroundingClass
Public Task As async
Private Sub New(ByVal obj As RefundPaymentRequest )
Dim dto As Output = New Output()
Dim url = {Provided End Point};
Dim client = New HttpClient()
client.BaseAddress = New Uri(url)
Try
obj.hash = ComputeHash(obj)
Dim resultser = JsonConvert.SerializeObject(obj)
client.DefaultRequestHeaders.Accept.Add(New System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"))
client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8")
Dim response = client.PostAsJsonAsync(url, obj).Result
If response.IsSuccessStatusCode Then
Dim ss = response.Content.ReadAsStringAsync()
Dim result = JsonConvert.DeserializeObject > (ss.Result)
dto = result
Else
Dim ss = response.Content.ReadAsStringAsync()
Dim resps = ss.Result
Dim resultse = JsonConvert.SerializeObject(resps.ToString())
End If
Catch ex As HttpRequestException
End Try
Return dto
End Sub
End Class
<?php
// referenceID must be 15 digit Payment Number
$referenceID = 123456412250000;
$amount = 20.50;
$authKey = 'Your Authorization Key';
$merchantID = 'Your Merchent Key';
// Concat all data string
$datatocomputeHash = ( float )$amount . $authKey . $merchantID . $referenceID ;
// convert the concated string in to hash and convert all string in upper character.
$hash = strtoupper( hash_hmac( "sha256", $datatocomputeHash, $secretkey ) );
$data = array(
'merchantCode' => $merchantID,
'authKey' => $authKey,
'hash' => $hash
'amount' => ( float )$amount,
'description' => $description,
'RequestedBy' => $RequestedBy,
);
$request = json_encode( $data, true );
if ( !$endpoint ) {
$curl = curl_init( 'https://ogcheckoutstage.oneglobal.com/OgPay/V1/api/GenToken/Refund' );
} else {
$curl = curl_init( $endpoint );
}
curl_setopt( $curl, CURLOPT_POST, true );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $request );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json' ) );
$ch = curl_exec( $curl );
curl_close( $curl );
$response = json_decode( $ch, true );
?>
pagecode:` public async Task> RefundRequest(RefundPaymentRequest obj)
{
Output dto = new Output();
var url = {Provided End Point};
var client = new HttpClient();
client.BaseAddress = new Uri(url);
try
{
obj.hash = ComputeHash(obj);
var resultser = JsonConvert.SerializeObject(obj);
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
var response = client.PostAsJsonAsync(url, obj).Result;
if (response.IsSuccessStatusCode)
{
var ss = response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject>(ss.Result);
dto = result;
}
else
{
var ss = response.Content.ReadAsStringAsync();
var resps = ss.Result;
var resultse = JsonConvert.SerializeObject(resps.ToString());
}
}
catch (HttpRequestException ex)
{
}
return dto;
}`;
Last updated