@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
package/README.md CHANGED
@@ -5652,6 +5652,106 @@ Bear in mind that you must set an environment before calling `button.load()`.
5652
5652
  button.setEnv('sandbox');
5653
5653
  ```
5654
5654
 
5655
+ ### Checking availability before instantiation (static)
5656
+
5657
+ `ApplePayOpenWalletButton.checkAvailability(options)` is a **static** method so you can decide
5658
+ whether to show an Apple Pay option — or which payment method to default to — **without
5659
+ instantiating the button** and waiting for the `onUnavailable` event.
5660
+
5661
+ > **Apple Pay is no longer Safari-only.** Since iOS 16 (third-party mobile browsers) and the
5662
+ > iOS 18 / 2025 desktop rollout, Apple Pay also works in Chrome, Edge and Firefox — including
5663
+ > on Windows — via a **cross-device QR handoff**: the user scans a code and completes the
5664
+ > payment on their iPhone. Because the paying device is often *not* the browsing device, the
5665
+ > only authoritative availability signal is the async `checkAvailability()`.
5666
+ > `applePayCapabilities()` is what Apple recommends; `canMakePayments()` is just a coarse
5667
+ > local-device hint. See
5668
+ > [Apple — Checking for Apple Pay availability](https://developer.apple.com/documentation/applepayontheweb/checking-for-apple-pay-availability).
5669
+
5670
+ #### `ApplePayOpenWalletButton.checkAvailability(options)`
5671
+
5672
+ The single, authoritative, cross-browser-aware check. It resolves the merchant identifier,
5673
+ loads Apple's web SDK if needed, and queries `ApplePaySession.applePayCapabilities()`.
5674
+
5675
+ You may supply the merchant context in either of two ways:
5676
+
5677
+ ```javascript
5678
+ // 1) Lightest path — no network — when you already know the Apple merchant identifier:
5679
+ const result = await paydock.ApplePayOpenWalletButton.checkAvailability({
5680
+ merchant_id: 'merchant.com.example',
5681
+ });
5682
+
5683
+ // 2) Resolve the merchant identifier from the service configuration (fetched & cached):
5684
+ const result = await paydock.ApplePayOpenWalletButton.checkAvailability({
5685
+ public_key_or_access_token: publicKeyOrAccessToken,
5686
+ service_id: serviceId,
5687
+ env: 'sandbox',
5688
+ // Optional — which device statuses count as "available".
5689
+ // Defaults to ['credentials_available', 'credentials_status_unknown'].
5690
+ apple_pay_capabilities: ['credentials_available', 'credentials_status_unknown'],
5691
+ });
5692
+ ```
5693
+
5694
+ **Result shape (`ApplePayAvailabilityResult`):**
5695
+
5696
+ ```javascript
5697
+ {
5698
+ available: true, // verdict vs the allowed capability set
5699
+ supported: true, // Apple Pay usable here AT ALL (incl. cross-device QR)
5700
+ has_native_session: false, // native same-device session present (canMakePayments)
5701
+ payment_credential_status: // OUTPUT — the device's reported status
5702
+ 'paymentCredentialStatusUnknown',
5703
+ reason: undefined, // set when not available, see below
5704
+ }
5705
+ ```
5706
+
5707
+ **Inferring the transport (Apple does not expose it directly):**
5708
+ - `available && has_native_session` ⇒ **native** Apple Pay sheet is likely (Safari on an Apple device).
5709
+ - `available && !has_native_session` ⇒ **cross-device / QR** handoff is likely (e.g. Chrome on desktop).
5710
+
5711
+ `payment_credential_status` is the device's actual status:
5712
+ `'paymentCredentialsAvailable'`, `'paymentCredentialStatusUnknown'`,
5713
+ `'paymentCredentialsUnavailable'`, or `'applePayUnsupported'`. **Third-party / desktop
5714
+ browsers normally report `paymentCredentialStatusUnknown`** (Apple can't see the remote
5715
+ iPhone's cards until the user scans the QR), which is why the default allowed set includes it.
5716
+
5717
+ The `apple_pay_capabilities` **input** maps to those statuses
5718
+ (`credentials_available` → `paymentCredentialsAvailable`,
5719
+ `credentials_status_unknown` → `paymentCredentialStatusUnknown`,
5720
+ `credentials_unavailable` → `paymentCredentialsUnavailable`) and decides which ones make
5721
+ `available` true. When omitted, **both** `paymentCredentialsAvailable` and
5722
+ `paymentCredentialStatusUnknown` count — narrow it to `['credentials_available']` only if you
5723
+ want to require a confirmed local card (this will hide the button in cross-browser/QR contexts).
5724
+
5725
+ When `available` is `false`, `reason` is one of: `'unsupported_browser'`,
5726
+ `'missing_merchant_id'`, `'service_type_mismatch'`, `'config_fetch_failed'`,
5727
+ `'sdk_load_failed'`, `'query_failed'`, `'no_credentials'`, or `'no_native_session'`
5728
+ (only from the synchronous check below).
5729
+
5730
+ ```javascript
5731
+ const result = await paydock.ApplePayOpenWalletButton.checkAvailability({ merchant_id: merchantId });
5732
+ if (result.available) {
5733
+ renderApplePayButton();
5734
+ } else {
5735
+ console.log('Apple Pay unavailable:', result.reason, result.payment_credential_status);
5736
+ }
5737
+ ```
5738
+
5739
+ **Synchronous native-only fast check (`sync: true`).** Pass `{ sync: true }` for a cheap,
5740
+ network-free pre-check that resolves immediately — it runs only the native same-device check
5741
+ (`window.ApplePaySession` + `canMakePayments()`), with no merchant resolution, SDK load, or
5742
+ `applePayCapabilities()` query. In this mode `available` reflects the native session only and
5743
+ `payment_credential_status` is `undefined`. It is a Safari-oriented hint and is **not**
5744
+ authoritative for cross-browser / QR availability (which require the full async check above).
5745
+
5746
+ ```javascript
5747
+ const { has_native_session } = await paydock.ApplePayOpenWalletButton.checkAvailability({
5748
+ sync: true,
5749
+ });
5750
+ if (has_native_session) {
5751
+ // Native Apple Pay is ready on this device (Safari fast path).
5752
+ }
5753
+ ```
5754
+
5655
5755
  ### Full Apple Pay example
5656
5756
 
5657
5757
  ```html
