@paydock/client-sdk 1.139.0-beta → 1.140.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +2573 -0
  2. package/bundles/index.cjs +1296 -508
  3. package/bundles/index.cjs.d.ts +1377 -200
  4. package/bundles/index.mjs +1295 -509
  5. package/bundles/index.mjs.d.ts +1377 -200
  6. package/bundles/types/checkout/checkout.d.ts.map +1 -1
  7. package/bundles/types/checkout/v1/instructions/instruction.card_form.show.d.ts.map +1 -1
  8. package/bundles/types/checkout/v3/instructions/instruction.card_form.show.d.ts.map +1 -1
  9. package/bundles/types/checkout/v3/instructions/instruction.payment_methods.show.d.ts.map +1 -1
  10. package/bundles/types/checkout-button/zipmoney/zipmoney-contextual.runner.d.ts +1 -2
  11. package/bundles/types/checkout-button/zipmoney/zipmoney-contextual.runner.d.ts.map +1 -1
  12. package/bundles/types/open-wallets/apple-pay-open-wallet-button.d.ts +70 -0
  13. package/bundles/types/open-wallets/apple-pay-open-wallet-button.d.ts.map +1 -0
  14. package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts +242 -74
  15. package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts.map +1 -1
  16. package/bundles/types/open-wallets/base/open-wallet.service.d.ts +62 -4
  17. package/bundles/types/open-wallets/base/open-wallet.service.d.ts.map +1 -1
  18. package/bundles/types/open-wallets/enum/error-operation.enum.d.ts +15 -0
  19. package/bundles/types/open-wallets/enum/error-operation.enum.d.ts.map +1 -0
  20. package/bundles/types/open-wallets/enum/event.enum.d.ts +11 -3
  21. package/bundles/types/open-wallets/enum/event.enum.d.ts.map +1 -1
  22. package/bundles/types/open-wallets/enum/token-type.enum.d.ts +10 -0
  23. package/bundles/types/open-wallets/enum/token-type.enum.d.ts.map +1 -0
  24. package/bundles/types/open-wallets/google-pay-open-wallet-button.d.ts +65 -0
  25. package/bundles/types/open-wallets/google-pay-open-wallet-button.d.ts.map +1 -0
  26. package/bundles/types/open-wallets/index.d.ts +293 -0
  27. package/bundles/types/open-wallets/index.d.ts.map +1 -1
  28. package/bundles/types/open-wallets/interfaces/events.interface.d.ts +87 -14
  29. package/bundles/types/open-wallets/interfaces/events.interface.d.ts.map +1 -1
  30. package/bundles/types/open-wallets/interfaces/google-pay/google-pay-meta.interface.d.ts +6 -0
  31. package/bundles/types/open-wallets/interfaces/google-pay/google-pay-meta.interface.d.ts.map +1 -1
  32. package/bundles/types/open-wallets/interfaces/index.d.ts +2 -2
  33. package/bundles/types/open-wallets/interfaces/index.d.ts.map +1 -1
  34. package/bundles/types/open-wallets/interfaces/open-wallet-meta.interface.d.ts +12 -0
  35. package/bundles/types/open-wallets/interfaces/open-wallet-meta.interface.d.ts.map +1 -1
  36. package/bundles/types/open-wallets/interfaces/payment-source.interface.d.ts +28 -2
  37. package/bundles/types/open-wallets/interfaces/payment-source.interface.d.ts.map +1 -1
  38. package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts +27 -2
  39. package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts.map +1 -1
  40. package/bundles/types/open-wallets/services/google-pay/constants/google-pay.constants.d.ts +9 -0
  41. package/bundles/types/open-wallets/services/google-pay/constants/google-pay.constants.d.ts.map +1 -1
  42. package/bundles/types/open-wallets/services/google-pay/google-pay.open-wallet.service.d.ts +20 -9
  43. package/bundles/types/open-wallets/services/google-pay/google-pay.open-wallet.service.d.ts.map +1 -1
  44. package/bundles/types/open-wallets/services/google-pay/utils/google-pay.utils.d.ts +45 -0
  45. package/bundles/types/open-wallets/services/google-pay/utils/google-pay.utils.d.ts.map +1 -1
  46. package/bundles/types/open-wallets/services/google-pay/utils/index.d.ts +1 -1
  47. package/bundles/types/open-wallets/services/google-pay/utils/index.d.ts.map +1 -1
  48. package/bundles/types/open-wallets/services/google-pay/validation/google-pay.validation.d.ts +13 -0
  49. package/bundles/types/open-wallets/services/google-pay/validation/google-pay.validation.d.ts.map +1 -1
  50. package/bundles/types/open-wallets/types/base-event-data.interface.d.ts +24 -2
  51. package/bundles/types/open-wallets/types/base-event-data.interface.d.ts.map +1 -1
  52. package/bundles/types/open-wallets/types/index.d.ts +2 -1
  53. package/bundles/types/open-wallets/types/index.d.ts.map +1 -1
  54. package/bundles/types/open-wallets/types/on-shipping-address-change-event-data.interface.d.ts +16 -2
  55. package/bundles/types/open-wallets/types/on-shipping-address-change-event-data.interface.d.ts.map +1 -1
  56. package/bundles/types/open-wallets/types/on-shipping-address-change-event-response.interface.d.ts +20 -2
  57. package/bundles/types/open-wallets/types/on-shipping-address-change-event-response.interface.d.ts.map +1 -1
  58. package/bundles/types/open-wallets/types/on-shipping-option-change-event-data.interface.d.ts +13 -2
  59. package/bundles/types/open-wallets/types/on-shipping-option-change-event-data.interface.d.ts.map +1 -1
  60. package/bundles/types/open-wallets/types/on-shipping-option-change-event-response.interface.d.ts +12 -0
  61. package/bundles/types/open-wallets/types/on-shipping-option-change-event-response.interface.d.ts.map +1 -1
  62. package/bundles/types/open-wallets/types/payment-source.type.d.ts +3 -2
  63. package/bundles/types/open-wallets/types/payment-source.type.d.ts.map +1 -1
  64. package/bundles/types/open-wallets/types/shipping-event-to-response.type.d.ts +8 -0
  65. package/bundles/types/open-wallets/types/shipping-event-to-response.type.d.ts.map +1 -1
  66. package/bundles/widget.umd.js +1296 -508
  67. package/bundles/widget.umd.js.d.ts +1377 -200
  68. package/bundles/widget.umd.js.min.d.ts +1377 -200
  69. package/bundles/widget.umd.min.js +1 -1
  70. package/docs/open-wallet-buttons-examples.md +561 -830
  71. package/docs/open-wallet-buttons.md +1652 -0
  72. package/package.json +1 -1
  73. package/slate.md +1673 -0
@@ -2132,6 +2132,16 @@ declare enum SERVICE_GROUP {
2132
2132
  WALLET = "wallet"
2133
2133
  }
2134
2134
 
2135
+ /**
2136
+ * Token types returned in the OTT (One-Time Token) creation response.
2137
+ */
2138
+ declare enum TOKEN_TYPE {
2139
+ /** FPAN - Funding Primary Account Number (Google Pay only). */
2140
+ CARD = "card",
2141
+ /** DPAN - Device Primary Account Number (Apple Pay & Google Pay). */
2142
+ CARD_SCHEME_TOKEN = "card_scheme_token"
2143
+ }
2144
+
2135
2145
  type WalletType = WALLET_TYPES;
