> ## Documentation Index
> Fetch the complete documentation index at: https://developer.nomba.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Learn how to receive either card or bank transfer payments from your customers

<Note>
  The aim of this document is to assist you in initiating payment acceptance from your custom application running on the Nomba Android terminal. If you encounter any difficulties with this process, feel free to [reach out for support.](/support/reach-out)
</Note>

<Tip>
  Trigger payments - available since NombaX Application `v1.6.2`
</Tip>

This following code snippet serves as a foundation for triggering payment events on the Nomba terminal. Adjustments to the amount, transaction reference, and other parameters can be easily made based on specific application requirements.

<CodeGroup>
  ```kotlin trigger_payment.kt theme={null}
  const val PAYMENT_OPTION_INTENT = "com.nomba.pro.feature.payment_option.ACTION_VIEW"
  const val AMOUNT_DATA = "amount"
  const val MERCHANT_TX_REF = "merchantTxRef"
  const val TXN_RESULT = "txnResultData"
  const val RECEIPT_OPTIONS = "receiptOptions"
  const val ARGS_PAYMENT_OPTION_STATE = "ARGS_PAYMENT_OPTION_STATE"
  const val SDK_PAYMENT_OPTIONS = "SDK_PAYMENT_OPTIONS"

  val resultString = mutableStateOf("")

  //setup a launcher that would help launch the intent
  var paymentOptionLauncher = registerForActivityResult(
      ActivityResultContracts
          .StartActivityForResult()
  ) { result ->
      val data: Intent? = result.data
      if (result.resultCode == Activity.RESULT_OK) {
          resultString.value = data?.getStringExtra(TXN_RESULT) ?: "null"
      }
  }

  //setup an intent to be triggered
  val intent = Intent(PAYMENT_OPTION_INTENT)

  //put the amount to be charged
  intent.putExtra(AMOUNT_DATA, "300")

  //tie a reference to the payment
  intent.putExtra(MERCHANT_TX_REF, "1234567890")

  //handle receipt medium
  val receiptOptionsMap = hashMapOf(
      "print" to true,
      "sms" to false,
      "email" to false
  )
  val receiptOptionsString = Json.encodeToString(serializer<HashMap<String, Boolean>>(), receiptOptionsMap)
  intent.putExtra(RECEIPT_OPTIONS, receiptOptionsString)

  //add extras
  intent.putExtra(ARGS_PAYMENT_OPTION_STATE, SDK_PAYMENT_OPTIONS)

  //launch the intent
  paymentOptionLauncher.launch(intent)
  ```

  ```java trigger_payment.java theme={null}
  public static final String PAYMENT_OPTION_INTENT = "com.nomba.pro.feature.payment_option.ACTION_VIEW";
  public static final String AMOUNT_DATA = "amount";
  public static final String MERCHANT_TX_REF = "merchantTxRef";
  public static final String TXN_RESULT = "txnResultData";
  public static final String RECEIPT_OPTIONS = "receiptOptions";
  public static final String ARGS_PAYMENT_OPTION_STATE = "ARGS_PAYMENT_OPTION_STATE";
  public static final String SDK_PAYMENT_OPTIONS = "SDK_PAYMENT_OPTIONS";

  // Assuming you have a mutable state variable similar to mutableStateOf in Java
  private MutableLiveData<String> resultString = new MutableLiveData<>();

  // Setup a launcher that would help launch the intent
  ActivityResultLauncher<Intent> paymentOptionLauncher = registerForActivityResult(
          new ActivityResultContracts.StartActivityForResult(),
          result -> {
              Intent data = result.getData();
              if (result.getResultCode() == Activity.RESULT_OK) {
                  resultString.setValue(data.getStringExtra(TXN_RESULT));
              }
          }
  );

  // Setup an intent to be triggered
  Intent intent = new Intent(PAYMENT_OPTION_INTENT);

  // Put the amount to be charged
  intent.putExtra(AMOUNT_DATA, "300");

  // Tie a reference to the payment
  intent.putExtra(MERCHANT_TX_REF, "1234567890");

  //handle receipt medium
  HashMap<String, Boolean> receiptOptionsMap = new HashMap<>();
  receiptOptionsMap.put("print", true);
  receiptOptionsMap.put("sms", false);
  receiptOptionsMap.put("email", false);

  String receiptOptionsString = Json.encodeToString(serializer(HashMap.class, Boolean.class), receiptOptionsMap);
  intent.putExtra(RECEIPT_OPTIONS, receiptOptionsString);

  //add extras
  intent.putExtra(ARGS_PAYMENT_OPTION_STATE, SDK_PAYMENT_OPTIONS);

  // Launch the intent
  paymentOptionLauncher.launch(intent);
  ```
</CodeGroup>

<Check>
  Please ensure to pass the amount as `kobo` i.e. `200` will charge your customer `NGN 2.00`
</Check>

Your resultString should look like;

```
{
    responseCode=00, responseCodeMeaning="Completed successfully", terminalId="2KUD2XFU", 
    rrn="240117080003", formattedAmountString="₦3.00", txnType="PURCHASE", dateTime="2024-01-17 8:00:03", 
    cardPan="559441******5882", stan="575780", expiryDate="2606", cardName="00002220", 
    merchantName="Etrack Systems", providerTid="2KUD2XFU", cardScheme="Debit Mastercard"
}
```

<Tip>
  Please note that the following details will make reference to the kotlin code snippet
</Tip>

#### Constants

|                         | Description                                                                                          |
| ----------------------- | ---------------------------------------------------------------------------------------------------- |
| `PAYMENT_OPTION_INTENT` | Defines the action string for the intent, indicating the type of action to be performed.             |
| `AMOUNT_DATA`           | Represents the key for passing the amount to be charged during the payment process.                  |
| `MERCHANT_TX_REF`       | Represents the key for tying a reference to the payment, often used for tracking and record-keeping. |
| `TXN_RESULT`            | Represents the key for extracting transaction result data from the intent.                           |

#### State Variable

|                | Description                                                                                                                                   |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `resultString` | A mutable state variable initialized as an empty string, which is intended to store the transaction result received from the launched intent. |

#### Intent Setup

|                                              | Description                                                                                                                       |
| -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `val intent = Intent(PAYMENT_OPTION_INTENT)` | Creates an instance of Intent with the specified action `PAYMENT_OPTION_INTENT`.                                                  |
| `intent.putExtra(AMOUNT_DATA, "300")`        | Adds extra data to the intent, including the amount to be charged `AMOUNT_DATA` and a reference to the payment `MERCHANT_TX_REF`. |

#### Launching the intent

|                                        | Description                                                                                     |
| -------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `paymentOptionLauncher.launch(intent)` | Initiates the intent, triggering the Android system to display the payment options to the user. |

#### Result Handling

Inside the result callback, the code retrieves the transaction result from the received intent and updates the `resultString` variable.
