Skip to main content

iOS SDK — Apple Pay

Native Apple Pay (PassKit) for a real device payment sheet.

SPM products: SwirepayCore, SwirepayApplePay
Import: import SwirepayApplePay


Native Apple Pay (PassKit)​

Requirements​

  • Physical iPhone — Simulator test cards do not work on Swirepay staging.
  • Apple Pay entitlement + merchant id issued by Swirepay.
  • SwirepayCore.shared.initialize called first.

With checkout session (encrypted v3 — same as Android payment modal): pass checkoutSession in initialize.
Without session (legacy): uses plain POST /v1/payment-method + POST /v2/payment-session.

Usage​

guard SwirepayApplePay.canMakeNativePayments() else { return }

let result = await SwirepayApplePay.shared.presentNativeApplePay(
from: self,
amountMinorUnits: 1000,
currencyCode: "USD",
presentation: ApplePayPresentation(
merchantIdentifier: "merchant.com.your.app",
transactionCountryCode: "US",
merchantDisplayName: "Your Store"
)
)

if let completion = result.paymentCompletionResponse, completion.success {
print(completion.prettyJSONString)
} else {
print(result.errorMessage ?? result.status.rawValue)
}

PassKit dismisses after the charge API calls. Always verify completion.success — HTTP 200 alone is not enough.