@spree/docs 0.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.
Files changed (183) hide show
  1. package/README.md +54 -0
  2. package/dist/api-reference/platform/authentication.md +38 -0
  3. package/dist/api-reference/store-api/authentication.md +188 -0
  4. package/dist/api-reference/store-api/errors.md +277 -0
  5. package/dist/api-reference/store-api/idempotency.md +129 -0
  6. package/dist/api-reference/store-api/introduction.md +34 -0
  7. package/dist/api-reference/store-api/localization.md +279 -0
  8. package/dist/api-reference/store-api/metadata.md +160 -0
  9. package/dist/api-reference/store-api/monetary-amounts.md +65 -0
  10. package/dist/api-reference/store-api/querying.md +399 -0
  11. package/dist/api-reference/store-api/rate-limitting.md +103 -0
  12. package/dist/api-reference/store-api/relations.md +185 -0
  13. package/dist/api-reference/storefront/authentication.md +88 -0
  14. package/dist/api-reference/tutorials/adyen-integration-guide-for-android.md +165 -0
  15. package/dist/api-reference/tutorials/adyen-integration-guide-for-ios.md +194 -0
  16. package/dist/api-reference/tutorials/quick-checkout-with-stripe.md +248 -0
  17. package/dist/api-reference/v2/fetching-multiple-resources.md +26 -0
  18. package/dist/api-reference/v2/filtering-and-sorting.md +53 -0
  19. package/dist/api-reference/v2/introduction.md +22 -0
  20. package/dist/api-reference/v2/pagination.md +37 -0
  21. package/dist/api-reference/webhooks-events.md +883 -0
  22. package/dist/developer/admin/admin.md +205 -0
  23. package/dist/developer/admin/authentication.md +59 -0
  24. package/dist/developer/admin/components.md +711 -0
  25. package/dist/developer/admin/custom-css.md +243 -0
  26. package/dist/developer/admin/custom-javascript.md +116 -0
  27. package/dist/developer/admin/extending-ui.md +1964 -0
  28. package/dist/developer/admin/form-builder.md +444 -0
  29. package/dist/developer/admin/helper-methods.md +531 -0
  30. package/dist/developer/admin/navigation.md +805 -0
  31. package/dist/developer/admin/tables.md +491 -0
  32. package/dist/developer/advanced/adding_spree_to_rails_app.md +106 -0
  33. package/dist/developer/cli/quickstart.md +137 -0
  34. package/dist/developer/contributing/creating-an-extension.md +258 -0
  35. package/dist/developer/contributing/developing-spree.md +339 -0
  36. package/dist/developer/contributing/quickstart.md +32 -0
  37. package/dist/developer/contributing/updating-extensions.md +67 -0
  38. package/dist/developer/core-concepts/addresses.md +265 -0
  39. package/dist/developer/core-concepts/adjustments.md +107 -0
  40. package/dist/developer/core-concepts/architecture.md +177 -0
  41. package/dist/developer/core-concepts/calculators.md +323 -0
  42. package/dist/developer/core-concepts/customers.md +230 -0
  43. package/dist/developer/core-concepts/events.md +624 -0
  44. package/dist/developer/core-concepts/imports-exports.md +698 -0
  45. package/dist/developer/core-concepts/inventory.md +191 -0
  46. package/dist/developer/core-concepts/markets.md +250 -0
  47. package/dist/developer/core-concepts/media.md +167 -0
  48. package/dist/developer/core-concepts/metafields.md +187 -0
  49. package/dist/developer/core-concepts/orders.md +328 -0
  50. package/dist/developer/core-concepts/payments.md +710 -0
  51. package/dist/developer/core-concepts/pricing.md +163 -0
  52. package/dist/developer/core-concepts/products.md +360 -0
  53. package/dist/developer/core-concepts/promotions.md +322 -0
  54. package/dist/developer/core-concepts/reports.md +206 -0
  55. package/dist/developer/core-concepts/search-filtering.md +237 -0
  56. package/dist/developer/core-concepts/shipments.md +212 -0
  57. package/dist/developer/core-concepts/slugs.md +111 -0
  58. package/dist/developer/core-concepts/staff-roles.md +123 -0
  59. package/dist/developer/core-concepts/store-credits-gift-cards.md +317 -0
  60. package/dist/developer/core-concepts/stores.md +117 -0
  61. package/dist/developer/core-concepts/taxes.md +135 -0
  62. package/dist/developer/core-concepts/translations.md +120 -0
  63. package/dist/developer/core-concepts/users.md +299 -0
  64. package/dist/developer/core-concepts/webhooks.md +378 -0
  65. package/dist/developer/create-spree-app/quickstart.md +158 -0
  66. package/dist/developer/customization/api.md +93 -0
  67. package/dist/developer/customization/authentication.md +88 -0
  68. package/dist/developer/customization/checkout.md +204 -0
  69. package/dist/developer/customization/configuration.md +55 -0
  70. package/dist/developer/customization/decorators.md +523 -0
  71. package/dist/developer/customization/dependencies.md +232 -0
  72. package/dist/developer/customization/emails.md +21 -0
  73. package/dist/developer/customization/extensions.md +92 -0
  74. package/dist/developer/customization/metadata.md +236 -0
  75. package/dist/developer/customization/model-preferences.md +130 -0
  76. package/dist/developer/customization/permissions.md +265 -0
  77. package/dist/developer/customization/quickstart.md +229 -0
  78. package/dist/developer/customization/routes.md +24 -0
  79. package/dist/developer/customization/v4/admin-panel.md +78 -0
  80. package/dist/developer/customization/v4/authentication.md +210 -0
  81. package/dist/developer/customization/v4/checkout.md +212 -0
  82. package/dist/developer/customization/v4/deface.md +251 -0
  83. package/dist/developer/customization/v4/images.md +86 -0
  84. package/dist/developer/customization/v4/storefront.md +450 -0
  85. package/dist/developer/deployment/assets.md +87 -0
  86. package/dist/developer/deployment/aws.md +335 -0
  87. package/dist/developer/deployment/caching.md +27 -0
  88. package/dist/developer/deployment/cdn.md +39 -0
  89. package/dist/developer/deployment/database.md +155 -0
  90. package/dist/developer/deployment/docker.md +128 -0
  91. package/dist/developer/deployment/emails.md +77 -0
  92. package/dist/developer/deployment/environment_variables.md +111 -0
  93. package/dist/developer/deployment/heroku.md +51 -0
  94. package/dist/developer/deployment/render.md +95 -0
  95. package/dist/developer/getting-started/quickstart.md +82 -0
  96. package/dist/developer/how-to/custom-payment-method.md +374 -0
  97. package/dist/developer/how-to/custom-promotion.md +373 -0
  98. package/dist/developer/how-to/custom-report.md +387 -0
  99. package/dist/developer/how-to/custom-search-provider.md +230 -0
  100. package/dist/developer/multi-store/quickstart.md +71 -0
  101. package/dist/developer/multi-store/setup.md +38 -0
  102. package/dist/developer/multi-tenant/configuration.md +41 -0
  103. package/dist/developer/multi-tenant/core-concepts.md +75 -0
  104. package/dist/developer/multi-tenant/installation.md +96 -0
  105. package/dist/developer/multi-tenant/quickstart.md +20 -0
  106. package/dist/developer/multi-vendor/installation.md +45 -0
  107. package/dist/developer/multi-vendor/quickstart.md +17 -0
  108. package/dist/developer/sdk/admin/quickstart.md +22 -0
  109. package/dist/developer/sdk/authentication.md +89 -0
  110. package/dist/developer/sdk/configuration.md +225 -0
  111. package/dist/developer/sdk/quickstart.md +82 -0
  112. package/dist/developer/sdk/store/account.md +67 -0
  113. package/dist/developer/sdk/store/cart-checkout.md +140 -0
  114. package/dist/developer/sdk/store/markets.md +151 -0
  115. package/dist/developer/sdk/store/payments.md +96 -0
  116. package/dist/developer/sdk/store/products.md +149 -0
  117. package/dist/developer/sdk/store/wishlists.md +52 -0
  118. package/dist/developer/security/pci_compliance.md +15 -0
  119. package/dist/developer/security/security_policy.md +68 -0
  120. package/dist/developer/storefront/blocks.md +285 -0
  121. package/dist/developer/storefront/custom-css.md +260 -0
  122. package/dist/developer/storefront/custom-javascript.md +166 -0
  123. package/dist/developer/storefront/helper-methods.md +1288 -0
  124. package/dist/developer/storefront/links.md +298 -0
  125. package/dist/developer/storefront/nextjs/architecture.md +150 -0
  126. package/dist/developer/storefront/nextjs/customization.md +141 -0
  127. package/dist/developer/storefront/nextjs/deployment.md +180 -0
  128. package/dist/developer/storefront/nextjs/quickstart.md +92 -0
  129. package/dist/developer/storefront/nextjs/spree-next-package.md +314 -0
  130. package/dist/developer/storefront/pages.md +163 -0
  131. package/dist/developer/storefront/sections.md +569 -0
  132. package/dist/developer/storefront/storefront.md +56 -0
  133. package/dist/developer/storefront/themes.md +161 -0
  134. package/dist/developer/tutorial/admin.md +134 -0
  135. package/dist/developer/tutorial/extending-models.md +380 -0
  136. package/dist/developer/tutorial/file-uploads.md +121 -0
  137. package/dist/developer/tutorial/introduction.md +33 -0
  138. package/dist/developer/tutorial/model.md +41 -0
  139. package/dist/developer/tutorial/page-builder.md +487 -0
  140. package/dist/developer/tutorial/rich-text.md +73 -0
  141. package/dist/developer/tutorial/seo.md +332 -0
  142. package/dist/developer/tutorial/storefront.md +352 -0
  143. package/dist/developer/tutorial/testing.md +558 -0
  144. package/dist/developer/upgrades/2.0-to-2.1.md +46 -0
  145. package/dist/developer/upgrades/2.1-to-2.2.md +59 -0
  146. package/dist/developer/upgrades/2.2-to-2.3.md +44 -0
  147. package/dist/developer/upgrades/2.3-to-2.4.md +42 -0
  148. package/dist/developer/upgrades/3.0-to-3.1.md +47 -0
  149. package/dist/developer/upgrades/3.1-to-3.2.md +34 -0
  150. package/dist/developer/upgrades/3.2-to-3.3.md +70 -0
  151. package/dist/developer/upgrades/3.3-to-3.4.md +36 -0
  152. package/dist/developer/upgrades/3.4-to-3.5.md +44 -0
  153. package/dist/developer/upgrades/3.5-to-3.6.md +40 -0
  154. package/dist/developer/upgrades/3.6-to-3.7.md +62 -0
  155. package/dist/developer/upgrades/3.7-to-4.0.md +152 -0
  156. package/dist/developer/upgrades/4.0-to-4.1.md +92 -0
  157. package/dist/developer/upgrades/4.1-to-4.2.md +109 -0
  158. package/dist/developer/upgrades/4.10-to-5.0.md +129 -0
  159. package/dist/developer/upgrades/4.2-to-4.3.md +100 -0
  160. package/dist/developer/upgrades/4.3-to-4.4.md +125 -0
  161. package/dist/developer/upgrades/4.4-to-4.5.md +94 -0
  162. package/dist/developer/upgrades/4.5-to-4.6.md +119 -0
  163. package/dist/developer/upgrades/4.6-to-4.7.md +39 -0
  164. package/dist/developer/upgrades/4.8-to-4.9.md +24 -0
  165. package/dist/developer/upgrades/4.9-to-4.10.md +24 -0
  166. package/dist/developer/upgrades/4.x-to-4.8.md +52 -0
  167. package/dist/developer/upgrades/5.0-to-5.1.md +28 -0
  168. package/dist/developer/upgrades/5.1-to-5.2.md +127 -0
  169. package/dist/developer/upgrades/5.2-to-5.3.md +338 -0
  170. package/dist/developer/upgrades/5.3-to-5.4.md +248 -0
  171. package/dist/developer/upgrades/quickstart.md +36 -0
  172. package/dist/integrations/analytics/google-analytics.md +64 -0
  173. package/dist/integrations/analytics/google-tag-manager.md +78 -0
  174. package/dist/integrations/integrations.md +39 -0
  175. package/dist/integrations/marketing/klaviyo.md +99 -0
  176. package/dist/integrations/payments/adyen.md +90 -0
  177. package/dist/integrations/payments/paypal.md +41 -0
  178. package/dist/integrations/payments/razorpay.md +45 -0
  179. package/dist/integrations/payments/stripe.md +109 -0
  180. package/dist/integrations/search/meilisearch.md +236 -0
  181. package/dist/integrations/sso-mfa-social-login/admin-dashboard.md +57 -0
  182. package/dist/integrations/sso-mfa-social-login/storefront.md +56 -0
  183. package/package.json +27 -0
