Apple Pay can be used with Primer's headless SDK integrations.

Apple Pay via headless is only support for iOS and React Native

Before you begin

This guide assumes that you know how to:

Accept payments with Apple Pay

Prepare the API

Apple Pay requires the following data to process a payment successfully. Pass the following data in the client session, or in the payment request (for manual payment creation).

Parameter NameRequiredDescription
3-letter currency code in ISO 4217 format, e.g. USD for US dollars
  1. order
Details of the line items of the order
  1. order
The country in which the order is created

Prepare the SDK for payments

Pre-requisites

Step 1: Prepare Apple Pay settings
  1. 1
    Select the Signing and Capabilities tab in your target’s settings.
  2. 2
    Tap the + Capability button on the top left, and select Apple Pay from the list.

null

    null

      123456
      let settings = PrimerSettings(    // ...    merchantIdentifier: "merchant-identifier",    // ...)Primer.shared.configure(settings: settings)
      swift
      copy
      Step 2: Display Apple Pay button
      1234567891011121314151617181920212223242526272829303132333435
      extension ViewController: PrimerHeadlessUniversalCheckoutDelegate {     func primerHeadlessUniversalCheckoutDidLoadAvailablePaymentMethods(_ paymentMethodTypes: [String]) {        self.paymentMethods = paymentMethodsTypes    }     func primerHeadlessUniversalCheckoutDidCompleteCheckoutWithData(_ data: PrimerCheckoutData) {        // Checkout completed    }} extension UIViewController: UITableViewDataSource, UITableViewDelegate {     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {        return self.paymentMethods.count    }     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {        let paymentMethod = self.paymentMethods[indexPath.row]        let cell = tableView.dequeueReusableCell(withIdentifier: "MerchantPaymentMethodCell", for: indexPath) as! MerchantPaymentMethodCell        cell.configure(paymentMethodType: paymentMethod)         // Primer SDK can provide you with Payment Method buttons that follow        // the payment methods UI guidelines.        // Example given for Apple Pay payment method        // https://developer.apple.com/design/human-interface-guidelines/technologies/apple-pay/introduction        // let paymentMethodButton = PrimerHeadlessUniversalCheckout.makeButton(for: paymentMethod)         return cell    }     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {        // The user has selected a payment method    }}
      swift
      copy

      Handle payment method

      1
      PrimerHeadlessUniversalCheckout.current.showPaymentMethod("APPLE_PAY")
      swift
      copy

      Limitations

      • When used in the simulator, Apple Pay appears but fails to complete the flow. This is due to a limitation of Apple Pay that does not return the correct data when used in the simulator.
      • Our current implementation of Apple Pay does not support the card networks mir, girocard, bancomat, and bancontact.

      Troubleshooting

      **[unable-to-make-payments-on-provided-networks]**

        null

        1. 3
          You are using a jailbroken device.
        2. 4
          Your Apple Pay wallet doesn’t contain any valid credit/debit cards.
        3. 5
          The card network (e.g. Visa) of the active card is not supported. Payment networks supported vary on iOS version. Also not all test cards work on development environment.
        4. 6
          Your device has restrictions enabled (e.g. parental controls).
        5. 7
          The hardware of your device doesn’t support Apple Pay.
        **How to recover?** - Try on a different (real) device. - Try with a different card (and also set it as the default wallet card).

        Apple Pay Is Not Available in “APP NAME”

        null
        The merchant identifier(s) configured in Xcode do not match the merchant identifiers of the Apple Pay certificates in your Apple Developer portal.

        **How to recover?** Make sure that you have the correct merchant identifier selected in Xcode, as shown in the screenshot below.

        A correct merchant identifier must satisfy the following conditions:

        • Is present in your Xcode’s merchant identifiers in the Apple Pay capability.
        • Is used by a valid Apple Pay certificate in your Apple Portal
        • The above mentioned Apple Pay certificate is uploaded in Primer’s dashboard

        **[server-error] Server error [404]: No Matching ProcessingCertificate could be found**

        Even though you are using the correct entitlements in your Xcode project, and there is a valid Apple Pay certificate in your Apple Developer portal, the Apple Pay certificate used by the app does not match the Apple Pay certificate that has been uploaded in your dashboard.

        **How to recover?** Upload the correct Apple Pay certificate on Primer’s dashboard.

        [payment-cancelled] Payment method APPLE_PAY cancelled or the Apple Pay view getting dismissed The merchant identifier that you’re passing to Primer SDK is not correct, and it isn’t present in Xcode’s capabilities, or you haven’t provided a merchant name.

        null

        **How to recover?** Make sure that you have the correct merchant identifier selected in Xcode.

        A correct merchant identifier must satisfy the following conditions:

        • Is present in your Xcode’s merchant identifiers in the Apple Pay capability.

        null

        • Is used by a valid Apple Pay certificate in your Apple Portal
        • The above mentioned Apple Pay certificate is uploaded in Primer’s dashboard

        [NSErrorDomain:4864] the data couldn't be read because it is not in the correct format

        Apple Pay will not work on the simulator, it will arrive to the Apple Pay modal view, then fail with the above error when trying to pay. Try it on a real device with Apple Pay enabled.

        **How to recover?** Attempt to complete a payment on a real device.

        Go live

        You don’t need to do anything particular to go live — just make sure to use production credentials.