Direct API integration
Delete token
Remove a saved card token with a DELETE request
A DELETE request is made to the "CancelToken" endpoint. A token can be removed using it. For example, an expired card, a new card, or a stolen card — it can be useful for removing the old card information.
Hashing
The remove hash is used to validate your order with what your customers are paying. Order hash generation uses the HMAC SHA256 crypto mechanism. You should generate the hash from your backend, and it is implemented as explained below:
//Copy and paste this code in your Backend
let crypto = require('crypto');
function generateKashierOrderHash(order) {
const mid = 'MID-123-123'; //your merchant id
const reference = '1'; //your customer id to save card
const secret = 'yourPaymentApiKey';
const path = `/?tokenization=${mid}.${reference}`;
const hash = crypto.createHmac('sha256', secret).update(path).digest('hex');
return hash;
}//Copy and paste this code in your Backend
function generateKashierOrderHash($order){
$mid = "MID-123-123"; //your merchant id
$secret = "yourPaymentApiKey";
$reference = "1"; //your customer id to save card
$path = "/?tokenization=".$mid.".".$reference;
$hash = hash_hmac('sha256', $path, $secret, false);
return $hash;
}#Copy and paste this code in your Backend
import hmac
import hashlib
import binascii
def generateKashierOrderHash(order):
mid = "MID-123-123"; #your merchant id
reference = '1'; #your customer id to save card
path = '/?tokenization={}.{}'.format(mid, reference)
path = bytes(path, 'utf-8')
secret = "yourPaymentApiKey"
secret = bytes(secret, 'utf-8')
return hmac.new(secret, path, hashlib.sha256).hexdigest()//Copy and paste this code in your Backend
using System.Security.Cryptography;
public class Kashier
{
public static string create_hash(){
string mid = "MID-123-123"; //your merchant id
string reference = "1"; //your customer Id
string secret = "yourPaymentApiKey";
string path = "/?tokenization=" + mid + "." + reference;
string message;
string key;
key = secret;
message = path;
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] keyByte = encoding.GetBytes(key);
byte[] messageBytes = encoding.GetBytes(message);
HMACSHA256 hmacmd256 = new HMACSHA256(keyByte);
byte[] hashmessage = hmacmd256.ComputeHash(messageBytes);
return ByteToString(hashmessage).ToLower();
}
public static string ByteToString(byte[] buff){
string sbinary = "";
for (int i = 0; i < buff.Length; i++){
sbinary += buff[i].ToString("X2"); // hex format
}
return (sbinary);
}
}Note
For creating the hash, use only the parameters mentioned in the snippet above. Don't add extra parameters in the hash creation.
Remove token
In case you are still in the development phase, you will need to call our API using the following testing endpoint API URL.
| Endpoint | Value |
|---|---|
| TEST-URL | https://test-fep.kashier.io/v3/cards/tokens/:token?customerReference=yourcustomerReference&merchantId=merchantId |
| LIVE-URL | https://fep.kashier.io/v3/cards/tokens/:token?customerReference=yourcustomerReference&merchantId=merchantId |
| Method | DELETE |
Headers
| Key | Description |
|---|---|
| Authorization | Your Secret Key. |
| Kashier-Hash (String) | HMAC SHA256 of /?tokenization={mid}.{customerReference}, keyed with your Payment API Key — see Hashing above. |
curl -X 'DELETE' 'https://test-fep.kashier.io/v3/cards/tokens/:token?customerReference={{customerReference}}' \
-H 'Authorization: your_secretKey' \
-H 'Kashier-Hash: your_generated_hash' \
-H 'accept: application/json'Full parameter and response reference → Delete token.