recur-tw 0.9.5 → 0.9.7

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/index.cjs CHANGED
@@ -429,11 +429,14 @@ var init_skeleton_loader = __esm({
429
429
  <div class="skeleton-label"></div>
430
430
  <div class="skeleton-input"></div>
431
431
  </div>
432
- <div class="skeleton-field">
433
- <div class="skeleton-label"></div>
434
- <div class="skeleton-row">
435
- <div class="skeleton-input-half"></div>
436
- <div class="skeleton-input-half"></div>
432
+ <div class="skeleton-row">
433
+ <div class="skeleton-field">
434
+ <div class="skeleton-label"></div>
435
+ <div class="skeleton-input"></div>
436
+ </div>
437
+ <div class="skeleton-field">
438
+ <div class="skeleton-label"></div>
439
+ <div class="skeleton-input"></div>
437
440
  </div>
438
441
  </div>
439
442
  <div class="skeleton-button"></div>
@@ -472,6 +475,7 @@ var init_skeleton_loader = __esm({
472
475
  <style>
473
476
  :host {
474
477
  display: block;
478
+ container-type: inline-size; /* Enable container queries */
475
479
  }
476
480
 
477
481
  @keyframes recur-sdk-pulse {
@@ -507,8 +511,8 @@ var init_skeleton_loader = __esm({
507
511
 
508
512
  .skeleton-row {
509
513
  display: grid;
510
- grid-template-columns: 1fr 1fr;
511
- gap: 12px;
514
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
515
+ column-gap: 16px;
512
516
  }
513
517
 
514
518
  .skeleton-input-half {
@@ -751,9 +755,7 @@ var init_payment_form_skeleton = __esm({
751
755
  }
752
756
 
753
757
  .info-row {
754
- display: flex;
755
- align-items: center;
756
- margin-bottom: 6px;
758
+ margin-bottom: 12px;
757
759
  }
758
760
 
759
761
  .info-row:last-child {
@@ -761,9 +763,11 @@ var init_payment_form_skeleton = __esm({
761
763
  }
762
764
 
763
765
  .info-label {
764
- font-size: 13px;
766
+ display: block;
767
+ font-size: 12px;
768
+ line-height: 16px;
765
769
  color: #718096;
766
- min-width: 80px;
770
+ margin-bottom: 2px;
767
771
  }
768
772
 
769
773
  .skeleton-info-value {
@@ -788,8 +792,8 @@ var init_payment_form_skeleton = __esm({
788
792
 
789
793
  .card-row {
790
794
  display: grid;
791
- grid-template-columns: 1fr 1fr;
792
- gap: 12px;
795
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
796
+ column-gap: 16px;
793
797
  }
794
798
 
795
799
  /* Submit Button - matches .recur-submit-button: padding 14px*2 + font 16px * line-height ~1.5 */
@@ -847,14 +851,14 @@ var init_payment_form_skeleton = __esm({
847
851
 
848
852
  <!-- Customer Info Section (matches createCustomerInfoSection read-only display) -->
849
853
  <div class="form-section">
850
- <h3 class="section-title">\u5BA2\u6236\u8CC7\u8A0A</h3>
854
+ <h3 class="section-title">\u806F\u7D61\u8CC7\u8A0A</h3>
851
855
  <div class="customer-info-display">
852
856
  <div class="info-row">
853
- <span class="info-label">\u5BA2\u6236\u59D3\u540D\uFF1A</span>
857
+ <span class="info-label">\u59D3\u540D</span>
854
858
  <div class="skeleton skeleton-info-value"></div>
855
859
  </div>
856
860
  <div class="info-row">
857
- <span class="info-label">\u96FB\u5B50\u90F5\u4EF6\uFF1A</span>
861
+ <span class="info-label">\u96FB\u5B50\u90F5\u4EF6</span>
858
862
  <div class="skeleton skeleton-info-value" style="width: 160px;"></div>
859
863
  </div>
860
864
  </div>
@@ -1207,7 +1211,7 @@ var init_payment_form = __esm({
1207
1211
  }
1208
1212
  // 監聽 attribute 變化
1209
1213
  static get observedAttributes() {
1210
- return ["custom-styles", "customer-name", "customer-email", "plan-name", "amount", "billing-period"];
1214
+ return ["custom-styles", "customer-name", "customer-email", "product-name", "amount", "interval"];
1211
1215
  }
1212
1216
  attributeChangedCallback(name, oldValue, newValue) {
1213
1217
  if (name === "custom-styles" && oldValue !== newValue) {
@@ -1234,6 +1238,8 @@ var init_payment_form = __esm({
1234
1238
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
1235
1239
  /* Prevent double-tap zoom on iOS */
1236
1240
  touch-action: manipulation;
1241
+ /* Enable container queries for responsive layout */
1242
+ container-type: inline-size;
1237
1243
  }
1238
1244
 
1239
1245
  .form-header {
@@ -1299,7 +1305,7 @@ var init_payment_form = __esm({
1299
1305
  <slot name="order-summary"></slot>
1300
1306
 
1301
1307
  <div class="form-section">
1302
- <h3 class="section-title">\u5BA2\u6236\u8CC7\u8A0A</h3>
1308
+ <h3 class="section-title">\u806F\u7D61\u8CC7\u8A0A</h3>
1303
1309
  <!-- Slot for customer info fields (Light DOM) -->
1304
1310
  <slot name="customer-info"></slot>
1305
1311
  </div>
@@ -1375,19 +1381,19 @@ var init_payment_form = __esm({
1375
1381
  createOrderSummarySection() {
1376
1382
  const section = document.createElement("div");
1377
1383
  section.className = "order-summary-section";
1378
- const planName = this.getAttribute("plan-name");
1384
+ const productName = this.getAttribute("product-name");
1379
1385
  const amount = this.getAttribute("amount");
1380
- const billingPeriod = this.getAttribute("billing-period");
1381
- if (!planName || !amount) {
1386
+ const interval = this.getAttribute("interval");
1387
+ if (!productName || !amount) {
1382
1388
  return section;
1383
1389
  }
1384
- const billingPeriodMap = {
1385
- "MONTHLY": "\u6708",
1386
- "QUARTERLY": "\u5B63",
1387
- "YEARLY": "\u5E74",
1388
- "WEEKLY": "\u9031"
1390
+ const intervalMap = {
1391
+ "day": "\u65E5",
1392
+ "week": "\u9031",
1393
+ "month": "\u6708",
1394
+ "year": "\u5E74"
1389
1395
  };
1390
- const periodText = billingPeriod ? billingPeriodMap[billingPeriod] || billingPeriod : "";
1396
+ const periodText = interval ? intervalMap[interval] || interval : "";
1391
1397
  section.innerHTML = `
1392
1398
  <style>
1393
1399
  .order-summary-section {
@@ -1441,7 +1447,7 @@ var init_payment_form = __esm({
1441
1447
  <h3 class="order-summary-title">\u8A02\u55AE\u6458\u8981</h3>
1442
1448
  <div class="order-summary-item">
1443
1449
  <span class="order-summary-label">\u8A02\u95B1\u65B9\u6848</span>
1444
- <span class="order-summary-value">${planName}</span>
1450
+ <span class="order-summary-value">${productName}</span>
1445
1451
  </div>
1446
1452
  ${periodText ? `
1447
1453
  <div class="order-summary-item">
@@ -1473,9 +1479,7 @@ var init_payment_form = __esm({
1473
1479
  }
1474
1480
 
1475
1481
  .recur-info-row {
1476
- display: flex;
1477
- align-items: center;
1478
- margin-bottom: 6px;
1482
+ margin-bottom: 12px;
1479
1483
  }
1480
1484
 
1481
1485
  .recur-info-row:last-child {
@@ -1483,28 +1487,33 @@ var init_payment_form = __esm({
1483
1487
  }
1484
1488
 
1485
1489
  .recur-info-label {
1486
- font-size: 13px;
1490
+ display: block;
1491
+ font-size: 12px;
1492
+ line-height: 16px;
1487
1493
  color: #718096;
1488
- min-width: 80px;
1494
+ margin-bottom: 2px;
1489
1495
  }
1490
1496
 
1491
1497
  .recur-info-value {
1498
+ display: block;
1492
1499
  font-size: 14px;
1493
1500
  line-height: 20px;
1501
+ min-height: 20px;
1494
1502
  color: #2d3748;
1495
1503
  font-weight: 500;
1504
+ word-break: break-all;
1496
1505
  }
1497
1506
  </style>
1498
1507
 
1499
1508
  <div class="recur-info-display">
1500
1509
  ${customerName ? `
1501
1510
  <div class="recur-info-row">
1502
- <span class="recur-info-label">\u5BA2\u6236\u59D3\u540D\uFF1A</span>
1511
+ <span class="recur-info-label">\u59D3\u540D</span>
1503
1512
  <span class="recur-info-value">${customerName}</span>
1504
1513
  </div>
1505
1514
  ` : ""}
1506
1515
  <div class="recur-info-row">
1507
- <span class="recur-info-label">\u96FB\u5B50\u90F5\u4EF6\uFF1A</span>
1516
+ <span class="recur-info-label">\u96FB\u5B50\u90F5\u4EF6</span>
1508
1517
  <span class="recur-info-value">${customerEmail}</span>
1509
1518
  </div>
1510
1519
  </div>
@@ -1602,8 +1611,8 @@ var init_payment_form = __esm({
1602
1611
 
1603
1612
  .recur-card-row {
1604
1613
  display: grid;
1605
- grid-template-columns: 1fr 1fr;
1606
- gap: 12px;
1614
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
1615
+ column-gap: 16px;
1607
1616
  max-width: 100%;
1608
1617
  box-sizing: border-box;
1609
1618
  }
@@ -2625,7 +2634,7 @@ function toCamelCase(obj) {
2625
2634
 
2626
2635
  // package.json
2627
2636
  var package_default = {
2628
- version: "0.9.5"};
2637
+ version: "0.9.7"};
2629
2638
  var SDK_VERSION = package_default.version;
2630
2639
  var SDK_TYPE = "react";
2631
2640
  var RecurContext = React.createContext(null);
@@ -2649,7 +2658,72 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2649
2658
  }, []);
2650
2659
  const checkout = React.useCallback(
2651
2660
  async (options) => {
2652
- let modalOverlay = null;
2661
+ let dialog = null;
2662
+ let savedScrollY = 0;
2663
+ let savedBodyStyles = null;
2664
+ const lockBodyScroll = () => {
2665
+ savedScrollY = window.scrollY;
2666
+ savedBodyStyles = {
2667
+ overflow: document.body.style.overflow,
2668
+ position: document.body.style.position,
2669
+ top: document.body.style.top,
2670
+ width: document.body.style.width,
2671
+ height: document.body.style.height
2672
+ };
2673
+ document.body.style.overflow = "hidden";
2674
+ document.body.style.position = "fixed";
2675
+ document.body.style.top = `-${savedScrollY}px`;
2676
+ document.body.style.width = "100%";
2677
+ document.body.style.height = "100%";
2678
+ };
2679
+ const unlockBodyScroll = () => {
2680
+ if (savedBodyStyles) {
2681
+ document.body.style.overflow = savedBodyStyles.overflow;
2682
+ document.body.style.position = savedBodyStyles.position;
2683
+ document.body.style.top = savedBodyStyles.top;
2684
+ document.body.style.width = savedBodyStyles.width;
2685
+ document.body.style.height = savedBodyStyles.height;
2686
+ window.scrollTo(0, savedScrollY);
2687
+ savedBodyStyles = null;
2688
+ }
2689
+ };
2690
+ const closeDialog = () => {
2691
+ if (dialog) {
2692
+ dialog.close();
2693
+ dialog.remove();
2694
+ unlockBodyScroll();
2695
+ }
2696
+ };
2697
+ const injectDialogStyles = () => {
2698
+ if (document.getElementById("recur-dialog-styles")) return;
2699
+ const styleEl = document.createElement("style");
2700
+ styleEl.id = "recur-dialog-styles";
2701
+ styleEl.textContent = `
2702
+ .recur-sdk__dialog {
2703
+ border: none;
2704
+ border-radius: 12px;
2705
+ padding: 0;
2706
+ max-width: 500px;
2707
+ width: 90%;
2708
+ max-height: 90vh;
2709
+ overflow: visible;
2710
+ background: transparent;
2711
+ /* Center the dialog */
2712
+ margin: auto;
2713
+ position: fixed;
2714
+ inset: 0;
2715
+ height: fit-content;
2716
+ }
2717
+ .recur-sdk__dialog::backdrop {
2718
+ background: rgba(0, 0, 0, 0.5);
2719
+ }
2720
+ .recur-sdk__dialog[open] {
2721
+ display: flex;
2722
+ flex-direction: column;
2723
+ }
2724
+ `;
2725
+ document.head.appendChild(styleEl);
2726
+ };
2653
2727
  try {
2654
2728
  console.log("[Recur SDK] Starting checkout flow...", {
2655
2729
  planId: options.planId,
@@ -2674,31 +2748,20 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2674
2748
  "X-Recur-SDK-Version": SDK_VERSION,
2675
2749
  "X-Recur-Source": typeof window !== "undefined" ? window.location.origin : "server"
2676
2750
  };
2677
- let modalContent = null;
2751
+ let dialogContent = null;
2678
2752
  let loadingContainer = null;
2679
2753
  let embeddedContainer = null;
2680
2754
  if (config.checkoutMode === "modal") {
2681
- console.log("[Recur SDK] Mode is modal, creating modal with loading state...");
2682
- modalOverlay = document.createElement("div");
2683
- modalOverlay.id = "recur-modal-overlay";
2684
- modalOverlay.className = "recur-sdk__modal-overlay";
2685
- modalOverlay.style.cssText = `
2686
- position: fixed;
2687
- top: 0;
2688
- left: 0;
2689
- width: 100%;
2690
- height: 100%;
2691
- background: rgba(0, 0, 0, 0.5);
2692
- display: flex;
2693
- align-items: center;
2694
- justify-content: center;
2695
- z-index: 9999;
2696
- `;
2697
- modalContent = document.createElement("div");
2698
- modalContent.className = "recur-sdk__modal-content";
2699
- modalContent.style.cssText = `
2755
+ console.log("[Recur SDK] Mode is modal, creating dialog with loading state...");
2756
+ injectDialogStyles();
2757
+ dialog = document.createElement("dialog");
2758
+ dialog.id = "recur-sdk-dialog";
2759
+ dialog.className = "recur-sdk__dialog";
2760
+ dialogContent = document.createElement("div");
2761
+ dialogContent.className = "recur-sdk__dialog-content";
2762
+ dialogContent.style.cssText = `
2700
2763
  max-width: 500px;
2701
- width: 90%;
2764
+ width: 100%;
2702
2765
  max-height: 90vh;
2703
2766
  overflow-y: auto;
2704
2767
  overflow-x: hidden;
@@ -2736,20 +2799,37 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2736
2799
  closeButton.style.background = "rgba(0, 0, 0, 0.05)";
2737
2800
  };
2738
2801
  closeButton.onclick = () => {
2739
- modalOverlay?.remove();
2802
+ closeDialog();
2740
2803
  setIsCheckingOut(false);
2741
2804
  options.onPaymentCancel?.();
2742
2805
  };
2743
2806
  loadingContainer = document.createElement("div");
2744
- loadingContainer.id = "recur-modal-loading";
2807
+ loadingContainer.id = "recur-dialog-loading";
2745
2808
  loadingContainer.className = "recur-sdk__loading-container";
2746
2809
  const skeleton = document.createElement("recur-payment-form-skeleton");
2747
2810
  loadingContainer.appendChild(skeleton);
2748
- modalContent.appendChild(closeButton);
2749
- modalContent.appendChild(loadingContainer);
2750
- modalOverlay.appendChild(modalContent);
2751
- document.body.appendChild(modalOverlay);
2752
- console.log("[Recur SDK] Modal created with loading state");
2811
+ dialogContent.appendChild(closeButton);
2812
+ dialogContent.appendChild(loadingContainer);
2813
+ dialog.appendChild(dialogContent);
2814
+ document.body.appendChild(dialog);
2815
+ dialog.showModal();
2816
+ lockBodyScroll();
2817
+ dialog.addEventListener("click", (e) => {
2818
+ const rect = dialog.getBoundingClientRect();
2819
+ const isInDialog = e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
2820
+ if (!isInDialog) {
2821
+ closeDialog();
2822
+ setIsCheckingOut(false);
2823
+ options.onPaymentCancel?.();
2824
+ }
2825
+ });
2826
+ dialog.addEventListener("cancel", (e) => {
2827
+ e.preventDefault();
2828
+ closeDialog();
2829
+ setIsCheckingOut(false);
2830
+ options.onPaymentCancel?.();
2831
+ });
2832
+ console.log("[Recur SDK] Dialog created with loading state");
2753
2833
  } else if (config.checkoutMode === "embedded") {
2754
2834
  console.log("[Recur SDK] Mode is embedded, checking for container...");
2755
2835
  if (!config.containerElementId) {
@@ -2836,16 +2916,16 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2836
2916
  console.log("[Recur SDK] Initial containerElementId from config:", config.containerElementId);
2837
2917
  let containerElementId = config.containerElementId;
2838
2918
  if (config.checkoutMode === "modal") {
2839
- console.log("[Recur SDK] Mode is modal, updating modal with payment form...");
2840
- if (!loadingContainer || !modalContent) {
2841
- throw new Error("Modal components not initialized");
2919
+ console.log("[Recur SDK] Mode is modal, updating dialog with payment form...");
2920
+ if (!loadingContainer || !dialogContent) {
2921
+ throw new Error("Dialog components not initialized");
2842
2922
  }
2843
2923
  loadingContainer.remove();
2844
2924
  const formContainer = document.createElement("div");
2845
- containerElementId = "recur-modal-payment-container";
2925
+ containerElementId = "recur-dialog-payment-container";
2846
2926
  formContainer.id = containerElementId;
2847
- modalContent.appendChild(formContainer);
2848
- console.log("[Recur SDK] Modal updated with container ID:", containerElementId);
2927
+ dialogContent.appendChild(formContainer);
2928
+ console.log("[Recur SDK] Dialog updated with container ID:", containerElementId);
2849
2929
  } else if (config.checkoutMode === "embedded") {
2850
2930
  console.log("[Recur SDK] Mode is embedded, preparing container...");
2851
2931
  if (!containerElementId) {
@@ -2885,14 +2965,14 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2885
2965
  if (options.customerEmail) {
2886
2966
  paymentForm.setAttribute("customer-email", options.customerEmail);
2887
2967
  }
2888
- if (checkoutResult.plan?.name) {
2889
- paymentForm.setAttribute("plan-name", checkoutResult.plan.name);
2968
+ if (checkoutResult.product?.name) {
2969
+ paymentForm.setAttribute("product-name", checkoutResult.product.name);
2890
2970
  }
2891
2971
  if (checkoutResult.checkout?.amount) {
2892
2972
  paymentForm.setAttribute("amount", checkoutResult.checkout.amount.toString());
2893
2973
  }
2894
- if (checkoutResult.plan?.billingPeriod) {
2895
- paymentForm.setAttribute("billing-period", checkoutResult.plan.billingPeriod);
2974
+ if (checkoutResult.product?.interval) {
2975
+ paymentForm.setAttribute("interval", checkoutResult.product.interval);
2896
2976
  }
2897
2977
  const customStyles = `
2898
2978
  /* PAYUNi SDK focus \u6A23\u5F0F - shadcn \u98A8\u683C */
@@ -3044,7 +3124,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3044
3124
  options.onPaymentComplete({
3045
3125
  id: paymentResult.subscription.id,
3046
3126
  status: "ACTIVE",
3047
- planId: checkoutResult.checkout.productId,
3127
+ productId: checkoutResult.checkout.productId,
3048
3128
  amount: checkoutResult.checkout.amount,
3049
3129
  billingPeriod: paymentResult.subscription.billingPeriod,
3050
3130
  currentPeriodStart: paymentResult.subscription.currentPeriodStart,
@@ -3054,7 +3134,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3054
3134
  options.onPaymentComplete({
3055
3135
  id: statusData.checkout?.orderId || checkoutId,
3056
3136
  status: "SUCCEEDED",
3057
- planId: checkoutResult.checkout.productId,
3137
+ productId: checkoutResult.checkout.productId,
3058
3138
  amount: checkoutResult.checkout.amount,
3059
3139
  billingPeriod: checkoutResult.checkout.productType,
3060
3140
  currentPeriodStart: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3062,9 +3142,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3062
3142
  });
3063
3143
  }
3064
3144
  }
3065
- if (modalOverlay) {
3066
- modalOverlay.remove();
3067
- }
3145
+ closeDialog();
3068
3146
  setIsCheckingOut(false);
3069
3147
  return;
3070
3148
  }
@@ -3106,7 +3184,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3106
3184
  options.onPaymentComplete({
3107
3185
  id: paymentResult.subscription.id,
3108
3186
  status: "ACTIVE",
3109
- planId: checkoutResult.checkout.productId,
3187
+ productId: checkoutResult.checkout.productId,
3110
3188
  amount: checkoutResult.checkout.amount,
3111
3189
  billingPeriod: paymentResult.subscription.billingPeriod,
3112
3190
  currentPeriodStart: paymentResult.subscription.currentPeriodStart,
@@ -3116,7 +3194,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3116
3194
  options.onPaymentComplete({
3117
3195
  id: finalOrderId || checkoutId,
3118
3196
  status: "SUCCEEDED",
3119
- planId: checkoutResult.checkout.productId,
3197
+ productId: checkoutResult.checkout.productId,
3120
3198
  amount: checkoutResult.checkout.amount,
3121
3199
  billingPeriod: checkoutResult.checkout.productType,
3122
3200
  currentPeriodStart: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3124,9 +3202,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3124
3202
  });
3125
3203
  }
3126
3204
  }
3127
- if (modalOverlay) {
3128
- modalOverlay.remove();
3129
- }
3205
+ closeDialog();
3130
3206
  setIsCheckingOut(false);
3131
3207
  }
3132
3208
  return;
@@ -3138,7 +3214,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3138
3214
  options.onPaymentComplete({
3139
3215
  id: paymentResult.subscription.id,
3140
3216
  status: paymentResult.subscription.status,
3141
- planId: checkoutResult.checkout.productId,
3217
+ productId: checkoutResult.checkout.productId,
3142
3218
  amount: checkoutResult.checkout.amount,
3143
3219
  billingPeriod: paymentResult.subscription.billingPeriod,
3144
3220
  currentPeriodStart: paymentResult.subscription.currentPeriodStart,
@@ -3150,7 +3226,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3150
3226
  options.onPaymentComplete({
3151
3227
  id: chargeId,
3152
3228
  status: chargeStatus,
3153
- planId: checkoutResult.checkout.productId,
3229
+ productId: checkoutResult.checkout.productId,
3154
3230
  amount: checkoutResult.checkout.amount,
3155
3231
  billingPeriod: checkoutResult.checkout.productType,
3156
3232
  currentPeriodStart: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3160,9 +3236,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3160
3236
  }
3161
3237
  console.log("[Recur SDK] Checkout flow completed successfully!");
3162
3238
  paymentForm.resetButton?.();
3163
- if (modalOverlay) {
3164
- modalOverlay.remove();
3165
- }
3239
+ closeDialog();
3166
3240
  setIsCheckingOut(false);
3167
3241
  } catch (error) {
3168
3242
  console.error("[Recur SDK] Error in payment flow:", error);
@@ -3181,9 +3255,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3181
3255
  console.log("[Recur SDK] Checkout flow initialized, waiting for user input...");
3182
3256
  } catch (error) {
3183
3257
  console.error("[Recur SDK] Checkout error:", error);
3184
- if (modalOverlay) {
3185
- modalOverlay.remove();
3186
- }
3258
+ closeDialog();
3187
3259
  const checkoutError = {
3188
3260
  code: "CHECKOUT_ERROR",
3189
3261
  message: error instanceof Error ? error.message : "An unknown error occurred"
package/dist/index.d.cts CHANGED
@@ -299,13 +299,13 @@ interface CheckoutResult {
299
299
  currentAttempts: number;
300
300
  };
301
301
  /**
302
- * Plan/Product information
302
+ * Product information
303
303
  */
304
- plan: {
304
+ product: {
305
305
  id: string;
306
306
  name: string;
307
307
  price: number;
308
- billingPeriod: string | null;
308
+ interval: string | null;
309
309
  description: string | null;
310
310
  };
311
311
  /**
@@ -334,7 +334,7 @@ interface CheckoutError {
334
334
  interface SubscriptionResult {
335
335
  id: string;
336
336
  status: string;
337
- planId: string;
337
+ productId: string;
338
338
  amount: number;
339
339
  billingPeriod: string;
340
340
  trialEndsAt?: string;
@@ -811,7 +811,7 @@ interface UseSubscribeResult {
811
811
  * @example
812
812
  * ```tsx
813
813
  * function SubscribePage() {
814
- * const { data: plans } = usePlans();
814
+ * const { data: products } = useProducts();
815
815
  * const { subscribe, isLoading, error } = useSubscribe({
816
816
  * onSuccess: () => {
817
817
  * console.log('Subscription created!');
@@ -823,12 +823,12 @@ interface UseSubscribeResult {
823
823
  *
824
824
  * return (
825
825
  * <div>
826
- * {plans?.map(plan => (
827
- * <PlanCard
828
- * key={plan.id}
829
- * plan={plan}
826
+ * {products?.map(product => (
827
+ * <ProductCard
828
+ * key={product.id}
829
+ * product={product}
830
830
  * onSubscribe={() => subscribe({
831
- * productId: plan.id, // or productSlug: plan.slug
831
+ * productId: product.id, // or productSlug: product.slug
832
832
  * customerEmail: 'user@example.com',
833
833
  * customerName: 'John Doe'
834
834
  * })}
package/dist/index.d.ts CHANGED
@@ -299,13 +299,13 @@ interface CheckoutResult {
299
299
  currentAttempts: number;
300
300
  };
301
301
  /**
302
- * Plan/Product information
302
+ * Product information
303
303
  */
304
- plan: {
304
+ product: {
305
305
  id: string;
306
306
  name: string;
307
307
  price: number;
308
- billingPeriod: string | null;
308
+ interval: string | null;
309
309
  description: string | null;
310
310
  };
311
311
  /**
@@ -334,7 +334,7 @@ interface CheckoutError {
334
334
  interface SubscriptionResult {
335
335
  id: string;
336
336
  status: string;
337
- planId: string;
337
+ productId: string;
338
338
  amount: number;
339
339
  billingPeriod: string;
340
340
  trialEndsAt?: string;
@@ -811,7 +811,7 @@ interface UseSubscribeResult {
811
811
  * @example
812
812
  * ```tsx
813
813
  * function SubscribePage() {
814
- * const { data: plans } = usePlans();
814
+ * const { data: products } = useProducts();
815
815
  * const { subscribe, isLoading, error } = useSubscribe({
816
816
  * onSuccess: () => {
817
817
  * console.log('Subscription created!');
@@ -823,12 +823,12 @@ interface UseSubscribeResult {
823
823
  *
824
824
  * return (
825
825
  * <div>
826
- * {plans?.map(plan => (
827
- * <PlanCard
828
- * key={plan.id}
829
- * plan={plan}
826
+ * {products?.map(product => (
827
+ * <ProductCard
828
+ * key={product.id}
829
+ * product={product}
830
830
  * onSubscribe={() => subscribe({
831
- * productId: plan.id, // or productSlug: plan.slug
831
+ * productId: product.id, // or productSlug: product.slug
832
832
  * customerEmail: 'user@example.com',
833
833
  * customerName: 'John Doe'
834
834
  * })}