import type { Plugin } from '@capacitor/core'; export interface OloPaySDKPlugin extends Plugin { /** * Initialize the Olo Pay SDK and, optionally, configure and initialize digital wallets. The SDK must be initialized prior to calling other methods. Calling this method will attempt to initialize the Olo Pay SDK and the digital wallet. * If a [DigitalWalletConfiguration](#digitalwalletconfiguration) is provided and either `initializeApplePay` or `initializeGooglePay` are `true`, when digital wallets become ready, a [DigitalWalletReadyEvent](#digitalwalletreadyevent) will be emitted. If digital wallets are not configured * and initialized here, this can be done later by calling [updateDigitalWalletConfiguration](#updatedigitalwalletconfiguration). * * **Important:** As long as [`options.productionEnvironment`](#sdkinitializationoptions) is of type `boolean`, the Olo Pay SDK is guaranteed to be initialized. The majority of promise rejections will likely occur due to an error while initializing digital wallets, which happens after successful SDK initialization. * * If the promise is rejected, the `code` property of the returned error object will be one of: * - [PromiseRejectionCode.missingParameter](#promiserejectioncode) * - [PromiseRejectionCode.invalidParameter](#promiserejectioncode) * - [PromiseRejectionCode.googlePayInvalidSetup](#promiserejectioncode) **_(Android only)_** * * @param options Options for initializing the Olo Pay SDK. See [SdkInitializationOptions](#sdkinitializationoptions) for more details. */ initialize(options: SdkInitializationOptions): Promise; /** * Used internally by the Olo Pay SDK Plugin. Calling this method manually * will result in a no-op */ initializeInternal(options: InternalInitOptions): Promise; /** * Update the configuration settings for digital wallets. * * This can be used to change configuration parameters for digital wallets. Calling this method will * immediately invalidate digital wallet readiness and will cause a [DigitalWalletReadyEvent](#digitalwalletreadyevent) * to be emitted with a value of `false`. Once the new configuration is ready to be used, * the [DigitalWalletReadyEvent](#digitalwalletreadyevent) will be triggered again with a value of `true`. * * **Note:** This method can also be used to initialize digital wallets if they were not initialized as part of SDK initialization (see [initialize](#initialize)). * * If the promise is rejected, the `code` property of the returned error object will be one of: * - [PromiseRejectionCode.missingParameter](#promiserejectioncode) * - [PromiseRejectionCode.invalidParameter](#promiserejectioncode) * - [PromiseRejectionCode.googlePayInvalidSetup](#promiserejectioncode) **_(Android only)_** * - [PromiseRejectionCode.sdkUninitialized](#promiserejectioncode) * - [PromiseRejectionCode.unexpectedError](#promiserejectioncode) **_(Android only)_** * * @param options Options for new configuration settings for digital wallets. See [DigitalWalletConfiguration](#digitalwalletconfiguration) for more details. */ updateDigitalWalletConfiguration(options: { digitalWalletConfig: DigitalWalletConfiguration; }): Promise; /** * 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: * - [PromiseRejectionCode.sdkUninitialized](#promiserejectioncode) * - [PromiseRejectionCode.digitalWalletUninitialized](#promiserejectioncode) * - [PromiseRejectionCode.digitalWalletNotReady](#promiserejectioncode) * - [PromiseRejectionCode.invalidParameter](#promiserejectioncode) * - [PromiseRejectionCode.missingParameter](#promiserejectioncode) * - [PromiseRejectionCode.invalidCompanyLabel](#promiserejectioncode) * - [PromiseRejectionCode.invalidCountyCode](#promiserejectioncode) * - [PromiseRejectionCode.lineItemsTotalMismatchError](#promiserejectioncode) * - [PromiseRejectionCode.emptyMerchantId](#promiserejectioncode) **_(iOS only)_** * - [PromiseRejectionCode.applePayUnsupported](#promiserejectioncode) **_(iOS only)_** * - [PromiseRejectionCode.applePayError](#promiserejectioncode) **_(iOS only)_** * - [PromiseRejectionCode.applePayTimeoutError](#promiserejectioncode) **_(iOS only)_** * - [PromiseRejectionCode.googlePayNetworkError](#promiserejectioncode) **_(Android only)_** * - [PromiseRejectionCode.googlePayDeveloperError](#promiserejectioncode) **_(Android only)_** * - [PromiseRejectionCode.googlePayInternalError](#promiserejectioncode) **_(Android only)_** * - [PromiseRejectionCode.unexpectedError](#promiserejectioncode) **_(Android only)_** * - [PromiseRejectionCode.generalError](#promiserejectioncode) * * ```typescript * try { * const { paymentMethod } = await createDigitalWalletPaymentMethod({ amount: 5.00 }); * if (!paymentMethod) { * // User canceled the digital wallet flow * } else { * // Send paymentMethod to Olo's Ordering API * } * } catch (error) { * // Handle error * } * ``` * * @param options Options for processing a digital wallet payment. _`amount` is a required option_ */ createDigitalWalletPaymentMethod(options: DigitalWalletPaymentRequestOptions): Promise; /** * Check if the Olo Pay SDK has been initialized */ isInitialized(): Promise; /** * 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. */ isDigitalWalletInitialized(): Promise; /** * 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. */ isDigitalWalletReady(): Promise; } /** * Used internally by the Olo Pay SDK Plugin */ export declare type InternalInitOptions = { version: string; buildType: string; }; /** * Options for requesting a digital wallet payment method via Google Pay or Apple Pay * | Property | Description | Default | * | -------- | ----------- | ------- | * | `amount` | The amount to be charged | - | * | `checkoutStatus` | The checkout status to be used for the transaction **_(Android only)_** | `FinalImmediatePurchase` | * | `totalPriceLabel` | A custom value to override the default total price label in the Google Pay sheet **_(Android only)_** | - | * | `lineItems` | A list of line items to be displayed in the digital wallet payment sheet | - | * | `validateLineItems` | Whether or not to validate the line items. If `true`, [createDigitalWalletPaymentMethod](#createdigitalwalletpaymentmethod) will throw an exception if the sum of the line items does not equal the total amount passed in. If no line items are provided, this parameter is ignored. | `true` | */ export declare type DigitalWalletPaymentRequestOptions = { amount: number; checkoutStatus?: GooglePayCheckoutStatus; totalPriceLabel?: string; lineItems?: LineItem[]; validateLineItems?: boolean; }; /** * Type alias representing a digital wallet payment method result. * | Property | Description | * | -------- | ----------- | * | `paymentMethod` | The payment method generated by the digital wallet flow. If the user canceles the flow, the value will be `null` on Android and `undefined` on iOS | */ export declare type DigitalWalletPaymentMethodResult = { paymentMethod: undefined | PaymentMethod | null; }; /** * Options for intializing digital wallets * | Property | Description | Default | * | -------- | ----------- | ------- | * | `countryCode` | A two character country code for the vendor that will be processing the payment | 'US' | * | `currencyCode` | A three character currency code for the transaction | 'USD' | * | `companyLabel` | The company display name | - | * | `emailRequired` | Whether an email will be collected and returned when processing transactions | `false` | * | `fullNameRequired` | Whether a full name will be collected and returned when processing transactions | `false` | * | `fullBillingAddressRequired` | Whether a full billing address will be collected and returned when processing transactions | `false` | * | `phoneNumberRequired` | Whether a phone number will be collected and returned when processing transactions | `false` | * | `initializeApplePay` | Whether Apple Pay should be initialized. | false | * | `initializeGooglePay` | Whether Google Pay should be initialized. | false | * | `applePayConfig` | Configuration options for initializing Apple Pay. Required if `initializeApplePay` is `true` | - | * | `googlePayConfig` | Configuration options for initializing Google Pay. Required if `initializeGooglePay` is `true` | - | * * **Note:** If Apple Pay or Google Pay were previously initialized and the respective initialize property (`initializeApplePay` or `initializeGooglePay`) is set to `false`, this will not uninitialize digital wallets and will result in a no-op. * */ export declare type DigitalWalletConfiguration = { companyLabel: string; countryCode?: string; currencyCode?: CurrencyCode; emailRequired?: boolean; phoneNumberRequired?: boolean; fullNameRequired?: boolean; fullBillingAddressRequired?: boolean; initializeApplePay?: boolean; initializeGooglePay?: boolean; applePayConfig?: ApplePayInitializationConfig; googlePayConfig?: GooglePayInitializationConfig; }; /** * Options for initializing the Olo Pay SDK and digital wallets. * | Property | Description | * | -------- | ----------- | * | `productionEnvironment` | Whether the SDK should be initialized in production mode. | `true` | * | `digitalWalletConfig` | Configuration options for initializing digital wallets. | - | */ export declare type SdkInitializationOptions = { productionEnvironment?: boolean; digitalWalletConfig?: DigitalWalletConfiguration; }; /** * Options for initializing Apple Pay * | Property | Description | Default | * | -------- | ----------- | ------- | * | `fullPhoneticNameRequired` | Whether a full phonetic name will be collected and returned when processing transactions. | `false` | * | `merchantId` | The merchant id registered with Apple for Apple Pay | - | */ declare type ApplePayInitializationConfig = { fullPhoneticNameRequired?: boolean; merchantId: string; }; /** * Options for intializing Google Pay * | Property | Description | Default | * | -------- | ----------- | ------- | * | `productionEnvironment` | Whether Google Pay will use the production environment | `true` | * | `existingPaymentMethodRequired` | Whether an existing saved payment method is required for Google Pay to be considered ready | `false` | * | `currencyMultiplier` | Multiplier to convert the amount to the currency's smallest unit (e.g. $2.34 * 100 = 234 cents) | `100` | */ export declare type GooglePayInitializationConfig = { productionEnvironment?: boolean; existingPaymentMethodRequired?: boolean; currencyMultiplier?: number; }; /** * Type alias representing a three character currency code. */ export declare type CurrencyCode = 'USD' | 'CAD'; export declare enum GooglePayCheckoutStatus { /** Represents an estimated price (meaning it's not final and could change) and the default checkout option. The confirmation button will display "Pay". */ estimatedDefault = "EstimatedDefault", /** Represents the final price of the transaction and the default checkout option. The confirmation button will display "Pay". */ finalDefault = "FinalDefault", /** Represents the final price of the transaction and the immediate checkout option. The confirmation button will display "Pay now". */ finalImmediatePurchase = "FinalImmediatePurchase" } /** * Represents the status of digital wallets * | Property | Description | * | -------- | ----------- | * | `isReady` | `true` if digital wallets are ready to be used, `false` otherwise | */ export declare type DigitalWalletStatus = { isReady: boolean; }; /** * Represents the initialization status of digital wallets * | Property | Description | * | -------- | ----------- | * | `isInitialized` | `true` if the SDK has been initialized, `false` otherwise | */ export declare type InitializationStatus = { isInitialized: boolean; }; /** * 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. Will always have the same value as `billingAddress.postalCode` | * | `countryCode` | Two character country code. Will always have the same value as `billingAddress.countryCode` | * | `isDigitalWallet` | `true` if this payment method was created by digital wallets (e.g. Apple Pay or Google Pay), `false` otherwise | * | `productionEnvironment` | `true` if this payment method was created in the production environment, `false` otherwise | * | `email` | The email address associated with the transaction, or an empty string if unavailable. Will only be provided for digital payment methods (see `isDigitalWallet`) with `DigitalWalletConfig.emailRequired` set to `true`. | * | `digitalWalletCardDescription` | The description of the card, as provided by Apple or Google. Only provided for digital wallet payment methods (see `isDigitalWallet`). For other payment methods, this property will be an empty string. | * | `billingAddress` | The billing address associated with the transaction. The country code and postal code fields will always have a non-empty value. Other fields will only be set for digital wallet payment methods (see `isDigitalWallet`) with `DigitalWalletConfig.fullBillingAddressRequired` set to `true` | * | `fullName` | The full name associated with the transaction. Will only be provided for digital wallet payment methods (see `isDigitalWallet`) with `DigitalWalletConfig.fullNameRequired` set to `true`. | * | `fullPhoneticName` | The full phonetic name associated with the transaction. Will only be provided for digital wallet payment methods (see `isDigitalWallet`) with `DigitalWalletConfig.applePayConfig.fullPhoneticNameRequired` set to `true`. **_(iOS Only)_** | * | `phoneNumber` | The phone number associated with the transaction. WIll only be provided for digital wallet payment methods (see `isDigitalWallet`) with `DigitalWalletConfig.phoneNumberRequired` set to `true`. | */ export declare type PaymentMethod = { id: string; last4: string; cardType: CardType; expMonth: number; expYear: number; postalCode: string; countryCode: string; isDigitalWallet: boolean; productionEnvironment: boolean; email: string; digitalWalletCardDescription: string; billingAddress: Address; fullName: string; fullPhoneticName: string; phoneNumber: string; }; /** * Represents a line item in a digital wallet transaction * * | Property | Description | * | -------- | ----------- | * | `label` | The label of the line item | * | `amount` | The amount of the line item | * | `type` | Enum representing the type of a line item in a digital wallet transaction | * | `status` | Enum representing the status of a line item. If not provided, default value is `LineItemStatus.final` | */ export declare type LineItem = { label: string; amount: number; type: LineItemType; status?: LineItemStatus; }; export declare enum LineItemType { /** Represents a subtotal line item in a digital wallet transaction */ subtotal = "Subtotal", /** Represents a line item in a digital wallet transaction */ lineItem = "LineItem", /** Represents a tax line item in a digital wallet transaction */ tax = "Tax" } export declare enum LineItemStatus { /** Indicates that the price is final and has no variance */ final = "Final", /** Indicates that the price is pending and may change. On iOS this will cause the amount to appear as an elipsis ("...") */ pending = "Pending" } /** * Represents an address. Currently only used for digital wallets if billing address details are requested to be returned in the * generated digital wallet payment method. * * | Property | Description | * | -------- | ----------- | * | `address1` | The first line of the address | * | `address2` | The second line of the address, or an empty string | * | `address3` | The third line of the address, or an empty string | * | `locality` | The city, town, neighborhood, or suburb | * | `postalCode` | The postal or zip code | * | `countryCode` | The two digit ISO country code | * | `administrativeArea` | A country subdivision, such as a state or province | */ export declare type Address = { address1: string; address2: string; address3: string; locality: string; postalCode: string; countryCode: string; administrativeArea: string; }; export declare enum CardType { /** Visa credit card type. Pass the string value of this into the Olo Ordering API when submitting orders */ visa = "Visa", /** American Express credit card type. Pass the string value of this into the Olo Ordering API when submitting orders */ amex = "Amex", /** Mastercard credit card type. Pass the string value of this into the Olo Ordering API when submitting orders */ mastercard = "Mastercard", /** Discover credit card type. Pass the string value of this into the Olo Ordering API when submitting orders */ discover = "Discover", /** Unsupported credit card type. Passing this to the Olo Ordering API will result in an error */ unsupported = "Unsupported", /** Unknown credit card type. Passing this to the Olo Ordering API will result in an error */ unknown = "Unknown" } /** Specific kinds of Google Pay Errors */ export declare enum GooglePayErrorType { /** Google Pay didn't succeed due to a network error */ networkError = "NetworkError", /** Google Pay didn't succeed due to developer error */ developerError = "DeveloperError", /** Google Pay didn't succeed due to an internal error */ internalError = "InternalError" } export declare enum PromiseRejectionCode { invalidParameter = "InvalidParameter", missingParameter = "MissingParameter", applePayUnsupported = "ApplePayUnsupported", sdkUninitialized = "SdkUninitialized", applePayError = "ApplePayError", applePayTimeoutError = "ApplePayTimeoutError", googlePayNetworkError = "GooglePayNetworkError", googlePayDeveloperError = "GooglePayDeveloperError", googlePayInternalError = "GooglePayInternalError", googlePayInvalidSetup = "GooglePayInvalidSetup", digitalWalletUninitialized = "DigitalWalletUninitialized", digitalWalletNotReady = "DigitalWalletNotReady", emptyCompanyLabel = "EmptyCompanyLabel", emptyMerchantId = "EmptyMerchantId", invalidCountryCode = "InvalidCountryCode", lineItemsTotalMismatch = "LineItemsTotalMismatch", unexpectedError = "UnexpectedError", uninmplemented = "UNIMPLEMENTED", generalError = "generalError" } export declare type PromiseRejection = { code: string; message: string; }; export declare const DigitalWalletReadyEvent = "digitalWalletReadyEvent"; export {};