Transaction Query
TranQuery
POST https://api.2pay.co/online/v1/tran-query
This API is used to query transaction details via transaction ID in the merchant services system.
Request Body
merchantNo*
String
ID of a merchant.
verifySign*
String
The merchants should verify the signature to ensure the response is from the server and not modified by any others.
reference*
String
The reference number of a trasaction in the merchant services system.
{
"ret_code": "000100",
"ret_msg": "success",
"result": {
"transactionNo": "0f72c718-4a33-47ca-81fe-c228p3a8d08d",
"reference": "8678528c-8c1c-4ff7-79a3-4f32afa6e2c6",
"amount": 1.99,
"status": "pending",
"currency": "USD",
"settleCurrency": "USD"
}
}{
"ret_code": "000022",
"ret_msg": "order not found"
}Response
Parameter
Type
Description
ret_msg
String
Return response message.
ret_code
String
Return response status code.
Result Object
Parameter
Type
Description
amount
String
The amount of a transaction.
This parameter will be returned when the transaction currency is "USD".
currency
String
Currency supported by 2Pay is "USD".
transactionNo
String
The transaction ID of 2Pay system.
reference
String
The reference number of a trasaction in the merchant services system.
status
String
Transaction status.
settleCurrency
String
Currency code from ISO 4217.
Potential value:"USD".
curl --location --request POST 'https://api.2pay.co//app-data-search/v1/tran-query' \
--header 'Content-Type: application/json' \
--data-raw '{
"merchantNo": "M1659370901281867",
"reference": "8677528c-8b1c-4bf7-79a3-9291jwil",
"verifySign": "{{verifySign}}"
}'import request from 'request'
import CryptoJS from 'crypto-js'
const token = 'yjmsy9vwjkajs21qqt4psc2o8y3rr5q'
const baseUrl = 'https://api.2pay.co'
const params = {
merchantNo: 'M1653001221867',
reference: '2991221b-4cdc-ba0f-7e121fc2beb2',
}
function buildAndSignParams(params) {
let sortArray = [];
Object.keys(params).sort().forEach(k => {
if (k == 'verifySign') {
return
}
if(params[k] || params[k] === false) {
sortArray.push(`${k}=${params[k]}`)
}
});
sortArray.push(CryptoJS.MD5(token).toString());
console.log('MD5 Token', CryptoJS.MD5(token).toString())
const tempStr = sortArray.join('&');
console.log('temStr:', tempStr)
const verifySign = CryptoJS.MD5(tempStr).toString();
console.log('verifySign', verifySign)
return {
...params,
verifySign
}
}
const json = await request.post({
url: BaseUrl + 'app-data-search/v1/tran-query',
form: buildAndSignParams(params)
}); <?php
function securepayReferenceQuery()
{
$url = 'https://api.2pay.co/app-data-search/v1/tran-query';
$token = '5cbfb079f15b150122221017086d77a';
$params = [
'merchantNo' => 'M2091210043',
'reference' => 'kasd-test201218070101'
];
ksort($params, SORT_STRING);
$str = '';
foreach ($params as $k => $v) {
$str .= $k . '=' . $v . '&';
}
$params['verifySign'] = md5($str . md5($token));
echo 'verifySign:', $params['verifySign'];
echo "\n";
$ch = curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($params),
));
$result = curl_exec($ch);
curl_exec($ch);
echo $result;
echo "\n";
return json_decode($result, true);
}
securepayReferenceQuery();
?>package main
import (
"fmt"
pay "github.com/2pay-co/golang-sdk"
"github.com/gogf/gf/v2/os/gtime"
)
func main() {
pay := NewPay("MerchantNo", "Token")
resp, err := pay.Query("2022-08-09 18:39:03")
t.Logf("resp: %#v, err: %v", resp, err)
}TranQueryRequest trq = new TranQueryRequest();
trq.setReference("f194b314-298b-4023-970e-a8701f77316d");
TranQueryResponse tfs = client.execute(trq);
System.out.println(JSONObject.fromObject(tfs)); Last updated