SWIFT
func configure(settings: PrimerSettings? = nil, delegate: PrimerDelegate? = nil)
Parameters
Hide Parameters
Hide Parameters
PrimerSettings
required
Hide Properties
Hide Properties
enum PrimerPaymentHandling
Use this to set you payment handling flow. Defaults to
.auto.Hide Cases
Hide Cases
default
Primer SDK will create the payment and handle the flow.
If you use the manual flow, make sure you add the
primerDidTokenizePaymentMethod(_:decisionHandler:) delegate function of PrimerDelegate, create a payment on your backend and call the decisionHandler of the delegate function once you receive your backend’s response.PrimerLocaleData
PrimerPaymentMethodOptions
Hide Properties
Hide Properties
String
⚠️ Required for some payment methods (e.g. PayPal).
This option sets the deeplink schema used when redirecting back from 3rd party applications to your app.
This option sets the deeplink schema used when redirecting back from 3rd party applications to your app.
PrimerApplePayOptions
⚠️ Required when using Apple Pay in your integration.
Hide Properties
Hide Properties
String
required
Set it to the merchant identifier as it is shown in your Apple Pay
certificate.
String
deprecated
Set it to the merchant name that you want to be shown on the Apple Pay screen. Deprecated, use ClientSession instead.
Bool
Defaults to
false. Set to true to let Apple Pay capture the customer’s billing address.Use BillingOptions to configure required billing fields.Bool
If in some cases you don’t want to present ApplePay option if the device is not supporting it set this to
false. The default value is true.Default value is true. Set to false if you do not want to present
Apple Pay option on unsupported devices.Bool
Flag introduced to enable the initiation of the ApplePay flow even when no cards are present in the Wallet. To enable the feature, set this to
false. The default value true.Default value is true. This flag supports the old behavior where Apple
Pay flow might not present if there are no cards in the Wallet.ShippingOptions
BillingOptions
Configure billing options for Apple Pay.
Hide Properties
Hide Properties
Array of RequiredContactField
Specify which contact fields are required for billing.
Array of CardType
Restrict the card types Apple Pay offers. Supported values:
.credit, .debit. When omitted or empty, all card types are offered.PrimerKlarnaOptions
⚠️ Required when using Klarna in your integration.
Hide Properties
Hide Properties
String
required
Set the payment description that will be shown on the Klarna screen.
PrimerThreeDsOptions
Hide Properties
Hide Properties
String
Set the iOS Universal Link that’s used to call your app after an out-of-band (OOB) authentication.
Supported in 3D Secure protocol versions 2.2.0 and after.
PrimerStripeOptions
⚠️ Required when using Stripe ACH in your integration.
Hide Properties
Hide Properties
String?
Set the Stripe publishable key.
PrimerUIOptions
Set the
uiOptions for custom UI options of the Primer SDK.Hide Properties
Hide Properties
Bool
Set to
false to hide the loading screen before the Universal Checkout or the Vault Manager. Defaults to true.Bool
Set to
false to hide the screen after a successful payment, or tokenization on the vault flow. Defaults to true.Bool
Set to
false to hide the error screen when an error occurs. Defaults to true.enum DismissalMechanism
Set the mechanism for dismissing Universal Checkout. Options are:
gestures: The dialog can be dismissed by tapping outside or by swiping down.closeButton: A close button is provided, allowing users to dismiss the dialog manually.
PrimerTheme
Set a custom theme for Primer SDK.
enum PrimerAppearanceMode
Control the SDK’s appearance mode independently of the system setting. This allows apps to force light or dark mode regardless of the device’s appearance setting.
Bool
Default: false
Before enabling the flag to true it’s recommended to reach out to Primer
support for additional verification since there are edge cases where it’s not
advised.
true, responses from the server will be cached on the client side, allowing for faster subsequent
access to the same data within the cache duration. When set to false, every request to the server will be
processed without utilizing any client-side cache, ensuring that the client always receives the most up-to-date data.PrimerApiVersion
Default: PrimerApiVersion.V2_4
Indicates the API version to use when interacting with the Primer backend. Options are:
PrimerApiVersion.V2_4- will use ApiVersion 2.4
V2.4 will be used by default.PrimerDelegate
Optional
Set Primer SDK’s delegate and implement the required delegate methods. Alternatively you can set the delegate directly like
Primer.shared.delegate = yourDelegate.Example
Configuring Primer SDK.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: true,
isSuccessScreenEnabled: true,
isErrorScreenEnabled: true,
cardFormUIOptions: PrimerCardFormUIOptions(
payButtonAddNewCard: true
)
),
debugOptions: PrimerDebugOptions(is3DSSanityCheckEnabled: false))
}
}