Refund a Payment
This guide provides a comprehensive overview of Codapay's Refund API. It describes how merchants can programmatically issue refunds, retrieve refund statuses, and handle refund notifications.
Overview of Refund Scenarios
Codapay supports Refunds for Completed Payments. If the payment is incomplete or cancelled when refund is requested, it will return an error response.
1. Refund Integration Flow
Refund for Completed Payments

Refund status flow chart

2. Create Refund
Endpoint
Sample Body
Request Parameters
refundRequest
Object
Yes
Valid JSON object
refundRequest.apiKey
String
Yes
API key provided by Coda
refundRequest.txnId
Numeric
Yes
The transaction ID to refund
refundRequest.country
String
No
ISO 3166 country code
refundRequest.projectId
Numeric
Yes
Unique project ID
refundRequest.customerEmail
String
No
Customer's email address
Sample Response
Response Fields
refundResult
Object
JSON object
refundResult.id
String
Refund ID
refundResult.createdAt
String
Timestamp (ISO 8601 format)
Format:
YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)
refundResult.statusCode
String
Status: accepted, succeeded, or failed
refundResult.finalizedAt
String
Optional timestamp when refund is finalized
Format:
YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)
*If null, this field will not be included in response
refundResult.type
String
Type of refund, always "full"
refundResult.txnId
Numeric
Refunded transaction ID
refundResult.amountValue
String
Amount refunded
refundResult.amountCurrency
String
Currency of the refund
Sample Error Response
Error Response Fields
refundResult
Object
JSON object
refundResult.resultCode
Numeric
Error code
refundResult.resultDesc
String
Description of the error
Error Codes
103
Invalid API Key, Merchant Not Found, or Invalid Email
206
Transaction Not Found, Invalid Transaction
551
Duplicate Refund Request
102
Internal Server Error
3. Retrieve Refund Status
Endpoint
Sample Body
Request Parameters
refundRequest
Object
Yes
Valid JSON object
refundRequest.apiKey
String
Yes
API key provided by Coda
refundRequest.country
String
No
ISO 3166 country code
refundRequest.projectId
Numeric
Yes
Unique project ID
refundRequest.refundId
String
Yes
The ID of the refund request to retrieve
Response
refundResult
Object
JSON object
refundResult.id
String
Refund ID
refundResult.createdAt
String
Timestamp (ISO 8601 format)
Format:
YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)
refundResult.statusCode
String
Status: accepted, succeeded, , failed, user_input_pending, and processing
refundResult.finalizedAt
String
Optional timestamp when refund is finalized
Format:
YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)
*If null, this field will not be included in response
refundResult.type
String
Type of refund, always "full"
refundResult.txnId
Numeric
Refunded transaction ID
refundResult.amountValue
String
Amount refunded
refundResult.amountCurrency
String
Currency of the refund
Same as the refundResult object in the createRefund response.
4. Refund Notification Callback
Codapay sends a webhook to the configured notification URL with the refund status.
Request from Codapay
Expected Response from webhook
Key Fields
EventType
String
The type of event being sent. In this case it will be "refund"
Id
String
Refund ID
CreatedAt
String
Timestamp of when the refund was created (ISO 8601 format).
Format:
YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)
StatusCode
String
Status: accepted, succeeded, failed, user_input_pending and processing
FinalizedAt
String
Timestamp of when the refund was finalized (ISO 8601 format).
Format:
YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)
Type
String
Type of refund, always "full"
TxnId
String
Transaction ID of this refund object
AmountValue
Float
Refunded amount, up to 4 decimal point (e.g. 200.0000)
AmountCurrency
String
Currency of the refund
OrderId
String
Unique order identifier from merchant
ResultCode
Integer
Indicates payment success (0 for success).
0: Success
431: Pending
216: Pending
481: Pending
Others: Failure
Checksum
String
Checksum for validation
Checksum Generation
5. Testing in Sandbox
Refunds
Complete a payment in sandbox
Use the transaction ID to request a refund
Verify refund status using the retrieveRefund endpoint
Notify Codapay support to simulate final status if needed
Example Requests
Create Refund
Retrieve Refund
Last updated
Was this helpful?