NAV Navbar
Logo
shell php java go

介绍

欢迎使用圆支付API文档! 本文档包括数字签名,Online API 和 In-Store API.
click here to view english document.

数字签名

数字签名示例如下:

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

}

1.Yuansfer系统数字签名的生成规则如下

1)参数转换成 param1=val1&param2=val2…paramN=valN的形式,其中param1,param2…paramN按照自然排序
2)得到临时字符串 param1=val1&param2=val2…paramN=valN&MD5(yuansferToken), 记此字符串为tempStr
3)得到verifySign=MD5(temStr)


2.Yuansfer系统数字签名的例子

1) 输入参数:
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
2) 排序并转换得到:
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
3) 得到tempStr:
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)
4) 得到verifySign:
verifySign = MD5(tempStr)
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)"), 具体实现过程参看右侧demo

Online API 文档

安全支付接口

安全支付异步回调参数如下:

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

?>
/**
 * 安全支付接口测试类
 * @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)
}

安全支付接口提供在线支付服务.

Sflow cn

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
verifySign true String 数字签名
amount depends Decimal 订单金额
rmbAmount depends Decimal 订单人民币金额, “amount"和"rmbAmount"有且只能存在一个
currency true Enum 订单币种,目前支持USD,CAD, 具体情况依合同而定
vendor true Enum 支持"alipay”,“wechatpay”,“unionpay",即支付宝,微信,银联
ipnUrl true String 异步回调地址,要求"https"协议,用于异步通知yuansfer下游,下游返回"success” 给yuansfer即算作成功,如若失败在2小时内会重发8次。建议用异步通知更新下游系统支付流水状态。回调参数更多内容参考注意事项。
callbackUrl true String 同步回调地址,仅1次,主要用于下游系统结果展示,不建议以此为标准来修改下游系统的支付流水状态。 回调参数遵循宏替换规则,例如 xxxCallbackUrl?transNo={reference}&amount={amount}, yuansfer会自动替换“{}"内的值。 回调参数更多内容参考注意事项。
terminal true Enum "ONLINE” 或 “WAP",即客户端类型
reference true String 客户系统中的支付流水号,要求唯一
description false String 订单描述信息
note false String 订单备注信息
timeout false Integer 订单超时时间,默认是120分钟

HTTP 返回

参数名 描述
返回信息 安全支付接口,返回收银台的HTML源码字符串, 用户接受后直接展示到页面即可,我们会自动跳转支付处理页面。需要注意的是,ONLINE API的vendor支持"alipay”, “wechatpay”,“unionpay” 三种,这三种又根据terminal分为"ONLINE" 和 “WAP”, 由于微信权限方面控制,"wechatpay",“WAP"的情况下,只能在微信内打开才能进行支付。

安全支付退款接口

退款接口请求如下:

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

退款接口返回如下:

{
    "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"
}

安全支付退款接口,用于退款业务

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
verifySign true String 数字签名
amount depends Decimal 退款金额
rmbAmount depends Decimal 退款人民币金额, "amount"和"rmbAmount"有且只能存在一个
reference true String 客户端系统订单id
managerAccountNo depends String 退款赋权店长账号, 商户可以配置退款的时候是否需要店长权限校验,如果配置了需要校验,该字段则必填;否则不需要填
password depends String 参考managerAccountNo, 密码生成规则参考注意事项

HTTP 返回

参数名 类型 描述
status Enum 状态
reference String 客户端支付流水号
refundTransactionId String 圆支付系统退款订单id
oldTransactionId String 圆支付系统原订单id

安全支付订单查询接口

订单查询接口请求如下:

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

用于订单查询,返回订单数据。另外,比如回调延时,回调异常的时候,客户端可以主动查询此接口及时获得订单在圆支付系统中的状态:

{
    "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"
}

通过客户端自己的支付流水号查询订单状态,正因为如此圆支付要求客户端支付流水号必须唯一

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
verifySign true String 数字签名
reference true String 客户端系统支付流水号

HTTP 返回

参数名 类型 描述
reference String 客户端系统支付流水号
yuansferId String 圆支付系统订单id
amount Decimal 订单金额
status String 订单状态
currency String 币种
refundInfo String 如果存在退款,则这里记录退款订单信息,其中又包括两个字段: ‘refundYuansferId’,‘refundAmount', 分别为圆支付系统退款订单id,退款金额.

汇率查询接口

汇率查询接口请求如下:

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




汇率查询接口返回如下:

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

该接口用于查询实时汇率

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
date true Date 日期, 'yyyyMMdd'格式
currency true Enum 币种,支持USD, CAD
vendor true Enum 支持"alipay”,“wechatpay”,“unionpay”
verifySign true String 数字签名

HTTP 返回

参数名 描述
exchangerate 汇率

In-Store API 文档

In-Store包含以下交易方式

商户扫码交易 Pos workflow

动态二维码交易 Trans qrcode flow

新增交易(商户扫码)

订单创建接口请求如下:

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

订单创建接口返回如下:

{
    "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"
    }
}

商户扫码,步骤一:收银员确认收银金额后,由商户收银台或者商户后台调用该接口将订单基本信息预先提交到支付系统,创建待支付交易订单。

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
storeAdminNo false String 店员账号
amount true Decimal 订单金额,这里是最终支付金额
verifySign true String 数字签名

HTTP 返回

参数名 描述
transactionNo 订单号
originalTransactionNo 原订单号(退款订单才有)
merchantNo 商户号
storeNo 店铺号
storeAdminNo 店员账号
amount 金额
refundAmount 退款金额
transactionType 订单类型
transactionStatus 订单状态
currency 币种
createTime 创建时间 (UTC+8)
paymentTime 支付时间 (UTC+8)
exchangeRate 汇率
vendor 支付渠道

支付(商户扫码)

支付接口请求如下:

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

支付接口返回如下:

{
    "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"
    }
}

商户扫码,步骤二:收银员使用扫码设备读取支付宝、微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台,由商户收银台或者商户后台调用该接口发起支付。

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
storeAdminNo false String 店员账号
transactionNo true String 订单号
paymentBarcode true String 用户条形码
vendor true Enum 用户选择的支付方式,支持"alipay" 或 “wechatpay”
verifySign true String 数字签名

HTTP 返回

参数名 描述
transactionNo 订单号
originalTransactionNo 原订单号(退款订单才有)
merchantNo 商户号
storeNo 店铺号
storeAdminNo 店员账号
amount 金额
refundAmount 退款金额
transactionType 订单类型
transactionStatus 订单状态
currency 币种
createTime 创建时间 (UTC+8)
paymentTime 支付时间 (UTC+8)
exchangeRate 汇率
vendor 支付渠道

新增交易(动态二维码)

交易新增接口请求如下:

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

交易新增接口返回如下:

{
    "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"
}

用户扫描商户展示在各种场景的二维码进行支付。商户根据支付宝、微信支付的规则,为不同商品服务生成不同的二维码,展示在各种场景,用于用户扫描购买。

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
verifySign true String 数字签名
currency true Enum 订单币种,目前支持USD,CAD, 具体情况依合同而定
vendor true Enum 支持"alipay",“wechatpay",即支付宝,微信
reference true String 客户系统支付流水号
amount true Decimal 订单金额
ipnUrl false String 异步回调地址,如果有填写要求支持https协议
needQrcode fasle String 是否需要yuansfer生成Qrcode图片,"true"或"false", 默认为"true”

HTTP 返回

参数名 描述
transactionNo 订单号
reference 客户系统中的支付流水号
deepLink app打开方式,链接地址
qrcodeUrl 二维码url

取消交易

交易取消接口请求如下:

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

交易取消接口返回如下:

{
    "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"
    }
}

支付交易返回失败或支付系统超时,调用该接口撤销交易。如果此订单用户支付失败,支付系统会将此订单关闭;如果用户支付成功,支付系统会将此订单资金退还给用户。

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
storeAdminNo optional String 店员账号
transactionNo optional String yuansfer订单号, 'transactionNo’ 和 ‘reference’ 不能同时为空
reference optional String 商户订单号,‘reference’ 和 ‘transactionNo’ 不能同时为空
verifySign true String 数字签名

HTTP 返回

Parameter Description
transactionNo 订单号
originalTransactionNo 原订单号 (退款订单才有)
merchantNo 商户号
storeNo 店铺号
storeAdminNo 店员账号
amount 支付金额
refundAmount 退款金额
transactionType 订单类型
transactionStatus 订单状态
currency 订单币种,目前支持USD,CAD, 具体情况依合同而定
createTime 创建时间 (UTC+8)
paymentTime 交易时间 (UTC+8)
exchangeRate 汇率
vendor 支持"alipay",“wechatpay",即支付宝,微信

退款

退款接口请求如下:

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

退款接口返回如下:

{
    "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"
    }
}

当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,支付宝、微信支付将在收到退款请求并且验证成功之后,按照退款规则将支付款按原路退到买家帐号上。

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
storeAdminNo false String 店员账号
transactionNo optional String yuansfer订单号, ‘transactionNo’ 和 ‘reference’ 不能同时为空
reference optional String 商户订单号,‘reference’ 和 ‘transactionNo’ 不能同时为空
refundAmount true Decimal 退款金额
verifySign true String 数字签名

HTTP 返回

参数名 描述
transactionNo 订单号
originalTransactionNo 原订单号(退款订单才有)
merchantNo 商户号
storeNo 店铺号
storeAdminNo 店员账号
amount 金额
refundAmount 退款金额
transactionType 订单类型
transactionStatus 订单状态
currency 币种
createTime 创建时间 (UTC+8)
paymentTime 支付时间 (UTC+8)
exchangeRate 汇率
vendor 支付渠道

查询交易

订单详情接口请求如下:

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

订单详情接口返回如下:

{
    "ret_msg": "query success ",
    "ret_code": "000100",
    "transaction": {
        "amount": 0.01,
        "createTime": "2017-12-11 00:45:22",
        "currency": "USD",
        "exchangeRate": "6.656060",
        "merchantNo": "200043",
        "originalTransactionNo": null,
        "paymentTime": "2017-12-11 00:45:31",
        "refundAmount": 0.00,
        "storeAdminNo": null,
        "storeNo": "300014",
        "transactionNo": "297553548656318669",
        "transactionStatus": "success",
        "transactionType": "payment",
        "vendor": "alipay"
    },
    "settlement": {
        "amount": "0.01",
        "fee": "0.00",
        "netReceivable": "0.01",
        "settlementAmount": "0.01",
        "settlementCurrency": "USD",
        "transactionNo": "297553548656318669"
    }
}
//订单详情
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);
}

该接口提供所有支付订单的查询,商户可以通过该接口主动查询订单状态,完成下一步的业务逻辑。

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
storeAdminNo false String 店员账号
transactionNo optional String yuansfer订单号, ‘transactionNo’ 和 ‘reference’ 不能同时为空
reference optional String 商户订单号,‘reference’ 和 ‘transactionNo’ 不能同时为空
verifySign true String 数字签名

HTTP 返回

Transaction 参数名 描述
transactionNo 订单号
originalTransactionNo 原订单号(退款订单才有)
merchantNo 商户号
storeNo 店铺号
storeAdminNo 店员账号
amount 金额
refundAmount 退款金额
transactionType 订单类型
transactionStatus 订单状态
currency 币种
createTime 创建时间 (UTC+8)
paymentTime 支付时间 (UTC+8)
exchangeRate 汇率
vendor 支付渠道
Settlement 参数名 描述
transactionNo 订单号
amount 金额
settlementCurrency 结算币种
settlementAmount 结算金额
fee 结算费用
netReceivable 结算净值=结算金额-结算费用

交易列表

订单列表接口请求如下:

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

订单列表接口返回如下:

{
    "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"
}

该接口提供了订单列表功能,一次查询的结束时间不能大于开始时间超过十天

HTTP 请求

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

POST 参数

参数 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
storeAdminNo false String 店员账号
startDate true String 开始时间, yyyyMMdd格式
endDate true String 结束时间, yyyyMMdd格式,结束时间不要超过开始时间15天
verifySign true String 数字签名

HTTP Response

Parameter Description
transactionNo 订单号
originalTransactionNo 原订单号(退款订单才有)
merchantNo 商户号
storeNo 店铺号
storeAdminNo 店员账号
amount 金额
refundAmount 退款金额
transactionType 订单类型
transactionStatus 订单状态
currency 币种
createTime 创建时间 (UTC+8)
paymentTime 支付时间 (UTC+8)
exchangeRate 汇率
vendor 支付渠道

结算列表

结算列表接口请求如下:

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

结算列表接口返回如下:

{
    "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"
}

该接口提供了结算列表查询功能,一次查询的结束时间不能大于开始时间超过15天

HTTP 请求

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

POST 参数

参数 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
storeAdminNo false String 店员账号
startDate true String 开始时间, yyyyMMdd格式
endDate true String 结束时间, yyyyMMdd格式,结束时间不要超过开始时间15天
verifySign true String 数字签名

HTTP Response

Parameter Description
merchantNo 商户号
storeNo 店铺号
storeAdminNo 店员账号
transactionNo 订单号
transactionType 订单类型
amount 交易金额
currency 交易币种
settleAmount 结算金额
settleCurrency 结算币种
fee 手续费
netSettleAmount 净结算
paymentTime 支付时间 (UTC+8)
exchangeRate 汇率
vendor 支付渠道

提现列表

提现列表接口请求如下:

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

提现列表接口返回如下:

{
    "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
    } 
    ]
}

该接口提供了提现列表查询功能,一次查询的结束时间不能大于开始时间超过15天

HTTP 请求

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

POST 参数

参数 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
storeAdminNo false String 店员账号
startDate true String 开始时间, yyyyMMdd格式
endDate true String 结束时间, yyyyMMdd格式,结束时间不要超过开始时间15天
verifySign true String 数字签名

HTTP Response

Withdrawal Parameter Description
merchantNo 商户号
salesAmount 交易金额
yuansferProcessingFee 手续费
withdrawalAmount 提现金额, withdrawalAmount=salesAmount-yuansferProcessingFee
bankSettlementFee 提现费
actualAppropriation 净提现,actualAppropriation=withdrawalAmount-bankSettlementFee
status 状态
currency 币种
date 日期
details 提现记录中关联的订单详情信息
Detail Parameter Description
transactionNo 订单号
transactionType 订单类型
transactionAmount 金额
transactionFee 手续费
transactionWithdrawalAmount 提现金额,transactionWithdrawalAmount=transactionAmount-transactionFee
transactionCurrency 币种
paymentTime 支付时间
vendor 支付渠道

数据状态

数据状态接口请求如下:

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

数据状态接口返回如下:

{
    "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"
}

该接口提供了某天数据状态查询功能

HTTP 请求

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

POST 参数

参数 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
storeAdminNo false String 店员账号
paymentDate true String 查询时间, yyyyMMdd格式
verifySign true String 数字签名

HTTP Response

DataStatus Parameter Description
merchantNo 商户号
storeNo 店铺号
paymentDate 查询日期(UTC+8)
status 状态
message 描述,status与message的映射参看下表
status message
"00” “NO_TRANSACTION”
“10” “NO_SETTLED”
“11” “PARTLY_SETTLED”
“12” “FULLY_SETTLED”

小程序支付文档

微信小程序支付权限开通流程:
1.微信小程序的主体须要是美国公司;
2.提供给小程序链接,以及小程序appid;
3.Yuansfer提交给微信官方团队审核;
4.微信开通支付权限,根据开发文档对接小程序支付。

微信小程序支付官方文档

预支付

微信小程序支付参数如下:

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

?>
/**
 * 微信小程序支付测试类
 * @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)
}

提现列表接口返回如下:

{
    "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 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
amount depends Decimal 订单金额
rmbAmount depends Decimal 订单人民币金额, “amount"和"rmbAmount"有且只能存在一个
currency true Enum 订单币种,目前支持USD
vendor true Enum "wechatpay”
ipnUrl true String 异步回调地址,要求"https"协议,用于异步通知yuansfer下游,下游返回"success" 给yuansfer即算作成功,如若失败在2小时内会重发8次。建议用异步通知更新下游系统支付流水状态。回调参数更多内容参考注意事项。
openid true 微信的openid
reference true String 客户系统中的支付流水号,要求唯一
description false String 订单描述信息
note false String 订单备注信息
verifySign true String 数字签名

HTTP 返回

参数名 描述
timeStamp 时间戳
nonceStr 随机字符串
package prepay_id等信息
signType 签名类型
paySign 签名

退款接口

退款接口请求如下:

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

退款接口返回如下:

{
    "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"
}

小程序支付退款接口,用于小程序支付退款业务

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
verifySign true String 数字签名
amount depends Decimal 退款金额
rmbAmount depends Decimal 退款人民币金额, “amount"和"rmbAmount"有且只能存在一个
reference true String 客户端系统订单id

HTTP 返回

参数名 类型 描述
status Enum 状态
reference String 客户端支付流水号
refundTransactionId String 圆支付系统退款订单id
oldTransactionId String 圆支付系统原订单id

订单查询接口

订单查询接口请求如下:

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

用于订单查询,返回订单数据。另外,比如回调延时,回调异常的时候,客户端可以主动查询此接口及时获得订单在圆支付系统中的状态:

{
    "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"
}

通过客户端自己的支付流水号查询订单状态,正因为如此圆支付要求客户端支付流水号必须唯一

HTTP 请求

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

POST 参数

参数名 是否必填 类型 描述
merchantNo true String 商户号
storeNo true String 店铺号
verifySign true String 数字签名
reference true String 客户端系统支付流水号

HTTP 返回

参数名 类型 描述
reference String 客户端系统支付流水号
yuansferId String 圆支付系统订单id
amount Decimal 订单金额
status String 订单状态
currency String 币种
refundInfo String 如果存在退款,则这里记录退款订单信息,其中又包括两个字段: ‘refundYuansferId’,‘refundAmount', 分别为圆支付系统退款订单id,退款金额.

注意事项

1.系统密码生成规则为: MD5(”@yuanex"+password)

2.圆支付系统回调时,建议客户端对回调信息进行数据校验,避免数据被篡改。

yuansfer系统回调(包括同步、异步)包含参数如下:

yuansferId: yuansfer系统订单号

status : yuansfer系统订单状态

amount : 金额

time : 时间,yyyyMMddHHmmss 格式

reference : 下游支付流水号

note : 备注

verifySign : 数字签名

3.系统中返回ret_code, “000100"表示成功, "000000"表示失败

4.Yuansfer系统时间统一采用UTC+8 时区

5.Yuansfer系统订单状态描述

no send : 新增交易订单,但未发送到支付渠道;

success :支付成功;

fail :交易失败;

pending: 支付结果未知,等待用户支付确认;

closed :已经和支付渠道进行通讯,但是商家或客户未继续完成交易,在一定时间内自动关闭;

reversed :取消交易,通过取消交易接口

6.安全支付demo

JAVA : 点击查看demo

PHP : 点击查看demo

GO : 点击查看demo

7.IN-STORE demo

JAVA : 点击查看demo

返回码

圆支付API使用如下返回码:

返回码 描述
000000 系统错误
000010 API版本错误
000020 参数为空错误
000021 参数找不到关联信息
000022 参数之间信息不匹配
000023 参数值错误
000030 没有权限
000040 订单状态异常
000080 上游系统错误
000100 成功

沙箱环境

测试账号信息:

—-ONLINE API—-
(1)yuansfer测试账号:
merchantNo : 200043
storeNo : 300014
yuansferToken : 5cbfb079f15b150122261c8537086d77a

(2)银联测试账号:
Card Number:6226388000000095
CVV:248
EXP:12/2019
Phone:18100000000
Verification Code:111111

(3)支付宝测试账号:
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


—-支付宝沙箱APK—-
https://oss.yuansfer.com/app/sandbox/wallet_101150122_release_201801221142.apk