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 +175 -97
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +175 -97
- package/dist/recur.umd.js +122 -90
- package/dist/server.cjs +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
- package/dist/server.d.cts +0 -194
- package/dist/server.d.ts +0 -194
package/dist/index.js
CHANGED
|
@@ -423,11 +423,14 @@ var init_skeleton_loader = __esm({
|
|
|
423
423
|
<div class="skeleton-label"></div>
|
|
424
424
|
<div class="skeleton-input"></div>
|
|
425
425
|
</div>
|
|
426
|
-
<div class="skeleton-
|
|
427
|
-
<div class="skeleton-
|
|
428
|
-
|
|
429
|
-
<div class="skeleton-input
|
|
430
|
-
|
|
426
|
+
<div class="skeleton-row">
|
|
427
|
+
<div class="skeleton-field">
|
|
428
|
+
<div class="skeleton-label"></div>
|
|
429
|
+
<div class="skeleton-input"></div>
|
|
430
|
+
</div>
|
|
431
|
+
<div class="skeleton-field">
|
|
432
|
+
<div class="skeleton-label"></div>
|
|
433
|
+
<div class="skeleton-input"></div>
|
|
431
434
|
</div>
|
|
432
435
|
</div>
|
|
433
436
|
<div class="skeleton-button"></div>
|
|
@@ -466,6 +469,7 @@ var init_skeleton_loader = __esm({
|
|
|
466
469
|
<style>
|
|
467
470
|
:host {
|
|
468
471
|
display: block;
|
|
472
|
+
container-type: inline-size; /* Enable container queries */
|
|
469
473
|
}
|
|
470
474
|
|
|
471
475
|
@keyframes recur-sdk-pulse {
|
|
@@ -501,8 +505,8 @@ var init_skeleton_loader = __esm({
|
|
|
501
505
|
|
|
502
506
|
.skeleton-row {
|
|
503
507
|
display: grid;
|
|
504
|
-
grid-template-columns:
|
|
505
|
-
gap:
|
|
508
|
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
509
|
+
column-gap: 16px;
|
|
506
510
|
}
|
|
507
511
|
|
|
508
512
|
.skeleton-input-half {
|
|
@@ -745,9 +749,7 @@ var init_payment_form_skeleton = __esm({
|
|
|
745
749
|
}
|
|
746
750
|
|
|
747
751
|
.info-row {
|
|
748
|
-
|
|
749
|
-
align-items: center;
|
|
750
|
-
margin-bottom: 6px;
|
|
752
|
+
margin-bottom: 12px;
|
|
751
753
|
}
|
|
752
754
|
|
|
753
755
|
.info-row:last-child {
|
|
@@ -755,9 +757,11 @@ var init_payment_form_skeleton = __esm({
|
|
|
755
757
|
}
|
|
756
758
|
|
|
757
759
|
.info-label {
|
|
758
|
-
|
|
760
|
+
display: block;
|
|
761
|
+
font-size: 12px;
|
|
762
|
+
line-height: 16px;
|
|
759
763
|
color: #718096;
|
|
760
|
-
|
|
764
|
+
margin-bottom: 2px;
|
|
761
765
|
}
|
|
762
766
|
|
|
763
767
|
.skeleton-info-value {
|
|
@@ -782,8 +786,8 @@ var init_payment_form_skeleton = __esm({
|
|
|
782
786
|
|
|
783
787
|
.card-row {
|
|
784
788
|
display: grid;
|
|
785
|
-
grid-template-columns:
|
|
786
|
-
gap:
|
|
789
|
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
790
|
+
column-gap: 16px;
|
|
787
791
|
}
|
|
788
792
|
|
|
789
793
|
/* Submit Button - matches .recur-submit-button: padding 14px*2 + font 16px * line-height ~1.5 */
|
|
@@ -841,14 +845,14 @@ var init_payment_form_skeleton = __esm({
|
|
|
841
845
|
|
|
842
846
|
<!-- Customer Info Section (matches createCustomerInfoSection read-only display) -->
|
|
843
847
|
<div class="form-section">
|
|
844
|
-
<h3 class="section-title">\
|
|
848
|
+
<h3 class="section-title">\u806F\u7D61\u8CC7\u8A0A</h3>
|
|
845
849
|
<div class="customer-info-display">
|
|
846
850
|
<div class="info-row">
|
|
847
|
-
<span class="info-label">\
|
|
851
|
+
<span class="info-label">\u59D3\u540D</span>
|
|
848
852
|
<div class="skeleton skeleton-info-value"></div>
|
|
849
853
|
</div>
|
|
850
854
|
<div class="info-row">
|
|
851
|
-
<span class="info-label">\u96FB\u5B50\u90F5\u4EF6
|
|
855
|
+
<span class="info-label">\u96FB\u5B50\u90F5\u4EF6</span>
|
|
852
856
|
<div class="skeleton skeleton-info-value" style="width: 160px;"></div>
|
|
853
857
|
</div>
|
|
854
858
|
</div>
|
|
@@ -1201,7 +1205,7 @@ var init_payment_form = __esm({
|
|
|
1201
1205
|
}
|
|
1202
1206
|
// 監聽 attribute 變化
|
|
1203
1207
|
static get observedAttributes() {
|
|
1204
|
-
return ["custom-styles", "customer-name", "customer-email", "
|
|
1208
|
+
return ["custom-styles", "customer-name", "customer-email", "product-name", "amount", "interval"];
|
|
1205
1209
|
}
|
|
1206
1210
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
1207
1211
|
if (name === "custom-styles" && oldValue !== newValue) {
|
|
@@ -1226,6 +1230,10 @@ var init_payment_form = __esm({
|
|
|
1226
1230
|
background: white;
|
|
1227
1231
|
border-radius: 12px;
|
|
1228
1232
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
1233
|
+
/* Prevent double-tap zoom on iOS */
|
|
1234
|
+
touch-action: manipulation;
|
|
1235
|
+
/* Enable container queries for responsive layout */
|
|
1236
|
+
container-type: inline-size;
|
|
1229
1237
|
}
|
|
1230
1238
|
|
|
1231
1239
|
.form-header {
|
|
@@ -1291,7 +1299,7 @@ var init_payment_form = __esm({
|
|
|
1291
1299
|
<slot name="order-summary"></slot>
|
|
1292
1300
|
|
|
1293
1301
|
<div class="form-section">
|
|
1294
|
-
<h3 class="section-title">\
|
|
1302
|
+
<h3 class="section-title">\u806F\u7D61\u8CC7\u8A0A</h3>
|
|
1295
1303
|
<!-- Slot for customer info fields (Light DOM) -->
|
|
1296
1304
|
<slot name="customer-info"></slot>
|
|
1297
1305
|
</div>
|
|
@@ -1367,19 +1375,19 @@ var init_payment_form = __esm({
|
|
|
1367
1375
|
createOrderSummarySection() {
|
|
1368
1376
|
const section = document.createElement("div");
|
|
1369
1377
|
section.className = "order-summary-section";
|
|
1370
|
-
const
|
|
1378
|
+
const productName = this.getAttribute("product-name");
|
|
1371
1379
|
const amount = this.getAttribute("amount");
|
|
1372
|
-
const
|
|
1373
|
-
if (!
|
|
1380
|
+
const interval = this.getAttribute("interval");
|
|
1381
|
+
if (!productName || !amount) {
|
|
1374
1382
|
return section;
|
|
1375
1383
|
}
|
|
1376
|
-
const
|
|
1377
|
-
"
|
|
1378
|
-
"
|
|
1379
|
-
"
|
|
1380
|
-
"
|
|
1384
|
+
const intervalMap = {
|
|
1385
|
+
"day": "\u65E5",
|
|
1386
|
+
"week": "\u9031",
|
|
1387
|
+
"month": "\u6708",
|
|
1388
|
+
"year": "\u5E74"
|
|
1381
1389
|
};
|
|
1382
|
-
const periodText =
|
|
1390
|
+
const periodText = interval ? intervalMap[interval] || interval : "";
|
|
1383
1391
|
section.innerHTML = `
|
|
1384
1392
|
<style>
|
|
1385
1393
|
.order-summary-section {
|
|
@@ -1433,7 +1441,7 @@ var init_payment_form = __esm({
|
|
|
1433
1441
|
<h3 class="order-summary-title">\u8A02\u55AE\u6458\u8981</h3>
|
|
1434
1442
|
<div class="order-summary-item">
|
|
1435
1443
|
<span class="order-summary-label">\u8A02\u95B1\u65B9\u6848</span>
|
|
1436
|
-
<span class="order-summary-value">${
|
|
1444
|
+
<span class="order-summary-value">${productName}</span>
|
|
1437
1445
|
</div>
|
|
1438
1446
|
${periodText ? `
|
|
1439
1447
|
<div class="order-summary-item">
|
|
@@ -1465,9 +1473,7 @@ var init_payment_form = __esm({
|
|
|
1465
1473
|
}
|
|
1466
1474
|
|
|
1467
1475
|
.recur-info-row {
|
|
1468
|
-
|
|
1469
|
-
align-items: center;
|
|
1470
|
-
margin-bottom: 6px;
|
|
1476
|
+
margin-bottom: 12px;
|
|
1471
1477
|
}
|
|
1472
1478
|
|
|
1473
1479
|
.recur-info-row:last-child {
|
|
@@ -1475,28 +1481,33 @@ var init_payment_form = __esm({
|
|
|
1475
1481
|
}
|
|
1476
1482
|
|
|
1477
1483
|
.recur-info-label {
|
|
1478
|
-
|
|
1484
|
+
display: block;
|
|
1485
|
+
font-size: 12px;
|
|
1486
|
+
line-height: 16px;
|
|
1479
1487
|
color: #718096;
|
|
1480
|
-
|
|
1488
|
+
margin-bottom: 2px;
|
|
1481
1489
|
}
|
|
1482
1490
|
|
|
1483
1491
|
.recur-info-value {
|
|
1492
|
+
display: block;
|
|
1484
1493
|
font-size: 14px;
|
|
1485
1494
|
line-height: 20px;
|
|
1495
|
+
min-height: 20px;
|
|
1486
1496
|
color: #2d3748;
|
|
1487
1497
|
font-weight: 500;
|
|
1498
|
+
word-break: break-all;
|
|
1488
1499
|
}
|
|
1489
1500
|
</style>
|
|
1490
1501
|
|
|
1491
1502
|
<div class="recur-info-display">
|
|
1492
1503
|
${customerName ? `
|
|
1493
1504
|
<div class="recur-info-row">
|
|
1494
|
-
<span class="recur-info-label">\
|
|
1505
|
+
<span class="recur-info-label">\u59D3\u540D</span>
|
|
1495
1506
|
<span class="recur-info-value">${customerName}</span>
|
|
1496
1507
|
</div>
|
|
1497
1508
|
` : ""}
|
|
1498
1509
|
<div class="recur-info-row">
|
|
1499
|
-
<span class="recur-info-label">\u96FB\u5B50\u90F5\u4EF6
|
|
1510
|
+
<span class="recur-info-label">\u96FB\u5B50\u90F5\u4EF6</span>
|
|
1500
1511
|
<span class="recur-info-value">${customerEmail}</span>
|
|
1501
1512
|
</div>
|
|
1502
1513
|
</div>
|
|
@@ -1521,7 +1532,7 @@ var init_payment_form = __esm({
|
|
|
1521
1532
|
.recur-form-input {
|
|
1522
1533
|
width: 100%;
|
|
1523
1534
|
padding: 10px 12px;
|
|
1524
|
-
font-size:
|
|
1535
|
+
font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
|
|
1525
1536
|
border: 1px solid #d1d5db;
|
|
1526
1537
|
border-radius: 6px;
|
|
1527
1538
|
transition: border-color 0.2s;
|
|
@@ -1588,12 +1599,14 @@ var init_payment_form = __esm({
|
|
|
1588
1599
|
width: 100%;
|
|
1589
1600
|
max-width: 100%;
|
|
1590
1601
|
box-sizing: border-box;
|
|
1602
|
+
/* Help reduce iOS zoom issues */
|
|
1603
|
+
touch-action: manipulation;
|
|
1591
1604
|
}
|
|
1592
1605
|
|
|
1593
1606
|
.recur-card-row {
|
|
1594
1607
|
display: grid;
|
|
1595
|
-
grid-template-columns:
|
|
1596
|
-
gap:
|
|
1608
|
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
1609
|
+
column-gap: 16px;
|
|
1597
1610
|
max-width: 100%;
|
|
1598
1611
|
box-sizing: border-box;
|
|
1599
1612
|
}
|
|
@@ -1601,6 +1614,8 @@ var init_payment_form = __esm({
|
|
|
1601
1614
|
/* Container needs relative positioning for skeleton overlay */
|
|
1602
1615
|
.recur-card-field-container {
|
|
1603
1616
|
position: relative;
|
|
1617
|
+
/* Help reduce iOS zoom issues */
|
|
1618
|
+
touch-action: manipulation;
|
|
1604
1619
|
}
|
|
1605
1620
|
|
|
1606
1621
|
/* Loading skeleton for card fields - shown until PAYUNi iframe loads */
|
|
@@ -2613,7 +2628,7 @@ function toCamelCase(obj) {
|
|
|
2613
2628
|
|
|
2614
2629
|
// package.json
|
|
2615
2630
|
var package_default = {
|
|
2616
|
-
version: "0.9.
|
|
2631
|
+
version: "0.9.7"};
|
|
2617
2632
|
var SDK_VERSION = package_default.version;
|
|
2618
2633
|
var SDK_TYPE = "react";
|
|
2619
2634
|
var RecurContext = createContext(null);
|
|
@@ -2637,7 +2652,72 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
2637
2652
|
}, []);
|
|
2638
2653
|
const checkout = useCallback(
|
|
2639
2654
|
async (options) => {
|
|
2640
|
-
let
|
|
2655
|
+
let dialog = null;
|
|
2656
|
+
let savedScrollY = 0;
|
|
2657
|
+
let savedBodyStyles = null;
|
|
2658
|
+
const lockBodyScroll = () => {
|
|
2659
|
+
savedScrollY = window.scrollY;
|
|
2660
|
+
savedBodyStyles = {
|
|
2661
|
+
overflow: document.body.style.overflow,
|
|
2662
|
+
position: document.body.style.position,
|
|
2663
|
+
top: document.body.style.top,
|
|
2664
|
+
width: document.body.style.width,
|
|
2665
|
+
height: document.body.style.height
|
|
2666
|
+
};
|
|
2667
|
+
document.body.style.overflow = "hidden";
|
|
2668
|
+
document.body.style.position = "fixed";
|
|
2669
|
+
document.body.style.top = `-${savedScrollY}px`;
|
|
2670
|
+
document.body.style.width = "100%";
|
|
2671
|
+
document.body.style.height = "100%";
|
|
2672
|
+
};
|
|
2673
|
+
const unlockBodyScroll = () => {
|
|
2674
|
+
if (savedBodyStyles) {
|
|
2675
|
+
document.body.style.overflow = savedBodyStyles.overflow;
|
|
2676
|
+
document.body.style.position = savedBodyStyles.position;
|
|
2677
|
+
document.body.style.top = savedBodyStyles.top;
|
|
2678
|
+
document.body.style.width = savedBodyStyles.width;
|
|
2679
|
+
document.body.style.height = savedBodyStyles.height;
|
|
2680
|
+
window.scrollTo(0, savedScrollY);
|
|
2681
|
+
savedBodyStyles = null;
|
|
2682
|
+
}
|
|
2683
|
+
};
|
|
2684
|
+
const closeDialog = () => {
|
|
2685
|
+
if (dialog) {
|
|
2686
|
+
dialog.close();
|
|
2687
|
+
dialog.remove();
|
|
2688
|
+
unlockBodyScroll();
|
|
2689
|
+
}
|
|
2690
|
+
};
|
|
2691
|
+
const injectDialogStyles = () => {
|
|
2692
|
+
if (document.getElementById("recur-dialog-styles")) return;
|
|
2693
|
+
const styleEl = document.createElement("style");
|
|
2694
|
+
styleEl.id = "recur-dialog-styles";
|
|
2695
|
+
styleEl.textContent = `
|
|
2696
|
+
.recur-sdk__dialog {
|
|
2697
|
+
border: none;
|
|
2698
|
+
border-radius: 12px;
|
|
2699
|
+
padding: 0;
|
|
2700
|
+
max-width: 500px;
|
|
2701
|
+
width: 90%;
|
|
2702
|
+
max-height: 90vh;
|
|
2703
|
+
overflow: visible;
|
|
2704
|
+
background: transparent;
|
|
2705
|
+
/* Center the dialog */
|
|
2706
|
+
margin: auto;
|
|
2707
|
+
position: fixed;
|
|
2708
|
+
inset: 0;
|
|
2709
|
+
height: fit-content;
|
|
2710
|
+
}
|
|
2711
|
+
.recur-sdk__dialog::backdrop {
|
|
2712
|
+
background: rgba(0, 0, 0, 0.5);
|
|
2713
|
+
}
|
|
2714
|
+
.recur-sdk__dialog[open] {
|
|
2715
|
+
display: flex;
|
|
2716
|
+
flex-direction: column;
|
|
2717
|
+
}
|
|
2718
|
+
`;
|
|
2719
|
+
document.head.appendChild(styleEl);
|
|
2720
|
+
};
|
|
2641
2721
|
try {
|
|
2642
2722
|
console.log("[Recur SDK] Starting checkout flow...", {
|
|
2643
2723
|
planId: options.planId,
|
|
@@ -2662,31 +2742,20 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
2662
2742
|
"X-Recur-SDK-Version": SDK_VERSION,
|
|
2663
2743
|
"X-Recur-Source": typeof window !== "undefined" ? window.location.origin : "server"
|
|
2664
2744
|
};
|
|
2665
|
-
let
|
|
2745
|
+
let dialogContent = null;
|
|
2666
2746
|
let loadingContainer = null;
|
|
2667
2747
|
let embeddedContainer = null;
|
|
2668
2748
|
if (config.checkoutMode === "modal") {
|
|
2669
|
-
console.log("[Recur SDK] Mode is modal, creating
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
width: 100%;
|
|
2678
|
-
height: 100%;
|
|
2679
|
-
background: rgba(0, 0, 0, 0.5);
|
|
2680
|
-
display: flex;
|
|
2681
|
-
align-items: center;
|
|
2682
|
-
justify-content: center;
|
|
2683
|
-
z-index: 9999;
|
|
2684
|
-
`;
|
|
2685
|
-
modalContent = document.createElement("div");
|
|
2686
|
-
modalContent.className = "recur-sdk__modal-content";
|
|
2687
|
-
modalContent.style.cssText = `
|
|
2749
|
+
console.log("[Recur SDK] Mode is modal, creating dialog with loading state...");
|
|
2750
|
+
injectDialogStyles();
|
|
2751
|
+
dialog = document.createElement("dialog");
|
|
2752
|
+
dialog.id = "recur-sdk-dialog";
|
|
2753
|
+
dialog.className = "recur-sdk__dialog";
|
|
2754
|
+
dialogContent = document.createElement("div");
|
|
2755
|
+
dialogContent.className = "recur-sdk__dialog-content";
|
|
2756
|
+
dialogContent.style.cssText = `
|
|
2688
2757
|
max-width: 500px;
|
|
2689
|
-
width:
|
|
2758
|
+
width: 100%;
|
|
2690
2759
|
max-height: 90vh;
|
|
2691
2760
|
overflow-y: auto;
|
|
2692
2761
|
overflow-x: hidden;
|
|
@@ -2724,20 +2793,37 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
2724
2793
|
closeButton.style.background = "rgba(0, 0, 0, 0.05)";
|
|
2725
2794
|
};
|
|
2726
2795
|
closeButton.onclick = () => {
|
|
2727
|
-
|
|
2796
|
+
closeDialog();
|
|
2728
2797
|
setIsCheckingOut(false);
|
|
2729
2798
|
options.onPaymentCancel?.();
|
|
2730
2799
|
};
|
|
2731
2800
|
loadingContainer = document.createElement("div");
|
|
2732
|
-
loadingContainer.id = "recur-
|
|
2801
|
+
loadingContainer.id = "recur-dialog-loading";
|
|
2733
2802
|
loadingContainer.className = "recur-sdk__loading-container";
|
|
2734
2803
|
const skeleton = document.createElement("recur-payment-form-skeleton");
|
|
2735
2804
|
loadingContainer.appendChild(skeleton);
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
document.body.appendChild(
|
|
2740
|
-
|
|
2805
|
+
dialogContent.appendChild(closeButton);
|
|
2806
|
+
dialogContent.appendChild(loadingContainer);
|
|
2807
|
+
dialog.appendChild(dialogContent);
|
|
2808
|
+
document.body.appendChild(dialog);
|
|
2809
|
+
dialog.showModal();
|
|
2810
|
+
lockBodyScroll();
|
|
2811
|
+
dialog.addEventListener("click", (e) => {
|
|
2812
|
+
const rect = dialog.getBoundingClientRect();
|
|
2813
|
+
const isInDialog = e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
|
|
2814
|
+
if (!isInDialog) {
|
|
2815
|
+
closeDialog();
|
|
2816
|
+
setIsCheckingOut(false);
|
|
2817
|
+
options.onPaymentCancel?.();
|
|
2818
|
+
}
|
|
2819
|
+
});
|
|
2820
|
+
dialog.addEventListener("cancel", (e) => {
|
|
2821
|
+
e.preventDefault();
|
|
2822
|
+
closeDialog();
|
|
2823
|
+
setIsCheckingOut(false);
|
|
2824
|
+
options.onPaymentCancel?.();
|
|
2825
|
+
});
|
|
2826
|
+
console.log("[Recur SDK] Dialog created with loading state");
|
|
2741
2827
|
} else if (config.checkoutMode === "embedded") {
|
|
2742
2828
|
console.log("[Recur SDK] Mode is embedded, checking for container...");
|
|
2743
2829
|
if (!config.containerElementId) {
|
|
@@ -2824,16 +2910,16 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
2824
2910
|
console.log("[Recur SDK] Initial containerElementId from config:", config.containerElementId);
|
|
2825
2911
|
let containerElementId = config.containerElementId;
|
|
2826
2912
|
if (config.checkoutMode === "modal") {
|
|
2827
|
-
console.log("[Recur SDK] Mode is modal, updating
|
|
2828
|
-
if (!loadingContainer || !
|
|
2829
|
-
throw new Error("
|
|
2913
|
+
console.log("[Recur SDK] Mode is modal, updating dialog with payment form...");
|
|
2914
|
+
if (!loadingContainer || !dialogContent) {
|
|
2915
|
+
throw new Error("Dialog components not initialized");
|
|
2830
2916
|
}
|
|
2831
2917
|
loadingContainer.remove();
|
|
2832
2918
|
const formContainer = document.createElement("div");
|
|
2833
|
-
containerElementId = "recur-
|
|
2919
|
+
containerElementId = "recur-dialog-payment-container";
|
|
2834
2920
|
formContainer.id = containerElementId;
|
|
2835
|
-
|
|
2836
|
-
console.log("[Recur SDK]
|
|
2921
|
+
dialogContent.appendChild(formContainer);
|
|
2922
|
+
console.log("[Recur SDK] Dialog updated with container ID:", containerElementId);
|
|
2837
2923
|
} else if (config.checkoutMode === "embedded") {
|
|
2838
2924
|
console.log("[Recur SDK] Mode is embedded, preparing container...");
|
|
2839
2925
|
if (!containerElementId) {
|
|
@@ -2873,14 +2959,14 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
2873
2959
|
if (options.customerEmail) {
|
|
2874
2960
|
paymentForm.setAttribute("customer-email", options.customerEmail);
|
|
2875
2961
|
}
|
|
2876
|
-
if (checkoutResult.
|
|
2877
|
-
paymentForm.setAttribute("
|
|
2962
|
+
if (checkoutResult.product?.name) {
|
|
2963
|
+
paymentForm.setAttribute("product-name", checkoutResult.product.name);
|
|
2878
2964
|
}
|
|
2879
2965
|
if (checkoutResult.checkout?.amount) {
|
|
2880
2966
|
paymentForm.setAttribute("amount", checkoutResult.checkout.amount.toString());
|
|
2881
2967
|
}
|
|
2882
|
-
if (checkoutResult.
|
|
2883
|
-
paymentForm.setAttribute("
|
|
2968
|
+
if (checkoutResult.product?.interval) {
|
|
2969
|
+
paymentForm.setAttribute("interval", checkoutResult.product.interval);
|
|
2884
2970
|
}
|
|
2885
2971
|
const customStyles = `
|
|
2886
2972
|
/* PAYUNi SDK focus \u6A23\u5F0F - shadcn \u98A8\u683C */
|
|
@@ -3032,7 +3118,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3032
3118
|
options.onPaymentComplete({
|
|
3033
3119
|
id: paymentResult.subscription.id,
|
|
3034
3120
|
status: "ACTIVE",
|
|
3035
|
-
|
|
3121
|
+
productId: checkoutResult.checkout.productId,
|
|
3036
3122
|
amount: checkoutResult.checkout.amount,
|
|
3037
3123
|
billingPeriod: paymentResult.subscription.billingPeriod,
|
|
3038
3124
|
currentPeriodStart: paymentResult.subscription.currentPeriodStart,
|
|
@@ -3042,7 +3128,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3042
3128
|
options.onPaymentComplete({
|
|
3043
3129
|
id: statusData.checkout?.orderId || checkoutId,
|
|
3044
3130
|
status: "SUCCEEDED",
|
|
3045
|
-
|
|
3131
|
+
productId: checkoutResult.checkout.productId,
|
|
3046
3132
|
amount: checkoutResult.checkout.amount,
|
|
3047
3133
|
billingPeriod: checkoutResult.checkout.productType,
|
|
3048
3134
|
currentPeriodStart: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3050,9 +3136,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3050
3136
|
});
|
|
3051
3137
|
}
|
|
3052
3138
|
}
|
|
3053
|
-
|
|
3054
|
-
modalOverlay.remove();
|
|
3055
|
-
}
|
|
3139
|
+
closeDialog();
|
|
3056
3140
|
setIsCheckingOut(false);
|
|
3057
3141
|
return;
|
|
3058
3142
|
}
|
|
@@ -3094,7 +3178,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3094
3178
|
options.onPaymentComplete({
|
|
3095
3179
|
id: paymentResult.subscription.id,
|
|
3096
3180
|
status: "ACTIVE",
|
|
3097
|
-
|
|
3181
|
+
productId: checkoutResult.checkout.productId,
|
|
3098
3182
|
amount: checkoutResult.checkout.amount,
|
|
3099
3183
|
billingPeriod: paymentResult.subscription.billingPeriod,
|
|
3100
3184
|
currentPeriodStart: paymentResult.subscription.currentPeriodStart,
|
|
@@ -3104,7 +3188,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3104
3188
|
options.onPaymentComplete({
|
|
3105
3189
|
id: finalOrderId || checkoutId,
|
|
3106
3190
|
status: "SUCCEEDED",
|
|
3107
|
-
|
|
3191
|
+
productId: checkoutResult.checkout.productId,
|
|
3108
3192
|
amount: checkoutResult.checkout.amount,
|
|
3109
3193
|
billingPeriod: checkoutResult.checkout.productType,
|
|
3110
3194
|
currentPeriodStart: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3112,9 +3196,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3112
3196
|
});
|
|
3113
3197
|
}
|
|
3114
3198
|
}
|
|
3115
|
-
|
|
3116
|
-
modalOverlay.remove();
|
|
3117
|
-
}
|
|
3199
|
+
closeDialog();
|
|
3118
3200
|
setIsCheckingOut(false);
|
|
3119
3201
|
}
|
|
3120
3202
|
return;
|
|
@@ -3126,7 +3208,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3126
3208
|
options.onPaymentComplete({
|
|
3127
3209
|
id: paymentResult.subscription.id,
|
|
3128
3210
|
status: paymentResult.subscription.status,
|
|
3129
|
-
|
|
3211
|
+
productId: checkoutResult.checkout.productId,
|
|
3130
3212
|
amount: checkoutResult.checkout.amount,
|
|
3131
3213
|
billingPeriod: paymentResult.subscription.billingPeriod,
|
|
3132
3214
|
currentPeriodStart: paymentResult.subscription.currentPeriodStart,
|
|
@@ -3138,7 +3220,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3138
3220
|
options.onPaymentComplete({
|
|
3139
3221
|
id: chargeId,
|
|
3140
3222
|
status: chargeStatus,
|
|
3141
|
-
|
|
3223
|
+
productId: checkoutResult.checkout.productId,
|
|
3142
3224
|
amount: checkoutResult.checkout.amount,
|
|
3143
3225
|
billingPeriod: checkoutResult.checkout.productType,
|
|
3144
3226
|
currentPeriodStart: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3148,9 +3230,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3148
3230
|
}
|
|
3149
3231
|
console.log("[Recur SDK] Checkout flow completed successfully!");
|
|
3150
3232
|
paymentForm.resetButton?.();
|
|
3151
|
-
|
|
3152
|
-
modalOverlay.remove();
|
|
3153
|
-
}
|
|
3233
|
+
closeDialog();
|
|
3154
3234
|
setIsCheckingOut(false);
|
|
3155
3235
|
} catch (error) {
|
|
3156
3236
|
console.error("[Recur SDK] Error in payment flow:", error);
|
|
@@ -3169,9 +3249,7 @@ function RecurProvider({ children, config: initialConfig = {} }) {
|
|
|
3169
3249
|
console.log("[Recur SDK] Checkout flow initialized, waiting for user input...");
|
|
3170
3250
|
} catch (error) {
|
|
3171
3251
|
console.error("[Recur SDK] Checkout error:", error);
|
|
3172
|
-
|
|
3173
|
-
modalOverlay.remove();
|
|
3174
|
-
}
|
|
3252
|
+
closeDialog();
|
|
3175
3253
|
const checkoutError = {
|
|
3176
3254
|
code: "CHECKOUT_ERROR",
|
|
3177
3255
|
message: error instanceof Error ? error.message : "An unknown error occurred"
|