UNPKG

@paydock/client-sdk

Version:

Paydock client sdk

299 lines 17.9 kB
export { ApplePayOpenWalletButton } from './apple-pay-open-wallet-button'; export { OpenWalletButtons } from './base/open-wallet-buttons'; export { ERROR_OPERATION } from './enum/error-operation.enum'; export { EVENT, type OpenWalletEventType } from './enum/event.enum'; export { TOKEN_TYPE } from './enum/token-type.enum'; export { GooglePayOpenWalletButton } from './google-pay-open-wallet-button'; export type * from './interfaces'; export type * from './types'; export { WALLET_TYPES } from './types/wallet-type.type'; /** * Interface for Apple Pay-specific metadata. * * For further information about ApplePay Capabilities refer to [the documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/4440085-applepaycapabilities). * Apple will determine if the device has an ApplePay wallet available and at least one active payment. * * @interface ApplePayOpenWalletMeta * * @type {object} * @param {number} amount - The payment amount. * @param {string} currency - The ISO 4217 currency code. * @param {string} country - The ISO 3166-1 alpha-2 country code. * @param {string} amount_label - Label shown next to the total amount (e.g. `'TOTAL'`). Used in the Apple Pay payment sheet. * @param {boolean} [request_shipping] - Enable shipping address collection in the Apple Pay sheet. * @param {IApplePayShippingOption[]} [shipping_options] - Array of available shipping options. The first item is used as the default selected option. Requires `request_shipping` to be `true`. * @param {boolean} [show_billing_address] - Show billing address fields in the Apple Pay sheet. * @param {string} store_name - The merchant's store name displayed during payment. * @param {Array<'credentials_available' | 'credentials_status_unknown' | 'credentials_unavailable'>} [apple_pay_capabilities] - Device capabilities needed for the wallet button to be available. * @param {Array<'supports3DS' | 'supportsEMV' | 'supportsCredit' | 'supportsDebit'>} [merchant_capabilities] - Array of merchant capabilities influencing the transaction processing features available. * @param {Array<'visa' | 'masterCard' | 'amex' | 'chinaUnionPay' | 'discover' | 'interac' | 'jcb' | 'privateLabel'>} [supported_networks] - List of payment networks supported for Apple Pay transactions. * @param {Array<'email' | 'name' | 'phone' | 'postalAddress'>} [required_billing_contact_fields] - Contact fields required from the user for billing purposes. Phone and email are currently not returned by Apple. * @param {Array<'email' | 'phone' | 'postalAddress' | 'name'>} [required_shipping_contact_fields] - Shipping contact fields required to complete the transaction. Include `'postalAddress'` to show address fields in the Apple Pay sheet. Required handling of onShippingAddressChange callback. * @param {string[]} [supported_countries] - List of countries where Apple Pay is supported by the merchant. * @param {'available' | 'store_pickup'} [shipping_editing_mode] - `'available'` for editable shipping, `'store_pickup'` for non-editable. * @param {object} [style] - Styling configuration for the Apple Pay button. * @param {ApplePayButtonType} [style.button_type] - The type of Apple Pay button (e.g. `'buy'`, `'donate'`, `'plain'`). * @param {ApplePayButtonStyle} [style.button_style] - The style of the Apple Pay button (`'black'`, `'white'`, `'white-outline'`). **/ /** * Interface for Google Pay-specific metadata. * * @interface GooglePayOpenWalletMeta * * @type {object} * @param {number} amount - The payment amount. * @param {string} currency - The ISO 4217 currency code. * @param {string} country - The ISO 3166-1 alpha-2 country code. * @param {string} [amount_label] - Label shown next to the total amount. * @param {string} [merchant_name] - Display name for the merchant in the Google Pay sheet. * @param {boolean} [request_shipping] - Enable shipping address collection. * @param {IGooglePayShippingOption[]} [shipping_options] - Array of available shipping options. The first item is used as the default selected option. Requires `request_shipping` to be `true`. * @param {boolean} [show_billing_address] - Show billing address fields. * @param {object} [card_config] - Google Pay card configuration for custom auth methods, card networks, and tokenization. * @param {object} [style] - Styling configuration for the Google Pay button. * @param {GooglePayButtonType} [style.button_type] - The type of Google Pay button (`'book'`, `'buy'`, `'checkout'`, `'donate'`, `'order'`, `'pay'`, `'plain'`, `'subscribe'`). * @param {GooglePayButtonColor} [style.button_color] - The color of the Google Pay button (`'default'`, `'black'`, `'white'`). * @param {GooglePayButtonSizeMode} [style.button_size_mode] - The size mode (`'static'`, `'fill'`). **/ /** * Interface for OnClickEventData. * Emitted when the wallet button is clicked. * * The merchant's `onClick` handler controls the payment flow via its return value: * - Return `void` / `undefined` to continue normally. * - Return `false` to abort the payment flow. * - Return a `Promise<void>` to defer the wallet sheet until the promise resolves. * - Return a `Promise<boolean>` — if it resolves to `false`, the flow is aborted. * - Throwing an error (sync or async) also aborts the flow. * * @interface OnClickEventData * * @type {object} * @param {string} event - Always `'onClick'`. **/ /** * Interface for OnCreateOTTSuccessfulEventData. * Emitted when the One-Time Token is successfully created. * @interface OnCreateOTTSuccessfulEventData * * @type {object} * @param {string} event - Always `'success'`. * @param {object} [data] - OTT success payload. * @param {object} data.token - The created OTT response. * @param {string} data.token.temp_token - The temporary one-time token string. * @param {TOKEN_TYPE} data.token.token_type - The type of the token. `TOKEN_TYPE.CARD` for FPAN (Google Pay only), `TOKEN_TYPE.CARD_SCHEME_TOKEN` for DPAN (Apple Pay & Google Pay). * @param {number} data.amount - The payment amount. * @param {object} [data.shipping] - The shipping address and contact information, if provided. * @param {string} [data.shipping.method] - The shipping method. * @param {Array<IApplePayShippingOption | IGooglePayShippingOption>} [data.shipping.options] - The selected shipping options. * @param {string} [data.shipping.address_line1] - Shipping address line 1. * @param {string} [data.shipping.address_line2] - Shipping address line 2. * @param {string} [data.shipping.address_city] - Shipping address city. * @param {string} [data.shipping.address_postcode] - Shipping address postal code. * @param {string} [data.shipping.address_state] - Shipping address state or province. * @param {string} [data.shipping.address_country] - Shipping address country code. * @param {string} [data.shipping.address_company] - Shipping company name. * @param {string} [data.shipping.address_origin_postcode] - Origin postal code. * @param {object} [data.shipping.contact] - Shipping contact information. * @param {string} [data.shipping.contact.first_name] - Contact first name. * @param {string} [data.shipping.contact.last_name] - Contact last name. * @param {string} [data.shipping.contact.email] - Contact email address. * @param {string} [data.shipping.contact.phone] - Contact phone number. * @param {string} [data.shipping.contact.phone2] - Contact secondary phone number. * @param {object} [data.billing] - The billing address, if provided. * @param {string} data.billing.address_line1 - Billing address line 1. * @param {string} data.billing.address_line2 - Billing address line 2. * @param {string} data.billing.address_country - Billing address country code. * @param {string} data.billing.address_city - Billing address city. * @param {string} data.billing.address_postcode - Billing address postal code. * @param {string} data.billing.address_state - Billing address state or province. **/ /** * Interface for OnCreateOTTErrorEventData. * Emitted when OTT creation fails. The error details are in the `data` payload. * @interface OnCreateOTTErrorEventData * * @type {object} * @param {string} event - Always `'error'`. * @param {object} [data] - Error details payload. * @param {string} [data.message] - Error message. * @param {string} [data.code] - Error code. **/ /** * Interface for OnUnavailableEventData. * Emitted when the wallet is not available on the current device or browser. * @interface OnUnavailableEventData * * @type {object} * @param {string} event - Always `'unavailable'`. * @param {object} [data] - Unavailability details payload. * @param {string} data.reason - A human-readable reason why the wallet is unavailable. * @param {object} [data.details] - Additional details about the unavailability. * @param {string} data.details.service_id - The service ID that was checked. **/ /** * Interface for OnErrorEventData. * Emitted when an error occurs during wallet operation, including configuration issues, service type mismatches, and OTT creation failures. * @interface OnErrorEventData * * @type {object} * @param {string} event - Always `'error'`. * @param {object} [data] - Error payload. * @param {Error} data.error - The Error object describing what went wrong. * @param {object} [data.context] - Context about the error. * @param {ERROR_OPERATION} [data.context.operation] - The operation that failed. See {@link ERROR_OPERATION} enum for possible values. **/ /** * Interface for OnLoadedEventData. * Emitted when the wallet button has been loaded and rendered in the DOM. * No payload — the specific wallet type is determined by the concrete button class * ({@link ApplePayOpenWalletButton} or {@link GooglePayOpenWalletButton}). * @interface OnLoadedEventData * * @type {object} * @param {string} event - Always `'loaded'`. **/ /** * Interface for OnCancelEventData. * Emitted when the wallet checkout is cancelled or closed by the user. No payload data. * @interface OnCancelEventData * * @type {object} * @param {string} event - Always `'checkoutClose'`. **/ /** * Interface for OnShippingAddressChangeEventData. * Emitted when the customer selects or updates their shipping address in the wallet payment sheet. * This event is also emitted when the payment sheet first opens (INITIALIZE) with the initial shipping address, if present in the User's wallet. * * If no handler is registered for this event, the SDK auto-accepts with the current transaction data. * @interface OnShippingAddressChangeEventData * * @type {object} * @param {string} event - Always `'onShippingAddressChange'`. * @param {object} [data] - Shipping address data. * @param {string} [data.address_city] - Shipping address city. * @param {string} [data.address_state] - Shipping address state. * @param {string} [data.address_postcode] - Shipping address postal code. * @param {string} [data.address_country] - Shipping address country code. * @param {string} [data.address_line1] - Apple Pay only - Shipping address line 1. * @param {string} [data.address_line2] - Apple Pay only - Shipping address line 2. * @param {string} [data.contact.phone] - Apple Pay only - Shipping contact phone. * @param {string} [data.contact.email] - Apple Pay only - Shipping contact email. * @param {string} [data.contact.first_name] - Apple Pay only - Shipping contact first name. * @param {string} [data.contact.last_name] - Apple Pay only - Shipping contact last name. **/ /** * Interface for OnShippingAddressChangeEventResponse. * Returned by the merchant's `onShippingAddressChange` handler. * @interface OnShippingAddressChangeEventResponse * * @type {object} * @param {number} [amount] - Updated payment amount based on the new shipping address. * @param {Array<IApplePayShippingOption | IGooglePayShippingOption>} [shipping_options] - Updated list of available shipping options. The first item is used as the default selected option. * @param {object} [error] - Error object to display in the wallet payment sheet if the address is invalid. * @param {string} error.code - Error code. Possible values: `'address_error'`, `'country_error'`, `'state_error'`, `'zip_error'`, `'shipping_contact_invalid'`, `'billing_contact_invalid'`. * @param {string} [error.field] - Apple Pay only - The specific field that caused the error. Possible values: `'phone'`, `'email'`, `'name'`, `'phonetic_name'`, `'address_lines'`, `'locality'`, `'postal_code'`, `'administrative_area'`, `'country'`, `'country_code'`. * @param {string} [error.message] - A human-readable error message to display to the customer. **/ /** * Interface for OnShippingOptionChangeEventData. * Emitted when the customer selects a shipping option in the wallet payment sheet. * * If no handler is registered for this event, the SDK auto-accepts with the current transaction data. * @interface OnShippingOptionChangeEventData * * @type {object} * @param {string} event - Always `'onShippingOptionsChange'`. * @param {object} [data] - Shipping option data. * @param {string} [data.shipping_option_id] - Selected shipping option ID. * @param {string} [data.label] - Selected shipping option label. * @param {string} [data.detail] - Selected shipping option detail. * @param {string} [data.amount] - Apple Pay only - Selected shipping option amount. **/ /** * Interface for OnShippingOptionChangeEventResponse. * Returned by the merchant's `onShippingOptionsChange` handler. * @interface OnShippingOptionChangeEventResponse * * @type {object} * @param {number} [amount] - Updated total payment amount based on the selected shipping option. * @param {object} [error] - Error object to display if the shipping option is invalid. * @param {string} error.code - Error code. Possible values: `'method_unavailable'`, `'store_unavailable'`. * @param {string} [error.message] - A human-readable error message. **/ /** * Interface for IApplePayShippingOption. * Used for shipping options in Apple Pay wallets. * @interface IApplePayShippingOption * * @type {object} * @param {string} id - Unique identifier for the shipping option. * @param {string} label - Display name for the shipping option. * @param {number} amount - Shipping cost amount. * @param {string} [detail] - Optional description or detail text. * @param {object} [date_components_range] - Apple Pay only - Delivery date range estimate. * @param {object} [date_components_range.start_date_components] - Start date for the delivery estimate. * @param {number} [date_components_range.start_date_components.years] - Years from now. * @param {number} [date_components_range.start_date_components.months] - Months from now. * @param {number} [date_components_range.start_date_components.days] - Days from now. * @param {number} [date_components_range.start_date_components.hours] - Hours from now. * @param {object} [date_components_range.end_date_components] - End date for the delivery estimate. * @param {number} [date_components_range.end_date_components.years] - Years from now. * @param {number} [date_components_range.end_date_components.months] - Months from now. * @param {number} [date_components_range.end_date_components.days] - Days from now. * @param {number} [date_components_range.end_date_components.hours] - Hours from now. **/ /** * Interface for IGooglePayShippingOption. * Used for shipping options in Google Pay wallets. * @interface IGooglePayShippingOption * * @type {object} * @param {string} id - Unique identifier for the shipping option. * @param {string} label - Display name for the shipping option. * @param {string} [detail] - Optional description or detail text. * @param {'ELECTRONIC' | 'GROUND' | 'NOT_SHIPPED' | 'OVERNIGHT' | 'PICKUP' | 'PRIORITY' | 'SAME_DAY'} [type] - The shipping type. **/ /** * List of available event names in the Open Wallet button lifecycle. * @const EVENT * * @type {object} * @param {string} ON_CLICK=onClick - Emitted when the wallet button is clicked. * @param {string} SUCCESS=success - Emitted when OTT creation succeeds. * @param {string} UNAVAILABLE=unavailable - Emitted when the wallet is not available. * @param {string} ERROR=error - Emitted when an error occurs. * @param {string} LOADED=loaded - Emitted when the button is rendered. * @param {string} CHECKOUT_CLOSE=checkoutClose - Emitted when the wallet checkout is cancelled. * @param {string} ON_SHIPPING_ADDRESS_CHANGE=onShippingAddressChange - Emitted when shipping address changes. * @param {string} ON_SHIPPING_OPTIONS_CHANGE=onShippingOptionsChange - Emitted when shipping option changes. */ /** * Enum of available wallet types. * @const WALLET_TYPES * * @type {object} * @param {string} APPLE_PAY=apple - Apple Pay wallet. * @param {string} GOOGLE_PAY=google - Google Pay wallet. */ /** * Token types returned in the OTT (One-Time Token) creation response. * @const TOKEN_TYPE * * @type {object} * @param {string} CARD=card - FPAN (Funding Primary Account Number). Available for Google Pay only. * @param {string} CARD_SCHEME_TOKEN=card_scheme_token - DPAN (Device Primary Account Number). Available for both Apple Pay and Google Pay. */ /** * Operations that can fail during the wallet lifecycle. * Used in the `context.operation` field of {@link OnErrorEventData}. * @const ERROR_OPERATION * * @type {object} * @param {string} WALLET_OPERATION=wallet_operation - General wallet lifecycle operation (default). * @param {string} CONFIGURATION=configuration - Loading or validating the wallet service configuration (e.g. network fetch failure, card config validation). * @param {string} HANDLER_REGISTRATION=handler_registration - A required event handler was not registered before calling load(). * @param {string} SHIPPING_UPDATE=shipping_update - Processing a shipping address or shipping option update failed. */ //# sourceMappingURL=index.d.ts.map