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

# Native setup

> Set up URL schemes, Apple Pay, Google Pay and the optional native dependencies for 3D Secure, Klarna and Stripe ACH.

> [!WARNING]
>
> Primer Checkout React Native SDK is currently in **beta** (v3.0.0-beta.1).
> The API is subject to change before the stable release.

The core SDK needs no native setup beyond [installation](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/installation.md). Some payment methods need changes in your iOS or Android project and options in `PrimerSettings`, which you pass to `PrimerCheckoutProvider` as `settings`.

| Feature | iOS | Android |
| - | - | - |
| Apple Pay | Apple Pay capability, merchant identifier, `applePayOptions` | Not available |
| Google Pay | Not available | `googlePayOptions` (optional) |
| 3D Secure | `Primer3DS` pod | `io.primer:3ds-android` |
| Klarna | `PrimerKlarnaSDK` pod, URL scheme | `io.primer:klarna-android`, Klarna's Maven repository, `klarnaOptions.returnIntentUrl`, a return activity |
| Stripe ACH | `PrimerStripeSDK` pod, `stripeOptions` | `io.primer:stripe-android`, `stripeOptions` |

## Add the optional native dependencies

Add a dependency for each of these features that you enable in the Primer Dashboard. On iOS, `Primer3DS` is installed with `PrimerSDK`.

### iOS

Add the pods to your app target in `ios/Podfile`:

```ruby theme={"dark"}
target 'MyApp' do
  # ...
  pod 'Primer3DS'
  pod 'PrimerKlarnaSDK'
  pod 'PrimerStripeSDK'
end
```

Don't add a `pod 'PrimerSDK'` line with another version. The package pins it.

Without more build settings, the app fails to link these pods. In the default React Native setup, where pods link as static libraries, add this loop to the `post_install` block of your `Podfile`, after the `react_native_post_install` call:

```ruby theme={"dark"}
post_install do |installer|
  # ...
  installer.pods_project.targets.each do |target|
    if target.name == "primer-io-react-native" || target.name == "PrimerSDK"
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_INCLUDE_PATHS'] = "$(inherited) ${PODS_CONFIGURATION_BUILD_DIR}/Primer3DS ${PODS_CONFIGURATION_BUILD_DIR}/PrimerKlarnaSDK ${PODS_CONFIGURATION_BUILD_DIR}/PrimerStripeSDK"
        config.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -Xcc -fmodule-map-file="${PODS_CONFIGURATION_BUILD_DIR}/Primer3DS/Primer3DS.modulemap"'
        config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -weak_library -l"Primer3DS" -l"PrimerKlarnaSDK" -l"PrimerStripeSDK"'
      end
    end
  end
end
```

The loop lists all three pods. Leave out the entries of a pod you don't add. Then run `pod install`.

