NAV Navbar
Logo
shell php java go

Welcome

Welcome to Yuansfer POS API Developer Center.
点击查看中文文档.

API Basics

The Yuansfer offers RESTful interface to help you create a payments solution that meets your needs. The API enables you to incorporate Chinese payment methods including WeChat Pay, China UnionPay, and Alipay. You can enable customers to make Chinese online and mobile payments with only a few clicks.

Get Started

The Yuansfer REST APIs use HTTP verbs and a RESTful endpoint structure. JSON is returned by all API responses, including errors.

Authentication and Authorization

You can get your API credentials in the Dashboard. API credentials (IE. API key, Merchant ID, store admin ID) convey many privileges for you, so be sure to keep them secure! Do not share your API keys in publicly accessible areas such as GitHub, clientside code, and so forth.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

Signature Algorithm

The result of the example:

{
    "verifySign":"4f0cc35728849e4b4aa4a176f4a5edac"
}
{
    "verifySign":"4f0cc35728849e4b4aa4a176f4a5edac"
}
{
    "verifySign":"4f0cc35728849e4b4aa4a176f4a5edac"
}
{
    "verifySign":"4f0cc35728849e4b4aa4a176f4a5edac"
}
<?php
function getVerifySign()
{
    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'date' => '20180620',
        'currency' => 'USD',
        'vendor' => 'alipay'
    ];

    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";

}

getVerifySign();

?>
import java.util.Map;
import java.util.TreeMap;
import org.json.simple.JSONObject;
import com.nengjian.yuansfer.pos.utils.MapUrlUtils;
import com.nengjian.yuansfer.pos.utils.Md5Utils;

public class VerifySignExample {

    public static void main(String[] args) {
        Map<String, Object> map = new TreeMap<String, Object>();
        String yuansferToken = "59600f2a9ad644c6a9570233560cc94e";
        map.put("merchantNo", "200043");
        map.put("storeNo", "300014");
        map.put("storeAdminNo", "3000140001");
        map.put("amount","0.01");
        VerifySignExample example = new VerifySignExample();
        String verifySign = example.getYuansferVerifySign(map, yuansferToken);
        JSONObject json = new JSONObject();
        json.put("verifySign", verifySign);
        System.out.println(json);
    }

    public String getYuansferVerifySign(final Map<String, Object> map, final String yuansferToken) {
        String calculateValue = commonGetVerifySign(map, yuansferToken);
        return calculateValue;
    }

    private String commonGetVerifySign(final Map<String, Object> map, final String yuansferToken) {
        Map<String, Object> treeMap = new TreeMap<String, Object>(map);
        String str = MapUrlUtils.getUrlParamsByMap(treeMap);
        str = str + "&" + Md5Utils.cryptHash(yuansferToken);

        String calculateValue = Md5Utils.cryptHash(str);
        return calculateValue;
    }
}


public class MapUrlUtils {

    public static String getUrlParamsByMap(Map<String, Object> map) {
        if (map == null) {
            return "";
        }
        StringBuilder sbuilder = new StringBuilder();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            sbuilder.append(entry.getKey()).append("=").append(entry.getValue());
            sbuilder.append("&");
        }
        String s = sbuilder.toString();
        if (s.endsWith("&")) {
            s = StringUtils.substringBeforeLast(s, "&");
        }
        return s;
    }
}

public class Md5Utils {
    public static String cryptHash(String hashStr) {
        String strCrypt = hashStr;
        if (strCrypt.length() > 0) {
            strCrypt = hash(strCrypt);
        }

        return strCrypt;
    }


    public static  String hash(String str) {
        try {  
            MessageDigest md = MessageDigest.getInstance("MD5");  
            md.update(str.getBytes());  
            byte b[] = md.digest();  

            int i;  

            StringBuilder buf = new StringBuilder("");  
            for (int offset = 0; offset < b.length; offset++) {  
                i = b[offset];  
                if (i < 0)  
                    i += 256;  
                if (i < 16)  
                    buf.append("0");  
                buf.append(Integer.toHexString(i));  
            }  
            //32位加密  
            return buf.toString();  
            // 16位的加密  
            //return buf.toString().substring(8, 24);  
        } catch (NoSuchAlgorithmException e) {  
            e.printStackTrace();  
            return null;  
        } 
    }

}


This is a general signature algorithm for signing Yuansfer APIs.

Step 1

Take parameters for example:

amount=1.00
storeNo=300014
currency=USD
merchantNo=200043
callbackUrl=https://wx.yuansfer.yunkeguan.com/wx
terminal=ONLINE
ipnUrl=https://wx.yuansfer.yunkeguan.com/wx
reference=seq_1525922323
vendor=alipay

Step 2

Sort the field lexicographically, and write variable-value pair in variable=value format. Concatenate the variable value pair using “&”:

amount=1.00&callbackUrl=https://wx.yuansfer.yunkeguan.com/wx&currency=USD&ipnUrl=https://wx.yuansfer.yunkeguan.com/wx&merchantNo=200043&reference=seq_1525922323&storeNo=300014&terminal=ONLINE&vendor=alipay

Step 3

Append &MD5(api_key):

amount=1.00&callbackUrl=https://wx.yuansfer.yunkeguan.com/wx&currency=USD&ipnUrl=https://wx.yuansfer.yunkeguan.com/wx&merchantNo=200043&reference=seq_1525922323&storeNo=300014&terminal=ONLINE&vendor=alipay&MD5(5cbfb079f15b150122261c8537086d77a)

Step 4

Get the verified signature. Calculate MD5 value of the string in Step 3:

verifySign = MD5 ("amount=1.00&callbackUrl=https://wx.yuansfer.yunkeguan.com/wx&currency=USD&ipnUrl=https://wx.yuansfer.yunkeguan.com/wx&merchantNo=200043&reference=seq_1525922323&storeNo=300014&terminal=ONLINE&vendor=alipay&MD5(5cbfb079f15b150122261c8537086d77a)")

Online Payments API

Use the Online Payments API to easily and securely accept Chinese online payments. The payments name space contains sales, refunds, and orders. Sflow en

Securepay

HTTP URL

POST https://mapi.yuansfer.com/appTransaction/v2/securepay
POST https://mapi.yuansfer.com/appTransaction/v2/securepay
POST https://mapi.yuansfer.com/appTransaction/v2/securepay
POST https://mapi.yuansfer.com/appTransaction/v2/securepay

Request

curl "https://mapi.yuansfer.com/appTransaction/v2/securepay" \
-d amount="1.00" \
-d storeNo="300014" \
-d currency="USD" \
-d merchantNo="200043" \
-d callbackUrl="https://wx.yuansfer.yunkeguan.com/wx" \
-d terminal="ONLINE" \
-d ipnUrl="https://wx.yuansfer.yunkeguan.com/wx" \
-d reference="seq_1525922323" \
-d vendor="alipay" \
-d verifySign="4f0cc35728849e4b4aa4a176f4a5edac"
<?php
function securepay()
{
    $url = 'https://mapi.yuansfer.com/appTransaction/v2/securepay';
    $token = '5cbfb079f15b150122261c8537086d77a';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'amount' => '0.01',
        'currency' => 'USD',
        'vendor' => 'alipay',
        'ipnUrl' => 'https://nengjtian.s1.natapp.cc/login/test',
        'callbackUrl' => 'https://nengjtian.s1.natapp.cc/login/test2?yuansferId={yuansferId}&status={status}&amount={amount}&time={time}&reference={reference}&note={note}',
        'terminal' => 'ONLINE',
        'reference' => 'test2018070101',
        'description' => 'test_description',
        'note' => 'test_note',
        'timeout' => '120'
    ];

    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);
}

securepay();

?>
/**
 * testing class of securepay API
 * @author zhoukai
 *
 */
public class SecurepayTest {

    public static final String TEST_URL = "https://mapi.yuansfer.yunkeguan.com";            //testing domain
    public static final String PROD_URL = "https://mapi.yuansfer.com";                      //production domain
    public static final String YUANSFER_TOKEN = "5c5fe30183be69fceff8174358d4b8ae";


    public static void main(String[] args) {
        YuansferVerifySignHelper helper = new YuansferVerifySignHelper();

        YuansferSecurepayDto dto = paramSetting();
        Map<String, Object> params = ReflectionUtils.convertBean2MapIgnoreNullVal(dto, new String[]{"serialVersionUID"});
        String verifySign = helper.getYuansferVerifySign(params, YUANSFER_TOKEN); 
        params.put("verifySign", verifySign);

        String url = TEST_URL + "/appTransaction/v2/securepay";
        String ret = HttpClientUtils.post(url, null, params);
        System.out.println(ret);
    }

    public static YuansferSecurepayDto paramSetting() {
        YuansferSecurepayDto dto = new YuansferSecurepayDto();
        /**
         * merchantNo,storeNo is necessory, and they are provided by Yuansfer
         */
        dto.setMerchantNo("200043");                                                //The Merchant NO.
        dto.setStoreNo("300014");                                                   //The Store NO.

        /**
         * transaction infomation is necessory
         */
        dto.setAmount("0.01");                                                      //The amount, unit "division"
        dto.setCurrency("USD");                                                     //currency, "USD" or "CAD"
        dto.setIpnUrl("https://nengjtian.s1.natapp.cc/login/test");                 //Asynchronous callback address
        dto.setCallbackUrl("https://nengjtian.s1.natapp.cc/login/test2");           //Synchronous callback address
        dto.setReference("9091023122");                                             //order NO. of client's system
        dto.setTerminal("ONLINE");                                                  //"ONLINE" or "WAP"
        dto.setTimeout("120");                                                      //unit "minute"
        dto.setVendor("alipay");                                                    //“alipay","wechatpay" or "unionpay"

        /**
         * note,desription are optional 
         */
        dto.setDescription("test-description");                                     //description
        dto.setNote("test-note");                                                   //note

        return dto;
    }
}
func securepay(t *table) {
    req := yuan.Securepay{
        MerchantNo:  "200043", //customer The merchant NO.
        StoreNo:     "300014",
        Currency:    "USD",
        Amount:      "0.01",
        Vendor:      "wechatpay",
        Reference:   fmt.Sprintf("demo_%d", time.Now().Unix()), //sequence number of customer system
        IpnUrl:      "https://customer-ipn",        //internet accessible 
        CallbackUrl: "https://customer-callback",   //internet accessible 
        Description: "description",
        Note:        "note",
        Terminal:    "ONLINE",
        Timeout:     "120",
    }
    resp, err := req.PostToYuansfer(yuansferToken)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(resp)
}