2136
2146
  declare enum WALLET_TYPES {
2137
2147
  APPLE_PAY = "apple",
@@ -2140,7 +2150,7 @@ declare enum WALLET_TYPES {
2140
2150
 
2141
2151
  interface CreateOTTResponse {
2142
2152
  temp_token: string;
2143
- token_type: string;
2153
+ token_type: TOKEN_TYPE;
2144
2154
  }
2145
2155
  interface Billing {
2146
2156
  address_line1: string;
@@ -2172,7 +2182,7 @@ interface CreateSessionRequest {
2172
2182
  service_id: string;
2173
2183
  session_id: string;
2174
2184
  request_shipping?: boolean;
2175
- store_name?: string;
2185
+ store_name: string;
2176
2186
  }
2177
2187
  interface CreateSessionResponse {
2178
2188
  id: string;
@@ -3053,87 +3063,248 @@ declare class FraudPreventionService {
3053
3063
  private validateMode;
3054
3064
  }
3055
3065
 
3056
- interface BaseEventData$1<T> {
3057
- event: string;
3058
- chargeId?: string;
3059
- data?: T | undefined;
3066
+ /**
3067
+ * Operations that can fail during the wallet lifecycle.
3068
+ * Used in {@link OnErrorPayload.context.operation} to identify what failed.
3069
+ */
3070
+ declare enum ERROR_OPERATION {
3071
+ /** General wallet lifecycle operation. */
3072
+ WALLET_OPERATION = "wallet_operation",
3073
+ /** Loading or validating the wallet service configuration. */
3074
+ CONFIGURATION = "configuration",
3075
+ /** A required event handler was not registered before calling load(). */
3076
+ HANDLER_REGISTRATION = "handler_registration",
3077
+ /** Processing a shipping address or shipping option update. */
3078
+ SHIPPING_UPDATE = "shipping_update"
3060
3079
  }
3061
3080
 
3081
+ /**
3082
+ * Events emitted during the OpenWallet payment lifecycle.
3083
+ */
3062
3084
  declare enum EVENT$1 {
3063
- ON_UPDATE = "onUpdate",
3085
+ /** Emitted when the wallet button is clicked by the user. */
3064
3086
  ON_CLICK = "onClick",
3065
- ON_CHECKOUT_CLOSE = "onCheckoutClose",
3087
+ /** Emitted when the OTT (One-Time Token) creation succeeds. */
3066
3088
  SUCCESS = "success",
3089
+ /** Emitted when the wallet is not available on the current device/browser. */
3067
3090
  UNAVAILABLE = "unavailable",
3091
+ /** Emitted when an error occurs during wallet operation. */
3068
3092
  ERROR = "error",
3069
- UPDATE = "update",
3093
+ /** Emitted when the wallet button has been loaded and rendered in the DOM. */
3070
3094
  LOADED = "loaded",
3095
+ /** Emitted when the wallet checkout is closed/cancelled by the user (internal). */
3071
3096
  CHECKOUT_CLOSE = "checkoutClose",
3097
+ /** Emitted when the customer selects or updates their shipping address. */
3072
3098
  ON_SHIPPING_ADDRESS_CHANGE = "onShippingAddressChange",
3099
+ /** Emitted when the customer selects a shipping option. */
3073
3100
  ON_SHIPPING_OPTIONS_CHANGE = "onShippingOptionsChange"
3074
3101
  }
3075
3102
  type OpenWalletEventType = EVENT$1;
3076
3103
 
3077
- interface OnClickEventData$1 {
3078
- request_type: string;
3079
- wallet_type?: string;
3080
- meta?: Record<string, unknown>;
3104
+ /**
3105
+ * Base interface for all OpenWallet event data payloads.
3106
+ * Every event emitted during the OpenWallet lifecycle carries an `event` identifier
3107
+ * that corresponds to a value from the {@link EVENT} enum.
3108
+ *
3109
+ * All concrete event interfaces (e.g. {@link OnClickEventData}, {@link OnErrorEventData})
3110
+ * extend this base.
3111
+ */
3112
+ interface OpenWalletBaseEvent {
3113
+ /** The event name identifier. */
3114
+ event: EVENT$1;
3115
+ }
3116
+ /**
3117
+ * Extended base interface for OpenWallet events that carry a typed data payload
3118
+ * in addition to the event identifier.
3119
+ *
3120
+ * Used by events whose payload is wrapped in a `data` field
3121
+ * (e.g. shipping change events, OTT error events).
3122
+ *
3123
+ * @template T - The type of the event-specific data payload.
3124
+ */
3125
+ interface OpenWalletDataEvent<T> extends OpenWalletBaseEvent {
3126
+ /** The event-specific data payload. */
3127
+ data?: T | undefined;
3081
3128
  }
3082
- interface OnCrateOTTSuccessfulEventData {
3129
+
3130
+ /**
3131
+ * Data emitted when the wallet button is clicked.
3132
+ *
3133
+ * The merchant's `onClick` handler controls the payment flow via its return value:
3134
+ * - Return `void` / `undefined` to continue normally.
3135
+ * - Return `false` to abort the payment flow.
3136
+ * - Return a `Promise<void>` to defer the wallet sheet until the promise resolves.
3137
+ * - Return a `Promise<boolean>` — if it resolves to `false`, the flow is aborted.
3138
+ * - Throwing an error also aborts the flow.
3139
+ */
3140
+ interface OnClickEventData$1 extends OpenWalletBaseEvent {
3141
+ event: EVENT$1.ON_CLICK;
3142
+ }
3143
+ /**
3144
+ * Payload for the onSuccess event data.
3145
+ */
3146
+ interface OnCreateOTTSuccessPayload {
3147
+ /** The created OTT response containing the temporary token. */
3083
3148
  token: CreateOTTResponse;
3149
+ /** The payment amount. */
3084
3150
  amount: number;
3151
+ /** The shipping address and contact information, if provided. */
3085
3152
  shipping?: Shipping;
3153
+ /** The billing address, if provided. */
3086
3154
  billing?: Billing;
3087
3155
  }
3088
- interface OnCreateOTTErrorEventData extends BaseEventData$1<{
3156
+ /**
3157
+ * Data emitted when the OTT (One-Time Token) creation is successful.
3158
+ */
3159
+ interface OnCreateOTTSuccessfulEventData extends OpenWalletDataEvent<OnCreateOTTSuccessPayload> {
3160
+ event: EVENT$1.SUCCESS;
3161
+ }
3162
+ /**
3163
+ * Payload for the OTT error event data.
3164
+ */
3165
+ interface OnCreateOTTErrorPayload {
3166
+ /** Error message from the API. */
3089
3167
  message?: string;
3168
+ /** Error code from the API. */
3090
3169
  code?: string;
3091
- }> {
3170
+ }
3171
+ /**
3172
+ * Data emitted when the OTT creation fails.
3173
+ */
3174
+ interface OnCreateOTTErrorEventData extends OpenWalletDataEvent<OnCreateOTTErrorPayload> {
3092
3175
  event: EVENT$1.ERROR;
3093
3176
  }
3094
- interface OnUnavailableEventData$1 {
3095
- wallet_type: string;
3177
+ /**
3178
+ * Typed details for the unavailable event.
3179
+ */
3180
+ interface OnUnavailableDetails {
3181
+ /** The service ID that was checked. */
3182
+ service_id: string;
3183
+ }
3184
+ /**
3185
+ * Payload for the onUnavailable event data.
3186
+ */
3187
+ interface OnUnavailablePayload {
3188
+ /** A human-readable reason why the wallet is unavailable. */
3096
3189
  reason: string;
3097
- details?: Record<string, unknown>;
3190
+ /** Additional details about the unavailability. */
3191
+ details?: OnUnavailableDetails;
3098
3192
  }
3099
- interface OnErrorEventData$1 {
3193
+ /**
3194
+ * Data emitted when the wallet is not available on the current device or browser.
3195
+ */
3196
+ interface OnUnavailableEventData$1 extends OpenWalletDataEvent<OnUnavailablePayload> {
3197
+ event: EVENT$1.UNAVAILABLE;
3198
+ }
3199
+ /**
3200
+ * Payload for the onError event data.
3201
+ */
3202
+ interface OnErrorPayload {
3203
+ /** The Error object describing what went wrong. */
3100
3204
  error: Error;
3205
+ /** Context about the error. */
3101
3206
  context?: {
3102
- operation?: string;
3103
- wallet_type?: string;
3207
+ /** The operation that failed. */
3208
+ operation?: ERROR_OPERATION;
3104
3209
  };
3105
3210
  }
3211
+ /**
3212
+ * Data emitted when an error occurs during wallet operation.
3213
+ */
3214
+ interface OnErrorEventData$1 extends OpenWalletDataEvent<OnErrorPayload> {
3215
+ event: EVENT$1.ERROR;
3216
+ }
3217
+ /**
3218
+ * Data emitted when the wallet button has been loaded and rendered in the DOM.
3219
+ * No payload — the specific wallet type is determined by the concrete button class.
3220
+ */
3221
+ interface OnLoadedEventData extends OpenWalletBaseEvent {
3222
+ event: EVENT$1.LOADED;
3223
+ }
3224
+ /**
3225
+ * Data emitted when the wallet checkout is cancelled or closed by the user.
3226
+ * No payload — matches WalletButtonsExpress `OnCloseEventData` convention.
3227
+ */
3228
+ interface OnCancelEventData extends OpenWalletBaseEvent {
3229
+ event: EVENT$1.CHECKOUT_CLOSE;
3230
+ }
3106
3231
 
3232
+ /**
3233
+ * Base metadata required to configure an OpenWallet button.
3234
+ */
3107
3235
  interface OpenWalletMeta {
3236
+ /** The payment amount as a number (e.g. `19.99`). */
3108
3237
  amount: number;
3238
+ /** The ISO 4217 currency code (e.g. `'AUD'`, `'USD'`). */
3109
3239
  currency: string;
3240
+ /** The ISO 3166-1 alpha-2 country code (e.g. `'AU'`, `'US'`). */
3110
3241
  country: string;
3242
+ /** Optional styling configuration for the wallet button. */
3111
3243
  style?: OpenWalletMetaStyles;
3112
3244
  }
3245
+ /**
3246
+ * Styling options for the wallet button appearance.
3247
+ */
3113
3248
  interface OpenWalletMetaStyles {
3249
+ /** The button type variant (wallet-specific values). */
3114
3250
  button_type?: string;
3251
+ /** The button color/style variant (wallet-specific values). */
3115
3252
  button_style?: string;
3116
3253
  }
3117
3254
 
3118
- interface WalletPaymentSource {
3119
- load(): void;
3120
- }
3121
-
3122
- interface BaseEventData<T> {
3123
- event: string;
3124
- data?: T | undefined;
3255
+ /**
3256
+ * Internal contract for wallet-specific service providers (Apple Pay, Google Pay, etc.).
3257
+ *
3258
+ * This interface defines the operations that the wallet-specific button classes
3259
+ * ({@link ApplePayOpenWalletButton}, {@link GooglePayOpenWalletButton}) delegate
3260
+ * to the resolved wallet service after fetching the service configuration.
3261
+ *
3262
+ * **Note:** This is NOT the merchant-facing API. Merchants interact with
3263
+ * {@link ApplePayOpenWalletButton} or {@link GooglePayOpenWalletButton} directly,
3264
+ * which orchestrate these providers internally.
3265
+ */
3266
+ interface IOpenWalletProvider {
3267
+ /**
3268
+ * Loads the wallet SDK, checks availability, and renders the wallet button.
3269
+ * If the wallet is not available, emits the `unavailable` event instead.
3270
+ */
3271
+ load(): Promise<void>;
3272
+ /**
3273
+ * Removes the wallet button from the DOM and releases resources.
3274
+ */
3275
+ destroy(): void;
3276
+ /**
3277
+ * Updates the wallet metadata (e.g. when order amount or currency changes).
3278
+ *
3279
+ * @param meta - The updated metadata.
3280
+ */
3281
+ setMeta(meta: OpenWalletMeta): void;
3125
3282
  }
3126
3283
 
3127
- interface OnShippingAddressChangeEventData$1 extends BaseEventData<AddressChangeEventData$1> {
3284
+ /**
3285
+ * Event data emitted when the customer selects or updates their shipping address
3286
+ * in the wallet payment sheet.
3287
+ */
3288
+ interface OnShippingAddressChangeEventData$1 extends OpenWalletDataEvent<AddressChangeEventData$1> {
3128
3289
  event: EVENT$1.ON_SHIPPING_ADDRESS_CHANGE;
3129
3290
  }
3291
+ /**
3292
+ * The shipping address data provided by the wallet.
3293
+ */
3130
3294
  interface AddressChangeEventData$1 {
3295
+ /** Postal/zip code of the shipping address. */
3131
3296
  address_postcode?: string;
3297
+ /** City of the shipping address. */
3132
3298
  address_city?: string;
3299
+ /** State or administrative area of the shipping address. */
3133
3300
  address_state?: string;
3301
+ /** Country code of the shipping address. */
3134
3302
  address_country?: string;
3303
+ /** Street address line 1 (Apple Pay only). */
3135
3304
  address_line1?: string;
3305
+ /** Street address line 2 (Apple Pay only). */
3136
3306
  address_line2?: string;
3307
+ /** Contact information for the shipping recipient (Apple Pay only). */
3137
3308
  contact?: {
3138
3309
  phone?: string;
3139
3310
  email?: string;
@@ -3142,212 +3313,1212 @@ interface AddressChangeEventData$1 {
3142
3313
  };
3143
3314
  }
3144
3315
 
3316
+ /**
3317
+ * Event data emitted when the customer selects a shipping option
3318
+ * in the wallet payment sheet.
3319
+ */
3320
+ interface OnShippingOptionChangeEventData$1 extends OpenWalletDataEvent<ShippingOptionChangeEventData$1> {
3321
+ event: EVENT$1.ON_SHIPPING_OPTIONS_CHANGE;
3322
+ }
3323
+ /**
3324
+ * The selected shipping option data provided by the wallet.
3325
+ */
3326
+ interface ShippingOptionChangeEventData$1 {
3327
+ /** The unique identifier of the selected shipping option. */
3328
+ shipping_option_id?: string;
3329
+ /** The amount associated with the selected shipping option. */
3330
+ amount?: string;
3331
+ /** The display label of the selected shipping option. */
3332
+ label?: string;
3333
+ /** Additional detail text for the selected shipping option. */
3334
+ detail?: string;
3335
+ }
3336
+
3337
+ /**
3338
+ * Response object returned by the merchant's `onShippingAddressChange` handler.
3339
+ * Used to update the wallet payment sheet with new amounts, shipping options, or errors.
3340
+ */
3145
3341
  interface OnShippingAddressChangeEventResponse$1 {
3342
+ /** The updated payment amount based on the new shipping address. */
3146
3343
  amount?: number;
3147
- shipping_options?: IApplePayShippingOption$1[];
3344
+ /**
3345
+ * Updated list of available shipping options for the new address.
3346
+ * The first item in the array is used as the default selected option.
3347
+ */
3348
+ shipping_options?: IShippingOption[];
3349
+ /** Optional error to display in the wallet payment sheet if the address is invalid. */
3350
+ error?: {
3351
+ /** The error code identifying the type of address validation error. */
3352
+ code: 'address_error' | 'country_error' | 'state_error' | 'zip_error' | 'shipping_contact_invalid' | 'billing_contact_invalid' | string;
3353
+ /** The specific field that caused the error (for Apple Pay error display). */
3354
+ field?: 'phone' | 'email' | 'name' | 'phonetic_name' | 'address_lines' | 'locality' | 'postal_code' | 'administrative_area' | 'country' | 'country_code';
3355
+ /** A human-readable error message to display to the customer. */
3356
+ message?: string;
3357
+ };
3358
+ }
3359
+
3360
+ /**
3361
+ * Response object returned by the merchant's `onShippingOptionsChange` handler.
3362
+ * Used to update the wallet payment sheet with a new total amount.
3363
+ */
3364
+ interface OnShippingOptionChangeEventResponse$1 {
3365
+ /** The updated total payment amount based on the selected shipping option. */
3366
+ amount?: number;
3367
+ /** Optional error to display in the wallet payment sheet if the option is invalid. */
3368
+ error?: {
3369
+ /** The error code identifying the type of shipping option error. */
3370
+ code: 'method_unavailable' | 'store_unavailable' | string;
3371
+ /** A human-readable error message. */
3372
+ message?: string;
3373
+ };
3374
+ }
3375
+
3376
+ /**
3377
+ * Conditional type that maps a shipping event data type to its corresponding response type.
3378
+ *
3379
+ * - `OnShippingAddressChangeEventData` maps to `OnShippingAddressChangeEventResponse`
3380
+ * - `OnShippingOptionChangeEventData` maps to `OnShippingOptionChangeEventResponse`
3381
+ *
3382
+ * @template T - The shipping event data type.
3383
+ */
3384
+ type ShippingEventToResponse$1<T> = T extends OnShippingAddressChangeEventData$1 ? OnShippingAddressChangeEventResponse$1 : T extends OnShippingOptionChangeEventData$1 ? OnShippingOptionChangeEventResponse$1 : never;
3385
+
3386
+ /**
3387
+ * Abstract base class for wallet-specific OpenWallet service implementations.
3388
+ *
3389
+ * Provides shared functionality for OTT creation, shipping event handling,
3390
+ * error/unavailable emission, and DOM cleanup. Concrete implementations
3391
+ * (e.g. Apple Pay, Google Pay) extend this class and implement {@link load} and {@link setMeta}.
3392
+ *
3393
+ * @implements {IOpenWalletProvider}
3394
+ */
3395
+ declare abstract class OpenWalletService implements IOpenWalletProvider {
3396
+ protected api: ApiInternal;
3397
+ protected eventEmitter: EventEmitter;
3398
+ protected walletType: WalletType;
3399
+ protected serviceId: string;
3400
+ protected container: Container;
3401
+ protected serviceType: SERVICE_TYPES;
3402
+ /** The service group identifier used in OTT creation requests. */
3403
+ protected readonly serviceGroup = SERVICE_GROUP.WALLET;
3404
+ /**
3405
+ * @param api - API client for backend communication.
3406
+ * @param eventEmitter - Shared event emitter for wallet lifecycle events.
3407
+ * @param walletType - The wallet type identifier (e.g. `'apple'`, `'google'`).
3408
+ * @param serviceId - The service ID for the wallet configuration.
3409
+ * @param container - The DOM container that holds the wallet button.
3410
+ * @param serviceType - The service type from the API configuration.
3411
+ */
3412
+ constructor(api: ApiInternal, eventEmitter: EventEmitter, walletType: WalletType, serviceId: string, container: Container, serviceType: SERVICE_TYPES);
3413
+ /**
3414
+ * Loads and renders the wallet button. Must be implemented by each wallet service.
3415
+ */
3416
+ abstract load(): Promise<void>;
3417
+ /**
3418
+ * Updates the wallet metadata. Must be implemented by each wallet service.
3419
+ *
3420
+ * @param meta - The updated metadata.
3421
+ */
3422
+ abstract setMeta(meta: OpenWalletMeta): void;
3423
+ /**
3424
+ * Creates a One-Time Token (OTT) by sending the payment data to the API.
3425
+ * Emits {@link EVENT.SUCCESS} on success or {@link EVENT.ERROR} on failure.
3426
+ *
3427
+ * @param data - The payment data including amount, shipping, billing, card info, and ref token.
3428
+ * @returns A promise resolving to the OTT response.
3429
+ */
3430
+ protected createOTT(data: CreateOTTData): Promise<CreateOTTResponse>;
3431
+ /**
3432
+ * Delegates a shipping change event to the merchant's registered handler
3433
+ * and returns the merchant's response.
3434
+ *
3435
+ * @param eventData - The shipping address or option change event data.
3436
+ * @returns A promise resolving to the merchant's shipping update response.
3437
+ * @throws {Error} If no handler is registered or the handler returns no result.
3438
+ */
3439
+ protected handleMerchantOnShippingChangedEvent<T extends OnShippingAddressChangeEventData$1 | OnShippingOptionChangeEventData$1>(eventData: T): Promise<ShippingEventToResponse$1<T>>;
3440
+ /**
3441
+ * Emits the {@link EVENT.UNAVAILABLE} event when the wallet is not available.
3442
+ *
3443
+ * @param reason - A human-readable description of why the wallet is unavailable.
3444
+ */
3445
+ protected handleOnUnavailable(reason?: string): void;
3446
+ /**
3447
+ * Emits the {@link EVENT.ERROR} event and logs the error to the console.
3448
+ *
3449
+ * @param error - The error that occurred.
3450
+ * @param operation - The operation that failed. Defaults to {@link ERROR_OPERATION.WALLET_OPERATION}.
3451
+ */
3452
+ protected handleOnError(error: Error, operation?: ERROR_OPERATION): void;
3453
+ /**
3454
+ * Removes the wallet button element from the DOM.
3455
+ * Call this to clean up resources when the button is no longer needed.
3456
+ */
3457
+ destroy(): void;
3458
+ }
3459
+
3460
+ /**
3461
+ * @classdesc Abstract base class for Open Wallet buttons. **Do not instantiate directly.**
3462
+ * Use {@link ApplePayOpenWalletButton} or {@link GooglePayOpenWalletButton} instead.
3463
+ *
3464
+ * Use one of the concrete implementations instead:
3465
+ * - {@link ApplePayOpenWalletButton} for Apple Pay integration
3466
+ * - {@link GooglePayOpenWalletButton} for Google Pay integration
3467
+ *
3468
+ * These subclasses inherit all event handlers and lifecycle methods documented below.
3469
+ *
3470
+ * @class OpenWalletButtons
3471
+ * @abstract
3472
+ * @hideconstructor
3473
+ */
3474
+ declare abstract class OpenWalletButtons<TMeta extends OpenWalletMeta = OpenWalletMeta> {
3475
+ protected container: Container;
3476
+ protected api: ApiInternal;
3477
+ protected env: string;
3478
+ protected serviceId: string;
3479
+ protected meta: TMeta;
3480
+ protected eventEmitter: EventEmitter;
3481
+ protected walletService: OpenWalletService | undefined;
3482
+ private onShippingOptionsChangeHandlerRegistered;
3483
+ /** @private */
3484
+ abstract readonly walletType: WalletType;
3485
+ /** @private */
3486
+ constructor(selector: string, publicKeyOrAccessToken: string, serviceId: string, meta: TMeta);
3487
+ /**
3488
+ * Creates the wallet-specific service instance for this button.
3489
+ * Each concrete subclass implements this to instantiate its specific wallet service.
3490
+ *
3491
+ * @param serviceConfig - The service configuration response from the API.
3492
+ * @returns The wallet service instance.
3493
+ */
3494
+ protected abstract createWalletService(serviceConfig: GetConfigResponse): OpenWalletService;
3495
+ /**
3496
+ * Validates that the service configuration type matches the expected wallet type.
3497
+ * Each concrete subclass implements this to ensure the service ID corresponds
3498
+ * to the correct wallet type.
3499
+ *
3500
+ * @param serviceConfig - The service configuration response from the API.
3501
+ * @throws {Error} If the service type does not match the expected wallet type.
3502
+ */
3503
+ protected abstract validateServiceType(serviceConfig: GetConfigResponse): void;
3504
+ /**
3505
+ * Validates wallet-specific metadata requirements.
3506
+ * Each concrete subclass implements this to enforce its own required fields
3507
+ * (e.g. Apple Pay requires `amount_label`).
3508
+ *
3509
+ * Called automatically during construction after base meta validation.
3510
+ *
3511
+ * @throws {Error} If any wallet-specific required field is missing or invalid.
3512
+ */
3513
+ protected abstract validateWalletMeta(): void;
3514
+ private getApiAuthType;
3515
+ /**
3516
+ * Validates the base metadata fields common to all wallet types:
3517
+ * `meta` must exist, `amount` must be a number, `currency` and `country` must be strings.
3518
+ *
3519
+ * @private
3520
+ * @throws {Error} If any base required field is missing or has an invalid type.
3521
+ */
3522
+ private validateBaseMeta;
3523
+ protected getOpenWalletServiceConfig(): Promise<GetConfigResponse>;
3524
+ protected handleOnError(error: Error, operation?: ERROR_OPERATION): void;
3525
+ /**
3526
+ * Loads and initializes the wallet button based on the service configuration.
3527
+ * This method fetches the wallet service configuration, validates that the service
3528
+ * type matches the expected wallet, and creates the appropriate wallet service instance.
3529
+ * Bear in mind that you must call this method after setting up all event handlers.
3530
+ *
3531
+ * @example
3532
+ * button.onClick((data) => { ... });
3533
+ * button.onSuccess((data) => { ... });
3534
+ * button.onError((error) => { ... });
3535
+ * button.load();
3536
+ */
3537
+ load(): void;
3538
+ /**
3539
+ * Current method can change environment. By default environment = sandbox.
3540
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
3541
+ * Bear in mind that you must set an environment before calling `button.load()`.
3542
+ *
3543
+ * @example
3544
+ * button.setEnv('production', 'paydock.com');
3545
+ *
3546
+ * @param {string} env - The target environment: `'sandbox'` or `'production'`.
3547
+ * @param {string} [alias] - Own domain alias.
3548
+ */
3549
+ setEnv(env: string, alias?: string): void;
3550
+ /**
3551
+ * Updates the wallet metadata after initialization.
3552
+ * Use this when order information changes (e.g. amount, currency) after the button has been rendered.
3553
+ * Bear in mind that this must be called before the next payment attempt takes effect.
3554
+ *
3555
+ * @example
3556
+ * button.setMeta({ ...meta, amount: 29.99 });
3557
+ *
3558
+ * @param {ApplePayOpenWalletMeta | GooglePayOpenWalletMeta} meta - The updated metadata object. The concrete type depends on the button class.
3559
+ */
3560
+ setMeta(meta: TMeta): void;
3561
+ /**
3562
+ * Removes the wallet button from the DOM and cleans up resources.
3563
+ * Call this method when the wallet button is no longer needed (e.g. navigating away from the payment page).
3564
+ *
3565
+ * @example
3566
+ * button.destroy();
3567
+ */
3568
+ destroy(): void;
3569
+ /**
3570
+ * Callback for onClick method.
3571
+ *
3572
+ * @callback OnClickCallback
3573
+ * @param {OnClickEventData} data - The click event data.
3574
+ * @returns {boolean | void | Promise<boolean | void>} Return `false` to abort, or a Promise to defer.
3575
+ */
3576
+ /**
3577
+ * Registers a callback function to be invoked when the wallet button gets clicked.
3578
+ * The handler controls the wallet payment flow via its return value:
3579
+ *
3580
+ * - Return `void` (or nothing) to continue the payment flow normally.
3581
+ * - Return `false` to abort the payment flow.
3582
+ * - Return a `Promise<void>` to defer the wallet sheet until the promise resolves.
3583
+ * - Return a `Promise<boolean>` — if it resolves to `false`, the flow is aborted.
3584
+ * - Throwing an error (sync or async) also aborts the flow.
3585
+ *
3586
+ * Both synchronous and asynchronous (async) handlers are supported.
3587
+ *
3588
+ * **Note:** this callback may be called multiple times as the customer closes the payment
3589
+ * checkout and re-clicks the button.
3590
+ *
3591
+ * @example
3592
+ * // Synchronous usage — continue normally
3593
+ * button.onClick((event) => {
3594
+ * performValidationLogic();
3595
+ * });
3596
+ *
3597
+ * @example
3598
+ * // Synchronous abort — return false to cancel the payment
3599
+ * button.onClick((event) => {
3600
+ * if (!isOrderValid()) return false;
3601
+ * });
3602
+ *
3603
+ * @example
3604
+ * // Asynchronous usage — defer wallet sheet until the promise resolves
3605
+ * button.onClick(async (event) => {
3606
+ * await fetch('/validate-order').then(res => res.json());
3607
+ * });
3608
+ *
3609
+ * @param {OnClickCallback} handler - Function to be called when the wallet button is clicked.
3610
+ */
3611
+ onClick(handler: (data: OnClickEventData$1) => boolean | undefined | Promise<boolean | undefined>): void;
3612
+ /**
3613
+ * Callback for onSuccess method.
3614
+ *
3615
+ * @callback OnSuccessCallback
3616
+ * @param {OnCreateOTTSuccessfulEventData} data - The OTT creation result including the token, amount, and address data.
3617
+ */
3618
+ /**
3619
+ * Registers a callback function to be invoked when the OTT (One-Time Token) creation was successful.
3620
+ * Both synchronous and asynchronous (async) handlers are supported.
3621
+ *
3622
+ * **Important:** A handler is required. Do not perform thread blocking operations in callback such as `window.alert()` calls.
3623
+ *
3624
+ * **Error handling:** If the handler throws (sync or async), the error is logged and swallowed
3625
+ * so that internal processing continues uninterrupted.
3626
+ *
3627
+ * @example
3628
+ * button.onSuccess((event) => {
3629
+ * console.log('OTT created:', event.data.token.temp_token);
3630
+ * console.log('Amount:', event.data.amount);
3631
+ * });
3632
+ *
3633
+ * @example
3634
+ * // Async handler
3635
+ * button.onSuccess(async (event) => {
3636
+ * await submitTokenToServer(event.data.token.temp_token);
3637
+ * });
3638
+ *
3639
+ * @param {OnSuccessCallback} handler - Function to be called when the OTT creation was successful.
3640
+ */
3641
+ onSuccess(handler: (data: OnCreateOTTSuccessfulEventData) => void | Promise<void>): void;
3642
+ /**
3643
+ * Callback for onUnavailable method.
3644
+ *
3645
+ * @callback OnUnavailableCallback
3646
+ * @param {OnUnavailableEventData} data - Data describing why the wallet is unavailable.
3647
+ */
3648
+ /**
3649
+ * Registers a callback function to be invoked when the wallet is not available in the current context.
3650
+ * This can happen when the wallet service is not supported on the current device or browser.
3651
+ * Both synchronous and asynchronous (async) handlers are supported.
3652
+ *
3653
+ * **Error handling:** If the handler throws (sync or async), the error is logged and swallowed
3654
+ * so that internal processing continues uninterrupted.
3655
+ *
3656
+ * @example
3657
+ * button.onUnavailable((event) => {
3658
+ * console.log('Wallet not available:', event.data.reason);
3659
+ * });
3660
+ *
3661
+ * @param {OnUnavailableCallback} handler - Function to be called when the wallet is not available in the current context.
3662
+ */
3663
+ onUnavailable(handler: (data: OnUnavailableEventData$1) => void | Promise<void>): void;
3664
+ /**
3665
+ * Callback for onError method.
3666
+ *
3667
+ * @callback OnErrorCallback
3668
+ * @param {OnErrorEventData} data - The error event data including the Error object and context.
3669
+ */
3670
+ /**
3671
+ * Registers a callback function to be invoked when an error occurs during wallet operation.
3672
+ * This includes configuration issues, validation errors, and OTT creation failures.
3673
+ * Both synchronous and asynchronous (async) handlers are supported.
3674
+ *
3675
+ * **Error handling:** If the handler throws (sync or async), the error is logged and swallowed
3676
+ * so that internal processing continues uninterrupted.
3677
+ *
3678
+ * @example
3679
+ * button.onError((event) => {
3680
+ * console.error('Wallet error:', event.data.error.message);
3681
+ * console.log('Context:', event.data.context);
3682
+ * });
3683
+ *
3684
+ * @param {OnErrorCallback} handler - Function to be called when the wallet has an error.
3685
+ */
3686
+ onError(handler: (data: OnErrorEventData$1) => void | Promise<void>): void;
3687
+ /**
3688
+ * Callback for onCancel method.
3689
+ *
3690
+ * @callback OnCancelCallback
3691
+ * @param {OnCancelEventData} data - Data associated with the cancellation event.
3692
+ */
3693
+ /**
3694
+ * Registers a callback function to be invoked when the wallet checkout is cancelled or closed by the user.
3695
+ * This event is triggered when the user dismisses the wallet payment interface without completing the transaction.
3696
+ * Both synchronous and asynchronous (async) handlers are supported.
3697
+ *
3698
+ * **Error handling:** If the handler throws (sync or async), the error is logged and swallowed
3699
+ * so that internal processing continues uninterrupted.
3700
+ *
3701
+ * @example
3702
+ * button.onCancel((event) => {
3703
+ * console.log('Wallet checkout cancelled', event);
3704
+ * });
3705
+ *
3706
+ * @param {OnCancelCallback} handler - Function to be called when the wallet checkout is cancelled.
3707
+ */
3708
+ onCancel(handler: (data: OnCancelEventData) => void | Promise<void>): void;
3709
+ /**
3710
+ * Registers a callback function to be invoked when the wallet button has been loaded and rendered in the DOM.
3711
+ * Both synchronous and asynchronous (async) handlers are supported.
3712
+ *
3713
+ * **Error handling:** If the handler throws (sync or async), the error is logged and swallowed
3714
+ * so that internal processing continues uninterrupted.
3715
+ *
3716
+ * @example
3717
+ * button.onLoaded((event) => {
3718
+ * console.log('Wallet button loaded');
3719
+ * });
3720
+ *
3721
+ * @param {Function} handler - Function to be called when the wallet button is loaded.
3722
+ */
3723
+ onLoaded(handler: (data: OnLoadedEventData) => void | Promise<void>): void;
3724
+ /**
3725
+ * Callback for onShippingAddressChange method.
3726
+ *
3727
+ * @callback OnShippingAddressChangeCallback
3728
+ * @param {OnShippingAddressChangeEventData} data - The shipping address data from the wallet.
3729
+ * @returns {OnShippingAddressChangeEventResponse | Promise<OnShippingAddressChangeEventResponse>} Address update result containing updated amount, shipping options, and optional error.
3730
+ */
3731
+ /**
3732
+ * Registers a callback for when the customer selects or updates their shipping address.
3733
+ * Use this method to listen for shipping address selection or input from customer when shipping is enabled.
3734
+ * The event handler should return updated payment information including the new amount and
3735
+ * available shipping options based on the selected address.
3736
+ * Both synchronous and asynchronous (async) handlers are supported.
3737
+ *
3738
+ * In case of an address validation error, include the `error` field in the response
3739
+ * to display an appropriate error in the wallet payment sheet.
3740
+ *
3741
+ * @example
3742
+ * // Async handler
3743
+ * button.onShippingAddressChange(async (data) => {
3744
+ * const response = await fetch('https://your-server.com/update-shipping-address', {
3745
+ * method: 'POST',
3746
+ * body: JSON.stringify(data),
3747
+ * });
3748
+ * const result = await response.json();
3749
+ * return {
3750
+ * amount: result.newAmount,
3751
+ * shipping_options: result.availableShippingOptions,
3752
+ * };
3753
+ * });
3754
+ *
3755
+ * @example
3756
+ * // Sync handler
3757
+ * button.onShippingAddressChange((data) => {
3758
+ * return {
3759
+ * amount: calculateShipping(data.data.address_country),
3760
+ * shipping_options: getOptionsForCountry(data.data.address_country),
3761
+ * };
3762
+ * });
3763
+ *
3764
+ * @param {OnShippingAddressChangeCallback} handler - Function to be called when the shipping address data is updated.
3765
+ */
3766
+ onShippingAddressChange(handler: (data: OnShippingAddressChangeEventData$1) => OnShippingAddressChangeEventResponse$1 | Promise<OnShippingAddressChangeEventResponse$1>): () => void;
3767
+ /**
3768
+ * Callback for onShippingOptionsChange method.
3769
+ *
3770
+ * @callback OnShippingOptionsChangeCallback
3771
+ * @param {OnShippingOptionChangeEventData} data - The selected shipping option data.
3772
+ * @returns {OnShippingOptionChangeEventResponse | Promise<OnShippingOptionChangeEventResponse>} Shipping options update result containing the updated amount.
3773
+ */
3774
+ /**
3775
+ * Registers a callback for when the customer selects a shipping option.
3776
+ * Use this method to listen for shipping option selection from customer when shipping is enabled.
3777
+ * The event handler should return the updated payment amount based on the selected shipping option.
3778
+ * Both synchronous and asynchronous (async) handlers are supported.
3779
+ *
3780
+ * @example
3781
+ * // Async handler
3782
+ * button.onShippingOptionsChange(async (data) => {
3783
+ * const response = await fetch('https://your-server.com/update-shipping-option', {
3784
+ * method: 'POST',
3785
+ * body: JSON.stringify({ shipping_option_id: data.data.shipping_option_id }),
3786
+ * });
3787
+ * const result = await response.json();
3788
+ * return {
3789
+ * amount: result.newTotalAmount,
3790
+ * };
3791
+ * });
3792
+ *
3793
+ * @example
3794
+ * // Sync handler
3795
+ * button.onShippingOptionsChange((data) => {
3796
+ * return {
3797
+ * amount: lookupShippingCost(data.data.shipping_option_id),
3798
+ * };
3799
+ * });
3800
+ *
3801
+ * @param {OnShippingOptionsChangeCallback} handler - Function to be called when the shipping options data is updated.
3802
+ */
3803
+ onShippingOptionsChange(handler: (data: OnShippingOptionChangeEventData$1) => OnShippingOptionChangeEventResponse$1 | Promise<OnShippingOptionChangeEventResponse$1>): () => void;
3804
+ /**
3805
+ * Whether a shipping options change handler has been registered.
3806
+ * Used internally by wallet services to validate shipping configuration.
3807
+ *
3808
+ * @private
3809
+ * @returns {boolean} `true` if an `onShippingOptionsChange` handler has been registered.
3810
+ */
3811
+ get isShippingOptionsChangeHandlerRegistered(): boolean;
3812
+ }
3813
+
3814
+ type ApplePayMerchantCapability =
3815
+ /**
3816
+ * Required. This value must be supplied.
3817
+ */
3818
+ 'supports3DS'
3819
+ /**
3820
+ * Include this value only if you support China Union Pay transactions.
3821
+ */
3822
+ | 'supportsEMV'
3823
+ /**
3824
+ * Optional. If present, only transactions that are categorized as credit cards are allowed.
3825
+ */
3826
+ | 'supportsCredit'
3827
+ /**
3828
+ * Optional. If present, only transactions that are categorized as debit cards are allowed.
3829
+ */
3830
+ | 'supportsDebit';
3831
+ type ApplePayContactField = 'email' | 'name' | 'phone' | 'postalAddress';
3832
+ interface ApplePayPaymentContact {
3833
+ /**
3834
+ * An email address for the contact.
3835
+ */
3836
+ email_address?: string | undefined;
3837
+ /**
3838
+ * The contact's family name.
3839
+ */
3840
+ family_name?: string | undefined;
3841
+ /**
3842
+ * The contact's given name.
3843
+ */
3844
+ given_name?: string | undefined;
3845
+ /**
3846
+ * A phone number for the contact.
3847
+ */
3848
+ phone_number?: string | undefined;
3849
+ /**
3850
+ * The phonetic spelling of the contact's family name.
3851
+ */
3852
+ phonetic_family_name?: string | undefined;
3853
+ /**
3854
+ * The phonetic spelling of the contact's given name.
3855
+ */
3856
+ phonetic_given_name?: string | undefined;
3857
+ /**
3858
+ * The street portion of the address for the contact.
3859
+ */
3860
+ address_lines?: string[] | undefined;
3861
+ /**
3862
+ * The city for the contact.
3863
+ */
3864
+ locality?: string | undefined;
3865
+ /**
3866
+ * Additional information associated with the location, typically defined at the city or town level (such as district or neighborhood), in a postal address.
3867
+ */
3868
+ sub_locality?: string | undefined;
3869
+ /**
3870
+ * The state for the contact.
3871
+ */
3872
+ administrative_area?: string | undefined;
3873
+ /**
3874
+ * The subadministrative area (such as a county or other region) in a postal address.
3875
+ */
3876
+ sub_administrative_area?: string | undefined;
3877
+ /**
3878
+ * The zip code or postal code, where applicable, for the contact.
3879
+ */
3880
+ postal_code?: string | undefined;
3881
+ /**
3882
+ * The name of the country for the contact.
3883
+ */
3884
+ country?: string | undefined;
3885
+ /**
3886
+ * The contact's two-letter ISO 3166 country code.
3887
+ */
3888
+ country_code?: string | undefined;
3889
+ }
3890
+ type ApplePayShippingContactEditingMode =
3891
+ /**
3892
+ * The user can edit the shipping contact on the payment sheet.
3893
+ */
3894
+ 'available'
3895
+ /**
3896
+ * The user can’t edit the shipping contact on the payment sheet.
3897
+ */
3898
+ | 'storePickup'
3899
+ /**
3900
+ * The user can edit the shipping contact on the payment sheet.
3901
+ * @deprecated Use ApplePayShippingContactEditingMode.available instead.
3902
+ */
3903
+ | 'enabled';
3904
+ type ApplePayLineItemType =
3905
+ /**
3906
+ * A line item representing the known, final cost.
3907
+ */
3908
+ 'final'
3909
+ /**
3910
+ * A line item representing an estimated or unknown cost.
3911
+ */
3912
+ | 'pending';
3913
+ /**
3914
+ * A type that indicates the time a payment occurs in a transaction.
3915
+ */
3916
+ type ApplePayPaymentTiming =
3917
+ /**
3918
+ * A value that specifies that the payment occurs when the transaction is complete.
3919
+ */
3920
+ 'immediate'
3921
+ /**
3922
+ * A value that specifies that the payment occurs in the future.
3923
+ */
3924
+ | 'deferred'
3925
+ /**
3926
+ * A value that specifies that the payment occurs on a regular basis.
3927
+ */
3928
+ | 'recurring'
3929
+ /**
3930
+ * A value that specifies that the payment occurs automatically when the account falls below the automaticReloadPaymentThresholdAmount amount.
3931
+ */
3932
+ | 'automaticReload';
3933
+ /**
3934
+ * A type that indicates calendrical units, such as year, month, day, and hour.
3935
+ */
3936
+ type ApplePayRecurringPaymentDateUnit =
3937
+ /**
3938
+ * A value that specifies the year unit.
3939
+ */
3940
+ 'year'
3941
+ /**
3942
+ * A value that specifies the month unit.
3943
+ */
3944
+ | 'month'
3945
+ /**
3946
+ * A value that specifies the day unit.
3947
+ */
3948
+ | 'day'
3949
+ /**
3950
+ * A value that specifies the hour unit.
3951
+ */
3952
+ | 'hour'
3953
+ /**
3954
+ * A value that specifies the minute unit.
3955
+ */
3956
+ | 'minute';
3957
+ /**
3958
+ * Defines a line item in a payment request - for example, total, tax, discount, or grand total.
3959
+ */
3960
+ interface ApplePayLineItem {
3961
+ /**
3962
+ * A short, localized description of the line item.
3963
+ */
3964
+ label: string;
3965
+ /**
3966
+ * The line item's amount.
3967
+ */
3968
+ amount: string;
3969
+ /**
3970
+ * A value that indicates if the line item is final or pending.
3971
+ */
3972
+ type?: ApplePayLineItemType | undefined;
3973
+ /**
3974
+ * The time that the payment occurs as part of a successful transaction.
3975
+ */
3976
+ payment_timing?: ApplePayPaymentTiming;
3977
+ /**
3978
+ * The date of the first payment.
3979
+ */
3980
+ recurring_payment_start_date?: Date;
3981
+ /**
3982
+ * The amount of time — in calendar units, such as day, month, or year — that represents a fraction of the total payment interval.
3983
+ */
3984
+ recurring_payment_interval_unit?: ApplePayRecurringPaymentDateUnit;
3985
+ /**
3986
+ * The number of interval units that make up the total payment interval.
3987
+ */
3988
+ recurring_payment_interval_count?: number;
3989
+ /**
3990
+ * The date of the final payment.
3991
+ */
3992
+ recurring_payment_end_date?: Date;
3993
+ /**
3994
+ * The date, in the future, of the payment.
3995
+ */
3996
+ deferred_payment_date?: Date;
3997
+ /**
3998
+ * The balance an account reaches before the merchant applies the automatic reload amount.
3999
+ */
4000
+ automatic_reload_payment_threshold_amount?: string;
4001
+ }
4002
+ /**
4003
+ * A type that indicates how purchased items are to be shipped.
4004
+ */
4005
+ type ApplePayShippingType = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
4006
+ /**
4007
+ * When specifying a range using date components, provide all elements of the ApplePayDateComponents down to the level of granularity that you want to expose.
4008
+ * For example, if you specify a range of days, be sure to include values for both months and years in addition to days in the ApplePayDateComponents.
4009
+ *
4010
+ * Apple Pay on the Web uses the Gregorian calendar when processing dates.
4011
+ */
4012
+ interface ApplePayDateComponents {
4013
+ /**
4014
+ * A number that represents a day.
4015
+ */
4016
+ days: number;
4017
+ /**
4018
+ * A number between 1 and 12 that represents a month.
4019
+ */
4020
+ months: number;
4021
+ /**
4022
+ * A number that represents a year.
4023
+ */
4024
+ years: number;
4025
+ /**
4026
+ * A number that represents an hour.
4027
+ */
4028
+ hours: number;
4029
+ }
4030
+ /**
4031
+ * A dictionary that specifies the start and end dates for a range of time.
4032
+ */
4033
+ interface ApplePayDateComponentsRange {
4034
+ /**
4035
+ * The start date and time of the range.
4036
+ */
4037
+ start_date_components: ApplePayDateComponents;
4038
+ /**
4039
+ * The end date and time of the range.
4040
+ */
4041
+ end_date_components: ApplePayDateComponents;
4042
+ }
4043
+ /**
4044
+ * Defines a shipping method for delivering physical goods.
4045
+ */
4046
+ interface ApplePayShippingMethod {
4047
+ /**
4048
+ * A short description of the shipping method.
4049
+ */
4050
+ label: string;
4051
+ /**
4052
+ * A further description of the shipping method.
4053
+ */
4054
+ detail: string;
4055
+ /**
4056
+ * The amount associated with this shipping method.
4057
+ */
4058
+ amount: string;
4059
+ /**
4060
+ * A client-defined identifier.
4061
+ */
4062
+ identifier: string;
4063
+ /**
4064
+ * A dictionary that specifies the start and end dates for a range of time.
4065
+ */
4066
+ date_components_range?: ApplePayDateComponentsRange;
4067
+ }
4068
+ /**
4069
+ * Use ApplePayPaymentTokenContext to authorize a payment amount for each payment token in a multimerchant payment request.
4070
+ * To enable multiple merchants for a transaction, use one ApplePayPaymentTokenContext object for each merchant.
4071
+ *
4072
+ * You can optionally associate each payment token with the merchant’s top-level domain.
4073
+ */
4074
+ interface ApplePayPaymentTokenContext {
4075
+ /**
4076
+ * The Apply Pay merchant identifier.
4077
+ */
4078
+ merchant_identifier: string;
4079
+ /**
4080
+ * An external identifier for the merchant.
4081
+ */
4082
+ external_identifier: string;
4083
+ /**
4084
+ * The merchant's display name that the Apple Pay server associates with the payment token.
4085
+ */
4086
+ merchant_name: string;
4087
+ /**
4088
+ * The merchant's top-level domain that the Apple Pay server associates with the payment token.
4089
+ */
4090
+ merchant_domain?: string;
4091
+ /**
4092
+ * The amount to authorize for the payment token context.
4093
+ */
4094
+ amount: string;
3148
4095
  }
3149
-
3150
- interface OnShippingOptionChangeEventData$1 extends BaseEventData<ShippingOptionChangeEventData$1> {
3151
- event: EVENT$1.ON_SHIPPING_OPTIONS_CHANGE;
4096
+ /**
4097
+ * Use an ApplePayAutomaticReloadPaymentRequest object to provide the user with payment details and a way to manage payment methods for an automatic reload payment.
4098
+ * You can optionally display a billing agreement and set up merchant token life-cycle notifications for the request.
4099
+ * For more information about the merchant token life-cycle notifications, see Apple Pay Merchant Token Management API.
4100
+ *
4101
+ * Apple Pay issues an Apple Pay Merchant Token if the user’s payment network supports merchant-specific payment tokens.
4102
+ * Otherwise, Apple Pay issues a device token for the payment request.
4103
+ */
4104
+ interface ApplePayAutomaticReloadPaymentRequest {
4105
+ /**
4106
+ * A description of the automatic reload payment that Apple Pay displays in the payment sheet.
4107
+ */
4108
+ payment_description: string;
4109
+ /**
4110
+ * A line item that contains the reload amount and balance threshold for the automatic reload payment.
4111
+ */
4112
+ automatic_reload_billing: ApplePayLineItem;
4113
+ /**
4114
+ * A localized billing agreement that the payment sheet displays to the user before the user authorizes the payment.
4115
+ */
4116
+ billing_agreement?: string;
4117
+ /**
4118
+ * A URL to a web page where the user can update or delete the payment method for the automatic reload payment.
4119
+ */
4120
+ management_url: string;
4121
+ /**
4122
+ * A URL you provide to receive life-cycle notifications from the Apple Pay servers about the Apple Pay merchant token for the recurring payment.
4123
+ */
4124
+ token_notification_url?: string;
3152
4125
  }
3153
- interface ShippingOptionChangeEventData$1 {
3154
- shipping_option_id?: string;
3155
- amount?: string;
3156
- label?: string;
3157
- detail?: string;
4126
+ /**
4127
+ * A dictionary that represents a request to set up a recurring payment, typically a subscription.
4128
+ *
4129
+ * Important
4130
+ * You must include the recurringPaymentRequest property in the ApplePayPaymentRequest object to specify a request for a recurring payment.
4131
+ * Use an ApplePayRecurringPaymentRequest object to provide the user with payment details and a way to manage payment methods for a recurring payment.
4132
+ * You can optionally display a billing agreement and set up merchant token life-cycle notifications for the request.
4133
+ */
4134
+ interface ApplePayRecurringPaymentRequest {
4135
+ /**
4136
+ * A description of the recurring payment that Apple Pay displays to the user in the payment sheet.
4137
+ */
4138
+ payment_description: string;
4139
+ /**
4140
+ * A localized billing agreement that the payment sheet displays to the user before the user authorizes the payment.
4141
+ */
4142
+ billing_agreement?: string;
4143
+ /**
4144
+ * The regular billing cycle for the recurring payment, including start and end dates, an interval, and an interval count.
4145
+ */
4146
+ regular_billing: ApplePayLineItem;
4147
+ /**
4148
+ * The trial billing cycle for the recurring payment.
4149
+ */
4150
+ trial_billing?: ApplePayLineItem;
4151
+ /**
4152
+ * A URL to a web page where the user can update or delete the payment method for the recurring payment.
4153
+ */
4154
+ management_url: string;
4155
+ /**
4156
+ * A URL you provide for receiving life-cycle notifications from the Apple Pay servers about the Apple Pay merchant token for the recurring payment.
4157
+ */
4158
+ token_notification_url?: string;
3158
4159
  }
3159
-
3160
- interface OnShippingOptionChangeEventResponse$1 {
3161
- amount?: number;
4160
+ /**
4161
+ * A dictionary that represents a request to set up a deferred payment, such as a hotel booking or a pre-order.
4162
+ */
4163
+ interface ApplePayDeferredPaymentRequest {
4164
+ /**
4165
+ * The localized billing agreement the framework displays to the user prior to payment authorization.
4166
+ */
4167
+ billing_agreement?: string | undefined;
4168
+ /**
4169
+ * A dictionary that contains details about the deferred payment.
4170
+ */
4171
+ deferred_billing: ApplePayLineItem;
4172
+ /**
4173
+ * The date and time at the destination location of the payment.
4174
+ */
4175
+ free_cancellation_date?: Date | undefined;
4176
+ /**
4177
+ * The time zone at the destination location of the payment.
4178
+ */
4179
+ free_cancellation_date_time_zone?: string | undefined;
4180
+ /**
4181
+ * A URL that links to a page on your web site where the user can manage the payment method for the deferred payment, including deleting it.
4182
+ */
4183
+ management_url: string;
4184
+ /**
4185
+ * A description of the deferred payment.
4186
+ */
4187
+ payment_description: string;
4188
+ /**
4189
+ * A URL to receive life-cycle notifications for the merchant-specific payment token the system issues for the request, if applicable.
4190
+ */
4191
+ token_notification_url?: string | undefined;
3162
4192
  }
3163
-
3164
- declare class OpenWalletButtons implements WalletPaymentSource {
3165
- protected container: Container;
3166
- protected api: ApiInternal;
3167
- protected env: string;
3168
- protected serviceId: string;
3169
- protected meta: OpenWalletMeta;
3170
- protected eventEmitter: EventEmitter;
3171
- readonly walletType: WalletType;
3172
- constructor(selector: string, publicKeyOrAccessToken: string, serviceId: string, meta: OpenWalletMeta, requiredMetaFields: string[]);
3173
- private getApiAuthType;
3174
- private validateRequiredMetaFields;
3175
- private getOpenWalletServiceConfig;
3176
- private handleOnError;
4193
+ /**
4194
+ * Values you use to enable or disable Apple Pay Later for a specific transaction.
4195
+ */
4196
+ type ApplePayLaterAvailability =
4197
+ /**
4198
+ * Apple Pay Later is available.
4199
+ * This is the default.
4200
+ */
4201
+ 'available'
4202
+ /**
4203
+ * Apple Pay Later is unavailable because one or more ineligible or prohibited items are in the shopping cart, such as gift cards
4204
+ */
4205
+ | 'unavailableItemIneligible'
4206
+ /**
4207
+ * Apple Pay Later is unavailable because there’s a recurring payment or subscription in the shopping cart.
4208
+ */
4209
+ | 'unavailableRecurringTransaction';
4210
+ interface ApplePayPaymentRequest {
3177
4211
  /**
3178
- * Loads and initializes the wallet button based on the service configuration.
3179
- * This method fetches the wallet service configuration and creates the appropriate wallet service instance.
3180
- * Bear in mind that you must call this method after setting up all event handlers.
3181
- *
3182
- * @example
3183
- * button.load();
4212
+ * An array of the payment capabilities that the merchant supports, such as credit or debit.
4213
+ * The value must at least contain ApplePayMerchantCapability.supports3DS.
3184
4214
  */
3185
- load(): void;
4215
+ merchant_capabilities: ApplePayMerchantCapability[];
3186
4216
  /**
3187
- * Current method can change environment. By default environment = sandbox.
3188
- * Also we can change domain alias for this environment. By default domain_alias = paydock.com
3189
- * Bear in mind that you must set an environment before calling `button.load()`.
3190
- *
3191
- * @example
3192
- * button.setEnv('production', 'paydock.com');
3193
- * @param {string} env - sandbox, production
3194
- * @param {string} [alias] - Own domain alias
4217
+ * The payment networks supported by the merchant.
3195
4218
  */
3196
- setEnv(env: string, alias?: string): void;
4219
+ supported_networks: string[];
3197
4220
  /**
3198
- * Callback for onClick method.
3199
- *
3200
- * @callback OnClickCallback
3201
- * @param {OnClickEventData} data
4221
+ * The merchant's two-letter ISO 3166 country code.
3202
4222
  */
4223
+ country_code: string;
3203
4224
  /**
4225
+ * The billing information that you require from the user in order to process the transaction.
4226
+ */
4227
+ required_billing_contact_fields?: ApplePayContactField[] | undefined;
3204
4228
  /**
3205
- * Registers a callback function to be invoked when the wallet button gets clicked.
3206
- * There are two operational modes supported, Synchronous and Asynchronous.
3207
- * When asynchronous operations need to occur on the callback handler, attaching the Promise via `attachResult` is required to have the wallet wait for a result.
3208
- * When synchronous operations occur on the callback handler, attaching a boolean result via `attachResult` is optional to control the execution flow.
3209
- * Note this is supported for Paypal, GooglePay and ApplePay wallet buttons at the moment.
3210
- *
3211
- * @example
3212
- * button.onClick((data) => {
3213
- * performValidationLogic();
3214
- * });
3215
- *
3216
- * @param {listener} handler - Function to be called when the wallet button is clicked.
4229
+ * Billing contact information for the user.
3217
4230
  */
3218
- onClick(handler: (data: OnClickEventData$1) => void): () => void;
4231
+ billing_contact?: ApplePayPaymentContact | undefined;
3219
4232
  /**
3220
- * Callback for onSuccess method.
3221
- *
3222
- * @callback OnSuccessCallback
3223
- * @param {OnCrateOTTSuccessfulEventData} data
3224
- * @return {Promise<string>} OTT (One Time Token) string result
4233
+ * The shipping information that you require from the user in order to fulfill the order.
3225
4234
  */
4235
+ required_shipping_contact_fields?: ApplePayContactField[] | undefined;
3226
4236
  /**
3227
- * If the OTT creation was successful, the function passed as parameter will be called.
3228
- * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
3229
- *
3230
- * @example
3231
- * button.onSuccess((data) => {
3232
- * console.log('OTT creation successful!', data);
3233
- * });
3234
- *
3235
- * @example
3236
- * button.onSuccess().then((data) => console.log('OTT creation successful!', data));
3237
- *
3238
- * @param {OnSuccessCallback} [handler] - Function to be called when the OTT creation was successful.
4237
+ * Shipping contact information for the user.
3239
4238
  */
3240
- onSuccess(handler?: (data: OnCrateOTTSuccessfulEventData) => void): () => void;
4239
+ shipping_contact?: ApplePayPaymentContact | undefined;
3241
4240
  /**
3242
- * Callback for onUnavailable method.
3243
- *
3244
- * @callback OnUnavailableCallback
3245
- * @param {OnUnavailableEventData} data
4241
+ * Optional user-defined data.
3246
4242
  */
4243
+ application_data?: string | undefined;
3247
4244
  /**
3248
- * Registers a callback function to be invoked when the wallet is not available in the current context.
3249
- * This can happen when the wallet service is not supported on the current device or browser.
3250
- *
3251
- * @example
3252
- * button.onUnavailable((data) => {
3253
- * console.log('Wallet not available', data);
3254
- * });
3255
- *
3256
- * @example
3257
- * button.onUnavailable().then((data) => console.log('Wallet not available', data));
3258
- *
3259
- * @param {OnUnavailableCallback} [handler] - Function to be called when the wallet is not available in the current context.
4245
+ * A list of ISO 3166 country codes for limiting payments to cards from specific countries.
3260
4246
  */
3261
- onUnavailable(handler?: (data: OnUnavailableEventData$1) => void): Promise<unknown> | (() => void);
4247
+ supported_countries?: string[] | undefined;
3262
4248
  /**
3263
- * Callback for onError method.
3264
- *
3265
- * @callback OnErrorCallback
3266
- * @param {OnErrorEventData} data
4249
+ * A Boolean value that determines whether the payment sheet displays the coupon code field.
3267
4250
  */
4251
+ supports_coupon_code?: boolean | undefined;
3268
4252
  /**
3269
- * Registers a callback function to be invoked when an error that is not related to payment execution occurs.
3270
- * For example, if there are configuration issues or validation errors during wallet initialization.
3271
- *
3272
- * @example
3273
- * button.onError((error) => {
3274
- * console.log('OpenWallet error', error);
3275
- * });
3276
- *
3277
- * @example
3278
- * button.onError().then((error) => console.log('OpenWallet error', error));
3279
- *
3280
- * @param {OnErrorCallback} [handler] - Function to be called when the OpenWallet has an error.
4253
+ * The initial coupon code for the payment request.
3281
4254
  */
3282
- onError(handler?: (data: OnErrorEventData$1) => void): Promise<unknown> | (() => void);
4255
+ coupon_code?: string | undefined;
3283
4256
  /**
3284
- * Callback for onCancel method.
3285
- *
3286
- * @callback OnCancelCallback
3287
- * @param {any} data
4257
+ * A value that indicates whether the shipping mode prevents the user from editing the shipping address.
3288
4258
  */
4259
+ shipping_contact_editing_mode?: ApplePayShippingContactEditingMode;
3289
4260
  /**
3290
- * Registers a callback function to be invoked when the wallet checkout is cancelled or closed by the user.
3291
- * This event is triggered when the user dismisses the wallet payment interface without completing the transaction.
3292
- *
3293
- * @example
3294
- * button.onCancel((data) => {
3295
- * console.log('Wallet checkout cancelled', data);
3296
- * });
3297
- *
3298
- * @example
3299
- * button.onCancel().then((data) => console.log('Wallet checkout cancelled', data));
3300
- *
3301
- * @param {OnCancelCallback} [handler] - Function to be called when the wallet checkout is cancelled.
4261
+ * A line item representing the total for the payment.
3302
4262
  */
3303
- onCancel(handler?: (data: any) => void): Promise<unknown> | (() => void);
4263
+ total: ApplePayLineItem;
3304
4264
  /**
3305
- * Callback for onShippingAddressChange method.
4265
+ * A set of line items that explain recurring payments and/or additional charges.
4266
+ */
4267
+ line_items?: ApplePayLineItem[] | undefined;
4268
+ /**
4269
+ * The three-letter ISO 4217 currency code for the payment.
4270
+ */
4271
+ currency_code: string;
4272
+ /**
4273
+ * How the items are to be shipped.
4274
+ */
4275
+ shipping_type?: ApplePayShippingType | undefined;
4276
+ /**
4277
+ * A set of shipping method objects that describe the available shipping methods.
4278
+ */
4279
+ shipping_methods?: ApplePayShippingMethod[] | undefined;
4280
+ /**
4281
+ * An array of payment token contexts that requests multiple payment tokens to support a multimerchant payment.
4282
+ */
4283
+ multi_token_contexts?: ApplePayPaymentTokenContext[];
4284
+ /**
4285
+ * A property that requests an automatic reload payment, such as a store card top-up.
4286
+ */
4287
+ automatic_reload_payment_request?: ApplePayAutomaticReloadPaymentRequest;
4288
+ /**
4289
+ * This property is optional. Use it to indicate that the payment request is for a recurring payment.
4290
+ * Apple Pay issues an Apple Pay Merchant Token if the user's payment network supports merchant-specific payment tokens.
4291
+ * Otherwise, Apple Pay issues a device token for the payment request.
3306
4292
  *
3307
- * @callback OnShippingAddressChangeCallback
3308
- * @param {OnShippingAddressChangeEventData} data
3309
- * @return {Promise<OnShippingAddressChangeEventResponse>} Address update result containing updated amount and/or shipping options
4293
+ * Important
4294
+ * You can't use this property with multi_token_contexts or automatic_reload_payment_request properties.
4295
+ * Simultaneous use of these properties results in an error and cancels the payment request.
3310
4296
  */
4297
+ recurring_payment_request?: ApplePayRecurringPaymentRequest;
3311
4298
  /**
3312
- * If shipping address data is updated, the function passed as parameter will be called.
3313
- * Use this method to listen for shipping address selection or input from customer when shipping is enabled.
3314
- * The event handler should return updated payment information including the new amount and available shipping options based on the selected address.
4299
+ * A property that requests a deferred payment, such as a hotel booking or a pre-order.
4300
+ */
4301
+ deferred_payment_request?: ApplePayDeferredPaymentRequest;
4302
+ /**
4303
+ * A value that indicates whether Apple Pay Later is available for a transaction.
4304
+ */
4305
+ apple_pay_later_availability?: ApplePayLaterAvailability;
4306
+ }
4307
+
4308
+ type ApplePayButtonStyle$1 = 'black' | 'white' | 'white-outline';
4309
+
4310
+ type ApplePayButtonType$1 = 'add-money' | 'book' | 'buy' | 'check-out' | 'continue' | 'contribute' | 'donate' | 'order' | 'pay' | 'plain' | 'reload' | 'rent' | 'set-up' | 'subscribe' | 'support' | 'tip' | 'top-up';
4311
+
4312
+ declare global {
4313
+ interface Window {
4314
+ ApplePaySession: ApplePaySession;
4315
+ }
4316
+ }
4317
+ interface ApplePayOpenWalletMetaStyles extends OpenWalletMetaStyles {
4318
+ button_type?: ApplePayButtonType$1;
4319
+ button_style?: ApplePayButtonStyle$1;
4320
+ }
4321
+ interface ApplePayOpenWalletMeta extends OpenWalletMeta, ApplePayPaymentRequest {
4322
+ amount_label: string;
4323
+ store_name: string;
4324
+ /** Whether shipping address collection is required. */
4325
+ request_shipping?: boolean;
4326
+ /**
4327
+ * Available shipping options to display in the payment sheet.
4328
+ * The first item in the array is used as the default selected option.
4329
+ * Requires `request_shipping` to be `true`.
4330
+ */
4331
+ shipping_options?: IApplePayShippingOption$1[];
4332
+ show_billing_address?: boolean;
4333
+ style?: ApplePayOpenWalletMetaStyles;
4334
+ apple_pay_capabilities?: Array<'credentials_available' | 'credentials_status_unknown' | 'credentials_unavailable'>;
4335
+ }
4336
+
4337
+ /**
4338
+ * @classdesc Apple Pay wallet button that creates One-Time Tokens (OTT) via Apple Pay.
4339
+ *
4340
+ * Provides a fully typed Apple Pay integration with Apple Pay-specific metadata
4341
+ * and validates that the service configuration corresponds to an Apple Pay service.
4342
+ * On `load()`, the button fetches the service configuration and raises an error via `onError`
4343
+ * if the service type does not match Apple Pay.
4344
+ *
4345
+ * @class ApplePayOpenWalletButton
4346
+ * @extends OpenWalletButtons
4347
+ *
4348
+ * @param {string} selector - CSS selector of the HTML element that will contain the Apple Pay button.
4349
+ * @param {string} publicKeyOrAccessToken - Public key or access token for API authentication.
4350
+ * @param {string} serviceId - The Apple Pay service ID configured in PayDock dashboard.
4351
+ * @param {ApplePayOpenWalletMeta} meta - Apple Pay-specific metadata (amount, currency, country, amount_label, store_name, style, apple_pay_capabilities, etc.).
4352
+ *
4353
+ * @example
4354
+ * const button = new ApplePayOpenWalletButton(
4355
+ * '#wallet-container',
4356
+ * publicKeyOrAccessToken,
4357
+ * serviceId,
4358
+ * {
4359
+ * amount: 100,
4360
+ * currency: 'AUD',
4361
+ * country: 'AU',
4362
+ * amount_label: 'TOTAL',
4363
+ * store_name: 'My Store',
4364
+ * apple_pay_capabilities: ['credentials_available'],
4365
+ * },
4366
+ * );
4367
+ * button.setEnv('sandbox');
4368
+ * button.onSuccess((data) => console.log('OTT:', data.token));
4369
+ * button.onError((error) => console.error('Error:', error));
4370
+ * button.load();
4371
+ */
4372
+ declare class ApplePayOpenWalletButton extends OpenWalletButtons<ApplePayOpenWalletMeta> {
4373
+ /** @private */
4374
+ readonly walletType: WalletType;
4375
+ /**
4376
+ * Validates Apple Pay-specific required metadata fields.
4377
+ * Apple Pay requires `amount_label` and `store_name` to be present and strings.
3315
4378
  *
3316
- * @example
3317
- * button.onShippingAddressChange(async (data) => {
3318
- * const responseData = await fetch('https://your-server.com/update-shipping-address');
3319
- * return {
3320
- * amount: responseData.newAmount,
3321
- * shipping_options: responseData.availableShippingOptions
3322
- * };
3323
- * });
4379
+ * @private
4380
+ * @throws {Error} If `amount_label` is missing or not a string.
4381
+ * @throws {Error} If `store_name` is missing or not a string.
4382
+ */
4383
+ protected validateWalletMeta(): void;
4384
+ /**
4385
+ * Validates that the service configuration type is Apple Pay.
3324
4386
  *
3325
- * @param {OnShippingAddressChangeCallback} [handler] - Function to be called when the shipping address data is updated.
4387
+ * @private
4388
+ * @param serviceConfig - The service configuration response from the API.
4389
+ * @throws {Error} If the service type is not Apple Pay.
3326
4390
  */
3327
- onShippingAddressChange(handler?: (data: OnShippingAddressChangeEventData$1) => Promise<OnShippingAddressChangeEventResponse$1>): () => void;
4391
+ protected validateServiceType(serviceConfig: GetConfigResponse): void;
3328
4392
  /**
3329
- * Callback for onShippingOptionsChange method.
4393
+ * Creates an Apple Pay wallet service instance.
3330
4394
  *
3331
- * @callback OnShippingOptionsChangeCallback
3332
- * @param {OnShippingOptionChangeEventData} data
3333
- * @return {Promise<OnShippingOptionChangeEventResponse>} Shipping options update result containing updated amount
4395
+ * @private
4396
+ * @param serviceConfig - The service configuration response from the API.
4397
+ * @returns The Apple Pay wallet service instance.
3334
4398
  */
4399
+ protected createWalletService(serviceConfig: GetConfigResponse): OpenWalletService;
4400
+ }
4401
+
4402
+ type GooglePayButtonColor = 'default' | 'black' | 'white';
4403
+
4404
+ type GooglePayButtonSizeMode = 'static' | 'fill';
4405
+
4406
+ type GooglePayButtonType = 'book' | 'buy' | 'checkout' | 'donate' | 'order' | 'pay' | 'plain' | 'subscribe';
4407
+
4408
+ type GooglePayAuthMethod = 'PAN_ONLY' | 'CRYPTOGRAM_3DS';
4409
+ type GooglePayCardNetwork = 'AMEX' | 'DISCOVER' | 'ELECTRON' | 'ELO' | 'ELO_DEBIT' | 'INTERAC' | 'JCB' | 'MAESTRO' | 'MASTERCARD' | 'VISA';
4410
+ type BillingAddressFormat = 'MIN' | 'FULL';
4411
+ interface GooglePayOpenWalletMetaStyles extends OpenWalletMetaStyles {
4412
+ button_type?: GooglePayButtonType;
4413
+ button_size_mode?: GooglePayButtonSizeMode;
4414
+ button_color?: GooglePayButtonColor;
4415
+ }
4416
+ interface GooglePayOpenWalletMeta extends OpenWalletMeta {
4417
+ merchant_name?: string;
4418
+ /** Whether shipping address collection is required. */
4419
+ request_shipping?: boolean;
4420
+ show_billing_address?: boolean;
3335
4421
  /**
3336
- * If shipping options data is updated, the function passed as parameter will be called.
3337
- * Use this method to listen for shipping option selection from customer when shipping is enabled.
3338
- * The event handler should return the updated payment amount based on the selected shipping option.
4422
+ * Available shipping options to display in the payment sheet.
4423
+ * The first item in the array is used as the default selected option.
4424
+ * Requires `request_shipping` to be `true`.
4425
+ */
4426
+ shipping_options?: IGooglePayShippingOption[];
4427
+ amount_label?: string;
4428
+ style?: GooglePayOpenWalletMetaStyles;
4429
+ card_config?: GooglePayCardConfig;
4430
+ }
4431
+ interface GooglePayCardConfig {
4432
+ type: 'CARD' | 'PAYPAL';
4433
+ parameters: {
4434
+ allowed_auth_methods: GooglePayAuthMethod[];
4435
+ allowed_card_networks: GooglePayCardNetwork[];
4436
+ allow_prepaid_cards?: boolean;
4437
+ allow_credit_cards?: boolean;
4438
+ assurance_details_required?: boolean;
4439
+ billing_address_required?: boolean;
4440
+ billing_address_parameters?: {
4441
+ format: BillingAddressFormat;
4442
+ phone_number_required?: boolean;
4443
+ };
4444
+ card_network_parameters?: {
4445
+ card_network: GooglePayCardNetwork;
4446
+ acquirer_bin?: string;
4447
+ acquirer_merchant_id?: string;
4448
+ }[];
4449
+ };
4450
+ tokenization_specification?: {
4451
+ type: 'PAYMENT_GATEWAY';
4452
+ parameters: {
4453
+ [key: string]: string;
4454
+ };
4455
+ } | {
4456
+ type: 'DIRECT';
4457
+ parameters: {
4458
+ protocol_version: string;
4459
+ public_key: string;
4460
+ };
4461
+ };
4462
+ }
4463
+
4464
+ /**
4465
+ * @classdesc Google Pay wallet button that creates One-Time Tokens (OTT) via Google Pay.
4466
+ *
4467
+ * Provides a fully typed Google Pay integration with Google Pay-specific metadata
4468
+ * and validates that the service configuration corresponds to a Google Pay service.
4469
+ * On `load()`, the button fetches the service configuration and raises an error via `onError`
4470
+ * if the service type does not match Google Pay.
4471
+ *
4472
+ * @class GooglePayOpenWalletButton
4473
+ * @extends OpenWalletButtons
4474
+ *
4475
+ * @param {string} selector - CSS selector of the HTML element that will contain the Google Pay button.
4476
+ * @param {string} publicKeyOrAccessToken - Public key or access token for API authentication.
4477
+ * @param {string} serviceId - The Google Pay service ID configured in PayDock dashboard.
4478
+ * @param {GooglePayOpenWalletMeta} meta - Google Pay-specific metadata (amount, currency, country, card_config, merchant_name, style, etc.).
4479
+ *
4480
+ * @example
4481
+ * const button = new GooglePayOpenWalletButton(
4482
+ * '#wallet-container',
4483
+ * publicKeyOrAccessToken,
4484
+ * serviceId,
4485
+ * {
4486
+ * amount: 100,
4487
+ * currency: 'AUD',
4488
+ * country: 'AU',
4489
+ * merchant_name: 'Your Store',
4490
+ * },
4491
+ * );
4492
+ * button.setEnv('sandbox');
4493
+ * button.onSuccess((data) => console.log('OTT:', data.token));
4494
+ * button.onError((error) => console.error('Error:', error));
4495
+ * button.load();
4496
+ */
4497
+ declare class GooglePayOpenWalletButton extends OpenWalletButtons<GooglePayOpenWalletMeta> {
4498
+ /** @private */
4499
+ readonly walletType: WalletType;
4500
+ /**
4501
+ * Validates Google Pay-specific required metadata fields.
4502
+ * Google Pay has no additional required fields beyond the base (amount, currency, country).
4503
+ * @private
4504
+ */
4505
+ protected validateWalletMeta(): void;
4506
+ /**
4507
+ * Validates that the service configuration type is Google Pay.
3339
4508
  *
3340
- * @example
3341
- * button.onShippingOptionsChange(async (data) => {
3342
- * const responseData = await fetch('https://your-server.com/update-shipping-option');
3343
- * return {
3344
- * amount: responseData.newTotalAmount
3345
- * };
3346
- * });
4509
+ * @private
4510
+ * @param serviceConfig - The service configuration response from the API.
4511
+ * @throws {Error} If the service type is not Google Pay.
4512
+ */
4513
+ protected validateServiceType(serviceConfig: GetConfigResponse): void;
4514
+ /**
4515
+ * Creates a Google Pay wallet service instance.
3347
4516
  *
3348
- * @param {OnShippingOptionsChangeCallback} [handler] - Function to be called when the shipping options data is updated.
4517
+ * @private
4518
+ * @param serviceConfig - The service configuration response from the API.
4519
+ * @returns The Google Pay wallet service instance.
3349
4520
  */
3350
- onShippingOptionsChange(handler?: (data: OnShippingOptionChangeEventData$1) => Promise<OnShippingOptionChangeEventResponse$1>): () => void;
4521
+ protected createWalletService(serviceConfig: GetConfigResponse): OpenWalletService;
3351
4522
  }
3352
4523
 
3353
4524
  declare const TYPE: {
@@ -4633,26 +5804,32 @@ declare enum EVENT {
4633
5804
  ON_SHIPPING_OPTIONS_CHANGE = "onShippingOptionsChange"
4634
5805
  }
4635
5806
 
4636
- interface OnClickEventData extends BaseEventData$1<undefined> {
5807
+ interface BaseEventData<T> {
5808
+ event: string;
5809
+ chargeId?: string;
5810
+ data?: T | undefined;
5811
+ }
5812
+
5813
+ interface OnClickEventData extends BaseEventData<undefined> {
4637
5814
  event: EVENT.ON_CLICK;
4638
5815
  }
4639
5816
 
4640
- interface OnCloseEventData extends BaseEventData$1<undefined> {
5817
+ interface OnCloseEventData extends BaseEventData<undefined> {
4641
5818
  event: EVENT.ON_CHECKOUT_CLOSE;
4642
5819
  }
4643
5820
 
4644
- interface OnErrorEventData extends BaseEventData$1<Error> {
5821
+ interface OnErrorEventData extends BaseEventData<Error> {
4645
5822
  event: EVENT.ERROR;
4646
5823
  }
4647
5824
 
4648
- interface OnPaymentErrorEventData extends BaseEventData$1<{
5825
+ interface OnPaymentErrorEventData extends BaseEventData<{
4649
5826
  message?: string;
4650
5827
  code?: string;
4651
5828
  }> {
4652
5829
  event: EVENT.PAYMENT_ERROR;
4653
5830
  }
4654
5831
 
4655
- interface OnPaymentSuccessfulEventData extends BaseEventData$1<{
5832
+ interface OnPaymentSuccessfulEventData extends BaseEventData<{
4656
5833
  id: string;
4657
5834
  amount: number;
4658
5835
  currency: string;
@@ -4665,7 +5842,7 @@ interface OnPaymentInReviewEventData extends Omit<OnPaymentSuccessfulEventData,
4665
5842
  event: EVENT.PAYMENT_IN_REVIEW;
4666
5843
  }
4667
5844
 
4668
- interface OnShippingAddressChangeEventData extends BaseEventData$1<AddressChangeEventData> {
5845
+ interface OnShippingAddressChangeEventData extends BaseEventData<AddressChangeEventData> {
4669
5846
  event: EVENT.ON_SHIPPING_ADDRESS_CHANGE;
4670
5847
  }
4671
5848
  interface AddressChangeEventData {
@@ -4692,7 +5869,7 @@ interface OnShippingAddressChangeEventResponse {
4692
5869
  };
4693
5870
  }
4694
5871
 
4695
- interface OnShippingOptionChangeEventData extends BaseEventData$1<ShippingOptionChangeEventData> {
5872
+ interface OnShippingOptionChangeEventData extends BaseEventData<ShippingOptionChangeEventData> {
4696
5873
  event: EVENT.ON_SHIPPING_OPTIONS_CHANGE;
4697
5874
  }
4698
5875
  interface ShippingOptionChangeEventData {
@@ -4711,7 +5888,7 @@ interface OnShippingOptionChangeEventResponse {
4711
5888
  };
4712
5889
  }
4713
5890
 
4714
- interface OnUnavailableEventData extends BaseEventData$1<undefined> {
5891
+ interface OnUnavailableEventData extends BaseEventData<undefined> {
4715
5892
  event: EVENT.UNAVAILABLE;
4716
5893
  }
4717
5894
 
@@ -5363,4 +6540,4 @@ declare global {
5363
6540
  }
5364
6541
  }
5365
6542
 
5366
- export { AfterpayCheckoutButton, AfterpayOnSiteMessaging, Api, ApplePayWalletButtonExpress, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, CheckoutActionCode, type CheckoutResponse, ClickToPay, Configuration, type CreateOTTData, type CreateOTTRequest, type CreateOTTResponse, type CreateSessionRequest, type CreateSessionResponse, ELEMENT, EVENT$2 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD, FRAUD_PREVENTION_EVENTS, type FraudPreventionEvent, type FraudPreventionEventType, type FraudPreventionProvider, FraudPreventionService, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, type ICheckout, type IClickToPayMeta, type IDetails, type IElementStyleInput, type IEventCheckoutFinishData, type IEventData, type IPayPalMeta, type IStyles$1 as IStyles, type ITexts, type IWalletMeta, type IWalletOnClickEvent, type IWalletPaymentSuccessfulEvent, type IWalletUnavailableEvent, type IWalletUpdateData, type IWalletUpdateEvent, InstructionDebugger, MultiWidget, type OTTResponse, type OnClickEventData$1 as OnClickEventData, type OnCrateOTTSuccessfulEventData, type OnCreateOTTErrorEventData, type OnErrorEventData$1 as OnErrorEventData, type OnUnavailableEventData$1 as OnUnavailableEventData, OpenWalletButtons, type OpenWalletEventType, type OpenWalletMeta, PAYMENT_TYPE, PURPOSE, PayPalDataCollector, PayPalSavePaymentSourceWidget, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE, SUPPORTED_CARD_TYPES, TEXT, TRIGGER, TYPE, VAULT_DISPLAY_STYLE, type VaultDisplayStyle, VaultDisplayWidget, WALLET_TYPES, WalletButtons, type WalletPaymentSource, type WalletType, ZipmoneyCheckoutButton };
6543
+ export { AfterpayCheckoutButton, AfterpayOnSiteMessaging, Api, ApplePayOpenWalletButton, ApplePayWalletButtonExpress, type Billing, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, CheckoutActionCode, type CheckoutResponse, ClickToPay, Configuration, type CreateOTTData, type CreateOTTRequest, type CreateOTTResponse, type CreateSessionRequest, type CreateSessionResponse, ELEMENT, ERROR_OPERATION, EVENT$2 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD, FRAUD_PREVENTION_EVENTS, type FraudPreventionEvent, type FraudPreventionEventType, type FraudPreventionProvider, FraudPreventionService, GooglePayOpenWalletButton, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, type ICheckout, type IClickToPayMeta, type IDetails, type IElementStyleInput, type IEventCheckoutFinishData, type IEventData, type IOpenWalletProvider, type IPayPalMeta, type IStyles$1 as IStyles, type ITexts, type IWalletMeta, type IWalletOnClickEvent, type IWalletPaymentSuccessfulEvent, type IWalletUnavailableEvent, type IWalletUpdateData, type IWalletUpdateEvent, InstructionDebugger, MultiWidget, type OTTResponse, type OnCancelEventData, type OnClickEventData$1 as OnClickEventData, type OnCreateOTTErrorEventData, type OnCreateOTTErrorPayload, type OnCreateOTTSuccessPayload, type OnCreateOTTSuccessfulEventData, type OnErrorEventData$1 as OnErrorEventData, type OnErrorPayload, type OnLoadedEventData, type OnUnavailableDetails, type OnUnavailableEventData$1 as OnUnavailableEventData, type OnUnavailablePayload, type OpenWalletBaseEvent, OpenWalletButtons, type OpenWalletDataEvent, type OpenWalletEventType, type OpenWalletMeta, PAYMENT_TYPE, PURPOSE, PayPalDataCollector, PayPalSavePaymentSourceWidget, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE, SUPPORTED_CARD_TYPES, type Shipping, TEXT, TOKEN_TYPE, TRIGGER, TYPE, VAULT_DISPLAY_STYLE, type VaultDisplayStyle, VaultDisplayWidget, WALLET_TYPES, WalletButtons, type WalletType, ZipmoneyCheckoutButton };