@@ -6070,6 +6170,58 @@ The GooglePayOpenWalletButton constructor accepts the following parameters:
6070
6170
 
6071
6171
  > **Note:** Required meta fields (`amount`, `currency`, `country`) are validated automatically by the `GooglePayOpenWalletButton` class. You do not need to specify them manually.
6072
6172
 
6173
+ ### Checking availability before instantiation (static)
6174
+
6175
+ `GooglePayOpenWalletButton.checkAvailability(options)` is a **static** method that reports
6176
+ whether Google Pay can be used in the current context **without instantiating the button**.
6177
+ It loads the Google Pay JS SDK if needed and runs `PaymentsClient.isReadyToPay()`.
6178
+
6179
+ Unlike Apple Pay, **all options are optional** — Google Pay's readiness check does not
6180
+ require a merchant identifier. Supplying `publicKeyOrAccessToken` + `serviceId` additionally
6181
+ validates that the service is a Google Pay service (and resolves the merchant id).
6182
+
6183
+ ```javascript
6184
+ // Simplest form — no merchant context needed:
6185
+ const result = await paydock.GooglePayOpenWalletButton.checkAvailability();
6186
+
6187
+ // Or validate the service is a Google Pay service while checking:
6188
+ const result = await paydock.GooglePayOpenWalletButton.checkAvailability({
6189
+ public_key_or_access_token: publicKeyOrAccessToken,
6190
+ service_id: serviceId,
6191
+ env: 'sandbox',
6192
+ });
6193
+ ```
6194
+
6195
+ **Result shape (`GooglePayAvailabilityResult`):**
6196
+
6197
+ ```javascript
6198
+ {
6199
+ available: true, // isReadyToPay().result — ready to pay in this context
6200
+ supported: true, // the Google Pay JS API is present and the query ran
6201
+ payment_method_present: true, // OUTPUT — whether the buyer already has a usable card
6202
+ reason: undefined, // set when not available, see below
6203
+ }
6204
+ ```
6205
+
6206
+ > **Note:** the static check uses the **default** card configuration (standard auth methods
6207
+ > and card networks). A button instance configured with a custom `card_config` may produce a
6208
+ > different result.
6209
+
6210
+ When `available` is `false`, `reason` is one of: `'unsupported_browser'`,
6211
+ `'service_type_mismatch'`, `'config_fetch_failed'`, `'sdk_load_failed'`, `'query_failed'`,
6212
+ `'no_payment_method'`, or `'api_not_loaded'` (only from the synchronous check below).
6213
+
6214
+ **Synchronous fast check (`sync: true`).** Google Pay has no synchronous device/card
6215
+ capability API, so `{ sync: true }` only reports whether the Google Pay JS API is already
6216
+ present in the page — it does **not** run `isReadyToPay()`:
6217
+
6218
+ ```javascript
6219
+ const { available } = await paydock.GooglePayOpenWalletButton.checkAvailability({
6220
+ sync: true,
6221
+ });
6222
+ // `available` here means "the Google Pay JS API script is loaded", not "ready to pay".
6223
+ ```
6224
+
6073
6225
  ### Full Google Pay Example
