/v1/payments/merchantAccept

POST /v1/payments/merchantAccept

The merchantAccept API is used in escrow payment scenarios. After the mini-app merchant reviews the customer’s order and verifies that the items are in stock and everything is fine (conditions are satisfied, etc.), the merchant may call this OpenAPI to accept the order.

Message structure

A message consists of a header and body. The following sections focus on the body structure. For the header structure, see:

Request

Property

Data Type

Required

Description

Example

paymentId

String

Yes

The unique ID that is assigned by the wallet to identify a payment.

Max. length: 64 characters.

"2023120611121280010016600090000xxxx"

Response

Property

Data Type

Required

Description

Example

result

Result

Yes

The request result, which contains information such as result status and error codes.

{

   "resultCode": "SUCCESS",

   "resultStatus": "S",

   "resultMessage": "Success."  

 }

Result process logic

In the response, the result.resultStatus field indicates the result of processing a request. The following table describes each result status:

resultStatus

Description 

S

It means that the merchant accept is successful.

The corresponding result.resultCode is "SUCCESS", and the

result.resultMessage is "Success.".

It means that the merchant accept is successful.

The corresponding result.resultCode is "SUCCESS", and the

result.resultMessage is "Success.".

U

It means that the status of the merchant accept result is unknown.

The corresponding result.resultCode is UNKNOWN_EXCEPTION, and

result.resultMessage is "An API calling is failed, which is caused by unknown reasons". For details, see the Common error codes section.

F

It means that the merchant accept fails.

The corresponding result.resultCode and

result.resultMessage may vary based on different situations. For details, see the Error codes section.

Error codes

Error codes are usually classified into the following categories:

  • Common error codes are common across all mini program's APIs.  
  • API-specific error codes: are listed in the following table.

resultStatus

resultCode

resultMessage

F

ORDER_UNSUPPORTED_OPERATION

The order not supported the operation.

F

ORDER_STATUS_INVALID

The order status is invalid.

F

ORDER_NOT_EXIST

The order does not exist.

F

ORDER_IS_FROZEN

The order is frozen.

F

ORDER_IS_MERCHANT_ACCEPTED

The order has been accepted by merchant.

F

CURRENCY_NOT_SUPPORT

The currency of a user's payment is not supported by the merchant.

F

USER_NOT_EXIST

The user does not exist.

F

USER_STATUS_ABNORMAL

The user status is abnormal.

F

PARTNER_NOT_EXIST

The partner does not exist.

F

PARTNER_STATUS_ABNORMAL

The partner status is abnormal.

Samples

For example, a customer pays 1,000 IQD for a meal on a food delivery platform. After the order is delivered and the customer verifies that the items are correct and in good condition (e.g., correct quantity, acceptable quality, no spillage), the customer may then confirm the order.

image.png

  1. The Mini Program calls this my.getAuthCode JSAPI with specific scopes(USER_ID) to request an authorization code.
  2. The E-wallet App service calls authorization service to processes the authorization information.
  3. The E-wallet backend verifies the authorization information, generates the authCode and returns.
  4. The E-wallet App service returns the authCode to the Mini Program.
  5. The Mini Program sends the authCode to the merchant backend.
  6. The merchant backend calls the applyToken API with authCode to apply the accessToken.
  7. The E-Wallet backend returns accessToken information to the merchant backend, such as customerId, accessToken, refreshToken, etc.
  8. The merchant backend returns customerId to mini program.
  9. The Mini Program creates an order with customerId.
  10. The merchant backend calls the payment API to initialte payment flow, including customerId as referenceBuyerId, paymentNotifyUrl(optional), etc.
  11. The E-Wallet backend returns payment detail information the merchant backend, such as redirectionUrl.
  12. The merchant backend passes the payment detail information to the Mini Program.
  13. The Mini Program calls the my.tradePay JSAPI with redirectionUrl to conduct the payment.
  14. The E-Wallet App Service displays the cashier page with order information, such as amount, order details, etc.
  15. The user confirms the payment in the cashier page.
  16. The E-Wallet App Service calls payment service and execute the payment process.
  17. When the payment reaches the final status, the E-wallet backend returns the payment result to the Mini Program (Step 19).
  18. The E-Wallet App Service returns the payment result to mini program.
  19. Also the E-wallet backend notifies the merchant backend of the payment result with paymentNotifyUrl provided in Step 10.
  20. Finally, E-wallet backend notifies the user of the payment result via SMS/Email/Inbox message .
  21. Merchant backend calls the merchantAccept API to accept this order.
  22. The E-Wallet backend returns the merchantAccept result to the merchant backend.

Request

copy
{
 "paymentId":"20240719111212800100166017200026447",
}
  • paymentId is the unique Id of a payment generated by Wallet, which is the unique payment identifier associated with this capture.

Response

copy
{
 "result": {
    "resultCode":"SUCCESS",
    "resultStatus":"S",
    "resultMessage":"Success."
 }
}
  • result.resultStatus==S shows that the Wallet capture is successful.