Payments

inquiryRefund

Poll refund status when asynchronous notifications are delayed.

Overview

POST /v1/payments/inquiryRefund retrieves the current status of a wallet refund. Use this endpoint when the refund completion callback takes longer than expected. All monetary amounts must be sent in the smallest currency unit (IQD fils).

  • Poll no more than once every 5 seconds (up to 1 minute) to reduce load.
  • Refund amounts and amounts in responses use the smallest currency unit, e.g. 100 IQD → 100000.

  1. Mini Program calls my.getAuthCode with USER_ID scope to request authorization.
  2. Wallet app service calls the authorization service to validate the request.
  3. Wallet backend returns authCode to the wallet app service.
  4. Wallet app service returns authCode to the Mini Program.
  5. Mini Program sends the authCode to the merchant backend.
  6. Merchant backend invokes applyToken with the authCode to obtain tokens.
  7. Wallet backend returns token data (accessToken, refreshToken, customerId) to the merchant backend.
  8. Mini Program creates an order using customerId.
  9. Merchant backend initiates the payment request with /v1/payments/pay, providing customerId, paymentNotifyUrl, etc.
  10. Wallet backend returns payment details (including redirectionUrl) to the merchant backend.
  11. Merchant backend forwards the payment details to the Mini Program.
  12. Mini Program calls my.tradePay with the redirectionUrl.
  13. Wallet app service opens the cashier page with order information.
  14. Wallet app service displays the cashier UI to the user.
  15. User confirms payment within the cashier UI.
  16. Wallet app service triggers the payment execution in the backend.
  17. Wallet backend processes the payment and returns the result to the wallet app service.
  18. Mini Program receives the payment result from the wallet backend.
  19. Wallet backend sends payment notifications to the merchant backend via paymentNotifyUrl.
  20. Wallet backend notifies the user via SMS/email/inbox of the payment outcome.
  21. User initiates a full or partial refund after receiving goods/services.
  22. Mini Program submits the refund request to the merchant backend.
  23. Merchant backend calls /v1/payments/refund to request the refund from the wallet backend.
  24. Wallet backend returns the refund processing result to the merchant backend.
  25. Wallet backend returns refund status to the Mini Program (displayed to user).
  26. Mini Program shows the refund result in the UI.
  27. If resultCode of the refund is REFUND_IN_PROCESS, merchant backend polls /v1/payments/inquiryRefund using refundId or refundRequestId.
  28. Wallet backend responds with the latest refund inquiry result to the merchant backend.

Endpoint

MethodPath
POST/v1/payments/inquiryRefund

API Structure

A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see: OpenAPIs Overview.

Request

FieldTypeRequiredDescriptionExample
refundIdstringConditionalWallet-generated refund ID (max 64 characters). Provide either refundId or refundRequestId."202312061112128013001660090000xxxx"
refundRequestIdstringConditionalMerchant-generated refund ID (max 64 characters). Used when refundId is not available."2023010123456789013255xxxx"
{
  "refundId": "202312061112128013001660090000xxxx",
  "refundRequestId": "2023010123456789013255xxxx"
}

If both identifiers are supplied, refundId takes precedence and refundRequestId is ignored.

Response

FieldTypeRequiredDescriptionExample
resultobjectYesOutcome metadata, including resultCode, resultStatus, and resultMessage.{ "resultCode": "SUCCESS", "resultStatus": "S", "resultMessage": "success" }
refundIdstringNoWallet refund ID."202312061112128013001660090000xxxx"
refundRequestIdstringNoMerchant refund ID."2023010123456789013255xxxx"
refundAmountobjectNoRefund amount/value in smallest currency unit.{ "value": "100000", "currency": "IQD" }
refundReasonstringNoReason for the refund, if supplied (max 256 characters)."Customer requested order cancellation."
refundTimestringNoTimestamp when funds were deducted from the merchant (ISO 8601)."2023-01-02T12:01:01+08:30"
refundStatusstringNoRefund processing state: PROCESSING, SUCCESS, or FAIL."SUCCESS"
refundFailReasonstringNoDescription explaining why the refund failed (present when refundStatus is FAIL)."Refund declined by issuer."
extendInfostringNoAdditional metadata provided by wallet or merchant (max 2048 characters)."extendInfo": "additional info"
{
  "result": {
    "resultCode": "SUCCESS",
    "resultStatus": "S",
    "resultMessage": "success"
  },
  "refundId": "202312061112128013001660090000xxxx",
  "refundRequestId": "2023010123456789013255xxxx",
  "refundAmount": {
    "value": "100000",
    "currency": "IQD"
  },
  "refundReason": "Order cancelled by user.",
  "refundTime": "2023-01-02T12:01:01+08:30",
  "refundStatus": "SUCCESS"
}

Result Processing Logic

StatusDescription
SRefund inquiry succeeded. Inspect refundStatus for the current state.
UUnknown result (resultCode: UNKNOWN_EXCEPTION). Retry later or review logs.
FInquiry failed. Review resultCode/resultMessage; see Error codes.

Error Codes

resultStatusresultCoderesultMessageRecommended Action
FREFUND_NOT_EXISTRefund does not exist.Verify refundId/refundRequestId; treat as pending if refund is still in process.