@usethrottle/cart 3.0.1 → 3.1.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 +22 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,11 @@ import { CartClient } from '@usethrottle/cart';
|
|
|
18
18
|
const client = new CartClient({ apiKey: process.env.THROTTLE_API_KEY! });
|
|
19
19
|
|
|
20
20
|
// 1. Create a cart
|
|
21
|
-
const cart = await client.carts.create({
|
|
21
|
+
const cart = await client.carts.create({
|
|
22
|
+
storeId: 'store_abc',
|
|
23
|
+
currency: 'USD',
|
|
24
|
+
netN: 45,
|
|
25
|
+
});
|
|
22
26
|
|
|
23
27
|
// 2. Add a line item
|
|
24
28
|
await client.items.add(cart.id, {
|
|
@@ -48,8 +52,25 @@ const order = await client.carts.checkout(cart.id, { paymentMethod: 'card' });
|
|
|
48
52
|
console.log(order.id, order.status);
|
|
49
53
|
```
|
|
50
54
|
|
|
55
|
+
`applicationId` is accepted as an alias for `storeId` when your integration
|
|
56
|
+
already uses the newer application naming.
|
|
57
|
+
|
|
51
58
|
All monetary values are integers in the smallest currency unit (cents for USD).
|
|
52
59
|
|
|
60
|
+
## Net-N invoice terms
|
|
61
|
+
|
|
62
|
+
Cart-level invoice terms are optional. Pass `netN` on cart create or update to
|
|
63
|
+
set the cart override, or `null` to clear it. The final invoice term is resolved
|
|
64
|
+
when the buyer completes checkout with Invoice Terms:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
customer.netN ?? cart.netN ?? DEFAULT_NET_N
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`allowedMethods` only controls which payment methods can appear in checkout; it
|
|
71
|
+
does not change the Net-N day count. For hosted/embed checkout, create a cart
|
|
72
|
+
with `netN` and then create a checkout session for that cart.
|
|
73
|
+
|
|
53
74
|
## Shipping and tax
|
|
54
75
|
|
|
55
76
|
Use the secret-key client on your backend to calculate and persist cart totals
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
interface Cart {
|
|
2
2
|
id: string;
|
|
3
3
|
merchantId: string;
|
|
4
|
+
applicationId: string;
|
|
4
5
|
storeId: string | null;
|
|
5
6
|
customerId: string | null;
|
|
6
7
|
status: 'open' | 'checkout' | 'converted' | 'abandoned';
|
|
@@ -10,6 +11,7 @@ interface Cart {
|
|
|
10
11
|
discountTotal: number;
|
|
11
12
|
shippingTotal: number;
|
|
12
13
|
total: number;
|
|
14
|
+
netN: number | null;
|
|
13
15
|
billingAddress: Record<string, unknown> | null;
|
|
14
16
|
shippingAddress: Record<string, unknown> | null;
|
|
15
17
|
notes: string | null;
|
|
@@ -86,17 +88,25 @@ interface CartEvent {
|
|
|
86
88
|
actorId: string | null;
|
|
87
89
|
createdAt: string;
|
|
88
90
|
}
|
|
89
|
-
|
|
91
|
+
type CartApplicationRef = {
|
|
90
92
|
storeId: string;
|
|
93
|
+
applicationId?: string;
|
|
94
|
+
} | {
|
|
95
|
+
applicationId: string;
|
|
96
|
+
storeId?: string;
|
|
97
|
+
};
|
|
98
|
+
type CreateCartInput = CartApplicationRef & {
|
|
91
99
|
customerId?: string;
|
|
92
100
|
currency?: string;
|
|
101
|
+
netN?: number | null;
|
|
93
102
|
metadata?: Record<string, unknown>;
|
|
94
|
-
}
|
|
103
|
+
};
|
|
95
104
|
interface UpdateCartInput {
|
|
96
105
|
customerId?: string;
|
|
97
106
|
billingAddress?: Record<string, unknown>;
|
|
98
107
|
shippingAddress?: Record<string, unknown>;
|
|
99
108
|
notes?: string;
|
|
109
|
+
netN?: number | null;
|
|
100
110
|
metadata?: Record<string, unknown>;
|
|
101
111
|
}
|
|
102
112
|
interface AddLineItemInput {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
interface Cart {
|
|
2
2
|
id: string;
|
|
3
3
|
merchantId: string;
|
|
4
|
+
applicationId: string;
|
|
4
5
|
storeId: string | null;
|
|
5
6
|
customerId: string | null;
|
|
6
7
|
status: 'open' | 'checkout' | 'converted' | 'abandoned';
|
|
@@ -10,6 +11,7 @@ interface Cart {
|
|
|
10
11
|
discountTotal: number;
|
|
11
12
|
shippingTotal: number;
|
|
12
13
|
total: number;
|
|
14
|
+
netN: number | null;
|
|
13
15
|
billingAddress: Record<string, unknown> | null;
|
|
14
16
|
shippingAddress: Record<string, unknown> | null;
|
|
15
17
|
notes: string | null;
|
|
@@ -86,17 +88,25 @@ interface CartEvent {
|
|
|
86
88
|
actorId: string | null;
|
|
87
89
|
createdAt: string;
|
|
88
90
|
}
|
|
89
|
-
|
|
91
|
+
type CartApplicationRef = {
|
|
90
92
|
storeId: string;
|
|
93
|
+
applicationId?: string;
|
|
94
|
+
} | {
|
|
95
|
+
applicationId: string;
|
|
96
|
+
storeId?: string;
|
|
97
|
+
};
|
|
98
|
+
type CreateCartInput = CartApplicationRef & {
|
|
91
99
|
customerId?: string;
|
|
92
100
|
currency?: string;
|
|
101
|
+
netN?: number | null;
|
|
93
102
|
metadata?: Record<string, unknown>;
|
|
94
|
-
}
|
|
103
|
+
};
|
|
95
104
|
interface UpdateCartInput {
|
|
96
105
|
customerId?: string;
|
|
97
106
|
billingAddress?: Record<string, unknown>;
|
|
98
107
|
shippingAddress?: Record<string, unknown>;
|
|
99
108
|
notes?: string;
|
|
109
|
+
netN?: number | null;
|
|
100
110
|
metadata?: Record<string, unknown>;
|
|
101
111
|
}
|
|
102
112
|
interface AddLineItemInput {
|