2.1.1 • Published 2 years ago

@dineengine/capacitor-olo-pay v2.1.1

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
2 years ago

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(...)

initialize(options: InitializationOptions) => Promise<void>

Initialize the Olo Pay SDK. The SDK must be initialized prior to calling other methods.

ParamTypeDescription
optionsInitializationOptionsInitialization 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
ParamTypeDescription
optionsGooglePayInitializationOptionsOptions 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
ParamTypeDescription
optionsChangeGooglePayCountryOptionsOptions 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
ParamTypeDescription
optionsDigitalWalletPaymentRequestOptionsOptions 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

PropTypeDescription
freshInstallbooleanIf 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

PropTypeDescription
countryCodestringA two character country code

ChangeGooglePayCountryOptions

Options for changing the country code or merchant name for Google Pay

PropTypeDescription
countryCodestringA two character country code
merchantNamestringThe merchant/vendor display name

DigitalWalletStatus

Represents the status of digital wallets

PropTypeDescription
isReadybooleantrue if digital wallets are ready to be used, false otherwise

PaymentMethod

Payment method used for submitting payments to Olo's Ordering API

PropTypeDescription
idstringThe payment method id. This should be set to the token field when submitting a basket
last4stringThe last four digits of the card
cardTypestringThe issuer of the card
expMonthnumberTwo-digit number representing the card's expiration month
expYearnumberFour-digit number representing the card's expiration year
postalCodestringZip or postal code
countryCodestringTwo character country code
isDigitalWalletbooleantrue 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

PropTypeDescription
amountnumberThe amount to be charged
currencyCodestringA three character currency code. Defaults to "USD"
currencyMultipliernumberCurrency 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

PropTypeDescription
amountnumberThe amount to be charged
countryCodestringA two character country code. Defaults to "US"
currencyCodestringA three character currency code. Defaults to "USD"

DigitalWalletSupportStatus

PropType
supportedboolean

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

2.1.1

2 years ago

2.1.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago