· 6 years ago · May 16, 2019, 03:40 PM
1var requestBody = {
2"orderId": "SampleOrderId1",
3"amount": 20
4};
5
6var hash = CryptoJS.HmacSHA512(JSON.stringify(requestBody), "SECRETKEY");
7var hashInHex = CryptoJS.enc.Hex.stringify(hash);
8
9$.ajax({
10url: "https://api.paymate.io/v1/transaction/create",
11contentType: "application/json",
12headers:{
13"apikey": "APIKEY",
14"hmac": hashInHex
15},
16dataType: "json",
17data: JSON.stringify(requestBody),
18type: 'POST'
19}).done(function (response){
20
21/* Receive response and send client generated payment address
22{
23"success": true,
24"paymentAddr": "1CKnVshDuganQDoxo4CU9Swf3SzDUjP5MH",
25"orderId": "SampleOrderId1",
26"amount": 20,
27"createdAt": 1557229082
28}
29*/
30}).fail(function (response){
31
32});