@@ -0,0 +1,82 @@
1
+ ---
2
+ title: Quickstart
3
+ description: Install and start using the Spree SDK in your project
4
+ ---
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install @spree/sdk
10
+ # or
11
+ yarn add @spree/sdk
12
+ # or
13
+ pnpm add @spree/sdk
14
+ ```
15
+
16
+ ## Quick Start
17
+
18
+ ```typescript
19
+ import { createClient } from '@spree/sdk';
20
+
21
+ // Initialize the client
22
+ const client = createClient({
23
+ baseUrl: 'https://api.mystore.com',
24
+ publishableKey: 'spree_pk_xxx', // Store API
25
+ });
26
+
27
+ // Browse products (Store API)
28
+ const products = await client.products.list({
29
+ limit: 10,
30
+ expand: ['variants', 'media'],
31
+ });
32
+
33
+ // Get a single product
34
+ const product = await client.products.get('spree-tote');
35
+
36
+ // Authentication
37
+ const { token, user } = await client.auth.login({
38
+ email: 'customer@example.com',
39
+ password: 'password123',
40
+ });
41
+
42
+ // Create a cart and add items
43
+ const cart = await client.carts.create();
44
+ await client.carts.items.create(cart.id, {
45
+ variant_id: 'var_abc123',
46
+ quantity: 2,
47
+ }, { spreeToken: cart.token });
48
+
49
+ // Checkout flow
50
+ await client.carts.complete(cart.id, { spreeToken: cart.token });
51
+ ```
52
+
53
+ ## Nested Resources
54
+
55
+ The SDK uses a resource builder pattern for nested resources:
56
+
57
+ | Parent Resource | Nested Resource | Available Methods |
58
+ |-----------------|-----------------|-------------------|
59
+ | `carts` | `items` | `create`, `update`, `delete` |
60
+ | `carts` | `payments` | `list`, `get`, `create` |
61
+ | `carts` | `paymentMethods` | `list` |
62
+ | `carts` | `paymentSessions` | `create`, `get`, `update`, `complete` |
63
+ | `carts` | `fulfillments` | `list`, `update` |
64
+ | `carts` | `couponCodes` | `apply`, `remove` |
65
+ | `carts` | `storeCredits` | `apply`, `remove` |
66
+ | `customer` | `addresses` | `list`, `get`, `create`, `update`, `delete`, `markAsDefault` |
67
+ | `customer` | `creditCards` | `list`, `get`, `delete` |
68
+ | `customer` | `giftCards` | `list`, `get` |
69
+ | `customer` | `orders` | `list` |
70
+ | `customer` | `paymentSetupSessions` | `create`, `get`, `complete` |
71
+ | `categories` | `products` | `list` |
72
+ | `wishlists` | `items` | `create`, `update`, `delete` |
73
+
74
+ ```typescript
75
+ // Nested resources follow the pattern: client.parent.nested.method(parentId, ...)
76
+ await client.carts.items.create(cartId, params, options);
77
+ await client.carts.payments.list(cartId, options);
78
+ await client.carts.fulfillments.update(cartId, fulfillmentId, params, options);
79
+ await client.customer.addresses.list({}, options);
80
+ await client.categories.products.list(categoryId, params, options);
81
+ await client.wishlists.items.create(wishlistId, params, options);
82
+ ```
@@ -0,0 +1,67 @@
1
+ ---
2
+ title: Customer Account
3
+ description: Manage customer profiles, addresses, and credit cards with the Spree SDK
4
+ ---
5
+
6
+ ## Customer Profile
7
+
8
+ ```typescript
9
+ const options = { token: jwtToken };
10
+
11
+ // Get profile
12
+ const profile = await client.customer.get(options);
13
+
14
+ // Update profile
15
+ await client.customer.update({
16
+ first_name: 'John',
17
+ last_name: 'Doe',
18
+ }, options);
19
+ ```
20
+
21
+ ## Addresses
22
+
23
+ ```typescript
24
+ const options = { token: jwtToken };
25
+
26
+ // List addresses
27
+ const { data: addresses } = await client.customer.addresses.list({}, options);
28
+
29
+ // Get address by ID
30
+ const address = await client.customer.addresses.get('addr_xxx', options);
31
+
32
+ // Create address
33
+ await client.customer.addresses.create({
34
+ first_name: 'John',
35
+ last_name: 'Doe',
36
+ address1: '123 Main St',
37
+ city: 'New York',
38
+ postal_code: '10001',
39
+ country_iso: 'US',
40
+ state_abbr: 'NY',
41
+ }, options);
42
+
43
+ // Update address
44
+ await client.customer.addresses.update('addr_xxx', { city: 'Brooklyn' }, options);
45
+
46
+ // Delete address
47
+ await client.customer.addresses.delete('addr_xxx', options);
48
+
49
+ // Mark as default billing or shipping address
50
+ await client.customer.addresses.markAsDefault('addr_xxx', 'billing', options);
51
+ await client.customer.addresses.markAsDefault('addr_xxx', 'shipping', options);
52
+ ```
53
+
54
+ ## Credit Cards
55
+
56
+ ```typescript
57
+ const options = { token: jwtToken };
58
+
59
+ // List saved credit cards
60
+ const { data: cards } = await client.customer.creditCards.list({}, options);
61
+
62
+ // Get credit card by ID
63
+ const card = await client.customer.creditCards.get('cc_xxx', options);
64
+
65
+ // Delete credit card
66
+ await client.customer.creditCards.delete('cc_xxx', options);
67
+ ```
@@ -0,0 +1,140 @@
1
+ ---
2
+ title: Cart, Checkout & Orders
3
+ description: Manage carts, line items, coupons, checkout flow, and completed orders with the Spree SDK
4
+ ---
5
+
6
+ The Store API is split into two resource groups:
7
+
8
+ - **Carts** — managing shopping carts, items, coupon codes, checkout flow (addresses, delivery, payments, completion)
9
+ - **Orders** — retrieving completed orders
10
+
11
+ All cart and checkout endpoints require a `cartId` as the first argument.
12
+
13
+ ## Carts
14
+
15
+ ### Create & Retrieve
16
+
17
+ ```typescript
18
+ // Create a new cart
19
+ const cart = await client.carts.create();
20
+
21
+ // Get a specific cart
22
+ const cart = await client.carts.get(cartId, { spreeToken: 'xxx' });
23
+
24
+ // List carts
25
+ const carts = await client.carts.list();
26
+
27
+ // Delete a cart
28
+ await client.carts.delete(cartId, { spreeToken: cart.token });
29
+
30
+ // Associate guest cart with authenticated user
31
+ // (after user logs in, merge their guest cart with their account)
32
+ await client.carts.associate(cartId, {
33
+ token: jwtToken, // User's JWT token
34
+ spreeToken: cart.token, // Guest cart token
35
+ });
36
+ ```
37
+
38
+ ### Items
39
+
40
+ ```typescript
41
+ const options = { spreeToken: cart.token };
42
+
43
+ // Add item
44
+ await client.carts.items.create(cartId, {
45
+ variant_id: 'var_123',
46
+ quantity: 2,
47
+ }, options);
48
+
49
+ // Update item quantity
50
+ await client.carts.items.update(cartId, lineItemId, {
51
+ quantity: 3,
52
+ }, options);
53
+
54
+ // Remove item
55
+ await client.carts.items.delete(cartId, lineItemId, options);
56
+ ```
57
+
58
+ ### Coupon Codes
59
+
60
+ ```typescript
61
+ const options = { spreeToken: cart.token };
62
+
63
+ // Apply a coupon code
64
+ await client.carts.couponCodes.apply(cartId, 'SAVE20', options);
65
+
66
+ // Remove a coupon code
67
+ await client.carts.couponCodes.remove(cartId, 'SUMMER20', options);
68
+ ```
69
+
70
+ ## Checkout
71
+
72
+ ### Update Cart
73
+
74
+ ```typescript
75
+ await client.carts.update(cartId, {
76
+ email: 'customer@example.com',
77
+ shipping_address: {
78
+ first_name: 'John',
79
+ last_name: 'Doe',
80
+ address1: '123 Main St',
81
+ city: 'New York',
82
+ postal_code: '10001',
83
+ phone: '+1 555 123 4567',
84
+ country_iso: 'US',
85
+ state_abbr: 'NY',
86
+ },
87
+ billing_address_id: 'addr_xxx', // Or use existing address by ID
88
+ }, { spreeToken: cart.token });
89
+ ```
90
+
91
+ ### Complete Checkout
92
+
93
+ ```typescript
94
+ await client.carts.complete(cartId, { spreeToken: cart.token });
95
+ ```
96
+
97
+ ### Fulfillments
98
+
99
+ ```typescript
100
+ const options = { spreeToken: cart.token };
101
+
102
+ // List fulfillments
103
+ const fulfillments = await client.carts.fulfillments.list(cartId, options);
104
+
105
+ // Select a delivery rate
106
+ await client.carts.fulfillments.update(cartId, fulfillmentId, {
107
+ selected_delivery_rate_id: 'rate_xxx',
108
+ }, options);
109
+ ```
110
+
111
+ ### Store Credits
112
+
113
+ ```typescript
114
+ const options = { spreeToken: cart.token };
115
+
116
+ // Apply store credit (applies maximum available by default)
117
+ await client.carts.storeCredits.apply(cartId, undefined, options);
118
+
119
+ // Apply specific amount of store credit
120
+ await client.carts.storeCredits.apply(cartId, 25.00, options);
121
+
122
+ // Remove store credit from order
123
+ await client.carts.storeCredits.remove(cartId, options);
124
+ ```
125
+
126
+ ## Orders
127
+
128
+ ### Get a Completed Order
129
+
130
+ ```typescript
131
+ const order = await client.orders.get('R123456789', {
132
+ expand: ['items', 'fulfillments'],
133
+ }, { spreeToken: cart.token });
134
+ ```
135
+
136
+ ### List Orders (Authenticated Customer)
137
+
138
+ ```typescript
139
+ const orders = await client.customer.orders.list({}, { token });
140
+ ```
@@ -0,0 +1,151 @@
1
+ ---
2
+ title: Markets
3
+ description: Fetch markets, resolve by country, and list market countries with the Spree SDK
4
+ ---
5
+
6
+ ## List Markets
7
+
8
+ Returns all markets for the current store with their countries, currency, locales, and tax configuration.
9
+
10
+
11
+ ```typescript SDK
12
+ const { data: markets } = await client.markets.list()
13
+
14
+ markets.forEach(market => {
15
+ market.id // "mkt_UkLWZg9DAJ"
16
+ market.name // "North America"
17
+ market.currency // "USD"
18
+ market.default_locale // "en"
19
+ market.tax_inclusive // false
20
+ market.default // true
21
+ market.supported_locales // ["en", "es"]
22
+ market.countries // [{ iso: "US", name: "United States of America", ... }]
23
+ })
24
+ ```
25
+
26
+ ```bash cURL
27
+ curl 'https://api.mystore.com/api/v3/store/markets' \
28
+ -H 'Authorization: Bearer spree_pk_xxx'
29
+ ```
30
+
31
+
32
+ **Response:**
33
+
34
+ ```json
35
+ {
36
+ "data": [
37
+ {
38
+ "id": "mkt_UkLWZg9DAJ",
39
+ "name": "North America",
40
+ "currency": "USD",
41
+ "default_locale": "en",
42
+ "tax_inclusive": false,
43
+ "default": true,
44
+ "supported_locales": ["en", "es"],
45
+ "countries": [
46
+ { "iso": "US", "iso3": "USA", "name": "United States of America", "states_required": true, "zipcode_required": true }
47
+ ]
48
+ },
49
+ {
50
+ "id": "mkt_gbHJdmfrXB",
51
+ "name": "Europe",
52
+ "currency": "EUR",
53
+ "default_locale": "de",
54
+ "tax_inclusive": true,
55
+ "default": false,
56
+ "supported_locales": ["de", "en", "fr"],
57
+ "countries": [
58
+ { "iso": "DE", "iso3": "DEU", "name": "Germany", "states_required": false, "zipcode_required": true },
59
+ { "iso": "FR", "iso3": "FRA", "name": "France", "states_required": false, "zipcode_required": true }
60
+ ]
61
+ }
62
+ ]
63
+ }
64
+ ```
65
+
66
+ ## Get a Market
67
+
68
+
69
+ ```typescript SDK
70
+ const market = await client.markets.get('mkt_gbHJdmfrXB')
71
+
72
+ market.name // "Europe"
73
+ market.currency // "EUR"
74
+ market.countries // [{ iso: "DE", ... }, { iso: "FR", ... }]
75
+ ```
76
+
77
+ ```bash cURL
78
+ curl 'https://api.mystore.com/api/v3/store/markets/mkt_gbHJdmfrXB' \
79
+ -H 'Authorization: Bearer spree_pk_xxx'
80
+ ```
81
+
82
+
83
+ ## Resolve Market by Country
84
+
85
+ Determine which market applies for a given country ISO code. Useful for auto-selecting the correct currency and locale when a customer's location is known.
86
+
87
+
88
+ ```typescript SDK
89
+ const market = await client.markets.resolve('DE')
90
+
91
+ market.id // "mkt_gbHJdmfrXB"
92
+ market.name // "Europe"
93
+ market.currency // "EUR"
94
+ ```
95
+
96
+ ```bash cURL
97
+ curl 'https://api.mystore.com/api/v3/store/markets/resolve?country=DE' \
98
+ -H 'Authorization: Bearer spree_pk_xxx'
99
+ ```
100
+
101
+
102
+ > **INFO:** If no market matches the given country, a `404` error is returned.
103
+
104
+ ## List Countries in a Market
105
+
106
+ Returns countries belonging to a specific market. Use this for address form country dropdowns during checkout.
107
+
108
+
109
+ ```typescript SDK
110
+ const { data: countries } = await client.markets.countries.list('mkt_gbHJdmfrXB')
111
+
112
+ countries.forEach(country => {
113
+ country.iso // "DE"
114
+ country.name // "Germany"
115
+ country.states_required // false
116
+ country.zipcode_required // true
117
+ })
118
+ ```
119
+
120
+ ```bash cURL
121
+ curl 'https://api.mystore.com/api/v3/store/markets/mkt_gbHJdmfrXB/countries' \
122
+ -H 'Authorization: Bearer spree_pk_xxx'
123
+ ```
124
+
125
+
126
+ ## Get a Country in a Market
127
+
128
+ Returns a single country by ISO code within a market. Use `expand: ['states']` for address forms that need state/province dropdowns.
129
+
130
+
131
+ ```typescript SDK
132
+ const country = await client.markets.countries.get('mkt_gbHJdmfrXB', 'US', {
133
+ expand: ['states'],
134
+ })
135
+
136
+ country.iso // "US"
137
+ country.name // "United States of America"
138
+ country.states // [{ id: "st_xxx", name: "New York", abbr: "NY" }, ...]
139
+ ```
140
+
141
+ ```bash cURL
142
+ curl 'https://api.mystore.com/api/v3/store/markets/mkt_gbHJdmfrXB/countries/US?expand=states' \
143
+ -H 'Authorization: Bearer spree_pk_xxx'
144
+ ```
145
+
146
+
147
+ ## Related Documentation
148
+
149
+ - [Markets](/developer/core-concepts/markets) — Market concepts, zones, and configuration
150
+ - [Localization](/api-reference/store-api/localization) — Locale and currency headers
151
+ - [Geography](/developer/sdk/store/products#geography) — Global country endpoints
@@ -0,0 +1,96 @@
1
+ ---
2
+ title: Payments & Delivery
3
+ description: Handle payments, payment sessions, and delivery with the Spree SDK
4
+ ---
5
+
6
+ All payment and delivery endpoints require a `cartId` as the first argument.
7
+
8
+ ## Payment Methods
9
+
10
+ ```typescript
11
+ const options = { spreeToken: cart.token };
12
+
13
+ // Get available payment methods for the current cart
14
+ const methods = await client.carts.paymentMethods.list(cartId, options);
15
+
16
+ // Each method includes a `session_required` flag:
17
+ // - true → use Payment Sessions (Stripe, Adyen, PayPal, etc.)
18
+ // - false → use direct payment creation (Check, Cash on Delivery, Bank Transfer, etc.)
19
+ ```
20
+
21
+ ## Payments
22
+
23
+ ```typescript
24
+ const options = { spreeToken: cart.token };
25
+
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
+ // Create a payment for a non-session payment method
33
+ // (e.g. Check, Cash on Delivery, Bank Transfer, Purchase Order)
34
+ const payment = await client.carts.payments.create(cartId, {
35
+ payment_method_id: 'pm_xxx',
36
+ amount: '99.99', // Optional, defaults to order total minus store credits
37
+ metadata: { // Optional, write-only metadata
38
+ purchase_order_number: 'PO-12345',
39
+ },
40
+ }, options);
41
+ ```
42
+
43
+ > **NOTE:** `payments.create()` only works with non-session payment methods (where `session_required` is `false`).
44
+ > For session-based gateways like Stripe or Adyen, use `paymentSessions.create()` instead.
45
+
46
+ ## Payment Sessions
47
+
48
+ Payment sessions provide a unified, provider-agnostic interface for payment processing. They work with any payment gateway (Stripe, Adyen, PayPal, etc.) through a single API.
49
+
50
+ ```typescript
51
+ const options = { spreeToken: cart.token };
52
+
53
+ // Create a payment session (initializes a session with the payment gateway)
54
+ const session = await client.carts.paymentSessions.create(cartId, {
55
+ payment_method_id: 'pm_xxx',
56
+ amount: '99.99', // Optional, defaults to order total
57
+ external_data: { // Optional, provider-specific data
58
+ return_url: 'https://mystore.com/checkout/complete',
59
+ },
60
+ }, options);
61
+
62
+ // The session contains provider-specific data (e.g., Stripe client_secret)
63
+ console.log(session.external_data.client_secret);
64
+
65
+ // Get a payment session
66
+ const existing = await client.carts.paymentSessions.get(
67
+ cartId, session.id, options
68
+ );
69
+
70
+ // Update a payment session (e.g., after order total changes)
71
+ await client.carts.paymentSessions.update(cartId, session.id, {
72
+ amount: '149.99',
73
+ }, options);
74
+
75
+ // Complete the payment session (after customer confirms payment on the frontend)
76
+ const completed = await client.carts.paymentSessions.complete(
77
+ cartId, session.id,
78
+ { session_result: 'success' },
79
+ options
80
+ );
81
+ console.log(completed.status); // 'completed'
82
+ ```
83
+
84
+ ## Fulfillments
85
+
86
+ ```typescript
87
+ const options = { spreeToken: cart.token };
88
+
89
+ // List fulfillments for the current cart
90
+ const fulfillments = await client.carts.fulfillments.list(cartId, options);
91
+
92
+ // Select a delivery rate
93
+ await client.carts.fulfillments.update(cartId, fulfillmentId, {
94
+ selected_delivery_rate_id: 'rate_xxx',
95
+ }, options);
96
+ ```
@@ -0,0 +1,149 @@
1
+ ---
2
+ title: Products & Categories
3
+ description: Browse products and categories with the Spree SDK
4
+ ---
5
+
6
+ ## Products
7
+
8
+ ### List Products
9
+
10
+ ```typescript
11
+ const products = await client.products.list({
12
+ page: 1,
13
+ limit: 25,
14
+ expand: ['variants', 'media', 'categories'],
15
+ });
16
+ ```
17
+
18
+ ### Filtering Products
19
+
20
+ Use flat param keys — the SDK wraps them in `q[...]` automatically:
21
+
22
+ ```typescript
23
+ const products = await client.products.list({
24
+ name_cont: 'shirt', // Name contains
25
+ price_gte: 20, // Min price
26
+ price_lte: 100, // Max price
27
+ with_option_value_ids: ['optval_abc', 'optval_def'], // By option values
28
+ in_stock: true, // In stock only
29
+ search: 'blue shirt', // Full-text search
30
+ });
31
+ ```
32
+
33
+ ### Sorting Products
34
+
35
+ Pass `sort` with one of the supported values. Prefix with `-` for descending order:
36
+
37
+ ```typescript
38
+ const products = await client.products.list({
39
+ sort: 'price', // price, -price, best_selling,
40
+ // name, -name, -available_on, available_on
41
+ });
42
+ ```
43
+
44
+ ### Field Selection
45
+
46
+ Request only specific fields to reduce payload size:
47
+
48
+ ```typescript
49
+ const products = await client.products.list({
50
+ fields: ['name', 'slug', 'price', 'display_price'],
51
+ });
52
+
53
+ const product = await client.products.get('spree-tote', {
54
+ fields: ['name', 'slug', 'price'],
55
+ expand: ['media'], // expanded associations are always included
56
+ });
57
+ ```
58
+
59
+ `id` is always included. Omit `fields` to return all fields.
60
+
61
+ ### Nested Expand
62
+
63
+ Use dot notation to expand nested associations (up to 4 levels):
64
+
65
+ ```typescript
66
+ // Expand variants with their images in one request
67
+ const product = await client.products.get('spree-tote', {
68
+ expand: ['variants.media', 'option_types'],
69
+ });
70
+
71
+ // Access nested data
72
+ product.variants.forEach(variant => {
73
+ console.log(variant.media); // Media are included
74
+ });
75
+ ```
76
+
77
+ ### Get a Product
78
+
79
+ Fetch a single product by slug or prefix ID:
80
+
81
+ ```typescript
82
+ const product = await client.products.get('spree-tote', {
83
+ expand: ['variants', 'media'],
84
+ });
85
+ ```
86
+
87
+ ### Product Filters
88
+
89
+ Get available filters (price range, availability, options, categories) and sort options for building filter UIs:
90
+
91
+ ```typescript
92
+ const filters = await client.products.filters({
93
+ category_id: 'ctg_abc123', // Optional: scope filters to a category
94
+ });
95
+
96
+ // Response:
97
+ // {
98
+ // filters: [
99
+ // { id: 'price', type: 'price_range', min: 9.99, max: 199.99, currency: 'USD' },
100
+ // { id: 'availability', type: 'availability', options: [{ id: 'in_stock', count: 42 }, ...] },
101
+ // { id: 'opttype_abc', type: 'option', name: 'color', presentation: 'Color', options: [...] },
102
+ // { id: 'categories', type: 'category', options: [{ id: 'ctg_abc', name: 'Shirts', permalink: '...', count: 12 }] },
103
+ // ],
104
+ // sort_options: [{ id: 'manual' }, { id: 'price' }, { id: 'best_selling' }, ...],
105
+ // default_sort: 'manual',
106
+ // total_count: 85,
107
+ // }
108
+ ```
109
+
110
+ ## Categories
111
+
112
+ ### List Categories
113
+
114
+ ```typescript
115
+ const categories = await client.categories.list({
116
+ depth_eq: 1, // Top-level categories only
117
+ });
118
+ ```
119
+
120
+ ### Get a Category
121
+
122
+ Fetch by ID or permalink:
123
+
124
+ ```typescript
125
+ const category = await client.categories.get('clothing/shirts', {
126
+ expand: ['ancestors', 'children'], // For breadcrumbs and subcategories
127
+ });
128
+ ```
129
+
130
+ ### List Products in a Category
131
+
132
+ ```typescript
133
+ const categoryProducts = await client.categories.products.list('clothing/shirts', {
134
+ page: 1,
135
+ limit: 12,
136
+ expand: ['media', 'default_variant'],
137
+ });
138
+ ```
139
+
140
+ ## Geography
141
+
142
+ ```typescript
143
+ // List countries available for checkout
144
+ const { data: countries } = await client.countries.list();
145
+
146
+ // Get country by ISO code (includes states)
147
+ const usa = await client.countries.get('US');
148
+ console.log(usa.states); // Array of states
149
+ ```