@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.
@@ -2227,6 +2227,7 @@ var CoBuySDK = (function (exports) {
2227
2227
  justify-content: center;
2228
2228
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
2229
2229
  transition: all 0.2s;
2230
+ word-break: break-all;
2230
2231
  }
2231
2232
 
2232
2233
  .offline-code-row .offline-code-value {
@@ -5625,12 +5626,28 @@ var CoBuySDK = (function (exports) {
5625
5626
  * @param checkoutRef - The checkout reference ID from the prepare step
5626
5627
  * @returns Promise with success status
5627
5628
  */
5628
- async confirmCheckout(groupId, checkoutRef) {
5629
+ async confirmCheckout(groupId, checkoutRef, data) {
5629
5630
  const endpoint = buildApiUrl("", API_ENDPOINTS.GROUP_CHECKOUT_CONFIRM, { groupId });
5630
5631
  this.logger.info(`Confirming checkout for group: ${groupId}`);
5631
- const response = await this.post(endpoint, {
5632
+ const payload = {
5632
5633
  checkout_ref: checkoutRef,
5633
- });
5634
+ };
5635
+ // Add optional fields if provided
5636
+ if (data) {
5637
+ if (data.order_id)
5638
+ payload.order_id = data.order_id;
5639
+ if (data.order_total !== undefined)
5640
+ payload.order_total = data.order_total;
5641
+ if (data.discount_applied !== undefined)
5642
+ payload.discount_applied = data.discount_applied;
5643
+ if (data.currency)
5644
+ payload.currency = data.currency;
5645
+ if (data.payment_method)
5646
+ payload.payment_method = data.payment_method;
5647
+ if (data.metadata)
5648
+ payload.metadata = data.metadata;
5649
+ }
5650
+ const response = await this.post(endpoint, payload);
5634
5651
  if (response.success) {
5635
5652
  this.logger.info("Checkout confirmed successfully");
5636
5653
  return {
@@ -10534,14 +10551,31 @@ var CoBuySDK = (function (exports) {
10534
10551
  *
10535
10552
  * @param groupId - The group ID to confirm checkout for
10536
10553
  * @param checkoutRef - The checkout reference ID from the prepare step
10554
+ /**
10555
+ * Confirm checkout for a group
10556
+ * Should be called after validateCheckout to complete the checkout process.
10557
+ *
10558
+ * @param groupId The group ID to confirm checkout for
10559
+ * @param checkoutRef The checkout reference from the prepare step
10560
+ * @param data Optional order details (order_id, order_total, discount_applied, currency, payment_method, metadata)
10537
10561
  *
10538
10562
  * @example
10539
10563
  * ```typescript
10540
10564
  * // Confirm checkout for a group
10541
10565
  * await CoBuy.confirmCheckout('fae238ae-7468-47e9-9eec-b6d52fe3b012', 'chk_9a6d8750-ed60-4795-a207-2abe955e8509');
10566
+ *
10567
+ * // Confirm checkout with order details
10568
+ * await CoBuy.confirmCheckout('fae238ae-7468-47e9-9eec-b6d52fe3b012', 'chk_9a6d8750-ed60-4795-a207-2abe955e8509', {
10569
+ * order_id: 'ORDER-1001',
10570
+ * order_total: 100.00,
10571
+ * discount_applied: 20.00,
10572
+ * currency: 'USD',
10573
+ * payment_method: 'card',
10574
+ * metadata: { coupon_code: 'WELCOME20', customer_id: 'cust_123' }
10575
+ * });
10542
10576
  * ```
10543
10577
  */
10544
- async confirmCheckout(groupId, checkoutRef) {
10578
+ async confirmCheckout(groupId, checkoutRef, data) {
10545
10579
  if (!this.configManager.isInitialized()) {
10546
10580
  this.logger.warn("SDK not initialized, cannot confirm checkout");
10547
10581
  return;
@@ -10551,7 +10585,7 @@ var CoBuySDK = (function (exports) {
10551
10585
  return;
10552
10586
  }
10553
10587
  try {
10554
- const response = await this.apiClient.confirmCheckout(groupId, checkoutRef);
10588
+ const response = await this.apiClient.confirmCheckout(groupId, checkoutRef, data);
10555
10589
  if (response.success) {
10556
10590
  this.logger.info(`Checkout confirmed successfully for group: ${groupId}`);
10557
10591
  // Directly refresh widgets. If we can infer productId, refresh only matching widgets.