# Pre\&Post Auth

Performing a pre/post auth follows the same structure at the SDK level with the payment transaction. However, there are some additional preparation steps at the Integrating application level as described in the next paragraph.

## **Pre Auth**

```kotlin
PayContactlessEmbed.getInstance().doPreAuth(@NonNull String amount, @Nullable String description, @Nullable String currencyCode, @NonNull FragmentActivity activity, @Nullable Map<String, String> rfuMap, @NonNull TransactionResultListener listener)
```

{% hint style="info" %}
If currency parameter is set null, the default currency is used for transaction. The default currecny is Naira in SDK.
{% endhint %}

**Parameters**:

1. **Amount**:
   * **Description**: Denotes the transaction's value as specified by the user.
   * **Constraints**:
     * Should be a whole number, with its length capped at 12 digits.
     * Exclude any separators or currency symbols.
   * **Examples**:
     * A payment amount of $100 should be conveyed as 10000, where the trailing two digits represent cents.
     * Conversely, $1.01 is represented as 101.
2. **Description**
   * **Description**: Provides contextual information detailing the purpose or reason behind the payment. It could relate to the product/service name, a brief summary, or any relevant description the merchant deems necessary.
3. **Currency Code**
   * **Description**: The currecy value of the transaction. It has be numeric code of ISO 4217 format.&#x20;
   * **Examples:**
     * 566 for Naira instead of NGN
4. **Activity**
   * **Description**: The current activity. Payment page is started as a new activity. In order to start payment activity Embed SDK needs the current acitivity of the app.
5. **RFU Map**
   * **Description:** RFUMap (Reserved for future use) object is used to transfer key value pairs between backend system and merchant application
6. **TransactionResultListener**:
   * **Description**: This interface is vital as it captures and manages transaction outcomes, be it success or failure scenarios.

Please check details for TransactionResultListener on Sale section.

{% content-ref url="/pages/DDAUl4QlI8eebdWuWZdo" %}
[Sale](/developer-console/merchant-embed-sdk/android/sdk-api-reference/pay-with-card/sale.md)
{% endcontent-ref %}

The merchant to request the receipt which is generated at payment step from the customer. After getting the details from the customer, merchant searches for the transaction using transaction code. If the transaction is found, the post auth is triggered according to the customer’s request. **doPostAuth** method is called from the SDK.

## Transaction Inquiry for PreAuth

This function is used to search the specific pre auth transaction in the system

```java
PayContactlessEmbed.getInstance().preAuthInquiry(@Nullable String transactionCode, @NonNull InquiryListener listener)
```

## **Inquiry Listener**

```java
public interface InquiryListener {
   void onSuccess(InquiryResult transaction);
   void onFailure(Error error);
}
```

## **Inquiry Result**

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

<table><thead><tr><th width="223">Field Names</th><th width="172.33333333333331">Field Descriptions</th><th>Values</th></tr></thead><tbody><tr><td>CardNumber</td><td>masked card number used in transaction</td><td><code>************6375</code></td></tr><tr><td>Amount</td><td>amount value of the transaction</td><td><pre><code>5.00
</code></pre></td></tr><tr><td>Currency</td><td>amount current of the transaction</td><td><p></p><pre><code>566
</code></pre></td></tr><tr><td>Error</td><td>Check 6.1 Error Handling section</td><td></td></tr></tbody></table>

## **Post Auth**

```kotlin
PayContactlessEmbed.getInstance().doPostAuth(@NonNull String amount, @NonNull String transactionCode, @Nullable String description, @Nullable String currencyCode, @NonNull FragmentActivity activity, @Nullable Map<String, String> rfuMap, @NonNull TransactionResultListener listener)
```

{% hint style="info" %}
If currency parameter is set null, the default currency is used for transaction. The default currecny is Naira in SDK.
{% endhint %}

**Parameters**:

1. **Amount**:
   * **Description**: Denotes the transaction's value as specified by the user.
   * **Constraints**:
     * Should be a whole number, with its length capped at 12 digits.
     * Exclude any separators or currency symbols.
   * **Examples**:
     * A payment amount of $100 should be conveyed as 10000, where the trailing two digits represent cents.
     * Conversely, $1.01 is represented as 101.
2. **Transaction Code**:
   * **Description:** Transaction code value confirmed according to preAuthInqury response.
3. **Description**
   * **Description**: Provides contextual information detailing the purpose or reason behind the payment. It could relate to the product/service name, a brief summary, or any relevant description the merchant deems necessary.
4. **Currency Code**
   * **Description**: The currecy value of the transaction. It has be numeric code of ISO 4217 format.&#x20;
   * **Examples:**
     * 566 for Naira instead of NGN
5. **Activity**
   * **Description**: The current activity. Payment page is started as a new activity. In order to start payment activity Embed SDK needs the current acitivity of the app.
6. **RFU Map**
   * **Description:** RFUMap (Reserved for future use) object is used to transfer key value pairs between backend system and merchant application
7. **TransactionResultListener**:
   * **Description**: This interface is vital as it captures and manages transaction outcomes, be it success or failure scenarios.

Please check details for TransactionResultListener on Sale section.

{% content-ref url="/pages/DDAUl4QlI8eebdWuWZdo" %}
[Sale](/developer-console/merchant-embed-sdk/android/sdk-api-reference/pay-with-card/sale.md)
{% endcontent-ref %}


---

# Agent Instructions: 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:

```
GET https://developer.prophius.com/developer-console/merchant-embed-sdk/android/sdk-api-reference/pay-with-card/pre-and-post-auth.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
