# Android SDK

### Introduction

The **UPITranzact Android SDK** enables seamless UPI payment processing for merchants. This documentation will guide you through the installation and implementation of the SDK in your Android application.

### Installation

To integrate the **UPITranzact** SDK into your Android project, add the following dependency in your **build.gradle** file:

```
implementation("com.upitranzact:upitranzact:1.1.0")
```

### Initialization

Before starting a payment, initialize the SDK with your credentials:

```
UpiTranzactSDK sdk = new UpiTranzactSDK(MainActivity.this, "PUBLIC_KEY", "SECRET_KEY", "MERCHANT_ID");
```

* `PUBLIC_KEY`: Your public key provided by UPITranzact.
* `SECRET_KEY`: Your secret key for authentication.
* `MERCHANT_ID`: Your unique merchant identifier.

### Starting a Payment

To initiate a UPI transaction, use the `startPayment` method:

```
sdk.startPayment("AMOUNT", // Amount to be paid
        "ORDER_ID", // Unique Order ID
        "CUSTOMER_NAME", // Customer's name
        "CUSTOMER_EMAIL", // Customer's email
        "CUSTOMER_NUMBER", // Customer's contact number
        new PaymentCallback() {
            @Override
            public void onPaymentSuccess(String order_id, String message) {
                Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onPaymentFailed(String order_id, String message) {
                String logMessage = message + " Order Id " + order_id;
                Toast.makeText(MainActivity.this, logMessage, Toast.LENGTH_SHORT).show();
                Log.d("PaymentFailed", logMessage);
            }
        });
```

#### Parameters

* `AMOUNT`: The payment amount.
* `ORDER_ID`: A unique order identifier generated by your app.
* `CUSTOMER_NAME`: The name of the customer making the payment.
* `CUSTOMER_EMAIL`: The customer's email address.
* `CUSTOMER_NUMBER`: The customer's contact number.
* `PaymentCallback`: Handles success and failure responses.

#### Payment Callback

Implement the `PaymentCallback` interface to handle payment responses:

* `onPaymentSuccess(String order_id, String message)`: Called when the payment is successful.
* `onPaymentFailed(String order_id, String message)`: Called when the payment fails.

### Logging and Debugging

For debugging failed transactions, use:

```
Log.d("PaymentFailed", logMessage);
```

This helps in tracking payment issues by logging the failure message and order ID.

### Support

For any issues or support, please contact UPITranzact Support.


---

# 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://upitranzact.gitbook.io/upitranzact/sdk/android-sdk.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.
