Cancel API
This API allows for canceling a payment transaction in either use case when the transaction is abandoned before submission, ensuring that merchants can efficiently manage their transactions.

- The customer uses a digital wallet to pay for the items of purchase.
- The merchant selects “digital wallet” and the Point-of-Sale calls Pockyt’s /add API to generate a transaction object.
curl -XPOST -d '{
"merchantNo": "200043",
"storeNo": "300014",
"verifySign": "c29c8240bf99510d4d53a0ca36f9c135",
"amount": "13",
"currency": "USD",
"settleCurrency": "USD",
"reference": "test202001011206"
}' 'https://mapi.yuansfer.com/app-instore/v3/add'
Parameter | Type | Description |
---|---|---|
merchantNo | string | Required-the merchant’s ID |
storeNo | string | Required- the store ID |
transactionNo | string | Required - transaction number of original sale |
reference | string | Required - reference number of original sale |
verifySign | string | Required- the parameter signature |
- The customer finds that they are unable to generate a QR code for the merchant to scan due to a lack of connectivity (or another issue).
- The merchant will then select “cancel” in the Point-of-Sale system by calling Pockyt’s /cancel API. The cancel API allows for canceling a payment transaction. This applies to transactions that are abandoned before submission.
curl -XPOST -H "Content-type: application/json" -d '{
"merchantNo": "200043",
"storeNo": "300014",
"verifySign": "dd81f7781603bec48ae2c6a9ac758bf2",
"transactionNo": "297553638301777927",
}' 'https://mapi.yuansfer.com/app-data-search/v3/cancel'
Parameter | Type | Description |
---|---|---|
amount | number | The transaction amount |
currency | string | The supported transaction currency is "USD","CNY". |
reference | string | The Invoice Number of the transaction in the merchant's system |
status | string | The status of the refund |
transactionNo | string | The Transaction ID in the Pockyt system |
- Pockyt notifies the digital wallet server to abandon the transaction.
- The digital wallet server responds by canceling the transaction and notifying Pockyt of the cancellation status.
- Pockyt will then relay the information to the Point-of-Sale
1
// POCKYT ADD API sandbox example
2
// Import crypto for MD5 hash calculation
3
4
var crypto = require('crypto');
5
6
// Assign all Sanbox parameters
7
8
var URL = "https://mapi.yuansfer.yunkeguan.com/app-data-search/v3/refund" ;
9
var merchantNo = "200043" ;
10
var storeNo = "303660" ;
11
var MyToken = "359c05eb811c7c8576f4a8a277dc6f6b" ;
12
13
// construct POS fields and assign to object
14
var myPOSParamObject = {
15
merchantNo: merchantNo,
16
storeNo: storeNo,
17
refundAmount: "10",
18
currency: "USD",
19
settleCurrency: "USD",
20
transactionNo: "316129873376769782",
21
}
22
23
// Calculate the VeriSign signature:
24
25
var MySignature = CalculateSignature(MyToken, myPOSParamObject)
26
27
// Add the signature to the POS parametes so we
28
// can use it in the body of the API call
29
30
var MyPocketParamObject = {
31
merchantNo: myPOSParamObject.merchantNo,
32
storeNo: myPOSParamObject.storeNo,
33
verifySign: MySignature,
34
refundAmount: myPOSParamObject.refundAmount,
35
currency: myPOSParamObject.currency,
36
settleCurrency: myPOSParamObject.settleCurrency,
37
transactionNo: myPOSParamObject.transactionNo
38
}
39
40
// function that calculates the signature according to Pockyt rules
41
function CalculateSignature(token,parameters)
42
{
43
// calculate the hash value of the token
44
45
var ApiTokenHashvalue = crypto.createHash('md5').update(token).digest("hex")
46
47
// order parameters alfabetically
48
var SortedParams = sortObj(parameters);
49
50
// Concatenate: add '&' between key and value pair and replace : for =
51
var MyString = '' ;
52
for (const [key, value] of Object.entries(SortedParams)) {
53
MyString += (`${key}=${value}&`);}
54
55
// add hash value of token at the and of the string
56
MyString += ApiTokenHashvalue ;
57
58
// create the verifySign
59
60
const MySignature = crypto.createHash('md5').update(MyString).digest("hex");
61
62
return MySignature;
63
64
65
// algabetical sort helper function
66
function sortObj(obj) {
67
return Object.keys(obj).sort().reduce(function (result, key) {
68
result[key] = obj[key];
69
return result;
70
}, {});
71
}
72
}
73
74
// Prepare JASON that will be used in the body of the API call
75
76
var MyPocketParamJason = JSON.stringify(MyPocketParamObject);
77
console.log(MyPocketParamJason);
78
79
fetch(URL, {
80
method: "POST",
81
headers: {
82
"Content-Type": "application/json"
83
},
84
body: MyPocketParamJason
85
})
86
.then(response => response.json())
87
.then(data => console.log(data))
88
.catch(error => console.error(error));
Last modified 5mo ago