@usethrottle/checkout-react 2.1.0 → 2.2.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 +14 -4
- package/dist/index.cjs +1012 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -8
- package/dist/index.d.ts +21 -8
- package/dist/index.js +1036 -13
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { CSSProperties, RefObject, ReactNode } from 'react';
|
|
3
|
+
import { CurrencyCode } from '@usethrottle/money';
|
|
4
|
+
import * as money from '@usethrottle/money';
|
|
5
|
+
export { money };
|
|
6
|
+
export { CURRENCIES, CurrencyCode, MoneyValue, UnknownCurrencyError, currencySymbol, formatMoney, isKnownCurrency, minorUnitsOf, moneyValue, parseMoney, toDecimalString, toMinor } from '@usethrottle/money';
|
|
3
7
|
import { CartSessionCart, AddLineItemInput, UpdateLineItemInput, SelectShippingInput, CheckoutHandoffInput, CheckoutHandoff, SelectedShipping } from '@usethrottle/cart';
|
|
4
8
|
|
|
5
9
|
/**
|
|
@@ -42,7 +46,7 @@ type ThrottleEvent = {
|
|
|
42
46
|
subscriptionIds?: string[];
|
|
43
47
|
/** v1.4 additive — order total in minor units, for analytics purchase events. */
|
|
44
48
|
total?: number;
|
|
45
|
-
currency?:
|
|
49
|
+
currency?: CurrencyCode;
|
|
46
50
|
lineItems?: ThrottleCompletedLineItem[];
|
|
47
51
|
} | {
|
|
48
52
|
type: 'throttle.cancelled';
|
|
@@ -151,9 +155,13 @@ interface ThrottleEmbedProps {
|
|
|
151
155
|
subscriptionId?: string;
|
|
152
156
|
/** Every subscription the checkout created, in line order. `subscriptionId` is set only when there is exactly one. */
|
|
153
157
|
subscriptionIds?: string[];
|
|
154
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Order total in minor units — fire `gtag`/`fbq` purchase events with
|
|
160
|
+
* value = `toDecimalString(total, currency)` (the currency's own exponent:
|
|
161
|
+
* JPY has none, KWD has three).
|
|
162
|
+
*/
|
|
155
163
|
total?: number;
|
|
156
|
-
currency?:
|
|
164
|
+
currency?: CurrencyCode;
|
|
157
165
|
lineItems?: ThrottleCompletedLineItem[];
|
|
158
166
|
}) => void;
|
|
159
167
|
onFailed?: (evt: {
|
|
@@ -221,9 +229,14 @@ declare function useThrottleEvents({ iframeRef, expectedOrigin, onMessage }: Use
|
|
|
221
229
|
interface UseCartSessionOptions {
|
|
222
230
|
/** Application UUID. */
|
|
223
231
|
applicationId: string;
|
|
224
|
-
/** Workspace environment UUID the
|
|
232
|
+
/** Workspace environment UUID the quote token was minted for. */
|
|
225
233
|
environmentId: string;
|
|
226
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Storefront quote token (`qt_…`), from the dashboard Shipping & Tax page or
|
|
236
|
+
* `POST /api/v1/shipping-tax/quote-tokens`. Tokens minted before `qt_` start
|
|
237
|
+
* with `pk_` and keep working. A `pk_` publishable API key is a different
|
|
238
|
+
* credential and is refused (`401 invalid_quote_token`).
|
|
239
|
+
*/
|
|
227
240
|
quoteToken: string;
|
|
228
241
|
baseUrl?: string;
|
|
229
242
|
/**
|
|
@@ -284,7 +297,7 @@ declare function useCartSession(options: UseCartSessionOptions): UseCartSessionR
|
|
|
284
297
|
*/
|
|
285
298
|
type ThrottleCheckoutStatus = 'idle' | 'loading' | 'recovering' | 'ready' | 'error';
|
|
286
299
|
interface CheckoutTotals {
|
|
287
|
-
currency:
|
|
300
|
+
currency: CurrencyCode;
|
|
288
301
|
subtotal: number;
|
|
289
302
|
discountTotal: number;
|
|
290
303
|
shippingTotal: number;
|
|
@@ -561,9 +574,9 @@ interface SecureCardCompleteResult {
|
|
|
561
574
|
orderId: string;
|
|
562
575
|
orderNumber: string;
|
|
563
576
|
paymentId: string;
|
|
564
|
-
/** Minor units
|
|
577
|
+
/** Minor units of `currency`. */
|
|
565
578
|
total: number;
|
|
566
|
-
currency:
|
|
579
|
+
currency: CurrencyCode;
|
|
567
580
|
status: string;
|
|
568
581
|
paymentStatus: string;
|
|
569
582
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { CSSProperties, RefObject, ReactNode } from 'react';
|
|
3
|
+
import { CurrencyCode } from '@usethrottle/money';
|
|
4
|
+
import * as money from '@usethrottle/money';
|
|
5
|
+
export { money };
|
|
6
|
+
export { CURRENCIES, CurrencyCode, MoneyValue, UnknownCurrencyError, currencySymbol, formatMoney, isKnownCurrency, minorUnitsOf, moneyValue, parseMoney, toDecimalString, toMinor } from '@usethrottle/money';
|
|
3
7
|
import { CartSessionCart, AddLineItemInput, UpdateLineItemInput, SelectShippingInput, CheckoutHandoffInput, CheckoutHandoff, SelectedShipping } from '@usethrottle/cart';
|
|
4
8
|
|
|
5
9
|
/**
|
|
@@ -42,7 +46,7 @@ type ThrottleEvent = {
|
|
|
42
46
|
subscriptionIds?: string[];
|
|
43
47
|
/** v1.4 additive — order total in minor units, for analytics purchase events. */
|
|
44
48
|
total?: number;
|
|
45
|
-
currency?:
|
|
49
|
+
currency?: CurrencyCode;
|
|
46
50
|
lineItems?: ThrottleCompletedLineItem[];
|
|
47
51
|
} | {
|
|
48
52
|
type: 'throttle.cancelled';
|
|
@@ -151,9 +155,13 @@ interface ThrottleEmbedProps {
|
|
|
151
155
|
subscriptionId?: string;
|
|
152
156
|
/** Every subscription the checkout created, in line order. `subscriptionId` is set only when there is exactly one. */
|
|
153
157
|
subscriptionIds?: string[];
|
|
154
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Order total in minor units — fire `gtag`/`fbq` purchase events with
|
|
160
|
+
* value = `toDecimalString(total, currency)` (the currency's own exponent:
|
|
161
|
+
* JPY has none, KWD has three).
|
|
162
|
+
*/
|
|
155
163
|
total?: number;
|
|
156
|
-
currency?:
|
|
164
|
+
currency?: CurrencyCode;
|
|
157
165
|
lineItems?: ThrottleCompletedLineItem[];
|
|
158
166
|
}) => void;
|
|
159
167
|
onFailed?: (evt: {
|
|
@@ -221,9 +229,14 @@ declare function useThrottleEvents({ iframeRef, expectedOrigin, onMessage }: Use
|
|
|
221
229
|
interface UseCartSessionOptions {
|
|
222
230
|
/** Application UUID. */
|
|
223
231
|
applicationId: string;
|
|
224
|
-
/** Workspace environment UUID the
|
|
232
|
+
/** Workspace environment UUID the quote token was minted for. */
|
|
225
233
|
environmentId: string;
|
|
226
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Storefront quote token (`qt_…`), from the dashboard Shipping & Tax page or
|
|
236
|
+
* `POST /api/v1/shipping-tax/quote-tokens`. Tokens minted before `qt_` start
|
|
237
|
+
* with `pk_` and keep working. A `pk_` publishable API key is a different
|
|
238
|
+
* credential and is refused (`401 invalid_quote_token`).
|
|
239
|
+
*/
|
|
227
240
|
quoteToken: string;
|
|
228
241
|
baseUrl?: string;
|
|
229
242
|
/**
|
|
@@ -284,7 +297,7 @@ declare function useCartSession(options: UseCartSessionOptions): UseCartSessionR
|
|
|
284
297
|
*/
|
|
285
298
|
type ThrottleCheckoutStatus = 'idle' | 'loading' | 'recovering' | 'ready' | 'error';
|
|
286
299
|
interface CheckoutTotals {
|
|
287
|
-
currency:
|
|
300
|
+
currency: CurrencyCode;
|
|
288
301
|
subtotal: number;
|
|
289
302
|
discountTotal: number;
|
|
290
303
|
shippingTotal: number;
|
|
@@ -561,9 +574,9 @@ interface SecureCardCompleteResult {
|
|
|
561
574
|
orderId: string;
|
|
562
575
|
orderNumber: string;
|
|
563
576
|
paymentId: string;
|
|
564
|
-
/** Minor units
|
|
577
|
+
/** Minor units of `currency`. */
|
|
565
578
|
total: number;
|
|
566
|
-
currency:
|
|
579
|
+
currency: CurrencyCode;
|
|
567
580
|
status: string;
|
|
568
581
|
paymentStatus: string;
|
|
569
582
|
}
|