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 ofOPApplePayStatus.timeoutprior to this method finishing.Declaration
Swift
@objc func paymentMethodCreated(from launcher: OPApplePayLauncherProtocol, with paymentMethod: OPPaymentMethodProtocol) -> NSError?Parameters
launcherThe apple pay launcher instance that caused this callback to be called
paymentMethodThe
OPPaymentMethodthat represents the customer’s Apple Pay payment method.Return Value
nilif 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
launcherThe apple pay launcher instance that caused this callback to be called
statusThe status of the payment. If the status is
OPApplePayStatus.timeoutthat meansOPApplePayLauncherDelegate.paymentMethodCreated(...)did not complete fast enough and Apple forced a timeout status of the Apple Pay sheeterrorThe error that occurred, if any. This could be the error returned from
paymentMethodCreated, anOPError,OPApplePayLauncher.unexpectedError, or an error generated by iOS. If it is anOPErrorand has anerrorTypeofcardError, it will also contain a user friendly message that can be used to help understand why the payment couldn’t be completed.