@paydock/client-sdk 1.144.1-beta → 1.145.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 (50) hide show
  1. package/README.md +422 -31
  2. package/bundles/index.cjs +1972 -532
  3. package/bundles/index.cjs.d.ts +192 -8
  4. package/bundles/index.mjs +1972 -532
  5. package/bundles/index.mjs.d.ts +192 -8
  6. package/bundles/types/helper/browser.d.ts.map +1 -1
  7. package/bundles/types/helper/element-id.d.ts +3 -1
  8. package/bundles/types/helper/element-id.d.ts.map +1 -1
  9. package/bundles/types/helper/uuid.d.ts.map +1 -1
  10. package/bundles/types/open-wallets/apple-pay-open-wallet-button.d.ts +41 -0
  11. package/bundles/types/open-wallets/apple-pay-open-wallet-button.d.ts.map +1 -1
  12. package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts +10 -0
  13. package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts.map +1 -1
  14. package/bundles/types/open-wallets/base/service-config-cache.d.ts +23 -0
  15. package/bundles/types/open-wallets/base/service-config-cache.d.ts.map +1 -0
  16. package/bundles/types/open-wallets/google-pay-open-wallet-button.d.ts +33 -1
  17. package/bundles/types/open-wallets/google-pay-open-wallet-button.d.ts.map +1 -1
  18. package/bundles/types/open-wallets/index.d.ts +82 -1
  19. package/bundles/types/open-wallets/index.d.ts.map +1 -1
  20. package/bundles/types/open-wallets/interfaces/apple-pay/apple-pay-availability.interface.d.ts +41 -0
  21. package/bundles/types/open-wallets/interfaces/apple-pay/apple-pay-availability.interface.d.ts.map +1 -0
  22. package/bundles/types/open-wallets/interfaces/apple-pay/index.d.ts +1 -0
  23. package/bundles/types/open-wallets/interfaces/apple-pay/index.d.ts.map +1 -1
  24. package/bundles/types/open-wallets/interfaces/google-pay/google-pay-availability.interface.d.ts +25 -0
  25. package/bundles/types/open-wallets/interfaces/google-pay/google-pay-availability.interface.d.ts.map +1 -0
  26. package/bundles/types/open-wallets/interfaces/google-pay/index.d.ts +1 -0
  27. package/bundles/types/open-wallets/interfaces/google-pay/index.d.ts.map +1 -1
  28. package/bundles/types/open-wallets/interfaces/index.d.ts +3 -0
  29. package/bundles/types/open-wallets/interfaces/index.d.ts.map +1 -1
  30. package/bundles/types/open-wallets/interfaces/open-wallet-availability.interface.d.ts +31 -0
  31. package/bundles/types/open-wallets/interfaces/open-wallet-availability.interface.d.ts.map +1 -0
  32. package/bundles/types/open-wallets/services/apple-pay/apple-pay-availability.d.ts +58 -0
  33. package/bundles/types/open-wallets/services/apple-pay/apple-pay-availability.d.ts.map +1 -0
  34. package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts +8 -10
  35. package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts.map +1 -1
  36. package/bundles/types/open-wallets/services/apple-pay/index.d.ts +1 -0
  37. package/bundles/types/open-wallets/services/apple-pay/index.d.ts.map +1 -1
  38. package/bundles/types/open-wallets/services/google-pay/google-pay-availability.d.ts +53 -0
  39. package/bundles/types/open-wallets/services/google-pay/google-pay-availability.d.ts.map +1 -0
  40. package/bundles/types/open-wallets/services/google-pay/google-pay.open-wallet.service.d.ts.map +1 -1
  41. package/bundles/types/open-wallets/services/google-pay/index.d.ts +1 -0
  42. package/bundles/types/open-wallets/services/google-pay/index.d.ts.map +1 -1
  43. package/bundles/widget.umd.js +1972 -532
  44. package/bundles/widget.umd.js.d.ts +192 -8
  45. package/bundles/widget.umd.js.min.d.ts +192 -8
  46. package/bundles/widget.umd.min.js +1 -1
  47. package/docs/open-wallet-buttons-examples.md +170 -2
  48. package/docs/open-wallet-buttons.md +252 -29
  49. package/package.json +10 -7
  50. package/slate.md +170 -2
@@ -81,6 +81,106 @@ Bear in mind that you must set an environment before calling `button.load()`.
81
81
  button.setEnv('sandbox');
