Yuansfer DOCS
Search…
JS SDK

Import

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

Example

1. Init

yuansfer.init({
merchantNo: '******', //Required
storeNo: '******', //Required
token: '**********', //Required
isvFlag: 1 || 0, //Required 1:Service provider; 0:Merchant
merGroupNo: '*******', //If isvFlag = 1, it is required
env: 'test' // Optional, Possible value: prod or test
})

2. Online 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 Payment channel include: "alipay", "wechatpay", "unionpay", "creditcard".
ipnUrl: ipnUrl, //required string Asynchronous notification url address
callbackUrl: callbackUrl, //required string Synchronous callback url address。Synchronous callback address supports macro replacement rules xxxcallback_url?trans_no={amount}&amount= {amount}, Yuansfer will replace{} content.
terminal: terminal, //required enum Client type include: "ONLINE", "WAP".
reference: reference, //required string Merchant system payment reference number, unique
description: description, //optional string Order description,The information will be displayed at the casher page, special characters are not supported
note: note, //optional string Order notes,The info will be returned to the merchant system as it is when the callback is made, and special characters are not supported
osType: osType, //String When terminal is WAP or APP, we need this parameter, the possible value is "IOS", "ANDROID"
timeout: timeout, //optional integer The timeout time, 120 by default, in minutes
goodsInfo: goodsInfo, //required string Order goods,JSON format,special characters are not supported, such as: [{"goods_name":"name1","quantity":"quantity1"}, {"goods_name":"name2","quantity":"quantity2"}]
creditType: creditType, //optional string Credit card payment type,required when vendor=creditcard include: "normal", "recurring". default "normal"
paymentCount: paymentCount, //optional integer Auto-Debit ,required when vendor=creditcard, creditType=recurring, 0: no limit
frequency: frequency, //optional integer Auto-Debit frequency,required when vendor=creditcard, creditType = recurring, unit 'day'
success: function(res) { //Success callback Use when broswer does not support promise
},
error: function(res) { //Failure callback
}
}).then(res => { //Success callback Browser support promise
}).catch(res => { //Failure callback
})

3. Offline API

yuansfer.createTransQrcode({
storeAdminNo: storeAdminNo, //optional string Store Admin Number
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 Yuansfer system order ID, either transactionNo or reference is required
ipnUrl: ipnUrl, //optional string Asynchronous notification url address
needQrcode: needQrcode, //optional string true or false. default true. if value is true, Yuansfer system will generate a QR Code
preAuth: preAuth, //optional string Prepay flag, true:prepay order,false:normal order,default false
timeout: timeout, //optional integer The timeout time, 120 by default, in minutes
})

4. Mobile 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 Payment channel include: "alipay", "wechatpay", "unionpay", "creditcard".
ipnUrl: ipnUrl, //required string Asynchronous notification url address
openid: openid, //optional string Required for WeChat-Mini Program
reference: reference, //required string Merchant System order ID,Unique
terminal: terminal, //required enum Client type "MINIPROGRAM","APP",when vendor=alipay, only support APP
description: description, //optional string Order description,The information will be displayed at the casher page, special characters are not supported
note: note, //optional string Order notes,The info will be returned to the merchant system as it is when the callback is made, and special characters are not supported
timeout: timeout, //optional integer The timeout time, 120 by default, in minutes
})

5. Return 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 system order ID, either transactionNo or reference is required
reference: reference, //optional string Merchant System order ID, either transactionNo or reference is required
refundReference: refundReference,//optional string Merchant system refund reference number
})
Copy link
On this page
Import
Example