@betterstore/react 0.7.1 → 0.7.2

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.
@@ -7,7 +7,8 @@ interface CheckoutFormProps {
7
7
  onSuccess: () => void;
8
8
  onError: () => void;
9
9
  cancelUrl: string;
10
- clientSecret: string;
10
+ checkoutSecret: string;
11
+ customerData?: GetCheckoutResponse["customerData"];
11
12
  customer?: GetCheckoutResponse["customer"];
12
13
  currency: string;
13
14
  checkoutAppearance?: AppearanceConfig;
@@ -24,6 +25,6 @@ interface CheckoutFormProps {
24
25
  currentAlpha3CountryCode?: string;
25
26
  shipments: GetCheckoutResponse["shipments"];
26
27
  }
27
- export default function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, fonts, locale, setShippingCost, exchangeRate, paymentSecret, publicKey, paymentComponentKey, clientProxy, latitude, longitude, currentAlpha3CountryCode, shipments, }: CheckoutFormProps): import("react/jsx-runtime").JSX.Element;
28
+ export default function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl, checkoutSecret, customer, customerData, currency, checkoutAppearance, fonts, locale, setShippingCost, exchangeRate, paymentSecret, publicKey, paymentComponentKey, clientProxy, latitude, longitude, currentAlpha3CountryCode, shipments, }: CheckoutFormProps): import("react/jsx-runtime").JSX.Element;
28
29
  export {};
29
30
  //# sourceMappingURL=checkout-form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkout-form.d.ts","sourceRoot":"","sources":["../../../src/components/checkout-embed/checkout-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EAGpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAcvD,UAAU,iBAAiB;IACzB,WAAW,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC7C;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,eAAe,EACf,YAAY,EACZ,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,SAAS,GACV,EAAE,iBAAiB,2CA2SnB"}
1
+ {"version":3,"file":"checkout-form.d.ts","sourceRoot":"","sources":["../../../src/components/checkout-embed/checkout-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EAGpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAcvD,UAAU,iBAAiB;IACzB,WAAW,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;IACnD,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC7C;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,EACT,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,eAAe,EACf,YAAY,EACZ,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,SAAS,GACV,EAAE,iBAAiB,2CA4SnB"}
@@ -35,7 +35,8 @@ export declare const customerSchema: z.ZodObject<{
35
35
  company?: string | null | undefined;
36
36
  }>;
37
37
  phone: z.ZodString;
38
- isEmailSubscribed: z.ZodOptional<z.ZodBoolean>;
38
+ isSubscribedEmail: z.ZodOptional<z.ZodBoolean>;
39
+ isSubscribedSMS: z.ZodOptional<z.ZodBoolean>;
39
40
  }, "strip", z.ZodTypeAny, {
40
41
  email: string;
41
42
  firstName: string;
@@ -52,7 +53,8 @@ export declare const customerSchema: z.ZodObject<{
52
53
  company?: string | null | undefined;
53
54
  };
54
55
  phone: string;
55
- isEmailSubscribed?: boolean | undefined;
56
+ isSubscribedEmail?: boolean | undefined;
57
+ isSubscribedSMS?: boolean | undefined;
56
58
  }, {
57
59
  email: string;
58
60
  firstName: string;
@@ -69,11 +71,12 @@ export declare const customerSchema: z.ZodObject<{
69
71
  company?: string | null | undefined;
70
72
  };
71
73
  phone: string;
72
- isEmailSubscribed?: boolean | undefined;
74
+ isSubscribedEmail?: boolean | undefined;
75
+ isSubscribedSMS?: boolean | undefined;
73
76
  }>;
74
77
  export declare const shipmentsFormSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
75
78
  rateId: z.ZodString;
76
- providerId: z.ZodOptional<z.ZodString>;
79
+ carrierId: z.ZodOptional<z.ZodString>;
77
80
  priceInCents: z.ZodNumber;
78
81
  pickupPointId: z.ZodOptional<z.ZodString>;
79
82
  pickupPointDisplayName: z.ZodOptional<z.ZodString>;
@@ -82,28 +85,28 @@ export declare const shipmentsFormSchema: z.ZodEffects<z.ZodRecord<z.ZodString,
82
85
  priceInCents: number;
83
86
  displayName: string;
84
87
  rateId: string;
85
- providerId?: string | undefined;
88
+ carrierId?: string | undefined;
86
89
  pickupPointId?: string | undefined;
87
90
  pickupPointDisplayName?: string | undefined;
88
91
  }, {
89
92
  priceInCents: number;
90
93
  displayName: string;
91
94
  rateId: string;
92
- providerId?: string | undefined;
95
+ carrierId?: string | undefined;
93
96
  pickupPointId?: string | undefined;
94
97
  pickupPointDisplayName?: string | undefined;
95
98
  }>>, Record<string, {
96
99
  priceInCents: number;
97
100
  displayName: string;
98
101
  rateId: string;
99
- providerId?: string | undefined;
102
+ carrierId?: string | undefined;
100
103
  pickupPointId?: string | undefined;
101
104
  pickupPointDisplayName?: string | undefined;
102
105
  }>, Record<string, {
103
106
  priceInCents: number;
104
107
  displayName: string;
105
108
  rateId: string;
106
- providerId?: string | undefined;
109
+ carrierId?: string | undefined;
107
110
  pickupPointId?: string | undefined;
108
111
  pickupPointDisplayName?: string | undefined;
109
112
  }>>;
@@ -144,7 +147,8 @@ export declare const checkoutSchema: z.ZodObject<{
144
147
  company?: string | null | undefined;
145
148
  }>;
146
149
  phone: z.ZodString;
147
- isEmailSubscribed: z.ZodOptional<z.ZodBoolean>;
150
+ isSubscribedEmail: z.ZodOptional<z.ZodBoolean>;
151
+ isSubscribedSMS: z.ZodOptional<z.ZodBoolean>;
148
152
  }, "strip", z.ZodTypeAny, {
149
153
  email: string;
150
154
  firstName: string;
@@ -161,7 +165,8 @@ export declare const checkoutSchema: z.ZodObject<{
161
165
  company?: string | null | undefined;
162
166
  };
163
167
  phone: string;
164
- isEmailSubscribed?: boolean | undefined;
168
+ isSubscribedEmail?: boolean | undefined;
169
+ isSubscribedSMS?: boolean | undefined;
165
170
  }, {
166
171
  email: string;
167
172
  firstName: string;
@@ -178,11 +183,12 @@ export declare const checkoutSchema: z.ZodObject<{
178
183
  company?: string | null | undefined;
179
184
  };
180
185
  phone: string;
181
- isEmailSubscribed?: boolean | undefined;
186
+ isSubscribedEmail?: boolean | undefined;
187
+ isSubscribedSMS?: boolean | undefined;
182
188
  }>;
183
189
  shipping: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
184
190
  rateId: z.ZodString;
185
- providerId: z.ZodOptional<z.ZodString>;
191
+ carrierId: z.ZodOptional<z.ZodString>;
186
192
  priceInCents: z.ZodNumber;
187
193
  pickupPointId: z.ZodOptional<z.ZodString>;
188
194
  pickupPointDisplayName: z.ZodOptional<z.ZodString>;
@@ -191,28 +197,28 @@ export declare const checkoutSchema: z.ZodObject<{
191
197
  priceInCents: number;
192
198
  displayName: string;
193
199
  rateId: string;
194
- providerId?: string | undefined;
200
+ carrierId?: string | undefined;
195
201
  pickupPointId?: string | undefined;
196
202
  pickupPointDisplayName?: string | undefined;
197
203
  }, {
198
204
  priceInCents: number;
199
205
  displayName: string;
200
206
  rateId: string;
201
- providerId?: string | undefined;
207
+ carrierId?: string | undefined;
202
208
  pickupPointId?: string | undefined;
203
209
  pickupPointDisplayName?: string | undefined;
204
210
  }>>, Record<string, {
205
211
  priceInCents: number;
206
212
  displayName: string;
207
213
  rateId: string;
208
- providerId?: string | undefined;
214
+ carrierId?: string | undefined;
209
215
  pickupPointId?: string | undefined;
210
216
  pickupPointDisplayName?: string | undefined;
211
217
  }>, Record<string, {
212
218
  priceInCents: number;
213
219
  displayName: string;
214
220
  rateId: string;
215
- providerId?: string | undefined;
221
+ carrierId?: string | undefined;
216
222
  pickupPointId?: string | undefined;
217
223
  pickupPointDisplayName?: string | undefined;
218
224
  }>>;
@@ -234,13 +240,14 @@ export declare const checkoutSchema: z.ZodObject<{
234
240
  company?: string | null | undefined;
235
241
  };
236
242
  phone: string;
237
- isEmailSubscribed?: boolean | undefined;
243
+ isSubscribedEmail?: boolean | undefined;
244
+ isSubscribedSMS?: boolean | undefined;
238
245
  };
239
246
  shipping: Record<string, {
240
247
  priceInCents: number;
241
248
  displayName: string;
242
249
  rateId: string;
243
- providerId?: string | undefined;
250
+ carrierId?: string | undefined;
244
251
  pickupPointId?: string | undefined;
245
252
  pickupPointDisplayName?: string | undefined;
246
253
  }>;
@@ -262,13 +269,14 @@ export declare const checkoutSchema: z.ZodObject<{
262
269
  company?: string | null | undefined;
263
270
  };
264
271
  phone: string;
265
- isEmailSubscribed?: boolean | undefined;
272
+ isSubscribedEmail?: boolean | undefined;
273
+ isSubscribedSMS?: boolean | undefined;
266
274
  };