82
82
  ```
83
83
 
84
+ ### Checking availability before instantiation (static)
85
+
86
+ `ApplePayOpenWalletButton.checkAvailability(options)` is a **static** method so you can decide
87
+ whether to show an Apple Pay option — or which payment method to default to — **without
88
+ instantiating the button** and waiting for the `onUnavailable` event.
89
+
90
+ > **Apple Pay is no longer Safari-only.** Since iOS 16 (third-party mobile browsers) and the
91
+ > iOS 18 / 2025 desktop rollout, Apple Pay also works in Chrome, Edge and Firefox — including
92
+ > on Windows — via a **cross-device QR handoff**: the user scans a code and completes the
93
+ > payment on their iPhone. Because the paying device is often *not* the browsing device, the
94
+ > only authoritative availability signal is the async `checkAvailability()`.
95
+ > `applePayCapabilities()` is what Apple recommends; `canMakePayments()` is just a coarse
96
+ > local-device hint. See
97
+ > [Apple — Checking for Apple Pay availability](https://developer.apple.com/documentation/applepayontheweb/checking-for-apple-pay-availability).
98
+
99
+ #### `ApplePayOpenWalletButton.checkAvailability(options)`
100
+
101
+ The single, authoritative, cross-browser-aware check. It resolves the merchant identifier,
102
+ loads Apple's web SDK if needed, and queries `ApplePaySession.applePayCapabilities()`.
103
+
104
+ You may supply the merchant context in either of two ways:
105
+
106
+ ```javascript
107
+ // 1) Lightest path — no network — when you already know the Apple merchant identifier:
108
+ const result = await paydock.ApplePayOpenWalletButton.checkAvailability({
109
+ merchant_id: 'merchant.com.example',
110
+ });
111
+
112
+ // 2) Resolve the merchant identifier from the service configuration (fetched & cached):
113
+ const result = await paydock.ApplePayOpenWalletButton.checkAvailability({
114
+ public_key_or_access_token: publicKeyOrAccessToken,
115
+ service_id: serviceId,
116
+ env: 'sandbox',
117
+ // Optional — which device statuses count as "available".
118
+ // Defaults to ['credentials_available', 'credentials_status_unknown'].
119
+ apple_pay_capabilities: ['credentials_available', 'credentials_status_unknown'],
120
+ });
121
+ ```
122
+
123
+ **Result shape (`ApplePayAvailabilityResult`):**
124
+
125
+ ```javascript
126
+ {
127
+ available: true, // verdict vs the allowed capability set
128
+ supported: true, // Apple Pay usable here AT ALL (incl. cross-device QR)
129
+ has_native_session: false, // native same-device session present (canMakePayments)
130
+ payment_credential_status: // OUTPUT — the device's reported status
131
+ 'paymentCredentialStatusUnknown',
132
+ reason: undefined, // set when not available, see below
133
+ }
134
+ ```
135
+
136
+ **Inferring the transport (Apple does not expose it directly):**
137
+ - `available && has_native_session` ⇒ **native** Apple Pay sheet is likely (Safari on an Apple device).
138
+ - `available && !has_native_session` ⇒ **cross-device / QR** handoff is likely (e.g. Chrome on desktop).
139
+
140
+ `payment_credential_status` is the device's actual status:
141
+ `'paymentCredentialsAvailable'`, `'paymentCredentialStatusUnknown'`,
142
+ `'paymentCredentialsUnavailable'`, or `'applePayUnsupported'`. **Third-party / desktop
143
+ browsers normally report `paymentCredentialStatusUnknown`** (Apple can't see the remote
144
+ iPhone's cards until the user scans the QR), which is why the default allowed set includes it.
145
+
146
+ The `apple_pay_capabilities` **input** maps to those statuses
147
+ (`credentials_available` → `paymentCredentialsAvailable`,
148
+ `credentials_status_unknown` → `paymentCredentialStatusUnknown`,
149
+ `credentials_unavailable` → `paymentCredentialsUnavailable`) and decides which ones make
150
+ `available` true. When omitted, **both** `paymentCredentialsAvailable` and
151
+ `paymentCredentialStatusUnknown` count — narrow it to `['credentials_available']` only if you
152
+ want to require a confirmed local card (this will hide the button in cross-browser/QR contexts).
153
+
154
+ When `available` is `false`, `reason` is one of: `'unsupported_browser'`,
155
+ `'missing_merchant_id'`, `'service_type_mismatch'`, `'config_fetch_failed'`,
156
+ `'sdk_load_failed'`, `'query_failed'`, `'no_credentials'`, or `'no_native_session'`
157
+ (only from the synchronous check below).
158
+
159
+ ```javascript
160
+ const result = await paydock.ApplePayOpenWalletButton.checkAvailability({ merchant_id: merchantId });
161
+ if (result.available) {
162
+ renderApplePayButton();
163
+ } else {
164
+ console.log('Apple Pay unavailable:', result.reason, result.payment_credential_status);
165
+ }
166
+ ```
167
+
168
+ **Synchronous native-only fast check (`sync: true`).** Pass `{ sync: true }` for a cheap,
169
+ network-free pre-check that resolves immediately — it runs only the native same-device check
170
+ (`window.ApplePaySession` + `canMakePayments()`), with no merchant resolution, SDK load, or
171
+ `applePayCapabilities()` query. In this mode `available` reflects the native session only and
172
+ `payment_credential_status` is `undefined`. It is a Safari-oriented hint and is **not**
173
+ authoritative for cross-browser / QR availability (which require the full async check above).
174
+
175
+ ```javascript
176
+ const { has_native_session } = await paydock.ApplePayOpenWalletButton.checkAvailability({
177
+ sync: true,
178
+ });
179
+ if (has_native_session) {
180
+ // Native Apple Pay is ready on this device (Safari fast path).
181
+ }
182
+ ```
183
+
84
184
  ### Full Apple Pay example
85
185
 
86
186
  ```html
@@ -499,6 +599,58 @@ The GooglePayOpenWalletButton constructor accepts the following parameters:
499
599
 
500
600
  > **Note:** Required meta fields (`amount`, `currency`, `country`) are validated automatically by the `GooglePayOpenWalletButton` class. You do not need to specify them manually.
501
601
 
