# Quick Start

This practical guide will walk you through the basic integration between your Android application and the Getnet payment application via Deeplink. By the end of this tutorial, you will have triggered a payment command and processed the transaction response.

## Before you begin

Before proceeding with the steps below, make sure you can meet these prerequisites.

* You need to understand what a Polling call (`getnet://payment/v1/polling`) does: it verifies whether the Getnet Payment App is properly connected and ready to receive commands before starting a transaction.

* Basic knowledge of Android Intents and `onActivityResult`.

## Step 1: Validate the terminal connection (polling)

Before initiating a payment, it is a best practice to perform a Polling operation. This non-financial request verifies that the Getnet Payment App is connected and ready to process transactions.

To perform this check, trigger an Intent using the following URI:

**Polling URI**: `getnet://payment/v1/polling`

Here's an example implementation:

```kotlin
val POLLING_REQUEST_CODE = 2001
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("getnet://payment/v1/polling"))
startActivityForResult(intent, POLLING_REQUEST_CODE)
```

<Callout type="note">

Polling does not require any parameters. Send the deeplink and the terminal responds with its current status.

</Callout>

The Getnet app returns the following parameters:

| Parameter | Type | Description |
| :--- | :--- | :--- |
| `result` | String | Result of the operation: `"0"` for success (terminal ready). |
| `resultDetails` | String | Detailed message regarding the terminal status. |

> If the `result` is `"0"`, you are cleared to proceed to the Payment.

## Step 2: Initialize the payment transaction

Communication is handled via an `Intent` with a specific URI. For the purpose of this tutorial, you will create a payment transaction using the following URI:

**Payment URI**: `getnet://payment/v1/payment`

To initiate a payment, you must build an Intent with specific request parameters passed as extras. Below is the table of the required parameters for the payment transaction:

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| `amount` | String | Yes | Transaction amount with two implicit decimal places (e.g., "10000" = \$100.00) |
| `originalAmount` | String | Yes | Value in local currency to perform the transaction |
| `receiptCode` | String | Yes | Identification code to be printed on receipt |
| `callerId` | String | Yes | Unique identifier to correlate request with response |

**Optional Parameters**

| Parameter | Type | Description |
| :--- | :--- | :--- |
| `paymentMethod` | String | `"1"` for Card, `"2"` for QR Code. Skips payment method selection screen. |
| `operationMode` | String | `"1"` for calculated mode, `"0"` for manual (default) |
| `skipReceipt` | String | Set to `"true"` to suppress the customer receipt view screen after approval |
| `allowPrintCurrentTransaction` | String | Set to `"true"` to let Getnet handle receipt printing, `"false"` to receive raw receipt data |

Here is an example of an Android implementation:

```kotlin
private val PAYMENT_REQUEST_CODE = 1001

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    // Define the payment URI
    val paymentUri = Uri.parse("getnet://payment/v1/payment")
    
    // Configure the Intent with the required parameters
    val intent = Intent(Intent.ACTION_VIEW, paymentUri)
    intent.putExtra("amount", "10000")        // $100.00
    intent.putExtra("originalAmount", "10000")
    intent.putExtra("receiptCode", "123456") 
    intent.putExtra("callerId", "payment_001")
    intent.putExtra("allowPrintCurrentTransaction", "true")
    
    // Start the activity and expect a result
    startActivityForResult(intent, PAYMENT_REQUEST_CODE)
}
```

## Step 3: Process the payment response

After the payment process completes, the Getnet app returns an Intent containing the transaction results. You must extract these extras to verify if the payment was approved.

**Response Parameters**

| Parameter | Type | Description |
| :--- | :--- | :--- |
| `result` | String | Result of the operation: `"0"` for success, any other value indicates failure or cancellation |
| `resultDetails` | String | Detailed message about the transaction result |
| `amount` | String | Final charged amount with two implicit decimal places |
| `receiptCode` | String | Identification code printed on receipt |
| `callerId` | String | The unique identifier sent in the request |
| `nsu` | String | Getnet transaction authorization code (unique per terminal) |
| `authorizationCode` | String | Authorization code provided by the card issuer |
| `brand` | String | Card brand used in the transaction (e.g., "VISA", "MASTERCARD") |
| `cardLastDigits` | String | Last 4 digits of the card used |
| `cardBin` | String | First 8 digits of the card (BIN) |
| `inputType` | String | Card input method: `"021"` (magnetic), `"051"` (chip), `"071"` (contactless), `"801"` (fallback) |
| `installments` | String | Number of installments (if applicable) |
| `planId` | String | Installment plan ID used (if applicable) |
| `gmtDateTime` | String | Transaction timestamp in GMT format (MMDDhhmmss) |
| `automationSlip` | String | Receipt data in JSON format (if `allowPrintCurrentTransaction = "false"`) |