Securepay is the online API to pay.

HTTP Request

POST https://mapi.yuansfer.com/appTransaction/v2/securepay

Request Body

Parameters Required Type Description
merchantNo required String The unique merchant Number assigned to merchants. Please login and check at your dashboard.
storeNo required String The unique store Number assigned to stores.
verifySign required String Verified signature of Yuansfer online API.
amount optional Decimal Transaction amount.
rmbAmount optional Decimal Transaction amount in RMB. You can’t have amount and rmbAmount at the same time.
currency required Enum Cash currency code. USD, CAD available.
vendor required Enum Payment method. alipay, wechatpay, unionpay are available.
ipnUrl required String Instant Payment Notification Handler URL. IPN URL must be secure.
Merchants create an IPN listener page on their websiteand then specify the URL of the listener page in therequest body. Yuansfer API then sends notifications ofall transaction-related events to that URL. Whencustomers pay for goods or services, API sends asecure FORM POST containing payment information(IPN messages) to the URL. The IPN listener detectsand processes IPN messages using the merchantbackend processes. The IPN listener page contains acustom script or program that waits for the messages,validates success status, and then passes them tovarious backend applications for processing.
IPN is not synchronized with actions on your website.Internet connectivity is not always 100% reliable andIPN messages can be lost or delayed. The IPN serviceautomatically resends messages until the listeneracknowledges them. The service resends messages forup to 8 times in 2 hours.
callbackUrl required String The synchronousHTTP callbacks that receivenotification messages for events. The callback URLfollows macro substitution rules likexxxcallback_url?trans_no={amount}&amount={amount},then Yuansfer will automatically replace the values of {}
terminal required Enum ONLINE,WAP.
reference required String Unique ID of client’s system.
description optional String Description Info, will be displayed on invoice.
note optional String Payment Note Info.
timeout optional Integer Timeout in minute, default timeout is 120.

Response

Parameters Description
return info When vendor is “wechatpay” and terminalis “WAP”, return html, but only can opencashier page in wechat pay browserdirectly; In other cases, return a htmlpage source as string.

SecurepayRefund

HTTP URL

POST https://mapi.yuansfer.com/appTransaction/v2/securepayRefund
POST https://mapi.yuansfer.com/appTransaction/v2/securepayRefund
POST https://mapi.yuansfer.com/appTransaction/v2/securepayRefund
POST https://mapi.yuansfer.com/appTransaction/v2/securepayRefund

Request

curl "https://mapi.yuansfer.com/appTransaction/v2/securepayRefund" \
-d "amount=0.01" \
-d "storeNo=300014" \
-d "currency=USD" \
-d "merchantNo=200043" \
-d "reference=origin_reference" \
-d "verifySign=verifySign"
<?php
function securepayRefund()
{
    $url = 'https://mapi.yuansfer.com/appTransaction/v2/securepayRefund';
    $token = '5cbfb079f15b150122261c8537086d77a';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'amount' => '0.01',
        'reference' => 'test2018070101',
        'managerAccountNo' => '3000140001',
        'password' => '1e2958a66c609467a4794c6c8adf3b84'
    ];

    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);
}

securepayRefund();

?>
public class SecurepayRefundTest {
    public static final String TEST_URL = "https://mapi.yuansfer.yunkeguan.com";            //testing domain
    public static final String PROD_URL = "https://mapi.yuansfer.com";                      //production domain
    public static final String YUANSFER_TOKEN = "5c5fe30183be69fceff8174358d4b8ae";


    public static void main(String[] args) {
        YuansferSecurepayRefundDto refundDto = new YuansferSecurepayRefundDto();
        YuansferVerifySignHelper verifyHelper = new YuansferVerifySignHelper();
        refundDto.setAmount("0.01");
        refundDto.setCurrency("USD");
        refundDto.setMerchantNo("200043");
        refundDto.setStoreNo("300014");
        refundDto.setReference("9091023122");

        /**
         * When managerAccountNo and password are refund, 
         * shop manager's permission check can be configured in the yuansfer background, 
         * and the check is unnecessary. If you don't check, you don't need to enter store account and password.
         */
//      YuansferPwdHelper pwdHelper = new YuansferPwdHelper();
//      refundDto.setManagerAccountNo("3000140001");    
//      String managerPwd = pwdHelper.genPwd("111111"); 
//      refundDto.setPassword(managerPwd);

        Map<String, Object> params = ReflectionUtils.convertBean2MapIgnoreNullVal(refundDto, new String[]{"serialVersionUID"});
        String verifySign = verifyHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
        refundDto.setVerifySign(verifySign);
        params.put("verifySign", verifySign);

        String url = TEST_URL + "/appTransaction/v2/securepayRefund";
        String ret = HttpClientUtils.post(url, null, params);
        JSON json = JSON.parseObject(ret);
        System.out.println(json);
    }
}
func refund(t *table) {
    req := yuan.Refund{
        MerchantNo:       "200043", //customer The merchant NO.
        StoreNo:          "300014",
        Currency:         "USD",
        Reference:        "original sequence No.", //sequence number of customer system
        Amount:           "0.01",
    }

    resp, err := req.PostToYuansfer(yuansferToken)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(resp)
}

Response

{
    "result":{
        "status": "success",
        "reference": "44444",
        "refundTransactionId": "297245675773380538",
        "oldTransactionId": "297245675773319174"
    },
    "ret_code": "000100"
}
{
    "result":{
        "status": "success",
        "reference": "44444",
        "refundTransactionId": "297245675773380538",
        "oldTransactionId": "297245675773319174"
    },
    "ret_code": "000100"
}
{
    "result":{
        "status": "success",
        "reference": "44444",
        "refundTransactionId": "297245675773380538",
        "oldTransactionId": "297245675773319174"
    },
    "ret_code": "000100"
}
{
    "result":{
        "status": "success",
        "reference": "44444",
        "refundTransactionId": "297245675773380538",
        "oldTransactionId": "297245675773319174"
    },
    "ret_code": "000100"
}

The refund method of ONLINE securepay

HTTP Request

POST https://mapi.yuansfer.com/appTransaction/v2/securepayRefund

Request Body

Parameters Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
verifySign required String The verifySign of yuansfer online API.
amount optional Decimal Transaction amount.
rmbAmount optional Decimal Transaction amount in RMB. You can’t have amount and rmbAmount at the same time.
reference required String Unique id of client’s system.
managerAccountNo optional String Only required when store manager validation is set.
password optional String Store manager validation password.

Response

Parameters Type Description
status Enum The state of the refund.
reference String Unique id of client’s system.
refundTransactionId String The ID of the refund transaction.
oldTransactionId String The ID of the transaction which transaction is based.

SecurepayReferenceQuery

HTTP URL

POST https://mapi.yuansfer.com/appTransaction/v2/securepay-reference-query
POST https://mapi.yuansfer.com/appTransaction/v2/securepay-reference-query
POST https://mapi.yuansfer.com/appTransaction/v2/securepay-reference-query
POST https://mapi.yuansfer.com/appTransaction/v2/securepay-reference-query

Request

curl "https://mapi.yuansfer.com/appTransaction/v2/securepay-reference-query" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "reference=origin_reference" \
-d "verifySign=verifySign"
<?php
function securepayReferenceQuery()
{
    $url = 'https://mapi.yuansfer.com/appTransaction/v2/securepay-reference-query';
    $token = '5cbfb079f15b150122261c8537086d77a';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'reference' => 'test2018070101'
    ];

    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();

?>
public class SecurepayReferenceQueryTest {
    public static final String TEST_URL = "https://mapi.yuansfer.yunkeguan.com";            //testing domain
    public static final String PROD_URL = "https://mapi.yuansfer.com";                      //production domain
    public static final String YUANSFER_TOKEN = "5cbfb079f15b150122261c8537086d77a";

    public static void main(String[] args) {
        YuansferVerifySignHelper helper = new YuansferVerifySignHelper();

        YuansferSecurepayQueryDto dto = paramSetting();
        Map<String, Object> params = ReflectionUtils.convertBean2MapIgnoreNullVal(dto, new String[]{"serialVersionUID"});
        String verifySign = helper.getYuansferVerifySign(params, YUANSFER_TOKEN);//得到verifySign
        params.put("verifySign", verifySign);

        String url = TEST_URL + "/appTransaction/v2/securepay-reference-query";
        String ret = HttpClientUtils.post(url, null, params);
        System.out.println(ret);
    }

    public static YuansferSecurepayQueryDto paramSetting() {
        YuansferSecurepayQueryDto dto = new YuansferSecurepayQueryDto();

        dto.setMerchantNo("200043");                                                //The merchant NO.
        dto.setStoreNo("300014");                                                   //The store NO.
        dto.setReference("20180126162433");
        return dto;
    }
}


func query(t *table) {
    req := yuan.Query{
        MerchantNo: "200043", //customer The merchant NO.
        StoreNo:    "300014",
        Currency:   "USD",
        Reference:  "original sequence No.", //sequence number of customer system
        Terminal:   "ONLINE",
    }

    //TO CALL VERIFYSIGN
    resp, err := req.PostToYuansfer(yuansferToken)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(resp)
}

Response