602
+ ### Checking availability before instantiation (static)
603
+
604
+ `GooglePayOpenWalletButton.checkAvailability(options)` is a **static** method that reports
605
+ whether Google Pay can be used in the current context **without instantiating the button**.
606
+ It loads the Google Pay JS SDK if needed and runs `PaymentsClient.isReadyToPay()`.
607
+
608
+ Unlike Apple Pay, **all options are optional** — Google Pay's readiness check does not
609
+ require a merchant identifier. Supplying `publicKeyOrAccessToken` + `serviceId` additionally
610
+ validates that the service is a Google Pay service (and resolves the merchant id).
611
+
612
+ ```javascript
613
+ // Simplest form — no merchant context needed:
614
+ const result = await paydock.GooglePayOpenWalletButton.checkAvailability();
615
+
616
+ // Or validate the service is a Google Pay service while checking:
617
+ const result = await paydock.GooglePayOpenWalletButton.checkAvailability({
618
+ public_key_or_access_token: publicKeyOrAccessToken,
619
+ service_id: serviceId,
620
+ env: 'sandbox',
621
+ });
622
+ ```
623
+
624
+ **Result shape (`GooglePayAvailabilityResult`):**
625
+
626
+ ```javascript
627
+ {
628
+ available: true, // isReadyToPay().result — ready to pay in this context
629
+ supported: true, // the Google Pay JS API is present and the query ran
630
+ payment_method_present: true, // OUTPUT — whether the buyer already has a usable card
631
+ reason: undefined, // set when not available, see below
632
+ }
633
+ ```
634
+
635
+ > **Note:** the static check uses the **default** card configuration (standard auth methods
636
+ > and card networks). A button instance configured with a custom `card_config` may produce a
637
+ > different result.
638
+
639
+ When `available` is `false`, `reason` is one of: `'unsupported_browser'`,
640
+ `'service_type_mismatch'`, `'config_fetch_failed'`, `'sdk_load_failed'`, `'query_failed'`,
641
+ `'no_payment_method'`, or `'api_not_loaded'` (only from the synchronous check below).
642
+
643
+ **Synchronous fast check (`sync: true`).** Google Pay has no synchronous device/card
644
+ capability API, so `{ sync: true }` only reports whether the Google Pay JS API is already
645
+ present in the page — it does **not** run `isReadyToPay()`:
646
+
647
+ ```javascript
648
+ const { available } = await paydock.GooglePayOpenWalletButton.checkAvailability({
649
+ sync: true,
650
+ });
651
+ // `available` here means "the Google Pay JS API script is loaded", not "ready to pay".
652
+ ```
653
+
502
654
  ### Full Google Pay Example
503
655
 
504
656
  ```html
@@ -641,12 +793,28 @@ Both `ApplePayOpenWalletButton` and `GooglePayOpenWalletButton` share the same e
641
793
 
642
794
  ### Checking for button availability
643
795
 
644
- If the customer's browser is not supported, or the customer does not have any card added to their wallet, the button will not load. In this case the callback onUnavailable() will be called. You can define the behavior of this function before loading the button.
796
+ There are two ways to know whether a wallet is available:
797
+
798
+ **1. After `load()` — the `onUnavailable()` callback.** If the customer's browser is not supported, or the customer does not have any card added to their wallet, the button will not load. In this case the callback onUnavailable() will be called. You can define the behavior of this function before loading the button.
645
799
 
646
800
  ```javascript
647
801
  button.onUnavailable(({ data }) => console.log("No wallet button available", data));
