@cshah18/sdk 4.1.0 → 4.3.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/dist/cobuy-sdk.esm.js +39 -5
- package/dist/cobuy-sdk.esm.js.map +1 -1
- package/dist/cobuy-sdk.umd.js +39 -5
- package/dist/cobuy-sdk.umd.js.map +1 -1
- package/dist/types/core/api-client.d.ts +2 -2
- package/dist/types/core/cobuy.d.ts +19 -2
- package/dist/types/core/types.d.ts +22 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiRequestOptions, ApiResponse, ApiClientConfig, ProductRewardData, ProductPrimaryGroupData, GroupJoinResponseData, GroupInviteResponseData, AuthStrategy, ShareChannel, Contact, CheckoutValidationData } from "./types";
|
|
1
|
+
import { ApiRequestOptions, ApiResponse, ApiClientConfig, ProductRewardData, ProductPrimaryGroupData, GroupJoinResponseData, GroupInviteResponseData, AuthStrategy, ShareChannel, Contact, CheckoutValidationData, CheckoutConfirmData } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* HTTP client for communicating with CoBuy API
|
|
4
4
|
*
|
|
@@ -158,5 +158,5 @@ export declare class ApiClient {
|
|
|
158
158
|
* @param checkoutRef - The checkout reference ID from the prepare step
|
|
159
159
|
* @returns Promise with success status
|
|
160
160
|
*/
|
|
161
|
-
confirmCheckout(groupId: string, checkoutRef: string): Promise<ApiResponse<void>>;
|
|
161
|
+
confirmCheckout(groupId: string, checkoutRef: string, data?: CheckoutConfirmData): Promise<ApiResponse<void>>;
|
|
162
162
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoBuySDK, CoBuyInitOptions, RenderWidgetOptions, ModalOptions, Contact, CheckoutValidationData } from "./types";
|
|
1
|
+
import { CoBuySDK, CoBuyInitOptions, RenderWidgetOptions, ModalOptions, Contact, CheckoutValidationData, CheckoutConfirmData } from "./types";
|
|
2
2
|
import { ApiClient } from "./api-client";
|
|
3
3
|
import { AnalyticsClient } from "./analytics";
|
|
4
4
|
import { SocketManager } from "./socket";
|
|
@@ -119,14 +119,31 @@ export declare class CoBuy implements CoBuySDK {
|
|
|
119
119
|
*
|
|
120
120
|
* @param groupId - The group ID to confirm checkout for
|
|
121
121
|
* @param checkoutRef - The checkout reference ID from the prepare step
|
|
122
|
+
/**
|
|
123
|
+
* Confirm checkout for a group
|
|
124
|
+
* Should be called after validateCheckout to complete the checkout process.
|
|
125
|
+
*
|
|
126
|
+
* @param groupId The group ID to confirm checkout for
|
|
127
|
+
* @param checkoutRef The checkout reference from the prepare step
|
|
128
|
+
* @param data Optional order details (order_id, order_total, discount_applied, currency, payment_method, metadata)
|
|
122
129
|
*
|
|
123
130
|
* @example
|
|
124
131
|
* ```typescript
|
|
125
132
|
* // Confirm checkout for a group
|
|
126
133
|
* await CoBuy.confirmCheckout('fae238ae-7468-47e9-9eec-b6d52fe3b012', 'chk_9a6d8750-ed60-4795-a207-2abe955e8509');
|
|
134
|
+
*
|
|
135
|
+
* // Confirm checkout with order details
|
|
136
|
+
* await CoBuy.confirmCheckout('fae238ae-7468-47e9-9eec-b6d52fe3b012', 'chk_9a6d8750-ed60-4795-a207-2abe955e8509', {
|
|
137
|
+
* order_id: 'ORDER-1001',
|
|
138
|
+
* order_total: 100.00,
|
|
139
|
+
* discount_applied: 20.00,
|
|
140
|
+
* currency: 'USD',
|
|
141
|
+
* payment_method: 'card',
|
|
142
|
+
* metadata: { coupon_code: 'WELCOME20', customer_id: 'cust_123' }
|
|
143
|
+
* });
|
|
127
144
|
* ```
|
|
128
145
|
*/
|
|
129
|
-
confirmCheckout(groupId: string, checkoutRef: string): Promise<void>;
|
|
146
|
+
confirmCheckout(groupId: string, checkoutRef: string, data?: CheckoutConfirmData): Promise<void>;
|
|
130
147
|
/**
|
|
131
148
|
* Get the initialized API client instance
|
|
132
149
|
*/
|
|
@@ -161,6 +161,26 @@ export interface CheckoutValidationData {
|
|
|
161
161
|
reward?: CheckoutValidationReward;
|
|
162
162
|
message?: string;
|
|
163
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Optional metadata for checkout confirmation
|
|
166
|
+
*/
|
|
167
|
+
export interface CheckoutConfirmMetadata {
|
|
168
|
+
coupon_code?: string;
|
|
169
|
+
customer_id?: string;
|
|
170
|
+
note?: string;
|
|
171
|
+
[key: string]: string | number | boolean | undefined;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Optional order details for checkout confirmation
|
|
175
|
+
*/
|
|
176
|
+
export interface CheckoutConfirmData {
|
|
177
|
+
order_id?: string;
|
|
178
|
+
order_total?: number;
|
|
179
|
+
discount_applied?: number;
|
|
180
|
+
currency?: string;
|
|
181
|
+
payment_method?: "cod" | "card" | string;
|
|
182
|
+
metadata?: CheckoutConfirmMetadata;
|
|
183
|
+
}
|
|
164
184
|
/**
|
|
165
185
|
* Offline redemption information for fulfilled groups
|
|
166
186
|
*/
|
|
@@ -581,8 +601,9 @@ export interface CoBuySDK {
|
|
|
581
601
|
* Finalizes the checkout and confirms the order
|
|
582
602
|
* @param _groupId The group ID to confirm checkout for
|
|
583
603
|
* @param _checkoutRef The checkout reference ID from the prepare step
|
|
604
|
+
* @param _data (optional) Additional order details (order_id, order_total, discount_applied, currency, payment_method, metadata)
|
|
584
605
|
*/
|
|
585
|
-
confirmCheckout(_groupId: string, _checkoutRef: string): Promise<void>;
|
|
606
|
+
confirmCheckout(_groupId: string, _checkoutRef: string, _data?: CheckoutConfirmData): Promise<void>;
|
|
586
607
|
/**
|
|
587
608
|
* Retrieve stored checkout reference for a product in this session
|
|
588
609
|
* Returns both the storage key and value; key/value null if not found or storage unavailable
|