@dineengine/capacitor-olo-pay
TypeScript icon, indicating that this package has built-in type declarations

3.1.2 • Public • Published

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: AndroidInitializationOptions | iOSInitializationOptions) => Promise<void>

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

This promise will only be rejected on iOS. If it is rejected the code property on the returned error will be PromiseRejectionCode.missingParameter

NOTE: On iOS, this method will also initialize Apple Pay and a DigitalWalletReadyEvent will be emitted when it is ready to process payments. On Android, a separate initialization call to initializeGooglePay() is required.

Param Type Description
options OloPayInitializationConfig | iOSInitializationOptions Initialization options

initializeInternal(...)

initializeInternal(options: InternalInitOptions) => Promise<void>

Used internally by the Olo Pay SDK Plugin. Calling this method manually will result in a no-op

Param Type
options InternalInitOptions

initializeGooglePay(...)

initializeGooglePay(options: GooglePayInitializationOptions) => Promise<void>

ANDROID ONLY: If this method is called on iOS the promise will be rejected

Initialize digital wallets. This must be called after initializing the SDK. When digital wallets are ready, a DigitalWalletReadyEvent will be emitted.

If the promise is rejected, possible values of the code property on the returned error will be one of:

Param Type Description
options GooglePayInitializationOptions Options for initializing digital wallets. countryCode and merchantName are required options.

changeGooglePayVendor(...)

changeGooglePayVendor(options: ChangeGooglePayVendorOptions) => Promise<void>

ANDROID ONLY: If this method is called on iOS the promise will be rejected

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 event 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.

If the promise is rejected, possible values of the code property on the returned error will be one of:

Param Type Description
options ChangeGooglePayVendorOptions Options for changing the country and merchant name. countryCode and merchantName are required options.

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.

If the promise is rejected, the code property of the returned error object will be one of:

Param Type Description
options DigitalWalletPaymentRequestOptions Options for processing a digital wallet payment. amount is a required option

Returns: Promise<DigitalWalletPaymentMethodResult>


isInitialized()

isInitialized() => Promise<InitializationStatus>

Check if the Olo Pay SDK has been initialized

Returns: Promise<InitializationStatus>


isDigitalWalletInitialized()

isDigitalWalletInitialized() => Promise<InitializationStatus>

Check if digital wallets have been initialized. On iOS, digital wallets are initialized when the SDK is initialized, so this method will behave the same as isInitialized(). On Android, a separate call to initializeGooglePay() is required to initialize digital wallets.

Returns: Promise<InitializationStatus>


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>


Type Aliases

AndroidInitializationOptions

Options for initializing the Android Olo Pay SDK. This is a type alias for code readability.

OloPayInitializationConfig

OloPayInitializationConfig

Options for initializing the Olo Pay SDK

Property Description Default
productionEnvironment true to use the production environment, false for the test environment. true

{ productionEnvironment?: boolean; }

iOSInitializationOptions

Options for initializing the iOS Olo Pay SDK. This is a type alias for code readability

OloPayInitializationConfig & ApplePayInitializationConfig

ApplePayInitializationConfig

Options for initializing Apple Pay

Property Description
applePayMerchantId The merchant id registered with Apple for Apple Pay
applePayCompanyLabel The company name that will be displayed on the Apple Pay payment sheet

{ applePayMerchantId: string; applePayCompanyLabel: string; }

InternalInitOptions

Used internally by the Olo Pay SDK Plugin

{ version: string; buildType: string; }

GooglePayInitializationOptions

Options for intializing Google Pay

Property Description Default
googlePayProductionEnvironment true to use the production environment, false for the test environment true
countryCode A two character country code for the vendor that will be processing the payment -
merchantName The merchant/vendor display name -
fullAddressFormat Determines what address fields are required to complete a Google Pay transaction. true includes name, street address, locality, region, country code, and postal code. false only includes name, country code, and postal code false
existingPaymentMethodRequired Whether an existing saved payment method is required for Google Pay to be considered ready true
emailRequired Whether Google Pay collects an email when processing payments false
phoenNumberRequired Whether Google Pay collects a phone number when processing payments false

