Yuansfer DOCS
Search…
Prepay
Referred to as prepay
post
https://mapi.yuansfer.com/micropay/v3
/prepay
Prepay
Response
Parameter
Type
Description
result
object
The wechat-mini result object.
The wechat-app result object.
The alipay-app result object.
ret_msg
string
The response return message.
ret_code
string
The response return code. For more details, see here.
wehcat-mini result object
Parameter
Type
Description
timeStamp
string
The timestamp.
nonceStr
string
A random string.
package
string
prepay_id information.
signType
string
The signature type.
paySign
string
The signature.
wechat-app result object
Parameter
Type
Description
appid
string
The App Id.
noncestr
string
A random string.
package
string
The value is 'Sign=WXPay'.
partnerid
string
partnerid information.
prepayid
string
prepay_id information.
sign
string
The signature.
timestamp
string
The timestamp.
alipay-app result object
Parameter
Type
Description
payInfo
string
The payment information.
cURL
PHP
Java
Go
1
curl -XPOST -H "Content-type: application/json" -d '{
2
"merchantNo": "200043",
3
"storeNo": "300014",
4
"verifySign": "09f722178f6cf2e71c9dfdd664e8663b",
5
"amount": "10",
6
"currency": "CNY",
7
"settleCurrency": "USD",
8
"ipnUrl": "http://zk-tys.yunkeguan.com/login/test",
9
"reference": "test2020101302",
10
"description": "司机支付会员费用",
11
"vendor": "wechatpay",
12
"terminal": "MINIPROGRAM",
13
"openid": "ocBgh5fnabrf-pxPgCWXlq2mOvG8"
14
}' 'https://mapi.yuansfer.com/micropay/v3/prepay'
Copied!
1
<?php
2
function microprepay()
3
{
4
$url = 'https://mapi.yuansfer.com/micropay/v3/prepay';
5
$token = '5cbfb079f15b150122261c8537086d77a';
6
$params = [
7
'merchantNo' => '200043',
8
'storeNo' => '300014',
9
'amount' => '0.01',
10
'currency' => 'USD',
11
'settleCurrency' => 'USD',
12
'vendor' => 'wechatpay',
13
'ipnUrl' => 'https://nengjtian.s1.natapp.cc/login/test',
14
'reference' => 'test2018070101',
15
'description' => 'test_description',
16
'note' => 'test_note',
17
'openid' => '***'
18
];
19
ksort($params, SORT_STRING);
20
$str = '';
21
foreach ($params as $k => $v) {
22
$str .= $k . '=' . $v . '&';
23
}
24
$params['verifySign'] = md5($str . md5($token));
25
echo 'verifySign:', $params['verifySign'];
26
echo "\n";
27
$ch = curl_init($url);
28
curl_setopt_array($ch, array(
29
CURLOPT_RETURNTRANSFER => true,
30
CURLOPT_HEADER => false,
31
CURLOPT_POST => true,
32
CURLOPT_POSTFIELDS => http_build_query($params),
33
));
34
$result = curl_exec($ch);
35
curl_exec($ch);
36
echo $result;
37
echo "\n";
38
return json_decode($result, true);
39
}
40
microprepay();
41
?>
Copied!
1
public class MicropayTest {
2
3
public static final String TEST_URL = "https://mapi.yuansfer.yunkeguan.com"; //testing domain
4
public static final String PROD_URL = "https://mapi.yuansfer.com"; //production domain
5
public static final String YUANSFER_TOKEN = "5c5fe30183be69fceff8174358d4b8ae";
6
7
8
public static void main(String[] args) {
9
YuansferVerifySignHelper helper = new YuansferVerifySignHelper();
10
11
AppMircopayDto dto = paramSetting();
12
Map<String, Object> params = ReflectionUtils.convertBean2MapIgnoreNullVal(dto, new String[]{"serialVersionUID"});
13
String verifySign = helper.getYuansferVerifySign(params, YUANSFER_TOKEN);
14
params.put("verifySign", verifySign);
15
16
String url = TEST_URL + "/micropay/v2/prepay";
17
String ret = HttpClientUtils.post(url, null, params);
18
System.out.println(ret);
19
}
20
21
public static AppMircopayDto paramSetting() {
22
AppMircopayDto dto = new AppMircopayDto();
23
/**
24
* merchantNo,storeNo is necessory, and they are provided by Yuansfer
25
*/
26
dto.setMerchantNo("200043"); //The Merchant NO.
27
dto.setStoreNo("300014"); //The Store NO.
28
29
/**
30
* transaction infomation is necessory
31
*/
32
dto.setAmount("0.01"); //The amount, unit "division"
33
dto.setCurrency("USD"); //currency, "USD"
34
dto.setSettleCurrency("USD"); //SettleCurrency, "USD"
35
dto.setIpnUrl("https://nengjtian.s1.natapp.cc/login/test"); //Asynchronous callback address
36
dto.setReference("9091023122"); //order NO. of client's system
37
dto.setOpenid("***"); //wechat openid
38
dto.setVendor("wechatpay"); //"wechatpay"
39
40
/**
41
* note,desription are optional
42
*/
43
dto.setDescription("test-description"); //description
44
dto.setNote("test-note"); //note
45
46
return dto;
47
}
48
}
Copied!
1
func mciropay(t *table) {
2
req := yuan.Securepay{
3
MerchantNo: "200043", //customer The merchant NO.
4
StoreNo: "300014",
5
Currency: "USD",
6
SettleCurrency: "USD",
7
Amount: "0.01",
8
Vendor: "wechatpay",
9
Reference: fmt.Sprintf("demo_%d", time.Now().Unix()), //sequence number of customer system
10
IpnUrl: "https://customer-ipn", //internet accessible
11
Description: "description",
12
Note: "note",
13
Openid: "***",
14
}
15
resp, err := req.PostToYuansfer(yuansferToken)
16
if err != nil {
17
fmt.Println(err)
18
return
19
}
20
fmt.Println(resp)
21
}
Copied!
Last modified 1mo ago
Copy link