For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

Refund API requires special approval, and is only available to payments that are made via Codapay APIs. Please contact your Account Manager or our integration support team for approval.

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 for Cancelled Payments

2. Create Refund

Endpoint

Sample Body

Request Parameters

Parameter
Type
Mandatory
Description

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

Parameter
Type
Description

refundResult

Object

JSON object

refundResult.id

String

Refund ID

refundResult.createdAt

String

Timestamp (ISO 8601 format)

Possible formats:

YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)

YYYY-MM-DDThh:mm:ss.sssssssssZ (up to nanoseconds)

refundResult.statusCode

String

Status: accepted, succeeded, or failed

refundResult.finalizedAt

String

Optional timestamp when refund is finalized

Possible formats:

YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)

YYYY-MM-DDThh:mm:ss.sssssssssZ (up to nanoseconds)

*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

Numeric

Amount refunded

refundResult.amountCurrency

String

Currency of the refund

Sample Error Response

Error Response Fields

Parameter
Type
Description

refundResult

Object

JSON object

refundResult.resultCode

Numeric

Error code

refundResult.resultDesc

String

Description of the error

Error Codes

Code
Description

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

Parameter
Type
Mandatory
Description

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

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

Field
Type
Description

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).

Possible formats:

YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)

YYYY-MM-DDThh:mm:ss.sssssssssZ (up to nanoseconds)

StatusCode

String

Status: accepted, succeeded, or failed

FinalizedAt

String

Timestamp of when the refund was finalized (ISO 8601 format).

Possible formats:

YYYY-MM-DDThh:mm:ss.ssssssZ (up to microseconds)

YYYY-MM-DDThh:mm:ss.sssssssssZ (up to nanoseconds)

Type

String

Type of refund, always "full"

TxnId

String

Transaction ID of this refund object

AmountValue

Float

Refunded amount

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

  1. Complete a payment in sandbox

  2. Use the transaction ID to request a refund

  3. Verify refund status using the retrieveRefund endpoint

  4. Notify Codapay support to simulate final status if needed

Example Requests

Create Refund

Retrieve Refund

Last updated

Was this helpful?