Skip to content

Create Refund

Request Method and Path

POST /payin/v1/createRefund

Request Headers

Field NameTypeRequiredDescription
content-typestringYesapplication/json
x-api-keystringYesProvided by Paydify, same as appId
x-api-timestampstringYesTimestamp in milliseconds
x-api-signaturestringYesSignature, see Signature Algorithm

Request Body

Field NameTypeRequiredDescription
mchTxnIdstring(60)YesMerchant order ID
paymentTxnIdstring(30)YesPayment order ID
typestringYesRefund responsibility:
- MERCHANT: Merchant handles refund (on-chain refund), requires txnHash
- PLATFORM: Platform handles refund (API/custodial wallet), requires refundAmount
refundAmountstring(32)ConditionalRefund amount (USDT)
- PLATFORM type: Required
- MERCHANT type: Optional, will fetch from on-chain transaction if not provided
txnHashstring(120)ConditionalBlockchain refund transaction hash
- PLATFORM type: Not required
- MERCHANT type: Required
mchExtInfostring(512)NoMerchant extension information, JSON string

Response Headers

Field NameTypeRequiredDescription
x-api-keystringYesProvided by Paydify, same as appId
x-api-timestampstringYesTimestamp in milliseconds
x-api-signaturestringYesSignature, see Signature Algorithm

Response

Field NameTypeDescription
codestringResponse code, SYS_SUCCESS indicates success
messagestringResponse message
messageDetailstringDetailed response message
successbooleanWhether the request was successful
data.refundTxnIdstringPaydify refund order ID
data.paymentTxnIdstringAssociated payment order ID
data.statestringRefund status, enum values see Refund Status
data.errorMsgstringRefund failure reason description

Examples

Platform Refund Example (Gate.io and other custodial models)

json
// Request Body
{
  "mchTxnId": "merchant_refund_123456",
  "paymentTxnId": "P2209141130105863014",
  "type": "PLATFORM",
  "refundAmount": "100.50",
  "mchExtInfo": "{\"reason\": \"customer request\"}"
}
// Request Body
{
  "mchTxnId": "merchant_refund_123456",
  "paymentTxnId": "P2209141130105863014",
  "type": "PLATFORM",
  "refundAmount": "100.50",
  "mchExtInfo": "{\"reason\": \"customer request\"}"
}

Merchant Refund Example (On-chain refund)

json
// Request Body
{
  "mchTxnId": "merchant_refund_789012",
  "paymentTxnId": "P2209141130105863015",
  "type": "MERCHANT",
  "txnHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "mchExtInfo": "{\"reason\": \"customer request\"}"
}
// Request Body
{
  "mchTxnId": "merchant_refund_789012",
  "paymentTxnId": "P2209141130105863015",
  "type": "MERCHANT",
  "txnHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "mchExtInfo": "{\"reason\": \"customer request\"}"
}

Successful Response

json
{
  "code": "SYS_SUCCESS",
  "message": null,
  "messageDetail": null,
  "data": {
    "refundTxnId": "R2209141130105863014",
    "paymentTxnId": "P2209141130105863014",
    "state": "pending",
    "errorMsg": null
  },
  "success": true
}
{
  "code": "SYS_SUCCESS",
  "message": null,
  "messageDetail": null,
  "data": {
    "refundTxnId": "R2209141130105863014",
    "paymentTxnId": "P2209141130105863014",
    "state": "pending",
    "errorMsg": null
  },
  "success": true
}

Failed Response

json
{
  "code": "SYS_ERROR",
  "message": "System error",
  "messageDetail": "Error details",
  "data": null,
  "success": false
}
{
  "code": "SYS_ERROR",
  "message": "System error",
  "messageDetail": "Error details",
  "data": null,
  "success": false
}

Notes

  1. The type parameter must match the fund custody type of the original payment order

    • For custodial payments (e.g., Gate.io), use type=PLATFORM (platform handles refund)
    • For non-custodial payments (e.g., BGW, third-party wallets), use type=MERCHANT (merchant handles refund)
  2. Parameter Dependencies

    • PLATFORM type: Must provide refundAmount, no need for txnHash
    • MERCHANT type: Must provide txnHash, refundAmount is optional
  3. Refund Processing Flow

    • PLATFORM type: Calls channel API to process refund from custodial account, usually instant
    • MERCHANT type: Validates merchant-provided on-chain refund transaction and marks as successful
  4. Idempotency

    • The same mchTxnId can only initiate one refund
    • It is recommended to use a unique identifier with a timestamp as mchTxnId