# Create a Pre-Authorized Payment

This guide walks you through processing a pre-authorization transaction using the Get Smart application. Pre-authorization allows you to block a specific amount on a customer's card without immediately capturing the funds. This is typically used in hotels, car rentals, or scenarios where the final service price is pending.

## Requirements

Before you begin, ensure you have:

* **Merchant profile with pre-authorization support** - Contact Get Smart support to verify your account supports this transaction type
* **Get Smart application** installed and configured on the Android device
* **Permission to launch external Intents** in your application

<Callout type="warning">

Not all merchant profiles support pre-authorization. Verify with Get Smart that your account is configured for pre-auth transactions before implementing this feature.

</Callout>

## Pre-authorization Transaction Process

This section guides you through the two-step process of pre-authorizing and confirming a payment with the Get Smart App2App integration. The workflow involves two distinct Intent calls: the pre-authorization to hold funds and the confirmation to capture them.

### Step 1: Execute the Pre-authorization

A pre-authorization transaction blocks funds on the customer's card without immediately capturing them. You must create an Intent with transaction type `10` to initiate the hold. The Get Smart application processes the pre-authorization and returns an order ID that you must store for later confirmation.

The table below lists the parameters you need to include in your pre-authorization Intent:

| Parameter | Type   | Required | Description                                      |
| :-------- | :----- | :------- | :----------------------------------------------- |
| `amount`  | double | Yes      | The amount to hold on the card                   |
| `type`    | int    | Yes      | Set to `10` for Pre-authorization transactions   |
| `invoice` | String | No       | Optional order number or identifier for tracking |

The following code example shows how to create and launch a pre-authorization Intent:

```java
// Define request code for result handling
static final int REQUEST_CODE_PREAUTH = 2001;

// Initialize the Intent with the Get Smart action
Intent intent = new Intent("es.android.redsys.mPOS.movil.tpvAndroid_PAYMENT_REQUEST");

// Add pre-authorization parameters
intent.putExtra("amount", 100.00);
intent.putExtra("type", 10); // 10 = Pre-authorization
intent.putExtra("invoice", "PRE-AUTH-001");

// Launch the Intent
try {
    startActivityForResult(intent, REQUEST_CODE_PREAUTH);
} catch (ActivityNotFoundException e) {
    // Handle missing Get Smart application
    new AlertDialog.Builder(this)
        .setTitle("Get Smart App Not Found")
        .setMessage("Please install and configure the Get Smart application.")
        .setPositiveButton("OK", null)
        .show();
}
```

### Step 2: Store and Confirm the Pre-authorization

When the pre-authorization is successful, the Get Smart app returns an `ORDER` parameter through the `onActivityResult` callback. You must store this order ID to confirm and capture the payment later. Pre-authorizations typically expire after 7 to 30 days depending on the card issuer, so you should confirm the capture within this timeframe.

To finalize the payment, send a confirmation request using transaction type `11` and include the original order ID. The confirmation amount can be equal to or less than the pre-authorized amount, depending on your merchant agreement configuration.

The table below lists the parameters for the confirmation Intent:

| Parameter        | Type   | Required | Description                                                         |
| :--------------- | :----- | :------- | :------------------------------------------------------------------ |
| `amount`         | double | Yes      | The amount to capture (equal to or less than pre-authorized amount) |
| `type`           | int    | Yes      | Set to `11` for Pre-authorization Confirmation                      |
| `original_order` | String | Yes      | The ORDER ID returned from the pre-authorization                    |

The following code example shows how to handle the pre-authorization result and later confirm the capture:

```java
// Handle pre-authorization result
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    
    if (requestCode == REQUEST_CODE_PREAUTH) {
        if (resultCode == RESULT_OK && data != null) {
            // Pre-authorization successful - store the order ID
            String orderId = data.getStringExtra("ORDER");
            String authCode = data.getStringExtra("AUTHORIZATION");
            
            // Store orderId for later confirmation
            savePreAuthOrderId(orderId);
        }
    } else if (requestCode == REQUEST_CODE_CONFIRM) {
        if (resultCode == RESULT_OK && data != null) {
            // Confirmation successful
            String orderId = data.getStringExtra("ORDER");
            // Process confirmed payment
        }
    }
}

// Later, when you're ready to capture the funds
private void confirmPreAuthorization(String originalOrderId, double captureAmount) {
    static final int REQUEST_CODE_CONFIRM = 2002;
    
    Intent intent = new Intent("es.android.redsys.mPOS.movil.tpvAndroid_PAYMENT_REQUEST");
    intent.putExtra("amount", captureAmount);
    intent.putExtra("type", 11); // 11 = Pre-auth Confirmation
    intent.putExtra("original_order", originalOrderId); // Required
    
    try {
        startActivityForResult(intent, REQUEST_CODE_CONFIRM);
    } catch (ActivityNotFoundException e) {
        // Handle missing Get Smart application
    }
}
```

<Callout type="note">

Some merchant configurations allow confirming a lower amount than originally authorized (partial capture). Check your merchant agreement to verify if this feature is available for your account.

</Callout>

### Next Steps

Now that you have successfully processed a pre-authorization transaction, you can explore more features of the Get Smart App2App integration:

* [Response Parameters Reference](/en/get-smart/get-smart-app2app/reference/response-parameters) - Complete response field specifications
* [Refund a Payment](/en/get-smart/get-smart-app2app/transaction-guides/transactions/refund-a-payment) - Learn how to reverse transactions
* [Request Parameters Reference](/en/get-smart/get-smart-app2app/reference/request-parameters) - Complete parameter specifications