@dineengine/capacitor-olo-pay v2.1.1
capacitor-olo-pay
Gives access to native Olo Pay SDKs for use in Capacitor projects
Install
npm install @dineengine/capacitor-olo-pay
Add the following to your Podfile
pod 'OloPaySDK', :path => '../../node_modules/@dineengine/capacitor-olo-pay/ios/OloPaySDK'
Run Capacitor Sync
npx cap sync
API
initialize(...)
initializeGooglePay(...)
changeGooglePayCountry(...)
isDigitalWalletReady()
getDigitalWalletPaymentMethod(...)
supportsApplePay()
supportsGooglePay()
- Interfaces
- Type Aliases
initialize(...)
initialize(options: InitializationOptions) => Promise<void>
Initialize the Olo Pay SDK. The SDK must be initialized prior to calling other methods.
Param | Type | Description |
---|---|---|
options | InitializationOptions | Initialization options |
initializeGooglePay(...)
initializeGooglePay(options: GooglePayInitializationOptions) => Promise<void>
ANDROID ONLY: This method is not needed for iOS and will be a no-op if called
Initialize digital wallets. This must be called after initializing the SDK. When digital wallets
are ready, a digitalWalletReadyEvent
will be emitted.
The pomise will be rejected if required options are not passed in
Param | Type | Description |
---|---|---|
options | GooglePayInitializationOptions | Options for initializing digital wallets. countryCode and merchantName are required options. |
changeGooglePayCountry(...)
changeGooglePayCountry(options: ChangeGooglePayCountryOptions) => Promise<void>
ANDROID ONLY: This method is not needed for iOS and will be a no-op if called
Call this to change the country and merchant name used for processing Google Pay payments. This will immediately
trigger a digitalWalletReadyEvent
indicating digital wallets are not ready. When Google Pay
has been reinitialized and is ready to be used with the new parameters, another digitalWalletReadyEvent
will be
emitted.
NOTE: If other options need to be changed besides country code and merchant name you can call
initializeGooglePay()
instead, but it is more expensive than calling this method.
The promise will be rejected if Google Pay hasn't been initialized or if required options are not passed in
Param | Type | Description |
---|---|---|
options | ChangeGooglePayCountryOptions | Options for changing the country and merchant name. countryCode and merchantName are required options. |
isDigitalWalletReady()
isDigitalWalletReady() => Promise<DigitalWalletStatus>
Check if digital wallets are ready to be used. Events are emitted whenever the digital wallet status changes, so listenting to that event can be used instead of calling this method, if desired.
Returns: Promise<DigitalWalletStatus>
getDigitalWalletPaymentMethod(...)
getDigitalWalletPaymentMethod(options: DigitalWalletPaymentRequestOptions) => Promise<DigitalWalletPaymentMethodResult | undefined>
Launch the digital wallet flow and generate a payment method to be used with Olo's Ordering API.
The promise will be rejected in the following scenarios
- Required options are not passed in
- Google Pay has not been initialized
- Google Pay isn't ready
Param | Type | Description |
---|---|---|
options | DigitalWalletPaymentRequestOptions | Options for processing a digital wallet payment. amount is a required option |
Returns: Promise<DigitalWalletPaymentMethodResult>
supportsApplePay()
supportsApplePay() => Promise<DigitalWalletSupportStatus>
Returns: Promise<DigitalWalletSupportStatus>
supportsGooglePay()
supportsGooglePay() => Promise<DigitalWalletSupportStatus>
Returns: Promise<DigitalWalletSupportStatus>
Interfaces
InitializationOptions
Options for initializing the Olo Pay SDK
Prop | Type | Description |
---|---|---|
freshInstall | boolean | If true , this will be treated as a fresh setup of the SDK and cached data will be overwritten. This is useful for testing purposes when switching between Dev and Production environments. Defaults to false . NOTE: This should generally be false for production builds |
GooglePayInitializationOptions
Options for intializing Google Pay
Prop | Type | Description |
---|---|---|
countryCode | string | A two character country code |
ChangeGooglePayCountryOptions
Options for changing the country code or merchant name for Google Pay
Prop | Type | Description |
---|---|---|
countryCode | string | A two character country code |
merchantName | string | The merchant/vendor display name |
DigitalWalletStatus
Represents the status of digital wallets
Prop | Type | Description |
---|---|---|
isReady | boolean | true if digital wallets are ready to be used, false otherwise |
PaymentMethod
Payment method used for submitting payments to Olo's Ordering API
Prop | Type | Description |
---|---|---|
id | string | The payment method id. This should be set to the token field when submitting a basket |
last4 | string | The last four digits of the card |
cardType | string | The issuer of the card |
expMonth | number | Two-digit number representing the card's expiration month |
expYear | number | Four-digit number representing the card's expiration year |
postalCode | string | Zip or postal code |
countryCode | string | Two character country code |
isDigitalWallet | boolean | true if this payment method was created by digital wallets (e.g. Apple Pay or Google Pay), false otherwise |
GooglePayPaymentRequestOptions
Options for requesting a payment method via Google Pay
Prop | Type | Description |
---|---|---|
amount | number | The amount to be charged |
currencyCode | string | A three character currency code. Defaults to "USD" |
currencyMultiplier | number | Currency multiplier to convert the amount to the currency's smallest currency unit (e.g. $2.34 100 = 234 cents). _IMPORTANT: The amount charged will be equivalent to `amount currencyCode` so ensure this is set properly_ |
ApplePayPaymentRequestOptions
Options for requesting a payment method via Apple Pay
Prop | Type | Description |
---|---|---|
amount | number | The amount to be charged |
countryCode | string | A two character country code. Defaults to "US" |
currencyCode | string | A three character currency code. Defaults to "USD" |
DigitalWalletSupportStatus
Prop | Type |
---|---|
supported | boolean |
Type Aliases
DigitalWalletPaymentMethodResult
Type representing a digital wallet payment method result.
{ paymentMethod: PaymentMethod; error?: undefined } | { paymentMethod?: undefined; error: DigitalWalletError }
DigitalWalletError
Type representing a digital wallet error
{ errorMessage: string; digitalWalletErrorType: DigitalWalletErrorType; } & (ApplePayError | GooglePayError)
DigitalWalletErrorType
Digital wallet types
'applePay' | 'googlePay'
ApplePayError
{ /* TODO: Will be flushed out in Apple Pay implementation ticket / }
GooglePayError
Represents an error while processing a Google Pay transaction
{ /* The type of Google Pay error / googlePayErrorType?: GooglePayErrorType; }
GooglePayErrorType
Specific kinds of Google Pay Error
'NetworkError' | 'DeveloperError' | 'InternalError'
DigitalWalletPaymentRequestOptions
Type representing options for a digital wallet payment method request
GooglePayPaymentRequestOptions | ApplePayPaymentRequestOptions