{
    "result":{
    "reference": "test20180801006",
    "yuansferId": "297553569604475564",
    "amount": "2.00",
    "refundInfo":[
        {
            "refundYuansferId": "297553569604658581",
            "refundAmount": "1.50"
        },
        {
            "refundYuansferId": "297553569604680588",
            "refundAmount": "0.50"
        }
    ],
    "currency": "CNY",
    "status": "success"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "result":{
    "reference": "test20180801006",
    "yuansferId": "297553569604475564",
    "amount": "2.00",
    "refundInfo":[
        {
            "refundYuansferId": "297553569604658581",
            "refundAmount": "1.50"
        },
        {
            "refundYuansferId": "297553569604680588",
            "refundAmount": "0.50"
        }
    ],
    "currency": "CNY",
    "status": "success"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "result":{
    "reference": "test20180801006",
    "yuansferId": "297553569604475564",
    "amount": "2.00",
    "refundInfo":[
        {
            "refundYuansferId": "297553569604658581",
            "refundAmount": "1.50"
        },
        {
            "refundYuansferId": "297553569604680588",
            "refundAmount": "0.50"
        }
    ],
    "currency": "CNY",
    "status": "success"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "result":{
    "reference": "test20180801006",
    "yuansferId": "297553569604475564",
    "amount": "2.00",
    "refundInfo":[
        {
            "refundYuansferId": "297553569604658581",
            "refundAmount": "1.50"
        },
        {
            "refundYuansferId": "297553569604680588",
            "refundAmount": "0.50"
        }
    ],
    "currency": "CNY",
    "status": "success"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}

The method to query transaction by reference

HTTP Request

POST https://mapi.yuansfer.com/appTransaction/v2/securepay-reference-query

Request Body

Parameters Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
verifySign required String The signature signed by Yuansfer.
reference required String Unique ID of client’s system.

Response

Parameters Type Description
reference String The client’s transaction ID.
yuansferId String The ID of the Yuansfer transaction.
amount Decimal The transaction amount.
status String The state of the transaction.
currency String The currency.
refundInfo String The refund details of the transaction if refunded.There are two fields: refundYuansferId and refundAmount.

Exchangerate

HTTP URL

POST https://mapi.yuansfer.com/appTransaction/v2/exchangerate
POST https://mapi.yuansfer.com/appTransaction/v2/exchangerate
POST https://mapi.yuansfer.com/appTransaction/v2/exchangerate
POST https://mapi.yuansfer.com/appTransaction/v2/exchangerate

Request

curl "https://mapi.yuansfer.com/appTransaction/v2/exchangerate" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "date=yyyyMMdd" \
-d "vendor=alipay" \
-d "verifySign=verifySign"
<?php
function exchangerate()
{
    $url = 'https://mapi.yuansfer.com/appTransaction/v2/exchangerate';
    $token = '5cbfb079f15b150122261c8537086d77a';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'date' => '20180620',
        'currency' => 'USD',
        'vendor' => 'alipay'
    ];

    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);
}

exchangerate();

?>
public class SecurepayExchangeTest {
    public static final String TEST_URL = "https://mapi.yuansfer.yunkeguan.com";            //testing domain
    public static final String PROD_URL = "https://mapi.yuansfer.com";                      //production domain
    public static final String YUANSFER_TOKEN = "5cbfb079f15b150122261c8537086d77a";

    public static void main(String[] args) {
        YuansferVerifySignHelper helper = new YuansferVerifySignHelper();

        YuansferSecurepayExchangeDto dto = paramSetting();
        Map<String, Object> params = ReflectionUtils.convertBean2MapIgnoreNullVal(dto, new String[]{"serialVersionUID"});
        String verifySign = helper.getYuansferVerifySign(params, YUANSFER_TOKEN);
        params.put("verifySign", verifySign);

        String url = TEST_URL + "/appTransaction/v2/exchangerate";
        String ret = HttpClientUtils.post(url, null, params);
        System.out.println(ret);
    }

    public static YuansferSecurepayExchangeDto paramSetting() {
        YuansferSecurepayExchangeDto dto = new YuansferSecurepayExchangeDto();

        dto.setMerchantNo("200043");                                                //The merchant NO.
        dto.setStoreNo("300014");                                                   //The store NO.
        dto.setDate("20180128");
        dto.setCurrency("USD");
        dto.setVendor("alipay");
        return dto;
    }
}




Response

{
    "exchangerate": "6.594300",
    "ret_code": "000100"
}
{
    "exchangerate": "6.594300",
    "ret_code": "000100"
}
{
    "exchangerate": "6.594300",
    "ret_code": "000100"
}
{
    "exchangerate": "6.594300",
    "ret_code": "000100"
}

Get exchange rate between two currencies.

HTTP Request

POST https://mapi.yuansfer.com/appTransaction/v2/exchangerate

Request Body

Parameters Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
date required Date Date time issued, ‘yyyyMMdd’
currency required Enum Currency code, USD or CAD.
vendor required Enum The payment method, alipay, wechatpay.
verifySign required String The signature signed by Yuansfer.

Response

Parameters Description
exchangerate The exchange rate of RMB and USD.

In-Store Payments APIs

Use the In-Store Payments API to easily and securely accept Chinese payments in your store. The payments name space contains Merchant QR Code Payment, Transaction QR Code Payment.

Merchant QR Code Scan trade

Pos workflow

Trans-qrcode trade Trans qrcode flow

Transaction-add(merchant scan)

HTTP URL

POST https://mapi.yuansfer.com/app-instore/v2/add
POST https://mapi.yuansfer.com/app-instore/v2/add
POST https://mapi.yuansfer.com/app-instore/v2/add
POST https://mapi.yuansfer.com/app-instore/v2/add

Request

curl "https://mapi.yuansfer.com/app-instore/v2/add" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "amount=0.01" \
-d "verifySign=verifySign"
<?php
function transAdd()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/add';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'vendor' => 'alipay',
        'amount' => '0.01'
    ];

    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);
}

transAdd();

?>
//add
public static String transactionAdd() {
    String url = DOMAIN_URL + TRANSACTION_ADD;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("amount", "0.01");
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---transaction add----");
    System.out.println(ret);
    JSONObject retInfo = (JSONObject)JSONValue.parse(ret);
    JSONObject transaction = (JSONObject)retInfo.get("transaction");
    String transactionNo = transaction.get("transactionNo").toString();
    return transactionNo;
}

Response

{
    "ret_msg": "add success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": null,
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "init",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "add success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": null,
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "init",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "add success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": null,
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "init",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "add success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": null,
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "init",
        "transactionType": "payment"
    }
}

After the customer confirms the payment amount, create the transaction order.

HTTP Request

POST https://mapi.yuansfer.com/app-instore/v2/add

Request Body

Parameter Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
storeAdminNo optional String The ID of the store admin.
amount required Decimal The order amount.
verifySign required String The signature signed by Yuansfer.

HTTP Response

A successful request returns the HTTP 200 OK status code and a JSON response body that shows details for captured order.

Parameter Description
transactionNo The ID of the transaction.
originalTransactionNo The ID of the original transaction.
merchantNo The ID of the merchant.
storeNo The ID of the store.
storeAdminNo The ID of the store admin.
amount The payment amount.
refundAmount The refund amount.
transactionType The type of the transaction.
transactionStatus The state of the transaction.
currency The Currency code.
createTime The date and time when the order was created.
paymentTime The date and time when the payment was created.
exchangeRate The exchange rate.
vendor The payment method, “alipay”, “wechatpay”.

Transaction-pay(merchant scan)

HTTP URL

POST https://mapi.yuansfer.com/app-instore/v2/pay
POST https://mapi.yuansfer.com/app-instore/v2/pay
POST https://mapi.yuansfer.com/app-instore/v2/pay
POST https://mapi.yuansfer.com/app-instore/v2/pay

Request

curl "https://mapi.yuansfer.com/app-instore/v2/pay" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "transactionNo=transactionNo" \
-d "paymentBarcode=paymentBarcode" \
-d "vendor=alipay" \
-d "verifySign=verifySign"
<?php
function transPay()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/pay';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'transactionNo' => '297553565108438359',
        'vendor' => 'alipay',
        'amount' => '0.01',
        'paymentBarcode' => '280526696410694666'
    ];

    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);
}

transPay();

?>
//pay
public static void transactionPay(String transactionNo) {
    String url = DOMAIN_URL + TRANSACTION_PAY;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("transactionNo", transactionNo);
    params.put("paymentBarcode", "286754322648217439");
    params.put("vendor", "alipay");
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---transaction pay----");
    System.out.println(ret);
}

Response

{
    "ret_msg": "pay success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "pay success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "pay success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "pay success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "payment"
    }
}

Create a sale for the captured order.

HTTP Requestt

POST https://mapi.yuansfer.com/app-instore/v2/pay

Request Body

Parameter Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
storeAdminNo optional String The ID of the store admin.
transactionNo required String The ID of the transaction.
paymentBarcode required String Payment barcode.
vendor required Enum The payment method, alipay, wechatpay.
verifySign required String The signature signed by Yuansfer.

HTTP Response

A successful request returns the HTTP 200 OK status code and a JSON response body that shows payment details.

Parameter Description
transactionNo The ID of the transaction.
originalTransactionNo The ID of the original transaction.
merchantNo The ID of the merchant.
storeNo The ID of the store.
storeAdminNo The ID of the store admin.
amount The payment amount.
refundAmount The refund amount.
transactionType The type of the transaction.
transactionStatus The state of the transaction.
currency The Currency code.
createTime The date and time when the order was created.
paymentTime The date and time when the payment was created.
exchangeRate The exchange rate.
vendor The payment method, “alipay”, “wechatpay”.

Trans-qrcode-create(trans-qrcode)

HTTP URL

POST https://mapi.yuansfer.com/app-instore/v2/create-trans-qrcode
POST https://mapi.yuansfer.com/app-instore/v2/create-trans-qrcode
POST https://mapi.yuansfer.com/app-instore/v2/create-trans-qrcode
POST https://mapi.yuansfer.com/app-instore/v2/create-trans-qrcode

Request

