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
  1. Direct Pay

1. Generate Merchant Keys

A merchant should have an RSA public key in order to integrate direct pay. The RSA key will be generated using this endpoint.

API Endpoints

Production Base URL /api/GenToken/GenerateMerchantKey
Sandbox Base URL /api/GenToken/GenerateMerchantKey

Sample Request & Response

Use the below parameters to get merchant keys.


{
    "merchantCode":"xxxxx",
    "authKey":"xxxxxxxxxx"
}
{
  "errorCode": 0,
  "errorMessgae": "string",
  "result": {
    "publicKey": "string"
  }
}

To obtain the public key, access the publicKey property directly from the API response object as follows:

var publicKey = response.result.publicKey;

In the event that an error occurs while retrieving or using response.result.publicKey (e.g., the property is malformed, or inaccessible), implement the following fallback mechanism: Use an RSA public key in the XML format specified below:

<RSAKeyValue>
    <Modulus>[Binary value]</Modulus>
    <Exponent>AQAB</Exponent>
</RSAKeyValue>

Replace [Binary value] with the base64-encoded modulus of the RSA public key. This is the primary component of the key.

sample code to post data

 public async Task> GenrateKeys(GenrateKeysRequest obj)
  {
  Output dto = new Output();
  var url = {Provided End Point};
  var client = new HttpClient();
  client.BaseAddress = new Uri(url);
  try
  {
  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 ValidatePaymentRequest)
  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
// Merchant Code
$merchantCode= xxxx;
// AuthKey
$authKey = 'Your Authorization Key';
$data = array(
  'merchantCode' => $merchantCode,
  'authKey' => $authKey,
);
$request = json_encode( $data, true );
if ( !$endpoint ) {
  $curl = curl_init( { Provided Url } );
} 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> GenrateKeys(GenrateKeysRequest obj)
  {
  Output dto = new Output();
  var url = {Provided End Point};
  var client = new HttpClient();
  client.BaseAddress = new Uri(url);
  try
  {
  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;
  
  }`;

Note: Merchant keys are valid for 24 hours and the same key to be use for decryption for 24 hours. Users are expected to generate a new merchant key every 24 hours. If the merchant utilizes an invalid RSA public key, the following error will show up in subsequent calls. { "ErrorMessage" : "Exception while decrypting the Card Details" }

PreviousDirect PayNext2. Validate Request

Last updated 8 days ago