Yuansfer DOCS
Search…
JS SDK

Import

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

Example

1. Init

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

2. Online API

1
yuansfer.securePay({
2
amount: amount, // String The price amount
3
currency: currency, // String The price currency, possible values: USD,CNY
4
settleCurrency: settleCurrency, // String The settlement currency, possible values:USD
5
vendor: vendor, //required enum Payment channel include: "alipay", "wechatpay", "unionpay", "creditcard".
6
ipnUrl: ipnUrl, //required string Asynchronous notification url address
7
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.
8
terminal: terminal, //required enum Client type include: "ONLINE", "WAP".
9
reference: reference, //required string Merchant system payment reference number, unique
10
description: description, //optional string Order description,The information will be displayed at the casher page, special characters are not supported
11
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
12
osType: osType, //String When terminal is WAP or APP, we need this parameter, the possible value is "IOS", "ANDROID"
13
timeout: timeout, //optional integer The timeout time, 120 by default, in minutes
14
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"}]
15
creditType: creditType, //optional string Credit card payment type,required when vendor=creditcard include: "normal", "recurring". default "normal"
16
paymentCount: paymentCount, //optional integer Auto-Debit ,required when vendor=creditcard, creditType=recurring, 0: no limit
17
frequency: frequency, //optional integer Auto-Debit frequency,required when vendor=creditcard, creditType = recurring, unit 'day'
18
success: function(res) { //Success callback Use when broswer does not support promise
19
},
20
error: function(res) { //Failure callback
21
}
22
}).then(res => { //Success callback Browser support promise
23
24
}).catch(res => { //Failure callback
25
26
})
Copied!

3. Offline API

1
yuansfer.createTransQrcode({
2
storeAdminNo: storeAdminNo, //optional string Store Admin Number
3
amount: amount, // String The price amount
4
currency: currency, // String The price currency, possible values: USD,CNY
5
settleCurrency: settleCurrency, // String The settlement currency, possible values:USD
6
reference: reference, //required string Yuansfer system order ID, either transactionNo or reference is required
7
ipnUrl: ipnUrl, //optional string Asynchronous notification url address
8
needQrcode: needQrcode, //optional string true or false. default true. if value is true, Yuansfer system will generate a QR Code
9
preAuth: preAuth, //optional string Prepay flag, true:prepay order,false:normal order,default false
10
timeout: timeout, //optional integer The timeout time, 120 by default, in minutes
11
})
Copied!

4. Mobile API

1
yuansfer.prepay({
2
amount: amount, // String The price amount
3
currency: currency, // String The price currency, possible values: USD,CNY
4
settleCurrency: settleCurrency, // String The settlement currency, possible values:USD
5
vendor: vendor, //required enum Payment channel include: "alipay", "wechatpay", "unionpay", "creditcard".
6
ipnUrl: ipnUrl, //required string Asynchronous notification url address
7
openid: openid, //optional string Required for WeChat-Mini Program
8
reference: reference, //required string Merchant System order ID,Unique
9
terminal: terminal, //required enum Client type "MINIPROGRAM","APP",when vendor=alipay, only support APP
10
description: description, //optional string Order description,The information will be displayed at the casher page, special characters are not supported
11
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
12
timeout: timeout, //optional integer The timeout time, 120 by default, in minutes
13
})
Copied!

5. Return API

1
yuansfer.refund({
2
amount: amount, // String The price amount
3
currency: currency, // String The price currency, possible values: USD,CNY
4
settleCurrency: settleCurrency, // String The settlement currency, possible values:USD
5
transactionNo: transactionNo, //optional string Yuansfer system order ID, either transactionNo or reference is required
6
reference: reference, //optional string Merchant System order ID, either transactionNo or reference is required
7
refundReference: refundReference,//optional string Merchant system refund reference number
8
})
Copied!
Last modified 7mo ago
Copy link