Creates a transaction and returns a transaction number for completing the payment with the my.tradePay mini program method.
Common request parameters
|
Parameter |
Type |
Required |
Maximum length |
Description |
Example |
|
app_id |
String |
required |
32 |
The mini program ID. |
2014072300007148 |
|
method |
String |
required |
128 |
The API name. |
trade.create |
|
format |
String |
optional |
40 |
Only JSON is supported. |
JSON |
|
charset |
String |
required |
10 |
The character set used in the request, such as utf-8, gbk, or gb2312. |
utf-8 |
|
sign_type |
String |
required |
10 |
The signature algorithm. Valid values: RSA2 and RSA. |
RSA2 |
|
sign |
String |
required |
344 |
The request signature. For details, see Signature. |
See example |
|
timestamp |
String |
required |
19 |
The request timestamp in the format |
2014-07-24 03:07:50 |
|
version |
String |
required |
3 |
The API version. Set this to 1.0. |
1.0 |
|
biz_content |
String |
required |
- |
A JSON string containing all biz-specific request parameters. No maximum length. |
- |
Biz-specific request parameters
|
Parameter |
Type |
Required |
Maximum length |
Description |
Example |
|
out_trade_no |
String |
required |
64 |
A unique, merchant-defined order number. Can contain only letters, digits, and underscores. |
20150320010101001 |
|
total_amount |
String |
required |
9 |
The total order amount. Must be precise to two decimal places and in the range [0.01, 100000000]. |
88.88 |
|
subject |
String |
required |
256 |
The order title. Important
Do not use special characters, such as /, =, and &. |
iPhone6 16G |
|
product_code |
String |
required |
64 |
The product code. Set to JSAPI_PAY for mini program payments. |
JSAPI_PAY |
|
op_app_id |
String |
required |
32 |
The app ID of the merchant's mini program that initiates the payment. |
2014072300007148 |
|
buyer_open_id |
String |
required |
128 |
The buyer's unique identifier. |
074a1CcTG1LelxKe4xQC0zgNdId0nxi95b5lsNpazWYoCo5 |
|
body |
String |
optional |
128 |
Additional order information. Returned unmodified in asynchronous notifications and on statements. Also appears as the transaction description in billing details for both the merchant and buyer. |
iPhone6 16G |
Sample request
Example:
curl 'https://xxxx/gateway.do?charset=UTF-8&method=trade.create&format=json&sign=${sign}&app_id=${appid}&version=1.0&sign_type=RSA2×tamp=${now}' \
-F 'biz_content={
"out_trade_no":"20150320010101001",
"product_code":"JSAPI_PAY",
"op_app_id":"2014072300007148",
"total_amount":"88.88",
"subject":"iphone6 16G",
"body":"iphone6 16G",
"buyer_open_id":"074a1CcTG1LelxKe4xQC0zgNdId0nxi95b5lsNpazWYoCo5"
}'
This example is for reference only.
Common response parameters
|
Parameter |
Type |
Required |
Maximum length |
Description |
Example |
|
code |
String |
required |
- |
The gateway result code. |
40004 |
|
msg |
String |
required |
- |
The gateway result code description. |
Business Failed |
|
sub_code |
String |
optional |
- |
The service result code. For details, see the error code reference. |
ACQ.TRADE_HAS_SUCCESS |
|
sub_msg |
String |
optional |
- |
The service result code description. For details, see the error code reference. |
Transaction has been paid |
|
sign |
String |
required |
- |
The signature. |
DZXh8eeTuAHoYE3w1J+POiPhfDxOYBfUNn1lkeT/V7P4zJdyojWEa6IZs6Hz0yDW5Cp/viufUb5I0/V5WENS3OYR8zRedqo6D+fUTdLHdc+EFyCkiQhBxIzgngPdPdfp1PIS7BdhhzrsZHbRqb7o4k3Dxc+AAnFauu4V6Zdwczo= |
Biz-specific response parameters
|
Parameter |
Type |
Required |
Maximum length |
Description |
Example |
|
out_trade_no |
String |
required |
64 |
The merchant order number. |
20150423001001 |
|
trade_no |
String |
required |
64 |
The Payme transaction number. |
2015042321001004720200028594 |
Sample response
{
"trade_create_response": {
"code": "10000",
"msg": "Success",
"out_trade_no": "20150423001001",
"trade_no": "2015042321001004720200028594"
},
"sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}