curl "https://mapi.yuansfer.com/app-instore/v2/create-trans-qrcode" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "currency=USD" \
-d "reference=reference" \
-d "vendor=alipay" \
-d "ipnUrl=IPN URL" \
-d "amount=0.01" \
-d "verifySign=verifySign"
<?php
function transQrcode()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/create-trans-qrcode';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'vendor' => 'alipay',
        'amount' => '0.01',
        'ipnUrl' => 'https://nengjtian.s1.natapp.cc/login/test',
        'reference' => 'test2018061901',
    ];

    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);
}

transQrcode();

?>

public static void transQrcode() {
    String url = DOMAIN_URL + TRANS_QRCODE;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("vendor", "alipay");
    params.put("amount", "0.01");
    params.put("ipnUrl", "https://nengjtian.s1.natapp.cc/login/test");
    params.put("reference", "testabc100");
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---trans-qrcode-create ----");
    System.out.println(ret);
}

Response

{
    "reference":"testabc1001",
    "deepLink":"url1",
    "transactionNo":"297553556919345525",
    "ret_code":"000100",
    "timeout":"120",
    "qrcodeUrl":"url2"
}
{
    "reference":"testabc1001",
    "deepLink":"url1",
    "transactionNo":"297553556919345525",
    "ret_code":"000100",
    "timeout":"120",
    "qrcodeUrl":"url2"
}
{
    "reference":"testabc1001",
    "deepLink":"url1",
    "transactionNo":"297553556919345525",
    "ret_code":"000100",
    "timeout":"120",
    "qrcodeUrl":"url2"
}
{
    "reference":"testabc1001",
    "deepLink":"url1",
    "transactionNo":"297553556919345525",
    "ret_code":"000100",
    "timeout":"120",
    "qrcodeUrl":"url2"
}

User scanning merchants show the payment of two dimensional codes in various scenes. According to Alipay, WeChat merchant payment rules, to generate a two-dimensional code for various goods and services, display in a variety of scenarios, for users to scan the purchase.

HTTP Request

POST https://mapi.yuansfer.com/app-instore/v2/create-trans-qrcode

POST Parameters

Parameter Required Type Description
merchantNo required String The unique merchant Number assigned to merchants. Please login and check at your dashboard.
storeNo required String The unique store Number assigned to stores.
verifySign required String Verified signature of Yuansfer API.
currency required Enum Cash currency code. USD, CAD available.
vendor required Enum Payment method. alipay, wechatpay are available.
reference required String Unique ID of client’s system.
amount required Decimal The amount of the order.
ipnUrl optional String Instant Payment Notification Handler URL. IPN URL must be secure.
IPN is not synchronized with actions on your website. Internet connectivity is not always 100% reliable and IPN messages can be lost or delayed. The IPN service automatically resends messages until the listener acknowledges them. The service resends messages for up to 8 times in 2 hours.
needQrcode optional String “true” or “false”, default value is “true”. If it is “true” ,yuansfer system will help to create the qrcode picture,if it is “false” , yuansfer system will not create qrcode picture.

HTTP Response

A successful request returns the HTTP 200 OK status code and a JSON response body that shows QR code details.

Parameter Description
transactionNo The ID of the transaction.
reference Unique ID of client’s system.
deepLink Deep link url.
qrcodeUrl The url of the transaction QR code.

Void order

HTTP URL

POST https://mapi.yuansfer.com/app-instore/v2/reverse

Request

curl "https://mapi.yuansfer.com/app-instore/v2/reverse" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "transactionNo=transactionNo" \
-d "verifySign=verifySign"

<?php
function transReverse()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/reverse';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'transactionNo' => '297553565108438359'
    ];

    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);
}

transReverse();

?>
//reverse
public static void transactionReverse(String transactionNo) {
    String url = DOMAIN_URL + TRANSACTION_REVERSE;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("transactionNo", transactionNo);
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---transaction reverse----");
    System.out.println(ret);
}

Response

{
    "ret_msg": "reverse success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "reversed",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "reverse success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "reversed",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "reverse success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "reversed",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "reverse success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "reversed",
        "transactionType": "payment"
    }
}

Voids, or cancels, an order.
A transaction returns a failure, and voids the transaction. When the payment fails, the payment system will voids the order. If the payment done successfully, the payment system will refund the amount of the order to you.

HTTP Request

POST https://mapi.yuansfer.com/app-instore/v2/reverse

Request Body

Parameter Required Type Description
merchantNo required String The merchant NO.
storeNo required String The store NO.
storeAdminNo optional String The store admin’s account
transactionNo optional String The ID of the transaction. ‘transactionNo’ and ‘reference’ cannot be null at the same time.
reference optional String Unique ID of client’s system. ‘reference’ and ‘transactionNo’ cannot be null at the same time.
verifySign required String check signature

HTTP Response

Parameter Description
transactionNo The transaction NO.
originalTransactionNo Original transaction NO. (refund order is available)
merchantNo The merchant NO.
storeNo The store NO.
storeAdminNo The store amdmin’s account
amount payment amount
refundAmount refund amount
transactionType the type of the transaction
transactionStatus the status of the transaction
currency currency
createTime create time (UTC+8)
paymentTime payment time (UTC+8)
exchangeRate exchange rate
vendor channel of payment, “alipay” or “wechatpay” are supported now.

Refund

HTTP URL

POST https://mapi.yuansfer.com/app-instore/v2/refund

The return info of transaction-refund API

curl "https://mapi.yuansfer.com/app-instore/v2/refund" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "transactionNo=transactionNo" \
-d "refundAmount=refundAmount" \
-d "verifySign=verifySign"
<?php
function transRefund()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/refund';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'transactionNo' => '297553565108438359',
        'refundAmount' => '0.01'
    ];

    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);
}

transRefund();

?>
//refund
public static void transactionRefund(String transactionNo) {
    String url = DOMAIN_URL + TRANSACTION_REFUND;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("transactionNo", transactionNo);
    params.put("refundAmount", "0.01");
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---transaction refund----");
    System.out.println(ret);
}

Response

{
    "ret_msg": "refund success ",
    "ret_code": "000100",
    "refundTransaction":{
        "amount": -0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": "297553554508274471",
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "refund"
    }
}
{
    "ret_msg": "refund success ",
    "ret_code": "000100",
    "refundTransaction":{
        "amount": -0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": "297553554508274471",
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "refund"
    }
}
{
    "ret_msg": "refund success ",
    "ret_code": "000100",
    "refundTransaction":{
        "amount": -0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": "297553554508274471",
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "refund"
    }
}
{
    "ret_msg": "refund success ",
    "ret_code": "000100",
    "refundTransaction":{
        "amount": -0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": "297553554508274471",
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "refund"
    }
}

Refunds the transaction to customers. Alipay and Wechat Pay will refund the payment according to their refund policy after the refund request is accepted successfully.

HTTP Request

POST https://mapi.yuansfer.com/app-instore/v2/refund

Request Body

Parameter Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
storeAdminNo optional String The ID of the store admin.
transactionNo optional String The ID of the transaction. ‘transactionNo’ and ‘reference’ cannot be null at the same time.
reference optional String Unique ID of client’s system. ‘reference’ and ‘transactionNo’ cannot be null at the same time.
refundAmount required Decimal The refund amount.
verifySign required String The signature signed by Yuansfer.

HTTP Response

A successful request returns the HTTP 200 OK status code and a JSON response body that shows refund details.

Parameter Description
transactionNo The ID of the transaction.
originalTransactionNo The ID of the original transaction.
merchantNo The ID of the merchant.
storeNo The ID of the store.
storeAdminNo The ID of the store admin.
amount The payment amount.
refundAmount The refund amount.
transactionType The type of the transaction.
transactionStatus The state of the transaction.
currency The Currency code.
createTime The date and time when the order was created.
paymentTime The date and time when the payment was created.
exchangeRate The exchange rate.
vendor The payment method, “alipay”, “wechatpay”.

Show order details

HTTP URL

POST https://mapi.yuansfer.com/app-instore/v2/detail
POST https://mapi.yuansfer.com/app-instore/v2/detail
POST https://mapi.yuansfer.com/app-instore/v2/detail
POST https://mapi.yuansfer.com/app-instore/v2/detail

Request

curl "https://mapi.yuansfer.com/app-instore/v2/detail" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "transactionNo=transactionNo" \
-d "verifySign=verifySign"
<?php
function transDetail()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/detail';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'transactionNo' => '297553565108438359'
    ];

    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);
}

transDetail();

?>
//transaction detail
public static void transactionDetail(String transactionNo) {
    String url = DOMAIN_URL + TRANSACTION_DETAIL;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("transactionNo", transactionNo);
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---transaction detail----");
    System.out.println(ret);
}

Response

{
    "ret_msg": "query success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "query success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "query success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "payment"
    }
}
{
    "ret_msg": "query success ",
    "ret_code": "000100",
    "transaction":{
        "amount": 0.01,
        "createTime": "2018-02-16 18:17:57",
        "currency": "USD",
        "exchangeRate": null,
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2018-02-16 18:17:57",
        "refundAmount": 0,
        "storeAdminNo": "3000140001",
        "storeNo": "300014",
        "transactionNo": "297553554508274472",
        "transactionStatus": "success",
        "transactionType": "payment"
    }
}

Show details for an order.

HTTP Request

POST https://mapi.yuansfer.com/app-instore/v2/detail

Request Body

Parameter Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
storeAdminNo optional String The ID of the store admin.
transactionNo optional String The ID of the transaction. ‘transactionNo’ and ‘reference’ cannot be null at the same time.
reference optional String Unique ID of client’s system. ‘reference’ and ‘transactionNo’ cannot be null at the same time.
verifySign required String The signature signed by Yuansfer.

HTTP Response

A successful request returns the HTTP 200 OK status code and a JSON response body shows order details.

