@classytic/commerce-sdk 0.1.1
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 +14 -0
- package/README.md +164 -0
- package/dist/adjustment-MNH3AT6S.js +5 -0
- package/dist/adjustment-MNH3AT6S.js.map +1 -0
- package/dist/analytics/index.d.ts +27 -0
- package/dist/analytics/index.js +6 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics-DMcD-o8w.d.ts +76 -0
- package/dist/api-factory-B_h4RKBm.d.ts +280 -0
- package/dist/auth/index.d.ts +39 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/catalog/index.d.ts +571 -0
- package/dist/catalog/index.js +9 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/chunk-24FDD6UR.js +75 -0
- package/dist/chunk-24FDD6UR.js.map +1 -0
- package/dist/chunk-2TF7QNYV.js +159 -0
- package/dist/chunk-2TF7QNYV.js.map +1 -0
- package/dist/chunk-2YAZ5WG6.js +479 -0
- package/dist/chunk-2YAZ5WG6.js.map +1 -0
- package/dist/chunk-36NLLAVH.js +177 -0
- package/dist/chunk-36NLLAVH.js.map +1 -0
- package/dist/chunk-3OYSJB3P.js +126 -0
- package/dist/chunk-3OYSJB3P.js.map +1 -0
- package/dist/chunk-5E57JODA.js +135 -0
- package/dist/chunk-5E57JODA.js.map +1 -0
- package/dist/chunk-7LZCW4VF.js +13 -0
- package/dist/chunk-7LZCW4VF.js.map +1 -0
- package/dist/chunk-ANYGZ6O5.js +830 -0
- package/dist/chunk-ANYGZ6O5.js.map +1 -0
- package/dist/chunk-AQAISI4F.js +183 -0
- package/dist/chunk-AQAISI4F.js.map +1 -0
- package/dist/chunk-B6MPVOV7.js +328 -0
- package/dist/chunk-B6MPVOV7.js.map +1 -0
- package/dist/chunk-CILP56G2.js +94 -0
- package/dist/chunk-CILP56G2.js.map +1 -0
- package/dist/chunk-ERQ52WHY.js +534 -0
- package/dist/chunk-ERQ52WHY.js.map +1 -0
- package/dist/chunk-FOTUJPM4.js +640 -0
- package/dist/chunk-FOTUJPM4.js.map +1 -0
- package/dist/chunk-IHCBBLLW.js +198 -0
- package/dist/chunk-IHCBBLLW.js.map +1 -0
- package/dist/chunk-J4JBQET2.js +76 -0
- package/dist/chunk-J4JBQET2.js.map +1 -0
- package/dist/chunk-L4OEI4VZ.js +123 -0
- package/dist/chunk-L4OEI4VZ.js.map +1 -0
- package/dist/chunk-LRV7MWWX.js +616 -0
- package/dist/chunk-LRV7MWWX.js.map +1 -0
- package/dist/chunk-N43VE355.js +126 -0
- package/dist/chunk-N43VE355.js.map +1 -0
- package/dist/chunk-PYYLHUV6.js +3 -0
- package/dist/chunk-PYYLHUV6.js.map +1 -0
- package/dist/chunk-QCTXAMLA.js +261 -0
- package/dist/chunk-QCTXAMLA.js.map +1 -0
- package/dist/chunk-RIKAPJNG.js +40 -0
- package/dist/chunk-RIKAPJNG.js.map +1 -0
- package/dist/chunk-U3XT35GZ.js +202 -0
- package/dist/chunk-U3XT35GZ.js.map +1 -0
- package/dist/chunk-W22WB3WZ.js +148 -0
- package/dist/chunk-W22WB3WZ.js.map +1 -0
- package/dist/chunk-WTIJMKML.js +27 -0
- package/dist/chunk-WTIJMKML.js.map +1 -0
- package/dist/chunk-X2CQFJPR.js +75 -0
- package/dist/chunk-X2CQFJPR.js.map +1 -0
- package/dist/chunk-YYFKLOKO.js +769 -0
- package/dist/chunk-YYFKLOKO.js.map +1 -0
- package/dist/client-Cs7E_usr.d.ts +113 -0
- package/dist/content/index.d.ts +309 -0
- package/dist/content/index.js +6 -0
- package/dist/content/index.js.map +1 -0
- package/dist/core/index.d.ts +166 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/react.d.ts +107 -0
- package/dist/core/react.js +5 -0
- package/dist/core/react.js.map +1 -0
- package/dist/coupon-BZSZ0y3n.d.ts +129 -0
- package/dist/coupon-CDzL4bJG.d.ts +655 -0
- package/dist/crud.factory-DyKaPHcU.d.ts +181 -0
- package/dist/finance/index.d.ts +81 -0
- package/dist/finance/index.js +5 -0
- package/dist/finance/index.js.map +1 -0
- package/dist/finance-BJdfKRw0.d.ts +135 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory/index.d.ts +512 -0
- package/dist/inventory/index.js +16 -0
- package/dist/inventory/index.js.map +1 -0
- package/dist/inventory-B5pssqRx.d.ts +748 -0
- package/dist/logistics/index.d.ts +248 -0
- package/dist/logistics/index.js +7 -0
- package/dist/logistics/index.js.map +1 -0
- package/dist/logistics-CrpKadKE.d.ts +410 -0
- package/dist/media-CNLJK93J.d.ts +721 -0
- package/dist/movement-R3CERFAM.js +5 -0
- package/dist/movement-R3CERFAM.js.map +1 -0
- package/dist/order-B3dCvHgK.d.ts +360 -0
- package/dist/payment-BRboLqvU.d.ts +127 -0
- package/dist/payments/index.d.ts +55 -0
- package/dist/payments/index.js +6 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/platform/index.d.ts +645 -0
- package/dist/platform/index.js +8 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/pos-BCqkx2-K.d.ts +527 -0
- package/dist/product-p09zXkXB.d.ts +260 -0
- package/dist/purchase-54PER2PY.js +5 -0
- package/dist/purchase-54PER2PY.js.map +1 -0
- package/dist/request-MP6NV5ZE.js +5 -0
- package/dist/request-MP6NV5ZE.js.map +1 -0
- package/dist/sales/index.d.ts +587 -0
- package/dist/sales/index.js +9 -0
- package/dist/sales/index.js.map +1 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.js +37 -0
- package/dist/server.js.map +1 -0
- package/dist/size-guide-DgjzjM5P.d.ts +554 -0
- package/dist/stock-2LP4HJSB.js +5 -0
- package/dist/stock-2LP4HJSB.js.map +1 -0
- package/dist/stock-CfrU5_Wr.d.ts +632 -0
- package/dist/supplier-BWJTRZ5Z.js +5 -0
- package/dist/supplier-BWJTRZ5Z.js.map +1 -0
- package/dist/transaction/index.d.ts +104 -0
- package/dist/transaction/index.js +8 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction-Bf6WjYCh.d.ts +84 -0
- package/dist/transaction-dL3WW-er.d.ts +442 -0
- package/dist/transfer-4XSS6HWT.js +5 -0
- package/dist/transfer-4XSS6HWT.js.map +1 -0
- package/dist/user-data-DdLjAGwO.d.ts +132 -0
- package/package.json +147 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order Types
|
|
3
|
+
*
|
|
4
|
+
* Source of truth: modules/commerce/order/order.model.js
|
|
5
|
+
*/
|
|
6
|
+
type ShippingStatus = 'pending' | 'requested' | 'picked_up' | 'in_transit' | 'out_for_delivery' | 'delivered' | 'failed_attempt' | 'returned' | 'cancelled';
|
|
7
|
+
type ShippingProvider = 'redx' | 'pathao' | 'steadfast' | 'paperfly' | 'sundarban' | 'sa_paribahan' | 'dhl' | 'fedex' | 'manual' | 'other';
|
|
8
|
+
declare enum OrderStatus {
|
|
9
|
+
PENDING = "pending",
|
|
10
|
+
PROCESSING = "processing",
|
|
11
|
+
CONFIRMED = "confirmed",
|
|
12
|
+
SHIPPED = "shipped",
|
|
13
|
+
DELIVERED = "delivered",
|
|
14
|
+
CANCELLED = "cancelled"
|
|
15
|
+
}
|
|
16
|
+
declare enum PaymentStatus {
|
|
17
|
+
PENDING = "pending",
|
|
18
|
+
VERIFIED = "verified",
|
|
19
|
+
FAILED = "failed",
|
|
20
|
+
REFUNDED = "refunded",
|
|
21
|
+
PARTIALLY_REFUNDED = "partially_refunded",
|
|
22
|
+
CANCELLED = "cancelled"
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Order Item
|
|
26
|
+
*/
|
|
27
|
+
interface OrderItem {
|
|
28
|
+
_id?: string;
|
|
29
|
+
product: string;
|
|
30
|
+
productName: string;
|
|
31
|
+
productSlug?: string;
|
|
32
|
+
variantSku?: string;
|
|
33
|
+
variantAttributes?: Record<string, string>;
|
|
34
|
+
variantPriceModifier?: number;
|
|
35
|
+
quantity: number;
|
|
36
|
+
price: number;
|
|
37
|
+
/**
|
|
38
|
+
* System field: Cost of Goods Sold at time of sale
|
|
39
|
+
* Used for profit calculation. Read-only.
|
|
40
|
+
*/
|
|
41
|
+
costPriceAtSale?: number;
|
|
42
|
+
vatRate?: number;
|
|
43
|
+
vatAmount?: number;
|
|
44
|
+
lineTotal?: number;
|
|
45
|
+
lineTotalExVat?: number;
|
|
46
|
+
profit?: number | null;
|
|
47
|
+
profitMargin?: number | null;
|
|
48
|
+
}
|
|
49
|
+
interface OrderDelivery {
|
|
50
|
+
method: string;
|
|
51
|
+
price: number;
|
|
52
|
+
estimatedDays?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Order Delivery Address
|
|
56
|
+
*/
|
|
57
|
+
interface OrderAddress {
|
|
58
|
+
/** Address label (e.g., "Home", "Office") - optional */
|
|
59
|
+
label?: string;
|
|
60
|
+
/** Recipient name for delivery label */
|
|
61
|
+
recipientName?: string;
|
|
62
|
+
/** Contact phone for delivery (format: 01XXXXXXXXX) */
|
|
63
|
+
recipientPhone?: string;
|
|
64
|
+
/** Street address (required for checkout) */
|
|
65
|
+
addressLine1?: string;
|
|
66
|
+
/** Additional address details (apartment, floor, etc.) */
|
|
67
|
+
addressLine2?: string;
|
|
68
|
+
/** Area ID from @classytic/bd-areas constants */
|
|
69
|
+
areaId?: number;
|
|
70
|
+
/** Area display name (e.g., "Mohammadpur", "Dhanmondi") */
|
|
71
|
+
areaName?: string;
|
|
72
|
+
/** Zone ID for delivery pricing (1-6) */
|
|
73
|
+
zoneId?: number;
|
|
74
|
+
/** Provider-specific area IDs for logistics integration */
|
|
75
|
+
providerAreaIds?: {
|
|
76
|
+
redx?: number;
|
|
77
|
+
pathao?: number;
|
|
78
|
+
steadfast?: number;
|
|
79
|
+
};
|
|
80
|
+
/** City/District name */
|
|
81
|
+
city?: string;
|
|
82
|
+
/** Division/State */
|
|
83
|
+
division?: string;
|
|
84
|
+
/** Postal code */
|
|
85
|
+
postalCode?: string;
|
|
86
|
+
/** Country (defaults to "Bangladesh") */
|
|
87
|
+
country?: string;
|
|
88
|
+
}
|
|
89
|
+
interface OrderVat {
|
|
90
|
+
applicable: boolean;
|
|
91
|
+
rate: number;
|
|
92
|
+
amount: number;
|
|
93
|
+
pricesIncludeVat: boolean;
|
|
94
|
+
taxableAmount: number;
|
|
95
|
+
sellerBin?: string;
|
|
96
|
+
invoiceNumber?: string;
|
|
97
|
+
invoiceIssuedAt?: string;
|
|
98
|
+
invoiceBranch?: string;
|
|
99
|
+
invoiceDateKey?: string;
|
|
100
|
+
}
|
|
101
|
+
interface OrderPayment {
|
|
102
|
+
transactionId?: string;
|
|
103
|
+
/** Amount in paisa (smallest unit). Divide by 100 for BDT display. */
|
|
104
|
+
amount: number;
|
|
105
|
+
status: PaymentStatus | string;
|
|
106
|
+
method: string;
|
|
107
|
+
reference?: string;
|
|
108
|
+
verifiedAt?: string;
|
|
109
|
+
verifiedBy?: string;
|
|
110
|
+
}
|
|
111
|
+
interface OrderShippingHistory {
|
|
112
|
+
status: ShippingStatus | string;
|
|
113
|
+
note?: string;
|
|
114
|
+
actor?: string;
|
|
115
|
+
timestamp: string;
|
|
116
|
+
}
|
|
117
|
+
interface OrderShipping {
|
|
118
|
+
provider?: ShippingProvider | string;
|
|
119
|
+
status?: ShippingStatus | string;
|
|
120
|
+
trackingNumber?: string;
|
|
121
|
+
trackingUrl?: string;
|
|
122
|
+
consignmentId?: string;
|
|
123
|
+
labelUrl?: string;
|
|
124
|
+
estimatedDelivery?: string;
|
|
125
|
+
requestedAt?: string;
|
|
126
|
+
pickedUpAt?: string;
|
|
127
|
+
deliveredAt?: string;
|
|
128
|
+
metadata?: Record<string, unknown>;
|
|
129
|
+
history?: OrderShippingHistory[];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Parcel metrics for delivery estimation
|
|
133
|
+
*/
|
|
134
|
+
interface OrderParcel {
|
|
135
|
+
/** Total weight in grams */
|
|
136
|
+
weightGrams: number;
|
|
137
|
+
/** Package dimensions in centimeters */
|
|
138
|
+
dimensionsCm?: {
|
|
139
|
+
length: number;
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
};
|
|
143
|
+
/** Number of items without weight data */
|
|
144
|
+
missingWeightItems: number;
|
|
145
|
+
/** Number of items without dimension data */
|
|
146
|
+
missingDimensionItems: number;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Cancellation request details
|
|
150
|
+
*/
|
|
151
|
+
interface CancellationRequest {
|
|
152
|
+
requested: boolean;
|
|
153
|
+
reason?: string;
|
|
154
|
+
requestedAt?: string;
|
|
155
|
+
requestedBy?: string;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Main Order Interface
|
|
159
|
+
*/
|
|
160
|
+
interface Order {
|
|
161
|
+
_id: string;
|
|
162
|
+
/** Virtual: last 8 chars of _id (uppercase) */
|
|
163
|
+
orderNumber?: string;
|
|
164
|
+
customer?: string;
|
|
165
|
+
customerName: string;
|
|
166
|
+
customerPhone?: string;
|
|
167
|
+
customerEmail?: string;
|
|
168
|
+
userId?: string;
|
|
169
|
+
items: OrderItem[];
|
|
170
|
+
subtotal: number;
|
|
171
|
+
discountAmount: number;
|
|
172
|
+
deliveryCharge: number;
|
|
173
|
+
totalAmount: number;
|
|
174
|
+
vat?: OrderVat;
|
|
175
|
+
delivery?: OrderDelivery;
|
|
176
|
+
deliveryAddress?: OrderAddress;
|
|
177
|
+
/** True if ordering on behalf of someone else (gift order) */
|
|
178
|
+
isGift?: boolean;
|
|
179
|
+
status: OrderStatus | string;
|
|
180
|
+
source: 'web' | 'pos' | 'api';
|
|
181
|
+
branch?: string;
|
|
182
|
+
terminalId?: string;
|
|
183
|
+
cashier?: string;
|
|
184
|
+
/** Idempotency key for safe retries */
|
|
185
|
+
idempotencyKey?: string;
|
|
186
|
+
/** Reservation ID for stock hold */
|
|
187
|
+
stockReservationId?: string;
|
|
188
|
+
stockReservationExpiresAt?: string;
|
|
189
|
+
currentPayment?: OrderPayment;
|
|
190
|
+
shipping?: OrderShipping;
|
|
191
|
+
/** Parcel metrics for delivery estimation */
|
|
192
|
+
parcel?: OrderParcel;
|
|
193
|
+
/** Customer cancellation request (awaiting admin review) */
|
|
194
|
+
cancellationRequest?: CancellationRequest;
|
|
195
|
+
/** Final cancellation reason (after cancelled) */
|
|
196
|
+
cancellationReason?: string;
|
|
197
|
+
notes?: string;
|
|
198
|
+
createdAt: string;
|
|
199
|
+
updatedAt: string;
|
|
200
|
+
canCancel?: boolean;
|
|
201
|
+
isCompleted?: boolean;
|
|
202
|
+
paymentStatus?: string;
|
|
203
|
+
paymentMethod?: string;
|
|
204
|
+
netAmount?: number;
|
|
205
|
+
grossAmount?: number;
|
|
206
|
+
trackingNumber?: string;
|
|
207
|
+
shippedAt?: string;
|
|
208
|
+
deliveredAt?: string;
|
|
209
|
+
shippingStatus?: string;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Payment Data for checkout
|
|
213
|
+
*/
|
|
214
|
+
interface PaymentData {
|
|
215
|
+
/**
|
|
216
|
+
* Payment method (optional, defaults to 'cash')
|
|
217
|
+
*/
|
|
218
|
+
type?: 'cash' | 'bkash' | 'nagad' | 'rocket' | 'bank_transfer' | 'card' | string;
|
|
219
|
+
/**
|
|
220
|
+
* Payment gateway (default: 'manual')
|
|
221
|
+
*/
|
|
222
|
+
gateway?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Transaction ID/reference (recommended for verification)
|
|
225
|
+
*/
|
|
226
|
+
reference?: string;
|
|
227
|
+
/**
|
|
228
|
+
* Mobile wallet sender phone (REQUIRED for bkash/nagad/rocket)
|
|
229
|
+
*/
|
|
230
|
+
senderPhone?: string;
|
|
231
|
+
/**
|
|
232
|
+
* Additional payment verification details
|
|
233
|
+
*/
|
|
234
|
+
paymentDetails?: {
|
|
235
|
+
walletNumber?: string;
|
|
236
|
+
walletType?: 'personal' | 'merchant';
|
|
237
|
+
bankName?: string;
|
|
238
|
+
accountNumber?: string;
|
|
239
|
+
accountName?: string;
|
|
240
|
+
proofUrl?: string;
|
|
241
|
+
};
|
|
242
|
+
/** Additional payment notes */
|
|
243
|
+
notes?: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Payload for Creating an Order (Web/API)
|
|
247
|
+
*/
|
|
248
|
+
interface CreateOrderPayload {
|
|
249
|
+
/** Delivery address (required) */
|
|
250
|
+
deliveryAddress: OrderAddress & {
|
|
251
|
+
recipientName: string;
|
|
252
|
+
recipientPhone: string;
|
|
253
|
+
addressLine1: string;
|
|
254
|
+
areaId: number;
|
|
255
|
+
areaName: string;
|
|
256
|
+
zoneId: number;
|
|
257
|
+
city: string;
|
|
258
|
+
};
|
|
259
|
+
/** Delivery method and pricing (required) */
|
|
260
|
+
delivery: OrderDelivery & {
|
|
261
|
+
method: string;
|
|
262
|
+
price: number;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Payment details for verification (optional, defaults to cash)
|
|
266
|
+
*/
|
|
267
|
+
paymentData?: PaymentData;
|
|
268
|
+
/** True if ordering on behalf of someone else (gift order) */
|
|
269
|
+
isGift?: boolean;
|
|
270
|
+
/** Coupon code to apply */
|
|
271
|
+
couponCode?: string;
|
|
272
|
+
/** Order notes */
|
|
273
|
+
notes?: string;
|
|
274
|
+
/** Preferred branch ID for fulfillment */
|
|
275
|
+
branchId?: string;
|
|
276
|
+
/** Preferred branch slug (alternative to branchId) */
|
|
277
|
+
branchSlug?: string;
|
|
278
|
+
/** Idempotency key for safe retries (prevents duplicate orders) */
|
|
279
|
+
idempotencyKey?: string;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Payload for Updating Order Status (Admin)
|
|
283
|
+
*/
|
|
284
|
+
interface UpdateStatusPayload {
|
|
285
|
+
status: OrderStatus;
|
|
286
|
+
/** Optional note for status change */
|
|
287
|
+
note?: string;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Payload for Cancelling an Order
|
|
291
|
+
*/
|
|
292
|
+
interface CancelOrderPayload {
|
|
293
|
+
/** Cancellation reason */
|
|
294
|
+
reason?: string;
|
|
295
|
+
/** Process refund if payment was verified */
|
|
296
|
+
refund?: boolean;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Payload for Requesting Cancellation (awaits admin review)
|
|
300
|
+
*/
|
|
301
|
+
interface CancelRequestPayload {
|
|
302
|
+
/** Reason for cancellation request */
|
|
303
|
+
reason?: string;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Payload for Fulfilling/Shipping an Order (Admin)
|
|
307
|
+
*/
|
|
308
|
+
interface FulfillOrderPayload {
|
|
309
|
+
/** Shipping tracking number */
|
|
310
|
+
trackingNumber?: string;
|
|
311
|
+
/** Shipping carrier (e.g., Pathao, Redx) */
|
|
312
|
+
carrier?: string;
|
|
313
|
+
/** Fulfillment notes */
|
|
314
|
+
notes?: string;
|
|
315
|
+
/** Shipping date */
|
|
316
|
+
shippedAt?: string;
|
|
317
|
+
/** Estimated delivery date */
|
|
318
|
+
estimatedDelivery?: string;
|
|
319
|
+
/** Branch ID for inventory decrement (overrides order.branch) */
|
|
320
|
+
branchId?: string;
|
|
321
|
+
/** Branch slug (alternative to branchId) */
|
|
322
|
+
branchSlug?: string;
|
|
323
|
+
/**
|
|
324
|
+
* Record COGS expense transaction (default: false)
|
|
325
|
+
*/
|
|
326
|
+
recordCogs?: boolean;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Payload for Refunding an Order (Admin)
|
|
330
|
+
*/
|
|
331
|
+
interface RefundOrderPayload {
|
|
332
|
+
/** Refund amount in smallest unit (paisa). Omit for full refund. */
|
|
333
|
+
amount?: number;
|
|
334
|
+
/** Refund reason */
|
|
335
|
+
reason?: string;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Payload for Requesting Shipping Pickup (Admin)
|
|
339
|
+
*/
|
|
340
|
+
interface RequestShippingPayload {
|
|
341
|
+
/** Shipping provider (required) */
|
|
342
|
+
provider: string;
|
|
343
|
+
/** Additional shipping options */
|
|
344
|
+
options?: Record<string, unknown>;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Payload for Updating Shipping Status (Admin/Webhook)
|
|
348
|
+
*/
|
|
349
|
+
interface UpdateShippingPayload {
|
|
350
|
+
/** Shipping status (required) */
|
|
351
|
+
status: string;
|
|
352
|
+
/** Status note */
|
|
353
|
+
note?: string;
|
|
354
|
+
/** Tracking number */
|
|
355
|
+
trackingNumber?: string;
|
|
356
|
+
/** Tracking URL */
|
|
357
|
+
trackingUrl?: string;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export { type CancellationRequest as C, type FulfillOrderPayload as F, OrderStatus as O, PaymentStatus as P, type RefundOrderPayload as R, type ShippingStatus as S, type UpdateStatusPayload as U, type ShippingProvider as a, type Order as b, type OrderItem as c, type OrderDelivery as d, type OrderAddress as e, type OrderVat as f, type OrderPayment as g, type OrderShipping as h, type OrderShippingHistory as i, type OrderParcel as j, type PaymentData as k, type CreateOrderPayload as l, type CancelOrderPayload as m, type CancelRequestPayload as n, type RequestShippingPayload as o, type UpdateShippingPayload as p };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { A as ApiResponse } from './api-factory-B_h4RKBm.js';
|
|
2
|
+
|
|
3
|
+
type PaymentStatus = "pending" | "verified" | "failed" | "refunded" | "partially_refunded" | "cancelled";
|
|
4
|
+
/**
|
|
5
|
+
* Transaction reference info
|
|
6
|
+
*/
|
|
7
|
+
interface TransactionEntity {
|
|
8
|
+
referenceModel: "Order";
|
|
9
|
+
referenceId: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Verification result returned from backend
|
|
13
|
+
*/
|
|
14
|
+
interface VerificationResult {
|
|
15
|
+
transactionId: string;
|
|
16
|
+
status: PaymentStatus;
|
|
17
|
+
amount: number;
|
|
18
|
+
category: string;
|
|
19
|
+
verifiedAt: string;
|
|
20
|
+
verifiedBy: string;
|
|
21
|
+
entity: TransactionEntity | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reject result returned from backend
|
|
25
|
+
*/
|
|
26
|
+
interface RejectResult {
|
|
27
|
+
transactionId: string;
|
|
28
|
+
status: "failed";
|
|
29
|
+
failedAt: string;
|
|
30
|
+
failureReason: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Verify payment request payload
|
|
34
|
+
*/
|
|
35
|
+
interface VerifyPaymentPayload {
|
|
36
|
+
/** Transaction ID (MongoDB ObjectId) */
|
|
37
|
+
transactionId: string;
|
|
38
|
+
/** Optional verification notes */
|
|
39
|
+
notes?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Reject payment request payload
|
|
43
|
+
*/
|
|
44
|
+
interface RejectPaymentPayload {
|
|
45
|
+
/** Transaction ID (MongoDB ObjectId) */
|
|
46
|
+
transactionId: string;
|
|
47
|
+
/** Reason for rejection */
|
|
48
|
+
reason: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface FetchOptions {
|
|
52
|
+
cache?: RequestCache;
|
|
53
|
+
revalidate?: number;
|
|
54
|
+
tags?: string[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Payment API for admin payment management
|
|
58
|
+
*
|
|
59
|
+
* Manual Payment Verification Flow:
|
|
60
|
+
* 1. Customer places order → Transaction created with status 'pending'
|
|
61
|
+
* 2. Customer pays via bKash/Nagad/bank transfer/cash
|
|
62
|
+
* 3. Admin verifies payment via verifyPayment() endpoint
|
|
63
|
+
* 4. Backend updates transaction to 'verified'
|
|
64
|
+
* 5. Order status auto-updates to 'confirmed', payment status to 'verified'
|
|
65
|
+
*
|
|
66
|
+
* Endpoints:
|
|
67
|
+
* - POST /webhooks/payments/manual/verify - Verify pending payment (superadmin)
|
|
68
|
+
* - POST /webhooks/payments/manual/reject - Reject pending payment (superadmin)
|
|
69
|
+
*/
|
|
70
|
+
declare class PaymentApi {
|
|
71
|
+
private baseUrl;
|
|
72
|
+
/**
|
|
73
|
+
* Verify a manual payment (Admin/Superadmin only)
|
|
74
|
+
* POST /webhooks/payments/manual/verify
|
|
75
|
+
*
|
|
76
|
+
* Use this when admin confirms a customer's manual payment
|
|
77
|
+
* (bKash, Nagad, bank transfer, cash, etc.)
|
|
78
|
+
*
|
|
79
|
+
* After verification:
|
|
80
|
+
* - Transaction status → 'verified'
|
|
81
|
+
* - Order payment status → 'verified'
|
|
82
|
+
* - Order status → 'confirmed' (if was 'pending')
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* const result = await paymentApi.verifyPayment({
|
|
86
|
+
* token: adminToken,
|
|
87
|
+
* data: {
|
|
88
|
+
* transactionId: '507f1f77bcf86cd799439011',
|
|
89
|
+
* notes: 'Verified bKash payment TrxID: ABC123'
|
|
90
|
+
* }
|
|
91
|
+
* });
|
|
92
|
+
*/
|
|
93
|
+
verifyPayment({ token, data, options, }: {
|
|
94
|
+
token: string;
|
|
95
|
+
data: VerifyPaymentPayload;
|
|
96
|
+
options?: FetchOptions;
|
|
97
|
+
}): Promise<ApiResponse<VerificationResult>>;
|
|
98
|
+
/**
|
|
99
|
+
* Reject a manual payment (Admin/Superadmin only)
|
|
100
|
+
* POST /webhooks/payments/manual/reject
|
|
101
|
+
*
|
|
102
|
+
* Use this when admin rejects a customer's payment claim
|
|
103
|
+
* (invalid reference, insufficient amount, fraud, etc.)
|
|
104
|
+
*
|
|
105
|
+
* After rejection:
|
|
106
|
+
* - Transaction status → 'failed'
|
|
107
|
+
* - Order payment status → 'failed'
|
|
108
|
+
* - Reason recorded in transaction
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* const result = await paymentApi.rejectPayment({
|
|
112
|
+
* token: adminToken,
|
|
113
|
+
* data: {
|
|
114
|
+
* transactionId: '507f1f77bcf86cd799439011',
|
|
115
|
+
* reason: 'Invalid bKash TrxID - payment not found'
|
|
116
|
+
* }
|
|
117
|
+
* });
|
|
118
|
+
*/
|
|
119
|
+
rejectPayment({ token, data, options, }: {
|
|
120
|
+
token: string;
|
|
121
|
+
data: RejectPaymentPayload;
|
|
122
|
+
options?: FetchOptions;
|
|
123
|
+
}): Promise<ApiResponse<RejectResult>>;
|
|
124
|
+
}
|
|
125
|
+
declare const paymentApi: PaymentApi;
|
|
126
|
+
|
|
127
|
+
export { PaymentApi as P, type RejectResult as R, type TransactionEntity as T, type VerificationResult as V, type VerifyPaymentPayload as a, type RejectPaymentPayload as b, paymentApi as p };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { a as VerifyPaymentPayload, V as VerificationResult, b as RejectPaymentPayload, R as RejectResult } from '../payment-BRboLqvU.js';
|
|
2
|
+
export { P as PaymentApi, T as TransactionEntity, p as paymentApi } from '../payment-BRboLqvU.js';
|
|
3
|
+
import '../api-factory-B_h4RKBm.js';
|
|
4
|
+
|
|
5
|
+
interface UsePaymentActionsReturn {
|
|
6
|
+
verifyPayment: (data: VerifyPaymentPayload) => Promise<VerificationResult>;
|
|
7
|
+
isVerifying: boolean;
|
|
8
|
+
rejectPayment: (data: RejectPaymentPayload) => Promise<RejectResult>;
|
|
9
|
+
isRejecting: boolean;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Payment verification actions for admin
|
|
15
|
+
*
|
|
16
|
+
* Manual Payment Verification Flow:
|
|
17
|
+
* 1. Customer places order → Transaction created with status 'pending'
|
|
18
|
+
* 2. Customer pays via bKash/Nagad/bank transfer/cash
|
|
19
|
+
* 3. Admin verifies payment via verifyPayment()
|
|
20
|
+
* 4. Backend updates transaction to 'verified'
|
|
21
|
+
* 5. Order status auto-updates to 'confirmed', payment status to 'verified'
|
|
22
|
+
*
|
|
23
|
+
* @param token - Auth token (admin/superadmin)
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* function PaymentVerifier({ transaction }) {
|
|
28
|
+
* const { verifyPayment, rejectPayment, isLoading } = usePaymentActions(token);
|
|
29
|
+
*
|
|
30
|
+
* const handleVerify = async () => {
|
|
31
|
+
* await verifyPayment({
|
|
32
|
+
* transactionId: transaction._id,
|
|
33
|
+
* notes: 'Verified bKash payment TrxID: ABC123',
|
|
34
|
+
* });
|
|
35
|
+
* };
|
|
36
|
+
*
|
|
37
|
+
* const handleReject = async () => {
|
|
38
|
+
* await rejectPayment({
|
|
39
|
+
* transactionId: transaction._id,
|
|
40
|
+
* reason: 'Invalid bKash TrxID - payment not found',
|
|
41
|
+
* });
|
|
42
|
+
* };
|
|
43
|
+
*
|
|
44
|
+
* return (
|
|
45
|
+
* <>
|
|
46
|
+
* <Button onClick={handleVerify} disabled={isLoading}>Verify</Button>
|
|
47
|
+
* <Button onClick={handleReject} disabled={isLoading}>Reject</Button>
|
|
48
|
+
* </>
|
|
49
|
+
* );
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function usePaymentActions(token: string): UsePaymentActionsReturn;
|
|
54
|
+
|
|
55
|
+
export { RejectPaymentPayload, RejectResult, type UsePaymentActionsReturn, VerificationResult, VerifyPaymentPayload, usePaymentActions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|