Casheer KW
  • Introduction
  • Integration Steps
  • Types of Integration
    • 1. Standard Pay
    • 2. Plugins
    • 3. SDK
  • Sample Code
    • 1. Get Payment URL
    • 2. Redirect to Payment URL
    • 3. Callback To Merchant Portal
    • 4. Compute HASH
    • 5. Refund Request
    • 6, Payment Status
  • Parameters & Description
  • Payment Methods
  • Test Cards
  • Download Plugins/SDK
  • Direct Pay
    • 1. Generate Merchant Keys
    • 2. Validate Request
    • 3. Initiate Pay
    • 4. Process Payment
  • Modules Setup Guides
    • WooCommerce
    • Drupal Commerce
    • OpenCart
    • Magento 1
    • Magento 2
    • PrestaShop
    • Joomla
    • WHMCS
Powered by GitBook
On this page
  • API Endpoints
  • Sample Request & Response
  • Hash Creation
  • Response Parameters
  1. Sample Code

5. Refund Request

API to request the refund for the paid transactions.

API Endpoints

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 a hash value using Hashing Key.

Amount+AuthenticationKey+MerchantCode+ReferenceID

Response Parameters

Parameters
Data Type
Description

errorCode

Integer

0 is success 1 is failed and 2 is initiated for manual refund

errorMessagee

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( 'Provided End Point' );
} 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;
  
  }`;
Previous4. Compute HASHNext6, Payment Status

Last updated 3 months ago