If your app links pods as dynamic or static frameworks, follow the steps for your linkage type in the React Native tab of the [3D Secure guide](https://primer.io/docs/payment-services/3d-secure/get-started.md#on-ios) instead.

### Android

Add the dependencies to `android/app/build.gradle`. Klarna's Android SDK is served from Klarna's own Maven repository, so add that repository too if you use Klarna:

```groovy theme={"dark"}
repositories {
  maven { url "https://x.klarnacdn.net/mobile-sdk/" }
}

dependencies {
  implementation "io.primer:3ds-android:1.8.0"
  implementation "io.primer:klarna-android:1.3.0"
  implementation "io.primer:stripe-android:1.1.2"
}
```

> [!NOTE]
>
> These are the wrapper versions that the native Android SDK in this release is built with.

## Register a URL scheme on iOS

Some payment methods, such as PayPal and Klarna, send the shopper to another app or to the browser and return to your app through a URL scheme. Register a scheme in `ios/<YourApp>/Info.plist`:

```xml theme={"dark"}
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>myapp</string>
    </array>
  </dict>
</array>
```

Then pass a URL with that scheme as `paymentMethodOptions.iOS.urlScheme`:

```tsx theme={"dark"}
import type { PrimerSettings } from '@primer-io/react-native';

const settings: PrimerSettings = {
  paymentMethodOptions: {
    iOS: {
      urlScheme: 'myapp://primer',
    },
  },
};
```

## Apple Pay

Apple Pay is available on iOS only. On Android, `usePrimerPaymentMethod('APPLE_PAY').isAvailable` is `false`.

1. In Xcode, select your app target, open **Signing & Capabilities** and add the **Apple Pay** capability. This adds the `com.apple.developer.in-app-payments` entitlement.
2. Create a merchant identifier in the [Apple Developer portal](https://developer.apple.com/account/resources/identifiers/list/merchant), for example `merchant.com.myapp`, and select it under the Apple Pay capability.
3. Pass the merchant identifier in `paymentMethodOptions.applePayOptions`:

```tsx theme={"dark"}
const settings: PrimerSettings = {
  paymentMethodOptions: {
    applePayOptions: {
      merchantIdentifier: 'merchant.com.myapp',
      isCaptureBillingAddressEnabled: false,
    },
  },
};
```

`merchantIdentifier` must match the identifier you selected in Xcode. It is required to pay. Without it, selecting Apple Pay fails with a `PrimerError`. `isCaptureBillingAddressEnabled` is deprecated. Use `billingOptions` to request billing fields. Set the merchant name in the [client session](https://primer.io/docs/checkout/client-session.md) rather than in `merchantName`, which is deprecated.

Apple Pay also needs a payment processing certificate and Apple Pay set up for your processor in the Primer Dashboard. See [Apple Pay](https://primer.io/docs/connections/payment-methods/apple-pay/overview.md). The prebuilt sheet shows Apple Pay with Apple's own Apple Pay button.

For the other `applePayOptions` fields, see [PrimerSettings](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/primer-settings.md).

## Google Pay

Google Pay is available on Android only. On iOS, `usePrimerPaymentMethod('GOOGLE_PAY').isAvailable` is `false`.

Enable Google Pay in the Primer Dashboard. To change what the Google Pay sheet collects, set `paymentMethodOptions.googlePayOptions`:

```tsx theme={"dark"}
const settings: PrimerSettings = {
  paymentMethodOptions: {
    googlePayOptions: {
      merchantName: 'My Store',
      isCaptureBillingAddressEnabled: true,
      emailAddressRequired: true,
    },
  },
};
```

All `googlePayOptions` fields are optional. For the full list, see [PrimerSettings](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/primer-settings.md).

## 3D Secure

Add `Primer3DS` on iOS and `io.primer:3ds-android` on Android, as shown above. The native SDK runs the 3D Secure challenge. There's no JavaScript API for it.

To send the shopper back to your app automatically after an out-of-band challenge in another app, set `threeDsAppRequestorUrl` for each platform. On iOS it must be a Universal Link, and on Android an App Link:

```tsx theme={"dark"}
const settings: PrimerSettings = {
  paymentMethodOptions: {
    threeDsOptions: {
      iOS: { threeDsAppRequestorUrl: 'https://myapp.example.com/3ds' },
      android: { threeDsAppRequestorUrl: 'https://myapp.example.com/3ds' },
    },
  },
};
```

For the Universal Link and App Link setup of your domain and app, see "Handle Out-of-Band (OOB) redirects" in the React Native tab of the [3D Secure guide](https://primer.io/docs/payment-services/3d-secure/get-started.md). Its iOS `AppDelegate` steps and Android manifest steps apply to Primer Checkout too.

> [!WARNING]
>
> The 3D Secure SDK runs security checks that fail on debug builds, emulators and apps not installed from a store. During development, you can turn them off with `debugOptions: { is3DSSanityCheckEnabled: false }`. Never ship that setting in a production build.

## Klarna

### iOS

Add the `PrimerKlarnaSDK` pod and [register a URL scheme](#register-a-url-scheme-on-ios). Without the pod, Klarna isn't listed on iOS, or fails with the message `PrimerKlarnaSDK missing`.

### Android

1. Add `io.primer:klarna-android` and Klarna's Maven repository, as shown above.
2. Add an activity that handles the URL Klarna returns to, in `android/app/src/main/AndroidManifest.xml`:

```xml theme={"dark"}
<activity
  android:name=".KlarnaReturnActivity"
  android:exported="true"
  android:launchMode="singleTop">
  <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="myapp" />
    <data android:host="klarna.return" />
  </intent-filter>
</activity>
```

The activity only has to bring your app back:

```kotlin theme={"dark"}
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class KlarnaReturnActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    startActivity(Intent(this, MainActivity::class.java))
    finish()
  }
}
```

With `MainActivity` on `android:launchMode="singleTask"`, as in the React Native app template, this returns the shopper to the running app.

3. Pass the same URL as `klarnaOptions.returnIntentUrl`:

```tsx theme={"dark"}
const settings: PrimerSettings = {
  paymentMethodOptions: {
    klarnaOptions: {
      returnIntentUrl: 'myapp://klarna.return',
    },
  },
};
```

> [!WARNING]
>
> Without `returnIntentUrl`, Klarna on Android fails with `klarna-return-url-missing` when the shopper selects a Klarna payment category. iOS doesn't use `returnIntentUrl`.

## Stripe ACH

Add `PrimerStripeSDK` on iOS and `io.primer:stripe-android` on Android, as shown above. Without the iOS pod, Stripe ACH fails with the message `PrimerStripeSDK missing`.

Then set `paymentMethodOptions.stripeOptions` with your Stripe publishable key and the mandate text:

```tsx theme={"dark"}
const settings: PrimerSettings = {
  paymentMethodOptions: {
    stripeOptions: {
      publishableKey: 'pk_live_...',
      mandateData: { merchantName: 'My Store' },
    },
  },
};
```

* Set `publishableKey`.
* Set `mandateData` to exactly one of `{ merchantName }`, which fills your name into Primer's standard mandate text, or `{ fullMandateText }`, which uses your own text.
* Without `mandateData`, the payment fails with `stripe-ach-mandate-config` when it reaches the mandate step, which comes after the shopper links a bank account.
* On Android, the activity that hosts React Native must extend `androidx.activity.ComponentActivity`. React Native's `ReactActivity` does. Otherwise Stripe ACH fails with a message that contains `Unsupported activity type`.

## See also

> [card] [Installation](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/installation.md)
>
> Install the package and the iOS pods

> [card] [PrimerSettings](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/primer-settings.md)
>
> Every settings key that affects Checkout Components

> [card] [Handle the payment result](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/handle-payment-result.md)
>
> Read the outcome of each payment attempt

> [card] [Troubleshooting](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/troubleshooting.md)
>
> Fix installation and setup errors


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.