recur-tw 0.9.4 → 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) {
@@ -1232,6 +1236,10 @@ var init_payment_form = __esm({
1232
1236
  background: white;
1233
1237
  border-radius: 12px;
1234
1238
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
1239
+ /* Prevent double-tap zoom on iOS */
1240
+ touch-action: manipulation;
1241
+ /* Enable container queries for responsive layout */
1242
+ container-type: inline-size;
1235
1243
  }
1236
1244
 
1237
1245
  .form-header {
@@ -1297,7 +1305,7 @@ var init_payment_form = __esm({
1297
1305
  <slot name="order-summary"></slot>
1298
1306
 
1299
1307
  <div class="form-section">
1300
- <h3 class="section-title">\u5BA2\u6236\u8CC7\u8A0A</h3>
1308
+ <h3 class="section-title">\u806F\u7D61\u8CC7\u8A0A</h3>
1301
1309
  <!-- Slot for customer info fields (Light DOM) -->
1302
1310
  <slot name="customer-info"></slot>
1303
1311
  </div>
@@ -1373,19 +1381,19 @@ var init_payment_form = __esm({
1373
1381
  createOrderSummarySection() {
1374
1382
  const section = document.createElement("div");
1375
1383
  section.className = "order-summary-section";
1376
- const planName = this.getAttribute("plan-name");
1384
+ const productName = this.getAttribute("product-name");
1377
1385
  const amount = this.getAttribute("amount");
1378
- const billingPeriod = this.getAttribute("billing-period");
1379
- if (!planName || !amount) {
1386
+ const interval = this.getAttribute("interval");
1387
+ if (!productName || !amount) {
1380
1388
  return section;
1381
1389
  }
1382
- const billingPeriodMap = {
1383
- "MONTHLY": "\u6708",
1384
- "QUARTERLY": "\u5B63",
1385
- "YEARLY": "\u5E74",
1386
- "WEEKLY": "\u9031"
1390
+ const intervalMap = {
1391
+ "day": "\u65E5",
1392
+ "week": "\u9031",
1393
+ "month": "\u6708",
1394
+ "year": "\u5E74"
1387
1395
  };
1388
- const periodText = billingPeriod ? billingPeriodMap[billingPeriod] || billingPeriod : "";
1396
+ const periodText = interval ? intervalMap[interval] || interval : "";
1389
1397
  section.innerHTML = `
1390
1398
  <style>
1391
1399
  .order-summary-section {
@@ -1439,7 +1447,7 @@ var init_payment_form = __esm({
1439
1447
  <h3 class="order-summary-title">\u8A02\u55AE\u6458\u8981</h3>
1440
1448
  <div class="order-summary-item">
1441
1449
  <span class="order-summary-label">\u8A02\u95B1\u65B9\u6848</span>
1442
- <span class="order-summary-value">${planName}</span>
1450
+ <span class="order-summary-value">${productName}</span>
1443
1451
  </div>
1444
1452
  ${periodText ? `
1445
1453
  <div class="order-summary-item">
@@ -1471,9 +1479,7 @@ var init_payment_form = __esm({
1471
1479
  }
1472
1480
 
1473
1481
  .recur-info-row {
1474
- display: flex;
1475
- align-items: center;
1476
- margin-bottom: 6px;
1482
+ margin-bottom: 12px;
1477
1483
  }
1478
1484
 
1479
1485
  .recur-info-row:last-child {
@@ -1481,28 +1487,33 @@ var init_payment_form = __esm({
1481
1487
  }
1482
1488
 
1483
1489
  .recur-info-label {
1484
- font-size: 13px;
1490
+ display: block;
1491
+ font-size: 12px;
1492
+ line-height: 16px;
1485
1493
  color: #718096;
1486
- min-width: 80px;
1494
+ margin-bottom: 2px;
1487
1495
  }
1488
1496
 
1489
1497
  .recur-info-value {
1498
+ display: block;
1490
1499
  font-size: 14px;
1491
1500
  line-height: 20px;
1501
+ min-height: 20px;
1492
1502
  color: #2d3748;
1493
1503
  font-weight: 500;
1504
+ word-break: break-all;
1494
1505
  }
1495
1506
  </style>
1496
1507
 
1497
1508
  <div class="recur-info-display">
1498
1509
  ${customerName ? `
1499
1510
  <div class="recur-info-row">
1500
- <span class="recur-info-label">\u5BA2\u6236\u59D3\u540D\uFF1A</span>
1511
+ <span class="recur-info-label">\u59D3\u540D</span>
1501
1512
  <span class="recur-info-value">${customerName}</span>
1502
1513
  </div>
1503
1514
  ` : ""}
1504
1515
  <div class="recur-info-row">
1505
- <span class="recur-info-label">\u96FB\u5B50\u90F5\u4EF6\uFF1A</span>
1516
+ <span class="recur-info-label">\u96FB\u5B50\u90F5\u4EF6</span>
1506
1517
  <span class="recur-info-value">${customerEmail}</span>
1507
1518
  </div>
1508
1519
  </div>
@@ -1527,7 +1538,7 @@ var init_payment_form = __esm({
1527
1538
  .recur-form-input {
1528
1539
  width: 100%;
1529
1540
  padding: 10px 12px;
1530
- font-size: 14px;
1541
+ font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
1531
1542
  border: 1px solid #d1d5db;
1532
1543
  border-radius: 6px;
1533
1544
  transition: border-color 0.2s;
@@ -1594,12 +1605,14 @@ var init_payment_form = __esm({
1594
1605
  width: 100%;
1595
1606
  max-width: 100%;
1596
1607
  box-sizing: border-box;
1608
+ /* Help reduce iOS zoom issues */
1609
+ touch-action: manipulation;
1597
1610
  }
1598
1611
 
1599
1612
  .recur-card-row {
1600
1613
  display: grid;
1601
- grid-template-columns: 1fr 1fr;
1602
- gap: 12px;
1614
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
1615
+ column-gap: 16px;
1603
1616
  max-width: 100%;
1604
1617
  box-sizing: border-box;
1605
1618
  }
@@ -1607,6 +1620,8 @@ var init_payment_form = __esm({
1607
1620
  /* Container needs relative positioning for skeleton overlay */
1608
1621
  .recur-card-field-container {
1609
1622
  position: relative;
1623
+ /* Help reduce iOS zoom issues */
1624
+ touch-action: manipulation;
1610
1625
  }
1611
1626
 
1612
1627
  /* Loading skeleton for card fields - shown until PAYUNi iframe loads */
@@ -2619,7 +2634,7 @@ function toCamelCase(obj) {
2619
2634
 
2620
2635
  // package.json
2621
2636
  var package_default = {
2622
- version: "0.9.4"};
2637
+ version: "0.9.7"};
2623
2638
  var SDK_VERSION = package_default.version;
2624
2639
  var SDK_TYPE = "react";
2625
2640
  var RecurContext = React.createContext(null);
@@ -2643,7 +2658,72 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2643
2658
  }, []);
2644
2659
  const checkout = React.useCallback(
2645
2660
  async (options) => {
2646
- 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
+ };
2647
2727
  try {
2648
2728
  console.log("[Recur SDK] Starting checkout flow...", {
2649
2729
  planId: options.planId,
@@ -2668,31 +2748,20 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2668
2748
  "X-Recur-SDK-Version": SDK_VERSION,
2669
2749
  "X-Recur-Source": typeof window !== "undefined" ? window.location.origin : "server"
2670
2750
  };
2671
- let modalContent = null;
2751
+ let dialogContent = null;
2672
2752
  let loadingContainer = null;
2673
2753
  let embeddedContainer = null;
2674
2754
  if (config.checkoutMode === "modal") {
2675
- console.log("[Recur SDK] Mode is modal, creating modal with loading state...");
2676
- modalOverlay = document.createElement("div");
2677
- modalOverlay.id = "recur-modal-overlay";
2678
- modalOverlay.className = "recur-sdk__modal-overlay";
2679
- modalOverlay.style.cssText = `
2680
- position: fixed;
2681
- top: 0;
2682
- left: 0;
2683
- width: 100%;
2684
- height: 100%;
2685
- background: rgba(0, 0, 0, 0.5);
2686
- display: flex;
2687
- align-items: center;
2688
- justify-content: center;
2689
- z-index: 9999;
2690
- `;
2691
- modalContent = document.createElement("div");
2692
- modalContent.className = "recur-sdk__modal-content";
2693
- 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 = `
2694
2763
  max-width: 500px;
2695
- width: 90%;
2764
+ width: 100%;
2696
2765
  max-height: 90vh;
2697
2766
  overflow-y: auto;
2698
2767
  overflow-x: hidden;
@@ -2730,20 +2799,37 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2730
2799
  closeButton.style.background = "rgba(0, 0, 0, 0.05)";
2731
2800
  };
2732
2801
  closeButton.onclick = () => {
2733
- modalOverlay?.remove();
2802
+ closeDialog();
2734
2803
  setIsCheckingOut(false);
2735
2804
  options.onPaymentCancel?.();
2736
2805
  };
2737
2806
  loadingContainer = document.createElement("div");
2738
- loadingContainer.id = "recur-modal-loading";
2807
+ loadingContainer.id = "recur-dialog-loading";
2739
2808
  loadingContainer.className = "recur-sdk__loading-container";
2740
2809
  const skeleton = document.createElement("recur-payment-form-skeleton");
2741
2810
  loadingContainer.appendChild(skeleton);
2742
- modalContent.appendChild(closeButton);
2743
- modalContent.appendChild(loadingContainer);
2744
- modalOverlay.appendChild(modalContent);
2745
- document.body.appendChild(modalOverlay);
2746
- 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");
2747
2833
  } else if (config.checkoutMode === "embedded") {
2748
2834
  console.log("[Recur SDK] Mode is embedded, checking for container...");
2749
2835
  if (!config.containerElementId) {
@@ -2830,16 +2916,16 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2830
2916
  console.log("[Recur SDK] Initial containerElementId from config:", config.containerElementId);
2831
2917
  let containerElementId = config.containerElementId;
2832
2918
  if (config.checkoutMode === "modal") {
2833
- console.log("[Recur SDK] Mode is modal, updating modal with payment form...");
2834
- if (!loadingContainer || !modalContent) {
2835
- 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");
2836
2922
  }
2837
2923
  loadingContainer.remove();
2838
2924
  const formContainer = document.createElement("div");
2839
- containerElementId = "recur-modal-payment-container";
2925
+ containerElementId = "recur-dialog-payment-container";
2840
2926
  formContainer.id = containerElementId;
2841
- modalContent.appendChild(formContainer);
2842
- 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);
2843
2929
  } else if (config.checkoutMode === "embedded") {
2844
2930
  console.log("[Recur SDK] Mode is embedded, preparing container...");
2845
2931
  if (!containerElementId) {
@@ -2879,14 +2965,14 @@ function RecurProvider({ children, config: initialConfig = {} }) {
2879
2965
  if (options.customerEmail) {
2880
2966
  paymentForm.setAttribute("customer-email", options.customerEmail);
2881
2967
  }
2882
- if (checkoutResult.plan?.name) {
2883
- paymentForm.setAttribute("plan-name", checkoutResult.plan.name);
2968
+ if (checkoutResult.product?.name) {
2969
+ paymentForm.setAttribute("product-name", checkoutResult.product.name);
2884
2970
  }
2885
2971
  if (checkoutResult.checkout?.amount) {
2886
2972
  paymentForm.setAttribute("amount", checkoutResult.checkout.amount.toString());
2887
2973
  }
2888
- if (checkoutResult.plan?.billingPeriod) {
2889
- paymentForm.setAttribute("billing-period", checkoutResult.plan.billingPeriod);
2974
+ if (checkoutResult.product?.interval) {
2975
+ paymentForm.setAttribute("interval", checkoutResult.product.interval);
2890
2976
  }
2891
2977
  const customStyles = `
2892
2978
  /* PAYUNi SDK focus \u6A23\u5F0F - shadcn \u98A8\u683C */
@@ -3038,7 +3124,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3038
3124
  options.onPaymentComplete({
3039
3125
  id: paymentResult.subscription.id,
3040
3126
  status: "ACTIVE",
3041
- planId: checkoutResult.checkout.productId,
3127
+ productId: checkoutResult.checkout.productId,
3042
3128
  amount: checkoutResult.checkout.amount,
3043
3129
  billingPeriod: paymentResult.subscription.billingPeriod,
3044
3130
  currentPeriodStart: paymentResult.subscription.currentPeriodStart,
@@ -3048,7 +3134,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3048
3134
  options.onPaymentComplete({
3049
3135
  id: statusData.checkout?.orderId || checkoutId,
3050
3136
  status: "SUCCEEDED",
3051
- planId: checkoutResult.checkout.productId,
3137
+ productId: checkoutResult.checkout.productId,
3052
3138
  amount: checkoutResult.checkout.amount,
3053
3139
  billingPeriod: checkoutResult.checkout.productType,
3054
3140
  currentPeriodStart: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3056,9 +3142,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3056
3142
  });
3057
3143
  }
3058
3144
  }
3059
- if (modalOverlay) {
3060
- modalOverlay.remove();
3061
- }
3145
+ closeDialog();
3062
3146
  setIsCheckingOut(false);
3063
3147
  return;
3064
3148
  }
@@ -3100,7 +3184,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3100
3184
  options.onPaymentComplete({
3101
3185
  id: paymentResult.subscription.id,
3102
3186
  status: "ACTIVE",
3103
- planId: checkoutResult.checkout.productId,
3187
+ productId: checkoutResult.checkout.productId,
3104
3188
  amount: checkoutResult.checkout.amount,
3105
3189
  billingPeriod: paymentResult.subscription.billingPeriod,
3106
3190
  currentPeriodStart: paymentResult.subscription.currentPeriodStart,
@@ -3110,7 +3194,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3110
3194
  options.onPaymentComplete({
3111
3195
  id: finalOrderId || checkoutId,
3112
3196
  status: "SUCCEEDED",
3113
- planId: checkoutResult.checkout.productId,
3197
+ productId: checkoutResult.checkout.productId,
3114
3198
  amount: checkoutResult.checkout.amount,
3115
3199
  billingPeriod: checkoutResult.checkout.productType,
3116
3200
  currentPeriodStart: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3118,9 +3202,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3118
3202
  });
3119
3203
  }
3120
3204
  }
3121
- if (modalOverlay) {
3122
- modalOverlay.remove();
3123
- }
3205
+ closeDialog();
3124
3206
  setIsCheckingOut(false);
3125
3207
  }
3126
3208
  return;
@@ -3132,7 +3214,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3132
3214
  options.onPaymentComplete({
3133
3215
  id: paymentResult.subscription.id,
3134
3216
  status: paymentResult.subscription.status,
3135
- planId: checkoutResult.checkout.productId,
3217
+ productId: checkoutResult.checkout.productId,
3136
3218
  amount: checkoutResult.checkout.amount,
3137
3219
  billingPeriod: paymentResult.subscription.billingPeriod,
3138
3220
  currentPeriodStart: paymentResult.subscription.currentPeriodStart,
@@ -3144,7 +3226,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3144
3226
  options.onPaymentComplete({
3145
3227
  id: chargeId,
3146
3228
  status: chargeStatus,
3147
- planId: checkoutResult.checkout.productId,
3229
+ productId: checkoutResult.checkout.productId,
3148
3230
  amount: checkoutResult.checkout.amount,
3149
3231
  billingPeriod: checkoutResult.checkout.productType,
3150
3232
  currentPeriodStart: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3154,9 +3236,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3154
3236
  }
3155
3237
  console.log("[Recur SDK] Checkout flow completed successfully!");
3156
3238
  paymentForm.resetButton?.();
3157
- if (modalOverlay) {
3158
- modalOverlay.remove();
3159
- }
3239
+ closeDialog();
3160
3240
  setIsCheckingOut(false);
3161
3241
  } catch (error) {
3162
3242
  console.error("[Recur SDK] Error in payment flow:", error);
@@ -3175,9 +3255,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
3175
3255
  console.log("[Recur SDK] Checkout flow initialized, waiting for user input...");
3176
3256
  } catch (error) {
3177
3257
  console.error("[Recur SDK] Checkout error:", error);
3178
- if (modalOverlay) {
3179
- modalOverlay.remove();
3180
- }
3258
+ closeDialog();
3181
3259
  const checkoutError = {
3182
3260
  code: "CHECKOUT_ERROR",
3183
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
  * })}