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.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 meansOPApplePayLauncherDelegate.paymentMethodCreated(...)
did not complete fast enough and Apple forced a timeout status of the Apple Pay sheeterror
The 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 anOPError
and has anerrorType
ofcardError
, it will also contain a user friendly message that can be used to help understand why the payment couldn’t be completed.