> For the complete documentation index, see [llms.txt](https://developer.prophius.com/developer-console/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.prophius.com/developer-console/merchant-embed-sdk/react-native/sdk-api-reference/creating-sdk-module-class/pay-with-card/refund.md).

# Refund

#### **Handling Refunds with the SDK**

**Overview**:\
Processing refunds is a crucial functionality for any payment gateway or service. Within our SDK, while the underlying mechanics resemble payment transactions, there are some nuances to consider for refunds. Let's delve into how the Prophius SDK manages refund operations.

**1. Preliminary Steps for Refunds**:

* **Receipt Collection**:
  * **Purpose**: To have a concrete reference for the transaction being refunded.
  * **Action**: The merchant must request the payment receipt from the customer. This receipt contains essential transaction details, most crucially, the transaction code.
* **Transaction Search**:
  * **Purpose**: To locate the specific transaction in the system and ensure it's valid for a refund.
  * **Action**: Using the provided transaction code from the receipt, the merchant searches for the corresponding transaction using **refundInquiry** function of the SDK.

## Transaction Inquiry for Refund

This function is used to search for a **specific transaction** in the system in order to perform a **refund inquiry**.

***

### API Method

```kotlin
PayContactlessEmbed.getInstance()
    .refundInquiry(
        transactionCode: String?,
        listener: InquiryListener
    )
```

#### Description

Initiates a refund inquiry request using a transaction reference code and returns the result asynchronously via a callback listener.

***

### Method Parameters

| Field Name      | Data Type       | Required | Description                                                                                                                                           |
| --------------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| transactionCode | String          | false    | Unique transaction reference code used to identify the transaction. If null, the system may attempt to resolve the transaction context automatically. |
| listener        | InquiryListener | true     | Callback interface to receive the inquiry result or error response.                                                                                   |

***

### Inquiry Listener

The `InquiryListener` interface is used to receive the refund inquiry response.

#### Kotlin Interface

```kotlin
interface InquiryListener {
    fun onSuccess(transaction: InquiryResult)
    fun onFailure(error: Error)
}
```

***

### InquiryListener Callbacks

#### onSuccess

| Field Name  | Data Type     | Required | Description                                                                |
| ----------- | ------------- | -------- | -------------------------------------------------------------------------- |
| transaction | InquiryResult | true     | Contains the transaction details returned from the refund inquiry request. |

#### onFailure

| Field Name | Data Type | Required | Description                                                   |
| ---------- | --------- | -------- | ------------------------------------------------------------- |
| error      | Error     | true     | Error object describing the reason the refund inquiry failed. |

***

### Inquiry Result Model

#### Kotlin Data Class

```kotlin
data class InquiryResult(
    var cardNumber: String?,
    var amount: Double,
    var currency: Int
)
```

***

### InquiryResult Fields

| Field Name | Data Type | Required | Description                                                            |
| ---------- | --------- | -------- | ---------------------------------------------------------------------- |
| cardNumber | String    | false    | Masked card number associated with the original transaction.           |
| amount     | Double    | true     | Transaction amount for which the refund inquiry was performed.         |
| currency   | Int       | true     | Numeric ISO 4217 currency code of the transaction (e.g., 566 for NGN). |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.prophius.com/developer-console/merchant-embed-sdk/react-native/sdk-api-reference/creating-sdk-module-class/pay-with-card/refund.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