267
275
  shipping: Record<string, {
268
276
  priceInCents: number;
269
277
  displayName: string;
270
278
  rateId: string;
271
- providerId?: string | undefined;
279
+ carrierId?: string | undefined;
272
280
  pickupPointId?: string | undefined;
273
281
  pickupPointDisplayName?: string | undefined;
274
282
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"checkout-schema.d.ts","sourceRoot":"","sources":["../../../src/components/checkout-embed/checkout-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBzB,CAAC;AAaH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK5B,CAAC;AAGL,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIzB,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
1
+ {"version":3,"file":"checkout-schema.d.ts","sourceRoot":"","sources":["../../../src/components/checkout-embed/checkout-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBzB,CAAC;AAaH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK5B,CAAC;AAGL,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIzB,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -4,7 +4,7 @@ import { AppearanceConfig, Fonts } from "./appearance";
4
4
  interface CheckoutEmbedProps {
5
5
  checkoutId: string;
6
6
  config: {
7
- clientSecret: string;
7
+ checkoutSecret: string;
8
8
  cancelUrl: string;
9
9
  successUrl: string;
10
10
  appearance?: AppearanceConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/checkout-embed/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,MAAM,EAAE,MAAM,cAAc,CAAC;AAErE,OAAO,KAA4C,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAOvD,UAAU,kBAAkB;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE;QACN,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,gBAAgB,CAAC;QAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAcD,iBAAS,sBAAsB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,kBAAkB,2CAwVzE;AAED,QAAA,MAAM,aAAa,0DAA+B,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/checkout-embed/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,MAAM,EAAE,MAAM,cAAc,CAAC;AAErE,OAAO,KAA4C,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAOvD,UAAU,kBAAkB;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE;QACN,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,gBAAgB,CAAC;QAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAcD,iBAAS,sBAAsB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,kBAAkB,2CAwVzE;AAED,QAAA,MAAM,aAAa,0DAA+B,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -3,12 +3,12 @@ interface CustomerFormProps {
3
3
  initialData?: CustomerFormData;
4
4
  onSubmit: (data: CustomerFormData) => void;
5
5
  clientProxy?: string;
6
- clientSecret: string;
6
+ checkoutSecret: string;
7
7
  latitude?: number;
8
8
  longitude?: number;
9
9
  currentAlpha3CountryCode?: string;
10
10
  locale?: string;
11
11
  }
12
- export default function CustomerForm({ initialData, onSubmit, clientProxy, clientSecret, latitude, longitude, currentAlpha3CountryCode, locale, }: CustomerFormProps): import("react/jsx-runtime").JSX.Element;
12
+ export default function CustomerForm({ initialData, onSubmit, clientProxy, checkoutSecret, latitude, longitude, currentAlpha3CountryCode, locale, }: CustomerFormProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
14
14
  //# sourceMappingURL=form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../src/components/checkout-embed/steps/customer/form.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,gBAAgB,EAAkB,MAAM,uBAAuB,CAAC;AAE9E,UAAU,iBAAiB;IACzB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,QAAQ,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,MAAM,GACP,EAAE,iBAAiB,2CA+EnB"}
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../src/components/checkout-embed/steps/customer/form.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,gBAAgB,EAAkB,MAAM,uBAAuB,CAAC;AAE9E,UAAU,iBAAiB;IACzB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,QAAQ,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,QAAQ,EACR,WAAW,EACX,cAAc,EACd,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,MAAM,GACP,EAAE,iBAAiB,2CA+EnB"}
@@ -1,12 +1,12 @@
1
1
  interface AddressInputProps {
2
2
  className?: string;
3
3
  proxy?: string;
4
- clientSecret: string;
4
+ checkoutSecret: string;
5
5
  latitude?: number;
6
6
  longitude?: number;
7
7
  currentAlpha3CountryCode?: string;
8
8
  locale?: string;
9
9
  }
10
- export declare function AddressInput({ className, proxy, clientSecret, latitude, longitude, currentAlpha3CountryCode, locale, }: AddressInputProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function AddressInput({ className, proxy, checkoutSecret, latitude, longitude, currentAlpha3CountryCode, locale, }: AddressInputProps): import("react/jsx-runtime").JSX.Element;
11
11
  export {};
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/compounds/form/address-input/index.tsx"],"names":[],"mappings":"AAkBA,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAc,EACd,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,MAAM,GACP,EAAE,iBAAiB,2CA4TnB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/compounds/form/address-input/index.tsx"],"names":[],"mappings":"AAkBA,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAc,EACd,KAAK,EACL,cAAc,EACd,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,MAAM,GACP,EAAE,iBAAiB,2CA6TnB"}
@@ -0,0 +1,5 @@
1
+ export declare const devdata: {
2
+ readonly checkoutSecret: "fbbdbf7102b56a6f41fe31120b60c36d7751039d17354a34d98dcf886a0e8004";
3
+ readonly checkoutSessionId: "b65ea813-b8a2-4a04-9af6-76f6d3c1f127";
4
+ };
5
+ //# sourceMappingURL=dev-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-data.d.ts","sourceRoot":"","sources":["../../src/dev/dev-data.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;;CAIV,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generate-test-checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-test-checkout.d.ts","sourceRoot":"","sources":["../../src/dev/generate-test-checkout.ts"],"names":[],"mappings":""}
package/dist/index.cjs.js CHANGED
@@ -3487,27 +3487,35 @@ const createI18nInstance = (locale) => __awaiter(void 0, void 0, void 0, functio
3487
3487
  });
3488
3488
 
3489
3489
  // src/base-client.ts
3490
+ var DEFAULT_BASE_URL = "https://v1.betterstore.io";
3490
3491
  var BaseClient = class {
3491
3492
  constructor(config) {
3492
3493
  this.config = config;
3494
+ this.headers = {
3495
+ "Content-Type": "application/json",
3496
+ Authorization: `Bearer ${this.config.secret}`
3497
+ };
3493
3498
  }
3499
+ headers;
3494
3500
  async get(path, params) {
3495
- const url = new URL(path, this.config.baseUrl);
3501
+ const url = `${this.config.baseUrl}${path}`;
3502
+ const searchParams = new URLSearchParams();
3496
3503
  if (params) {
3497
3504
  Object.entries(params).forEach(([key, val]) => {
3498
- if (val !== void 0) url.searchParams.set(key, String(val));
3505
+ if (val !== void 0) searchParams.set(key, val);
3499
3506
  });
3500
3507
  }
3501
- const res = await fetch(url.toString(), {
3508
+ console.log(`${url}?${searchParams.toString()}`);
3509
+ const res = await fetch(`${url}?${searchParams.toString()}`, {
3502
3510
  method: "GET",
3503
- headers: this.config.headers
3511
+ headers: this.headers
3504
3512
  });
3505
3513
  return this.handleResponse(res);
3506
3514
  }
3507
3515
  async post(path, body) {
3508
3516
  const res = await fetch(`${this.config.baseUrl}${path}`, {
3509
3517
  method: "POST",
3510
- headers: this.config.headers,
3518
+ headers: this.headers,
3511
3519
  body: body ? JSON.stringify(body) : void 0
3512
3520
  });
3513
3521
  return this.handleResponse(res);
@@ -3515,13 +3523,14 @@ var BaseClient = class {
3515
3523
  async delete(path) {
3516
3524
  const res = await fetch(`${this.config.baseUrl}${path}`, {
3517
3525
  method: "DELETE",
3518
- headers: this.config.headers
3526
+ headers: this.headers
3519
3527
  });
3520
3528
  return this.handleResponse(res);
3521
3529
  }
3522
3530
  async handleResponse(res) {
3523
3531
  if (!res.ok) {
3524
- const error = await res.json().catch(() => ({ message: res.statusText }));
3532
+ const error = await res.json().catch(() => ({ message: res.statusText, data: res.body }));
3533
+ console.log(error);
3525
3534
  throw new Error(error.message || `HTTP ${res.status}`);
3526
3535
  }
3527
3536
  return res.json();
@@ -3618,13 +3627,10 @@ var ClientUtilsNamespace = class {
3618
3627
  };
3619
3628
 
3620
3629
  // src/client-factory.ts
3621
- function createBetterStoreClient(clientSecret, config) {
3630
+ function createBetterStoreClient(checkoutSecret, config) {
3622
3631
  const baseClient = new BaseClient({
3623
- baseUrl: config?.proxy || "https://api.betterstore.com",
3624
- headers: {
3625
- Authorization: `Bearer ${clientSecret}`,
3626
- "Content-Type": "application/json"
3627
- }
3632
+ baseUrl: config?.proxy || DEFAULT_BASE_URL,
3633
+ secret: checkoutSecret
3628
3634
  });
3629
3635
  return {
3630
3636
  checkout: new ClientCheckoutNamespace(baseClient),
@@ -8632,12 +8638,13 @@ const customerSchema = objectType({
8632
8638
  company: stringType().nullable().optional(),
8633
8639
  }),
8634
8640
  phone: stringType().regex(phoneRegex, "invalid_phone"),
8635
- isEmailSubscribed: booleanType().optional(),
8641
+ isSubscribedEmail: booleanType().optional(),
8642
+ isSubscribedSMS: booleanType().optional(),
8636
8643
  });
8637
8644
  // Shipping method schema
8638
8645
  const shippingMethodSchema = objectType({
8639
8646
  rateId: stringType().min(1, "required_error"),
8640
- providerId: optionalType(stringType()),
8647
+ carrierId: optionalType(stringType()),
8641
8648
  priceInCents: numberType().min(1, "required_error"),
8642
8649
  pickupPointId: stringType().optional(),
8643
8650
  pickupPointDisplayName: stringType().optional(), // Only for display purposes
@@ -31257,10 +31264,10 @@ const countryProvinces = {
31257
31264
  };
31258
31265
  const countriesWithProvinces = Object.keys(countryProvinces);
31259
31266
 
31260
- function AddressInput({ className = "", proxy, clientSecret, latitude, longitude, currentAlpha3CountryCode, locale, }) {
31267
+ function AddressInput({ className = "", proxy, checkoutSecret, latitude, longitude, currentAlpha3CountryCode, locale, }) {
31261
31268
  var _a;
31262
31269
  const { t } = useTranslation();
31263
- const storeClient = createBetterStoreClient(clientSecret, { proxy });
31270
+ const storeClient = createBetterStoreClient(checkoutSecret, { proxy });
31264
31271
  const form = useFormContext();
31265
31272
  const [showSuggestions, setShowSuggestions] = React.useState(false);
31266
31273
  const [showAllInputs, setShowAllInputs] = React.useState(false);
@@ -31305,6 +31312,8 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
31305
31312
  const fetchSuggestions = () => __awaiter(this, void 0, void 0, function* () {
31306
31313
  try {
31307
31314
  const countryCode = form.watch("address.countryCode");
31315
+ if (!addressInput)
31316
+ return;
31308
31317
  const results = yield storeClient.utils.autosuggestAddress({
31309
31318
  query: addressInput,
31310
31319
  latitude: latitude,
@@ -31408,7 +31417,7 @@ const r$1=(t,r,o)=>{if(t&&"reportValidity"in t){const s=get(o,r);t.setCustomVali
31408
31417
 
31409
31418
  function n(r,e){for(var n={};r.length;){var s=r[0],t=s.code,i=s.message,a=s.path.join(".");if(!n[a])if("unionErrors"in s){var u=s.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:t};if("unionErrors"in s&&s.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[s.code];n[a]=appendErrors(a,e,n,t,f?[].concat(f,s.message):s.message);}r.shift();}return n}function s(o$1,s,t){return void 0===t&&(t={}),function(i,a,u){try{return Promise.resolve(function(e,n){try{var a=Promise.resolve(o$1["sync"===t.mode?"parse":"parseAsync"](i,s)).then(function(e){return u.shouldUseNativeValidation&&o({},u),{errors:{},values:t.raw?Object.assign({},i):e}});}catch(r){return n(r)}return a&&a.then?a.then(void 0,n):a}(0,function(r){if(function(r){return Array.isArray(null==r?void 0:r.errors)}(r))return {values:{},errors:s$1(n(r.errors,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)};throw r}))}catch(r){return Promise.reject(r)}}}
31410
31419
 
31411
- function CustomerForm({ initialData, onSubmit, clientProxy, clientSecret, latitude, longitude, currentAlpha3CountryCode, locale, }) {
31420
+ function CustomerForm({ initialData, onSubmit, clientProxy, checkoutSecret, latitude, longitude, currentAlpha3CountryCode, locale, }) {
31412
31421
  const { t } = useTranslation();
31413
31422
  const form = useForm({
31414
31423
  resolver: s(customerSchema),
@@ -31428,7 +31437,7 @@ function CustomerForm({ initialData, onSubmit, clientProxy, clientSecret, latitu
31428
31437
  phone: "",
31429
31438
  },
31430
31439
  });
31431
- return (jsxRuntime.jsx(Form, Object.assign({}, form, { children: jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "grid gap-5 md:grid-cols-2", children: [jsxRuntime.jsx("div", { className: "md:col-span-2", children: jsxRuntime.jsx("h2", { children: t("CheckoutEmbed.CustomerForm.title") }) }), jsxRuntime.jsx(InputGroup, { className: "md:col-span-2", name: "email", label: t("CheckoutEmbed.CustomerForm.email"), type: "email", autoComplete: "email" }), jsxRuntime.jsx(InputGroup, { name: "firstName", label: t("CheckoutEmbed.CustomerForm.firstName"), autoComplete: "given-name" }), jsxRuntime.jsx(InputGroup, { name: "lastName", label: t("CheckoutEmbed.CustomerForm.lastName"), autoComplete: "family-name" }), jsxRuntime.jsx(AddressInput, { className: "md:col-span-2", proxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }), jsxRuntime.jsx(InputGroup, { name: "phone", label: t("CheckoutEmbed.CustomerForm.phone"), type: "tel", autoComplete: "tel" }), jsxRuntime.jsx("div", { className: "flex justify-end pt-2 md:col-span-2", children: jsxRuntime.jsx(SubmitButton, { isValid: form.formState.isDirty || form.formState.isValid, isSubmitting: form.formState.isSubmitting, children: t("CheckoutEmbed.CustomerForm.button") }) })] }) })));
31440
+ return (jsxRuntime.jsx(Form, Object.assign({}, form, { children: jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "grid gap-5 md:grid-cols-2", children: [jsxRuntime.jsx("div", { className: "md:col-span-2", children: jsxRuntime.jsx("h2", { children: t("CheckoutEmbed.CustomerForm.title") }) }), jsxRuntime.jsx(InputGroup, { className: "md:col-span-2", name: "email", label: t("CheckoutEmbed.CustomerForm.email"), type: "email", autoComplete: "email" }), jsxRuntime.jsx(InputGroup, { name: "firstName", label: t("CheckoutEmbed.CustomerForm.firstName"), autoComplete: "given-name" }), jsxRuntime.jsx(InputGroup, { name: "lastName", label: t("CheckoutEmbed.CustomerForm.lastName"), autoComplete: "family-name" }), jsxRuntime.jsx(AddressInput, { className: "md:col-span-2", proxy: clientProxy, checkoutSecret: checkoutSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }), jsxRuntime.jsx(InputGroup, { name: "phone", label: t("CheckoutEmbed.CustomerForm.phone"), type: "tel", autoComplete: "tel" }), jsxRuntime.jsx("div", { className: "flex justify-end pt-2 md:col-span-2", children: jsxRuntime.jsx(SubmitButton, { isValid: form.formState.isDirty || form.formState.isValid, isSubmitting: form.formState.isSubmitting, children: t("CheckoutEmbed.CustomerForm.button") }) })] }) })));
31432
31441
  }
31433
31442
 
31434
31443
  var reactStripe_umd$1 = {exports: {}};
@@ -37826,7 +37835,7 @@ function ShipmentsShippingMethodForm({ shippingRates, initialData, onSubmit, onB
37826
37835
  shipment.id,
37827
37836
  {
37828
37837
  rateId: "",
37829
- provider: "",
37838
+ carrierId: "",
37830
37839
  priceInCents: 0,
37831
37840
  pickupPointId: "",
37832
37841
  pickupPointDisplayName: "",
@@ -37870,14 +37879,14 @@ const SingleShipmentSection = ({ shippingRates, form, currency, exchangeRate, lo
37870
37879
  return (jsxRuntime.jsx(ShippingOptionWrapper, { rate: rate, onPickupPointSelected: (pickupPointId, pickupPointName) => {
37871
37880
  const newData = {
37872
37881
  rateId: rate.id,
37873
- providerId: isAutoRate ? rate.carrierId : undefined,
37882
+ carrierId: isAutoRate ? rate.carrierId : undefined,
37874
37883
  priceInCents: intPrice,
37875
37884
  displayName: name,
37876
37885
  pickupPointId: isZasilkovna ? pickupPointId : "",
37877
37886
  pickupPointDisplayName: isZasilkovna ? pickupPointName : "",
37878
37887
  };
37879
37888
  form.setValue(`${shipmentId}.rateId`, newData.rateId);
37880
- form.setValue(`${shipmentId}.providerId`, newData.providerId);
37889
+ form.setValue(`${shipmentId}.carrierId`, newData.carrierId);
37881
37890
  form.setValue(`${shipmentId}.displayName`, newData.displayName);
37882
37891
  form.setValue(`${shipmentId}.priceInCents`, newData.priceInCents);
37883
37892
  form.setValue(`${shipmentId}.pickupPointId`, newData.pickupPointId);
@@ -37905,7 +37914,7 @@ const resetFormStore = (formData) => {
37905
37914
  localStorage.setItem("checkout", JSON.stringify(Object.assign(Object.assign({}, currentState), { state: Object.assign(Object.assign({}, currentState.state), { step: "customer", formData: { customer: formData.customer } }) })));
37906
37915
  };
37907
37916
 
37908
- function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, fonts, locale, setShippingCost, exchangeRate, paymentSecret, publicKey, paymentComponentKey, clientProxy, latitude, longitude, currentAlpha3CountryCode, shipments, }) {
37917
+ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl, checkoutSecret, customer, customerData, currency, checkoutAppearance, fonts, locale, setShippingCost, exchangeRate, paymentSecret, publicKey, paymentComponentKey, clientProxy, latitude, longitude, currentAlpha3CountryCode, shipments, }) {
37909
37918
  const { formData, setFormData, step, setStep, checkoutId: storedCheckoutId, setCheckoutId, } = useFormStore();
37910
37919
  const [shippingRates, setShippingRates] = React.useState(undefined);
37911
37920
  const validateStep = React.useCallback(() => {
@@ -37930,37 +37939,37 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
37930
37939
  // eslint-disable-next-line react-hooks/exhaustive-deps
37931
37940
  }, [step]);
37932
37941
  React.useEffect(() => {
37933
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33;
37942
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
37934
37943
  if (checkoutId !== storedCheckoutId) {
37935
37944
  setStep("customer");
37936
37945
  setCheckoutId(checkoutId);
37937
- if (customer) {
37938
- if ((_a = customer === null || customer === void 0 ? void 0 : customer.address) === null || _a === void 0 ? void 0 : _a.city) {
37946
+ if (customerData && customer) {
37947
+ if ((_a = customerData === null || customerData === void 0 ? void 0 : customerData.address) === null || _a === void 0 ? void 0 : _a.city) {
37939
37948
  setStep("shipping");
37940
37949
  }
37941
37950
  setFormData({
37942
37951
  customerId: customer.id,
37943
37952
  customer: {
37944
- firstName: (_d = (_c = (_b = customer.address) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.split(" ")[0]) !== null && _d !== void 0 ? _d : "",
37945
- lastName: (_g = (_f = (_e = customer.address) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.split(" ")[1]) !== null && _g !== void 0 ? _g : "",
37946
- phone: (_j = (_h = customer.address) === null || _h === void 0 ? void 0 : _h.phone) !== null && _j !== void 0 ? _j : "",
37947
- email: (_k = customer.email) !== null && _k !== void 0 ? _k : "",
37953
+ firstName: customerData.firstName,
37954
+ lastName: customerData.lastName,
37955
+ phone: customerData.phone,
37956
+ email: customerData.email,
37948
37957
  address: {
37949
- line1: (_m = (_l = customer.address) === null || _l === void 0 ? void 0 : _l.line1) !== null && _m !== void 0 ? _m : "",
37950
- line2: (_p = (_o = customer.address) === null || _o === void 0 ? void 0 : _o.line2) !== null && _p !== void 0 ? _p : null,
37951
- city: (_r = (_q = customer.address) === null || _q === void 0 ? void 0 : _q.city) !== null && _r !== void 0 ? _r : "",
37952
- province: (_t = (_s = customer.address) === null || _s === void 0 ? void 0 : _s.province) !== null && _t !== void 0 ? _t : null,
37953
- provinceCode: (_v = (_u = customer.address) === null || _u === void 0 ? void 0 : _u.provinceCode) !== null && _v !== void 0 ? _v : null,
37954
- zipCode: (_x = (_w = customer.address) === null || _w === void 0 ? void 0 : _w.zipCode) !== null && _x !== void 0 ? _x : "",
37955
- country: (_z = (_y = customer.address) === null || _y === void 0 ? void 0 : _y.country) !== null && _z !== void 0 ? _z : "",
37956
- countryCode: (_1 = (_0 = customer.address) === null || _0 === void 0 ? void 0 : _0.countryCode) !== null && _1 !== void 0 ? _1 : "",
37957
- company: (_3 = (_2 = customer.address) === null || _2 === void 0 ? void 0 : _2.company) !== null && _3 !== void 0 ? _3 : null,
37958
+ line1: (_b = customerData.address) === null || _b === void 0 ? void 0 : _b.line1,
37959
+ line2: (_d = (_c = customerData.address) === null || _c === void 0 ? void 0 : _c.line2) !== null && _d !== void 0 ? _d : null,
37960
+ city: (_e = customerData.address) === null || _e === void 0 ? void 0 : _e.city,
37961
+ province: (_g = (_f = customerData.address) === null || _f === void 0 ? void 0 : _f.province) !== null && _g !== void 0 ? _g : null,
37962
+ provinceCode: (_j = (_h = customerData.address) === null || _h === void 0 ? void 0 : _h.provinceCode) !== null && _j !== void 0 ? _j : null,
37963
+ zipCode: (_k = customerData.address) === null || _k === void 0 ? void 0 : _k.zipCode,
37964
+ country: (_l = customerData.address) === null || _l === void 0 ? void 0 : _l.country,
37965
+ countryCode: (_m = customerData.address) === null || _m === void 0 ? void 0 : _m.countryCode,
37966
+ company: (_p = (_o = customerData.address) === null || _o === void 0 ? void 0 : _o.company) !== null && _p !== void 0 ? _p : null,
37958
37967
  },
37959
37968
  },
37960
37969
  });
37961
37970
  return;
37962
37971
  }
37963
- else if ((_4 = formData.customer) === null || _4 === void 0 ? void 0 : _4.email) {
37972
+ else if ((_q = formData.customer) === null || _q === void 0 ? void 0 : _q.email) {
37964
37973
  setFormData({
37965
37974
  customer: formData.customer,
37966
37975
  });
@@ -37970,26 +37979,26 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
37970
37979
  }
37971
37980
  return;
37972
37981
  }
37973
- if (customer && !((_5 = formData.customer) === null || _5 === void 0 ? void 0 : _5.email)) {
37982
+ if (customerData && customer && !((_r = formData.customer) === null || _r === void 0 ? void 0 : _r.email)) {
37974
37983
  setStep("customer");
37975
- if ((_6 = customer.address) === null || _6 === void 0 ? void 0 : _6.city) {
37984
+ if ((_s = customerData === null || customerData === void 0 ? void 0 : customerData.address) === null || _s === void 0 ? void 0 : _s.city) {
37976
37985
  setStep("shipping");
37977
37986
  }
37978
37987
  setFormData(Object.assign(Object.assign({}, formData), { customerId: customer.id, customer: {
37979
- firstName: (_9 = (_8 = (_7 = customer.address) === null || _7 === void 0 ? void 0 : _7.name) === null || _8 === void 0 ? void 0 : _8.split(" ")[0]) !== null && _9 !== void 0 ? _9 : "",
37980
- lastName: (_12 = (_11 = (_10 = customer.address) === null || _10 === void 0 ? void 0 : _10.name) === null || _11 === void 0 ? void 0 : _11.split(" ")[1]) !== null && _12 !== void 0 ? _12 : "",
37981
- phone: (_14 = (_13 = customer.address) === null || _13 === void 0 ? void 0 : _13.phone) !== null && _14 !== void 0 ? _14 : "",
37982
- email: (_15 = customer.email) !== null && _15 !== void 0 ? _15 : "",
37988
+ firstName: customerData.firstName,
37989
+ lastName: customerData.lastName,
37990
+ phone: customerData.phone,
37991
+ email: customerData.email,
37983
37992
  address: {
37984
- line1: (_17 = (_16 = customer.address) === null || _16 === void 0 ? void 0 : _16.line1) !== null && _17 !== void 0 ? _17 : "",
37985
- line2: (_19 = (_18 = customer.address) === null || _18 === void 0 ? void 0 : _18.line2) !== null && _19 !== void 0 ? _19 : null,
37986
- city: (_21 = (_20 = customer.address) === null || _20 === void 0 ? void 0 : _20.city) !== null && _21 !== void 0 ? _21 : "",
37987
- province: (_23 = (_22 = customer.address) === null || _22 === void 0 ? void 0 : _22.province) !== null && _23 !== void 0 ? _23 : null,
37988
- provinceCode: (_25 = (_24 = customer.address) === null || _24 === void 0 ? void 0 : _24.provinceCode) !== null && _25 !== void 0 ? _25 : null,
37989
- zipCode: (_27 = (_26 = customer.address) === null || _26 === void 0 ? void 0 : _26.zipCode) !== null && _27 !== void 0 ? _27 : "",
37990
- country: (_29 = (_28 = customer.address) === null || _28 === void 0 ? void 0 : _28.country) !== null && _29 !== void 0 ? _29 : "",
37991
- countryCode: (_31 = (_30 = customer.address) === null || _30 === void 0 ? void 0 : _30.countryCode) !== null && _31 !== void 0 ? _31 : "",
37992
- company: (_33 = (_32 = customer.address) === null || _32 === void 0 ? void 0 : _32.company) !== null && _33 !== void 0 ? _33 : null,
37993
+ line1: (_t = customerData.address) === null || _t === void 0 ? void 0 : _t.line1,
37994
+ line2: (_v = (_u = customerData.address) === null || _u === void 0 ? void 0 : _u.line2) !== null && _v !== void 0 ? _v : null,
37995
+ city: (_w = customerData.address) === null || _w === void 0 ? void 0 : _w.city,
37996
+ province: (_y = (_x = customerData.address) === null || _x === void 0 ? void 0 : _x.province) !== null && _y !== void 0 ? _y : null,
37997
+ provinceCode: (_0 = (_z = customerData.address) === null || _z === void 0 ? void 0 : _z.provinceCode) !== null && _0 !== void 0 ? _0 : null,
37998
+ zipCode: (_1 = customerData.address) === null || _1 === void 0 ? void 0 : _1.zipCode,
37999
+ country: (_2 = customerData.address) === null || _2 === void 0 ? void 0 : _2.country,
38000
+ countryCode: (_3 = customerData.address) === null || _3 === void 0 ? void 0 : _3.countryCode,
38001
+ company: (_5 = (_4 = customerData.address) === null || _4 === void 0 ? void 0 : _4.company) !== null && _5 !== void 0 ? _5 : null,
37993
38002
  },
37994
38003
  } }));
37995
38004
  }
@@ -38003,7 +38012,6 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38003
38012
  const getShippingRates = () => __awaiter(this, void 0, void 0, function* () {
38004
38013
  try {
38005
38014
  const shippingRates = yield storeClient.checkout.getShippingRates(checkoutId);
38006
- console.log("FETCHED SHIPPING RATES: ", shippingRates);
38007
38015
  setShippingRates(shippingRates);
38008
38016
  }
38009
38017
  catch (error) {
@@ -38013,7 +38021,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38013
38021
  });
38014
38022
  getShippingRates();
38015
38023
  // eslint-disable-next-line react-hooks/exhaustive-deps
38016
- }, [step, clientSecret, checkoutId]);
38024
+ }, [step, checkoutSecret, checkoutId]);
38017
38025
  // Handle address form submission
38018
38026
  const handleCustomerSubmit = (data) => __awaiter(this, void 0, void 0, function* () {
38019
38027
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -38022,12 +38030,15 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38022
38030
  if (!newCustomerId) {
38023
38031
  const newCustomer = yield storeClient.customers.upsert({
38024
38032
  email: data.email,
38025
- phone: data.phone,
38026
- firstName: data.firstName,
38027
- lastName: data.lastName,
38028
- address: Object.assign(Object.assign({}, data.address), { company: (_a = data.address.company) !== null && _a !== void 0 ? _a : null, line2: (_b = data.address.line2) !== null && _b !== void 0 ? _b : null, province: (_c = data.address.province) !== null && _c !== void 0 ? _c : null, provinceCode: (_d = data.address.provinceCode) !== null && _d !== void 0 ? _d : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
38029
38033
  });
38030
38034
  yield storeClient.checkout.update(checkoutId, {
38035
+ customerData: {
38036
+ email: data.email,
38037
+ phone: data.phone,
38038
+ firstName: data.firstName,
38039
+ lastName: data.lastName,
38040
+ address: Object.assign(Object.assign({}, data.address), { company: (_a = data.address.company) !== null && _a !== void 0 ? _a : null, line2: (_b = data.address.line2) !== null && _b !== void 0 ? _b : null, province: (_c = data.address.province) !== null && _c !== void 0 ? _c : null, provinceCode: (_d = data.address.provinceCode) !== null && _d !== void 0 ? _d : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
38041
+ },
38031
38042
  customerId: newCustomer.id,
38032
38043
  });
38033
38044
  newCustomerId = newCustomer.id;
@@ -38041,7 +38052,6 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38041
38052
  address: Object.assign(Object.assign({}, data.address), { company: (_e = data.address.company) !== null && _e !== void 0 ? _e : null, line2: (_f = data.address.line2) !== null && _f !== void 0 ? _f : null, province: (_g = data.address.province) !== null && _g !== void 0 ? _g : null, provinceCode: (_h = data.address.provinceCode) !== null && _h !== void 0 ? _h : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
38042
38053
  });
38043
38054
  }
38044
- console.log("FETCHING SHIPPING RATES");
38045
38055
  const shippingRates = yield storeClient.checkout.getShippingRates(checkoutId);
38046
38056
  setShippingRates(shippingRates);
38047
38057
  setFormData(Object.assign(Object.assign({}, formData), { customer: data, customerId: newCustomerId }));
@@ -38051,16 +38061,20 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38051
38061
  const handleShippingSubmit = (data) => __awaiter(this, void 0, void 0, function* () {
38052
38062
  const newFormData = Object.assign(Object.assign({}, formData), { shipping: data });
38053
38063
  setFormData(newFormData);
38054
- const shipments = Object.entries(data).map(([id, shipmentFormData]) => ({
38055
- id: id,
38056
- shipmentData: {
38057
- rateId: shipmentFormData.rateId,
38058
- providerId: shipmentFormData.providerId,
38059
- priceInCents: shipmentFormData.priceInCents,
38060
- pickupPointId: shipmentFormData.pickupPointId,
38061
- },
38062
- }));
38063
- console.log("UPDATING CHECKOUT WITH SHIPMENTS: ", shipments);
38064
+ const shipments = Object.entries(data).map(([id, shipmentFormData]) => {
38065
+ var _a, _b;
38066
+ return ({
38067
+ id: id,
38068
+ shipmentData: {
38069
+ rateId: shipmentFormData.rateId,
38070
+ carrierId: (_a = shipmentFormData.carrierId) !== null && _a !== void 0 ? _a : null,
38071
+ priceInCents: shipmentFormData.priceInCents,
38072
+ pickupPointId: (_b = shipmentFormData.pickupPointId) !== null && _b !== void 0 ? _b : null,
38073
+ trackingId: null,
38074
+ trackingUrl: null,
38075
+ },
38076
+ });
38077
+ });
38064
38078
  yield storeClient.checkout.update(checkoutId, {
38065
38079
  shipments,
38066
38080
  });
@@ -38087,7 +38101,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38087
38101
  if (step === "shipping" && formData.customer) {
38088
38102
  return (jsxRuntime.jsx(ShipmentsShippingMethodForm, { setFormData: setFormData, formData: formData, shippingRates: shippingRates, initialData: formData.shipping, onSubmit: handleShippingSubmit, onBack: handleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: formData.customer.address.countryCode, shipments: shipments }));
38089
38103
  }
38090
- return (jsxRuntime.jsx(CustomerForm, { initialData: formData.customer, onSubmit: handleCustomerSubmit, clientProxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }));
38104
+ return (jsxRuntime.jsx(CustomerForm, { initialData: formData.customer, onSubmit: handleCustomerSubmit, clientProxy: clientProxy, checkoutSecret: checkoutSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }));
38091
38105
  };
38092
38106
  return jsxRuntime.jsx("div", { className: "relative h-max min-h-full w-full", children: renderStep() });
38093
38107
  }
@@ -38273,10 +38287,10 @@ function getIpInfo() {
38273
38287
  }
38274
38288
  function CheckoutEmbedComponent({ checkoutId, config }) {
38275
38289
  var _a, _b, _c, _d, _e, _f, _g;
38276
- const { cancelUrl, successUrl, appearance, locale, clientSecret, clientProxy, } = config;
38290
+ const { cancelUrl, successUrl, appearance, locale, checkoutSecret, clientProxy, } = config;
38277
38291
  const storeClient = React.useMemo(() => {
38278
- return createBetterStoreClient(clientSecret, { proxy: clientProxy });
38279
- }, [clientSecret, clientProxy]);
38292
+ return createBetterStoreClient(checkoutSecret, { proxy: clientProxy });
38293
+ }, [checkoutSecret, clientProxy]);
38280
38294
  React.useMemo(() => createI18nInstance(locale), [locale]);
38281
38295
  const { formData, step } = useFormStore();
38282
38296
  const paymentSecretPromiseRef = React.useRef(null);
@@ -38474,7 +38488,7 @@ function CheckoutEmbedComponent({ checkoutId, config }) {
38474
38488
  };
38475
38489
  // eslint-disable-next-line react-hooks/exhaustive-deps
38476
38490
  }, []);
38477
- return (jsxRuntime.jsxs("div", { className: "flex h-max flex-col gap-6 py-4 md:grid md:grid-cols-7 md:gap-0 md:py-12", children: [jsxRuntime.jsx("div", { className: "h-max px-4 md:col-span-4 md:px-8", children: loading ? (jsxRuntime.jsx(CheckoutFormLoading, {})) : (jsxRuntime.jsx(CheckoutForm, { locale: locale, setShippingCost: setTotalShipping, storeClient: storeClient, fonts: config.fonts, checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, clientSecret: clientSecret, onSuccess: onSuccess, onError: onError, exchangeRate: (_b = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _b !== void 0 ? _b : 1, publicKey: publicKey, paymentSecret: paymentSecret, paymentComponentKey: paymentComponentKey, clientProxy: clientProxy, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, shipments: (checkout === null || checkout === void 0 ? void 0 : checkout.shipments) || [] })) }), jsxRuntime.jsxs("div", { className: "order-first h-max px-4 md:order-last md:col-span-3 md:px-8", children: [jsxRuntime.jsx(Toaster, {}), loading ? (jsxRuntime.jsx(CheckoutSummaryLoading, {})) : (jsxRuntime.jsx(CheckoutSummary, { currency: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _c !== void 0 ? _c : "", lineItems: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _d !== void 0 ? _d : [], shipping: totalShipping, tax: (_e = checkout === null || checkout === void 0 ? void 0 : checkout.taxInCents) !== null && _e !== void 0 ? _e : 0, onCancel: onCancel, exchangeRate: (_f = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _f !== void 0 ? _f : 1, applyDiscountCode: applyDiscountCode, appliedDiscounts: (_g = checkout === null || checkout === void 0 ? void 0 : checkout.appliedDiscounts) !== null && _g !== void 0 ? _g : [], removeDiscount: removeDiscount }))] })] }));
38491
+ return (jsxRuntime.jsxs("div", { className: "flex h-max flex-col gap-6 py-4 md:grid md:grid-cols-7 md:gap-0 md:py-12", children: [jsxRuntime.jsx("div", { className: "h-max px-4 md:col-span-4 md:px-8", children: loading ? (jsxRuntime.jsx(CheckoutFormLoading, {})) : (jsxRuntime.jsx(CheckoutForm, { locale: locale, setShippingCost: setTotalShipping, storeClient: storeClient, fonts: config.fonts, checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, checkoutSecret: checkoutSecret, onSuccess: onSuccess, onError: onError, exchangeRate: (_b = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _b !== void 0 ? _b : 1, publicKey: publicKey, paymentSecret: paymentSecret, paymentComponentKey: paymentComponentKey, clientProxy: clientProxy, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, shipments: (checkout === null || checkout === void 0 ? void 0 : checkout.shipments) || [] })) }), jsxRuntime.jsxs("div", { className: "order-first h-max px-4 md:order-last md:col-span-3 md:px-8", children: [jsxRuntime.jsx(Toaster, {}), loading ? (jsxRuntime.jsx(CheckoutSummaryLoading, {})) : (jsxRuntime.jsx(CheckoutSummary, { currency: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _c !== void 0 ? _c : "", lineItems: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _d !== void 0 ? _d : [], shipping: totalShipping, tax: (_e = checkout === null || checkout === void 0 ? void 0 : checkout.taxInCents) !== null && _e !== void 0 ? _e : 0, onCancel: onCancel, exchangeRate: (_f = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _f !== void 0 ? _f : 1, applyDiscountCode: applyDiscountCode, appliedDiscounts: (_g = checkout === null || checkout === void 0 ? void 0 : checkout.appliedDiscounts) !== null && _g !== void 0 ? _g : [], removeDiscount: removeDiscount }))] })] }));
38478
38492
  }
38479
38493
  const CheckoutEmbed = React.memo(CheckoutEmbedComponent);
38480
38494
 
package/dist/index.mjs CHANGED
@@ -3467,27 +3467,35 @@ const createI18nInstance = (locale) => __awaiter(void 0, void 0, void 0, functio
3467
3467
  });
3468
3468
 
3469
3469
  // src/base-client.ts
3470
+ var DEFAULT_BASE_URL = "https://v1.betterstore.io";
3470
3471
  var BaseClient = class {
3471
3472
  constructor(config) {
3472
3473
  this.config = config;
3474
+ this.headers = {
3475
+ "Content-Type": "application/json",
3476
+ Authorization: `Bearer ${this.config.secret}`
3477
+ };
3473
3478
  }
3479
+ headers;
3474
3480
  async get(path, params) {
3475
- const url = new URL(path, this.config.baseUrl);
3481
+ const url = `${this.config.baseUrl}${path}`;
3482
+ const searchParams = new URLSearchParams();
3476
3483
  if (params) {
3477
3484
  Object.entries(params).forEach(([key, val]) => {
3478
- if (val !== void 0) url.searchParams.set(key, String(val));
3485
+ if (val !== void 0) searchParams.set(key, val);
3479
3486
  });
3480
3487
  }
3481
- const res = await fetch(url.toString(), {
3488
+ console.log(`${url}?${searchParams.toString()}`);
3489
+ const res = await fetch(`${url}?${searchParams.toString()}`, {
3482
3490
  method: "GET",
3483
- headers: this.config.headers
3491
+ headers: this.headers
3484
3492
  });
3485
3493
  return this.handleResponse(res);
3486
3494
  }
3487
3495
  async post(path, body) {
3488
3496
  const res = await fetch(`${this.config.baseUrl}${path}`, {
3489
3497
  method: "POST",
3490
- headers: this.config.headers,
3498
+ headers: this.headers,
3491
3499
  body: body ? JSON.stringify(body) : void 0
3492
3500
  });
3493
3501
  return this.handleResponse(res);
@@ -3495,13 +3503,14 @@ var BaseClient = class {
3495
3503
  async delete(path) {
3496
3504
  const res = await fetch(`${this.config.baseUrl}${path}`, {
3497
3505
  method: "DELETE",
3498
- headers: this.config.headers
3506
+ headers: this.headers
3499
3507
  });
3500
3508
  return this.handleResponse(res);
3501
3509
  }
3502
3510
  async handleResponse(res) {
3503
3511
  if (!res.ok) {
3504
- const error = await res.json().catch(() => ({ message: res.statusText }));
3512
+ const error = await res.json().catch(() => ({ message: res.statusText, data: res.body }));
3513
+ console.log(error);
3505
3514
  throw new Error(error.message || `HTTP ${res.status}`);
3506
3515
  }
3507
3516
  return res.json();
@@ -3598,13 +3607,10 @@ var ClientUtilsNamespace = class {
3598
3607
  };
3599
3608
 
3600
3609
  // src/client-factory.ts
3601
- function createBetterStoreClient(clientSecret, config) {
3610
+ function createBetterStoreClient(checkoutSecret, config) {
3602
3611
  const baseClient = new BaseClient({
3603
- baseUrl: config?.proxy || "https://api.betterstore.com",
3604
- headers: {
3605
- Authorization: `Bearer ${clientSecret}`,
3606
- "Content-Type": "application/json"
3607
- }
3612
+ baseUrl: config?.proxy || DEFAULT_BASE_URL,
3613
+ secret: checkoutSecret
3608
3614
  });
3609
3615
  return {
3610
3616
  checkout: new ClientCheckoutNamespace(baseClient),
@@ -8612,12 +8618,13 @@ const customerSchema = objectType({
8612
8618
  company: stringType().nullable().optional(),
8613
8619
  }),
8614
8620
  phone: stringType().regex(phoneRegex, "invalid_phone"),
8615
- isEmailSubscribed: booleanType().optional(),
8621
+ isSubscribedEmail: booleanType().optional(),
8622
+ isSubscribedSMS: booleanType().optional(),
8616
8623
  });
8617
8624
  // Shipping method schema
8618
8625
  const shippingMethodSchema = objectType({
8619
8626
  rateId: stringType().min(1, "required_error"),
8620
- providerId: optionalType(stringType()),
8627
+ carrierId: optionalType(stringType()),
8621
8628
  priceInCents: numberType().min(1, "required_error"),
8622
8629
  pickupPointId: stringType().optional(),
8623
8630
  pickupPointDisplayName: stringType().optional(), // Only for display purposes
@@ -31237,10 +31244,10 @@ const countryProvinces = {
31237
31244
  };
31238
31245
  const countriesWithProvinces = Object.keys(countryProvinces);
31239
31246
 
31240
- function AddressInput({ className = "", proxy, clientSecret, latitude, longitude, currentAlpha3CountryCode, locale, }) {
31247
+ function AddressInput({ className = "", proxy, checkoutSecret, latitude, longitude, currentAlpha3CountryCode, locale, }) {
31241
31248
  var _a;
31242
31249
  const { t } = useTranslation();
31243
- const storeClient = createBetterStoreClient(clientSecret, { proxy });
31250
+ const storeClient = createBetterStoreClient(checkoutSecret, { proxy });
31244
31251
  const form = useFormContext();
31245
31252
  const [showSuggestions, setShowSuggestions] = useState(false);
31246
31253
  const [showAllInputs, setShowAllInputs] = useState(false);
@@ -31285,6 +31292,8 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
31285
31292
  const fetchSuggestions = () => __awaiter(this, void 0, void 0, function* () {
31286
31293
  try {
31287
31294
  const countryCode = form.watch("address.countryCode");
31295
+ if (!addressInput)
31296
+ return;
31288
31297
  const results = yield storeClient.utils.autosuggestAddress({
31289
31298
  query: addressInput,
31290
31299
  latitude: latitude,
@@ -31388,7 +31397,7 @@ const r$1=(t,r,o)=>{if(t&&"reportValidity"in t){const s=get(o,r);t.setCustomVali
31388
31397
 
31389
31398
  function n(r,e){for(var n={};r.length;){var s=r[0],t=s.code,i=s.message,a=s.path.join(".");if(!n[a])if("unionErrors"in s){var u=s.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:t};if("unionErrors"in s&&s.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[s.code];n[a]=appendErrors(a,e,n,t,f?[].concat(f,s.message):s.message);}r.shift();}return n}function s(o$1,s,t){return void 0===t&&(t={}),function(i,a,u){try{return Promise.resolve(function(e,n){try{var a=Promise.resolve(o$1["sync"===t.mode?"parse":"parseAsync"](i,s)).then(function(e){return u.shouldUseNativeValidation&&o({},u),{errors:{},values:t.raw?Object.assign({},i):e}});}catch(r){return n(r)}return a&&a.then?a.then(void 0,n):a}(0,function(r){if(function(r){return Array.isArray(null==r?void 0:r.errors)}(r))return {values:{},errors:s$1(n(r.errors,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)};throw r}))}catch(r){return Promise.reject(r)}}}
31390
31399
 
31391
- function CustomerForm({ initialData, onSubmit, clientProxy, clientSecret, latitude, longitude, currentAlpha3CountryCode, locale, }) {
31400
+ function CustomerForm({ initialData, onSubmit, clientProxy, checkoutSecret, latitude, longitude, currentAlpha3CountryCode, locale, }) {
31392
31401
  const { t } = useTranslation();
31393
31402
  const form = useForm({
31394
31403
  resolver: s(customerSchema),
@@ -31408,7 +31417,7 @@ function CustomerForm({ initialData, onSubmit, clientProxy, clientSecret, latitu
31408
31417
  phone: "",
31409
31418
  },
31410
31419
  });
31411
- return (jsx(Form, Object.assign({}, form, { children: jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "grid gap-5 md:grid-cols-2", children: [jsx("div", { className: "md:col-span-2", children: jsx("h2", { children: t("CheckoutEmbed.CustomerForm.title") }) }), jsx(InputGroup, { className: "md:col-span-2", name: "email", label: t("CheckoutEmbed.CustomerForm.email"), type: "email", autoComplete: "email" }), jsx(InputGroup, { name: "firstName", label: t("CheckoutEmbed.CustomerForm.firstName"), autoComplete: "given-name" }), jsx(InputGroup, { name: "lastName", label: t("CheckoutEmbed.CustomerForm.lastName"), autoComplete: "family-name" }), jsx(AddressInput, { className: "md:col-span-2", proxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }), jsx(InputGroup, { name: "phone", label: t("CheckoutEmbed.CustomerForm.phone"), type: "tel", autoComplete: "tel" }), jsx("div", { className: "flex justify-end pt-2 md:col-span-2", children: jsx(SubmitButton, { isValid: form.formState.isDirty || form.formState.isValid, isSubmitting: form.formState.isSubmitting, children: t("CheckoutEmbed.CustomerForm.button") }) })] }) })));
31420
+ return (jsx(Form, Object.assign({}, form, { children: jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "grid gap-5 md:grid-cols-2", children: [jsx("div", { className: "md:col-span-2", children: jsx("h2", { children: t("CheckoutEmbed.CustomerForm.title") }) }), jsx(InputGroup, { className: "md:col-span-2", name: "email", label: t("CheckoutEmbed.CustomerForm.email"), type: "email", autoComplete: "email" }), jsx(InputGroup, { name: "firstName", label: t("CheckoutEmbed.CustomerForm.firstName"), autoComplete: "given-name" }), jsx(InputGroup, { name: "lastName", label: t("CheckoutEmbed.CustomerForm.lastName"), autoComplete: "family-name" }), jsx(AddressInput, { className: "md:col-span-2", proxy: clientProxy, checkoutSecret: checkoutSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }), jsx(InputGroup, { name: "phone", label: t("CheckoutEmbed.CustomerForm.phone"), type: "tel", autoComplete: "tel" }), jsx("div", { className: "flex justify-end pt-2 md:col-span-2", children: jsx(SubmitButton, { isValid: form.formState.isDirty || form.formState.isValid, isSubmitting: form.formState.isSubmitting, children: t("CheckoutEmbed.CustomerForm.button") }) })] }) })));
31412
31421
  }
31413
31422
 
31414
31423
  var reactStripe_umd$1 = {exports: {}};
@@ -37806,7 +37815,7 @@ function ShipmentsShippingMethodForm({ shippingRates, initialData, onSubmit, onB
37806
37815
  shipment.id,
37807
37816
  {
37808
37817
  rateId: "",
37809
- provider: "",
37818
+ carrierId: "",
37810
37819
  priceInCents: 0,
37811
37820
  pickupPointId: "",
37812
37821
  pickupPointDisplayName: "",
@@ -37850,14 +37859,14 @@ const SingleShipmentSection = ({ shippingRates, form, currency, exchangeRate, lo
37850
37859
  return (jsx(ShippingOptionWrapper, { rate: rate, onPickupPointSelected: (pickupPointId, pickupPointName) => {
37851
37860
  const newData = {
37852
37861
  rateId: rate.id,
37853
- providerId: isAutoRate ? rate.carrierId : undefined,
37862
+ carrierId: isAutoRate ? rate.carrierId : undefined,
37854
37863
  priceInCents: intPrice,
37855
37864
  displayName: name,
37856
37865
  pickupPointId: isZasilkovna ? pickupPointId : "",
37857
37866
  pickupPointDisplayName: isZasilkovna ? pickupPointName : "",
37858
37867
  };
37859
37868
  form.setValue(`${shipmentId}.rateId`, newData.rateId);
37860
- form.setValue(`${shipmentId}.providerId`, newData.providerId);
37869
+ form.setValue(`${shipmentId}.carrierId`, newData.carrierId);
37861
37870
  form.setValue(`${shipmentId}.displayName`, newData.displayName);
37862
37871
  form.setValue(`${shipmentId}.priceInCents`, newData.priceInCents);
37863
37872
  form.setValue(`${shipmentId}.pickupPointId`, newData.pickupPointId);
@@ -37885,7 +37894,7 @@ const resetFormStore = (formData) => {
37885
37894
  localStorage.setItem("checkout", JSON.stringify(Object.assign(Object.assign({}, currentState), { state: Object.assign(Object.assign({}, currentState.state), { step: "customer", formData: { customer: formData.customer } }) })));
37886
37895
  };
37887
37896
 
37888
- function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, fonts, locale, setShippingCost, exchangeRate, paymentSecret, publicKey, paymentComponentKey, clientProxy, latitude, longitude, currentAlpha3CountryCode, shipments, }) {
37897
+ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl, checkoutSecret, customer, customerData, currency, checkoutAppearance, fonts, locale, setShippingCost, exchangeRate, paymentSecret, publicKey, paymentComponentKey, clientProxy, latitude, longitude, currentAlpha3CountryCode, shipments, }) {
37889
37898
  const { formData, setFormData, step, setStep, checkoutId: storedCheckoutId, setCheckoutId, } = useFormStore();
37890
37899
  const [shippingRates, setShippingRates] = useState(undefined);
37891
37900
  const validateStep = useCallback(() => {
@@ -37910,37 +37919,37 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
37910
37919
  // eslint-disable-next-line react-hooks/exhaustive-deps
37911
37920
  }, [step]);
37912
37921
  useEffect(() => {
37913
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33;
37922
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
37914
37923
  if (checkoutId !== storedCheckoutId) {
37915
37924
  setStep("customer");
37916
37925
  setCheckoutId(checkoutId);
37917
- if (customer) {
37918
- if ((_a = customer === null || customer === void 0 ? void 0 : customer.address) === null || _a === void 0 ? void 0 : _a.city) {
37926
+ if (customerData && customer) {
37927
+ if ((_a = customerData === null || customerData === void 0 ? void 0 : customerData.address) === null || _a === void 0 ? void 0 : _a.city) {
37919
37928
  setStep("shipping");
37920
37929
  }
37921
37930
  setFormData({
37922
37931
  customerId: customer.id,
37923
37932
  customer: {
37924
- firstName: (_d = (_c = (_b = customer.address) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.split(" ")[0]) !== null && _d !== void 0 ? _d : "",
37925
- lastName: (_g = (_f = (_e = customer.address) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.split(" ")[1]) !== null && _g !== void 0 ? _g : "",
37926
- phone: (_j = (_h = customer.address) === null || _h === void 0 ? void 0 : _h.phone) !== null && _j !== void 0 ? _j : "",
37927
- email: (_k = customer.email) !== null && _k !== void 0 ? _k : "",
37933
+ firstName: customerData.firstName,
37934
+ lastName: customerData.lastName,
37935
+ phone: customerData.phone,
37936
+ email: customerData.email,
37928
37937
  address: {
37929
- line1: (_m = (_l = customer.address) === null || _l === void 0 ? void 0 : _l.line1) !== null && _m !== void 0 ? _m : "",
37930
- line2: (_p = (_o = customer.address) === null || _o === void 0 ? void 0 : _o.line2) !== null && _p !== void 0 ? _p : null,
37931
- city: (_r = (_q = customer.address) === null || _q === void 0 ? void 0 : _q.city) !== null && _r !== void 0 ? _r : "",
37932
- province: (_t = (_s = customer.address) === null || _s === void 0 ? void 0 : _s.province) !== null && _t !== void 0 ? _t : null,
37933
- provinceCode: (_v = (_u = customer.address) === null || _u === void 0 ? void 0 : _u.provinceCode) !== null && _v !== void 0 ? _v : null,
37934
- zipCode: (_x = (_w = customer.address) === null || _w === void 0 ? void 0 : _w.zipCode) !== null && _x !== void 0 ? _x : "",
37935
- country: (_z = (_y = customer.address) === null || _y === void 0 ? void 0 : _y.country) !== null && _z !== void 0 ? _z : "",
37936
- countryCode: (_1 = (_0 = customer.address) === null || _0 === void 0 ? void 0 : _0.countryCode) !== null && _1 !== void 0 ? _1 : "",
37937
- company: (_3 = (_2 = customer.address) === null || _2 === void 0 ? void 0 : _2.company) !== null && _3 !== void 0 ? _3 : null,
37938
+ line1: (_b = customerData.address) === null || _b === void 0 ? void 0 : _b.line1,
37939
+ line2: (_d = (_c = customerData.address) === null || _c === void 0 ? void 0 : _c.line2) !== null && _d !== void 0 ? _d : null,
37940
+ city: (_e = customerData.address) === null || _e === void 0 ? void 0 : _e.city,
37941
+ province: (_g = (_f = customerData.address) === null || _f === void 0 ? void 0 : _f.province) !== null && _g !== void 0 ? _g : null,
37942
+ provinceCode: (_j = (_h = customerData.address) === null || _h === void 0 ? void 0 : _h.provinceCode) !== null && _j !== void 0 ? _j : null,
37943
+ zipCode: (_k = customerData.address) === null || _k === void 0 ? void 0 : _k.zipCode,
37944
+ country: (_l = customerData.address) === null || _l === void 0 ? void 0 : _l.country,
37945
+ countryCode: (_m = customerData.address) === null || _m === void 0 ? void 0 : _m.countryCode,
37946
+ company: (_p = (_o = customerData.address) === null || _o === void 0 ? void 0 : _o.company) !== null && _p !== void 0 ? _p : null,
37938
37947
  },
37939
37948
  },
37940
37949
  });
37941
37950
  return;
37942
37951
  }
37943
- else if ((_4 = formData.customer) === null || _4 === void 0 ? void 0 : _4.email) {
37952
+ else if ((_q = formData.customer) === null || _q === void 0 ? void 0 : _q.email) {
37944
37953
  setFormData({
37945
37954
  customer: formData.customer,
37946
37955
  });
@@ -37950,26 +37959,26 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
37950
37959
  }
37951
37960
  return;
37952
37961
  }
37953
- if (customer && !((_5 = formData.customer) === null || _5 === void 0 ? void 0 : _5.email)) {
37962
+ if (customerData && customer && !((_r = formData.customer) === null || _r === void 0 ? void 0 : _r.email)) {
37954
37963
  setStep("customer");
37955
- if ((_6 = customer.address) === null || _6 === void 0 ? void 0 : _6.city) {
37964
+ if ((_s = customerData === null || customerData === void 0 ? void 0 : customerData.address) === null || _s === void 0 ? void 0 : _s.city) {
37956
37965
  setStep("shipping");
37957
37966
  }
37958
37967
  setFormData(Object.assign(Object.assign({}, formData), { customerId: customer.id, customer: {
37959
- firstName: (_9 = (_8 = (_7 = customer.address) === null || _7 === void 0 ? void 0 : _7.name) === null || _8 === void 0 ? void 0 : _8.split(" ")[0]) !== null && _9 !== void 0 ? _9 : "",
37960
- lastName: (_12 = (_11 = (_10 = customer.address) === null || _10 === void 0 ? void 0 : _10.name) === null || _11 === void 0 ? void 0 : _11.split(" ")[1]) !== null && _12 !== void 0 ? _12 : "",
37961
- phone: (_14 = (_13 = customer.address) === null || _13 === void 0 ? void 0 : _13.phone) !== null && _14 !== void 0 ? _14 : "",
37962
- email: (_15 = customer.email) !== null && _15 !== void 0 ? _15 : "",
37968
+ firstName: customerData.firstName,
37969
+ lastName: customerData.lastName,
37970
+ phone: customerData.phone,
37971
+ email: customerData.email,
37963
37972
  address: {
37964
- line1: (_17 = (_16 = customer.address) === null || _16 === void 0 ? void 0 : _16.line1) !== null && _17 !== void 0 ? _17 : "",
37965
- line2: (_19 = (_18 = customer.address) === null || _18 === void 0 ? void 0 : _18.line2) !== null && _19 !== void 0 ? _19 : null,
37966
- city: (_21 = (_20 = customer.address) === null || _20 === void 0 ? void 0 : _20.city) !== null && _21 !== void 0 ? _21 : "",
37967
- province: (_23 = (_22 = customer.address) === null || _22 === void 0 ? void 0 : _22.province) !== null && _23 !== void 0 ? _23 : null,
37968
- provinceCode: (_25 = (_24 = customer.address) === null || _24 === void 0 ? void 0 : _24.provinceCode) !== null && _25 !== void 0 ? _25 : null,
37969
- zipCode: (_27 = (_26 = customer.address) === null || _26 === void 0 ? void 0 : _26.zipCode) !== null && _27 !== void 0 ? _27 : "",
37970
- country: (_29 = (_28 = customer.address) === null || _28 === void 0 ? void 0 : _28.country) !== null && _29 !== void 0 ? _29 : "",
37971
- countryCode: (_31 = (_30 = customer.address) === null || _30 === void 0 ? void 0 : _30.countryCode) !== null && _31 !== void 0 ? _31 : "",
37972
- company: (_33 = (_32 = customer.address) === null || _32 === void 0 ? void 0 : _32.company) !== null && _33 !== void 0 ? _33 : null,
37973
+ line1: (_t = customerData.address) === null || _t === void 0 ? void 0 : _t.line1,
37974
+ line2: (_v = (_u = customerData.address) === null || _u === void 0 ? void 0 : _u.line2) !== null && _v !== void 0 ? _v : null,
37975
+ city: (_w = customerData.address) === null || _w === void 0 ? void 0 : _w.city,
37976
+ province: (_y = (_x = customerData.address) === null || _x === void 0 ? void 0 : _x.province) !== null && _y !== void 0 ? _y : null,
37977
+ provinceCode: (_0 = (_z = customerData.address) === null || _z === void 0 ? void 0 : _z.provinceCode) !== null && _0 !== void 0 ? _0 : null,
37978
+ zipCode: (_1 = customerData.address) === null || _1 === void 0 ? void 0 : _1.zipCode,
37979
+ country: (_2 = customerData.address) === null || _2 === void 0 ? void 0 : _2.country,
37980
+ countryCode: (_3 = customerData.address) === null || _3 === void 0 ? void 0 : _3.countryCode,
37981
+ company: (_5 = (_4 = customerData.address) === null || _4 === void 0 ? void 0 : _4.company) !== null && _5 !== void 0 ? _5 : null,
37973
37982
  },
37974
37983
  } }));
37975
37984
  }
@@ -37983,7 +37992,6 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
37983
37992
  const getShippingRates = () => __awaiter(this, void 0, void 0, function* () {
37984
37993
  try {
37985
37994
  const shippingRates = yield storeClient.checkout.getShippingRates(checkoutId);
37986
- console.log("FETCHED SHIPPING RATES: ", shippingRates);
37987
37995
  setShippingRates(shippingRates);
37988
37996
  }
37989
37997
  catch (error) {
@@ -37993,7 +38001,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
37993
38001
  });
37994
38002
  getShippingRates();
37995
38003
  // eslint-disable-next-line react-hooks/exhaustive-deps
37996
- }, [step, clientSecret, checkoutId]);
38004
+ }, [step, checkoutSecret, checkoutId]);
37997
38005
  // Handle address form submission
37998
38006
  const handleCustomerSubmit = (data) => __awaiter(this, void 0, void 0, function* () {
37999
38007
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -38002,12 +38010,15 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38002
38010
  if (!newCustomerId) {
38003
38011
  const newCustomer = yield storeClient.customers.upsert({
38004
38012
  email: data.email,
38005
- phone: data.phone,
38006
- firstName: data.firstName,
38007
- lastName: data.lastName,
38008
- address: Object.assign(Object.assign({}, data.address), { company: (_a = data.address.company) !== null && _a !== void 0 ? _a : null, line2: (_b = data.address.line2) !== null && _b !== void 0 ? _b : null, province: (_c = data.address.province) !== null && _c !== void 0 ? _c : null, provinceCode: (_d = data.address.provinceCode) !== null && _d !== void 0 ? _d : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
38009
38013
  });
38010
38014
  yield storeClient.checkout.update(checkoutId, {
38015
+ customerData: {
38016
+ email: data.email,
38017
+ phone: data.phone,
38018
+ firstName: data.firstName,
38019
+ lastName: data.lastName,
38020
+ address: Object.assign(Object.assign({}, data.address), { company: (_a = data.address.company) !== null && _a !== void 0 ? _a : null, line2: (_b = data.address.line2) !== null && _b !== void 0 ? _b : null, province: (_c = data.address.province) !== null && _c !== void 0 ? _c : null, provinceCode: (_d = data.address.provinceCode) !== null && _d !== void 0 ? _d : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
38021
+ },
38011
38022
  customerId: newCustomer.id,
38012
38023
  });
38013
38024
  newCustomerId = newCustomer.id;
@@ -38021,7 +38032,6 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38021
38032
  address: Object.assign(Object.assign({}, data.address), { company: (_e = data.address.company) !== null && _e !== void 0 ? _e : null, line2: (_f = data.address.line2) !== null && _f !== void 0 ? _f : null, province: (_g = data.address.province) !== null && _g !== void 0 ? _g : null, provinceCode: (_h = data.address.provinceCode) !== null && _h !== void 0 ? _h : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
38022
38033
  });
38023
38034
  }
38024
- console.log("FETCHING SHIPPING RATES");
38025
38035
  const shippingRates = yield storeClient.checkout.getShippingRates(checkoutId);
38026
38036
  setShippingRates(shippingRates);
38027
38037
  setFormData(Object.assign(Object.assign({}, formData), { customer: data, customerId: newCustomerId }));
@@ -38031,16 +38041,20 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38031
38041
  const handleShippingSubmit = (data) => __awaiter(this, void 0, void 0, function* () {
38032
38042
  const newFormData = Object.assign(Object.assign({}, formData), { shipping: data });
38033
38043
  setFormData(newFormData);
38034
- const shipments = Object.entries(data).map(([id, shipmentFormData]) => ({
38035
- id: id,
38036
- shipmentData: {
38037
- rateId: shipmentFormData.rateId,
38038
- providerId: shipmentFormData.providerId,
38039
- priceInCents: shipmentFormData.priceInCents,
38040
- pickupPointId: shipmentFormData.pickupPointId,
38041
- },
38042
- }));
38043
- console.log("UPDATING CHECKOUT WITH SHIPMENTS: ", shipments);
38044
+ const shipments = Object.entries(data).map(([id, shipmentFormData]) => {
38045
+ var _a, _b;
38046
+ return ({
38047
+ id: id,
38048
+ shipmentData: {
38049
+ rateId: shipmentFormData.rateId,
38050
+ carrierId: (_a = shipmentFormData.carrierId) !== null && _a !== void 0 ? _a : null,
38051
+ priceInCents: shipmentFormData.priceInCents,
38052
+ pickupPointId: (_b = shipmentFormData.pickupPointId) !== null && _b !== void 0 ? _b : null,
38053
+ trackingId: null,
38054
+ trackingUrl: null,
38055
+ },
38056
+ });
38057
+ });
38044
38058
  yield storeClient.checkout.update(checkoutId, {
38045
38059
  shipments,
38046
38060
  });
@@ -38067,7 +38081,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
38067
38081
  if (step === "shipping" && formData.customer) {
38068
38082
  return (jsx(ShipmentsShippingMethodForm, { setFormData: setFormData, formData: formData, shippingRates: shippingRates, initialData: formData.shipping, onSubmit: handleShippingSubmit, onBack: handleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: formData.customer.address.countryCode, shipments: shipments }));
38069
38083
  }
38070
- return (jsx(CustomerForm, { initialData: formData.customer, onSubmit: handleCustomerSubmit, clientProxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }));
38084
+ return (jsx(CustomerForm, { initialData: formData.customer, onSubmit: handleCustomerSubmit, clientProxy: clientProxy, checkoutSecret: checkoutSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }));
38071
38085
  };
38072
38086
  return jsx("div", { className: "relative h-max min-h-full w-full", children: renderStep() });
38073
38087
  }
@@ -38253,10 +38267,10 @@ function getIpInfo() {
38253
38267
  }
38254
38268
  function CheckoutEmbedComponent({ checkoutId, config }) {
38255
38269
  var _a, _b, _c, _d, _e, _f, _g;
38256
- const { cancelUrl, successUrl, appearance, locale, clientSecret, clientProxy, } = config;
38270
+ const { cancelUrl, successUrl, appearance, locale, checkoutSecret, clientProxy, } = config;
38257
38271
  const storeClient = React__default.useMemo(() => {
38258
- return createBetterStoreClient(clientSecret, { proxy: clientProxy });
38259
- }, [clientSecret, clientProxy]);
38272
+ return createBetterStoreClient(checkoutSecret, { proxy: clientProxy });
38273
+ }, [checkoutSecret, clientProxy]);
38260
38274
  React__default.useMemo(() => createI18nInstance(locale), [locale]);
38261
38275
  const { formData, step } = useFormStore();
38262
38276
  const paymentSecretPromiseRef = useRef(null);
@@ -38454,7 +38468,7 @@ function CheckoutEmbedComponent({ checkoutId, config }) {
38454
38468
  };
38455
38469
  // eslint-disable-next-line react-hooks/exhaustive-deps
38456
38470
  }, []);
38457
- return (jsxs("div", { className: "flex h-max flex-col gap-6 py-4 md:grid md:grid-cols-7 md:gap-0 md:py-12", children: [jsx("div", { className: "h-max px-4 md:col-span-4 md:px-8", children: loading ? (jsx(CheckoutFormLoading, {})) : (jsx(CheckoutForm, { locale: locale, setShippingCost: setTotalShipping, storeClient: storeClient, fonts: config.fonts, checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, clientSecret: clientSecret, onSuccess: onSuccess, onError: onError, exchangeRate: (_b = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _b !== void 0 ? _b : 1, publicKey: publicKey, paymentSecret: paymentSecret, paymentComponentKey: paymentComponentKey, clientProxy: clientProxy, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, shipments: (checkout === null || checkout === void 0 ? void 0 : checkout.shipments) || [] })) }), jsxs("div", { className: "order-first h-max px-4 md:order-last md:col-span-3 md:px-8", children: [jsx(Toaster, {}), loading ? (jsx(CheckoutSummaryLoading, {})) : (jsx(CheckoutSummary, { currency: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _c !== void 0 ? _c : "", lineItems: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _d !== void 0 ? _d : [], shipping: totalShipping, tax: (_e = checkout === null || checkout === void 0 ? void 0 : checkout.taxInCents) !== null && _e !== void 0 ? _e : 0, onCancel: onCancel, exchangeRate: (_f = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _f !== void 0 ? _f : 1, applyDiscountCode: applyDiscountCode, appliedDiscounts: (_g = checkout === null || checkout === void 0 ? void 0 : checkout.appliedDiscounts) !== null && _g !== void 0 ? _g : [], removeDiscount: removeDiscount }))] })] }));
38471
+ return (jsxs("div", { className: "flex h-max flex-col gap-6 py-4 md:grid md:grid-cols-7 md:gap-0 md:py-12", children: [jsx("div", { className: "h-max px-4 md:col-span-4 md:px-8", children: loading ? (jsx(CheckoutFormLoading, {})) : (jsx(CheckoutForm, { locale: locale, setShippingCost: setTotalShipping, storeClient: storeClient, fonts: config.fonts, checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, checkoutSecret: checkoutSecret, onSuccess: onSuccess, onError: onError, exchangeRate: (_b = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _b !== void 0 ? _b : 1, publicKey: publicKey, paymentSecret: paymentSecret, paymentComponentKey: paymentComponentKey, clientProxy: clientProxy, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, shipments: (checkout === null || checkout === void 0 ? void 0 : checkout.shipments) || [] })) }), jsxs("div", { className: "order-first h-max px-4 md:order-last md:col-span-3 md:px-8", children: [jsx(Toaster, {}), loading ? (jsx(CheckoutSummaryLoading, {})) : (jsx(CheckoutSummary, { currency: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _c !== void 0 ? _c : "", lineItems: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _d !== void 0 ? _d : [], shipping: totalShipping, tax: (_e = checkout === null || checkout === void 0 ? void 0 : checkout.taxInCents) !== null && _e !== void 0 ? _e : 0, onCancel: onCancel, exchangeRate: (_f = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _f !== void 0 ? _f : 1, applyDiscountCode: applyDiscountCode, appliedDiscounts: (_g = checkout === null || checkout === void 0 ? void 0 : checkout.appliedDiscounts) !== null && _g !== void 0 ? _g : [], removeDiscount: removeDiscount }))] })] }));
38458
38472
  }
38459
38473
  const CheckoutEmbed = memo(CheckoutEmbedComponent);
38460
38474
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/react",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -19,12 +19,14 @@
19
19
  "@types/react": "19.1.0",
20
20
  "@types/react-dom": "19.1.1",
21
21
  "@vitejs/plugin-react": "^5.0.4",
22
+ "dotenv": "^17.2.3",
22
23
  "eslint": "^9.29.0",
23
24
  "eslint-plugin-i18next": "^6.1.2",
24
25
  "rollup": "^4.41.1",
25
26
  "rollup-plugin-dts": "^6.2.1",
26
27
  "rollup-plugin-peer-deps-external": "^2.2.4",
27
28
  "tailwindcss": "^4.1.11",
29
+ "tsx": "^4.21.0",
28
30
  "typescript": "5.8.2",
29
31
  "vite": "^7.1.9",
30
32
  "@betterstore/eslint-config": "0.0.0",
@@ -76,8 +78,8 @@
76
78
  "world_countries_lists": "^3.2.0",
77
79
  "zod": "^3.25.30",
78
80
  "zustand": "^5.0.5",
79
- "@betterstore/helpers": "0.7.1",
80
- "@betterstore/sdk": "0.7.1"
81
+ "@betterstore/helpers": "0.7.2",
82
+ "@betterstore/sdk": "0.7.2"
81
83
  },
82
84
  "publishConfig": {
83
85
  "access": "public"
@@ -85,6 +87,7 @@
85
87
  "scripts": {
86
88
  "build": "rollup -c",
87
89
  "dev": "vite",
90
+ "generate-test-checkout": "tsx src/dev/generate-test-checkout.ts",
88
91
  "lint": "eslint . --max-warnings 0",
89
92
  "check-types": "tsc --noEmit"
90
93
  }