Here's an example of a successful transaction response:

```
{
  "result": "0",
  "resultDetails": "APPROVED",
  "amount": "10000",
  "tip": "0",
  "receiptCode": "123456",
  "callerId": "payment_001",
  "nsu": "57003",
  "nsuLastSuccesfullMessage": "750057003",
  "paymentType": "credit",
  "brand": "VISA",
  "inputType": "051",
  "installments": "1",
  "planId": "",
  "Interest": "false",
  "gmtDateTime": "0612211725",
  "authorizationCode": "004433",
  "cardBin": "51559030",
  "cardLastDigits": "8015",
  "automationSlip": ""
}
```

Use the `onActivityResult` method to extract the response parameters. Here's an example implementation of how to handle the payment response:

```
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    if (requestCode == PAYMENT_REQUEST_CODE && resultCode == RESULT_OK) {
        val extras = data?.extras ?: return

        // Transaction Status
        val result = extras.getString("result")
        val resultDetails = extras.getString("resultDetails")

        if (result == "0") {
            // Payment successful
            val nsu = extras.getString("nsu")
            val authCode = extras.getString("authorizationCode")
            val amount = extras.getString("amount")
            val brand = extras.getString("brand")
            val cardLastDigits = extras.getString("cardLastDigits")
            
            // Log or display success
            Log.d("Payment", "Success! NSU: $nsu, Auth: $authCode")
            
        } else {
            // Payment failed or cancelled
            Log.e("Payment", "Failed: $resultDetails")
            // Handle error appropriately
        }
    }
}
```

## Complete implementation example

Here's a complete example that brings together all three steps:

```kotlin
class PaymentActivity : AppCompatActivity() {

    private val POLLING_REQUEST_CODE = 2001
    private val PAYMENT_REQUEST_CODE = 1001

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        // Step 1: Verify terminal is ready
        val pollingIntent = Intent(Intent.ACTION_VIEW, Uri.parse("getnet://payment/v1/polling"))
        startActivityForResult(pollingIntent, POLLING_REQUEST_CODE)
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        
        if (resultCode == RESULT_OK && data != null) {
            val result = data.extras?.getString("result")
            
            when (requestCode) {
                POLLING_REQUEST_CODE -> {
                    // If terminal is ready, proceed to payment
                    if (result == "0") {
                        // Step 2: Initiate payment
                        val paymentIntent = Intent(Intent.ACTION_VIEW, Uri.parse("getnet://payment/v1/payment"))
                        paymentIntent.putExtra("amount", "10000")
                        paymentIntent.putExtra("originalAmount", "10000")
                        paymentIntent.putExtra("receiptCode", "123456")
                        paymentIntent.putExtra("callerId", "payment_001")
                        paymentIntent.putExtra("allowPrintCurrentTransaction", "true")
                        startActivityForResult(paymentIntent, PAYMENT_REQUEST_CODE)
                    } else {
                        // Terminal not ready
                        val resultDetails = data.extras?.getString("resultDetails")
                        Log.e("Polling", "Terminal not ready: $resultDetails")
                    }
                }
                
                PAYMENT_REQUEST_CODE -> {
                    // Step 3: Handle payment response
                    if (result == "0") {
                        val nsu = data.extras?.getString("nsu")
                        val authCode = data.extras?.getString("authorizationCode")
                        val amount = data.extras?.getString("amount")
                        // Payment successful
                        Log.d("Payment", "Success! NSU: $nsu")
                    } else {
                        val resultDetails = data.extras?.getString("resultDetails")
                        // Payment failed or cancelled
                        Log.e("Payment", "Failed: $resultDetails")
                    }
                }
            }
        }
    }
}
```

## Next steps

Congratulations! You have successfully completed the basic integration between your Android application and the Getnet Payment App via Deeplink. 

You now have a working foundation for processing payments through the Getnet Payment App. With this knowledge, you can expand your integration to handle more complex scenarios, implement additional payment options, and create a robust payment experience for your users.

* [Create a single-step payment](/en/app2app/payment-guides-a2a/create-single-step-payment) - remove user interaction from the terminal flow.
* [Create a payment with installments](/en/app2app/payment-guides-a2a/create-installments-and-plan) - offer installment plans at the terminal.
* [Deeplink parameters reference](/en/app2app/reference-a2a/deeplink-parameters) - every parameter available per operation.