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