OPApplePayLauncherDelegate

@objc
public protocol OPApplePayLauncherDelegate : NSObjectProtocol

Protocol to hook into important events in the ApplePay flow

Required: Implement paymentMethodCreated to get payment method details that need to be submitted to Olo’s Ordering API when submitting a basket with OloPay

Optional: Implement applePayDismissed to know when the ApplePay sheet is dismissed

  • Called after the customer has authorized ApplePay and a payment method has been created. Implement this method to pass the payment method ID to Olo’s Ordering API when submitting a basket. If the API call returns an error, return that error so the ApplePay payment sheet can be dismissed appropriately.

    Warning

    This method should complete as quickly as possible. If it takes too long, Apple will force a timeout and display an error on the payment sheet. The timeout window is about 30 seconds. If a timeout occurs, then OPApplePayLauncherDelegate.applePayDismissed(...) will be called with a status of OPApplePayStatus.timeout prior to this method finishing.

    Declaration

    Swift

    @objc
    func paymentMethodCreated(from launcher: OPApplePayLauncherProtocol, with paymentMethod: OPPaymentMethodProtocol) -> NSError?

    Parameters

    launcher

    The apple pay launcher instance that caused this callback to be called

    paymentMethod

    The OPPaymentMethod that represents the customer’s Apple Pay payment method.

    Return Value

    nil if basket submission was successful, or an Error from Olo’s Ordering API if submission was unsuccessful

  • Called after the Apple Pay sheet is dismissed with the result of the payment. Your implementation could stop a spinner and display a receipt view or error to the customer, for example.

    Declaration

    Swift

    @objc
    optional func applePayDismissed(from launcher: OPApplePayLauncherProtocol, with status: OPApplePayStatus, error: Error?)

    Parameters

    launcher

    The apple pay launcher instance that caused this callback to be called

    status

    The status of the payment. If the status is OPApplePayStatus.timeout that means OPApplePayLauncherDelegate.paymentMethodCreated(...) did not complete fast enough and Apple forced a timeout status of the Apple Pay sheet

    error

    The error that occurred, if any. This will generally be OPError. If the error has an errorType of cardError it will also contain a user-friendly message that can be used to help the user understand why the payment couldn’t be completed.