@blocklet/payment-react 1.14.21 → 1.14.22
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/es/checkout/donate.d.ts +2 -1
- package/es/checkout/donate.js +9 -10
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +23 -1
- package/es/checkout/table.d.ts +1 -1
- package/es/checkout/table.js +8 -1
- package/es/components/blockchain/tx.js +2 -1
- package/es/components/country-select.d.ts +16 -0
- package/es/components/country-select.js +82 -0
- package/es/components/input.d.ts +21 -21
- package/es/components/input.js +43 -42
- package/es/components/livemode.js +1 -0
- package/es/components/pricing-table.js +0 -2
- package/es/components/status.js +2 -3
- package/es/components/table.d.ts +2 -0
- package/es/components/table.js +186 -0
- package/es/contexts/payment.d.ts +2 -0
- package/es/contexts/payment.js +5 -2
- package/es/history/invoice/list.d.ts +3 -1
- package/es/history/invoice/list.js +215 -48
- package/es/hooks/mobile.d.ts +4 -0
- package/es/hooks/mobile.js +10 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +7 -1
- package/es/libs/util.d.ts +15 -2
- package/es/libs/util.js +92 -28
- package/es/locales/en.js +22 -7
- package/es/locales/index.d.ts +0 -1
- package/es/locales/index.js +10 -1
- package/es/locales/zh.js +21 -6
- package/es/payment/error.js +2 -2
- package/es/payment/footer.js +1 -1
- package/es/payment/form/address.d.ts +9 -2
- package/es/payment/form/address.js +69 -69
- package/es/payment/form/currency.js +39 -25
- package/es/payment/form/index.d.ts +1 -1
- package/es/payment/form/index.js +83 -81
- package/es/payment/form/phone.js +15 -51
- package/es/payment/index.d.ts +1 -10
- package/es/payment/index.js +274 -219
- package/es/payment/product-card.js +4 -4
- package/es/payment/product-donation.js +7 -2
- package/es/payment/product-item.d.ts +2 -2
- package/es/payment/product-item.js +120 -81
- package/es/payment/summary.js +188 -118
- package/es/theme/index.css +240 -0
- package/es/theme/index.d.ts +9 -0
- package/es/theme/index.js +243 -0
- package/es/theme/typography.d.ts +2 -0
- package/es/theme/typography.js +53 -0
- package/es/types/index.d.ts +11 -0
- package/lib/checkout/donate.d.ts +2 -1
- package/lib/checkout/donate.js +14 -2
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +22 -1
- package/lib/checkout/table.d.ts +1 -1
- package/lib/checkout/table.js +14 -1
- package/lib/components/blockchain/tx.js +4 -1
- package/lib/components/country-select.d.ts +16 -0
- package/lib/components/country-select.js +115 -0
- package/lib/components/input.d.ts +21 -21
- package/lib/components/input.js +21 -12
- package/lib/components/livemode.js +1 -0
- package/lib/components/pricing-table.js +0 -2
- package/lib/components/status.js +2 -3
- package/lib/components/table.d.ts +2 -0
- package/lib/components/table.js +220 -0
- package/lib/contexts/payment.d.ts +2 -0
- package/lib/contexts/payment.js +4 -1
- package/lib/history/invoice/list.d.ts +3 -1
- package/lib/history/invoice/list.js +290 -62
- package/lib/hooks/mobile.d.ts +4 -0
- package/lib/hooks/mobile.js +17 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +36 -0
- package/lib/libs/util.d.ts +15 -2
- package/lib/libs/util.js +115 -37
- package/lib/locales/en.js +22 -7
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/index.js +14 -3
- package/lib/locales/zh.js +21 -6
- package/lib/payment/error.js +5 -1
- package/lib/payment/footer.js +1 -1
- package/lib/payment/form/address.d.ts +9 -2
- package/lib/payment/form/address.js +67 -59
- package/lib/payment/form/currency.js +31 -24
- package/lib/payment/form/index.d.ts +1 -1
- package/lib/payment/form/index.js +92 -93
- package/lib/payment/form/phone.js +11 -59
- package/lib/payment/index.d.ts +1 -10
- package/lib/payment/index.js +291 -219
- package/lib/payment/product-card.js +5 -4
- package/lib/payment/product-donation.js +9 -2
- package/lib/payment/product-item.d.ts +2 -2
- package/lib/payment/product-item.js +38 -19
- package/lib/payment/summary.js +219 -127
- package/lib/theme/index.css +240 -0
- package/lib/theme/index.d.ts +9 -0
- package/lib/theme/index.js +259 -0
- package/lib/theme/typography.d.ts +2 -0
- package/lib/theme/typography.js +59 -0
- package/lib/types/index.d.ts +11 -0
- package/package.json +14 -11
- package/src/checkout/donate.tsx +16 -10
- package/src/checkout/form.tsx +23 -0
- package/src/checkout/table.tsx +13 -1
- package/src/components/blockchain/tx.tsx +2 -1
- package/src/components/country-select.tsx +93 -0
- package/src/components/input.tsx +49 -46
- package/src/components/livemode.tsx +1 -0
- package/src/components/pricing-table.tsx +0 -2
- package/src/components/status.tsx +1 -2
- package/src/components/table.tsx +200 -0
- package/src/contexts/payment.tsx +6 -1
- package/src/history/invoice/list.tsx +254 -49
- package/src/hooks/mobile.ts +13 -0
- package/src/index.ts +7 -0
- package/src/libs/util.ts +120 -31
- package/src/locales/en.tsx +18 -4
- package/src/locales/index.tsx +10 -3
- package/src/locales/zh.tsx +17 -3
- package/src/payment/error.tsx +2 -2
- package/src/payment/footer.tsx +1 -1
- package/src/payment/form/address.tsx +56 -47
- package/src/payment/form/currency.tsx +29 -23
- package/src/payment/form/index.tsx +89 -76
- package/src/payment/form/phone.tsx +14 -51
- package/src/payment/index.tsx +294 -242
- package/src/payment/product-card.tsx +4 -4
- package/src/payment/product-donation.tsx +7 -3
- package/src/payment/product-item.tsx +49 -20
- package/src/payment/summary.tsx +191 -108
- package/src/theme/index.css +240 -0
- package/src/theme/index.tsx +250 -0
- package/src/theme/typography.ts +56 -0
- package/src/types/index.ts +12 -0
package/lib/libs/util.js
CHANGED
|
@@ -14,11 +14,14 @@ exports.formatDateTime = formatDateTime;
|
|
|
14
14
|
exports.formatError = void 0;
|
|
15
15
|
exports.formatLineItemPricing = formatLineItemPricing;
|
|
16
16
|
exports.formatLocale = void 0;
|
|
17
|
+
exports.formatMeteredThen = formatMeteredThen;
|
|
17
18
|
exports.formatNumber = formatNumber;
|
|
18
19
|
exports.formatPriceAmount = exports.formatPrice = exports.formatPrettyMsLocale = void 0;
|
|
20
|
+
exports.formatPriceDisplay = formatPriceDisplay;
|
|
19
21
|
exports.formatQuantityInventory = formatQuantityInventory;
|
|
20
22
|
exports.formatRecurring = formatRecurring;
|
|
21
23
|
exports.formatSubscriptionProduct = formatSubscriptionProduct;
|
|
24
|
+
exports.formatSubscriptionStatus = formatSubscriptionStatus;
|
|
22
25
|
exports.formatTime = formatTime;
|
|
23
26
|
exports.formatToDate = formatToDate;
|
|
24
27
|
exports.formatToDatetime = formatToDatetime;
|
|
@@ -471,17 +474,48 @@ function formatUpsellSaving(items, currency) {
|
|
|
471
474
|
const after = new _util.BN(to.total);
|
|
472
475
|
return Number(before.sub(after).mul(new _util.BN(100)).div(before).toString()).toFixed(0);
|
|
473
476
|
}
|
|
477
|
+
function formatMeteredThen(subscription, recurring, hasMetered, locale = "en") {
|
|
478
|
+
if (hasMetered) {
|
|
479
|
+
return (0, _locales.t)("payment.checkout.meteredThen", locale, {
|
|
480
|
+
subscription,
|
|
481
|
+
recurring
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
return (0, _locales.t)("payment.checkout.then", locale, {
|
|
485
|
+
subscription,
|
|
486
|
+
recurring
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
function formatPriceDisplay({
|
|
490
|
+
amount,
|
|
491
|
+
then,
|
|
492
|
+
actualAmount,
|
|
493
|
+
showThen
|
|
494
|
+
}, recurring, hasMetered, locale = "en") {
|
|
495
|
+
if (Number(actualAmount) === 0 && hasMetered) {
|
|
496
|
+
return (0, _locales.t)("payment.checkout.metered", locale, {
|
|
497
|
+
recurring
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
if (showThen) {
|
|
501
|
+
return [amount, then].filter(Boolean).join(", ");
|
|
502
|
+
}
|
|
503
|
+
return [amount, then].filter(Boolean).join(" ");
|
|
504
|
+
}
|
|
474
505
|
function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
|
|
475
506
|
const brand = getStatementDescriptor(items);
|
|
476
507
|
const {
|
|
477
508
|
total
|
|
478
509
|
} = getCheckoutAmount(items, currency, trialInDays > 0);
|
|
510
|
+
const actualAmount = (0, _util.fromUnitToToken)(total, currency.decimal);
|
|
479
511
|
const amount = `${(0, _util.fromUnitToToken)(total, currency.decimal)} ${currency.symbol}`;
|
|
480
512
|
if (items.length === 0) {
|
|
481
513
|
return {
|
|
482
514
|
action: (0, _locales.t)("payment.checkout.empty", locale),
|
|
483
515
|
amount: "0",
|
|
484
|
-
then: ""
|
|
516
|
+
then: "",
|
|
517
|
+
actualAmount: "0",
|
|
518
|
+
priceDisplay: "0"
|
|
485
519
|
};
|
|
486
520
|
}
|
|
487
521
|
const {
|
|
@@ -496,19 +530,23 @@ function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
|
|
|
496
530
|
if (items.length > 1) {
|
|
497
531
|
return {
|
|
498
532
|
action,
|
|
499
|
-
amount
|
|
533
|
+
amount,
|
|
534
|
+
actualAmount,
|
|
535
|
+
priceDisplay: amount
|
|
500
536
|
};
|
|
501
537
|
}
|
|
502
538
|
return {
|
|
503
539
|
action,
|
|
504
540
|
amount,
|
|
505
|
-
then: ""
|
|
541
|
+
then: "",
|
|
542
|
+
actualAmount,
|
|
543
|
+
priceDisplay: amount
|
|
506
544
|
};
|
|
507
545
|
}
|
|
508
546
|
const item = items.find(x => x.price.type === "recurring");
|
|
509
547
|
const recurring = formatRecurring((item?.upsell_price || item?.price)?.recurring, false, "per", locale);
|
|
548
|
+
const hasMetered = items.some(x => x.price.type === "recurring" && x.price.recurring?.usage_type === "metered");
|
|
510
549
|
if (items.every(x => x.price.type === "recurring")) {
|
|
511
|
-
const hasMetered = items.some(x => x.price.type === "recurring" && x.price.recurring?.usage_type === "metered");
|
|
512
550
|
const subscription2 = [hasMetered ? (0, _locales.t)("payment.checkout.least", locale) : "", (0, _util.fromUnitToToken)(items.reduce((acc, x) => {
|
|
513
551
|
if (x.price.recurring?.usage_type === "metered") {
|
|
514
552
|
return acc;
|
|
@@ -517,7 +555,7 @@ function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
|
|
|
517
555
|
}, new _util.BN(0)), currency.decimal), currency.symbol].filter(Boolean).join(" ");
|
|
518
556
|
if (items.length > 1) {
|
|
519
557
|
if (trialInDays > 0) {
|
|
520
|
-
|
|
558
|
+
const result4 = {
|
|
521
559
|
action: (0, _locales.t)("payment.checkout.try2", locale, {
|
|
522
560
|
name,
|
|
523
561
|
count: items.length - 1
|
|
@@ -525,41 +563,63 @@ function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
|
|
|
525
563
|
amount: (0, _locales.t)("payment.checkout.free", locale, {
|
|
526
564
|
count: trialInDays
|
|
527
565
|
}),
|
|
528
|
-
then: (
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
566
|
+
then: formatMeteredThen(subscription2, recurring, hasMetered && Number(subscription2) === 0, locale),
|
|
567
|
+
showThen: true,
|
|
568
|
+
actualAmount: "0"
|
|
569
|
+
};
|
|
570
|
+
return {
|
|
571
|
+
...result4,
|
|
572
|
+
priceDisplay: formatPriceDisplay(result4, recurring, hasMetered, locale)
|
|
532
573
|
};
|
|
533
574
|
}
|
|
534
|
-
|
|
575
|
+
const result3 = {
|
|
535
576
|
action: (0, _locales.t)("payment.checkout.sub2", locale, {
|
|
536
577
|
name,
|
|
537
578
|
count: items.length - 1
|
|
538
579
|
}),
|
|
539
580
|
amount,
|
|
540
|
-
then:
|
|
581
|
+
then: hasMetered ? (0, _locales.t)("payment.checkout.meteredThen", locale, {
|
|
582
|
+
recurring
|
|
583
|
+
}) : recurring,
|
|
584
|
+
showThen: hasMetered,
|
|
585
|
+
actualAmount
|
|
586
|
+
};
|
|
587
|
+
return {
|
|
588
|
+
...result3,
|
|
589
|
+
priceDisplay: formatPriceDisplay(result3, recurring, hasMetered, locale)
|
|
541
590
|
};
|
|
542
591
|
}
|
|
543
592
|
if (trialInDays > 0) {
|
|
544
|
-
|
|
593
|
+
const result3 = {
|
|
545
594
|
action: (0, _locales.t)("payment.checkout.try1", locale, {
|
|
546
595
|
name
|
|
547
596
|
}),
|
|
548
597
|
amount: (0, _locales.t)("payment.checkout.free", locale, {
|
|
549
598
|
count: trialInDays
|
|
550
599
|
}),
|
|
551
|
-
then: (
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
600
|
+
then: formatMeteredThen(subscription2, recurring, hasMetered && Number(subscription2) === 0, locale),
|
|
601
|
+
showThen: true,
|
|
602
|
+
actualAmount: "0"
|
|
603
|
+
};
|
|
604
|
+
return {
|
|
605
|
+
...result3,
|
|
606
|
+
priceDisplay: formatPriceDisplay(result3, recurring, hasMetered, locale)
|
|
555
607
|
};
|
|
556
608
|
}
|
|
557
|
-
|
|
609
|
+
const result2 = {
|
|
558
610
|
action: (0, _locales.t)("payment.checkout.sub1", locale, {
|
|
559
611
|
name
|
|
560
612
|
}),
|
|
561
613
|
amount,
|
|
562
|
-
then:
|
|
614
|
+
then: hasMetered ? (0, _locales.t)("payment.checkout.meteredThen", locale, {
|
|
615
|
+
recurring
|
|
616
|
+
}) : recurring,
|
|
617
|
+
showThen: hasMetered,
|
|
618
|
+
actualAmount
|
|
619
|
+
};
|
|
620
|
+
return {
|
|
621
|
+
...result2,
|
|
622
|
+
priceDisplay: formatPriceDisplay(result2, recurring, hasMetered, locale)
|
|
563
623
|
};
|
|
564
624
|
}
|
|
565
625
|
const subscription = (0, _util.fromUnitToToken)(items.filter(x => x.price.type === "recurring").reduce((acc, x) => {
|
|
@@ -568,15 +628,18 @@ function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
|
|
|
568
628
|
}
|
|
569
629
|
return acc.add(new _util.BN(getPriceUintAmountByCurrency(x.price, currency)).mul(new _util.BN(x.quantity)));
|
|
570
630
|
}, new _util.BN(0)), currency.decimal);
|
|
571
|
-
|
|
631
|
+
const result = {
|
|
572
632
|
action: (0, _locales.t)("payment.checkout.pay", locale, {
|
|
573
633
|
payee: brand
|
|
574
634
|
}),
|
|
575
635
|
amount,
|
|
576
|
-
then: (
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
636
|
+
then: formatMeteredThen(`${subscription} ${currency.symbol}`, recurring, hasMetered && Number(subscription) === 0, locale),
|
|
637
|
+
showThen: true,
|
|
638
|
+
actualAmount
|
|
639
|
+
};
|
|
640
|
+
return {
|
|
641
|
+
...result,
|
|
642
|
+
priceDisplay: formatPriceDisplay(result, recurring, hasMetered, locale)
|
|
580
643
|
};
|
|
581
644
|
}
|
|
582
645
|
function formatAmount(amount, decimals) {
|
|
@@ -615,24 +678,29 @@ function formatSubscriptionProduct(items, maxLength = 2) {
|
|
|
615
678
|
return names.slice(0, maxLength).join(", ") + (names.length > maxLength ? ` and ${names.length - maxLength} more` : "");
|
|
616
679
|
}
|
|
617
680
|
const getSubscriptionTimeSummary = subscription => {
|
|
618
|
-
const lines = [`
|
|
681
|
+
const lines = [`Start on ${formatToDate(subscription.start_date * 1e3, "en", "YYYY-MM-DD")}`];
|
|
682
|
+
const getLineTimeMessage = time => {
|
|
683
|
+
const curDay = (0, _dayjs.default)().isSame((0, _dayjs.default)(time), "day");
|
|
684
|
+
const timeFormat = curDay ? "HH:mm:ss" : "YYYY-MM-DD";
|
|
685
|
+
return `${curDay ? "in" : "on"} ${formatToDate(time, "en", timeFormat)}`;
|
|
686
|
+
};
|
|
619
687
|
if (subscription.status === "active" || subscription.status === "trialing") {
|
|
620
688
|
if (subscription.cancel_at) {
|
|
621
|
-
lines.push(`
|
|
689
|
+
lines.push(`Ended ${getLineTimeMessage(subscription.cancel_at * 1e3)}`);
|
|
622
690
|
} else if (subscription.cancel_at_period_end) {
|
|
623
|
-
lines.push(`
|
|
691
|
+
lines.push(`Ended ${getLineTimeMessage(subscription.current_period_end * 1e3)}`);
|
|
624
692
|
} else {
|
|
625
|
-
lines.push(`
|
|
693
|
+
lines.push(`Renew ${getLineTimeMessage(subscription.current_period_end * 1e3)}`);
|
|
626
694
|
}
|
|
627
695
|
} else if (subscription.status === "past_due") {
|
|
628
|
-
lines.push(`
|
|
696
|
+
lines.push(`Ended ${getLineTimeMessage((subscription.cancel_at || subscription.current_period_end) * 1e3)}`);
|
|
629
697
|
} else if (subscription.status === "canceled") {
|
|
630
|
-
lines.push(`
|
|
698
|
+
lines.push(`Ended ${getLineTimeMessage(subscription.canceled_at * 1e3)}`);
|
|
631
699
|
}
|
|
632
|
-
return lines.join(",
|
|
700
|
+
return lines.join(",");
|
|
633
701
|
};
|
|
634
702
|
exports.getSubscriptionTimeSummary = getSubscriptionTimeSummary;
|
|
635
|
-
const getSubscriptionAction = subscription => {
|
|
703
|
+
const getSubscriptionAction = (subscription, actionProps) => {
|
|
636
704
|
if (subscription.status === "active" || subscription.status === "trialing") {
|
|
637
705
|
if (subscription.cancel_at_period_end) {
|
|
638
706
|
if (subscription.cancelation_details?.reason === "payment_failed") {
|
|
@@ -642,7 +710,8 @@ const getSubscriptionAction = subscription => {
|
|
|
642
710
|
action: "recover",
|
|
643
711
|
variant: "contained",
|
|
644
712
|
color: "primary",
|
|
645
|
-
canRenew: false
|
|
713
|
+
canRenew: false,
|
|
714
|
+
...actionProps?.recover
|
|
646
715
|
};
|
|
647
716
|
}
|
|
648
717
|
if (subscription.cancel_at && subscription.cancel_at !== subscription.current_period_end) {
|
|
@@ -652,7 +721,8 @@ const getSubscriptionAction = subscription => {
|
|
|
652
721
|
action: "cancel",
|
|
653
722
|
variant: "outlined",
|
|
654
723
|
color: "inherit",
|
|
655
|
-
canRenew: false
|
|
724
|
+
canRenew: false,
|
|
725
|
+
...actionProps?.cancel
|
|
656
726
|
};
|
|
657
727
|
}
|
|
658
728
|
if (subscription.status === "past_due") {
|
|
@@ -661,7 +731,8 @@ const getSubscriptionAction = subscription => {
|
|
|
661
731
|
action: "pastDue",
|
|
662
732
|
variant: "contained",
|
|
663
733
|
color: "primary",
|
|
664
|
-
canRenew
|
|
734
|
+
canRenew,
|
|
735
|
+
...actionProps?.pastDue
|
|
665
736
|
};
|
|
666
737
|
}
|
|
667
738
|
if (subscription.status !== "canceled" && subscription.cancel_at_period_end) {
|
|
@@ -669,7 +740,8 @@ const getSubscriptionAction = subscription => {
|
|
|
669
740
|
action: "recover",
|
|
670
741
|
variant: "contained",
|
|
671
742
|
color: "primary",
|
|
672
|
-
canRenew: false
|
|
743
|
+
canRenew: false,
|
|
744
|
+
...actionProps?.recover
|
|
673
745
|
};
|
|
674
746
|
}
|
|
675
747
|
return null;
|
|
@@ -789,8 +861,8 @@ function formatTotalPrice({
|
|
|
789
861
|
}
|
|
790
862
|
const unitValue = new _util.BN(price.custom_unit_amount || price.unit_amount);
|
|
791
863
|
const currency = price?.currency ?? {};
|
|
792
|
-
const total = `${(0, _util.fromUnitToToken)(unitValue.mul(new _util.BN(quantity)), currency.decimal)} ${currency.symbol}`;
|
|
793
|
-
const unit = `${(0, _util.fromUnitToToken)(unitValue, currency.decimal)} ${currency.symbol}`;
|
|
864
|
+
const total = `${(0, _util.fromUnitToToken)(unitValue.mul(new _util.BN(quantity)), currency.decimal)} ${currency.symbol} `;
|
|
865
|
+
const unit = `${(0, _util.fromUnitToToken)(unitValue, currency.decimal)} ${currency.symbol} `;
|
|
794
866
|
const appendUnit = (v, alt) => {
|
|
795
867
|
if (product.unit_label) {
|
|
796
868
|
return `${v}/${price.product.unit_label}`;
|
|
@@ -826,6 +898,12 @@ function formatQuantityInventory(price, quantity, locale = "en") {
|
|
|
826
898
|
}
|
|
827
899
|
return "";
|
|
828
900
|
}
|
|
901
|
+
function formatSubscriptionStatus(status) {
|
|
902
|
+
if (status === "canceled") {
|
|
903
|
+
return "Ended";
|
|
904
|
+
}
|
|
905
|
+
return status;
|
|
906
|
+
}
|
|
829
907
|
function formatAmountPrecisionLimit(amount, locale = "en", precision = 6) {
|
|
830
908
|
if (!amount) {
|
|
831
909
|
return "";
|
package/lib/locales/en.js
CHANGED
|
@@ -67,7 +67,7 @@ module.exports = (0, _flat.default)({
|
|
|
67
67
|
continue: "Continue",
|
|
68
68
|
qty: "Qty {count}",
|
|
69
69
|
each: "{unit} each",
|
|
70
|
-
trial: "Free for {count}
|
|
70
|
+
trial: "Free for {count} day{count > 1 ? 's' : ''}",
|
|
71
71
|
billed: "billed {rule}",
|
|
72
72
|
metered: "based on usage",
|
|
73
73
|
hour: "hour",
|
|
@@ -116,10 +116,12 @@ module.exports = (0, _flat.default)({
|
|
|
116
116
|
subscription: "View subscription",
|
|
117
117
|
invoice: "View invoice"
|
|
118
118
|
},
|
|
119
|
+
paymentRequired: "Payment Required",
|
|
119
120
|
staking: {
|
|
120
121
|
title: "Staking Required",
|
|
121
122
|
tooltip: "Staking is used to ensure that future invoices can be paid normally. Revoking the staking from DID Wallet means canceling the subscription."
|
|
122
123
|
},
|
|
124
|
+
stakingConfirm: "In this payment, the staked amount is separate from the product cost.",
|
|
123
125
|
donation: {
|
|
124
126
|
between: "Please enter an amount between {min} and {max}.",
|
|
125
127
|
custom: "Custom Amount",
|
|
@@ -136,7 +138,9 @@ module.exports = (0, _flat.default)({
|
|
|
136
138
|
sub1: "Subscribe to {name}",
|
|
137
139
|
sub2: "Subscribe to {name} and {count} more",
|
|
138
140
|
then: "Then {subscription} {recurring}",
|
|
139
|
-
|
|
141
|
+
meteredThen: "Then {recurring} based on usage",
|
|
142
|
+
metered: "{recurring} based on usage",
|
|
143
|
+
free: "{count} day{count > 1 ? 's' : ''} free",
|
|
140
144
|
least: "continue with at least",
|
|
141
145
|
completed: {
|
|
142
146
|
payment: "Thanks for your purchase",
|
|
@@ -145,7 +149,7 @@ module.exports = (0, _flat.default)({
|
|
|
145
149
|
donate: "Thanks for your support",
|
|
146
150
|
tip: "A payment to {payee} has been completed. You can view the details of this payment in your account."
|
|
147
151
|
},
|
|
148
|
-
confirm: "
|
|
152
|
+
confirm: "Confirming allows {payee} to charge or reduce your staking. You can cancel or revoke staking anytime.",
|
|
149
153
|
required: "Required",
|
|
150
154
|
invalid: "Invalid",
|
|
151
155
|
billing: {
|
|
@@ -185,13 +189,17 @@ module.exports = (0, _flat.default)({
|
|
|
185
189
|
emptyItems: {
|
|
186
190
|
title: "Nothing to show here",
|
|
187
191
|
description: "Seems this checkoutSession is not configured properly"
|
|
188
|
-
}
|
|
192
|
+
},
|
|
193
|
+
orderSummary: "Order Summary",
|
|
194
|
+
paymentDetails: "Payment Details",
|
|
195
|
+
productListTotal: "Includes {total} items"
|
|
189
196
|
},
|
|
190
197
|
customer: {
|
|
191
198
|
payments: "Payment History",
|
|
192
199
|
invoices: "Invoice History",
|
|
193
200
|
details: "Details",
|
|
194
201
|
summary: "Summary",
|
|
202
|
+
specifics: "Specifics",
|
|
195
203
|
update: "Update Information",
|
|
196
204
|
empty: "Seems you do not have any subscriptions or payments here",
|
|
197
205
|
cancel: {
|
|
@@ -266,13 +274,17 @@ module.exports = (0, _flat.default)({
|
|
|
266
274
|
renewSuccess: "You have successfully renewed the subscription",
|
|
267
275
|
renewError: "Failed to renew the subscription",
|
|
268
276
|
empty: "There are no invoices",
|
|
269
|
-
next: "No invoices yet, next invoice will be generated on {date}"
|
|
277
|
+
next: "No invoices yet, next invoice will be generated on {date}",
|
|
278
|
+
invoiceNumber: "Invoice Number",
|
|
279
|
+
emptyList: "No Invoice"
|
|
270
280
|
},
|
|
271
281
|
payment: {
|
|
272
|
-
empty: "There are no payments"
|
|
282
|
+
empty: "There are no payments",
|
|
283
|
+
emptyList: "No Payment"
|
|
273
284
|
},
|
|
274
285
|
refund: {
|
|
275
|
-
empty: "There are no refunds"
|
|
286
|
+
empty: "There are no refunds",
|
|
287
|
+
emptyList: "No Refund"
|
|
276
288
|
},
|
|
277
289
|
subscriptions: {
|
|
278
290
|
plan: "Plan",
|
|
@@ -305,5 +317,8 @@ module.exports = (0, _flat.default)({
|
|
|
305
317
|
[_constant.RefundType.refund]: "Refund",
|
|
306
318
|
[_constant.RefundType.stakeReturn]: "Stake Return"
|
|
307
319
|
}
|
|
320
|
+
},
|
|
321
|
+
empty: {
|
|
322
|
+
records: "No matching records found"
|
|
308
323
|
}
|
|
309
324
|
});
|
package/lib/locales/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export declare const translations: {
|
|
|
2
2
|
zh: any;
|
|
3
3
|
en: any;
|
|
4
4
|
};
|
|
5
|
-
export declare const replace: (template: string, data?: Record<string, any>) => string;
|
|
6
5
|
export declare const createTranslator: ({ fallbackLocale }: {
|
|
7
6
|
fallbackLocale?: string | undefined;
|
|
8
7
|
}, langs?: any) => (key: string, locale?: string, data?: Record<string, any>) => string;
|
package/lib/locales/index.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.translations = exports.translate = exports.t = exports.
|
|
6
|
+
exports.translations = exports.translate = exports.t = exports.createTranslator = void 0;
|
|
7
|
+
var _lodash = require("lodash");
|
|
7
8
|
var _en = _interopRequireDefault(require("./en"));
|
|
8
9
|
var _zh = _interopRequireDefault(require("./zh"));
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -11,8 +12,18 @@ const translations = exports.translations = {
|
|
|
11
12
|
zh: _zh.default,
|
|
12
13
|
en: _en.default
|
|
13
14
|
};
|
|
14
|
-
const replace = (
|
|
15
|
-
|
|
15
|
+
const replace = (t2, data = {}) => {
|
|
16
|
+
try {
|
|
17
|
+
const compiled = (0, _lodash.template)(t2, {
|
|
18
|
+
interpolate: /{([\s\S]+?)}/g,
|
|
19
|
+
escape: /{([\s\S]+?)}/g
|
|
20
|
+
});
|
|
21
|
+
return compiled(data);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.error(`Error evaluating template: ${t2}`, e);
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
16
27
|
const createTranslator = ({
|
|
17
28
|
fallbackLocale = "en"
|
|
18
29
|
}, langs = translations) => {
|
package/lib/locales/zh.js
CHANGED
|
@@ -116,10 +116,12 @@ module.exports = (0, _flat.default)({
|
|
|
116
116
|
subscription: "\u67E5\u770B\u8BA2\u9605",
|
|
117
117
|
invoice: "\u67E5\u770B\u8D26\u5355"
|
|
118
118
|
},
|
|
119
|
+
paymentRequired: "\u652F\u4ED8\u6570\u91CF",
|
|
119
120
|
staking: {
|
|
120
121
|
title: "\u8D28\u62BC\u6570\u91CF",
|
|
121
122
|
tooltip: "\u8D28\u62BC\u76F8\u5F53\u4E8E\u4FDD\u8BC1\u91D1\uFF0C\u7528\u4E8E\u786E\u4FDD\u672A\u6765\u7684\u8D26\u5355\u80FD\u591F\u6B63\u5E38\u6263\u6B3E\uFF0C\u5982\u679C\u4F60\u4ECE DID Wallet \u64A4\u9500\u8D28\u62BC\uFF0C\u8BA2\u9605\u4E5F\u4F1A\u88AB\u53D6\u6D88\u3002"
|
|
122
123
|
},
|
|
124
|
+
stakingConfirm: "\u5728\u6B64\u652F\u4ED8\u4E2D\uFF0C\u8D28\u62BC\u91D1\u989D\u4E0E\u4EA7\u54C1\u8D39\u7528\u5206\u5F00",
|
|
123
125
|
donation: {
|
|
124
126
|
between: "\u91D1\u989D\u5FC5\u987B\u5927\u4E8E {min} \u4E14\u5C0F\u4E8E {max}",
|
|
125
127
|
custom: "\u8F93\u5165\u91D1\u989D",
|
|
@@ -136,7 +138,9 @@ module.exports = (0, _flat.default)({
|
|
|
136
138
|
sub1: "\u8BA2\u9605 {name}",
|
|
137
139
|
sub2: "\u8BA2\u9605 {name} \u7B49{count}\u4E2A\u4EA7\u54C1",
|
|
138
140
|
then: "\u7136\u540E {subscription} {recurring}",
|
|
139
|
-
|
|
141
|
+
meteredThen: "\u7136\u540E{recurring}\u6309\u7528\u91CF\u8BA1\u8D39",
|
|
142
|
+
metered: "{recurring}\u6309\u7528\u91CF\u8BA1\u8D39",
|
|
143
|
+
free: "\u514D\u8D39\u8BD5\u7528 {count} \u5929",
|
|
140
144
|
least: "\u81F3\u5C11",
|
|
141
145
|
completed: {
|
|
142
146
|
payment: "\u611F\u8C22\u60A8\u7684\u8D2D\u4E70",
|
|
@@ -145,7 +149,7 @@ module.exports = (0, _flat.default)({
|
|
|
145
149
|
donate: "\u611F\u8C22\u60A8\u7684\u652F\u6301",
|
|
146
150
|
tip: "\u5411{payee}\u7684\u4ED8\u6B3E\u5DF2\u5B8C\u6210\u3002\u60A8\u53EF\u4EE5\u5728\u60A8\u7684\u8D26\u6237\u4E2D\u67E5\u770B\u6B64\u4ED8\u6B3E\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002"
|
|
147
151
|
},
|
|
148
|
-
confirm: "\
|
|
152
|
+
confirm: "\u786E\u8BA4\u5141\u8BB8{payee}\u5BF9\u60A8\u7684\u8D26\u6237\u8FDB\u884C\u4ED8\u6B3E\u6216\u8005\u7F5A\u6CA1\u60A8\u7684\u8D28\u62BC\u3002\u60A8\u968F\u65F6\u53EF\u4EE5\u53D6\u6D88\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u8005\u64A4\u9500\u8D28\u62BC\u3002",
|
|
149
153
|
required: "\u5FC5\u586B\u9879",
|
|
150
154
|
invalid: "\u65E0\u6548",
|
|
151
155
|
billing: {
|
|
@@ -185,13 +189,17 @@ module.exports = (0, _flat.default)({
|
|
|
185
189
|
emptyItems: {
|
|
186
190
|
title: "\u6CA1\u6709\u4EFB\u4F55\u8D2D\u4E70\u9879\u76EE",
|
|
187
191
|
description: "\u53EF\u80FD\u8FD9\u4E2A\u4ED8\u6B3E\u94FE\u63A5\u6CA1\u6709\u6B63\u786E\u914D\u7F6E"
|
|
188
|
-
}
|
|
192
|
+
},
|
|
193
|
+
orderSummary: "\u8BA2\u5355\u6982\u89C8",
|
|
194
|
+
paymentDetails: "\u652F\u4ED8\u4FE1\u606F",
|
|
195
|
+
productListTotal: "\u5305\u62EC {total} \u9879"
|
|
189
196
|
},
|
|
190
197
|
customer: {
|
|
191
198
|
payments: "\u652F\u4ED8\u5386\u53F2",
|
|
192
199
|
invoices: "\u8D26\u5355\u5386\u53F2",
|
|
193
200
|
details: "\u8D26\u6237\u8BE6\u60C5",
|
|
194
201
|
summary: "\u8BA1\u8D39\u6458\u8981",
|
|
202
|
+
specifics: "\u5177\u4F53\u4FE1\u606F",
|
|
195
203
|
update: "\u66F4\u65B0\u5BA2\u6237\u4FE1\u606F",
|
|
196
204
|
empty: "\u770B\u8D77\u6765\u60A8\u5728\u8FD9\u91CC\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605\u6216\u652F\u4ED8",
|
|
197
205
|
cancel: {
|
|
@@ -266,13 +274,17 @@ module.exports = (0, _flat.default)({
|
|
|
266
274
|
renewSuccess: "\u8BA2\u9605\u6062\u590D\u6210\u529F",
|
|
267
275
|
renewError: "\u8BA2\u9605\u6062\u590D\u5931\u8D25",
|
|
268
276
|
empty: "\u6CA1\u6709\u4EFB\u4F55\u8D26\u5355",
|
|
269
|
-
next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210"
|
|
277
|
+
next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210",
|
|
278
|
+
invoiceNumber: "\u8D26\u5355\u7F16\u53F7",
|
|
279
|
+
emptyList: "\u6CA1\u6709\u8D26\u5355"
|
|
270
280
|
},
|
|
271
281
|
payment: {
|
|
272
|
-
empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55"
|
|
282
|
+
empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55",
|
|
283
|
+
emptyList: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55"
|
|
273
284
|
},
|
|
274
285
|
refund: {
|
|
275
|
-
empty: "\u6CA1\u6709\u9000\u6B3E\u8BB0\u5F55"
|
|
286
|
+
empty: "\u6CA1\u6709\u9000\u6B3E\u8BB0\u5F55",
|
|
287
|
+
emptyList: "\u6CA1\u6709\u9000\u6B3E\u8BB0\u5F55"
|
|
276
288
|
},
|
|
277
289
|
subscriptions: {
|
|
278
290
|
plan: "\u8BA2\u9605",
|
|
@@ -305,5 +317,8 @@ module.exports = (0, _flat.default)({
|
|
|
305
317
|
[_constant.RefundType.refund]: "\u9000\u6B3E",
|
|
306
318
|
[_constant.RefundType.stakeReturn]: "\u9000\u62BC\u91D1"
|
|
307
319
|
}
|
|
320
|
+
},
|
|
321
|
+
empty: {
|
|
322
|
+
records: "\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u8BB0\u5F55"
|
|
308
323
|
}
|
|
309
324
|
});
|
package/lib/payment/error.js
CHANGED
|
@@ -10,7 +10,8 @@ function getHeightStyle(mode) {
|
|
|
10
10
|
switch (mode) {
|
|
11
11
|
case "standalone":
|
|
12
12
|
return {
|
|
13
|
-
height: "100vh"
|
|
13
|
+
height: "100vh",
|
|
14
|
+
maxHeight: "100%"
|
|
14
15
|
};
|
|
15
16
|
default:
|
|
16
17
|
return {
|
|
@@ -53,6 +54,9 @@ function PaymentError({
|
|
|
53
54
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
54
55
|
variant: "text",
|
|
55
56
|
size: "small",
|
|
57
|
+
sx: {
|
|
58
|
+
color: "text.link"
|
|
59
|
+
},
|
|
56
60
|
component: _material.Link,
|
|
57
61
|
href: window.blocklet?.appUrl,
|
|
58
62
|
children: button
|
package/lib/payment/footer.js
CHANGED
|
@@ -10,7 +10,7 @@ function CheckoutFooter({
|
|
|
10
10
|
...props
|
|
11
11
|
}) {
|
|
12
12
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
13
|
-
color: "text.
|
|
13
|
+
color: "text.lighter",
|
|
14
14
|
fontSize: 12,
|
|
15
15
|
...props,
|
|
16
16
|
children: ["Powered by", " ", /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { SxProps } from '@mui/material';
|
|
2
3
|
type Props = {
|
|
3
4
|
mode: string;
|
|
4
5
|
stripe: boolean;
|
|
6
|
+
sx?: SxProps;
|
|
5
7
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
declare function AddressForm({ mode, stripe, sx }: Props): import("react").JSX.Element | null;
|
|
9
|
+
declare namespace AddressForm {
|
|
10
|
+
var defaultProps: {
|
|
11
|
+
sx: {};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export default AddressForm;
|