Skip to main content
Primer’s SDK will need to be configured with a PrimerSettings object, no matter whether you’re using the drop-in or headless integration, auto or manual flow. This object greatly depends on your payment methods configuration.

Parameters

Example

Create a settings object.
SWIFT
// 👇 Add this
import PrimerSDK

class MyViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // 👇 Create your settings
        let settings = PrimerSettings(
            paymentHandling: .auto,
            localeData: PrimerLocaleData(
                languageCode: "en",
                regionCode: "US"),
            paymentMethodOptions: PrimerPaymentMethodOptions(
                urlScheme: "URL_SCHEME://",
                applePayOptions: PrimerApplePayOptions(
                    merchantIdentifier: "MERCHANT_IDENTIFIER",
                    merchantName: "MERCHANT_NAME",
                    isCaptureBillingAddressEnabled: true,
                    showApplePayForUnsupportedDevice: true,
                    checkProvidedNetworks: true,
                    shippingOptions: PrimerApplePayOptions.ShippingOptions(
                        shippingContactFields: [.name, .emailAddress],
                        requireShippingMethod: true
                    ),
                    billingOptions: PrimerApplePayOptions.BillingOptions(
                        requiredBillingContactFields: [.postalAddress]
                    )
                ),
                klarnaOptions: PrimerKlarnaOptions(
                    recurringPaymentDescription: "RECURRING_PAYMENT_DESCRIPTION"),
                stripeOptions: PrimerStripeOptions(
                    publishableKey: "STRIPE_PUBLISHABLE_KEY")),
            uiOptions: PrimerUIOptions(
                isInitScreenEnabled: false,
                isSuccessScreenEnabled: false,
                isErrorScreenEnabled: false,
                appearanceMode: .light), // Force light mode regardless of system setting
            debugOptions: PrimerDebugOptions(is3DSSanityCheckEnabled: false),
            clientSessionCachingEnabled: false)
    }
}

Appearance Mode Configuration

You can control the SDK’s appearance mode independently of the system setting using the appearanceMode property in PrimerUIOptions. This is particularly useful for apps that implement their own theme management.
SWIFT
// Force light mode regardless of system setting
let uiOptions = PrimerUIOptions(
    appearanceMode: .light  // Options: .system (default), .light, .dark
)

let settings = PrimerSettings(
    paymentHandling: .auto,
    uiOptions: uiOptions
)

// Configure Primer with the settings
Primer.shared.configure(settings: settings, delegate: self)
This feature is especially helpful when:
  • Your app has a “Always Light” or “Always Dark” mode setting
  • You want to maintain consistent appearance across the payment flow
  • You need to override the system’s dark mode setting for specific user preferences