Refund API
In the instance where a customer requests a refund, the following request and response objects are initiated to complete the refund workflow.

- The customer approaches the Point-of-sale manager with a paper receipt or a barcode generated by their digital wallet.
- The POS manager will scan the barcode or paper receipt by selecting the “refund” button.
- The Point-of-Sale will use the transaction number to identify the exact details of the original purchase and call Pockyt’s /refund API which will request the digital wallet server to refund the payment originally made by the customer
- POST: https://mapi.yuansfer.com/app-data-search/v3/refund
- The wallet server will reimburse the transaction amount to the customer as well as alert the latter about the refund via a notification.
curl -XPOST -H "Content-type: application/json" -d '{
"merchantNo": "200043",
"storeNo": "300014",
"verifySign": "dd81f7781603bec48ae2c6a9ac758bf2",
"refundAmount": "0.01",
"currency": "USD",
"settleCurrency": "USD",
"transactionNo": "297553638301777927",
"refundReference": "refund2020101305"
}' 'https://mapi.yuansfer.com/app-data-search/v3/refund'
Parameter | Type | Description |
---|---|---|
merchantNo | string | Required-the merchant’s ID |
storeNo | string | Required- the store’s ID |
refundAmount | string | Required- the amount that has to be refunded |
currency | number | Required - The supported settlement currency "USD". |
settleCurrency | number | Required - The supported settlement currency "USD". |
transactionNo | string | Required - transaction number of original sale |
reference | string | Required - reference number of original sale |
refundReference | string | Optional - ID of reference transaction in Point-of-Sale |
verifySign | string | Required- the parameter signature |
{
"result": {
"amount": "0.01",
"currency": "USD",
"reference": "test20200101306",
"refundAmount": "0.01",
"refundReference": "refund2020101305",
"refundTransactionNo": "297553638302358781",
"settleCurrency": "USD",
"status": "success",
"transactionNo": "297553638301777927"
},
"ret_msg": "refund success ",
"ret_code": "000100"
}
Parameter | Type | Description |
---|---|---|
amount | number | The transaction amount |
refundAmount | number | The transaction refund amount. This parameter will be returned only when the payment order contains a 'Amount'. |
currency | string | The supported transaction currencies are "USD" "CNY". |
settleCurrency | string | The supported settlement currencies are "USD". |
status | string | The status of the refund |
reference | string | The Invoice Number of the transaction in the merchant’s system |
refundReference | string | The ID of the refund transaction in the merchant’s system |
refundTransactionNo | string | The ID of the refund transaction in the Pockyt system |
transactionNo | string | The Transaction ID in the Pockyt system |
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