Parameter Description
transactionNo The ID of the transaction.
originalTransactionNo The ID of the original transaction.
merchantNo The ID of the merchant.
storeNo The ID of the store.
storeAdminNo The ID of the store admin.
amount The payment amount.
refundAmount The refund amount.
transactionType The type of the transaction.
transactionStatus The state of the transaction.
currency The Currency code.
createTime The date and time when the order was created.
paymentTime The date and time when the payment was created.
exchangeRate The exchange rate.
vendor The payment method, “alipay”, “wechatpay”.

List transactions

HTTP URL

POST https://mapi.yuansfer.com/app-instore/v2/trans-list
POST https://mapi.yuansfer.com/app-instore/v2/trans-list
POST https://mapi.yuansfer.com/app-instore/v2/trans-list
POST https://mapi.yuansfer.com/app-instore/v2/trans-list

Request

curl "https://mapi.yuansfer.com/app-instore/v2/trans-list" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "startDate=startDate" \
-d "endDate=endDate" \
-d "verifySign=verifySign"
<?php
function transList()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/trans-list';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'startDate' => '20180619',
        'endDate' => '20180619'
    ];

    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);
}

transList();

?>
//transaction list
public static void transactionList(String startDate, String endDate) {
    String url = DOMAIN_URL + TRANSACTION_LIST;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("startDate", startDate);
    params.put("endDate", endDate);
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---transaction list----");
    System.out.println(ret);
}

Response

{
    "size": 2,
    "transactions":[
        {
            "amount": -0.01,
            "createTime": "2018-03-02 14:49:38",
            "currency": "USD",
            "exchangeRate": "6.361300",
            "merchantNo": "200043",
            "originalTransactionNo": "297553555705268810",
            "paymentTime": "2018-03-02 14:49:38",
            "refundAmount": 0,
            "storeAdminNo": null,
            "storeNo": "300014",
            "transactionNo": "297553555705374195",
            "transactionStatus": "success",
            "transactionType": "refund",
            "vendor": "wechatpay"
        },
        {
            "amount": 0.01,
            "createTime": "2018-03-02 14:47:52",
            "currency": "USD",
            "exchangeRate": "6.361300",
            "merchantNo": "200043",
            "originalTransactionNo": null,
            "paymentTime": "2018-03-02 14:48:07",
            "refundAmount": 0.01,
            "storeAdminNo": null,
            "storeNo": "300014",
            "transactionNo": "297553555705268810",
            "transactionStatus": "success",
            "transactionType": "payment",
            "vendor": "wechatpay"
        }
    ],
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "size": 2,
    "transactions":[
        {
            "amount": -0.01,
            "createTime": "2018-03-02 14:49:38",
            "currency": "USD",
            "exchangeRate": "6.361300",
            "merchantNo": "200043",
            "originalTransactionNo": "297553555705268810",
            "paymentTime": "2018-03-02 14:49:38",
            "refundAmount": 0,
            "storeAdminNo": null,
            "storeNo": "300014",
            "transactionNo": "297553555705374195",
            "transactionStatus": "success",
            "transactionType": "refund",
            "vendor": "wechatpay"
        },
        {
            "amount": 0.01,
            "createTime": "2018-03-02 14:47:52",
            "currency": "USD",
            "exchangeRate": "6.361300",
            "merchantNo": "200043",
            "originalTransactionNo": null,
            "paymentTime": "2018-03-02 14:48:07",
            "refundAmount": 0.01,
            "storeAdminNo": null,
            "storeNo": "300014",
            "transactionNo": "297553555705268810",
            "transactionStatus": "success",
            "transactionType": "payment",
            "vendor": "wechatpay"
        }
    ],
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "size": 2,
    "transactions":[
        {
            "amount": -0.01,
            "createTime": "2018-03-02 14:49:38",
            "currency": "USD",
            "exchangeRate": "6.361300",
            "merchantNo": "200043",
            "originalTransactionNo": "297553555705268810",
            "paymentTime": "2018-03-02 14:49:38",
            "refundAmount": 0,
            "storeAdminNo": null,
            "storeNo": "300014",
            "transactionNo": "297553555705374195",
            "transactionStatus": "success",
            "transactionType": "refund",
            "vendor": "wechatpay"
        },
        {
            "amount": 0.01,
            "createTime": "2018-03-02 14:47:52",
            "currency": "USD",
            "exchangeRate": "6.361300",
            "merchantNo": "200043",
            "originalTransactionNo": null,
            "paymentTime": "2018-03-02 14:48:07",
            "refundAmount": 0.01,
            "storeAdminNo": null,
            "storeNo": "300014",
            "transactionNo": "297553555705268810",
            "transactionStatus": "success",
            "transactionType": "payment",
            "vendor": "wechatpay"
        }
    ],
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "size": 2,
    "transactions":[
        {
            "amount": -0.01,
            "createTime": "2018-03-02 14:49:38",
            "currency": "USD",
            "exchangeRate": "6.361300",
            "merchantNo": "200043",
            "originalTransactionNo": "297553555705268810",
            "paymentTime": "2018-03-02 14:49:38",
            "refundAmount": 0,
            "storeAdminNo": null,
            "storeNo": "300014",
            "transactionNo": "297553555705374195",
            "transactionStatus": "success",
            "transactionType": "refund",
            "vendor": "wechatpay"
        },
        {
            "amount": 0.01,
            "createTime": "2018-03-02 14:47:52",
            "currency": "USD",
            "exchangeRate": "6.361300",
            "merchantNo": "200043",
            "originalTransactionNo": null,
            "paymentTime": "2018-03-02 14:48:07",
            "refundAmount": 0.01,
            "storeAdminNo": null,
            "storeNo": "300014",
            "transactionNo": "297553555705268810",
            "transactionStatus": "success",
            "transactionType": "payment",
            "vendor": "wechatpay"
        }
    ],
    "ret_msg": "query success ",
    "ret_code": "000100"
}

Show all transaction details for time period.
Note: 
All date format is YYYYMMDD. endDate cannot be 15 days greater than startDate.

HTTP Request

POST https://mapi.yuansfer.com/app-instore/v2/trans-list

Request Body

Parameter Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
storeAdminNo optional String The ID of the store admin.
startDate required String The start date of time period.
endDate required String The end date of time period.
verifySign required String The signature signed by Yuansfer.

HTTP Response

A successful request returns the HTTP 200 OK status code and a JSON response body that lists transactions with transaction details.

Parameter Description
transactionNo The ID of the transaction.
originalTransactionNo The ID of the original transaction.
merchantNo The ID of the merchant.
storeNo The ID of the store.
storeAdminNo The ID of the store admin.
amount The payment amount.
refundAmount The refund amount.
transactionType The type of the transaction.
transactionStatus The state of the transaction.
currency The Currency code.
createTime The date and time when the order was created.
paymentTime The date and time when the payment was created.
exchangeRate The exchange rate.
vendor The payment method, “alipay”, “wechatpay”.

List settlements

HTTP URL

POST https://mapi.yuansfer.com/app-instore/v2/settle-list
POST https://mapi.yuansfer.com/app-instore/v2/settle-list
POST https://mapi.yuansfer.com/app-instore/v2/settle-list
POST https://mapi.yuansfer.com/app-instore/v2/settle-list

Request

curl "https://mapi.yuansfer.com/app-instore/v2/settle-list" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "startDate=startDate" \
-d "endDate=endDate" \
-d "verifySign=verifySign"
<?php
function settleList()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/settle-list';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'startDate' => '20171201',
        'endDate' => '20171210'
    ];

    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);
}

settleList();

?>
//settlement list
public static void settleList(String startDate, String endDate) {
    String url = DOMAIN_URL + SETTLE_LIST;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("startDate", startDate);
    params.put("endDate", endDate);
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---settle list----");
    System.out.println(ret);
}

Response

{
    "settlements": [{
        "amount": 0.01,
        "currency": "USD",
        "exchangeRate": "6.354920",
        "fee": 0.00,
        "merchantNo": "200277",
        "netSettleAmount": 0.01,
        "paymentTime": "2018-03-07 23:43:06",
        "settleAmount": 0.01,
        "settleCurrency": "USD",
        "storeAdminNo": "3004890001",
        "storeNo": "300489",
        "transactionNo": "298068127611181075",
        "transactionType": "payment",
        "vendor","alipay"
    }, {
        "amount": 0.01,
        "currency": "USD",
        "exchangeRate": "6.345900",
        "fee": 0.00,
        "merchantNo": "200277",
        "netSettleAmount": 0.01,
        "paymentTime": "2018-03-07 15:32:55",
        "settleAmount": 0.01,
        "settleCurrency": "USD",
        "storeAdminNo": "3004890001",
        "storeNo": "300489",
        "transactionNo": "298068127581770149",
        "transactionType": "payment",
        "vendor","wechatpay"
    }],
    "size": 2,
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "settlements": [{
        "amount": 0.01,
        "currency": "USD",
        "exchangeRate": "6.354920",
        "fee": 0.00,
        "merchantNo": "200277",
        "netSettleAmount": 0.01,
        "paymentTime": "2018-03-07 23:43:06",
        "settleAmount": 0.01,
        "settleCurrency": "USD",
        "storeAdminNo": "3004890001",
        "storeNo": "300489",
        "transactionNo": "298068127611181075",
        "transactionType": "payment",
        "vendor","alipay"
    }, {
        "amount": 0.01,
        "currency": "USD",
        "exchangeRate": "6.345900",
        "fee": 0.00,
        "merchantNo": "200277",
        "netSettleAmount": 0.01,
        "paymentTime": "2018-03-07 15:32:55",
        "settleAmount": 0.01,
        "settleCurrency": "USD",
        "storeAdminNo": "3004890001",
        "storeNo": "300489",
        "transactionNo": "298068127581770149",
        "transactionType": "payment",
        "vendor","wechatpay"
    }],
    "size": 2,
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "settlements": [{
        "amount": 0.01,
        "currency": "USD",
        "exchangeRate": "6.354920",
        "fee": 0.00,
        "merchantNo": "200277",
        "netSettleAmount": 0.01,
        "paymentTime": "2018-03-07 23:43:06",
        "settleAmount": 0.01,
        "settleCurrency": "USD",
        "storeAdminNo": "3004890001",
        "storeNo": "300489",
        "transactionNo": "298068127611181075",
        "transactionType": "payment",
        "vendor","alipay"
    }, {
        "amount": 0.01,
        "currency": "USD",
        "exchangeRate": "6.345900",
        "fee": 0.00,
        "merchantNo": "200277",
        "netSettleAmount": 0.01,
        "paymentTime": "2018-03-07 15:32:55",
        "settleAmount": 0.01,
        "settleCurrency": "USD",
        "storeAdminNo": "3004890001",
        "storeNo": "300489",
        "transactionNo": "298068127581770149",
        "transactionType": "payment",
        "vendor","wechatpay"
    }],
    "size": 2,
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "settlements": [{
        "amount": 0.01,
        "currency": "USD",
        "exchangeRate": "6.354920",
        "fee": 0.00,
        "merchantNo": "200277",
        "netSettleAmount": 0.01,
        "paymentTime": "2018-03-07 23:43:06",
        "settleAmount": 0.01,
        "settleCurrency": "USD",
        "storeAdminNo": "3004890001",
        "storeNo": "300489",
        "transactionNo": "298068127611181075",
        "transactionType": "payment",
        "vendor","alipay"
    }, {
        "amount": 0.01,
        "currency": "USD",
        "exchangeRate": "6.345900",
        "fee": 0.00,
        "merchantNo": "200277",
        "netSettleAmount": 0.01,
        "paymentTime": "2018-03-07 15:32:55",
        "settleAmount": 0.01,
        "settleCurrency": "USD",
        "storeAdminNo": "3004890001",
        "storeNo": "300489",
        "transactionNo": "298068127581770149",
        "transactionType": "payment",
        "vendor","wechatpay"
    }],
    "size": 2,
    "ret_msg": "query success ",
    "ret_code": "000100"
}

