@sazito/client-sdk 1.2.2 → 1.2.4
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/LICENSE +21 -0
- package/README.md +60 -6
- package/dist/index.d.mts +2289 -0
- package/dist/index.d.ts +143 -71
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.umd.js +1 -1
- package/package.json +14 -23
- package/dist/index.esm.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sazito
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Official JavaScript/TypeScript SDK for Sazito storefronts.
|
|
4
4
|
|
|
5
|
+
Read the full developer documentation at [developers.sazito.com](https://developers.sazito.com).
|
|
6
|
+
|
|
5
7
|
This SDK is built for application developers who want a typed, framework-agnostic client with:
|
|
6
8
|
- automatic request/response key transformation
|
|
7
9
|
- unified response objects (`{ data, error }`)
|
|
@@ -56,6 +58,54 @@ if (res.error) {
|
|
|
56
58
|
}
|
|
57
59
|
```
|
|
58
60
|
|
|
61
|
+
## Checkout component
|
|
62
|
+
|
|
63
|
+
For a ready-made React/Next.js checkout UI, install the companion package:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pnpm add @sazito/client-sdk @sazito/checkout
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Create one SDK client, provide it to the checkout, and import the checkout
|
|
70
|
+
stylesheet once:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
'use client';
|
|
74
|
+
|
|
75
|
+
import '@sazito/checkout/styles.css';
|
|
76
|
+
import { createSazitoClient } from '@sazito/client-sdk';
|
|
77
|
+
import { SazitoCheckoutPage, SazitoProvider } from '@sazito/checkout/next';
|
|
78
|
+
|
|
79
|
+
const sazito = createSazitoClient({ domain: 'mystore.sazito.com' });
|
|
80
|
+
|
|
81
|
+
export default function CheckoutPage() {
|
|
82
|
+
return (
|
|
83
|
+
<SazitoProvider client={sazito}>
|
|
84
|
+
<SazitoCheckoutPage
|
|
85
|
+
credentials={{ cart: { identifier: 'cart-identifier' } }}
|
|
86
|
+
config={{
|
|
87
|
+
locale: 'fa',
|
|
88
|
+
continueShoppingUrl: '/',
|
|
89
|
+
theme: {
|
|
90
|
+
accent: '#4f46e5',
|
|
91
|
+
accentForeground: '#ffffff',
|
|
92
|
+
radius: 16
|
|
93
|
+
}
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
</SazitoProvider>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The component provides a typed, RTL-first flow for `cart → shipping → payment → result`,
|
|
102
|
+
including cart editing, address and shipping-rate selection, discounts, payment
|
|
103
|
+
gateway redirects, and pending-payment polling. It reuses the credentials stored
|
|
104
|
+
by the SDK client, so credentials created through `sazito.cart` and
|
|
105
|
+
`sazito.invoices` can be used by the component. For theming, custom buttons,
|
|
106
|
+
analytics, payment returns, and a fully custom layout, see the
|
|
107
|
+
[checkout guide](https://developers.sazito.com/docs/guides/checkout).
|
|
108
|
+
|
|
59
109
|
## Core Response Model
|
|
60
110
|
|
|
61
111
|
All SDK methods return a `SazitoResponse<T>`:
|
|
@@ -198,6 +248,8 @@ The client instance exposes:
|
|
|
198
248
|
- `entityRoutes`
|
|
199
249
|
- `menu`
|
|
200
250
|
- `general`
|
|
251
|
+
- `dynamicForms`
|
|
252
|
+
- `regions`
|
|
201
253
|
|
|
202
254
|
### Methods by Module
|
|
203
255
|
|
|
@@ -205,14 +257,14 @@ The client instance exposes:
|
|
|
205
257
|
|---|---|
|
|
206
258
|
| `products` | `get`, `list`, `search` |
|
|
207
259
|
| `categories` | `get`, `list` |
|
|
208
|
-
| `cart` | `get`, `create`, `addItem`, `updateItem`, `removeItem`, `clearCart` |
|
|
260
|
+
| `cart` | `get`, `create`, `addItem`, `addItemWithAttributes`, `updateItem`, `updateItemWithAttributes`, `removeItem`, `clearCart` |
|
|
209
261
|
| `orders` | `list`, `get` |
|
|
210
|
-
| `invoices` | `get`, `create`, `refresh`, `addShippingAddress`, `addDiscountCode`, `assignShippingMethod`, `addDetails`, `getApplicableShippingMethods`, `clearInvoice` |
|
|
211
|
-
| `shipping` | `createAddress`, `updateAddress`, `getAddress`, `getMethods`, `clearAddress` |
|
|
212
|
-
| `payments` | `getMethods`, `create`, `initialize`, `processStep`, `clearPayment` |
|
|
262
|
+
| `invoices` | `get`, `create`, `refresh`, `addShippingAddress`, `addDiscountCode`, `assignShippingMethod`, `addDetails`, `addForm`, `addCredit`, `removeCredit`, `toggleCredit`, `getApplicableShippingMethods`, `clearInvoice` |
|
|
263
|
+
| `shipping` | `createAddress`, `updateAddress` (legacy), `listAddresses`, `getAddress`, `getMethods`, `clearAddress` |
|
|
264
|
+
| `payments` | `getMethods`, `create`, `initialize`, `verify`, `processStep`, `processStepForm`, `pollUntilSettled`, `clearPayment` |
|
|
213
265
|
| `users` | `login`, `requestMobileOTP`, `verifyMobileOTP`, `requestEmailLogin`, `register`, `getCurrentUser`, `updateProfile`, `requestMobilePhoneUpdate`, `verifyMobilePhoneUpdate`, `forgotPassword`, `revivePassword`, `mergeUser` |
|
|
214
|
-
| `search` | `
|
|
215
|
-
| `feedbacks` | `list`, `create`, `get` |
|
|
266
|
+
| `search` | `query` |
|
|
267
|
+
| `feedbacks` | `getSeed`, `createOrderRating`, `submitProductReview`, `getProductStatistics`, `getProductReviews`, `uploadReviewImages`, `list`, `create`, `get` |
|
|
216
268
|
| `wallet` | `getBalance`, `applyCredit`, `removeCredit`, `listTransactions` |
|
|
217
269
|
| `cms` | `getPage`, `listPages`, `getBlogPost`, `listBlogPosts`, `listAll` |
|
|
218
270
|
| `images` | `upload`, `delete` |
|
|
@@ -221,6 +273,8 @@ The client instance exposes:
|
|
|
221
273
|
| `entityRoutes` | `resolve` |
|
|
222
274
|
| `menu` | `getHeaderMenu` |
|
|
223
275
|
| `general` | `getInfo`, `getFeatures`, `getCheckoutConfig`, `getWalletConfig`, `getTajrobeConfig` |
|
|
276
|
+
| `dynamicForms` | `getForm`, `uploadProductFormFile` |
|
|
277
|
+
| `regions` | `list` |
|
|
224
278
|
|
|
225
279
|
## Usage Examples
|
|
226
280
|
|