6074
6226
 
6075
6227
  ```html
@@ -6212,12 +6364,28 @@ Both `ApplePayOpenWalletButton` and `GooglePayOpenWalletButton` share the same e
6212
6364
 
6213
6365
  ### Checking for button availability
6214
6366
 
6215
- 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.
6367
+ There are two ways to know whether a wallet is available:
6368
+
6369
+ **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.
6216
6370
 
6217
6371
  ```javascript
6218
6372
  button.onUnavailable(({ data }) => console.log("No wallet button available", data));
6219
6373
  ```
6220
6374
 
6375
+ **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).
6376
+
6377
+ ```javascript
6378
+ // Apple Pay
6379
+ const apple = await paydock.ApplePayOpenWalletButton.checkAvailability({ merchant_id: merchantId });
6380
+
6381
+ // Google Pay (merchant context optional)
6382
+ const google = await paydock.GooglePayOpenWalletButton.checkAvailability();
6383
+
6384
+ if (apple.available || google.available) {
6385
+ // Show a wallet payment option.
6386
+ }
6387
+ ```
6388
+
6221
6389
  ### Service type validation
6222
6390
 
6223
6391
  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`:
@@ -6379,7 +6547,7 @@ A full description of the [ApplePayOpenWalletMeta](#ApplePayOpenWalletMeta) prop
6379
6547
  - `request_shipping?: boolean`: Enable shipping address collection
6380
6548
  - `shipping_options?: IApplePayShippingOption[]`: Array of shipping options
6381
6549
  - `show_billing_address?: boolean`: Show billing address fields
6382
- - `apple_pay_capabilities?: string[]`: Device capabilities
6550
+ - `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.
6383
6551
  - `merchant_capabilities?: string[]`: Merchant capabilities
6384
6552
  - `supported_networks?: string[]`: Supported payment networks
6385
6553
  - `required_billing_contact_fields?: string[]`: Required billing contact fields
@@ -6561,6 +6729,37 @@ Apple will determine if the device has an ApplePay wallet available and at least
6561
6729
  <dt><a href="#GooglePayOpenWalletMeta">GooglePayOpenWalletMeta</a> : <code>object</code></dt>
6562
6730
  <dd><p>Interface for Google Pay-specific metadata.</p>
6563
6731
  </dd>
6732
+ <dt><a href="#OpenWalletAvailabilityOptions">OpenWalletAvailabilityOptions</a> : <code>object</code></dt>
6733
+ <dd><p>Base options shared by every wallet&#39;s static availability check
6734
+ (e.g. <a href="#ApplePayOpenWalletButton">ApplePayOpenWalletButton</a>.checkAvailability). Wallet-specific option
6735
+ interfaces (such as <a href="#ApplePayAvailabilityOptions">ApplePayAvailabilityOptions</a>) extend this.</p>
6736
+ </dd>
6737
+ <dt><a href="#OpenWalletAvailabilityResult">OpenWalletAvailabilityResult</a> : <code>object</code></dt>
6738
+ <dd><p>Base result shared by every wallet&#39;s static availability check. Wallet-specific
6739
+ result interfaces (such as <a href="#ApplePayAvailabilityResult">ApplePayAvailabilityResult</a>) extend this.</p>
6740
+ </dd>
6741
+ <dt><a href="#ApplePayAvailabilityOptions">ApplePayAvailabilityOptions</a> : <code>object</code></dt>
6742
+ <dd><p>Options for <code>ApplePayOpenWalletButton.checkAvailability</code>. Extends
6743
+ <a href="#OpenWalletAvailabilityOptions">OpenWalletAvailabilityOptions</a>. Provide <code>merchant_id</code> directly to skip the network
6744
+ call, <strong>or</strong> provide <code>public_key_or_access_token</code> + <code>service_id</code> to resolve the merchant
6745
+ identifier from the service configuration.</p>
6746
+ </dd>
6747
+ <dt><a href="#ApplePayAvailabilityResult">ApplePayAvailabilityResult</a> : <code>object</code></dt>
6748
+ <dd><p>Result of <code>ApplePayOpenWalletButton.checkAvailability</code>. Extends
6749
+ <a href="#OpenWalletAvailabilityResult">OpenWalletAvailabilityResult</a>.</p>
6750
+ <p>Infer the transport (Apple does not expose it directly): <code>available &amp;&amp; has_native_session</code>
6751
+ ⇒ native sheet likely; <code>available &amp;&amp; !has_native_session</code> ⇒ cross-device / QR handoff likely.</p>
6752
+ </dd>
6753
+ <dt><a href="#GooglePayAvailabilityOptions">GooglePayAvailabilityOptions</a> : <code>object</code></dt>
6754
+ <dd><p>Options for <code>GooglePayOpenWalletButton.checkAvailability</code>. Extends
6755
+ <a href="#OpenWalletAvailabilityOptions">OpenWalletAvailabilityOptions</a>. All fields are optional — Google Pay&#39;s
6756
+ <code>isReadyToPay</code> check does not require a merchant identifier. Supplying
6757
+ <code>public_key_or_access_token</code> + <code>service_id</code> additionally validates the service type.</p>
6758
+ </dd>
6759
+ <dt><a href="#GooglePayAvailabilityResult">GooglePayAvailabilityResult</a> : <code>object</code></dt>
6760
+ <dd><p>Result of <code>GooglePayOpenWalletButton.checkAvailability</code>. Extends
6761
+ <a href="#OpenWalletAvailabilityResult">OpenWalletAvailabilityResult</a>.</p>
6762
+ </dd>
6564
6763
  <dt><a href="#OnClickEventData">OnClickEventData</a> : <code>object</code></dt>
6565
6764
  <dd><p>Interface for OnClickEventData.
6566
6765
  Emitted when the wallet button is clicked.</p>
@@ -6648,7 +6847,7 @@ Apple will determine if the device has an ApplePay wallet available and at least
6648
6847
  | [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`. |
6649
6848
  | [show_billing_address] | <code>boolean</code> | Show billing address fields in the Apple Pay sheet. |
6650
6849
  | store_name | <code>string</code> | The merchant's store name displayed during payment. |
6651
- | [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. |
6850
+ | [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. |
6652
6851
  | [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. |
6653
6852
  | [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. |
6654
6853
  | [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. |
@@ -6682,6 +6881,105 @@ Interface for Google Pay-specific metadata.
6682
6881
  | [style.button_color] | <code>GooglePayButtonColor</code> | The color of the Google Pay button (`'default'`, `'black'`, `'white'`). |
6683
6882
  | [style.button_size_mode] | <code>GooglePayButtonSizeMode</code> | The size mode (`'static'`, `'fill'`). |
6684
6883
 
6884
+ <a name="OpenWalletAvailabilityOptions" id="OpenWalletAvailabilityOptions" href="#OpenWalletAvailabilityOptions">&nbsp;</a>
6885
+
6886
+ ## OpenWalletAvailabilityOptions : <code>object</code>
6887
+ Base options shared by every wallet's static availability check
6888
+ (e.g. [ApplePayOpenWalletButton](#ApplePayOpenWalletButton).checkAvailability). Wallet-specific option
6889
+ interfaces (such as [ApplePayAvailabilityOptions](#ApplePayAvailabilityOptions)) extend this.
6890
+
6891
+ **Kind**: global interface
6892
+
6893
+ | Param | Type | Description |
6894
+ | --- | --- | --- |
6895
+ | [public_key_or_access_token] | <code>string</code> | Public key or access token used to fetch the service config when needed. |
6896
+ | [service_id] | <code>string</code> | Service ID — used with `public_key_or_access_token` to resolve the wallet configuration. |
6897
+ | [env] | <code>string</code> | Environment for the config fetch (e.g. `'sandbox'`). Defaults to the SDK default. |
6898
+ | [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. |
6899
+
6900
+ <a name="OpenWalletAvailabilityResult" id="OpenWalletAvailabilityResult" href="#OpenWalletAvailabilityResult">&nbsp;</a>
6901
+
6902
+ ## OpenWalletAvailabilityResult : <code>object</code>
6903
+ Base result shared by every wallet's static availability check. Wallet-specific
6904
+ result interfaces (such as [ApplePayAvailabilityResult](#ApplePayAvailabilityResult)) extend this.
6905
+
6906
+ **Kind**: global interface
6907
+
6908
+ | Param | Type | Description |
6909
+ | --- | --- | --- |
6910
+ | available | <code>boolean</code> | Convenience verdict: the wallet is usable for a payment in the current context. |
6911
+ | supported | <code>boolean</code> | Whether the wallet is supported here at all (may be available via a fallback flow). |
6912
+ | [reason] | <code>string</code> | Machine-readable reason when not available. |
6913
+
6914
+ <a name="ApplePayAvailabilityOptions" id="ApplePayAvailabilityOptions" href="#ApplePayAvailabilityOptions">&nbsp;</a>
6915
+
6916
+ ## ApplePayAvailabilityOptions : <code>object</code>
6917
+ Options for `ApplePayOpenWalletButton.checkAvailability`. Extends
6918
+ [OpenWalletAvailabilityOptions](#OpenWalletAvailabilityOptions). Provide `merchant_id` directly to skip the network
6919
+ call, **or** provide `public_key_or_access_token` + `service_id` to resolve the merchant
6920
+ identifier from the service configuration.
6921
+
6922
+ **Kind**: global interface
6923
+ **Extends**: [<code>OpenWalletAvailabilityOptions</code>](#OpenWalletAvailabilityOptions)
6924
+
6925
+ | Param | Type | Description |
6926
+ | --- | --- | --- |
6927
+ | [merchant_id] | <code>string</code> | Apple merchant identifier. Provide this OR (`public_key_or_access_token` + `service_id`). |
6928
+ | [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. |
6929
+ | [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. |
6930
+
6931
+ <a name="ApplePayAvailabilityResult" id="ApplePayAvailabilityResult" href="#ApplePayAvailabilityResult">&nbsp;</a>
6932
+
6933
+ ## ApplePayAvailabilityResult : <code>object</code>
6934
+ Result of `ApplePayOpenWalletButton.checkAvailability`. Extends
6935
+ [OpenWalletAvailabilityResult](#OpenWalletAvailabilityResult).
6936
+
6937
+ Infer the transport (Apple does not expose it directly): `available && has_native_session`
6938
+ ⇒ native sheet likely; `available && !has_native_session` ⇒ cross-device / QR handoff likely.
6939
+
6940
+ **Kind**: global interface
6941
+ **Extends**: [<code>OpenWalletAvailabilityResult</code>](#OpenWalletAvailabilityResult)
6942
+
6943
+ | Param | Type | Description |
6944
+ | --- | --- | --- |
6945
+ | available | <code>boolean</code> | Whether the device credential status is within the allowed capability set. |
6946
+ | 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. |
6947
+ | has_native_session | <code>boolean</code> | Whether a native, same-device Apple Pay session is present right now (`ApplePaySession` exists and `canMakePayments()` is `true`). |
6948
+ | [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. |
6949
+ | [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). |
6950
+
6951
+ <a name="GooglePayAvailabilityOptions" id="GooglePayAvailabilityOptions" href="#GooglePayAvailabilityOptions">&nbsp;</a>
6952
+
6953
+ ## GooglePayAvailabilityOptions : <code>object</code>
6954
+ Options for `GooglePayOpenWalletButton.checkAvailability`. Extends
6955
+ [OpenWalletAvailabilityOptions](#OpenWalletAvailabilityOptions). All fields are optional — Google Pay's
6956
+ `isReadyToPay` check does not require a merchant identifier. Supplying
6957
+ `public_key_or_access_token` + `service_id` additionally validates the service type.
6958
+
6959
+ **Kind**: global interface
6960
+ **Extends**: [<code>OpenWalletAvailabilityOptions</code>](#OpenWalletAvailabilityOptions)
6961
+
6962
+ | Param | Type | Description |
6963
+ | --- | --- | --- |
6964
+ | [merchant_id] | <code>string</code> | Google Pay gateway merchant identifier. Optional; the readiness check runs without it. |
6965
+ | [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. |
6966
+
6967
+ <a name="GooglePayAvailabilityResult" id="GooglePayAvailabilityResult" href="#GooglePayAvailabilityResult">&nbsp;</a>
6968
+
6969
+ ## GooglePayAvailabilityResult : <code>object</code>
6970
+ Result of `GooglePayOpenWalletButton.checkAvailability`. Extends
6971
+ [OpenWalletAvailabilityResult](#OpenWalletAvailabilityResult).
6972
+
6973
+ **Kind**: global interface
6974
+ **Extends**: [<code>OpenWalletAvailabilityResult</code>](#OpenWalletAvailabilityResult)
6975
+
6976
+ | Param | Type | Description |
6977
+ | --- | --- | --- |
6978
+ | available | <code>boolean</code> | Whether Google Pay is ready to pay in the current context (from `isReadyToPay().result`). |
6979
+ | supported | <code>boolean</code> | Whether the Google Pay JS API is present and the readiness query could run. |
6980
+ | [payment_method_present] | <code>boolean</code> | Google's `isReadyToPay` `paymentMethodPresent` — whether the buyer already has a usable payment method. Undefined when not reported. |
6981
+ | [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). |
6982
+
6685
6983
  <a name="OnClickEventData" id="OnClickEventData" href="#OnClickEventData">&nbsp;</a>
6686
6984
 
6687
6985
  ## OnClickEventData : <code>object</code>
@@ -6948,20 +7246,23 @@ if the service type does not match Apple Pay.
6948
7246
 
6949
7247
  * [ApplePayOpenWalletButton](#ApplePayOpenWalletButton) ⇐ [<code>OpenWalletButtons</code>](#OpenWalletButtons)
6950
7248
  * [new ApplePayOpenWalletButton(selector, publicKeyOrAccessToken, serviceId, meta)](#new_ApplePayOpenWalletButton_new)
6951
- * [.load()](#OpenWalletButtons+load)
6952
- * [.enable()](#OpenWalletButtons+enable)
6953
- * [.disable()](#OpenWalletButtons+disable)
6954
- * [.setEnv(env, [alias])](#OpenWalletButtons+setEnv)
6955
- * [.setMeta(meta)](#OpenWalletButtons+setMeta)
6956
- * [.destroy()](#OpenWalletButtons+destroy)
6957
- * [.onClick(handler)](#OpenWalletButtons+onClick)
6958
- * [.onSuccess(handler)](#OpenWalletButtons+onSuccess)
6959
- * [.onUnavailable(handler)](#OpenWalletButtons+onUnavailable)
6960
- * [.onError(handler)](#OpenWalletButtons+onError)
6961
- * [.onCancel(handler)](#OpenWalletButtons+onCancel)
6962
- * [.onLoaded(handler)](#OpenWalletButtons+onLoaded)
6963
- * [.onShippingAddressChange(handler)](#OpenWalletButtons+onShippingAddressChange)
6964
- * [.onShippingOptionsChange(handler)](#OpenWalletButtons+onShippingOptionsChange)
7249
+ * _instance_
7250
+ * [.load()](#OpenWalletButtons+load)
7251
+ * [.enable()](#OpenWalletButtons+enable)
7252
+ * [.disable()](#OpenWalletButtons+disable)
7253
+ * [.setEnv(env, [alias])](#OpenWalletButtons+setEnv)
7254
+ * [.setMeta(meta)](#OpenWalletButtons+setMeta)
7255
+ * [.destroy()](#OpenWalletButtons+destroy)
7256
+ * [.onClick(handler)](#OpenWalletButtons+onClick)
7257
+ * [.onSuccess(handler)](#OpenWalletButtons+onSuccess)
7258
+ * [.onUnavailable(handler)](#OpenWalletButtons+onUnavailable)
7259
+ * [.onError(handler)](#OpenWalletButtons+onError)
7260
+ * [.onCancel(handler)](#OpenWalletButtons+onCancel)
7261
+ * [.onLoaded(handler)](#OpenWalletButtons+onLoaded)
7262
+ * [.onShippingAddressChange(handler)](#OpenWalletButtons+onShippingAddressChange)
7263
+ * [.onShippingOptionsChange(handler)](#OpenWalletButtons+onShippingOptionsChange)
7264
+ * _static_
7265
+ * [.checkAvailability([options])](#ApplePayOpenWalletButton.checkAvailability) ⇒ [<code>Promise.&lt;ApplePayAvailabilityResult&gt;</code>](#ApplePayAvailabilityResult)
6965
7266
 
6966
7267
  <a name="new_ApplePayOpenWalletButton_new" id="new_ApplePayOpenWalletButton_new" href="#new_ApplePayOpenWalletButton_new">&nbsp;</a>
6967
7268
 
@@ -7334,6 +7635,54 @@ button.onShippingOptionsChange((data) => {
7334
7635
  };
7335
7636
  });
7336
7637
  ```
7638
+ <a name="ApplePayOpenWalletButton.checkAvailability" id="ApplePayOpenWalletButton.checkAvailability" href="#ApplePayOpenWalletButton.checkAvailability">&nbsp;</a>
7639
+
7640
+ ### ApplePayOpenWalletButton.checkAvailability([options]) ⇒ [<code>Promise.&lt;ApplePayAvailabilityResult&gt;</code>](#ApplePayAvailabilityResult)
7641
+ Checks Apple Pay availability **without instantiating the button** — the single,
7642
+ authoritative, cross-browser-aware availability entry point.
7643
+
7644
+ Resolves the merchant identifier (either supplied directly or fetched from the
7645
+ service configuration), loads Apple's web SDK if needed, then queries
7646
+ `ApplePaySession.applePayCapabilities()`. Returns a convenience `available` verdict
7647
+ (computed against `apple_pay_capabilities`), the raw device-reported
7648
+ `payment_credential_status`, and `has_native_session` so callers can infer the transport:
7649
+ `available && has_native_session` ⇒ native sheet likely; `available && !has_native_session`
7650
+ ⇒ cross-device / QR handoff likely.
7651
+
7652
+ Pass `{ sync: true }` for a cheap, network-free native same-device pre-check that
7653
+ resolves immediately (see [ApplePayAvailabilityOptions.sync](ApplePayAvailabilityOptions.sync)).
7654
+
7655
+ **Kind**: static method of [<code>ApplePayOpenWalletButton</code>](#ApplePayOpenWalletButton)
7656
+ **Returns**: [<code>Promise.&lt;ApplePayAvailabilityResult&gt;</code>](#ApplePayAvailabilityResult) - The availability result.
7657
+
7658
+ | Param | Type | Description |
7659
+ | --- | --- | --- |
7660
+ | [options] | [<code>ApplePayAvailabilityOptions</code>](#ApplePayAvailabilityOptions) | Merchant context, allowed capabilities, and mode. |
7661
+
7662
+ **Example**
7663
+ ```js
7664
+ // Lightest path — no network, when you already know the merchant identifier:
7665
+ const result = await ApplePayOpenWalletButton.checkAvailability({ merchant_id });
7666
+ ```
7667
+ **Example**
7668
+ ```js
7669
+ // Resolve the merchant identifier from the service configuration:
7670
+ const result = await ApplePayOpenWalletButton.checkAvailability({
7671
+ public_key_or_access_token,
7672
+ service_id,
7673
+ env: 'sandbox',
7674
+ });
7675
+ if (result.available) {
7676
+ // Render the Apple Pay button (native sheet or cross-device QR, per has_native_session).
7677
+ } else {
7678
+ console.log('Unavailable:', result.reason, result.payment_credential_status);
7679
+ }
7680
+ ```
7681
+ **Example**
7682
+ ```js
7683
+ // Synchronous native-only fast check (no network / SDK load):
7684
+ const { has_native_session } = await ApplePayOpenWalletButton.checkAvailability({ sync: true });
7685
+ ```
7337
7686
  <a name="GooglePayOpenWalletButton" id="GooglePayOpenWalletButton" href="#GooglePayOpenWalletButton">&nbsp;</a>
7338
7687
 
7339
7688
  ## GooglePayOpenWalletButton ⇐ [<code>OpenWalletButtons</code>](#OpenWalletButtons)
@@ -7349,20 +7698,23 @@ if the service type does not match Google Pay.
7349
7698
 
7350
7699
  * [GooglePayOpenWalletButton](#GooglePayOpenWalletButton) ⇐ [<code>OpenWalletButtons</code>](#OpenWalletButtons)
7351
7700
  * [new GooglePayOpenWalletButton(selector, publicKeyOrAccessToken, serviceId, meta)](#new_GooglePayOpenWalletButton_new)
7352
- * [.load()](#OpenWalletButtons+load)
7353
- * [.enable()](#OpenWalletButtons+enable)
7354
- * [.disable()](#OpenWalletButtons+disable)
7355
- * [.setEnv(env, [alias])](#OpenWalletButtons+setEnv)
7356
- * [.setMeta(meta)](#OpenWalletButtons+setMeta)
7357
- * [.destroy()](#OpenWalletButtons+destroy)
7358
- * [.onClick(handler)](#OpenWalletButtons+onClick)
7359
- * [.onSuccess(handler)](#OpenWalletButtons+onSuccess)
7360
- * [.onUnavailable(handler)](#OpenWalletButtons+onUnavailable)
7361
- * [.onError(handler)](#OpenWalletButtons+onError)
7362
- * [.onCancel(handler)](#OpenWalletButtons+onCancel)
7363
- * [.onLoaded(handler)](#OpenWalletButtons+onLoaded)
7364
- * [.onShippingAddressChange(handler)](#OpenWalletButtons+onShippingAddressChange)
7365
- * [.onShippingOptionsChange(handler)](#OpenWalletButtons+onShippingOptionsChange)
7701
+ * _instance_
7702
+ * [.load()](#OpenWalletButtons+load)
7703
+ * [.enable()](#OpenWalletButtons+enable)
7704
+ * [.disable()](#OpenWalletButtons+disable)
7705
+ * [.setEnv(env, [alias])](#OpenWalletButtons+setEnv)
7706
+ * [.setMeta(meta)](#OpenWalletButtons+setMeta)
7707
+ * [.destroy()](#OpenWalletButtons+destroy)
7708
+ * [.onClick(handler)](#OpenWalletButtons+onClick)
7709
+ * [.onSuccess(handler)](#OpenWalletButtons+onSuccess)
7710
+ * [.onUnavailable(handler)](#OpenWalletButtons+onUnavailable)
7711
+ * [.onError(handler)](#OpenWalletButtons+onError)
7712
+ * [.onCancel(handler)](#OpenWalletButtons+onCancel)
7713
+ * [.onLoaded(handler)](#OpenWalletButtons+onLoaded)
7714
+ * [.onShippingAddressChange(handler)](#OpenWalletButtons+onShippingAddressChange)
7715
+ * [.onShippingOptionsChange(handler)](#OpenWalletButtons+onShippingOptionsChange)
7716
+ * _static_
7717
+ * [.checkAvailability([options])](#GooglePayOpenWalletButton.checkAvailability) ⇒ [<code>Promise.&lt;GooglePayAvailabilityResult&gt;</code>](#GooglePayAvailabilityResult)
7366
7718
 
7367
7719
  <a name="new_GooglePayOpenWalletButton_new" id="new_GooglePayOpenWalletButton_new" href="#new_GooglePayOpenWalletButton_new">&nbsp;</a>
7368
7720
 
@@ -7733,6 +8085,45 @@ button.onShippingOptionsChange((data) => {
7733
8085
  };
7734
8086
  });
7735
8087
  ```
8088
+ <a name="GooglePayOpenWalletButton.checkAvailability" id="GooglePayOpenWalletButton.checkAvailability" href="#GooglePayOpenWalletButton.checkAvailability">&nbsp;</a>
8089
+
8090
+ ### GooglePayOpenWalletButton.checkAvailability([options]) ⇒ [<code>Promise.&lt;GooglePayAvailabilityResult&gt;</code>](#GooglePayAvailabilityResult)
8091
+ Checks Google Pay availability **without instantiating the button** — the static
8092
+ availability entry point.
8093
+
8094
+ Loads the Google Pay JS SDK if needed, then runs `PaymentsClient.isReadyToPay()` using
8095
+ the **default** card configuration (a button instance with a custom `card_config` may
8096
+ produce a different result). All options are optional — unlike Apple Pay, Google Pay's
8097
+ readiness check does not require a merchant identifier; supplying `service_id` +
8098
+ `public_key_or_access_token` additionally validates that the service is a Google Pay service.
8099
+
8100
+ Pass `{ sync: true }` for a cheap, network-free check that only reports whether the
8101
+ Google Pay JS API is already present (see [GooglePayAvailabilityOptions.sync](GooglePayAvailabilityOptions.sync)).
8102
+
8103
+ **Kind**: static method of [<code>GooglePayOpenWalletButton</code>](#GooglePayOpenWalletButton)
8104
+ **Returns**: [<code>Promise.&lt;GooglePayAvailabilityResult&gt;</code>](#GooglePayAvailabilityResult) - The availability result.
8105
+
8106
+ | Param | Type | Description |
8107
+ | --- | --- | --- |
8108
+ | [options] | [<code>GooglePayAvailabilityOptions</code>](#GooglePayAvailabilityOptions) | Optional merchant context and mode. |
8109
+
8110
+ **Example**
8111
+ ```js
8112
+ // Simplest form — no merchant context needed:
8113
+ const result = await GooglePayOpenWalletButton.checkAvailability();
8114
+ if (result.available) {
8115
+ // Render the Google Pay button.
8116
+ }
8117
+ ```
8118
+ **Example**
8119
+ ```js
8120
+ // Validate the service is a Google Pay service while checking:
8121
+ const result = await GooglePayOpenWalletButton.checkAvailability({
8122
+ public_key_or_access_token,
8123
+ service_id,
8124
+ env: 'sandbox',
8125
+ });
8126
+ ```
7736
8127
  <a name="OpenWalletButtons" id="OpenWalletButtons" href="#OpenWalletButtons">&nbsp;</a>
7737
8128
 
7738
8129
  ## *OpenWalletButtons*