Show all settlements details for time period.
Note: 
All date format is YYYYMMDD. endDate cannot be 15 days greater than startDate.

HTTP Request

POST https://mapi.yuansfer.com/app-instore/v2/settle-list

Request Body

Parameter Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
storeAdminNo optional String The ID of the store admin.
startDate required String The start date for the range to show in the response.
endDate required String The end date for the range to show in the response.
verifySign required String The signature signed by Yuansfer.

HTTP Response

A successful request returns the HTTP 200 OK status code and a JSON response body that lists settlements with settlement details.

Parameter Description
merchantNo The ID of the merchant.
storeNo The ID of the store.
storeAdminNo The ID of the store admin.
transactionNo The ID of the transaction.
transactionType The type of the transaction.
amount The payment amount.
currency The currency code, example: USD.
settleAmount The settlement amount.
settleCurrency The settlement currency code, example: USD
fee The transaction fee.
netSettleAmount The Net settlement amount.
paymentTime The date and time when the payment was created.
exchangeRate The exchange rate.
vendor The payment method, “alipay”, “wechatpay”.

List withdrawals

HTTP URL

POST https://mapi.yuansfer.com/app-instore/v2/withdrawal-list
POST https://mapi.yuansfer.com/app-instore/v2/withdrawal-list
POST https://mapi.yuansfer.com/app-instore/v2/withdrawal-list
POST https://mapi.yuansfer.com/app-instore/v2/withdrawal-list

Request

curl "https://mapi.yuansfer.com/app-instore/v2/withdrawal-list" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "startDate=startDate" \
-d "endDate=endDate" \
-d "verifySign=verifySign"
<?php
function withdrawalList()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/withdrawal-list';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'startDate' => '20171201',
        'endDate' => '20171210'
    ];

    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);
}

withdrawalList();

?>
//withdrawal list
public static void withdrawalList(String startDate, String endDate) {
    String url = DOMAIN_URL + WITHDRAWAL_LIST;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("startDate", startDate);
    params.put("endDate", endDate);
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---withdrawal list----");
    System.out.println(ret);
}

Response

{
    "size": 1,
    "ret_msg": "query success ",
    "ret_code": "000100",
    "withdrawals": [{
        "actualAppropriation": 53.72,
        "bankSettlementFee": 0.3,
        "currency": "USD",
        "date": "20180307",
        "details": [{
            "paymentTime": "20180305230715",
            "transactionAmount": 0.01,
            "transactionCurrency": "USD",
            "transactionFee": 0.00,
            "transactionNo": "298068127436229571",
            "transactionType": "payment",
            "transactionWithdrawalAmount": 0.01,
            "vendor": "alipay"
        }, {
            "paymentTime": "20180306204828",
            "transactionAmount": 20.00,
            "transactionCurrency": "USD",
            "transactionFee": 0.36,
            "transactionNo": "298068127514235706",
            "transactionType": "payment",
            "transactionWithdrawalAmount": 19.64,
            "vendor": "alipay"
        }],
        "merchantNo": "200277",
        "salesAmount": 55.01,
        "status": "completed",
        "withdrawalAmount": 54.02,
        "yuansferProcessingFee": 0.99
    } 
    ]
}
{
    "size": 1,
    "ret_msg": "query success ",
    "ret_code": "000100",
    "withdrawals": [{
        "actualAppropriation": 53.72,
        "bankSettlementFee": 0.3,
        "currency": "USD",
        "date": "20180307",
        "details": [{
            "paymentTime": "20180305230715",
            "transactionAmount": 0.01,
            "transactionCurrency": "USD",
            "transactionFee": 0.00,
            "transactionNo": "298068127436229571",
            "transactionType": "payment",
            "transactionWithdrawalAmount": 0.01,
            "vendor": "alipay"
        }, {
            "paymentTime": "20180306204828",
            "transactionAmount": 20.00,
            "transactionCurrency": "USD",
            "transactionFee": 0.36,
            "transactionNo": "298068127514235706",
            "transactionType": "payment",
            "transactionWithdrawalAmount": 19.64,
            "vendor": "alipay"
        }],
        "merchantNo": "200277",
        "salesAmount": 55.01,
        "status": "completed",
        "withdrawalAmount": 54.02,
        "yuansferProcessingFee": 0.99
    } 
    ]
}
{
    "size": 1,
    "ret_msg": "query success ",
    "ret_code": "000100",
    "withdrawals": [{
        "actualAppropriation": 53.72,
        "bankSettlementFee": 0.3,
        "currency": "USD",
        "date": "20180307",
        "details": [{
            "paymentTime": "20180305230715",
            "transactionAmount": 0.01,
            "transactionCurrency": "USD",
            "transactionFee": 0.00,
            "transactionNo": "298068127436229571",
            "transactionType": "payment",
            "transactionWithdrawalAmount": 0.01,
            "vendor": "alipay"
        }, {
            "paymentTime": "20180306204828",
            "transactionAmount": 20.00,
            "transactionCurrency": "USD",
            "transactionFee": 0.36,
            "transactionNo": "298068127514235706",
            "transactionType": "payment",
            "transactionWithdrawalAmount": 19.64,
            "vendor": "alipay"
        }],
        "merchantNo": "200277",
        "salesAmount": 55.01,
        "status": "completed",
        "withdrawalAmount": 54.02,
        "yuansferProcessingFee": 0.99
    } 
    ]
}
{
    "size": 1,
    "ret_msg": "query success ",
    "ret_code": "000100",
    "withdrawals": [{
        "actualAppropriation": 53.72,
        "bankSettlementFee": 0.3,
        "currency": "USD",
        "date": "20180307",
        "details": [{
            "paymentTime": "20180305230715",
            "transactionAmount": 0.01,
            "transactionCurrency": "USD",
            "transactionFee": 0.00,
            "transactionNo": "298068127436229571",
            "transactionType": "payment",
            "transactionWithdrawalAmount": 0.01,
            "vendor": "alipay"
        }, {
            "paymentTime": "20180306204828",
            "transactionAmount": 20.00,
            "transactionCurrency": "USD",
            "transactionFee": 0.36,
            "transactionNo": "298068127514235706",
            "transactionType": "payment",
            "transactionWithdrawalAmount": 19.64,
            "vendor": "alipay"
        }],
        "merchantNo": "200277",
        "salesAmount": 55.01,
        "status": "completed",
        "withdrawalAmount": 54.02,
        "yuansferProcessingFee": 0.99
    } 
    ]
}

Show all withdrawals details for time period.
Note: 
All date format is YYYYMMDD. endDate cannot be 15 days greater than startDate.

HTTP Request

POST https://mapi.yuansfer.com/app-instore/v2/withdrawal-list

POST Parameters

Parameter Required Type Description
merchantNo required String The ID of the merchant.
storeNo required String The ID of the store.
storeAdminNo optional String The ID of the store admin.
startDate required String The start date for the range to show in the response.
endDate required String The end date for the range to show in the response.
verifySign required String The signature signed by Yuansfer.

HTTP Response

A successful request returns the HTTP 200 OK status code and a JSON response body that lists settlements with withdrawal details.

Parameter Description
merchantNo The ID of the merchant.
salesAmount Total transaction amount.
yuansferProcessingFee Yuansfer Processing Fee.
withdrawalAmount The withdrawal amount.
bankSettlementFee The bank settlement fee.
actualAppropriation The actual appropriation.
status The state of the withdrawal.
currency The Currency code.
date The withdrawal date.
details The order details associated in the record.
details described below.

The details’ parameters description. Parameter | Description ——— | ———– transactionNo | The ID of the transaction. transactionType | The type of the transaction. transactionAmount | The transaction amount. transactionFee | The transaction processing fee . transactionWithdrawalAmount | The transaction withdrawal amount. transactionCurrency | The transaction currency code. paymentTime | The date and time when the payment was created. vendor | The payment method, “alipay”, “wechatpay”.

Data status

HTTP URL

curl "https://mapi.yuansfer.com/app-instore/v2/data-status" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "paymentDate=20180520" \
-d "verifySign=verifySign"
<?php
function dataStatus()
{
    $url = 'https://mapi.yuansfer.yunkeguan.com/app-instore/v2/data-status';
    $token = '59600f2a9ad644c6a9570233560cc94e';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'paymentDate' => '20180619'
    ];

    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);
}

