Introduction
This section describes the WebVola payment gateway API.
WebVola API is easy to implement in your business software. Our API is well formatted URLs, accepts cURL requests, returns JSON responses.
You can use the API in test mode, which does not affect your live data. The API key is use to authenticate the request and determines the request is valid payment or not. For test mode just use the sandbox URL and In case of live mode use the live URL from section Initiate Payment .
Supported Currencies
This section describes the currencies supported by WebVola
WebVola allows to make transaction with below currencies. Any new currency may update in future.
Currency Name | Currency Symbol | Currency Code |
---|---|---|
United States Dollar | $ | USD |
EURO | Є | EUR |
Malagasy Ariary | Ar | MGA |
GBP | £ | GPB |
Canadian Dollar | C$ | CAD |
Swiss Franc | ? | CHF |
JPY | � | JPY |
CNY | CN� | CNY |
Bitcoin | BTC | BTC |
Ethereum | ? | ETH |
Tether | ? | USDT |
BNB | BNB | BNB |
Dogecoin | � | DOGE |
USDC | USDC | USDC |
TRON | TRX | TRX |
Litecoin | ? | LTC |
Bitcoin Cash | ? | BCH |
Get The Api Key
This section describes how you can get your api key.
Login to your WebVola merchant account. 'If you don\'t have any ? ('Click Here')
Next step is to find the Api Key menu in your dashboard sidebar. Click the menu.
The api keys can be found there which is Public key and Secret key. Use these keys to initiate the API request. Every time you can generate new API key by clicking Generate Api Key button. Remember do not share these keys with anyone.
Initiate Payment
This section describes the process of initaiing the payment.
To initiate the payment follow the example code and be careful with the perameters. You will need to make request with these following API end points.
Live End Point: https://webvola.com/payment/initiate
Test End Point: https://webvola.com/sandbox/payment/initiate
Test Mode Mail: test_mode@mail.com
Test Mode Verification Code: 222666
Request Method: POST
Request to the end point with the following parameters below.
Param Name | Param Type | Description |
---|---|---|
public_key | string (50) | Required Your Public API key |
identifier | string (20) | Required Identifier is basically for identify payment at your end |
currency | string (4) | Required Currency Code, Must be in Upper Case. e.g. USD,EUR |
amount | decimal | Required Payment amount. |
details | string (100) | Required Details of your payment or transaction. |
ipn_url | string | Required The url of instant payment notification. |
success_url | string | Required Payment success redirect url. |
cancel_url | string | Required Payment cancel redirect url. |
site_logo | string/url | Required Your business site logo. |
checkout_theme | string | Optional Checkout form theme dark/light. Default theme is light |
customer_name | string (30) | Required Customer name. |
customer_email | string (30) | Required Customer valid email. |
curl -X POST https://webvola.com/payment/initiate \
-H "Content-Type: application/json" \
-d '{
"identifier": "DFU80XZIKS",
"currency": "USD",
"amount": 100.00,
"details": "Purchase T-shirt",
"ipn_url": "http://example.com/ipn_url.php",
"cancel_url": "http://example.com/cancel_url.php",
"success_url": "http://example.com/success_url.php",
"public_key": "your_public_key",
"site_logo": "https://webvola.com/assets/images/logoIcon/logo.png",
"checkout_theme": "dark",
"customer_name": "John Doe",
"customer_email": "john@mail.com"
}'
const axios = require('axios');
const url = "https://webvola.com/payment/initiate";
// For test: const url = "https://webvola.com/sandbox/payment/initiate";
const payload = {
identifier: "DFU80XZIKS",
currency: "USD",
amount: 100.00,
details: "Purchase T-shirt",
ipn_url: "http://example.com/ipn_url.php",
cancel_url: "http://example.com/cancel_url.php",
success_url: "http://example.com/success_url.php",
public_key: "your_public_key",
site_logo: "https://webvola.com/assets/images/logoIcon/logo.png",
checkout_theme: "dark",
customer_name: "John Doe",
customer_email: "john@mail.com"
};
axios.post(url, payload)
.then(response => console.log(response.data))
.catch(error => console.error(error));
require 'uri'
require 'net/http'
url = URI("https://webvola.com/payment/initiate")
# For test: url = URI("https://webvola.com/sandbox/payment/initiate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = {
identifier: "DFU80XZIKS",
currency: "USD",
amount: 100.00,
details: "Purchase T-shirt",
ipn_url: "http://example.com/ipn_url.php",
cancel_url: "http://example.com/cancel_url.php",
success_url: "http://example.com/success_url.php",
public_key: "your_public_key",
site_logo: "https://webvola.com/assets/images/logoIcon/logo.png",
checkout_theme: "dark",
customer_name: "John Doe",
customer_email: "john@mail.com"
}.to_json
response = http.request(request)
puts response.read_body
<?php
$parameters = [
'identifier' => 'DFU80XZIKS',
'currency' => 'USD',
'amount' => 100.00,
'details' => 'Purchase T-shirt',
'ipn_url' => 'http://example.com/ipn_url.php',
'cancel_url' => 'http://example.com/cancel_url.php',
'success_url' => 'http://example.com/success_url.php',
'public_key' => 'your_public_key',
'site_logo' => 'https://webvola.com/assets/images/logoIcon/logo.png',
'checkout_theme' => 'dark',
'customer_name' => 'John Doe',
'customer_email' => 'john@mail.com',
];
// live end point
$url = "https://webvola.com/payment/initiate";
// test end point
// $url = "https://webvola.com/sandbox/payment/initiate";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
// $result contains the response back.
?>
import requests
url = "https://webvola.com/payment/initiate"
# For test: url = "https://webvola.com/sandbox/payment/initiate"
payload = {
"identifier": "DFU80XZIKS",
"currency": "USD",
"amount": 100.00,
"details": "Purchase T-shirt",
"ipn_url": "http://example.com/ipn_url.php",
"cancel_url": "http://example.com/cancel_url.php",
"success_url": "http://example.com/success_url.php",
"public_key": "your_public_key",
"site_logo": "https://webvola.com/assets/images/logoIcon/logo.png",
"checkout_theme": "dark",
"customer_name": "John Doe",
"customer_email": "john@mail.com"
}
response = requests.post(url, data=payload)
print(response.json())
/* Requires libcurl */
#include <curl/curl.h>
int main() {
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://webvola.com/payment/initiate");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "identifier=DFU80XZIKS¤cy=USD&amount=100.00&details=Purchase+T-shirt&ipn_url=http://example.com/ipn_url.php&cancel_url=http://example.com/cancel_url.php&success_url=http://example.com/success_url.php&public_key=your_public_key&site_logo=https://webvola.com/assets/images/logoIcon/logo.png&checkout_theme=dark&customer_name=John+Doe&customer_email=john@mail.com");
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}
using System.Net.Http;
using System.Collections.Generic;
var client = new HttpClient();
var values = new Dictionary<string, string> {
{"identifier", "DFU80XZIKS"},
{"currency", "USD"},
{"amount", "100.00"},
{"details", "Purchase T-shirt"},
{"ipn_url", "http://example.com/ipn_url.php"},
{"cancel_url", "http://example.com/cancel_url.php"},
{"success_url", "http://example.com/success_url.php"},
{"public_key", "your_public_key"},
{"site_logo", "https://webvola.com/assets/images/logoIcon/logo.png"},
{"checkout_theme", "dark"},
{"customer_name", "John Doe"},
{"customer_email", "john@mail.com"}
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://webvola.com/payment/initiate", content);
var responseString = await response.Content.ReadAsStringAsync();
// Use cpr (https://github.com/libcpr/cpr)
#include <cpr/cpr.h>
int main() {
auto r = cpr::Post(cpr::Url{"https://webvola.com/payment/initiate"},
cpr::Payload{
{"identifier", "DFU80XZIKS"},
{"currency", "USD"},
{"amount", "100.00"},
{"details", "Purchase T-shirt"},
{"ipn_url", "http://example.com/ipn_url.php"},
{"cancel_url", "http://example.com/cancel_url.php"},
{"success_url", "http://example.com/success_url.php"},
{"public_key", "your_public_key"},
{"site_logo", "https://webvola.com/assets/images/logoIcon/logo.png"},
{"checkout_theme", "dark"},
{"customer_name", "John Doe"},
{"customer_email", "john@mail.com"}
});
std::cout << r.text << std::endl;
}
package main
import (
"net/http"
"net/url"
"strings"
"io/ioutil"
"fmt"
)
func main() {
data := url.Values{
"identifier": {"DFU80XZIKS"},
"currency": {"USD"},
"amount": {"100.00"},
"details": {"Purchase T-shirt"},
"ipn_url": {"http://example.com/ipn_url.php"},
"cancel_url": {"http://example.com/cancel_url.php"},
"success_url": {"http://example.com/success_url.php"},
"public_key": {"your_public_key"},
"site_logo": {"https://webvola.com/assets/images/logoIcon/logo.png"},
"checkout_theme": {"dark"},
"customer_name": {"John Doe"},
"customer_email": {"john@mail.com"},
}
resp, _ := http.Post(
"https://webvola.com/payment/initiate",
"application/x-www-form-urlencoded",
strings.NewReader(data.Encode()))
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
POST /payment/initiate HTTP/1.1
Host: webvola.com
Content-Type: application/x-www-form-urlencoded
identifier=DFU80XZIKS¤cy=USD&amount=100.00&details=Purchase+T-shirt&ipn_url=http://example.com/ipn_url.php&cancel_url=http://example.com/cancel_url.php&success_url=http://example.com/success_url.php&public_key=your_public_key&site_logo=https://webvola.com/assets/images/logoIcon/logo.png&checkout_theme=dark&customer_name=John+Doe&customer_email=john@mail.com
import java.net.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("https://webvola.com/payment/initiate");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
String data = "identifier=DFU80XZIKS¤cy=USD&amount=100.00&details=Purchase+T-shirt&ipn_url=http://example.com/ipn_url.php&cancel_url=http://example.com/cancel_url.php&success_url=http://example.com/success_url.php&public_key=your_public_key&site_logo=https://webvola.com/assets/images/logoIcon/logo.png&checkout_theme=dark&customer_name=John+Doe&customer_email=john@mail.com";
OutputStream os = con.getOutputStream();
os.write(data.getBytes());
os.flush();
os.close();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
}
}
fetch("https://webvola.com/payment/initiate", {
method: "POST",
headers: {"Content-Type": "application/x-www-form-urlencoded"},
body: "identifier=DFU80XZIKS¤cy=USD&amount=100.00&details=Purchase+T-shirt&ipn_url=http://example.com/ipn_url.php&cancel_url=http://example.com/cancel_url.php&success_url=http://example.com/success_url.php&public_key=your_public_key&site_logo=https://webvola.com/assets/images/logoIcon/logo.png&checkout_theme=dark&customer_name=John+Doe&customer_email=john@mail.com"
})
.then(response => response.json())
.then(data => console.log(data));
{
"identifier": "DFU80XZIKS",
"currency": "USD",
"amount": 100.00,
"details": "Purchase T-shirt",
"ipn_url": "http://example.com/ipn_url.php",
"cancel_url": "http://example.com/cancel_url.php",
"success_url": "http://example.com/success_url.php",
"public_key": "your_public_key",
"site_logo": "https://webvola.com/assets/images/logoIcon/logo.png",
"checkout_theme": "dark",
"customer_name": "John Doe",
"customer_email": "john@mail.com"
}
// Uses OkHttp
import okhttp3.*
val client = OkHttpClient()
val body = FormBody.Builder()
.add("identifier", "DFU80XZIKS")
.add("currency", "USD")
.add("amount", "100.00")
.add("details", "Purchase T-shirt")
.add("ipn_url", "http://example.com/ipn_url.php")
.add("cancel_url", "http://example.com/cancel_url.php")
.add("success_url", "http://example.com/success_url.php")
.add("public_key", "your_public_key")
.add("site_logo", "https://webvola.com/assets/images/logoIcon/logo.png")
.add("checkout_theme", "dark")
.add("customer_name", "John Doe")
.add("customer_email", "john@mail.com")
.build()
val request = Request.Builder()
.url("https://webvola.com/payment/initiate")
.post(body)
.build()
val response = client.newCall(request).execute()
println(response.body?.string())
(* Use Cohttp_lwt_unix *)
open Cohttp_lwt_unix
open Cohttp
open Lwt.Infix
let () =
let uri = Uri.of_string "https://webvola.com/payment/initiate" in
let headers = Header.init_with "Content-Type" "application/x-www-form-urlencoded" in
let body = "identifier=DFU80XZIKS¤cy=USD&amount=100.00&details=Purchase+T-shirt&ipn_url=http://example.com/ipn_url.php&cancel_url=http://example.com/cancel_url.php&success_url=http://example.com/success_url.php&public_key=your_public_key&site_logo=https://webvola.com/assets/images/logoIcon/logo.png&checkout_theme=dark&customer_name=John+Doe&customer_email=john@mail.com" in
let _ =
Client.post ~headers ~body:(Cohttp_lwt.Body.of_string body) uri
>>= fun (resp, body) ->
Cohttp_lwt.Body.to_string body >|= fun body -> print_endline body
in ()
// Uses NSURLSession
NSURL *url = [NSURL URLWithString:@"https://webvola.com/payment/initiate"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
NSString *body = @"identifier=DFU80XZIKS¤cy=USD&amount=100.00&details=Purchase+T-shirt&ipn_url=http://example.com/ipn_url.php&cancel_url=http://example.com/cancel_url.php&success_url=http://example.com/success_url.php&public_key=your_public_key&site_logo=https://webvola.com/assets/images/logoIcon/logo.png&checkout_theme=dark&customer_name=John+Doe&customer_email=john@mail.com";
[request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}];
[task resume];
$url = "https://webvola.com/payment/initiate"
$body = @{
identifier = "DFU80XZIKS"
currency = "USD"
amount = 100.00
details = "Purchase T-shirt"
ipn_url = "http://example.com/ipn_url.php"
cancel_url = "http://example.com/cancel_url.php"
success_url = "http://example.com/success_url.php"
public_key = "your_public_key"
site_logo = "https://webvola.com/assets/images/logoIcon/logo.png"
checkout_theme = "dark"
customer_name = "John Doe"
customer_email = "john@mail.com"
}
Invoke-RestMethod -Uri $url -Method Post -Body $body
library(httr)
url <- "https://webvola.com/payment/initiate"
body <- list(
identifier = "DFU80XZIKS",
currency = "USD",
amount = 100.00,
details = "Purchase T-shirt",
ipn_url = "http://example.com/ipn_url.php",
cancel_url = "http://example.com/cancel_url.php",
success_url = "http://example.com/success_url.php",
public_key = "your_public_key",
site_logo = "https://webvola.com/assets/images/logoIcon/logo.png",
checkout_theme = "dark",
customer_name = "John Doe",
customer_email = "john@mail.com"
)
response <- POST(url, body = body, encode = "form")
content(response, "text")
import Foundation
let url = URL(string: "https://webvola.com/payment/initiate")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
let body = "identifier=DFU80XZIKS¤cy=USD&amount=100.00&details=Purchase+T-shirt&ipn_url=http://example.com/ipn_url.php&cancel_url=http://example.com/cancel_url.php&success_url=http://example.com/success_url.php&public_key=your_public_key&site_logo=https://webvola.com/assets/images/logoIcon/logo.png&checkout_theme=dark&customer_name=John+Doe&customer_email=john@mail.com"
request.httpBody = body.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request) { data, _, _ in
if let data = data { print(String(data: data, encoding: .utf8)!) }
}
task.resume()
(require '[clj-http.client :as client])
(client/post "https://webvola.com/payment/initiate"
{:form-params {:identifier "DFU80XZIKS"
:currency "USD"
:amount 100.00
:details "Purchase T-shirt"
:ipn_url "http://example.com/ipn_url.php"
:cancel_url "http://example.com/cancel_url.php"
:success_url "http://example.com/success_url.php"
:public_key "your_public_key"
:site_logo "https://webvola.com/assets/images/logoIcon/logo.png"
:checkout_theme "dark"
:customer_name "John Doe"
:customer_email "john@mail.com"}})
//Error Response.
{
"error": "true",
"message": "Invalid api key"
}
//Success Response.
{
"success": "ok",
"message": "Payment Initiated. Redirect to url.",
"url":"http://example.com/initiate/payment/checkout?payment_id=eJSAASDxdrt4DASDASVNASJA7893232432cvmdsamnvASF"
}
Validate The Payment and IPN
This section describes the process to get your instant payment notification.
To initiate the payment follow the example code and be careful with the perameters. You will need to make request with these following API end points.
End Point: Your business application ipn url.
Request Method: POST
You will get following parameters below.
Param Name | Description |
---|---|
status | Payment success status. |
identifier | Identifier is basically for identify payment at your end. |
signature | A hash signature to verify your payment at your end. |
data | Data contains some basic information with charges, amount, currency, payment transaction id etc. |
<?php
$status = $_POST['status'];
$signature = $_POST['signature'];
$identifier = $_POST['identifier'];
$data = $_POST['data'];
$customKey = $data['amount'].$identifier;
$secret = 'YOUR_SECRET_KEY';
$mySignature = strtoupper(hash_hmac('sha256', $customKey , $secret));
$myIdentifier = 'YOUR_GIVEN_IDENTIFIER';
if($status == "success" && $signature == $mySignature && $identifier == $myIdentifier){
// your operation logic
}
?>
import hashlib
import hmac
status = request.form['status']
signature = request.form['signature']
identifier = request.form['identifier']
data = request.form['data'] # Should be a dict
custom_key = str(data['amount']) + identifier
secret = b'YOUR_SECRET_KEY'
my_signature = hmac.new(secret, custom_key.encode(), hashlib.sha256).hexdigest().upper()
my_identifier = 'YOUR_GIVEN_IDENTIFIER'
if status == "success" and signature == my_signature and identifier == my_identifier:
# your operation logic
pass
const crypto = require('crypto');
const status = req.body.status;
const signature = req.body.signature;
const identifier = req.body.identifier;
const data = req.body.data; // {amount: ...}
const customKey = data.amount + identifier;
const secret = 'YOUR_SECRET_KEY';
const mySignature = crypto.createHmac('sha256', secret).update(customKey).digest('hex').toUpperCase();
const myIdentifier = 'YOUR_GIVEN_IDENTIFIER';
if (status === "success" && signature === mySignature && identifier === myIdentifier) {
// your operation logic
}
# For local manual test, to generate HMAC:
custom_key="100.00YOUR_GIVEN_IDENTIFIER"
secret="YOUR_SECRET_KEY"
signature=$(echo -n $custom_key | openssl dgst -sha256 -hmac $secret | sed 's/^.* //; s/[a-z]/\U&/g')
echo $signature
require 'openssl'
status = params['status']
signature = params['signature']
identifier = params['identifier']
data = params['data']
custom_key = "#{data['amount']}#{identifier}"
secret = 'YOUR_SECRET_KEY'
my_signature = OpenSSL::HMAC.hexdigest('sha256', secret, custom_key).upcase
my_identifier = 'YOUR_GIVEN_IDENTIFIER'
if status == "success" && signature == my_signature && identifier == my_identifier
# your operation logic
end
#include <openssl/hmac.h>
#include <string.h>
const char *status = getenv("STATUS");
const char *signature = getenv("SIGNATURE");
const char *identifier = getenv("IDENTIFIER");
const char *amount = getenv("AMOUNT"); // from data
char customKey[256];
sprintf(customKey, "%s%s", amount, identifier);
const char *secret = "YOUR_SECRET_KEY";
unsigned char* result;
unsigned int len = 32;
result = HMAC(EVP_sha256(), secret, strlen(secret), (unsigned char*)customKey, strlen(customKey), NULL, NULL);
// Convert result to hex uppercase and compare with received signature.
using System.Security.Cryptography;
using System.Text;
string status = Request.Form["status"];
string signature = Request.Form["signature"];
string identifier = Request.Form["identifier"];
string amount = Request.Form["amount"]; // from data
string customKey = amount + identifier;
string secret = "YOUR_SECRET_KEY";
using (var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secret)))
{
var hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(customKey));
var mySignature = BitConverter.ToString(hash).Replace("-", "").ToUpper();
if (status == "success" && signature == mySignature && identifier == "YOUR_GIVEN_IDENTIFIER") {
// your operation logic
}
}
// Requires OpenSSL
#include <openssl/hmac.h>
#include <string>
// Build customKey and secret as above, use HMAC like in C.
(require '[clojure.data.codec.base64 :as b64])
(import '[javax.crypto Mac]
'[javax.crypto.spec SecretKeySpec])
(defn hmac-sha256 [secret data]
(let [mac (doto (Mac/getInstance "HmacSHA256")
(.init (SecretKeySpec. (.getBytes secret) "HmacSHA256")))]
(-> (.doFinal mac (.getBytes data))
(map #(format "%02X" (bit-and % 0xff)))
(apply str))))
; compare status, signature, etc.
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
)
status := r.FormValue("status")
signature := r.FormValue("signature")
identifier := r.FormValue("identifier")
amount := r.FormValue("amount") // from data
customKey := amount + identifier
secret := []byte("YOUR_SECRET_KEY")
mac := hmac.New(sha256.New, secret)
mac.Write([]byte(customKey))
mySignature := strings.ToUpper(hex.EncodeToString(mac.Sum(nil)))
if status == "success" && signature == mySignature && identifier == "YOUR_GIVEN_IDENTIFIER" {
// your operation logic
}
POST /ipn HTTP/1.1
Host: yourserver.com
Content-Type: application/x-www-form-urlencoded
status=success&signature=GENERATED_SIGNATURE&identifier=YOUR_GIVEN_IDENTIFIER&data[amount]=100.00
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.Formatter;
String status = request.getParameter("status");
String signature = request.getParameter("signature");
String identifier = request.getParameter("identifier");
String amount = request.getParameter("amount");
String customKey = amount + identifier;
String secret = "YOUR_SECRET_KEY";
SecretKeySpec keySpec = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(keySpec);
byte[] hash = mac.doFinal(customKey.getBytes());
StringBuilder sb = new StringBuilder();
for (byte b : hash) sb.append(String.format("%02X", b));
String mySignature = sb.toString();
if (status.equals("success") && signature.equals(mySignature) && identifier.equals("YOUR_GIVEN_IDENTIFIER")) {
// your operation logic
}
// See Node.js above; in browser JS, use SubtleCrypto API for HMAC if needed
{
"status": "success",
"signature": "GENERATED_SIGNATURE",
"identifier": "YOUR_GIVEN_IDENTIFIER",
"data": {
"amount": "100.00"
}
}
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
val status = request.getParameter("status")
val signature = request.getParameter("signature")
val identifier = request.getParameter("identifier")
val amount = request.getParameter("amount")
val customKey = "$amount$identifier"
val secret = "YOUR_SECRET_KEY"
val hmacSha256 = Mac.getInstance("HmacSHA256")
val keySpec = SecretKeySpec(secret.toByteArray(), "HmacSHA256")
hmacSha256.init(keySpec)
val hash = hmacSha256.doFinal(customKey.toByteArray())
val mySignature = hash.joinToString("") { "%02X".format(it) }
if (status == "success" && signature == mySignature && identifier == "YOUR_GIVEN_IDENTIFIER") {
// your operation logic
}
(* See digestif library for HMAC SHA256 in OCaml *)
// Use CCHmac for HMAC SHA256
$status = $Request.Form.status
$signature = $Request.Form.signature
$identifier = $Request.Form.identifier
$amount = $Request.Form.amount # from data
$customKey = $amount + $identifier
$secret = 'YOUR_SECRET_KEY'
$hmacsha256 = New-Object System.Security.Cryptography.HMACSHA256
$hmacsha256.Key = [Text.Encoding]::UTF8.GetBytes($secret)
$hashBytes = $hmacsha256.ComputeHash([Text.Encoding]::UTF8.GetBytes($customKey))
$mySignature = [BitConverter]::ToString($hashBytes) -replace "-", "" -replace "[a-z]", {$args[0].ToUpper()}
if ($status -eq "success" -and $signature -eq $mySignature -and $identifier -eq "YOUR_GIVEN_IDENTIFIER") {
# your operation logic
}
library(openssl)
status <- Sys.getenv("STATUS")
signature <- Sys.getenv("SIGNATURE")
identifier <- Sys.getenv("IDENTIFIER")
amount <- Sys.getenv("AMOUNT") # from data
custom_key <- paste0(amount, identifier)
secret <- "YOUR_SECRET_KEY"
my_signature <- toupper(hmac_sha256(custom_key, secret))
if (status == "success" && signature == my_signature && identifier == "YOUR_GIVEN_IDENTIFIER") {
# your operation logic
}
import CryptoKit
let status = ... // get from POST
let signature = ... // get from POST
let identifier = ... // get from POST
let amount = ... // get from POST data
let customKey = "\(amount)\(identifier)"
let key = SymmetricKey(data: "YOUR_SECRET_KEY".data(using: .utf8)!)
let hmac = HMAC<SHA256>.authenticationCode(for: customKey.data(using: .utf8)!, using: key)
let mySignature = hmac.map { String(format: "%02X", $0) }.joined()
if status == "success" && signature == mySignature && identifier == "YOUR_GIVEN_IDENTIFIER" {
// your operation logic
}