UNPKG

@paydock/client-sdk

Version:

Paydock client sdk

70 lines 2.97 kB
import { type GetConfigResponse } from '../api/api-service-internal'; import type { OpenWalletService } from './base/open-wallet.service'; import { OpenWalletButtons } from './base/open-wallet-buttons'; import type { ApplePayOpenWalletMeta } from './services/apple-pay'; import type { WalletType } from './types'; /** * @classdesc Apple Pay wallet button that creates One-Time Tokens (OTT) via Apple Pay. * * Provides a fully typed Apple Pay integration with Apple Pay-specific metadata * and validates that the service configuration corresponds to an Apple Pay service. * On `load()`, the button fetches the service configuration and raises an error via `onError` * if the service type does not match Apple Pay. * * @class ApplePayOpenWalletButton * @extends OpenWalletButtons * * @param {string} selector - CSS selector of the HTML element that will contain the Apple Pay button. * @param {string} publicKeyOrAccessToken - Public key or access token for API authentication. * @param {string} serviceId - The Apple Pay service ID configured in PayDock dashboard. * @param {ApplePayOpenWalletMeta} meta - Apple Pay-specific metadata (amount, currency, country, amount_label, store_name, style, apple_pay_capabilities, etc.). * * @example * const button = new ApplePayOpenWalletButton( * '#wallet-container', * publicKeyOrAccessToken, * serviceId, * { * amount: 100, * currency: 'AUD', * country: 'AU', * amount_label: 'TOTAL', * store_name: 'My Store', * apple_pay_capabilities: ['credentials_available'], * }, * ); * button.setEnv('sandbox'); * button.onSuccess((data) => console.log('OTT:', data.token)); * button.onError((error) => console.error('Error:', error)); * button.load(); */ export declare class ApplePayOpenWalletButton extends OpenWalletButtons<ApplePayOpenWalletMeta> { /** @private */ readonly walletType: WalletType; /** * Validates Apple Pay-specific required metadata fields. * Apple Pay requires `amount_label` and `store_name` to be present and strings. * * @private * @throws {Error} If `amount_label` is missing or not a string. * @throws {Error} If `store_name` is missing or not a string. */ protected validateWalletMeta(): void; /** * Validates that the service configuration type is Apple Pay. * * @private * @param serviceConfig - The service configuration response from the API. * @throws {Error} If the service type is not Apple Pay. */ protected validateServiceType(serviceConfig: GetConfigResponse): void; /** * Creates an Apple Pay wallet service instance. * * @private * @param serviceConfig - The service configuration response from the API. * @returns The Apple Pay wallet service instance. */ protected createWalletService(serviceConfig: GetConfigResponse): OpenWalletService; } //# sourceMappingURL=apple-pay-open-wallet-button.d.ts.map