dataStatus();

?>
//data status
public static void dataStatus(String paymentDate) {
    String url = DOMAIN_URL + DATA_STATUS;
    Map<String, Object> params = new TreeMap<String, Object>();
    params.put("merchantNo", MERCHANT_NO);
    params.put("storeNo", STORE_NO);
    if (StringUtils.isNotEmpty(STORE_ADMIN_NO)) {
        params.put("storeAdminNo", STORE_ADMIN_NO);
    }

    params.put("paymentDate", paymentDate);
    String verifySign = verifySignHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
    params.put("verifySign", verifySign);
    String ret = HttpClientUtils.post(url, null, params);
    System.out.println("---data status----");
    System.out.println(ret);
}

Response

{
    "result": {
        "merchantNo": "200043",
        "message": "NO_TRANSACTION",
        "paymentDate": "20180520",
        "status": "00",
        "storeNo": "300014"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "result": {
        "merchantNo": "200043",
        "message": "NO_TRANSACTION",
        "paymentDate": "20180520",
        "status": "00",
        "storeNo": "300014"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "result": {
        "merchantNo": "200043",
        "message": "NO_TRANSACTION",
        "paymentDate": "20180520",
        "status": "00",
        "storeNo": "300014"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "result": {
        "merchantNo": "200043",
        "message": "NO_TRANSACTION",
        "paymentDate": "20180520",
        "status": "00",
        "storeNo": "300014"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}

This interface provides a data status query function for a day.

HTTP Request

POST https://mapi.yuansfer.com/app-instore/v2/data-status

POST parameters

Parameter Required Type Description
merchantNo true String The ID of the merchant.
storeNo true String The ID of the store.
storeAdminNo false String The ID of the storeAdmin.
paymentDate true String payment date, in YYYYMMDDHHMMSS format
verifySign true String The signature signed by Yuansfer.

HTTP Response

DataStatus Parameter Description
merchantNo The ID of the merchant.
storeNo The ID of the store.
paymentDate payment date(UTC+8)
status status
message description,The mappings of status and message see the table below
status message
“00” “NO_TRANSACTION”
“10” “NO_SETTLED”
“11” “PARTLY_SETTLED”
“12” “FULLY_SETTLED”

Wechat MicroPay API

Wechat MicroPay authority open process:
1. The main body of Wechat MicroPay should be American company;
2. To provide links to Wechat MicroPay, as well as the appid;
3. Yuansfer submitted to WeChat official team for verification;
4. WeChat opens the payment authority, pays according to the development document docking small program.

The official documents of Wechat MicroPay

Prepay

Request:

curl "https://mapi.yuansfer.com/micropay/v2/prepay" \
-d amount="1.00" \
-d storeNo="300014" \
-d currency="USD" \
-d merchantNo="200043" \
-d ipnUrl="https://wx.yuansfer.yunkeguan.com/wx" \
-d reference="seq_1525922323" \
-d description="testDescription"\
-d note="testNote"\
-d openid="***"\
-d vendor="wechatpay" \
-d verifySign="4f0cc35728849e4b4aa4a176f4a5edac"
/<?php
function microprepay()
{
    $url = 'https://mapi.yuansfer.com/micropay/v2/prepay';
    $token = '5cbfb079f15b150122261c8537086d77a';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'amount' => '0.01',
        'currency' => 'USD',
        'vendor' => 'wechatpay',
        'ipnUrl' => 'https://nengjtian.s1.natapp.cc/login/test',        
        'reference' => 'test2018070101',
        'description' => 'test_description',
        'note' => 'test_note',
        'openid' => '***'
    ];

    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);
}

microprepay();

?>
/**
 * prepay test
 * @author zhoukai
 *
 */
public class MicropayTest {

    public static final String TEST_URL = "https://mapi.yuansfer.yunkeguan.com";            //testing domain
    public static final String PROD_URL = "https://mapi.yuansfer.com";                      //production domain
    public static final String YUANSFER_TOKEN = "5c5fe30183be69fceff8174358d4b8ae";


    public static void main(String[] args) {
        YuansferVerifySignHelper helper = new YuansferVerifySignHelper();

        AppMircopayDto dto = paramSetting();
        Map<String, Object> params = ReflectionUtils.convertBean2MapIgnoreNullVal(dto, new String[]{"serialVersionUID"});
        String verifySign = helper.getYuansferVerifySign(params, YUANSFER_TOKEN); 
        params.put("verifySign", verifySign);

        String url = TEST_URL + "/micropay/v2/prepay";
        String ret = HttpClientUtils.post(url, null, params);
        System.out.println(ret);
    }

    public static AppMircopayDto paramSetting() {
        AppMircopayDto dto = new AppMircopayDto();
        /**
         * merchantNo,storeNo is necessory, and they are provided by Yuansfer
         */
        dto.setMerchantNo("200043");                                                //The Merchant NO.
        dto.setStoreNo("300014");                                                   //The Store NO.

        /**
         * transaction infomation is necessory
         */
        dto.setAmount("0.01");                                                      //The amount, unit "division"
        dto.setCurrency("USD");                                                     //currency, "USD" or "CAD"
        dto.setIpnUrl("https://nengjtian.s1.natapp.cc/login/test");                 //Asynchronous callback address
        dto.setReference("9091023122");                                             //order NO. of client's system
        dto.setOpenid("***");                                                       //wechat openid
        dto.setVendor("wechatpay");                                                 //"wechatpay" 

        /**
         * note,desription are optional 
         */
        dto.setDescription("test-description");                                     //description
        dto.setNote("test-note");                                                   //note

        return dto;
    }
}
func mciropay(t *table) {
    req := yuan.Securepay{
        MerchantNo:  "200043", //customer The merchant NO.
        StoreNo:     "300014",
        Currency:    "USD",
        Amount:      "0.01",
        Vendor:      "wechatpay",
        Reference:   fmt.Sprintf("demo_%d", time.Now().Unix()), //sequence number of customer system
        IpnUrl:      "https://customer-ipn",        //internet accessible 
        Description: "description",
        Note:        "note",
        Openid:      "***",
    }
    resp, err := req.PostToYuansfer(yuansferToken)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(resp)
}

Response:

{
    "ret_msg": "prepay success",
    "ret_code": "000100",
    "result": {
        "timeStamp": "1510341967363",
        "nonceStr": "a611bda03d544b9f941393c48c2e517f",
        "package": "prepay_id=wx201711110326070ccf2a7f060678638664",
        "signType": "MD5",
        "paySign": "09E5BE5B9D93080E3B7DD05C8F41049E"
    }
}
{
    "ret_msg": "prepay success",
    "ret_code": "000100",
    "result": {
        "timeStamp": "1510341967363",
        "nonceStr": "a611bda03d544b9f941393c48c2e517f",
        "package": "prepay_id=wx201711110326070ccf2a7f060678638664",
        "signType": "MD5",
        "paySign": "09E5BE5B9D93080E3B7DD05C8F41049E"
    }
}
{
    "ret_msg": "prepay success",
    "ret_code": "000100",
    "result": {
        "timeStamp": "1510341967363",
        "nonceStr": "a611bda03d544b9f941393c48c2e517f",
        "package": "prepay_id=wx201711110326070ccf2a7f060678638664",
        "signType": "MD5",
        "paySign": "09E5BE5B9D93080E3B7DD05C8F41049E"
    }
}
{
    "ret_msg": "prepay success",
    "ret_code": "000100",
    "result": {
        "timeStamp": "1510341967363",
        "nonceStr": "a611bda03d544b9f941393c48c2e517f",
        "package": "prepay_id=wx201711110326070ccf2a7f060678638664",
        "signType": "MD5",
        "paySign": "09E5BE5B9D93080E3B7DD05C8F41049E"
    }
}

HTTP Request

POST https://mapi.yuansfer.com/micropay/v2/prepay

POST parameters

Parameter Required Type Description
merchantNo true String The ID of the merchant.
storeNo true String The ID of the store.
amount optional Decimal Transaction amount.
rmbAmount optional Decimal Transaction amount in RMB. You can’t have amount and rmbAmount at the same time.
currency true Enum currency
vendor true Enum “wechatpay”
ipnUrl true String Instant Payment Notification Handler URL. IPN URL must be secure.Merchants create an IPN listener page on their websiteand then specify the URL of the listener page in therequest body. Yuansfer API then sends notifications ofall transaction-related events to that URL. Whencustomers pay for goods or services, API sends asecure FORM POST containing payment information(IPN messages) to the URL. The IPN listener detectsand processes IPN messages using the merchantbackend processes. The IPN listener page contains acustom script or program that waits for the messages,validates success status, and then passes them tovarious backend applications for processing.IPN is not synchronized with actions on your website.Internet connectivity is not always 100% reliable andIPN messages can be lost or delayed. The IPN serviceautomatically resends messages until the listeneracknowledges them. The service resends messages forup to 8 times in 2 hours.
openid true String openid from wechat.
reference true String Unique ID of client’s system.
description false String Description Infomation, will be displayed on invoice.
note false String Note Infomation, will be displayed on invoice.
verifySign true String Verified signature of Yuansfer API.

HTTP Response

Parameter Description
timeStamp Time Stamp
nonceStr Random String
package prepay_id infomaition
signType sign type
paySign sign

Refund

Request:

curl "https://mapi.yuansfer.com/micropay/v2/refund" \
-d "amount=0.01" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "reference=origin_reference" \
-d "verifySign=verifySign"
<?php
function micropayRefund()
{
    $url = 'https://mapi.yuansfer.com/micropay/v2/refund';
    $token = '5cbfb079f15b150122261c8537086d77a';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'amount' => '0.01',
        'reference' => 'test2018070101'
    ];

    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);
}

micropayRefund();

