- Web
- Android
- iOS
- React Native
Primer Checkout Web uses two types of configuration: component properties (HTML attributes) and SDK options (JavaScript object).
const checkout = document.querySelector('primer-checkout');
// Component properties - use setAttribute()
checkout.setAttribute('client-token', 'your-token');
// SDK options - assign directly
checkout.options = {
locale: 'en-GB',
card: { cardholderName: { required: true } }
};
The Android SDK uses
PrimerSettings to configure checkout behavior. Pass it when creating the checkout controller:val checkout = rememberPrimerCheckoutController(
clientToken = clientToken,
settings = PrimerSettings().apply {
locale = Locale("fr", "FR")
uiOptions.dismissalMechanism = listOf(DismissalMechanism.CLOSE_BUTTON)
},
)
The iOS SDK uses
PrimerSettings and PrimerCheckoutTheme to configure checkout behavior and appearance. Pass them when creating PrimerCheckout:PrimerCheckout(
clientToken: clientToken,
primerSettings: PrimerSettings(paymentHandling: .auto),
primerTheme: PrimerCheckoutTheme(
colors: ColorOverrides(primerColorBrand: .blue)
)
)
The React Native SDK uses
PrimerSettings to configure checkout behavior and a separate theme prop for appearance. Pass both to PrimerCheckoutProvider:import type { ReactNode } from 'react';
import { PrimerCheckoutProvider } from '@primer-io/react-native';
import type { PrimerSettings, PrimerThemeOverride } from '@primer-io/react-native';
const settings: PrimerSettings = {
uiOptions: { appearanceMode: 'SYSTEM' },
};
const theme: PrimerThemeOverride = {
light: { colors: { brand: '#2F6FED' } },
};
export function Checkout({ clientToken, children }: { clientToken: string; children: ReactNode }) {
return (
<PrimerCheckoutProvider clientToken={clientToken} settings={settings} theme={theme}>
{children}
</PrimerCheckoutProvider>
);
}
Configuration Overview
- Web
- Android
- iOS
- React Native
| Type | How to Set | Examples |
|---|---|---|
| Component Properties | setAttribute() | client-token, custom-styles, loader-disabled |
| SDK Options | Direct assignment to .options | locale, card, vault, applePay |
Don’t mix them up. Component properties must use
setAttribute(). SDK options must be assigned directly to .options.| Type | How to Set | Examples |
|---|---|---|
| Client token | rememberPrimerCheckoutController(clientToken) | Authentication token |
| Settings | PrimerSettings object | locale, uiOptions, paymentMethodOptions, debugOptions |
| Theme | PrimerTheme parameter on composable | PrimerCheckoutSheet(theme = ...) |
Theming is not part of
PrimerSettings. Pass PrimerTheme directly to PrimerCheckoutSheet or PrimerCheckoutHost. See Styling Guide.| Type | How to Set | Examples |
|---|---|---|
| Client token | PrimerCheckout(clientToken:) | Authentication token |
| Settings | PrimerSettings parameter | paymentHandling, uiOptions, paymentMethodOptions |
| Theme | PrimerCheckoutTheme parameter | colors, darkColors, radius, spacing, sizes, typography, width |
Theming is not part of
PrimerSettings. Pass PrimerCheckoutTheme as a separate parameter to PrimerCheckout or PrimerCheckoutPresenter. See Styling Guide.| Type | How to Set | Examples |
|---|---|---|
| Client token | clientToken prop of PrimerCheckoutProvider | Authentication token |
| Settings | settings prop (PrimerSettings) | paymentMethodOptions, uiOptions, debugOptions, headlessUniversalCheckoutCallbacks |
| Theme | theme prop (PrimerThemeOverride) | light and dark, each with colors, spacing, typography, radii, sizes, widths |
Theming is not part of
PrimerSettings. Pass theme as a separate prop to PrimerCheckoutProvider. See Styling Guide and PrimerThemeOverride.Component Properties / Client Token
The client token authenticates your checkout session. Obtain this by creating a client session.- Web
- Android
- iOS
- React Native
client-token (required)
// ✅ Correct
checkout.setAttribute('client-token', 'your-client-token');
// ❌ Wrong - won't work
checkout.clientToken = 'your-token';
<!-- Or set directly in HTML -->
<primer-checkout client-token="your-client-token"></primer-checkout>
Updating the client token
To start a new session, set a new client token on the existing component. The checkout tears down the current session and initializes the new one in place, so you don’t need to reload the page or recreate the component.checkout.setAttribute('client-token', newClientToken);
primer:ready fires again with a new PrimerJS instance. Don’t change the token while a payment is in progress.If you updated the existing client session on your server and the token hasn’t changed, call primer.refreshSession() instead. It syncs the checkout with the session without re-initializing.custom-styles
JSON string containing CSS variables for theming.const styles = {
primerColorBrand: '#4a6cf7',
primerTypographyBrand: 'Inter, sans-serif'
};
checkout.setAttribute('custom-styles', JSON.stringify(styles));
See Styling Guide for available properties.
loader-disabled
Disables the default loading spinner.checkout.setAttribute('loader-disabled', 'true');
Pass the client token directly when creating the checkout controller:
val checkout = rememberPrimerCheckoutController(
clientToken = clientToken,
)
Pass the client token directly when creating
PrimerCheckout:// SwiftUI
PrimerCheckout(clientToken: clientToken)
// UIKit
PrimerCheckoutPresenter.presentCheckout(
clientToken: clientToken,
from: viewController,
primerSettings: PrimerSettings(),
primerTheme: PrimerCheckoutTheme()
)
Pass the client token as the A new
clientToken prop of PrimerCheckoutProvider. The provider starts the session when it mounts:<PrimerCheckoutProvider clientToken={clientToken}>
<PrimerCheckoutSheet visible={visible} onRequestDismiss={() => setVisible(false)} />
</PrimerCheckoutProvider>
clientToken ends the current session and starts a new one.SDK Options / Settings
- Web
- Android
- iOS
- React Native
SDK options configure checkout behavior. Assign a JavaScript object directly to the
options property.// ✅ Correct - assign directly
checkout.options = {
locale: 'en-GB',
card: { cardholderName: { required: true } }
};
// ❌ Wrong - don't use setAttribute for options
checkout.setAttribute('options', JSON.stringify({...}));
For the complete list of available options, see the SDK Options Reference.
PrimerSettings configures the SDK behavior for a checkout session. Pass it when creating the controller.val checkout = rememberPrimerCheckoutController(
clientToken = clientToken,
settings = PrimerSettings().apply {
locale = Locale("fr", "FR")
uiOptions.dismissalMechanism = listOf(DismissalMechanism.CLOSE_BUTTON)
paymentMethodOptions.redirectScheme = "myapp"
},
)
For the complete list of available options, see the SDK Options Reference.
PrimerSettings configures the SDK behavior for a checkout session. Pass it when creating PrimerCheckout.let settings = PrimerSettings(
paymentHandling: .auto,
paymentMethodOptions: PrimerPaymentMethodOptions(),
uiOptions: PrimerUIOptions()
)
PrimerCheckout(
clientToken: clientToken,
primerSettings: settings
)
For the complete list of available options, see the SDK Options Reference.
PrimerSettings configures the SDK behavior for a checkout session. Pass it as the settings prop of PrimerCheckoutProvider.import type { PrimerSettings } from '@primer-io/react-native';
const settings: PrimerSettings = {
paymentMethodOptions: {
iOS: { urlScheme: 'myapp://primer' },
},
uiOptions: { appearanceMode: 'SYSTEM' },
};
For the complete list of available options, see the SDK Options Reference.
Common Patterns
- Web
- Android
- iOS
- React Native
Set Locale
checkout.options = {
locale: 'en-GB'
};
Supported locales
Enable Specific Payment Methods
import { PaymentMethodType } from '@primer-io/primer-js';
checkout.options = {
enabledPaymentMethods: [
PaymentMethodType.PAYMENT_CARD,
PaymentMethodType.PAYPAL,
PaymentMethodType.ADYEN_BLIK
]
};
Pre-fill Cardholder Name
checkout.options = {
card: {
cardholderName: {
required: true,
visible: true,
defaultValue: 'John Doe'
}
}
};
primer.setCardholderName() instead.Enable Vault (Saved Payment Methods)
checkout.options = {
vault: {
enabled: true
}
};
Configure Apple Pay Button
checkout.options = {
applePay: {
buttonType: 'buy',
buttonStyle: 'black'
}
};
Configure Google Pay Button
checkout.options = {
googlePay: {
buttonType: 'buy',
buttonColor: 'black',
captureBillingAddress: true
}
};
Configure Klarna
checkout.options = {
klarna: {
paymentFlow: 'DEFAULT',
allowedPaymentCategories: ['pay_now', 'pay_later'],
buttonOptions: {
text: 'Pay with Klarna'
}
}
};
Configure Klarna via Adyen
checkout.options = {
adyenKlarna: {
buttonOptions: {
text: 'Pay with Klarna'
}
}
};
Set Locale
settings = PrimerSettings().apply {
locale = Locale("fr", "FR")
}
Locale.getDefault() (device locale). Controls SDK-internal strings and currency formatting.Custom Success/Error Screens
Replace the default success and error screens with your own composables via slot parameters:PrimerCheckoutSheet(
checkout = checkout,
success = { checkoutData ->
MyCustomSuccessScreen(checkoutData)
},
error = { primerError, _ ->
MyCustomErrorScreen(primerError)
},
)
Configure Dismissal Behavior
settings = PrimerSettings().apply {
uiOptions.dismissalMechanism = listOf(DismissalMechanism.CLOSE_BUTTON)
}
| Value | Behavior |
|---|---|
GESTURES | Swipe-to-dismiss (default) |
CLOSE_BUTTON | Explicit close button |
listOf(DismissalMechanism.GESTURES, DismissalMechanism.CLOSE_BUTTON).Configure Google Pay
settings = PrimerSettings().apply {
paymentMethodOptions.googlePayOptions = PrimerGooglePayOptions(
merchantName = "My Store",
captureBillingAddress = true,
emailAddressRequired = true,
buttonStyle = GooglePayButtonStyle.BLACK,
)
}
Set Redirect Scheme
Required for redirect-based payment methods (PayPal, Klarna, etc.):settings = PrimerSettings().apply {
paymentMethodOptions.redirectScheme = "myapp"
}
Set Payment Handling
let settings = PrimerSettings(paymentHandling: .auto)
| Value | Behavior |
|---|---|
.auto | Primer handles the full payment flow (recommended) |
.manual | Not supported in Primer Checkout. The checkout fails at start with a PrimerError whose errorId is invalid-value. Keep .auto. See PrimerPaymentHandling. |
Toggle Managed Screens
PrimerCheckout renders Primer’s default init, success, and error screens. Toggle them through uiOptions to handle results yourself instead:let settings = PrimerSettings(
uiOptions: PrimerUIOptions(
isInitScreenEnabled: false,
isSuccessScreenEnabled: false,
isErrorScreenEnabled: false
)
)
PrimerCheckoutSession instead of PrimerCheckout and drive them with the session’s published state.Configure Theme Colors
let theme = PrimerCheckoutTheme(
colors: ColorOverrides(
primerColorBrand: .blue,
primerColorBackgroundPrimary: .white
)
)
Handle Completion
PrimerCheckout(
clientToken: clientToken,
onCompletion: { state in
switch state {
case .success(let result):
print("Payment: \(result.paymentId)")
case let .failure(error, _):
print("Failed: \(error.localizedDescription)")
case .dismissed:
print("Dismissed")
default:
break
}
}
)
Set Payment Handling
const settings: PrimerSettings = { paymentHandling: 'AUTO' };
| Value | Behavior |
|---|---|
'AUTO' | Primer handles the full payment flow (default) |
'MANUAL' | Not supported in Primer Checkout. Keep 'AUTO'. |
Toggle Result Screens
PrimerCheckoutSheet shows a success, pending or error screen for each payment result. Turn them off through uiOptions to handle results yourself:const settings: PrimerSettings = {
uiOptions: {
isSuccessScreenEnabled: false,
isErrorScreenEnabled: false,
},
};
paymentOutcome and calls onRequestDismiss instead of showing it.For your own screens, build a custom layout with the hooks and the status screens.Configure Dismissal Behavior
<PrimerCheckoutSheet
visible={visible}
dismissOnBackdropPress={false}
onRequestDismiss={() => setVisible(false)}
/>
| Prop | Behavior |
|---|---|
onRequestDismiss | Called on a backdrop tap, a swipe down on the drag handle, Android back on a screen without a Back button, Cancel, and when a success or pending screen closes. Set visible to false here |
dismissOnBackdropPress | Whether a backdrop tap calls onRequestDismiss (default true) |
PrimerCheckoutSheet.Configure Google Pay
const settings: PrimerSettings = {
paymentMethodOptions: {
googlePayOptions: {
merchantName: 'My Store',
isCaptureBillingAddressEnabled: true,
emailAddressRequired: true,
},
},
};
applePayOptions.merchantIdentifier. See Native setup.Set Redirect URL Scheme
Payment methods such as PayPal and Klarna return to your iOS app through a URL scheme. Register the scheme in your app’sInfo.plist, then pass a URL with it:const settings: PrimerSettings = {
paymentMethodOptions: {
iOS: { urlScheme: 'myapp://primer' },
},
};
klarnaOptions.returnIntentUrl and an activity that handles that URL. See Native setup.Configure Theme Colors
const theme: PrimerThemeOverride = {
light: {
colors: { brand: '#2F6FED', backgroundPrimary: '#FFFFFF' },
},
dark: {
colors: { brand: '#6B9BFF' },
},
};
theme prop of PrimerCheckoutProvider. Set tokens for each mode under light and dark. See PrimerThemeOverride.Handle Completion
import { useEffect } from 'react';
import { usePrimerCheckout } from '@primer-io/react-native';
export function PaymentResult() {
const { paymentOutcome } = usePrimerCheckout();
useEffect(() => {
if (!paymentOutcome) return;
switch (paymentOutcome.status) {
case 'success':
console.log(`Payment: ${paymentOutcome.data.payment?.id}`);
break;
case 'pending':
console.log(`Pending: ${paymentOutcome.data.payment?.id}`);
break;
case 'error':
console.log(`Failed: ${paymentOutcome.error.description}`);
break;
}
}, [paymentOutcome]);
return null;
}
PaymentResult inside PrimerCheckoutProvider. Closing the sheet calls onRequestDismiss and onDismiss on PrimerCheckoutSheet. See Handle the payment result.Complete Example
- Web
- Android
- iOS
- React Native
import { PaymentMethodType } from '@primer-io/primer-js';
const checkout = document.querySelector('primer-checkout');
// 1. Component properties
checkout.setAttribute('client-token', 'your-client-token');
checkout.setAttribute('custom-styles', JSON.stringify({
primerColorBrand: '#4a6cf7'
}));
// 2. SDK options
checkout.options = {
locale: 'en-GB',
enabledPaymentMethods: [
PaymentMethodType.PAYMENT_CARD,
PaymentMethodType.PAYPAL
],
card: {
cardholderName: {
required: true,
visible: true
}
},
vault: {
enabled: true
}
};
@Composable
fun CheckoutScreen(clientToken: String) {
val checkout = rememberPrimerCheckoutController(
clientToken = clientToken,
settings = PrimerSettings().apply {
locale = Locale("fr", "FR")
uiOptions.dismissalMechanism = listOf(DismissalMechanism.CLOSE_BUTTON)
paymentMethodOptions.redirectScheme = "myapp"
paymentMethodOptions.googlePayOptions = PrimerGooglePayOptions(
merchantName = "My Store",
captureBillingAddress = true,
)
},
)
val state by checkout.state.collectAsStateWithLifecycle()
LaunchedEffect(state) {
when (val s = state) {
is PrimerCheckoutState.Success -> navigateToConfirmation(s.checkoutData)
is PrimerCheckoutState.Failure -> {
Log.e("Checkout", "Failed: ${s.primerError.description}")
}
else -> Unit
}
}
PrimerCheckoutSheet(
checkout = checkout,
success = { checkoutData -> MySuccessScreen(checkoutData) },
error = { primerError, _ -> MyErrorScreen(primerError) },
onDismiss = {
navigateBack()
},
)
}
private let primerSettings = PrimerSettings(
paymentHandling: .auto,
uiOptions: PrimerUIOptions(
dismissalMechanism: [.gestures, .closeButton]
)
)
private let primerTheme = PrimerCheckoutTheme(
colors: ColorOverrides(primerColorBrand: .blue),
radius: RadiusOverrides(primerRadiusMedium: 12)
)
struct CheckoutView: View {
let clientToken: String
var body: some View {
PrimerCheckout(
clientToken: clientToken,
primerSettings: primerSettings,
primerTheme: primerTheme,
onCompletion: { state in
switch state {
case .success(let result):
print("Payment: \(result.paymentId)")
case let .failure(error, _):
print("Failed: \(error.localizedDescription)")
case .dismissed:
print("Dismissed")
default:
break
}
}
)
}
}
import { useEffect, useState } from 'react';
import { Button } from 'react-native';
import {
PrimerCheckoutProvider,
PrimerCheckoutSheet,
usePrimerCheckout,
} from '@primer-io/react-native';
import type { PrimerSettings, PrimerThemeOverride } from '@primer-io/react-native';
import { fetchClientToken, showOrderConfirmation } from './checkout-api';
const settings: PrimerSettings = {
paymentMethodOptions: {
iOS: { urlScheme: 'myapp://primer' },
googlePayOptions: {
merchantName: 'My Store',
isCaptureBillingAddressEnabled: true,
},
},
uiOptions: { appearanceMode: 'SYSTEM' },
};
const theme: PrimerThemeOverride = {
light: { colors: { brand: '#2F6FED' }, radii: { medium: 12 } },
dark: { colors: { brand: '#6B9BFF' }, radii: { medium: 12 } },
};
function PaymentResult() {
const { paymentOutcome } = usePrimerCheckout();
useEffect(() => {
if (paymentOutcome?.status === 'success') {
showOrderConfirmation(paymentOutcome.data.payment?.id);
} else if (paymentOutcome?.status === 'error') {
console.warn(`Failed [${paymentOutcome.error.errorId}]: ${paymentOutcome.error.description}`);
}
}, [paymentOutcome]);
return null;
}
export function CheckoutScreen() {
const [clientToken, setClientToken] = useState<string | null>(null);
const [visible, setVisible] = useState(false);
const openCheckout = async () => {
setClientToken(await fetchClientToken());
setVisible(true);
};
return (
<>
<Button title="Checkout" onPress={openCheckout} />
{clientToken !== null && (
<PrimerCheckoutProvider clientToken={clientToken} settings={settings} theme={theme}>
<PaymentResult />
<PrimerCheckoutSheet
visible={visible}
onRequestDismiss={() => setVisible(false)}
onDismiss={() => setClientToken(null)}
/>
</PrimerCheckoutProvider>
)}
</>
);
}
Framework-Specific Patterns
- Web
- Android
- iOS
- React Native
- Vanilla JS
- React
- Next.js / SSR
document.addEventListener('DOMContentLoaded', () => {
const checkout = document.querySelector('primer-checkout');
checkout.setAttribute('client-token', 'your-token');
checkout.options = { locale: 'en-GB' };
});
const SDK_OPTIONS = { locale: 'en-GB' };
function CheckoutPage() {
return (
<primer-checkout
client-token="your-token"
options={SDK_OPTIONS}
/>
);
}
See React Integration Guide for stable references and React 18/19 differences.
'use client';
import { useEffect } from 'react';
import { loadPrimer } from '@primer-io/primer-js';
const SDK_OPTIONS = { locale: 'en-GB' };
export default function CheckoutPage() {
useEffect(() => {
loadPrimer();
}, []);
return (
<primer-checkout
client-token="your-token"
options={SDK_OPTIONS}
/>
);
}
See SSR Guide for framework-specific patterns.
The Android SDK uses standard Jetpack Compose patterns. Configuration is passed when creating the checkout controller:See the Best Practices guide for Compose-specific patterns.
@Composable
fun CheckoutScreen(clientToken: String) {
val checkout = rememberPrimerCheckoutController(
clientToken = clientToken,
settings = PrimerSettings().apply {
paymentMethodOptions.redirectScheme = "myapp"
},
)
PrimerCheckoutSheet(checkout = checkout)
}
- SwiftUI
- UIKit
struct CheckoutView: View {
let clientToken: String
var body: some View {
PrimerCheckout(
clientToken: clientToken,
primerSettings: PrimerSettings(paymentHandling: .auto),
onCompletion: { state in
// Handle result
}
)
}
}
See the Best Practices guide for SwiftUI-specific patterns.
class CheckoutViewController: UIViewController, PrimerCheckoutPresenterDelegate {
func showCheckout() {
PrimerCheckoutPresenter.shared.delegate = self
PrimerCheckoutPresenter.presentCheckout(
clientToken: clientToken,
from: self,
primerSettings: PrimerSettings(paymentHandling: .auto),
primerTheme: PrimerCheckoutTheme()
)
}
func primerCheckoutPresenterDidCompleteWithSuccess(_ result: PaymentResult) {
// Navigate to confirmation
}
func primerCheckoutPresenterDidFailWithError(_ error: PrimerError, checkoutData: PrimerCheckoutData?) {
print("Failed: \(error.localizedDescription)")
}
func primerCheckoutPresenterDidDismiss() {
print("Dismissed")
}
}
See UIKit Integration Guide for more details.
The React Native SDK is a set of React components and hooks, so there is one integration pattern. Configuration is passed as props to Define
PrimerCheckoutProvider:import { useState } from 'react';
import { PrimerCheckoutProvider, PrimerCheckoutSheet } from '@primer-io/react-native';
import type { PrimerSettings } from '@primer-io/react-native';
const settings: PrimerSettings = {
paymentMethodOptions: {
iOS: { urlScheme: 'myapp://primer' },
},
};
export function CheckoutScreen({ clientToken }: { clientToken: string }) {
const [visible, setVisible] = useState(true);
return (
<PrimerCheckoutProvider clientToken={clientToken} settings={settings}>
<PrimerCheckoutSheet visible={visible} onRequestDismiss={() => setVisible(false)} />
</PrimerCheckoutProvider>
);
}
settings and theme outside your component, or memoize them. The provider merges the theme tokens again each time it receives new theme.light or theme.dark objects. See the Best Practices guide for more patterns.Advanced Configuration
- Web
- Android
- iOS
- React Native
Headless Vault
Headless Vault
Build custom vault UIs while retaining full vault functionality. Enable headless mode:Then use
checkout.options = {
vault: {
enabled: true,
headless: true
}
};
onVaultedMethodsUpdate, vault.createCvvInput(), and vault.startPayment() to build your custom UI.Headless Vault Implementation Guide
External Submit Button
External Submit Button
Use your own submit button instead of the built-in one:
checkout.options = {
submitButton: {
useBuiltInButton: false
}
};
// Trigger submission from your button
document.getElementById('my-button').addEventListener('click', () => {
document.dispatchEvent(new CustomEvent('primer:card-submit', {
bubbles: true,
composed: true
}));
});
External Submit Button Recipe
Show Amount on Button
Show Amount on Button
Display the payment amount on the submit button:
checkout.options = {
submitButton: {
amountVisible: true
}
};
Custom Submit Button
Custom Submit Button
Override the submit button slot in
PrimerCardForm:PrimerCardForm(
controller = cardFormController,
submitButton = {
Button(
onClick = { cardFormController.submit() },
enabled = formState.isFormValid && !formState.isLoading,
) {
Text("Pay")
}
},
)
External Submit Button Recipe
Pay Button Text
Pay Button Text
Set the text of the card form Pay button. Write The button reads “Complete order £11.50”. Without
{amount} where the order total should go, and the SDK fills it in with any card surcharge included:settings = PrimerSettings().apply {
uiOptions.cardFormUIOptions = PrimerCardFormUIOptions(
payButtonText = "Complete order {amount}",
)
}
{amount} it shows no amount, and unset keeps “Pay”.Google Pay with Shipping
Google Pay with Shipping
Configure Google Pay to collect billing address, email, and shipping:
settings = PrimerSettings().apply {
paymentMethodOptions.googlePayOptions = PrimerGooglePayOptions(
merchantName = "My Store",
captureBillingAddress = true,
emailAddressRequired = true,
shippingAddressParameters = PrimerGoogleShippingAddressParameters(
phoneNumberRequired = true,
),
requireShippingMethod = true,
)
}
Stripe ACH Mandate
Stripe ACH Mandate
Configure mandate data for Stripe ACH payments:
settings = PrimerSettings().apply {
paymentMethodOptions.stripeOptions = PrimerStripeOptions(
mandateData = MandateData.TemplateMandateData(merchantName = "My Store"),
)
}
3DS Configuration
3DS Configuration
Set the 3DS App Requestor URL:
settings = PrimerSettings().apply {
paymentMethodOptions.threeDsOptions = PrimerThreeDsOptions(
threeDsAppRequestorUrl = "https://mystore.com",
)
}
Inline Custom Layout
Inline Custom Layout
PrimerCheckout renders the SDK’s default screens. For a fully custom layout, hold a PrimerCheckoutSession as a @StateObject, compose the SwiftUI views you need, and wire them up with the .primerCheckoutSession(_:theme:onCompletion:) modifier:struct CustomCheckoutView: View {
@StateObject private var session: PrimerCheckoutSession
init(clientToken: String) {
_session = StateObject(wrappedValue: PrimerCheckoutSession(clientToken: clientToken))
}
var body: some View {
ScrollView {
VStack(spacing: 24) {
Text("Secure Checkout").font(.headline)
PrimerPaymentMethods()
PrimerCardForm()
}
.padding()
}
.primerCheckoutSession(session) { state in
// The closure receives .failure for each failed payment attempt, so the shopper can retry.
// It receives .success or .dismissed once. After either, or after a failed initialization, it receives nothing more.
}
}
}
Pay Button Text
Pay Button Text
Set the text of the card form Pay button. Write The button reads “Complete order £11.50”. Without
{amount} where the order total should go, and the SDK fills it in with any card surcharge included:let settings = PrimerSettings(
uiOptions: PrimerUIOptions(
cardFormUIOptions: PrimerCardFormUIOptions(payButtonText: "Complete order {amount}")
)
)
{amount} it shows no amount, and nil keeps “Pay”.Custom Card Form Submit Button
Custom Card Form Submit Button
Override the The other slots (
submitButton slot on PrimerCardForm. Each slot closure receives the active PrimerCardFormSession, so you read session.state and call session.submit():PrimerCardForm(submitButton: { session in
Button("Pay Now") {
session.submit()
}
.disabled(!session.state.isValid || session.state.isLoading)
})
cardDetails, billingAddress) keep their CardFormDefaults styling. Place PrimerCardForm under the .primerCheckoutSession modifier so it resolves its session from the environment.Custom Submit Button Recipe
Pay Button Text
Pay Button Text
Set the text of the card form Pay button. Write The button reads “Complete order £11.50”. Without
{amount} where the order total should go, and the SDK fills it in with any card surcharge included:const settings: PrimerSettings = {
uiOptions: {
cardFormUIOptions: { payButtonText: 'Complete order {amount}' },
},
};
{amount} it shows no amount, and unset keeps “Pay”.Custom Layout and Pay Button
Custom Layout and Pay Button
Instead of Set your own “paying” flag on tap, and clear it only if the payment fails. The result arrives in
PrimerCheckoutSheet, compose your own layout inside PrimerCheckoutProvider. A card payment needs PrimerCardFormProvider, a call to start() on usePrimerPaymentMethod('PAYMENT_CARD'), and your own Pay button that calls usePrimerCardForm().submit():import { useEffect, useState } from 'react';
import { Button, ScrollView, Text } from 'react-native';
import {
PrimerCardForm,
PrimerCardFormProvider,
PrimerCheckoutProvider,
usePrimerCardForm,
usePrimerCheckout,
usePrimerPaymentMethod,
} from '@primer-io/react-native';
function CardPayment() {
const { paymentOutcome } = usePrimerCheckout();
const card = usePrimerPaymentMethod('PAYMENT_CARD');
const cardForm = usePrimerCardForm();
const [isPaying, setIsPaying] = useState(false);
const start = card.kind === 'card' && card.isAvailable ? card.start : undefined;
useEffect(() => {
start?.();
}, [start]);
useEffect(() => {
if (paymentOutcome?.status === 'error') setIsPaying(false);
}, [paymentOutcome]);
const pay = () => {
if (!cardForm.isValid || isPaying) return;
setIsPaying(true);
void cardForm.submit();
};
return (
<ScrollView contentContainerStyle={{ gap: 24, padding: 16 }}>
<Text>Secure Checkout</Text>
<PrimerCardForm editable={!isPaying} onSubmit={pay} />
<Button title="Pay" disabled={!cardForm.isValid || isPaying} onPress={pay} />
</ScrollView>
);
}
export function CustomCheckout({ clientToken }: { clientToken: string }) {
return (
<PrimerCheckoutProvider clientToken={clientToken}>
<PrimerCardFormProvider>
<CardPayment />
</PrimerCardFormProvider>
</PrimerCheckoutProvider>
);
}
usePrimerCheckout().paymentOutcome.Custom Submit Button Recipe
Stripe ACH Mandate
Stripe ACH Mandate
Configure the publishable key and mandate data for Stripe ACH payments:Set exactly one of
const settings: PrimerSettings = {
paymentMethodOptions: {
stripeOptions: {
publishableKey: 'pk_live_...',
mandateData: { merchantName: 'My Store' },
},
},
};
merchantName or fullMandateText in mandateData. See Native setup.3DS Configuration
3DS Configuration
Set the 3DS App Requestor URL for each platform:
const settings: PrimerSettings = {
paymentMethodOptions: {
threeDsOptions: {
iOS: { threeDsAppRequestorUrl: 'https://mystore.com/3ds' },
android: { threeDsAppRequestorUrl: 'https://mystore.com/3ds' },
},
},
};
See also
Web SDK Options Reference
Complete list of all available Web options
Android SDK Reference
Android SDK API documentation
Events Guide
Handle payment success, failure, and state changes
Styling
Customize colors, fonts, and spacing