@spree/docs 0.1.3 → 0.1.5
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.
|
@@ -10,6 +10,7 @@ const options = { token: jwtToken };
|
|
|
10
10
|
|
|
11
11
|
// Get profile
|
|
12
12
|
const profile = await client.customer.get(options);
|
|
13
|
+
// profile includes `available_store_credit_total` and `display_available_store_credit_total`
|
|
13
14
|
|
|
14
15
|
// Update profile
|
|
15
16
|
await client.customer.update({
|
|
@@ -38,17 +39,31 @@ await client.customer.addresses.create({
|
|
|
38
39
|
postal_code: '10001',
|
|
39
40
|
country_iso: 'US',
|
|
40
41
|
state_abbr: 'NY',
|
|
42
|
+
is_default_billing: true, // Optional — set as default billing address
|
|
43
|
+
is_default_shipping: true, // Optional — set as default shipping address
|
|
41
44
|
}, options);
|
|
42
45
|
|
|
43
46
|
// Update address
|
|
44
|
-
await client.customer.addresses.update('addr_xxx', {
|
|
47
|
+
await client.customer.addresses.update('addr_xxx', {
|
|
48
|
+
city: 'Brooklyn',
|
|
49
|
+
is_default_billing: true, // Optional — set as default billing address
|
|
50
|
+
is_default_shipping: false, // Optional — set as default shipping address
|
|
51
|
+
}, options);
|
|
45
52
|
|
|
46
53
|
// Delete address
|
|
47
54
|
await client.customer.addresses.delete('addr_xxx', options);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Store Credits
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const options = { token: jwtToken };
|
|
61
|
+
|
|
62
|
+
// List store credits
|
|
63
|
+
const { data: credits } = await client.customer.storeCredits.list({}, options);
|
|
48
64
|
|
|
49
|
-
//
|
|
50
|
-
await client.customer.
|
|
51
|
-
await client.customer.addresses.markAsDefault('addr_xxx', 'shipping', options);
|
|
65
|
+
// Get a specific store credit
|
|
66
|
+
const credit = await client.customer.storeCredits.get('sc_xxx', options);
|
|
52
67
|
```
|
|
53
68
|
|
|
54
69
|
## Credit Cards
|
|
@@ -96,11 +96,14 @@ await client.carts.complete(cartId, { spreeToken: cart.token });
|
|
|
96
96
|
|
|
97
97
|
### Fulfillments
|
|
98
98
|
|
|
99
|
+
Fulfillments are included in the cart response — there is no separate list endpoint.
|
|
100
|
+
|
|
99
101
|
```typescript
|
|
100
102
|
const options = { spreeToken: cart.token };
|
|
101
103
|
|
|
102
|
-
//
|
|
103
|
-
const
|
|
104
|
+
// Access fulfillments from the cart response
|
|
105
|
+
const cart = await client.carts.get(cartId, options);
|
|
106
|
+
const fulfillments = cart.fulfillments;
|
|
104
107
|
|
|
105
108
|
// Select a delivery rate
|
|
106
109
|
await client.carts.fulfillments.update(cartId, fulfillmentId, {
|
|
@@ -123,6 +126,13 @@ await client.carts.storeCredits.apply(cartId, 25.00, options);
|
|
|
123
126
|
await client.carts.storeCredits.remove(cartId, options);
|
|
124
127
|
```
|
|
125
128
|
|
|
129
|
+
The cart/order response includes store credit and gift card totals:
|
|
130
|
+
|
|
131
|
+
- `store_credit_total` / `display_store_credit_total` — total store credit applied
|
|
132
|
+
- `gift_card_total` / `display_gift_card_total` — total gift card value applied
|
|
133
|
+
- `covered_by_store_credit` — boolean, whether the order is fully covered by store credit
|
|
134
|
+
- `gift_card` — associated gift card (if applicable)
|
|
135
|
+
|
|
126
136
|
## Orders
|
|
127
137
|
|
|
128
138
|
### Get a Completed Order
|
|
@@ -7,13 +7,18 @@ All payment and delivery endpoints require a `cartId` as the first argument.
|
|
|
7
7
|
|
|
8
8
|
## Payment Methods
|
|
9
9
|
|
|
10
|
+
Payment methods, payments, and fulfillments are included in the cart response -- there are no separate list or get endpoints for these resources.
|
|
11
|
+
|
|
10
12
|
```typescript
|
|
11
13
|
const options = { spreeToken: cart.token };
|
|
12
14
|
|
|
13
|
-
//
|
|
14
|
-
const
|
|
15
|
+
// Access payment methods, payments, and fulfillments from the cart response
|
|
16
|
+
const cart = await client.carts.get(cartId, options);
|
|
17
|
+
const paymentMethods = cart.payment_methods;
|
|
18
|
+
const payments = cart.payments;
|
|
19
|
+
const fulfillments = cart.fulfillments;
|
|
15
20
|
|
|
16
|
-
// Each method includes a `session_required` flag:
|
|
21
|
+
// Each payment method includes a `session_required` flag:
|
|
17
22
|
// - true → use Payment Sessions (Stripe, Adyen, PayPal, etc.)
|
|
18
23
|
// - false → use direct payment creation (Check, Cash on Delivery, Bank Transfer, etc.)
|
|
19
24
|
```
|
|
@@ -23,12 +28,6 @@ const methods = await client.carts.paymentMethods.list(cartId, options);
|
|
|
23
28
|
```typescript
|
|
24
29
|
const options = { spreeToken: cart.token };
|
|
25
30
|
|
|
26
|
-
// List payments on the current cart
|
|
27
|
-
const payments = await client.carts.payments.list(cartId, options);
|
|
28
|
-
|
|
29
|
-
// Get a specific payment
|
|
30
|
-
const payment = await client.carts.payments.get(cartId, paymentId, options);
|
|
31
|
-
|
|
32
31
|
// Create a payment for a non-session payment method
|
|
33
32
|
// (e.g. Check, Cash on Delivery, Bank Transfer, Purchase Order)
|
|
34
33
|
const payment = await client.carts.payments.create(cartId, {
|
|
@@ -86,8 +85,9 @@ console.log(completed.status); // 'completed'
|
|
|
86
85
|
```typescript
|
|
87
86
|
const options = { spreeToken: cart.token };
|
|
88
87
|
|
|
89
|
-
//
|
|
90
|
-
const
|
|
88
|
+
// Fulfillments are included in the cart response
|
|
89
|
+
const cart = await client.carts.get(cartId, options);
|
|
90
|
+
const fulfillments = cart.fulfillments;
|
|
91
91
|
|
|
92
92
|
// Select a delivery rate
|
|
93
93
|
await client.carts.fulfillments.update(cartId, fulfillmentId, {
|