Query API
This API is used for polling transaction results, researching transactions for refunds, and generating custom reports
The /trans-query API is a versatile tool that caters to various payment scenarios, whether it's in the realm of ecommerce or in-store transactions. Its primary purpose is to enable users to retrieve transaction information and perform essential actions such as polling transaction results, researching transactions for potential refunds, or generating custom reports.
Regardless of the payment context, whether it's an online purchase, a point-of-sale transaction, or any other payment scenario, the /trans-query API serves as a robust solution to retrieve and manage transaction information. It empowers businesses to access real-time transaction details, monitor payment statuses, and efficiently handle refund processes. Additionally, it allows users to leverage transaction data for comprehensive reporting and analysis, helping businesses make informed decisions based on valuable insights.
curl -XPOST -H "Content-type: application/json" -d '{
"merchantNo": "200043",
"storeNo": "300014",
"transactionNo": "297553638300708562",
"verifySign": "0df745088d7202a6d186596acdc82c6a"
}' 'https://mapi.yuansfer.com/app-data-search/v3/tran-query'
Parameter | Type | Description |
---|---|---|
merchantNo | string | Required-merchant’s ID |
storeNo | string | Required-store ID |
transactionNo | string | Required - transaction number of original sale |
reference | string | Required - reference number of original sale |
verifySign | string | Required-the parameter signature |
{
"result": {
"amount": "10.00",
"currency": "CNY",
"reference": "test202001011305",
"settleCurrency": "USD",
"status": "success",
"transactionNo": "297553638300708562",
"transactionType": "payment"
},
"ret_code": "000100",
"ret_msg": "query success "
}
Parameter | Type | Description |
---|---|---|
transactionNo | string | The Transaction ID in the Pockyt system |
reference | string | The Invoice Number of the transaction in the merchant’s system |
amount | number | The transaction amount |
status | string | The status of the transaction |
currency | string | The supported transaction currency is "USD", "CNY". |
settleCurrency | string | The supported settlement currency is "USD", "CNY". |
transactionType | string | The type will be either "payment" or "refund". |
Parameter | Type | Description |
---|---|---|
refundTransactionId | string | The ID of the refund transaction in the Pockyt system |
refundReference | string | The ID of the refund transaction in the merchant’s system |
refundAmount | string | The transaction refund amount. This parameter will be returned only when the payment order contains a 'Amount'. |
refundRmbAmount | string | The transaction refund amount of CNY. This parameter will be returned only when the payment order contains a 'rmbAmount'. |
currency | string | The supported transaction currency is "USD", "CNY". |
settleCurrency | string | The supported settlement currency is "USD", "CNY". |
1
// POCKYT TRANSACT QUERY AFTER AND ADD TO CHECK RESULTS API sandbox example
2
// Import crypto for MD5 hash calculation
3
4
var crypto = require('crypto');
5
6
// Assign all Sanbox parameters
7
8
varURL="https://mapi.yuansfer.yunkeguan.com/app-data-search/v3/tran-query" ;
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
transactionNo: "316129873376769782",
18
// reference: No reference in this case
19
}
20
21
// Calculate the VeriSign signature:
22
23
var MySignature = CalculateSignature(MyToken, myPOSParamObject)
24
25
// Add the signature to the POS parametes so we
26
// can use it in the body of the API call
27
28
var MyPocketParamObject = {
29
merchantNo: myPOSParamObject.merchantNo,
30
storeNo: myPOSParamObject.storeNo,
31
verifySign: MySignature,
32
// transactionNo: myPOSParamObject.transactionNo,
33
// reference: myPOSParamObject.reference
34
transactionNo: myPOSParamObject.transactionNo
35
}
36
37
// function that calculates the signature according to Pockyt rules
38
function CalculateSignature(token,parameters)
39
{
40
// calculate the hash value of the token
41
42
var ApiTokenHashvalue = crypto.createHash('md5').update(token).digest("hex")
43
44
// order parameters alfabetically
45
var SortedParams = sortObj(parameters);
46
47
// Concatenate: add '&' between key and value pair and replace : for =
48
var MyString = '' ;
49
for (const [key, value] of Object.entries(SortedParams)) {
50
MyString += (`${key}=${value}&`);}
51
52
// add hash value of token at the and of the string
53
MyString += ApiTokenHashvalue ;
54
55
// create the verifySign
56
57
const MySignature = crypto.createHash('md5').update(MyString).digest("hex");
58
59
return MySignature;
60
61
62
// alphabetical sort helper function
63
function sortObj(obj) {
64
return Object.keys(obj).sort().reduce(function (result, key) {
65
result[key] = obj[key];
66
return result;
67
}, {});
68
}
69
70
// Prepare JASON that will be used in the body of the API call
71
72
var MyPocketParamJason = JSON.stringify(MyPocketParamObject);
73
console.log(MyPocketParamJason);
74
75
fetch(URL, {
76
method: "POST",
77
headers: {
78
"Content-Type": "application/json"
79
},
80
body: MyPocketParamJason
81
})
82
.then(response => response.json())
83
.then(data => console.log(data))
84
.catch(error => console.error(error));
Last modified 5mo ago