OloPayAPI
@objc
public class OloPayAPI : NSObject, OloPayAPIProtocol
Represents the OloPayAPI and functionality related to it
Important
Prior to calling methods in this class be sure to initialize the SDK by callingOloPayApiInitializer.setup(...)
-
Creates an
OPPaymentMethodProtocol
instance with the provided parametersDeclaration
Swift
@objc(createPaymentMethodWithPaymentMethodParams:completion:) public func createPaymentMethod(with params: OPPaymentMethodParamsProtocol, completion: @escaping OPPaymentMethodCompletionBlock)
Parameters
params
The
OPPaymentMethodParamsProtocol
supplied either by anOPPaymentCardDetailsView
orOPPaymentCardDetailsForm
.completion
The callback to run with the returned
OPPaymentMethodProtocol
instance, or an error. -
Creates an
OPCvvUpdateTokenProtocol
instance with the provided parametersDeclaration
Swift
@objc(createCvvUpdateTokenWithTokenParams:completion:) public func createCvvUpdateToken(with params: OPCvvTokenParamsProtocol, completion: @escaping OPCvvTokenUpdateCompletionBlock)
Parameters
params
The
OPCvvTokenParamsProtocol
supplied by anOPPaymentCardCvvView
.completion
The callback to run with the returned
OPCvvUpdateTokenProtocol
instance, or an error -
Whether or not this device can make Apple Pay payments via a supported card network Supported ApplePay card networks are: American Express, Visa, Mastercard, Discover
Important
While this should be used in determining if an Apple Pay button can be displayed, it should not be the only determining factor. It is also important to determine whether a restaurant/vendor supports Apple Pay as a payment method, which can be determined using the Olo Ordering API.
Declaration
Swift
public func deviceSupportsApplePay() -> Bool
Return Value
true
if the device is currently able to make Apple Pay payments via one of the supported networks, orfalse
if the user does not have a saved card of a supported type, or other restrictions prevent payment (such as parental controls). -
A convenience method to build a
PKPaymentRequest
with sane default values.Important
OloPayApiInitializer.setup(...)
must have been called with both the Apple Pay merchant id and company name prior to calling this methodDeclaration
Swift
public func createPaymentRequest(forAmount amount: NSDecimalNumber, inCountry country: String = "US", withCurrency currency: String = "USD") throws -> PKPaymentRequest
Parameters
forAmount
The amount to charge
inCountry
The two-letter code for the payment country (Defaults to “US”)
withCurrency
The three-letter code for the currency (Defaults to “USD”). ApplePay interprets the amounts provided by the summary items attached to this request as amounts in this currency.
Return Value
a
PKPaymentRequest
with proper default values -
The environment the SDK is configured for
Declaration
Swift
public internal(set) static var environment: OPEnvironment { get set }