?>
public class MicropayRefundTest {
    public static final String TEST_URL = "https://mapi.yuansfer.yunkeguan.com";            //testing domain
    public static final String PROD_URL = "https://mapi.yuansfer.com";                      //production domain
    public static final String YUANSFER_TOKEN = "5c5fe30183be69fceff8174358d4b8ae";


    public static void main(String[] args) {
        YuansferSecurepayRefundDto refundDto = new YuansferSecurepayRefundDto();
        YuansferVerifySignHelper verifyHelper = new YuansferVerifySignHelper();
        refundDto.setAmount("0.01");
        refundDto.setCurrency("USD");
        refundDto.setMerchantNo("200043");
        refundDto.setStoreNo("300014");
        refundDto.setReference("9091023122");

        Map<String, Object> params = ReflectionUtils.convertBean2MapIgnoreNullVal(refundDto, new String[]{"serialVersionUID"});
        String verifySign = verifyHelper.getYuansferVerifySign(params, YUANSFER_TOKEN);
        refundDto.setVerifySign(verifySign);
        params.put("verifySign", verifySign);

        String url = TEST_URL + "/micropay/v2/refund";
        String ret = HttpClientUtils.post(url, null, params);
        JSON json = JSON.parseObject(ret);
        System.out.println(json);
    }
}
func refund(t *table) {
    req := yuan.Refund{
        MerchantNo:       "200043", //customer The merchant NO.
        StoreNo:          "300014",
        Currency:         "USD",
        Reference:        "original sequence No.", //sequence number of customer system
        Amount:           "0.01",
    }

    resp, err := req.PostToYuansfer(yuansferToken)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(resp)
}

Response:

{
    "result":{
        "status": "success",
        "reference": "44444",
        "refundTransactionId": "297245675773380538",
        "oldTransactionId": "297245675773319174"
    },
    "ret_code": "000100"
}
{
    "result":{
        "status": "success",
        "reference": "44444",
        "refundTransactionId": "297245675773380538",
        "oldTransactionId": "297245675773319174"
    },
    "ret_code": "000100"
}
{
    "result":{
        "status": "success",
        "reference": "44444",
        "refundTransactionId": "297245675773380538",
        "oldTransactionId": "297245675773319174"
    },
    "ret_code": "000100"
}
{
    "result":{
        "status": "success",
        "reference": "44444",
        "refundTransactionId": "297245675773380538",
        "oldTransactionId": "297245675773319174"
    },
    "ret_code": "000100"
}

The refund API of WeChat micropay.

HTTP Request

POST https://mapi.yuansfer.com/micropay/v2/refund

POST parameters

Parameter Required Type Description
merchantNo true String The ID of the merchant.
storeNo true String The ID of the store.
verifySign true String Verified signature of Yuansfer API.
amount depends Decimal The refund amount .
rmbAmount depends Decimal Transaction amount in RMB. You can’t have amount and rmbAmount at the same time
reference true String Unique ID of client’s system.

HTTP Response

Parameter Type Description
status Enum status
reference String Unique ID of client’s system.
refundTransactionId String The transaction id of Yuansfer’s refund transaction.
oldTransactionId String The transaction id of Yuansfer’s payment transaction.

Reference Query

Http Request:

curl "https://mapi.yuansfer.com/micropay/v2/reference-query" \
-d "storeNo=300014" \
-d "merchantNo=200043" \
-d "reference=origin_reference" \
-d "verifySign=verifySign"
<?php
function micropayReferenceQuery()
{
    $url = 'https://mapi.yuansfer.com/micropay/v2/reference-query';
    $token = '5cbfb079f15b150122261c8537086d77a';

    $params = [
        'merchantNo' => '200043',
        'storeNo' => '300014',
        'reference' => 'test2018070101'
    ];

    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);
}

microReferenceQuery();

?>
public class MircopayReferenceQueryTest {
    public static final String TEST_URL = "https://mapi.yuansfer.yunkeguan.com";            //testing domain
    public static final String PROD_URL = "https://mapi.yuansfer.com";                      //production domain
    public static final String YUANSFER_TOKEN = "5cbfb079f15b150122261c8537086d77a";

    public static void main(String[] args) {
        YuansferVerifySignHelper helper = new YuansferVerifySignHelper();

        YuansferSecurepayQueryDto dto = paramSetting();
        Map<String, Object> params = ReflectionUtils.convertBean2MapIgnoreNullVal(dto, new String[]{"serialVersionUID"});
        String verifySign = helper.getYuansferVerifySign(params, YUANSFER_TOKEN);//得到verifySign
        params.put("verifySign", verifySign);

        String url = TEST_URL + "/micropay/v2/reference-query";
        String ret = HttpClientUtils.post(url, null, params);
        System.out.println(ret);
    }

    public static YuansferSecurepayQueryDto paramSetting() {
        YuansferSecurepayQueryDto dto = new YuansferSecurepayQueryDto();

        dto.setMerchantNo("200043");                                                //The merchant NO.
        dto.setStoreNo("300014");                                                   //The store NO.
        dto.setReference("20180126162433");
        return dto;
    }
}


func query(t *table) {
    req := yuan.Query{
        MerchantNo: "200043", //customer The merchant NO.
        StoreNo:    "300014",
        Currency:   "USD",
        Reference:  "original sequence No.", //sequence number of customer system
        Terminal:   "ONLINE",
    }

    //TO CALL VERIFYSIGN
    resp, err := req.PostToYuansfer(yuansferToken)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(resp)
}

Response:

{
    "result":{
    "reference": "test20180801006",
    "yuansferId": "297553569604475564",
    "amount": "2.00",
    "refundInfo":[
        {
            "refundYuansferId": "297553569604658581",
            "refundAmount": "1.50"
        },
        {
            "refundYuansferId": "297553569604680588",
            "refundAmount": "0.50"
        }
    ],
    "currency": "CNY",
    "status": "success"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "result":{
    "reference": "test20180801006",
    "yuansferId": "297553569604475564",
    "amount": "2.00",
    "refundInfo":[
        {
            "refundYuansferId": "297553569604658581",
            "refundAmount": "1.50"
        },
        {
            "refundYuansferId": "297553569604680588",
            "refundAmount": "0.50"
        }
    ],
    "currency": "CNY",
    "status": "success"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "result":{
    "reference": "test20180801006",
    "yuansferId": "297553569604475564",
    "amount": "2.00",
    "refundInfo":[
        {
            "refundYuansferId": "297553569604658581",
            "refundAmount": "1.50"
        },
        {
            "refundYuansferId": "297553569604680588",
            "refundAmount": "0.50"
        }
    ],
    "currency": "CNY",
    "status": "success"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}
{
    "result":{
    "reference": "test20180801006",
    "yuansferId": "297553569604475564",
    "amount": "2.00",
    "refundInfo":[
        {
            "refundYuansferId": "297553569604658581",
            "refundAmount": "1.50"
        },
        {
            "refundYuansferId": "297553569604680588",
            "refundAmount": "0.50"
        }
    ],
    "currency": "CNY",
    "status": "success"
    },
    "ret_msg": "query success ",
    "ret_code": "000100"
}

It is used to query the transaction by reference, the reference must be unique.

HTTP Request

POST https://mapi.yuansfer.com/micropay/v2/reference-query

POST parameters

Parameter Required Type Description
merchantNo true String The merchant NO.
storeNo true String The store NO.
verifySign true String The verify sign.
reference true String Client’s reference

HTTP Response

Parameter Type Description
reference String Unique ID of client’s system.
yuansferId String The transaction ID of Yuansfer.
amount Decimal Transaction amount
status String status
currency String currency
refundInfo String The refund infomation of the transaction.

Notice

1.Password Generation Algorithm : MD5(“@yuanex”+password)

Yuansfer callback( synchronous, asynchronous ) parameters:

YuansferId: Yuansfer system order ID

Status: Yuansfer system order state

Amount: The order amount

Time: The order time, in YYYYMMDDHHMMSS format

Reference: Unique ID of client’s system

Note: Payment note

VerifySign: Digital signature signed by Yuansfer

3.The return code “000100” represents success while “000000” is failure.


4.Yuansfer date and time is in UTC +8.

5.The transaction status of Yuansfer:

no send: a new order created, but not sent to the payment channel;

success: the transaction succeed;

fail: the transaction failed;

pending: Waiting for the payment confirmation;

closed : closed: the payment channel is setup, but the customer didn’t continue to complete payment action and automatically closed after a certain period;

reverse : the customer voids the transaction by closing the transaction interface;

6.Demo of SecurePay API:

JAVA : click to view demo

PHP : click to view demo

GO : click to view demo

7.Demo of In-Store API:

JAVA : click to view demo

Return Code

The Yuansfer APIs return the following codes :

Return Code Meaning
000000 System Error
000010 API Version Error
000020 Parameter Null Error
000021 Parameter No Related Infomation
000022 Parameters Not Match
000023 Parameter Value Error
000030 No Rights
000040 Transaction Status Error
000080 Supplier System’s Error
000100 Success

Sandbox Environment

To make the API as explorable as possible, accounts have test mode and live mode API keys. There is no “switch” for changing between modes, just use the appropriate key to perform a live or test transaction. Requests made with test mode credentials never hit the banking networks and incur no cost:

—-ONLINE API—-
(1)Yuansfer Test Account Info:
merchantNo : 200043
storeNo : 300014
yuansferToken : 5cbfb079f15b150122261c8537086d77a

(2) UnionPay Test Account Info:
Card Number:6226388000000095
CVV:248
EXP:12/2019
Phone:18100000000
Verification Code:111111

(3)Alipay Test Account Info:
Account:douyufua@alitest.com
Captcha Code:8888
Login Password:111111
Payment Password on Cashier Page:111111


—-IN-STORE API—-
merchantNo : 200043
storeNo : 300014
storeAdminNo : 3000140001
yuansferToken : 59600f2a9ad644c6a9570233560cc94e


—-Pay Treasure Sandbox Apk—-
https://oss.yuansfer.com/app/sandbox/wallet_101150122_release_201801221142.apk