648
802
  ```
649
803
 
804
+ **2. Before instantiation — the static `checkAvailability()` method.** Each button class exposes a static `checkAvailability(options)` that resolves availability **without instantiating the button**, so you can decide whether to render a wallet option (or which payment method to default to) up front. The options and result are wallet-specific — see [Apple Pay → Checking availability before instantiation](#checking-availability-before-instantiation-static) and [Google Pay → Checking availability before instantiation](#checking-availability-before-instantiation-static-1).
805
+
806
+ ```javascript
807
+ // Apple Pay
808
+ const apple = await paydock.ApplePayOpenWalletButton.checkAvailability({ merchant_id: merchantId });
809
+
810
+ // Google Pay (merchant context optional)
811
+ const google = await paydock.GooglePayOpenWalletButton.checkAvailability();
812
+
813
+ if (apple.available || google.available) {
814
+ // Show a wallet payment option.
815
+ }
816
+ ```
817
+
650
818
  ### Service type validation
651
819
 
652
820
  Each button validates that the service configuration matches its expected wallet type. If you use an Apple Pay service ID with `GooglePayOpenWalletButton` (or vice versa), an error will be emitted via `onError`:
@@ -808,7 +976,7 @@ A full description of the [ApplePayOpenWalletMeta](#ApplePayOpenWalletMeta) prop
808
976
  - `request_shipping?: boolean`: Enable shipping address collection
809
977
  - `shipping_options?: IApplePayShippingOption[]`: Array of shipping options
810
978
  - `show_billing_address?: boolean`: Show billing address fields
811
- - `apple_pay_capabilities?: string[]`: Device capabilities
979
+ - `apple_pay_capabilities?: string[]`: Device credential statuses that make the button render. **Defaults to `['credentials_available', 'credentials_status_unknown']`**: `credentials_available` means the device has a confirmed Apple Pay card ready to use; `credentials_status_unknown` means a local card can't be confirmed but Apple Pay can still proceed (e.g. the cross-device QR flow used by Chrome, Edge and Firefox). Narrow to `['credentials_available']` to require a confirmed local card.
812
980
  - `merchant_capabilities?: string[]`: Merchant capabilities
813
981
  - `supported_networks?: string[]`: Supported payment networks
814
982
  - `required_billing_contact_fields?: string[]`: Required billing contact fields
@@ -100,6 +100,37 @@ Apple will determine if the device has an ApplePay wallet available and at least
100
100
  <dt><a href="#GooglePayOpenWalletMeta">GooglePayOpenWalletMeta</a> : <code>object</code></dt>
101
101
  <dd><p>Interface for Google Pay-specific metadata.</p>
102
102
  </dd>
103
+ <dt><a href="#OpenWalletAvailabilityOptions">OpenWalletAvailabilityOptions</a> : <code>object</code></dt>
104
+ <dd><p>Base options shared by every wallet&#39;s static availability check
105
+ (e.g. <a href="#ApplePayOpenWalletButton">ApplePayOpenWalletButton</a>.checkAvailability). Wallet-specific option
106
+ interfaces (such as <a href="#ApplePayAvailabilityOptions">ApplePayAvailabilityOptions</a>) extend this.</p>
107
+ </dd>
108
+ <dt><a href="#OpenWalletAvailabilityResult">OpenWalletAvailabilityResult</a> : <code>object</code></dt>
109
+ <dd><p>Base result shared by every wallet&#39;s static availability check. Wallet-specific
110
+ result interfaces (such as <a href="#ApplePayAvailabilityResult">ApplePayAvailabilityResult</a>) extend this.</p>
111
+ </dd>
112
+ <dt><a href="#ApplePayAvailabilityOptions">ApplePayAvailabilityOptions</a> : <code>object</code></dt>
113
+ <dd><p>Options for <code>ApplePayOpenWalletButton.checkAvailability</code>. Extends
114
+ <a href="#OpenWalletAvailabilityOptions">OpenWalletAvailabilityOptions</a>. Provide <code>merchant_id</code> directly to skip the network
115
+ call, <strong>or</strong> provide <code>public_key_or_access_token</code> + <code>service_id</code> to resolve the merchant
116
+ identifier from the service configuration.</p>
117
+ </dd>
118
+ <dt><a href="#ApplePayAvailabilityResult">ApplePayAvailabilityResult</a> : <code>object</code></dt>
119
+ <dd><p>Result of <code>ApplePayOpenWalletButton.checkAvailability</code>. Extends
120
+ <a href="#OpenWalletAvailabilityResult">OpenWalletAvailabilityResult</a>.</p>
121
+ <p>Infer the transport (Apple does not expose it directly): <code>available &amp;&amp; has_native_session</code>
122
+ ⇒ native sheet likely; <code>available &amp;&amp; !has_native_session</code> ⇒ cross-device / QR handoff likely.</p>
123
+ </dd>
124
+ <dt><a href="#GooglePayAvailabilityOptions">GooglePayAvailabilityOptions</a> : <code>object</code></dt>
125
+ <dd><p>Options for <code>GooglePayOpenWalletButton.checkAvailability</code>. Extends
126
+ <a href="#OpenWalletAvailabilityOptions">OpenWalletAvailabilityOptions</a>. All fields are optional — Google Pay&#39;s
127
+ <code>isReadyToPay</code> check does not require a merchant identifier. Supplying
128
+ <code>public_key_or_access_token</code> + <code>service_id</code> additionally validates the service type.</p>
129
+ </dd>
130
+ <dt><a href="#GooglePayAvailabilityResult">GooglePayAvailabilityResult</a> : <code>object</code></dt>
131
+ <dd><p>Result of <code>GooglePayOpenWalletButton.checkAvailability</code>. Extends
132
+ <a href="#OpenWalletAvailabilityResult">OpenWalletAvailabilityResult</a>.</p>
133
+ </dd>
103
134
  <dt><a href="#OnClickEventData">OnClickEventData</a> : <code>object</code></dt>
104
135
  <dd><p>Interface for OnClickEventData.
105
136
  Emitted when the wallet button is clicked.</p>
@@ -187,7 +218,7 @@ Apple will determine if the device has an ApplePay wallet available and at least
187
218
  | [shipping_options] | [<code>Array.&lt;IApplePayShippingOption&gt;</code>](#IApplePayShippingOption) | Array of available shipping options. The first item is used as the default selected option. Requires `request_shipping` to be `true`. |
188
219
  | [show_billing_address] | <code>boolean</code> | Show billing address fields in the Apple Pay sheet. |
189
220
  | store_name | <code>string</code> | The merchant's store name displayed during payment. |
190
- | [apple_pay_capabilities] | <code>Array.&lt;(&#x27;credentials\_available&#x27;\|&#x27;credentials\_status\_unknown&#x27;\|&#x27;credentials\_unavailable&#x27;)&gt;</code> | Device capabilities needed for the wallet button to be available. |
221
+ | [apple_pay_capabilities] | <code>Array.&lt;(&#x27;credentials\_available&#x27;\|&#x27;credentials\_status\_unknown&#x27;\|&#x27;credentials\_unavailable&#x27;)&gt;</code> | Device credential statuses that make the button render. Defaults to `['credentials_available', 'credentials_status_unknown']`: `credentials_available` means the device has a confirmed Apple Pay card ready to use; `credentials_status_unknown` means a local card can't be confirmed but Apple Pay can still proceed (e.g. the cross-device QR flow used by Chrome, Edge and Firefox). Narrow to `['credentials_available']` to require a confirmed local card. |
191
222
  | [merchant_capabilities] | <code>Array.&lt;(&#x27;supports3DS&#x27;\|&#x27;supportsEMV&#x27;\|&#x27;supportsCredit&#x27;\|&#x27;supportsDebit&#x27;)&gt;</code> | Array of merchant capabilities influencing the transaction processing features available. |
192
223
  | [supported_networks] | <code>Array.&lt;(&#x27;visa&#x27;\|&#x27;masterCard&#x27;\|&#x27;amex&#x27;\|&#x27;chinaUnionPay&#x27;\|&#x27;discover&#x27;\|&#x27;interac&#x27;\|&#x27;jcb&#x27;\|&#x27;privateLabel&#x27;)&gt;</code> | List of payment networks supported for Apple Pay transactions. |
193
224
  | [required_billing_contact_fields] | <code>Array.&lt;(&#x27;email&#x27;\|&#x27;name&#x27;\|&#x27;phone&#x27;\|&#x27;postalAddress&#x27;)&gt;</code> | Contact fields required from the user for billing purposes. Phone and email are currently not returned by Apple. |
@@ -221,6 +252,105 @@ Interface for Google Pay-specific metadata.
221
252
  | [style.button_color] | <code>GooglePayButtonColor</code> | The color of the Google Pay button (`'default'`, `'black'`, `'white'`). |
222
253
  | [style.button_size_mode] | <code>GooglePayButtonSizeMode</code> | The size mode (`'static'`, `'fill'`). |
223
254
 
255
+ <a name="OpenWalletAvailabilityOptions" id="OpenWalletAvailabilityOptions" href="#OpenWalletAvailabilityOptions">&nbsp;</a>
256
+
257
+ ## OpenWalletAvailabilityOptions : <code>object</code>
258
+ Base options shared by every wallet's static availability check
259
+ (e.g. [ApplePayOpenWalletButton](#ApplePayOpenWalletButton).checkAvailability). Wallet-specific option
260
+ interfaces (such as [ApplePayAvailabilityOptions](#ApplePayAvailabilityOptions)) extend this.
261
+
262
+ **Kind**: global interface
263
+
264
+ | Param | Type | Description |
265
+ | --- | --- | --- |
266
+ | [public_key_or_access_token] | <code>string</code> | Public key or access token used to fetch the service config when needed. |
267
+ | [service_id] | <code>string</code> | Service ID — used with `public_key_or_access_token` to resolve the wallet configuration. |
268
+ | [env] | <code>string</code> | Environment for the config fetch (e.g. `'sandbox'`). Defaults to the SDK default. |
269
+ | [sync] | <code>boolean</code> | When `true`, performs only the cheap, network-free synchronous check and resolves immediately — no config fetch, SDK load, or remote capability query. |
270
+
271
+ <a name="OpenWalletAvailabilityResult" id="OpenWalletAvailabilityResult" href="#OpenWalletAvailabilityResult">&nbsp;</a>
272
+
273
+ ## OpenWalletAvailabilityResult : <code>object</code>
274
+ Base result shared by every wallet's static availability check. Wallet-specific
275
+ result interfaces (such as [ApplePayAvailabilityResult](#ApplePayAvailabilityResult)) extend this.
276
+
277
+ **Kind**: global interface
278
+
279
+ | Param | Type | Description |
280
+ | --- | --- | --- |
281
+ | available | <code>boolean</code> | Convenience verdict: the wallet is usable for a payment in the current context. |
282
+ | supported | <code>boolean</code> | Whether the wallet is supported here at all (may be available via a fallback flow). |
283
+ | [reason] | <code>string</code> | Machine-readable reason when not available. |
284
+
285
+ <a name="ApplePayAvailabilityOptions" id="ApplePayAvailabilityOptions" href="#ApplePayAvailabilityOptions">&nbsp;</a>
286
+
287
+ ## ApplePayAvailabilityOptions : <code>object</code>
288
+ Options for `ApplePayOpenWalletButton.checkAvailability`. Extends
289
+ [OpenWalletAvailabilityOptions](#OpenWalletAvailabilityOptions). Provide `merchant_id` directly to skip the network
290
+ call, **or** provide `public_key_or_access_token` + `service_id` to resolve the merchant
291
+ identifier from the service configuration.
292
+
293
+ **Kind**: global interface
294
+ **Extends**: [<code>OpenWalletAvailabilityOptions</code>](#OpenWalletAvailabilityOptions)
295
+
296
+ | Param | Type | Description |
297
+ | --- | --- | --- |
298
+ | [merchant_id] | <code>string</code> | Apple merchant identifier. Provide this OR (`public_key_or_access_token` + `service_id`). |
299
+ | [apple_pay_capabilities] | <code>Array.&lt;(&#x27;credentials\_available&#x27;\|&#x27;credentials\_status\_unknown&#x27;\|&#x27;credentials\_unavailable&#x27;)&gt;</code> | Device credential statuses that count as available. Defaults to `['credentials_available', 'credentials_status_unknown']` — `credentials_status_unknown` is what third-party / cross-device (QR) browsers report, so the default keeps Apple Pay visible outside Safari. |
300
+ | [sync] | <code>boolean</code> | When `true`, runs only the synchronous native same-device check (`window.ApplePaySession` + `canMakePayments()`) and resolves immediately — no merchant resolution, SDK load, or `applePayCapabilities()` query. In this mode `available` reflects the native session only and `payment_credential_status` is `undefined`; it is **not** authoritative for cross-browser / QR availability. |
301
+
302
+ <a name="ApplePayAvailabilityResult" id="ApplePayAvailabilityResult" href="#ApplePayAvailabilityResult">&nbsp;</a>
303
+
304
+ ## ApplePayAvailabilityResult : <code>object</code>
305
+ Result of `ApplePayOpenWalletButton.checkAvailability`. Extends
306
+ [OpenWalletAvailabilityResult](#OpenWalletAvailabilityResult).
307
+
308
+ Infer the transport (Apple does not expose it directly): `available && has_native_session`
309
+ ⇒ native sheet likely; `available && !has_native_session` ⇒ cross-device / QR handoff likely.
310
+
311
+ **Kind**: global interface
312
+ **Extends**: [<code>OpenWalletAvailabilityResult</code>](#OpenWalletAvailabilityResult)
313
+
314
+ | Param | Type | Description |
315
+ | --- | --- | --- |
316
+ | available | <code>boolean</code> | Whether the device credential status is within the allowed capability set. |
317
+ | supported | <code>boolean</code> | Whether Apple Pay is usable here at all (incl. the cross-device QR flow). Derived from `payment_credential_status` (anything other than `applePayUnsupported`); falls back to the native `canMakePayments()` signal when the capabilities query could not run. |
318
+ | has_native_session | <code>boolean</code> | Whether a native, same-device Apple Pay session is present right now (`ApplePaySession` exists and `canMakePayments()` is `true`). |
319
+ | [payment_credential_status] | <code>&#x27;paymentCredentialsAvailable&#x27;</code> \| <code>&#x27;paymentCredentialStatusUnknown&#x27;</code> \| <code>&#x27;paymentCredentialsUnavailable&#x27;</code> \| <code>&#x27;applePayUnsupported&#x27;</code> | The raw device-reported credential status. Undefined when unsupported or not queried. |
320
+ | [reason] | <code>string</code> | Machine-readable reason when not available: `'unsupported_browser'`, `'missing_merchant_id'`, `'service_type_mismatch'`, `'config_fetch_failed'`, `'sdk_load_failed'`, `'query_failed'`, `'no_credentials'`, or `'no_native_session'` (only from the synchronous `sync: true` check). |
321
+
322
+ <a name="GooglePayAvailabilityOptions" id="GooglePayAvailabilityOptions" href="#GooglePayAvailabilityOptions">&nbsp;</a>
323
+
324
+ ## GooglePayAvailabilityOptions : <code>object</code>
325
+ Options for `GooglePayOpenWalletButton.checkAvailability`. Extends
326
+ [OpenWalletAvailabilityOptions](#OpenWalletAvailabilityOptions). All fields are optional — Google Pay's
327
+ `isReadyToPay` check does not require a merchant identifier. Supplying
328
+ `public_key_or_access_token` + `service_id` additionally validates the service type.
329
+
330
+ **Kind**: global interface
331
+ **Extends**: [<code>OpenWalletAvailabilityOptions</code>](#OpenWalletAvailabilityOptions)
332
+
333
+ | Param | Type | Description |
334
+ | --- | --- | --- |
335
+ | [merchant_id] | <code>string</code> | Google Pay gateway merchant identifier. Optional; the readiness check runs without it. |
336
+ | [sync] | <code>boolean</code> | When `true`, reports only whether the Google Pay JS API is already present in the page (no `isReadyToPay` call). It does **not** run the device/card readiness check. |
337
+
338
+ <a name="GooglePayAvailabilityResult" id="GooglePayAvailabilityResult" href="#GooglePayAvailabilityResult">&nbsp;</a>
339
+
340
+ ## GooglePayAvailabilityResult : <code>object</code>
341
+ Result of `GooglePayOpenWalletButton.checkAvailability`. Extends
342
+ [OpenWalletAvailabilityResult](#OpenWalletAvailabilityResult).
343
+
344
+ **Kind**: global interface
345
+ **Extends**: [<code>OpenWalletAvailabilityResult</code>](#OpenWalletAvailabilityResult)
346
+
347
+ | Param | Type | Description |
348
+ | --- | --- | --- |
349
+ | available | <code>boolean</code> | Whether Google Pay is ready to pay in the current context (from `isReadyToPay().result`). |
350
+ | supported | <code>boolean</code> | Whether the Google Pay JS API is present and the readiness query could run. |
351
+ | [payment_method_present] | <code>boolean</code> | Google's `isReadyToPay` `paymentMethodPresent` — whether the buyer already has a usable payment method. Undefined when not reported. |
352
+ | [reason] | <code>string</code> | Machine-readable reason when not available: `'unsupported_browser'`, `'service_type_mismatch'`, `'config_fetch_failed'`, `'sdk_load_failed'`, `'query_failed'`, `'no_payment_method'`, or `'api_not_loaded'` (only from the synchronous `sync: true` check). |
353
+
224
354
  <a name="OnClickEventData" id="OnClickEventData" href="#OnClickEventData">&nbsp;</a>
225
355
 
226
356
  ## OnClickEventData : <code>object</code>
@@ -487,20 +617,23 @@ if the service type does not match Apple Pay.
487
617
 
488
618
  * [ApplePayOpenWalletButton](#ApplePayOpenWalletButton) ⇐ [<code>OpenWalletButtons</code>](#OpenWalletButtons)
489
619
  * [new ApplePayOpenWalletButton(selector, publicKeyOrAccessToken, serviceId, meta)](#new_ApplePayOpenWalletButton_new)
490
- * [.load()](#OpenWalletButtons+load)
491
- * [.enable()](#OpenWalletButtons+enable)
492
- * [.disable()](#OpenWalletButtons+disable)
493
- * [.setEnv(env, [alias])](#OpenWalletButtons+setEnv)
494
- * [.setMeta(meta)](#OpenWalletButtons+setMeta)
495
- * [.destroy()](#OpenWalletButtons+destroy)
496
- * [.onClick(handler)](#OpenWalletButtons+onClick)
497
- * [.onSuccess(handler)](#OpenWalletButtons+onSuccess)
498
- * [.onUnavailable(handler)](#OpenWalletButtons+onUnavailable)
499
- * [.onError(handler)](#OpenWalletButtons+onError)
500
- * [.onCancel(handler)](#OpenWalletButtons+onCancel)
501
- * [.onLoaded(handler)](#OpenWalletButtons+onLoaded)
502
- * [.onShippingAddressChange(handler)](#OpenWalletButtons+onShippingAddressChange)
503
- * [.onShippingOptionsChange(handler)](#OpenWalletButtons+onShippingOptionsChange)
620
+ * _instance_
621
+ * [.load()](#OpenWalletButtons+load)
622
+ * [.enable()](#OpenWalletButtons+enable)
623
+ * [.disable()](#OpenWalletButtons+disable)
624
+ * [.setEnv(env, [alias])](#OpenWalletButtons+setEnv)
625
+ * [.setMeta(meta)](#OpenWalletButtons+setMeta)
626
+ * [.destroy()](#OpenWalletButtons+destroy)
627
+ * [.onClick(handler)](#OpenWalletButtons+onClick)
628
+ * [.onSuccess(handler)](#OpenWalletButtons+onSuccess)
629
+ * [.onUnavailable(handler)](#OpenWalletButtons+onUnavailable)
630
+ * [.onError(handler)](#OpenWalletButtons+onError)
631
+ * [.onCancel(handler)](#OpenWalletButtons+onCancel)
632
+ * [.onLoaded(handler)](#OpenWalletButtons+onLoaded)
633
+ * [.onShippingAddressChange(handler)](#OpenWalletButtons+onShippingAddressChange)
634
+ * [.onShippingOptionsChange(handler)](#OpenWalletButtons+onShippingOptionsChange)
635
+ * _static_
636
+ * [.checkAvailability([options])](#ApplePayOpenWalletButton.checkAvailability) ⇒ [<code>Promise.&lt;ApplePayAvailabilityResult&gt;</code>](#ApplePayAvailabilityResult)
504
637
 
505
638
  <a name="new_ApplePayOpenWalletButton_new" id="new_ApplePayOpenWalletButton_new" href="#new_ApplePayOpenWalletButton_new">&nbsp;</a>
506
639
 
@@ -873,6 +1006,54 @@ button.onShippingOptionsChange((data) => {
873
1006
  };
874
1007
  });
875
1008
  ```
