# Revolut Merchant Card Form SDK

This page contains information about the available methods, parameters and data types of the Revolut Merchant Card Form SDK for Android.

:::info
For detailed instructions on how to install and integrate the SDK, see: [Accept payments via Revolut Merchant Card Form SDK - Android](/docs/guides/merchant/accept-payments/online-payments/card-payments/mobile/android).
:::

## SDK components

### `RevolutPaymentsSDK` object

This is the main entry point for configuring the SDK.

### `RevolutPaymentsSDK.configure` method

The `configure` method is used to initialise the SDK with your merchant public key and the desired environment. It must be called once before performing any payment operations, typically in your application's `onCreate` method.

```kotlin
fun configure(
  configuration: Configuration
)
```

| Parameter       | Description                                                                      | Format                                                    | Required |
| --------------- | -------------------------------------------------------------------------------- | --------------------------------------------------------- | -------- |
| `configuration` | A configuration object that specifies the `environment` and `merchantPublicKey`. | [`Configuration`](#revolutpaymentssdkconfiguration-class) | Yes      |

### `RevolutPaymentsSDK.Configuration` class

This data class holds the configuration settings for the SDK.

```kotlin
class Configuration(
    environment: Environment,
    merchantPublicKey: String
)
```

| Parameter           | Description                                                                                                                                                                                                                                                                                      | Format                             | Required |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------- | -------- |
| `environment`       | This parameter specifies the environment in which the SDK operates. Default value: **`Envorinment.PRODUCTION`** <br/><br/>**Possible values:**<ul><li>**`Environment.PRODUCTION`**</li><li>**`Environment.SANDBOX`**</li></ul>                                                                   | [`Environment`](#environment-enum) | Yes      |
| `merchantPublicKey` | The merchant's public API key used for authorisation, obtained from the [Merchant API settings](https://business.revolut.com/settings/merchant-api) page. <br/><br/> _For the Sandbox environment use the [Sandbox API Public key](https://sandbox-business.revolut.com/settings/merchant-api)._ | `String`                           | Yes      |

### `CardPaymentLauncher` class

This class handles the presentation of the payment UI and delivers the final result. You must register it as a member variable in your `Activity` or `Fragment`.

```kotlin
class CardPaymentLauncher(
    caller: ActivityResultCaller,
    onResult: (CardPaymentResult) -> Unit
)
```

| Parameter  | Description                                                                                                                                               | Format                        | Required |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | -------- |
| `caller`   | The `Activity` or `Fragment` that will launch the payment flow. This component handles the `startActivityForResult` contract. Typically, you pass `this`. | `ActivityResultCaller`        | Yes      |
| `onResult` | A callback function that receives the final outcome of the payment operation.                                                                             | `(CardPaymentResult) -> Unit` | Yes      |

### `CardPaymentLauncher.launch` method

This method starts the payment process, displaying the card form to the user.

```kotlin
fun launch(
    params: CardPaymentParams
)
```

| Parameter | Description                                                                                               | Format                                          | Required |
| --------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | -------- |
| `params`  | A data object containing all the necessary information to start the payment, including the order `token`. | [`CardPaymentParams`](#cardpaymentparams-class) | Yes      |

## Data classes

### `CardPaymentParams` class

This data class is used to pass all required and optional information to the [`launch` method](#revolutpaycardpaymentlauncherlaunch-method).

```kotlin
class CardPaymentParams(
    orderId: String,
    email: String?,
    billingAddress: AddressParams?,
    shippingAddress: AddressParams?,
    savePaymentMethodFor: UserType?
)
```

| Parameter              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Format                                  | Required |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | -------- |
| `orderId`              | The unique `token` of the order, obtained from your server after creating an order. This identifies the transaction to be processed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | `String`                                | Yes      |
| `email`                | The email address of the customer, which can be pre-filled on the payment form. If not provided, the customer will be prompted to enter it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | `String`                                | No       |
| `billingAddress`       | Object containing data for the billing address. This is used to pre-fill the billing address on the payment form and can help reduce fraud.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | [`AddressParams`](#addressparams-class) | No       |
| `shippingAddress`      | Object containing data for the shipping address, used to pre-fill the shipping address on the payment form if applicable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | [`AddressParams`](#addressparams-class) | No       |
| `savePaymentMethodFor` | This parameter accepts a `UserType` enum, which indicates whether the payment method should be saved for the customer or merchant. <br/><br/>**Possible values:**<br/><br/> <ul><li>**`UserType.CUSTOMER`** - This method is used only when the customer is on the checkout page. </li><li>**`UserType.MERCHANT`** - This method can be used without the customer being on the checkout page, and the merchant can initiate transactions (e.g. take payments for recurring transactions). This method is saved as the new default payment method for merchant initiated transactions, regardless of the number of saved payment methods stored against the customer.</li></ul> _For more information, see: [Charge a customer's saved payment method](/docs/guides/merchant/optimise-checkout/save-payment-methods/charge-saved-payment-method)_ | `UserType`                              | No       |

### `AddressParams` class

The `AddressParams` class represents an address used for billing or shipping purposes. Providing accurate address information can help reduce the likelihood of transaction declines and improve overall payment success rates.

```kotlin
class AddressParams(
    streetLine1: String?,
    streetLine2: String?,
    city: String?,
    region: String?,
    country: String?,
    postcode: String?
)
```

| Parameter     | Description                                                                 | Format   | Required |
| ------------- | --------------------------------------------------------------------------- | -------- | -------- |
| `streetLine1` | The primary street address line.                                            | `String` | No       |
| `streetLine2` | The second line of the street address, such as a floor or apartment number. | String   | No       |
| `city`        | The city or locality of the address.                                        | `String` | No       |
| `region`      | The region or state within the country.                                     | `String` | No       |
| `country`     | The 2-letter country code of the country associated with the address.       | `String` | Yes      |
| `postcode`    | The postcode of the address.                                                | `String` | No       |

### `Environment` enum

The `Environment` enum defines the possible server environments that the SDK can point to.

```kotlin
enum class Environment {
    PRODUCTION,
    SANDBOX
}
```

| Value        | Description                                                    |
| ------------ | -------------------------------------------------------------- |
| `PRODUCTION` | The live environment for processing real transactions.         |
| `SANDBOX`    | The test environment for integration and development purposes. |

### `UserType` enum

The `UserType` enum specifies for whom a payment method should be saved, distinguishing if the payment method can be used for customer-initiated or merchant-initiated transactions.

```kotlin
enum class UserType {
    CUSTOMER,
    MERCHANT
}
```

| Value      | Description                                                                                 |
| ---------- | ------------------------------------------------------------------------------------------- |
| `CUSTOMER` | The payment method is saved for customer-initiated transactions.                            |
| `MERCHANT` | The payment method is saved for merchant-initiated transactions (e.g., recurring payments). |

## Results

The `CardPaymentResult` is a sealed class that represents the outcome of a payment operation. It is delivered to the `onResult` callback of the `CardPaymentLauncher`.

### `Authorised` object

Indicates that the payment was successfully authorised.

```kotlin
object Authorised : CardPaymentResult()
```

### `Declined` object

Indicates that the payment was declined by the card issuer or payment network.

```kotlin
object Declined : CardPaymentResult()
```

:::info
For more information about the potential reasons for a decline, see: [Decline reasons](/docs/guides/merchant/reference/error-codes/decline-reasons).
:::

### `Failed` object

Indicates that a technical failure occurred during the payment process (e.g., network issues).

```kotlin
object Failed : CardPaymentResult()
```

### `Error` class

Indicates that an error occurred due to invalid input or configuration.

```kotlin
class Error(
    errorCode: String,
    errorMessage: String
) : CardPaymentResult()
```

### `UserAbandonedPayment` object

Indicates that the user abandoned the payment (e.g., using a system back button, a back gesture, or a close button).

```kotlin
object UserAbandonedPayment : CardPaymentResult()
```