@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.
- package/README.md +422 -31
- package/bundles/index.cjs +1972 -532
- package/bundles/index.cjs.d.ts +192 -8
- package/bundles/index.mjs +1972 -532
- package/bundles/index.mjs.d.ts +192 -8
- package/bundles/types/helper/browser.d.ts.map +1 -1
- package/bundles/types/helper/element-id.d.ts +3 -1
- package/bundles/types/helper/element-id.d.ts.map +1 -1
- package/bundles/types/helper/uuid.d.ts.map +1 -1
- package/bundles/types/open-wallets/apple-pay-open-wallet-button.d.ts +41 -0
- package/bundles/types/open-wallets/apple-pay-open-wallet-button.d.ts.map +1 -1
- package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts +10 -0
- package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts.map +1 -1
- package/bundles/types/open-wallets/base/service-config-cache.d.ts +23 -0
- package/bundles/types/open-wallets/base/service-config-cache.d.ts.map +1 -0
- package/bundles/types/open-wallets/google-pay-open-wallet-button.d.ts +33 -1
- package/bundles/types/open-wallets/google-pay-open-wallet-button.d.ts.map +1 -1
- package/bundles/types/open-wallets/index.d.ts +82 -1
- package/bundles/types/open-wallets/index.d.ts.map +1 -1
- package/bundles/types/open-wallets/interfaces/apple-pay/apple-pay-availability.interface.d.ts +41 -0
- package/bundles/types/open-wallets/interfaces/apple-pay/apple-pay-availability.interface.d.ts.map +1 -0
- package/bundles/types/open-wallets/interfaces/apple-pay/index.d.ts +1 -0
- package/bundles/types/open-wallets/interfaces/apple-pay/index.d.ts.map +1 -1
- package/bundles/types/open-wallets/interfaces/google-pay/google-pay-availability.interface.d.ts +25 -0
- package/bundles/types/open-wallets/interfaces/google-pay/google-pay-availability.interface.d.ts.map +1 -0
- package/bundles/types/open-wallets/interfaces/google-pay/index.d.ts +1 -0
- package/bundles/types/open-wallets/interfaces/google-pay/index.d.ts.map +1 -1
- package/bundles/types/open-wallets/interfaces/index.d.ts +3 -0
- package/bundles/types/open-wallets/interfaces/index.d.ts.map +1 -1
- package/bundles/types/open-wallets/interfaces/open-wallet-availability.interface.d.ts +31 -0
- package/bundles/types/open-wallets/interfaces/open-wallet-availability.interface.d.ts.map +1 -0
- package/bundles/types/open-wallets/services/apple-pay/apple-pay-availability.d.ts +58 -0
- package/bundles/types/open-wallets/services/apple-pay/apple-pay-availability.d.ts.map +1 -0
- package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts +8 -10
- package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts.map +1 -1
- package/bundles/types/open-wallets/services/apple-pay/index.d.ts +1 -0
- package/bundles/types/open-wallets/services/apple-pay/index.d.ts.map +1 -1
- package/bundles/types/open-wallets/services/google-pay/google-pay-availability.d.ts +53 -0
- package/bundles/types/open-wallets/services/google-pay/google-pay-availability.d.ts.map +1 -0
- package/bundles/types/open-wallets/services/google-pay/google-pay.open-wallet.service.d.ts.map +1 -1
- package/bundles/types/open-wallets/services/google-pay/index.d.ts +1 -0
- package/bundles/types/open-wallets/services/google-pay/index.d.ts.map +1 -1
- package/bundles/widget.umd.js +1972 -532
- package/bundles/widget.umd.js.d.ts +192 -8
- package/bundles/widget.umd.js.min.d.ts +192 -8
- package/bundles/widget.umd.min.js +1 -1
- package/docs/open-wallet-buttons-examples.md +170 -2
- package/docs/open-wallet-buttons.md +252 -29
- package/package.json +10 -7
- package/slate.md +170 -2
package/slate.md
CHANGED
|
@@ -2147,6 +2147,106 @@ Bear in mind that you must set an environment before calling `button.load()`.
|
|
|
2147
2147
|
button.setEnv('sandbox');
|
|
2148
2148
|
```
|
|
2149
2149
|
|
|
2150
|
+
### Checking availability before instantiation (static)
|
|
2151
|
+
|
|
2152
|
+
`ApplePayOpenWalletButton.checkAvailability(options)` is a **static** method so you can decide
|
|
2153
|
+
whether to show an Apple Pay option — or which payment method to default to — **without
|
|
2154
|
+
instantiating the button** and waiting for the `onUnavailable` event.
|
|
2155
|
+
|
|
2156
|
+
> **Apple Pay is no longer Safari-only.** Since iOS 16 (third-party mobile browsers) and the
|
|
2157
|
+
> iOS 18 / 2025 desktop rollout, Apple Pay also works in Chrome, Edge and Firefox — including
|
|
2158
|
+
> on Windows — via a **cross-device QR handoff**: the user scans a code and completes the
|
|
2159
|
+
> payment on their iPhone. Because the paying device is often *not* the browsing device, the
|
|
2160
|
+
> only authoritative availability signal is the async `checkAvailability()`.
|
|
2161
|
+
> `applePayCapabilities()` is what Apple recommends; `canMakePayments()` is just a coarse
|
|
2162
|
+
> local-device hint. See
|
|
2163
|
+
> [Apple — Checking for Apple Pay availability](https://developer.apple.com/documentation/applepayontheweb/checking-for-apple-pay-availability).
|
|
2164
|
+
|
|
2165
|
+
#### `ApplePayOpenWalletButton.checkAvailability(options)`
|
|
2166
|
+
|
|
2167
|
+
The single, authoritative, cross-browser-aware check. It resolves the merchant identifier,
|
|
2168
|
+
loads Apple's web SDK if needed, and queries `ApplePaySession.applePayCapabilities()`.
|
|
2169
|
+
|
|
2170
|
+
You may supply the merchant context in either of two ways:
|
|
2171
|
+
|
|
2172
|
+
```javascript
|
|
2173
|
+
// 1) Lightest path — no network — when you already know the Apple merchant identifier:
|
|
2174
|
+
const result = await paydock.ApplePayOpenWalletButton.checkAvailability({
|
|
2175
|
+
merchant_id: 'merchant.com.example',
|
|
2176
|
+
});
|
|
2177
|
+
|
|
2178
|
+
// 2) Resolve the merchant identifier from the service configuration (fetched & cached):
|
|
2179
|
+
const result = await paydock.ApplePayOpenWalletButton.checkAvailability({
|
|
2180
|
+
public_key_or_access_token: publicKeyOrAccessToken,
|
|
2181
|
+
service_id: serviceId,
|
|
2182
|
+
env: 'sandbox',
|
|
2183
|
+
// Optional — which device statuses count as "available".
|
|
2184
|
+
// Defaults to ['credentials_available', 'credentials_status_unknown'].
|
|
2185
|
+
apple_pay_capabilities: ['credentials_available', 'credentials_status_unknown'],
|
|
2186
|
+
});
|
|
2187
|
+
```
|
|
2188
|
+
|
|
2189
|
+
**Result shape (`ApplePayAvailabilityResult`):**
|
|
2190
|
+
|
|
2191
|
+
```javascript
|
|
2192
|
+
{
|
|
2193
|
+
available: true, // verdict vs the allowed capability set
|
|
2194
|
+
supported: true, // Apple Pay usable here AT ALL (incl. cross-device QR)
|
|
2195
|
+
has_native_session: false, // native same-device session present (canMakePayments)
|
|
2196
|
+
payment_credential_status: // OUTPUT — the device's reported status
|
|
2197
|
+
'paymentCredentialStatusUnknown',
|
|
2198
|
+
reason: undefined, // set when not available, see below
|
|
2199
|
+
}
|
|
2200
|
+
```
|
|
2201
|
+
|
|
2202
|
+
**Inferring the transport (Apple does not expose it directly):**
|
|
2203
|
+
- `available && has_native_session` ⇒ **native** Apple Pay sheet is likely (Safari on an Apple device).
|
|
2204
|
+
- `available && !has_native_session` ⇒ **cross-device / QR** handoff is likely (e.g. Chrome on desktop).
|
|
2205
|
+
|
|
2206
|
+
`payment_credential_status` is the device's actual status:
|
|
2207
|
+
`'paymentCredentialsAvailable'`, `'paymentCredentialStatusUnknown'`,
|
|
2208
|
+
`'paymentCredentialsUnavailable'`, or `'applePayUnsupported'`. **Third-party / desktop
|
|
2209
|
+
browsers normally report `paymentCredentialStatusUnknown`** (Apple can't see the remote
|
|
2210
|
+
iPhone's cards until the user scans the QR), which is why the default allowed set includes it.
|
|
2211
|
+
|
|
2212
|
+
The `apple_pay_capabilities` **input** maps to those statuses
|
|
2213
|
+
(`credentials_available` → `paymentCredentialsAvailable`,
|
|
2214
|
+
`credentials_status_unknown` → `paymentCredentialStatusUnknown`,
|
|
2215
|
+
`credentials_unavailable` → `paymentCredentialsUnavailable`) and decides which ones make
|
|
2216
|
+
`available` true. When omitted, **both** `paymentCredentialsAvailable` and
|
|
2217
|
+
`paymentCredentialStatusUnknown` count — narrow it to `['credentials_available']` only if you
|
|
2218
|
+
want to require a confirmed local card (this will hide the button in cross-browser/QR contexts).
|
|
2219
|
+
|
|
2220
|
+
When `available` is `false`, `reason` is one of: `'unsupported_browser'`,
|
|
2221
|
+
`'missing_merchant_id'`, `'service_type_mismatch'`, `'config_fetch_failed'`,
|
|
2222
|
+
`'sdk_load_failed'`, `'query_failed'`, `'no_credentials'`, or `'no_native_session'`
|
|
2223
|
+
(only from the synchronous check below).
|
|
2224
|
+
|
|
2225
|
+
```javascript
|
|
2226
|
+
const result = await paydock.ApplePayOpenWalletButton.checkAvailability({ merchant_id: merchantId });
|
|
2227
|
+
if (result.available) {
|
|
2228
|
+
renderApplePayButton();
|
|
2229
|
+
} else {
|
|
2230
|
+
console.log('Apple Pay unavailable:', result.reason, result.payment_credential_status);
|
|
2231
|
+
}
|
|
2232
|
+
```
|
|
2233
|
+
|
|
2234
|
+
**Synchronous native-only fast check (`sync: true`).** Pass `{ sync: true }` for a cheap,
|
|
2235
|
+
network-free pre-check that resolves immediately — it runs only the native same-device check
|
|
2236
|
+
(`window.ApplePaySession` + `canMakePayments()`), with no merchant resolution, SDK load, or
|
|
2237
|
+
`applePayCapabilities()` query. In this mode `available` reflects the native session only and
|
|
2238
|
+
`payment_credential_status` is `undefined`. It is a Safari-oriented hint and is **not**
|
|
2239
|
+
authoritative for cross-browser / QR availability (which require the full async check above).
|
|
2240
|
+
|
|
2241
|
+
```javascript
|
|
2242
|
+
const { has_native_session } = await paydock.ApplePayOpenWalletButton.checkAvailability({
|
|
2243
|
+
sync: true,
|
|
2244
|
+
});
|
|
2245
|
+
if (has_native_session) {
|
|
2246
|
+
// Native Apple Pay is ready on this device (Safari fast path).
|
|
2247
|
+
}
|
|
2248
|
+
```
|
|
2249
|
+
|
|
2150
2250
|
### Full Apple Pay example
|
|
2151
2251
|
|
|
2152
2252
|
```html
|
|
@@ -2565,6 +2665,58 @@ The GooglePayOpenWalletButton constructor accepts the following parameters:
|
|
|
2565
2665
|
|
|
2566
2666
|
> **Note:** Required meta fields (`amount`, `currency`, `country`) are validated automatically by the `GooglePayOpenWalletButton` class. You do not need to specify them manually.
|
|
2567
2667
|
|
|
2668
|
+
### Checking availability before instantiation (static)
|
|
2669
|
+
|
|
2670
|
+
`GooglePayOpenWalletButton.checkAvailability(options)` is a **static** method that reports
|
|
2671
|
+
whether Google Pay can be used in the current context **without instantiating the button**.
|
|
2672
|
+
It loads the Google Pay JS SDK if needed and runs `PaymentsClient.isReadyToPay()`.
|
|
2673
|
+
|
|
2674
|
+
Unlike Apple Pay, **all options are optional** — Google Pay's readiness check does not
|
|
2675
|
+
require a merchant identifier. Supplying `publicKeyOrAccessToken` + `serviceId` additionally
|
|
2676
|
+
validates that the service is a Google Pay service (and resolves the merchant id).
|
|
2677
|
+
|
|
2678
|
+
```javascript
|
|
2679
|
+
// Simplest form — no merchant context needed:
|
|
2680
|
+
const result = await paydock.GooglePayOpenWalletButton.checkAvailability();
|
|
2681
|
+
|
|
2682
|
+
// Or validate the service is a Google Pay service while checking:
|
|
2683
|
+
const result = await paydock.GooglePayOpenWalletButton.checkAvailability({
|
|
2684
|
+
public_key_or_access_token: publicKeyOrAccessToken,
|
|
2685
|
+
service_id: serviceId,
|
|
2686
|
+
env: 'sandbox',
|
|
2687
|
+
});
|
|
2688
|
+
```
|
|
2689
|
+
|
|
2690
|
+
**Result shape (`GooglePayAvailabilityResult`):**
|
|
2691
|
+
|
|
2692
|
+
```javascript
|
|
2693
|
+
{
|
|
2694
|
+
available: true, // isReadyToPay().result — ready to pay in this context
|
|
2695
|
+
supported: true, // the Google Pay JS API is present and the query ran
|
|
2696
|
+
payment_method_present: true, // OUTPUT — whether the buyer already has a usable card
|
|
2697
|
+
reason: undefined, // set when not available, see below
|
|
2698
|
+
}
|
|
2699
|
+
```
|
|
2700
|
+
|
|
2701
|
+
> **Note:** the static check uses the **default** card configuration (standard auth methods
|
|
2702
|
+
> and card networks). A button instance configured with a custom `card_config` may produce a
|
|
2703
|
+
> different result.
|
|
2704
|
+
|
|
2705
|
+
When `available` is `false`, `reason` is one of: `'unsupported_browser'`,
|
|
2706
|
+
`'service_type_mismatch'`, `'config_fetch_failed'`, `'sdk_load_failed'`, `'query_failed'`,
|
|
2707
|
+
`'no_payment_method'`, or `'api_not_loaded'` (only from the synchronous check below).
|
|
2708
|
+
|
|
2709
|
+
**Synchronous fast check (`sync: true`).** Google Pay has no synchronous device/card
|
|
2710
|
+
capability API, so `{ sync: true }` only reports whether the Google Pay JS API is already
|
|
2711
|
+
present in the page — it does **not** run `isReadyToPay()`:
|
|
2712
|
+
|
|
2713
|
+
```javascript
|
|
2714
|
+
const { available } = await paydock.GooglePayOpenWalletButton.checkAvailability({
|
|
2715
|
+
sync: true,
|
|
2716
|
+
});
|
|
2717
|
+
// `available` here means "the Google Pay JS API script is loaded", not "ready to pay".
|
|
2718
|
+
```
|
|
2719
|
+
|
|
2568
2720
|
### Full Google Pay Example
|
|
2569
2721
|
|
|
2570
2722
|
```html
|
|
@@ -2707,12 +2859,28 @@ Both `ApplePayOpenWalletButton` and `GooglePayOpenWalletButton` share the same e
|
|
|
2707
2859
|
|
|
2708
2860
|
### Checking for button availability
|
|
2709
2861
|
|
|
2710
|
-
|
|
2862
|
+
There are two ways to know whether a wallet is available:
|
|
2863
|
+
|
|
2864
|
+
**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.
|
|
2711
2865
|
|
|
2712
2866
|
```javascript
|
|
2713
2867
|
button.onUnavailable(({ data }) => console.log("No wallet button available", data));
|
|
2714
2868
|
```
|
|
2715
2869
|
|
|
2870
|
+
**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).
|
|
2871
|
+
|
|
2872
|
+
```javascript
|
|
2873
|
+
// Apple Pay
|
|
2874
|
+
const apple = await paydock.ApplePayOpenWalletButton.checkAvailability({ merchant_id: merchantId });
|
|
2875
|
+
|
|
2876
|
+
// Google Pay (merchant context optional)
|
|
2877
|
+
const google = await paydock.GooglePayOpenWalletButton.checkAvailability();
|
|
2878
|
+
|
|
2879
|
+
if (apple.available || google.available) {
|
|
2880
|
+
// Show a wallet payment option.
|
|
2881
|
+
}
|
|
2882
|
+
```
|
|
2883
|
+
|
|
2716
2884
|
### Service type validation
|
|
2717
2885
|
|
|
2718
2886
|
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`:
|
|
@@ -2874,7 +3042,7 @@ A full description of the [ApplePayOpenWalletMeta](#ApplePayOpenWalletMeta) prop
|
|
|
2874
3042
|
- `request_shipping?: boolean`: Enable shipping address collection
|
|
2875
3043
|
- `shipping_options?: IApplePayShippingOption[]`: Array of shipping options
|
|
2876
3044
|
- `show_billing_address?: boolean`: Show billing address fields
|
|
2877
|
-
- `apple_pay_capabilities?: string[]`: Device
|
|
3045
|
+
- `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.
|
|
2878
3046
|
- `merchant_capabilities?: string[]`: Merchant capabilities
|
|
2879
3047
|
- `supported_networks?: string[]`: Supported payment networks
|
|
2880
3048
|
- `required_billing_contact_fields?: string[]`: Required billing contact fields
|