1009
+ <a name="ApplePayOpenWalletButton.checkAvailability" id="ApplePayOpenWalletButton.checkAvailability" href="#ApplePayOpenWalletButton.checkAvailability">&nbsp;</a>
1010
+
1011
+ ### ApplePayOpenWalletButton.checkAvailability([options]) ⇒ [<code>Promise.&lt;ApplePayAvailabilityResult&gt;</code>](#ApplePayAvailabilityResult)
1012
+ Checks Apple Pay availability **without instantiating the button** — the single,
1013
+ authoritative, cross-browser-aware availability entry point.
1014
+
1015
+ Resolves the merchant identifier (either supplied directly or fetched from the
1016
+ service configuration), loads Apple's web SDK if needed, then queries
1017
+ `ApplePaySession.applePayCapabilities()`. Returns a convenience `available` verdict
1018
+ (computed against `apple_pay_capabilities`), the raw device-reported
1019
+ `payment_credential_status`, and `has_native_session` so callers can infer the transport:
1020
+ `available && has_native_session` ⇒ native sheet likely; `available && !has_native_session`
1021
+ ⇒ cross-device / QR handoff likely.
1022
+
1023
+ Pass `{ sync: true }` for a cheap, network-free native same-device pre-check that
1024
+ resolves immediately (see [ApplePayAvailabilityOptions.sync](ApplePayAvailabilityOptions.sync)).
1025
+
1026
+ **Kind**: static method of [<code>ApplePayOpenWalletButton</code>](#ApplePayOpenWalletButton)
1027
+ **Returns**: [<code>Promise.&lt;ApplePayAvailabilityResult&gt;</code>](#ApplePayAvailabilityResult) - The availability result.
1028
+
1029
+ | Param | Type | Description |
1030
+ | --- | --- | --- |
1031
+ | [options] | [<code>ApplePayAvailabilityOptions</code>](#ApplePayAvailabilityOptions) | Merchant context, allowed capabilities, and mode. |
1032
+
1033
+ **Example**
1034
+ ```js
1035
+ // Lightest path — no network, when you already know the merchant identifier:
1036
+ const result = await ApplePayOpenWalletButton.checkAvailability({ merchant_id });
1037
+ ```
1038
+ **Example**
1039
+ ```js
1040
+ // Resolve the merchant identifier from the service configuration:
1041
+ const result = await ApplePayOpenWalletButton.checkAvailability({
1042
+ public_key_or_access_token,
1043
+ service_id,
1044
+ env: 'sandbox',
1045
+ });
1046
+ if (result.available) {
1047
+ // Render the Apple Pay button (native sheet or cross-device QR, per has_native_session).
1048
+ } else {
1049
+ console.log('Unavailable:', result.reason, result.payment_credential_status);
1050
+ }
1051
+ ```
1052
+ **Example**
1053
+ ```js
1054
+ // Synchronous native-only fast check (no network / SDK load):
1055
+ const { has_native_session } = await ApplePayOpenWalletButton.checkAvailability({ sync: true });
1056
+ ```
876
1057
  <a name="GooglePayOpenWalletButton" id="GooglePayOpenWalletButton" href="#GooglePayOpenWalletButton">&nbsp;</a>
877
1058
 
878
1059
  ## GooglePayOpenWalletButton ⇐ [<code>OpenWalletButtons</code>](#OpenWalletButtons)
@@ -888,20 +1069,23 @@ if the service type does not match Google Pay.
888
1069
 
889
1070
  * [GooglePayOpenWalletButton](#GooglePayOpenWalletButton) ⇐ [<code>OpenWalletButtons</code>](#OpenWalletButtons)
890
1071
  * [new GooglePayOpenWalletButton(selector, publicKeyOrAccessToken, serviceId, meta)](#new_GooglePayOpenWalletButton_new)
891
- * [.load()](#OpenWalletButtons+load)
892
- * [.enable()](#OpenWalletButtons+enable)
893
- * [.disable()](#OpenWalletButtons+disable)
894
- * [.setEnv(env, [alias])](#OpenWalletButtons+setEnv)
895
- * [.setMeta(meta)](#OpenWalletButtons+setMeta)
896
- * [.destroy()](#OpenWalletButtons+destroy)
897
- * [.onClick(handler)](#OpenWalletButtons+onClick)
898
- * [.onSuccess(handler)](#OpenWalletButtons+onSuccess)
899
- * [.onUnavailable(handler)](#OpenWalletButtons+onUnavailable)
900
- * [.onError(handler)](#OpenWalletButtons+onError)
901
- * [.onCancel(handler)](#OpenWalletButtons+onCancel)
902
- * [.onLoaded(handler)](#OpenWalletButtons+onLoaded)
903
- * [.onShippingAddressChange(handler)](#OpenWalletButtons+onShippingAddressChange)
904
- * [.onShippingOptionsChange(handler)](#OpenWalletButtons+onShippingOptionsChange)
1072
+ * _instance_
1073
+ * [.load()](#OpenWalletButtons+load)
1074
+ * [.enable()](#OpenWalletButtons+enable)
1075
+ * [.disable()](#OpenWalletButtons+disable)
1076
+ * [.setEnv(env, [alias])](#OpenWalletButtons+setEnv)
1077
+ * [.setMeta(meta)](#OpenWalletButtons+setMeta)
1078
+ * [.destroy()](#OpenWalletButtons+destroy)
1079
+ * [.onClick(handler)](#OpenWalletButtons+onClick)
1080
+ * [.onSuccess(handler)](#OpenWalletButtons+onSuccess)
1081
+ * [.onUnavailable(handler)](#OpenWalletButtons+onUnavailable)
1082
+ * [.onError(handler)](#OpenWalletButtons+onError)
1083
+ * [.onCancel(handler)](#OpenWalletButtons+onCancel)
1084
+ * [.onLoaded(handler)](#OpenWalletButtons+onLoaded)
1085
+ * [.onShippingAddressChange(handler)](#OpenWalletButtons+onShippingAddressChange)
1086
+ * [.onShippingOptionsChange(handler)](#OpenWalletButtons+onShippingOptionsChange)
1087
+ * _static_
1088
+ * [.checkAvailability([options])](#GooglePayOpenWalletButton.checkAvailability) ⇒ [<code>Promise.&lt;GooglePayAvailabilityResult&gt;</code>](#GooglePayAvailabilityResult)
905
1089
 
906
1090
  <a name="new_GooglePayOpenWalletButton_new" id="new_GooglePayOpenWalletButton_new" href="#new_GooglePayOpenWalletButton_new">&nbsp;</a>
907
1091
 
@@ -1272,6 +1456,45 @@ button.onShippingOptionsChange((data) => {
1272
1456
  };
1273
1457
  });
1274
1458
  ```
1459
+ <a name="GooglePayOpenWalletButton.checkAvailability" id="GooglePayOpenWalletButton.checkAvailability" href="#GooglePayOpenWalletButton.checkAvailability">&nbsp;</a>
1460
+
1461
+ ### GooglePayOpenWalletButton.checkAvailability([options]) ⇒ [<code>Promise.&lt;GooglePayAvailabilityResult&gt;</code>](#GooglePayAvailabilityResult)
1462
+ Checks Google Pay availability **without instantiating the button** — the static
1463
+ availability entry point.
1464
+
1465
+ Loads the Google Pay JS SDK if needed, then runs `PaymentsClient.isReadyToPay()` using
1466
+ the **default** card configuration (a button instance with a custom `card_config` may
1467
+ produce a different result). All options are optional — unlike Apple Pay, Google Pay's
1468
+ readiness check does not require a merchant identifier; supplying `service_id` +
1469
+ `public_key_or_access_token` additionally validates that the service is a Google Pay service.
1470
+
1471
+ Pass `{ sync: true }` for a cheap, network-free check that only reports whether the
1472
+ Google Pay JS API is already present (see [GooglePayAvailabilityOptions.sync](GooglePayAvailabilityOptions.sync)).
1473
+
1474
+ **Kind**: static method of [<code>GooglePayOpenWalletButton</code>](#GooglePayOpenWalletButton)
1475
+ **Returns**: [<code>Promise.&lt;GooglePayAvailabilityResult&gt;</code>](#GooglePayAvailabilityResult) - The availability result.
1476
+
1477
+ | Param | Type | Description |
1478
+ | --- | --- | --- |
1479
+ | [options] | [<code>GooglePayAvailabilityOptions</code>](#GooglePayAvailabilityOptions) | Optional merchant context and mode. |
1480
+
1481
+ **Example**
1482
+ ```js
1483
+ // Simplest form — no merchant context needed:
1484
+ const result = await GooglePayOpenWalletButton.checkAvailability();
1485
+ if (result.available) {
1486
+ // Render the Google Pay button.
1487
+ }
1488
+ ```
1489
+ **Example**
1490
+ ```js
1491
+ // Validate the service is a Google Pay service while checking:
1492
+ const result = await GooglePayOpenWalletButton.checkAvailability({
1493
+ public_key_or_access_token,
1494
+ service_id,
1495
+ env: 'sandbox',
1496
+ });
1497
+ ```
1275
1498
  <a name="OpenWalletButtons" id="OpenWalletButtons" href="#OpenWalletButtons">&nbsp;</a>
1276
1499
 
1277
1500
  ## *OpenWalletButtons*
package/package.json CHANGED
@@ -104,7 +104,7 @@
104
104
  }
105
105
  },
106
106
  "name": "@paydock/client-sdk",
107
- "version": "1.144.1-beta",
107
+ "version": "1.145.0-beta",
108
108
  "scripts": {
109
109
  "build:doc": "node docs/html/marked.js",
110
110
  "build:js": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
@@ -145,7 +145,7 @@
145
145
  },
146
146
  "devDependencies": {
147
147
  "@babel/cli": "7.24.5",
148
- "@babel/core": "7.24.5",
148
+ "@babel/core": "7.29.6",
149
149
  "@babel/plugin-external-helpers": "7.24.1",
150
150
  "@babel/plugin-transform-modules-umd": "7.24.1",
151
151
  "@babel/plugin-transform-object-assign": "7.24.1",
@@ -214,14 +214,15 @@
214
214
  "tsify": "3.0.4",
215
215
  "tslib": "2.6.2",
216
216
  "typescript": "5.4.5",
217
- "vitest": "3.0.5",
217
+ "vitest": "3.2.6",
218
218
  "zod": "3.23.8"
219
219
  },
220
220
  "overrides": {
221
221
  "sha.js@>=2.0.0 <=2.4.11": "2.4.12",
222
222
  "pbkdf2": ">=3.1.3",
223
- "form-data": ">=4.0.4",
223
+ "form-data": ">=4.0.6",
224
224
  "qs": ">=6.15.2",
225
+ "js-yaml": ">=4.2.0",
225
226
  "@babel/plugin-transform-modules-systemjs": ">=7.29.4",
226
227
  "fast-uri": ">=3.1.2",
227
228
  "tmp": ">=0.2.6",
@@ -234,15 +235,17 @@
234
235
  "ajv": "8.18.0",
235
236
  "serialize-javascript": ">=7.0.3",
236
237
  "underscore": ">=1.13.8",
237
- "dompurify": ">=3.4.0",
238
+ "dompurify": "3.4.11",
238
239
  "immutable": ">=5.1.5",
239
240
  "flatted": ">=3.4.2",
240
241
  "node-forge": ">=1.4.0",
241
242
  "picomatch": ">=2.3.2",
242
243
  "socket.io-parser": ">=4.2.6",
243
244
  "lodash": ">=4.18.0",
244
- "vite": ">=6.4.2",
245
- "follow-redirects": ">=1.16.0"
245
+ "vite": ">=6.4.2 <7",
246
+ "follow-redirects": ">=1.16.0",
247
+ "shell-quote": ">=1.8.4",
248
+ "esbuild": ">=0.28.1"
246
249
  },
247
250
  "engines": {
248
251
  "node": ">=16.0.0"