{ googlePayProductionEnvironment?: boolean; countryCode: string; merchantName: string; fullAddressFormat?: boolean; existingPaymentMethodRequired?: boolean; emailRequired?: boolean; phoneNumberRequired?: boolean; }

ChangeGooglePayVendorOptions

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

Property Description
countryCode A two character country code for the vendor that will be processing the payment
merchantName The merchant/vendor display name

{ countryCode: string; merchantName: string; }

DigitalWalletPaymentMethodResult

Type alias representing a digital wallet payment method result. The object will either contain payment method data or error data.

{ paymentMethod: PaymentMethod; error?: undefined; } | { paymentMethod?: undefined; error: DigitalWalletError; }

PaymentMethod

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

Property Description
id The payment method id. This should be set to the token field when submitting a basket
last4 The last four digits of the card
cardType The issuer of the card
expMonth Two-digit number representing the card's expiration month
expYear Four-digit number representing the card's expiration year
postalCode Zip or postal code
countryCode Two character country code
isDigitalWallet true if this payment method was created by digital wallets (e.g. Apple Pay or Google Pay), false otherwise
productionEnvironment Whether or not this payment method was created in the production environment

{ id?: string; last4?: string; cardType?: string; expMonth?: number; expYear?: number; postalCode?: string; countryCode?: string; isDigitalWallet: boolean; productionEnvironment: boolean; }

DigitalWalletError

Type representing a digital wallet error

Property Description
errorMessage Error message indicating what went wrong
digitalWalletType Enum value indicating Apple Pay or Google Pay. If this is a Google Pay error, there are additional properties indicating the type of error that occurred. See GooglePayError

{ errorMessage: string; digitalWalletType: DigitalWalletType; } & (GooglePayError | null)

GooglePayError

Type representing specific error types that can occur while processing a Google Pay transaction

Property Description
googlePayErrorType The type of error that occurred. See GooglePayErrorType

{ googlePayErrorType: GooglePayErrorType; }

DigitalWalletPaymentRequestOptions

Type alias representing options for a digital wallet payment method request

GooglePayPaymentRequestOptions | ApplePayPaymentRequestOptions

GooglePayPaymentRequestOptions

Options for requesting a payment method via Google Pay

Property Description Default
amount The amount to be charged -
currencyCode A three character currency code for the transaction 'USD'
currencyMulitplier Multiplier to convert the amount to the currency's smallest currency unit (e.g. $2.34 * 100 = 234 cents) 100

IMPORTANT: The amount charged will be equivalent to amount * currencyCode so ensure these are set properly

{ amount: number; currencyCode?: string; currencyMultiplier?: number; }

ApplePayPaymentRequestOptions

Options for requesting a payment method via Apple Pay

Property Description Default
amount The amount to be charged -
currencyCode A three character currency code for the transaction 'USD'
countryCode A two character country code 'US'

{ amount: number; countryCode?: string; currencyCode?: string; }

InitializationStatus

Represents the initialization status of digital wallets

Property Description
isInitialized true if the SDK has been initialized, false otherwise

{ isInitialized: boolean; }

DigitalWalletStatus

Represents the status of digital wallets

Property Description
isReady true if digital wallets are ready to be used, false otherwise

{ isReady: boolean; }

Enums

DigitalWalletType

Members Value
applePay "applePay"
googlePay "googlePay"

GooglePayErrorType

Members Value Description
networkError "NetworkError" Google Pay didn't succeed due to a network error
developerError "DeveloperError" Google Pay didn't succeed due to developer error
internalError "InternalError" Google Pay didn't succeed due to an internal error

Readme

Keywords

Package Sidebar

Install

npm i @dineengine/capacitor-olo-pay

Weekly Downloads

9

Version

3.1.2

License

MIT

Unpacked Size

129 kB

Total Files

36

Last publish

Collaborators

  • dedeveloper
  • nnorris