Yuansfer API 文档
搜索文档…
JS SDK

引入方式

<script src="Yuansfer-js-sdk.js"></script>
或者
import yuansfer from 'Yuansfer-js-sdk'

范例

1. 初始化

yuansfer.init({
merchantNo: '******', //必填
storeNo: '******', //必填
token: '**********', //必填
isvFlag: 1 || 0, //必填 1:服务商; 0:普通商户
merGroupNo: '*******', //isvFlag = 1为必填
env: 'test' // 选填 默认 prod-生产,test-测试
})

2. 在线API

yuansfer.securePay({
amount: amount, // String The price amount
currency: currency, // String The price currency, possible values: USD,CNY
settleCurrency: settleCurrency, // String The settlement currency, possible values:USD
vendor: vendor, //required enum 支付渠道 包括: "alipay", "wechatpay", "unionpay", "creditcard".
ipnUrl: ipnUrl, //required string 异步通知url地址
callbackUrl: callbackUrl, //required string 同步回调url地址。同步回调地址支持宏替换规则 xxxcallback_url?trans_no={amount}&amount={amount}, Yuansfer系统会替换{}中的内容.
terminal: terminal, //required enum 客户端类型 包括: "ONLINE", "WAP".
reference: reference, //required string 商户系统支付流水号,要求唯一
description: description, //optional string 订单信息描述,该信息将会展示在收银台,不支持特殊字符
note: note, //optional string 订单备注信息,该信息将会在回调的时候原样返回给商户系统,不支持特殊字符
osType: osType, //String When terminal is WAP or APP, we need this parameter, the possible value is "IOS", "ANDROID"
timeout: timeout, //optional integer 超时时间 默认120,单位分钟
goodsInfo: goodsInfo, //required string 订单商品信息,使用JSON格式,不支持特殊字符 例如: [{"goods_name":"name1","quantity":"quantity1"},{"goods_name":"name2","quantity":"quantity2"}]
creditType: creditType, //optional string 信用卡支付类型,只有当vendor=creditcard时需要 包括: "normal"(普通支付), "recurring"(自动扣款). 默认为 "normal"
paymentCount: paymentCount, //optional integer 自动扣款次数,只有当vendor=creditcard, creditType=recurring时需要 0 表示无截止日期
frequency: frequency, //optional integer 自动扣款频率,只有当vendor=creditcard, creditType=recurring时需要 单位'天'
success: function(res) { //成功回调 浏览器不支持promise使用
},
error: function(res) { //失败回调
}
}).then(res => { //成功回调 浏览器支持promise
}).catch(res => { //失败回调
})

3. 线下API

yuansfer.createTransQrcode({
storeAdminNo: storeAdminNo, //optional string 店员号
amount: amount, // String The price amount
currency: currency, // String The price currency, possible values: USD,CNY
settleCurrency: settleCurrency, // String The settlement currency, possible values:USD
reference: reference, //required string 商户系统支付流水号,要求唯一
ipnUrl: ipnUrl, //optional string 异步通知url地址
needQrcode: needQrcode, //optional string 值为: true 或者 false. 默认为 true. 如果值为 true, Yuansfer系统将会创建二维码图片 如果值为 false, Yuansfer系统将不会创建二维码图片
preAuth: preAuth, //optional string 预付款标志, true表示预付款订单,false为普通订单, 默认false
timeout: timeout, //optional integer 超时时间 默认120,单位分钟
})

4. 手机API

yuansfer.prepay({
amount: amount, // String The price amount
currency: currency, // String The price currency, possible values: USD,CNY
settleCurrency: settleCurrency, // String The settlement currency, possible values:USD
vendor: vendor, //required enum 支付渠道 包括: "alipay", "wechatpay", "unionpay", "creditcard".
ipnUrl: ipnUrl, //required string 异步通知url地址
openid: openid, //optional string 微信小程序需要用到
reference: reference, //required string 商户系统支付流水号,要求唯一
terminal: terminal, //required enum 客户端类型 "MINIPROGRAM","APP",vendor=alipay时暂时只支持APP
description: description, //optional string 订单信息描述,该信息将会展示在收银台,不支持特殊字符
note: note, //optional string 订单备注信息,该信息将会在回调的时候原样返回给商户系统,不支持特殊字符
timeout: timeout, //optional integer 超时时间 默认120,单位分钟
})

5. 退款API

yuansfer.refund({
amount: amount, // String The price amount
currency: currency, // String The price currency, possible values: USD,CNY
settleCurrency: settleCurrency, // String The settlement currency, possible values:USD
transactionNo: transactionNo, //optional string Yuansfer系统订单ID transactionNo 和 reference 有且只能存在一个
reference: reference, //optional string 商户系统支付流水号 Either transactionNo or reference 有且只能存在一个
refundReference: refundReference,//optional string 商户系统退款流水号
})
复制链接
大纲
引入方式
范例