@schematichq/schematic-components 2.27.1 → 2.28.0
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 +91 -0
- package/dist/schematic-components.browser.cjs.js +39 -5
- package/dist/schematic-components.browser.esm.js +39 -5
- package/dist/schematic-components.cjs.js +39 -5
- package/dist/schematic-components.d.ts +22 -0
- package/dist/schematic-components.esm.js +39 -5
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -93,6 +93,97 @@ notice that appears in the same spot.
|
|
|
93
93
|
The Plans and add-ons available to the checkout flows must be live in your
|
|
94
94
|
Schematic account [Catalog configuration](https://docs.schematichq.com/catalog/overview).
|
|
95
95
|
|
|
96
|
+
To offer an add-on that isn't live, see
|
|
97
|
+
[Rehydrating With Params](#rehydrating-with-params).
|
|
98
|
+
|
|
99
|
+
## Rehydrating With Params
|
|
100
|
+
|
|
101
|
+
We provide a function `rehydrateWithParams` for re-fetching the embed's data
|
|
102
|
+
with params the standard load doesn't send. Like `initializeWithPlan`, it's
|
|
103
|
+
suitable for click handlers and must be extracted from the library's embedded
|
|
104
|
+
context.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
const { rehydrateWithParams } = useEmbed();
|
|
108
|
+
|
|
109
|
+
const data = await rehydrateWithParams({ includeAddOnIds: ['plan_BQx8kWjSx4'] });
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
It re-fetches the component your `SchematicEmbed` loaded and applies the
|
|
113
|
+
result in place:
|
|
114
|
+
|
|
115
|
+
- The embed's data updates without the embed showing its loading state.
|
|
116
|
+
- It isn't debounced: every call makes a request, and the promise resolves
|
|
117
|
+
with the new data once it's applied.
|
|
118
|
+
- The promise rejects if the request fails, leaving the embed's data and
|
|
119
|
+
error state as they were, so your UI decides how to handle it. It also
|
|
120
|
+
rejects if no `SchematicEmbed` has loaded yet.
|
|
121
|
+
- The params apply to this fetch only. The embed's next refresh, such as the
|
|
122
|
+
one after a purchase, goes back to the standard load.
|
|
123
|
+
|
|
124
|
+
Await it before anything that depends on the new data, such as opening a
|
|
125
|
+
checkout with `initializeWithPlan`.
|
|
126
|
+
|
|
127
|
+
### Params
|
|
128
|
+
|
|
129
|
+
| Param | Type | Effect |
|
|
130
|
+
| ----------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
131
|
+
| `includeAddOnIds` | `string[]` | Add-ons to offer in the checkout even though they aren't live. Each must be an add-on with a billing product; any other ID is left out, with a console warning. |
|
|
132
|
+
|
|
133
|
+
### Example: selling an add-on that isn't live
|
|
134
|
+
|
|
135
|
+
Say your backend creates an add-on for a single purchase, such as a one-off
|
|
136
|
+
service, and deletes it afterward, so it's never live in your catalog. A "Buy
|
|
137
|
+
now" button can create it, include it, and open the checkout with it
|
|
138
|
+
selected:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { useState } from 'react';
|
|
142
|
+
import { useEmbed } from '@schematichq/schematic-components';
|
|
143
|
+
|
|
144
|
+
function BuyServiceButton({ serviceId }: { serviceId: string }) {
|
|
145
|
+
const { rehydrateWithParams, initializeWithPlan } = useEmbed();
|
|
146
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
147
|
+
const [error, setError] = useState<string>();
|
|
148
|
+
|
|
149
|
+
const handleClick = async () => {
|
|
150
|
+
setIsLoading(true);
|
|
151
|
+
setError(undefined);
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
// Your backend creates the add-on and returns its Schematic ID
|
|
155
|
+
const { addOnId } = await createServiceAddOn(serviceId);
|
|
156
|
+
|
|
157
|
+
// Fetch the embed's data again, this time with the add-on in it
|
|
158
|
+
await rehydrateWithParams({ includeAddOnIds: [addOnId] });
|
|
159
|
+
|
|
160
|
+
// Open the checkout. Including an add-on only makes it available;
|
|
161
|
+
// list it in `addOnIds` to pre-select it.
|
|
162
|
+
initializeWithPlan({
|
|
163
|
+
addOnIds: [addOnId],
|
|
164
|
+
skipped: { addOnStage: true }, // it's already chosen
|
|
165
|
+
});
|
|
166
|
+
} catch {
|
|
167
|
+
setError("We couldn't start the checkout. Please try again.");
|
|
168
|
+
} finally {
|
|
169
|
+
setIsLoading(false);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<>
|
|
175
|
+
<button onClick={handleClick} disabled={isLoading}>
|
|
176
|
+
{isLoading ? 'Preparing checkout…' : 'Buy now'}
|
|
177
|
+
</button>
|
|
178
|
+
{error && <p role="alert">{error}</p>}
|
|
179
|
+
</>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The add-on still has to be compatible with the selected plan and priced in
|
|
185
|
+
the checkout's currency and billing period to appear.
|
|
186
|
+
|
|
96
187
|
## Programmatic Unsubscribe
|
|
97
188
|
|
|
98
189
|
We provide a function `requestUnsubscribe` for starting the unsubscribe flow
|
|
@@ -2028,6 +2028,7 @@ var initialContext = {
|
|
|
2028
2028
|
hydrate: stub,
|
|
2029
2029
|
hydrateComponent: stub,
|
|
2030
2030
|
hydrateExternal: stub,
|
|
2031
|
+
rehydrateWithParams: stub,
|
|
2031
2032
|
getUpcomingInvoice: stub,
|
|
2032
2033
|
getCustomerBalance: stub,
|
|
2033
2034
|
listInvoices: stub,
|
|
@@ -7567,7 +7568,8 @@ function HydrateComponentParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
7567
7568
|
return json;
|
|
7568
7569
|
}
|
|
7569
7570
|
return {
|
|
7570
|
-
catalogId: json["catalog_id"] == null ? void 0 : json["catalog_id"]
|
|
7571
|
+
catalogId: json["catalog_id"] == null ? void 0 : json["catalog_id"],
|
|
7572
|
+
includeAddOnIds: json["include_add_on_ids"] == null ? void 0 : json["include_add_on_ids"]
|
|
7571
7573
|
};
|
|
7572
7574
|
}
|
|
7573
7575
|
|
|
@@ -8599,6 +8601,9 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
8599
8601
|
if (requestParameters["catalogId"] != null) {
|
|
8600
8602
|
queryParameters["catalog_id"] = requestParameters["catalogId"];
|
|
8601
8603
|
}
|
|
8604
|
+
if (requestParameters["includeAddOnIds"] != null) {
|
|
8605
|
+
queryParameters["include_add_on_ids"] = requestParameters["includeAddOnIds"];
|
|
8606
|
+
}
|
|
8602
8607
|
const headerParameters = {};
|
|
8603
8608
|
if (this.configuration && this.configuration.apiKey) {
|
|
8604
8609
|
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
@@ -15509,7 +15514,7 @@ var reducer = (state, action) => {
|
|
|
15509
15514
|
// src/context/EmbedProvider.tsx
|
|
15510
15515
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
15511
15516
|
var getCustomHeaders = (sessionId) => ({
|
|
15512
|
-
"X-Schematic-Components-Version": "2.
|
|
15517
|
+
"X-Schematic-Components-Version": "2.28.0",
|
|
15513
15518
|
"X-Schematic-Session-ID": sessionId
|
|
15514
15519
|
});
|
|
15515
15520
|
var normalizeCurrencyFilter = (filter2) => {
|
|
@@ -15707,6 +15712,34 @@ var EmbedProvider = ({
|
|
|
15707
15712
|
),
|
|
15708
15713
|
[hydrateExternal]
|
|
15709
15714
|
);
|
|
15715
|
+
const rehydrateWithParams = (0, import_react5.useCallback)(
|
|
15716
|
+
async (params) => {
|
|
15717
|
+
const componentId = state.data?.component?.id;
|
|
15718
|
+
if (!componentId || !checkoutApi) {
|
|
15719
|
+
throw new Error(
|
|
15720
|
+
"[Schematic] `rehydrateWithParams` needs a `SchematicEmbed` that has loaded."
|
|
15721
|
+
);
|
|
15722
|
+
}
|
|
15723
|
+
const response = await checkoutApi.hydrateComponent({
|
|
15724
|
+
componentId,
|
|
15725
|
+
includeAddOnIds: params.includeAddOnIds
|
|
15726
|
+
});
|
|
15727
|
+
const returnedIds = new Set(
|
|
15728
|
+
response.data.activeAddOns.map((addOn) => addOn.id)
|
|
15729
|
+
);
|
|
15730
|
+
const missingIds = (params.includeAddOnIds ?? []).filter(
|
|
15731
|
+
(id) => !returnedIds.has(id)
|
|
15732
|
+
);
|
|
15733
|
+
if (missingIds.length > 0) {
|
|
15734
|
+
console.warn(
|
|
15735
|
+
`[Schematic] These included add-ons were left out because each must be an add-on with a billing product: ${missingIds.join(", ")}`
|
|
15736
|
+
);
|
|
15737
|
+
}
|
|
15738
|
+
dispatch({ type: "HYDRATE_COMPONENT", data: response.data });
|
|
15739
|
+
return response.data;
|
|
15740
|
+
},
|
|
15741
|
+
[checkoutApi, state.data?.component?.id]
|
|
15742
|
+
);
|
|
15710
15743
|
const createSetupIntent = (0, import_react5.useCallback)(async () => {
|
|
15711
15744
|
return checkoutApi?.createSetupIntent();
|
|
15712
15745
|
}, [checkoutApi]);
|
|
@@ -16050,6 +16083,7 @@ var EmbedProvider = ({
|
|
|
16050
16083
|
hydrate: debouncedHydrate,
|
|
16051
16084
|
hydrateComponent: debouncedHydrateComponent,
|
|
16052
16085
|
hydrateExternal: debouncedHydrateExternal,
|
|
16086
|
+
rehydrateWithParams,
|
|
16053
16087
|
createSetupIntent: debouncedCreateSetupIntent,
|
|
16054
16088
|
updatePaymentMethod: debouncedUpdatePaymentMethod,
|
|
16055
16089
|
deletePaymentMethod: debouncedDeletePaymentMethod,
|
|
@@ -26235,7 +26269,7 @@ PaymentMethod.displayName = "PaymentMethod";
|
|
|
26235
26269
|
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
26236
26270
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
26237
26271
|
|
|
26238
|
-
// node_modules/.pnpm/@stripe+stripe-js@9.
|
|
26272
|
+
// node_modules/.pnpm/@stripe+stripe-js@9.17.0/node_modules/@stripe/stripe-js/dist/index.mjs
|
|
26239
26273
|
function _typeof(obj) {
|
|
26240
26274
|
"@babel/helpers - typeof";
|
|
26241
26275
|
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
@@ -26289,7 +26323,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
26289
26323
|
}
|
|
26290
26324
|
stripe._registerWrapper({
|
|
26291
26325
|
name: "stripe-js",
|
|
26292
|
-
version: "9.
|
|
26326
|
+
version: "9.17.0",
|
|
26293
26327
|
startTime
|
|
26294
26328
|
});
|
|
26295
26329
|
};
|
|
@@ -26367,7 +26401,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
26367
26401
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
26368
26402
|
var expectedVersion = RELEASE_TRAIN;
|
|
26369
26403
|
if (isTestKey && version !== expectedVersion) {
|
|
26370
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.
|
|
26404
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.17.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
26371
26405
|
}
|
|
26372
26406
|
var stripe = maybeStripe.apply(void 0, args);
|
|
26373
26407
|
registerWrapper(stripe, startTime);
|
|
@@ -1932,6 +1932,7 @@ var initialContext = {
|
|
|
1932
1932
|
hydrate: stub,
|
|
1933
1933
|
hydrateComponent: stub,
|
|
1934
1934
|
hydrateExternal: stub,
|
|
1935
|
+
rehydrateWithParams: stub,
|
|
1935
1936
|
getUpcomingInvoice: stub,
|
|
1936
1937
|
getCustomerBalance: stub,
|
|
1937
1938
|
listInvoices: stub,
|
|
@@ -7471,7 +7472,8 @@ function HydrateComponentParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
7471
7472
|
return json;
|
|
7472
7473
|
}
|
|
7473
7474
|
return {
|
|
7474
|
-
catalogId: json["catalog_id"] == null ? void 0 : json["catalog_id"]
|
|
7475
|
+
catalogId: json["catalog_id"] == null ? void 0 : json["catalog_id"],
|
|
7476
|
+
includeAddOnIds: json["include_add_on_ids"] == null ? void 0 : json["include_add_on_ids"]
|
|
7475
7477
|
};
|
|
7476
7478
|
}
|
|
7477
7479
|
|
|
@@ -8503,6 +8505,9 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
8503
8505
|
if (requestParameters["catalogId"] != null) {
|
|
8504
8506
|
queryParameters["catalog_id"] = requestParameters["catalogId"];
|
|
8505
8507
|
}
|
|
8508
|
+
if (requestParameters["includeAddOnIds"] != null) {
|
|
8509
|
+
queryParameters["include_add_on_ids"] = requestParameters["includeAddOnIds"];
|
|
8510
|
+
}
|
|
8506
8511
|
const headerParameters = {};
|
|
8507
8512
|
if (this.configuration && this.configuration.apiKey) {
|
|
8508
8513
|
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
@@ -15420,7 +15425,7 @@ var reducer = (state, action) => {
|
|
|
15420
15425
|
// src/context/EmbedProvider.tsx
|
|
15421
15426
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
15422
15427
|
var getCustomHeaders = (sessionId) => ({
|
|
15423
|
-
"X-Schematic-Components-Version": "2.
|
|
15428
|
+
"X-Schematic-Components-Version": "2.28.0",
|
|
15424
15429
|
"X-Schematic-Session-ID": sessionId
|
|
15425
15430
|
});
|
|
15426
15431
|
var normalizeCurrencyFilter = (filter2) => {
|
|
@@ -15618,6 +15623,34 @@ var EmbedProvider = ({
|
|
|
15618
15623
|
),
|
|
15619
15624
|
[hydrateExternal]
|
|
15620
15625
|
);
|
|
15626
|
+
const rehydrateWithParams = useCallback2(
|
|
15627
|
+
async (params) => {
|
|
15628
|
+
const componentId = state.data?.component?.id;
|
|
15629
|
+
if (!componentId || !checkoutApi) {
|
|
15630
|
+
throw new Error(
|
|
15631
|
+
"[Schematic] `rehydrateWithParams` needs a `SchematicEmbed` that has loaded."
|
|
15632
|
+
);
|
|
15633
|
+
}
|
|
15634
|
+
const response = await checkoutApi.hydrateComponent({
|
|
15635
|
+
componentId,
|
|
15636
|
+
includeAddOnIds: params.includeAddOnIds
|
|
15637
|
+
});
|
|
15638
|
+
const returnedIds = new Set(
|
|
15639
|
+
response.data.activeAddOns.map((addOn) => addOn.id)
|
|
15640
|
+
);
|
|
15641
|
+
const missingIds = (params.includeAddOnIds ?? []).filter(
|
|
15642
|
+
(id) => !returnedIds.has(id)
|
|
15643
|
+
);
|
|
15644
|
+
if (missingIds.length > 0) {
|
|
15645
|
+
console.warn(
|
|
15646
|
+
`[Schematic] These included add-ons were left out because each must be an add-on with a billing product: ${missingIds.join(", ")}`
|
|
15647
|
+
);
|
|
15648
|
+
}
|
|
15649
|
+
dispatch({ type: "HYDRATE_COMPONENT", data: response.data });
|
|
15650
|
+
return response.data;
|
|
15651
|
+
},
|
|
15652
|
+
[checkoutApi, state.data?.component?.id]
|
|
15653
|
+
);
|
|
15621
15654
|
const createSetupIntent = useCallback2(async () => {
|
|
15622
15655
|
return checkoutApi?.createSetupIntent();
|
|
15623
15656
|
}, [checkoutApi]);
|
|
@@ -15961,6 +15994,7 @@ var EmbedProvider = ({
|
|
|
15961
15994
|
hydrate: debouncedHydrate,
|
|
15962
15995
|
hydrateComponent: debouncedHydrateComponent,
|
|
15963
15996
|
hydrateExternal: debouncedHydrateExternal,
|
|
15997
|
+
rehydrateWithParams,
|
|
15964
15998
|
createSetupIntent: debouncedCreateSetupIntent,
|
|
15965
15999
|
updatePaymentMethod: debouncedUpdatePaymentMethod,
|
|
15966
16000
|
deletePaymentMethod: debouncedDeletePaymentMethod,
|
|
@@ -26177,7 +26211,7 @@ PaymentMethod.displayName = "PaymentMethod";
|
|
|
26177
26211
|
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
26178
26212
|
import { Elements } from "@stripe/react-stripe-js";
|
|
26179
26213
|
|
|
26180
|
-
// node_modules/.pnpm/@stripe+stripe-js@9.
|
|
26214
|
+
// node_modules/.pnpm/@stripe+stripe-js@9.17.0/node_modules/@stripe/stripe-js/dist/index.mjs
|
|
26181
26215
|
function _typeof(obj) {
|
|
26182
26216
|
"@babel/helpers - typeof";
|
|
26183
26217
|
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
@@ -26231,7 +26265,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
26231
26265
|
}
|
|
26232
26266
|
stripe._registerWrapper({
|
|
26233
26267
|
name: "stripe-js",
|
|
26234
|
-
version: "9.
|
|
26268
|
+
version: "9.17.0",
|
|
26235
26269
|
startTime
|
|
26236
26270
|
});
|
|
26237
26271
|
};
|
|
@@ -26309,7 +26343,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
26309
26343
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
26310
26344
|
var expectedVersion = RELEASE_TRAIN;
|
|
26311
26345
|
if (isTestKey && version !== expectedVersion) {
|
|
26312
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.
|
|
26346
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.17.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
26313
26347
|
}
|
|
26314
26348
|
var stripe = maybeStripe.apply(void 0, args);
|
|
26315
26349
|
registerWrapper(stripe, startTime);
|
|
@@ -3796,6 +3796,7 @@ var initialContext = {
|
|
|
3796
3796
|
hydrate: stub,
|
|
3797
3797
|
hydrateComponent: stub,
|
|
3798
3798
|
hydrateExternal: stub,
|
|
3799
|
+
rehydrateWithParams: stub,
|
|
3799
3800
|
getUpcomingInvoice: stub,
|
|
3800
3801
|
getCustomerBalance: stub,
|
|
3801
3802
|
listInvoices: stub,
|
|
@@ -7923,7 +7924,8 @@ function HydrateComponentParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
7923
7924
|
return json;
|
|
7924
7925
|
}
|
|
7925
7926
|
return {
|
|
7926
|
-
catalogId: json["catalog_id"] == null ? void 0 : json["catalog_id"]
|
|
7927
|
+
catalogId: json["catalog_id"] == null ? void 0 : json["catalog_id"],
|
|
7928
|
+
includeAddOnIds: json["include_add_on_ids"] == null ? void 0 : json["include_add_on_ids"]
|
|
7927
7929
|
};
|
|
7928
7930
|
}
|
|
7929
7931
|
|
|
@@ -8955,6 +8957,9 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
8955
8957
|
if (requestParameters["catalogId"] != null) {
|
|
8956
8958
|
queryParameters["catalog_id"] = requestParameters["catalogId"];
|
|
8957
8959
|
}
|
|
8960
|
+
if (requestParameters["includeAddOnIds"] != null) {
|
|
8961
|
+
queryParameters["include_add_on_ids"] = requestParameters["includeAddOnIds"];
|
|
8962
|
+
}
|
|
8958
8963
|
const headerParameters = {};
|
|
8959
8964
|
if (this.configuration && this.configuration.apiKey) {
|
|
8960
8965
|
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
@@ -15866,7 +15871,7 @@ var reducer = (state, action) => {
|
|
|
15866
15871
|
// src/context/EmbedProvider.tsx
|
|
15867
15872
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
15868
15873
|
var getCustomHeaders = (sessionId) => ({
|
|
15869
|
-
"X-Schematic-Components-Version": "2.
|
|
15874
|
+
"X-Schematic-Components-Version": "2.28.0",
|
|
15870
15875
|
"X-Schematic-Session-ID": sessionId
|
|
15871
15876
|
});
|
|
15872
15877
|
var normalizeCurrencyFilter = (filter) => {
|
|
@@ -16064,6 +16069,34 @@ var EmbedProvider = ({
|
|
|
16064
16069
|
),
|
|
16065
16070
|
[hydrateExternal]
|
|
16066
16071
|
);
|
|
16072
|
+
const rehydrateWithParams = (0, import_react4.useCallback)(
|
|
16073
|
+
async (params) => {
|
|
16074
|
+
const componentId = state.data?.component?.id;
|
|
16075
|
+
if (!componentId || !checkoutApi) {
|
|
16076
|
+
throw new Error(
|
|
16077
|
+
"[Schematic] `rehydrateWithParams` needs a `SchematicEmbed` that has loaded."
|
|
16078
|
+
);
|
|
16079
|
+
}
|
|
16080
|
+
const response = await checkoutApi.hydrateComponent({
|
|
16081
|
+
componentId,
|
|
16082
|
+
includeAddOnIds: params.includeAddOnIds
|
|
16083
|
+
});
|
|
16084
|
+
const returnedIds = new Set(
|
|
16085
|
+
response.data.activeAddOns.map((addOn) => addOn.id)
|
|
16086
|
+
);
|
|
16087
|
+
const missingIds = (params.includeAddOnIds ?? []).filter(
|
|
16088
|
+
(id) => !returnedIds.has(id)
|
|
16089
|
+
);
|
|
16090
|
+
if (missingIds.length > 0) {
|
|
16091
|
+
console.warn(
|
|
16092
|
+
`[Schematic] These included add-ons were left out because each must be an add-on with a billing product: ${missingIds.join(", ")}`
|
|
16093
|
+
);
|
|
16094
|
+
}
|
|
16095
|
+
dispatch({ type: "HYDRATE_COMPONENT", data: response.data });
|
|
16096
|
+
return response.data;
|
|
16097
|
+
},
|
|
16098
|
+
[checkoutApi, state.data?.component?.id]
|
|
16099
|
+
);
|
|
16067
16100
|
const createSetupIntent = (0, import_react4.useCallback)(async () => {
|
|
16068
16101
|
return checkoutApi?.createSetupIntent();
|
|
16069
16102
|
}, [checkoutApi]);
|
|
@@ -16407,6 +16440,7 @@ var EmbedProvider = ({
|
|
|
16407
16440
|
hydrate: debouncedHydrate,
|
|
16408
16441
|
hydrateComponent: debouncedHydrateComponent,
|
|
16409
16442
|
hydrateExternal: debouncedHydrateExternal,
|
|
16443
|
+
rehydrateWithParams,
|
|
16410
16444
|
createSetupIntent: debouncedCreateSetupIntent,
|
|
16411
16445
|
updatePaymentMethod: debouncedUpdatePaymentMethod,
|
|
16412
16446
|
deletePaymentMethod: debouncedDeletePaymentMethod,
|
|
@@ -26613,7 +26647,7 @@ PaymentMethod.displayName = "PaymentMethod";
|
|
|
26613
26647
|
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
26614
26648
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
26615
26649
|
|
|
26616
|
-
// node_modules/.pnpm/@stripe+stripe-js@9.
|
|
26650
|
+
// node_modules/.pnpm/@stripe+stripe-js@9.17.0/node_modules/@stripe/stripe-js/dist/index.mjs
|
|
26617
26651
|
function _typeof(obj) {
|
|
26618
26652
|
"@babel/helpers - typeof";
|
|
26619
26653
|
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
@@ -26667,7 +26701,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
26667
26701
|
}
|
|
26668
26702
|
stripe._registerWrapper({
|
|
26669
26703
|
name: "stripe-js",
|
|
26670
|
-
version: "9.
|
|
26704
|
+
version: "9.17.0",
|
|
26671
26705
|
startTime
|
|
26672
26706
|
});
|
|
26673
26707
|
};
|
|
@@ -26745,7 +26779,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
26745
26779
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
26746
26780
|
var expectedVersion = RELEASE_TRAIN;
|
|
26747
26781
|
if (isTestKey && version !== expectedVersion) {
|
|
26748
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.
|
|
26782
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.17.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
26749
26783
|
}
|
|
26750
26784
|
var stripe = maybeStripe.apply(void 0, args);
|
|
26751
26785
|
registerWrapper(stripe, startTime);
|
|
@@ -7207,6 +7207,13 @@ export declare interface EmbedContextProps extends Omit<EmbedState, SettingsLaye
|
|
|
7207
7207
|
hydrate: () => DebouncedApiPromise<HydrateDataWithCompanyContext>;
|
|
7208
7208
|
hydrateComponent: (id: string) => DebouncedApiPromise<HydrateDataWithCompanyContext>;
|
|
7209
7209
|
hydrateExternal: (fn: () => Promise<HydrateDataWithCompanyContext>) => DebouncedApiPromise<HydrateDataWithCompanyContext>;
|
|
7210
|
+
/**
|
|
7211
|
+
* Re-fetch the mounted `SchematicEmbed`'s component with extra params,
|
|
7212
|
+
* without swapping the embed for its loading state. Resolves with the new
|
|
7213
|
+
* data once it's applied. Rejects if the fetch fails, or if no component has
|
|
7214
|
+
* been hydrated yet.
|
|
7215
|
+
*/
|
|
7216
|
+
rehydrateWithParams: (params: RehydrateParams) => Promise<HydrateDataWithCompanyContext>;
|
|
7210
7217
|
getUpcomingInvoice: (id: string) => DebouncedApiPromise<HydrateUpcomingInvoiceResponse>;
|
|
7211
7218
|
getCustomerBalance: () => DebouncedApiPromise<FetchCustomerBalanceResponse>;
|
|
7212
7219
|
listInvoices: () => DebouncedApiPromise<ListInvoicesResponse>;
|
|
@@ -9630,6 +9637,7 @@ export declare const initialContext: {
|
|
|
9630
9637
|
hydrate: () => never;
|
|
9631
9638
|
hydrateComponent: () => never;
|
|
9632
9639
|
hydrateExternal: () => never;
|
|
9640
|
+
rehydrateWithParams: () => never;
|
|
9633
9641
|
getUpcomingInvoice: () => never;
|
|
9634
9642
|
getCustomerBalance: () => never;
|
|
9635
9643
|
listInvoices: () => never;
|
|
@@ -12935,6 +12943,20 @@ declare interface QuantityProps {
|
|
|
12935
12943
|
currency?: string;
|
|
12936
12944
|
}
|
|
12937
12945
|
|
|
12946
|
+
/**
|
|
12947
|
+
* Extra params for {@link EmbedContextProps.rehydrateWithParams}.
|
|
12948
|
+
*/
|
|
12949
|
+
export declare interface RehydrateParams {
|
|
12950
|
+
/**
|
|
12951
|
+
* Add-on IDs to offer in the checkout even when they aren't live in the
|
|
12952
|
+
* catalog, such as an add-on created for a single purchase. Including an
|
|
12953
|
+
* add-on doesn't select it; pass it in `initializeWithPlan`'s `addOnIds` for
|
|
12954
|
+
* that. An ID that isn't an add-on with a billing product is left out, with
|
|
12955
|
+
* a console warning.
|
|
12956
|
+
*/
|
|
12957
|
+
includeAddOnIds?: string[];
|
|
12958
|
+
}
|
|
12959
|
+
|
|
12938
12960
|
declare interface RequestContext {
|
|
12939
12961
|
fetch: FetchAPI;
|
|
12940
12962
|
url: string;
|
|
@@ -1932,6 +1932,7 @@ var initialContext = {
|
|
|
1932
1932
|
hydrate: stub,
|
|
1933
1933
|
hydrateComponent: stub,
|
|
1934
1934
|
hydrateExternal: stub,
|
|
1935
|
+
rehydrateWithParams: stub,
|
|
1935
1936
|
getUpcomingInvoice: stub,
|
|
1936
1937
|
getCustomerBalance: stub,
|
|
1937
1938
|
listInvoices: stub,
|
|
@@ -7596,7 +7597,8 @@ function HydrateComponentParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
7596
7597
|
return json;
|
|
7597
7598
|
}
|
|
7598
7599
|
return {
|
|
7599
|
-
catalogId: json["catalog_id"] == null ? void 0 : json["catalog_id"]
|
|
7600
|
+
catalogId: json["catalog_id"] == null ? void 0 : json["catalog_id"],
|
|
7601
|
+
includeAddOnIds: json["include_add_on_ids"] == null ? void 0 : json["include_add_on_ids"]
|
|
7600
7602
|
};
|
|
7601
7603
|
}
|
|
7602
7604
|
|
|
@@ -8628,6 +8630,9 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
8628
8630
|
if (requestParameters["catalogId"] != null) {
|
|
8629
8631
|
queryParameters["catalog_id"] = requestParameters["catalogId"];
|
|
8630
8632
|
}
|
|
8633
|
+
if (requestParameters["includeAddOnIds"] != null) {
|
|
8634
|
+
queryParameters["include_add_on_ids"] = requestParameters["includeAddOnIds"];
|
|
8635
|
+
}
|
|
8631
8636
|
const headerParameters = {};
|
|
8632
8637
|
if (this.configuration && this.configuration.apiKey) {
|
|
8633
8638
|
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
@@ -15545,7 +15550,7 @@ var reducer = (state, action) => {
|
|
|
15545
15550
|
// src/context/EmbedProvider.tsx
|
|
15546
15551
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
15547
15552
|
var getCustomHeaders = (sessionId) => ({
|
|
15548
|
-
"X-Schematic-Components-Version": "2.
|
|
15553
|
+
"X-Schematic-Components-Version": "2.28.0",
|
|
15549
15554
|
"X-Schematic-Session-ID": sessionId
|
|
15550
15555
|
});
|
|
15551
15556
|
var normalizeCurrencyFilter = (filter2) => {
|
|
@@ -15743,6 +15748,34 @@ var EmbedProvider = ({
|
|
|
15743
15748
|
),
|
|
15744
15749
|
[hydrateExternal]
|
|
15745
15750
|
);
|
|
15751
|
+
const rehydrateWithParams = useCallback2(
|
|
15752
|
+
async (params) => {
|
|
15753
|
+
const componentId = state.data?.component?.id;
|
|
15754
|
+
if (!componentId || !checkoutApi) {
|
|
15755
|
+
throw new Error(
|
|
15756
|
+
"[Schematic] `rehydrateWithParams` needs a `SchematicEmbed` that has loaded."
|
|
15757
|
+
);
|
|
15758
|
+
}
|
|
15759
|
+
const response = await checkoutApi.hydrateComponent({
|
|
15760
|
+
componentId,
|
|
15761
|
+
includeAddOnIds: params.includeAddOnIds
|
|
15762
|
+
});
|
|
15763
|
+
const returnedIds = new Set(
|
|
15764
|
+
response.data.activeAddOns.map((addOn) => addOn.id)
|
|
15765
|
+
);
|
|
15766
|
+
const missingIds = (params.includeAddOnIds ?? []).filter(
|
|
15767
|
+
(id) => !returnedIds.has(id)
|
|
15768
|
+
);
|
|
15769
|
+
if (missingIds.length > 0) {
|
|
15770
|
+
console.warn(
|
|
15771
|
+
`[Schematic] These included add-ons were left out because each must be an add-on with a billing product: ${missingIds.join(", ")}`
|
|
15772
|
+
);
|
|
15773
|
+
}
|
|
15774
|
+
dispatch({ type: "HYDRATE_COMPONENT", data: response.data });
|
|
15775
|
+
return response.data;
|
|
15776
|
+
},
|
|
15777
|
+
[checkoutApi, state.data?.component?.id]
|
|
15778
|
+
);
|
|
15746
15779
|
const createSetupIntent = useCallback2(async () => {
|
|
15747
15780
|
return checkoutApi?.createSetupIntent();
|
|
15748
15781
|
}, [checkoutApi]);
|
|
@@ -16086,6 +16119,7 @@ var EmbedProvider = ({
|
|
|
16086
16119
|
hydrate: debouncedHydrate,
|
|
16087
16120
|
hydrateComponent: debouncedHydrateComponent,
|
|
16088
16121
|
hydrateExternal: debouncedHydrateExternal,
|
|
16122
|
+
rehydrateWithParams,
|
|
16089
16123
|
createSetupIntent: debouncedCreateSetupIntent,
|
|
16090
16124
|
updatePaymentMethod: debouncedUpdatePaymentMethod,
|
|
16091
16125
|
deletePaymentMethod: debouncedDeletePaymentMethod,
|
|
@@ -26302,7 +26336,7 @@ PaymentMethod.displayName = "PaymentMethod";
|
|
|
26302
26336
|
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
26303
26337
|
import { Elements } from "@stripe/react-stripe-js";
|
|
26304
26338
|
|
|
26305
|
-
// node_modules/.pnpm/@stripe+stripe-js@9.
|
|
26339
|
+
// node_modules/.pnpm/@stripe+stripe-js@9.17.0/node_modules/@stripe/stripe-js/dist/index.mjs
|
|
26306
26340
|
function _typeof(obj) {
|
|
26307
26341
|
"@babel/helpers - typeof";
|
|
26308
26342
|
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
@@ -26356,7 +26390,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
26356
26390
|
}
|
|
26357
26391
|
stripe._registerWrapper({
|
|
26358
26392
|
name: "stripe-js",
|
|
26359
|
-
version: "9.
|
|
26393
|
+
version: "9.17.0",
|
|
26360
26394
|
startTime
|
|
26361
26395
|
});
|
|
26362
26396
|
};
|
|
@@ -26434,7 +26468,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
26434
26468
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
26435
26469
|
var expectedVersion = RELEASE_TRAIN;
|
|
26436
26470
|
if (isTestKey && version !== expectedVersion) {
|
|
26437
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.
|
|
26471
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("9.17.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
26438
26472
|
}
|
|
26439
26473
|
var stripe = maybeStripe.apply(void 0, args);
|
|
26440
26474
|
registerWrapper(stripe, startTime);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematichq/schematic-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
4
4
|
"main": "dist/schematic-components.cjs.js",
|
|
5
5
|
"module": "dist/schematic-components.esm.js",
|
|
6
6
|
"types": "dist/schematic-components.d.ts",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@schematichq/schematic-icons": "^0.8.0",
|
|
72
|
-
"@stripe/stripe-js": "^9.
|
|
72
|
+
"@stripe/stripe-js": "^9.17.0",
|
|
73
73
|
"i18next": "^26.4.2",
|
|
74
74
|
"lodash": "^4.18.1",
|
|
75
75
|
"pako": "^3.0.2",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@openapitools/openapi-generator-cli": "^2.41.0",
|
|
85
85
|
"@schematichq/schematic-js": "^1.8.0",
|
|
86
86
|
"@schematichq/schematic-react": "^1.8.0",
|
|
87
|
-
"@stripe/react-stripe-js": "^6.
|
|
87
|
+
"@stripe/react-stripe-js": "^6.11.0",
|
|
88
88
|
"@swc/core": "^1.16.2",
|
|
89
89
|
"@testing-library/dom": "^10.4.2",
|
|
90
90
|
"@testing-library/jest-dom": "^7.0.1",
|
|
@@ -102,13 +102,13 @@
|
|
|
102
102
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
103
103
|
"globals": "^17.12.0",
|
|
104
104
|
"happy-dom": "^20.14.5",
|
|
105
|
-
"jsdom": "^30.1.
|
|
105
|
+
"jsdom": "^30.1.1",
|
|
106
106
|
"msw": "^2.15.0",
|
|
107
107
|
"prettier": "^3.9.8",
|
|
108
108
|
"react": "^19.3.0",
|
|
109
109
|
"react-dom": "^19.3.0",
|
|
110
110
|
"typescript": "^6.0.3",
|
|
111
|
-
"typescript-eslint": "^8.70.
|
|
111
|
+
"typescript-eslint": "^8.70.1",
|
|
112
112
|
"vitest": "^5.0.1"
|
|
113
113
|
},
|
|
114
114
|
"peerDependencies": {
|