/v1/payments/pay
POST /v1/payments/pay
The pay
API is used to initiate a payment request to wallets.
Note: A payment which takes place at wallets.
1)The merchant/partner initiates a payment request to wallet through this interface.
2)The wallet will handle different payment scenarios based on the parameters in the request.
Currently, this API support following scenarios:
- Cashier payment:Usually used in the online payment scenario. In this scenario, the merchant/partner will call this API to create an order, and the wallet will return the cashier page URL to the merchant/partner, and then redirect to this cashier page. So user can finish the payment in the cashier page.
Message structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Request
Property | Data type | Required | Description | Example |
productCode | String | Yes | The product code, Max. length: 32 characters. | "51051000101000000011" |
paymentRequestId | String | Yes | The unqiue ID of a payment generated by merchants.
| "2019112719074101000700000077771xxxx" |
paymentAmount | Yes | The order amount, displaying users' consumption records, payment results page. | { "currency": "CLP", "value": "10000" } | |
order | Yes | The purchase order details, such as Merchant, Buyer, Goods, etc. The information in the Order is only used to display user's payment result page and transactions history, regulation reporting, etc. It will not make use of the amount in the order for fund operation. | { "referenceOrderId":"OrderID_0101010101xxxx", "orderDescription":"SHOES", "orderAmount":{ "currency": "CLP", "value": "10000" }, "orderCreateTime": "2020-01-01T12:01:01+08:30", "merchant":{ "referenceMerchantId":"M00000000001xxxx", "merchantMCC":"1405", "merchantName":"UGG Technology Limited", "merchantDisplayName":"UGG", "merchantAddress":{ "region":"MY", "city":"KL" } }, "env": { "osType": "IOS", "terminalType": "APP" } } | |
paymentExpiryTime | String | No | The payment order close time defined by merchant, which follows the ISO 8601 standard. | "2020-06-08T12:12:12+08:00" |
paymentNotifyUrl | String | No | The payment success notification URL defined by merchants. Max. length: 1024 characters. | "https://www.merchant.com/paymentNotifyxxx" |
paymentAuthCode | String | No | The payment auth code generated by the wallet, such as the accessToken in the agreement pay scenario. Max. length: 128 characters. | "000000000220231001JfQ6vpiUNV79nT00006725" |
Response
Property | Data type | Required | Description | Example |
result | Yes | The request result, which contains information related to the request result, such as status and error codes. | { "resultCode": "SUCCESS", "resultStatus": "S", "resultMessage": "success" } | |
paymentId | String | No | The unqiue ID of a payment generated by Wallet. Max. length: 64 characters. | "4374784884773748478499xxxx" |
paymentTime | String/Datetime | No | Payment success time, which follows the ISO 8601 standard. | "2020-01-08T12:12:12+08:00" |
redirectActionForm | No | Indicates a redirect URL. | { "method":"POST", "redirectionUrl":"https://www.wallet.com/cashier?orderId=xxxxxxx" } |
Result process logic
In the response, the result.resultStatus
field indicates the result of processing a request as follows.
resultStatus | Decription |
S | The corresponding That means that this transaction is successful. The merchant/partner can update transaction to success. What needs to note is :
|
U | The corresponding That means that unknown exception occurs on the wallet side. The merchant/partner can inquiry the payment result or wait for the payment status notification to get the real payment result. What needs to note is :
|
F | That means this transaction is failed. The corresponding Usually the `F` transactions can not be successful again if use the same payment request to call wallets. |
Error codes
Error codes are usually classified into the following categories:
- Common error codes: are common for all Mini Program OpenAPIs.
- API-specific error codes: are listed in the following table.
resultStatus | resultCode | resultMessage |
S | SUCCESS | Success |
F | NO_INTERFACE_DEF | API is not defined. |
F | MSG_PARSE_ERROR | Message parsed error. |
F | FUNCTION_NOT_MATCH | Function parameter does not match API. |
F | INVALID_CLIENT | INVALID_CLIENT Invalid client. |
F | INVALID_SIGNATURE | INVALID_SIGNATURE Signature is invalid. |
F | INVALID_CLIENT_STATUS | Invalid client status. |
S | REPEAT_REQUEST | repeat order create request, merchantTransId = xxx |
F | PAYMENT_AMOUNT_EXCEED_LIMIT | Payment amount exceeds limit. |
F | USER_NOT_EXIST | User not exist. |
F | USER_STATUS_ABNORMAL | The user status is abnormal. |
F | USER_BALANCE_NOT_ENOUGH | User balance is not enough for this payment. |
F | PARTNER_NOT_EXIST | Partner not exist. |
Sample
Cashier Payment
For example, a user purchases a 100 USD good at the merchant/partner(online merchant usually) , the merchant/partner calls this API to create the payment order first, the wallet will return the payment order ID and wallet cashier page URL to the merchant/partner, then merchant/partner can redirect user to wallet cashier page with the my.tradePay
API.
- The Mini Program creates an order.
- The merchant server calls this pay interface with paymentNotifyUrl to initialte payment flow.
- E-wallet server returns payment detail information with paymentId to the merchant server.
- The merchant server passes the payment detail information to the Mini Program.
- The Mini Program calls the my.tradePay interface to conduct the payment.
- When the payment reaches the final status, the e-wallet server notifies the merchant server of the payment result with paymentNotifyUrl provided in Step 2 (Step 8).
- Also the E-wallet App returns the payment result to the Mini Program (Step 9).
Request
{
"paymentRequestId": "2019112719074101000700000077771xxxx",
"productCode": "51051000101000000011",
"paymentAmount": {
"currency": "CLP",
"value": "2000"
},
"paymentNotifyUrl": "http://alipayplusmerchant.com/api/v1/payments/paymentNotify.htm",
"order": {
"orderDescription": "iphone details",
"goods": {
"referenceGoodsId": "goods123",
"goodsName": "mobile1"
},
"buyer": {
"referenceBuyerId": "6227800026802"
}
}
}
- paymentRequestId is generated by the merchant/partner, which uniquely identifies the payment. Wallet must make use of paymentRequestId for idempotent control. For example, if a payment with paymentRequestId== 2019112719074101000700000077771 has been processed successfully by Wallet, when the merchant/partner uses the same paymentRequestId for payment, Wallet will respond with sucessful payment.
- productCode is the product code, including the
51051000101000000012
information
- paymentNotifyUrl is the URL defined by the merchant/partner. In the cashier payment scenario, after the user finished payment in the wallet cashier page, the wallet will notify the merchant of the payment result based on this URL.
- paymentAmount describes the amount of 100 USD to be collected by Wallet from user's account for this payment.
- order describes the order details of the purchase of the 100CNY merchandise by the user at the merchant. Such as Merchant, Buyer, Goods, etc are included in order . The information in the Order is only used to display user's payment result page and transactions history, regulation reporting, etc. It will not make use of the amount in the order for fund operation.
Response
{
"result": {
"resultCode":"SUCCESS",
"resultStatus":"S",
"resultMessage":"Success"
},
"paymentId": "4374784884773748478499xxxx",
"paymentTime": "2022-11-24T18:34:09+08:00",
"redirectActionForm":{
"method":"POST",
"redirectionUrl":"https://www.wallet.com/cashier?orderId=xxxxxxx"
}
}
- result.resultStatus == S shows that the payment is accept success. After user finish payment in cashier page, payment will change to success.
- paymentId is generated by Wallet, uniquely identifies the payment.
- redirectActionForm returns the cashier page URL to the merchant/partner. After the merchant/partner receives the accept result, which will be redirected to this URL.