@blocklet/payment-react 1.13.156 → 1.13.158
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/locales/en.js +3 -0
- package/es/locales/zh.js +3 -0
- package/es/util.d.ts +1 -0
- package/es/util.js +11 -7
- package/lib/locales/en.js +3 -0
- package/lib/locales/zh.js +3 -0
- package/lib/util.d.ts +1 -0
- package/lib/util.js +19 -11
- package/package.json +3 -3
- package/src/locales/en.tsx +3 -0
- package/src/locales/zh.tsx +3 -0
- package/src/util.ts +13 -8
package/es/locales/en.js
CHANGED
|
@@ -210,6 +210,9 @@ export default flat({
|
|
|
210
210
|
pay: "Pay this invoice",
|
|
211
211
|
paySuccess: "You have successfully paid the invoice",
|
|
212
212
|
payError: "Failed to paid the invoice",
|
|
213
|
+
renew: "Renew the subscription",
|
|
214
|
+
renewSuccess: "You have successfully renewed the subscription",
|
|
215
|
+
renewError: "Failed to renew the subscription",
|
|
213
216
|
empty: "There are no invoices here"
|
|
214
217
|
},
|
|
215
218
|
payment: {
|
package/es/locales/zh.js
CHANGED
|
@@ -210,6 +210,9 @@ export default flat({
|
|
|
210
210
|
pay: "\u652F\u4ED8\u6B64\u53D1\u7968",
|
|
211
211
|
paySuccess: "\u652F\u4ED8\u6210\u529F",
|
|
212
212
|
payError: "\u652F\u4ED8\u5931\u8D25",
|
|
213
|
+
renew: "\u6062\u590D\u8BA2\u9605",
|
|
214
|
+
renewSuccess: "\u8BA2\u9605\u6062\u590D\u6210\u529F",
|
|
215
|
+
renewError: "\u8BA2\u9605\u6062\u590D\u5931\u8D25",
|
|
213
216
|
empty: "\u6CA1\u6709\u4EFB\u4F55\u53D1\u7968"
|
|
214
217
|
},
|
|
215
218
|
payment: {
|
package/es/util.d.ts
CHANGED
package/es/util.js
CHANGED
|
@@ -432,27 +432,31 @@ export const getSubscriptionTimeSummary = (subscription) => {
|
|
|
432
432
|
lines.push(`will renew on ${formatToDate(subscription.current_period_end * 1e3)}`);
|
|
433
433
|
}
|
|
434
434
|
} else if (subscription.status === "past_due") {
|
|
435
|
-
lines.push(`will cancel on ${formatToDate(subscription.current_period_end * 1e3)}`);
|
|
435
|
+
lines.push(`will cancel on ${formatToDate((subscription.cancel_at || subscription.current_period_end) * 1e3)}`);
|
|
436
436
|
} else if (subscription.status === "canceled") {
|
|
437
437
|
lines.push(`canceled on ${formatToDate(subscription.canceled_at * 1e3)}`);
|
|
438
438
|
}
|
|
439
439
|
return lines.join(", ");
|
|
440
440
|
};
|
|
441
441
|
export const getSubscriptionAction = (subscription) => {
|
|
442
|
-
if (subscription.status !== "canceled" && subscription.cancel_at_period_end) {
|
|
443
|
-
return { action: "recover", variant: "contained", color: "primary" };
|
|
444
|
-
}
|
|
445
442
|
if (subscription.status === "active" || subscription.status === "trialing") {
|
|
446
443
|
if (subscription.cancel_at) {
|
|
447
444
|
return null;
|
|
448
445
|
}
|
|
449
446
|
if (subscription.cancel_at_period_end) {
|
|
450
|
-
|
|
447
|
+
if (subscription.cancelation_details?.reason === "payment_failed") {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
return { action: "recover", variant: "contained", color: "primary", canRenew: false };
|
|
451
451
|
}
|
|
452
|
-
return { action: "cancel", variant: "outlined", color: "inherit" };
|
|
452
|
+
return { action: "cancel", variant: "outlined", color: "inherit", canRenew: false };
|
|
453
453
|
}
|
|
454
454
|
if (subscription.status === "past_due") {
|
|
455
|
-
|
|
455
|
+
const canRenew = subscription.cancel_at && subscription.cancel_at !== subscription.current_period_end;
|
|
456
|
+
return { action: "pastDue", variant: "contained", color: "primary", canRenew };
|
|
457
|
+
}
|
|
458
|
+
if (subscription.status !== "canceled" && subscription.cancel_at_period_end) {
|
|
459
|
+
return { action: "recover", variant: "contained", color: "primary", canRenew: false };
|
|
456
460
|
}
|
|
457
461
|
return null;
|
|
458
462
|
};
|
package/lib/locales/en.js
CHANGED
|
@@ -217,6 +217,9 @@ module.exports = (0, _flat.default)({
|
|
|
217
217
|
pay: "Pay this invoice",
|
|
218
218
|
paySuccess: "You have successfully paid the invoice",
|
|
219
219
|
payError: "Failed to paid the invoice",
|
|
220
|
+
renew: "Renew the subscription",
|
|
221
|
+
renewSuccess: "You have successfully renewed the subscription",
|
|
222
|
+
renewError: "Failed to renew the subscription",
|
|
220
223
|
empty: "There are no invoices here"
|
|
221
224
|
},
|
|
222
225
|
payment: {
|
package/lib/locales/zh.js
CHANGED
|
@@ -217,6 +217,9 @@ module.exports = (0, _flat.default)({
|
|
|
217
217
|
pay: "\u652F\u4ED8\u6B64\u53D1\u7968",
|
|
218
218
|
paySuccess: "\u652F\u4ED8\u6210\u529F",
|
|
219
219
|
payError: "\u652F\u4ED8\u5931\u8D25",
|
|
220
|
+
renew: "\u6062\u590D\u8BA2\u9605",
|
|
221
|
+
renewSuccess: "\u8BA2\u9605\u6062\u590D\u6210\u529F",
|
|
222
|
+
renewError: "\u8BA2\u9605\u6062\u590D\u5931\u8D25",
|
|
220
223
|
empty: "\u6CA1\u6709\u4EFB\u4F55\u53D1\u7968"
|
|
221
224
|
},
|
|
222
225
|
payment: {
|
package/lib/util.d.ts
CHANGED
package/lib/util.js
CHANGED
|
@@ -517,7 +517,7 @@ const getSubscriptionTimeSummary = subscription => {
|
|
|
517
517
|
lines.push(`will renew on ${formatToDate(subscription.current_period_end * 1e3)}`);
|
|
518
518
|
}
|
|
519
519
|
} else if (subscription.status === "past_due") {
|
|
520
|
-
lines.push(`will cancel on ${formatToDate(subscription.current_period_end * 1e3)}`);
|
|
520
|
+
lines.push(`will cancel on ${formatToDate((subscription.cancel_at || subscription.current_period_end) * 1e3)}`);
|
|
521
521
|
} else if (subscription.status === "canceled") {
|
|
522
522
|
lines.push(`canceled on ${formatToDate(subscription.canceled_at * 1e3)}`);
|
|
523
523
|
}
|
|
@@ -525,35 +525,43 @@ const getSubscriptionTimeSummary = subscription => {
|
|
|
525
525
|
};
|
|
526
526
|
exports.getSubscriptionTimeSummary = getSubscriptionTimeSummary;
|
|
527
527
|
const getSubscriptionAction = subscription => {
|
|
528
|
-
if (subscription.status !== "canceled" && subscription.cancel_at_period_end) {
|
|
529
|
-
return {
|
|
530
|
-
action: "recover",
|
|
531
|
-
variant: "contained",
|
|
532
|
-
color: "primary"
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
528
|
if (subscription.status === "active" || subscription.status === "trialing") {
|
|
536
529
|
if (subscription.cancel_at) {
|
|
537
530
|
return null;
|
|
538
531
|
}
|
|
539
532
|
if (subscription.cancel_at_period_end) {
|
|
533
|
+
if (subscription.cancelation_details?.reason === "payment_failed") {
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
540
536
|
return {
|
|
541
537
|
action: "recover",
|
|
542
538
|
variant: "contained",
|
|
543
|
-
color: "primary"
|
|
539
|
+
color: "primary",
|
|
540
|
+
canRenew: false
|
|
544
541
|
};
|
|
545
542
|
}
|
|
546
543
|
return {
|
|
547
544
|
action: "cancel",
|
|
548
545
|
variant: "outlined",
|
|
549
|
-
color: "inherit"
|
|
546
|
+
color: "inherit",
|
|
547
|
+
canRenew: false
|
|
550
548
|
};
|
|
551
549
|
}
|
|
552
550
|
if (subscription.status === "past_due") {
|
|
551
|
+
const canRenew = subscription.cancel_at && subscription.cancel_at !== subscription.current_period_end;
|
|
553
552
|
return {
|
|
554
553
|
action: "pastDue",
|
|
555
554
|
variant: "contained",
|
|
556
|
-
color: "primary"
|
|
555
|
+
color: "primary",
|
|
556
|
+
canRenew
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
if (subscription.status !== "canceled" && subscription.cancel_at_period_end) {
|
|
560
|
+
return {
|
|
561
|
+
action: "recover",
|
|
562
|
+
variant: "contained",
|
|
563
|
+
color: "primary",
|
|
564
|
+
canRenew: false
|
|
557
565
|
};
|
|
558
566
|
}
|
|
559
567
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.158",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@babel/core": "^7.23.9",
|
|
90
90
|
"@babel/preset-env": "^7.23.9",
|
|
91
91
|
"@babel/preset-react": "^7.23.3",
|
|
92
|
-
"@blocklet/payment-types": "1.13.
|
|
92
|
+
"@blocklet/payment-types": "1.13.158",
|
|
93
93
|
"@storybook/addon-essentials": "^7.6.13",
|
|
94
94
|
"@storybook/addon-interactions": "^7.6.13",
|
|
95
95
|
"@storybook/addon-links": "^7.6.13",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"vite-plugin-babel": "^1.2.0",
|
|
119
119
|
"vite-plugin-node-polyfills": "^0.19.0"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "f53ad79f77852d57376924819e1fb81044462fa5"
|
|
122
122
|
}
|
package/src/locales/en.tsx
CHANGED
|
@@ -216,6 +216,9 @@ export default flat({
|
|
|
216
216
|
pay: 'Pay this invoice',
|
|
217
217
|
paySuccess: 'You have successfully paid the invoice',
|
|
218
218
|
payError: 'Failed to paid the invoice',
|
|
219
|
+
renew: 'Renew the subscription',
|
|
220
|
+
renewSuccess: 'You have successfully renewed the subscription',
|
|
221
|
+
renewError: 'Failed to renew the subscription',
|
|
219
222
|
empty: 'There are no invoices here',
|
|
220
223
|
},
|
|
221
224
|
payment: {
|
package/src/locales/zh.tsx
CHANGED
package/src/util.ts
CHANGED
|
@@ -586,7 +586,7 @@ export const getSubscriptionTimeSummary = (subscription: TSubscriptionExpanded)
|
|
|
586
586
|
lines.push(`will renew on ${formatToDate(subscription.current_period_end * 1000)}`);
|
|
587
587
|
}
|
|
588
588
|
} else if (subscription.status === 'past_due') {
|
|
589
|
-
lines.push(`will cancel on ${formatToDate(subscription.current_period_end * 1000)}`);
|
|
589
|
+
lines.push(`will cancel on ${formatToDate((subscription.cancel_at || subscription.current_period_end) * 1000)}`);
|
|
590
590
|
} else if (subscription.status === 'canceled') {
|
|
591
591
|
lines.push(`canceled on ${formatToDate(subscription.canceled_at * 1000)}`);
|
|
592
592
|
}
|
|
@@ -595,23 +595,28 @@ export const getSubscriptionTimeSummary = (subscription: TSubscriptionExpanded)
|
|
|
595
595
|
};
|
|
596
596
|
|
|
597
597
|
export const getSubscriptionAction = (subscription: TSubscriptionExpanded) => {
|
|
598
|
-
if (subscription.status !== 'canceled' && subscription.cancel_at_period_end) {
|
|
599
|
-
return { action: 'recover', variant: 'contained', color: 'primary' };
|
|
600
|
-
}
|
|
601
|
-
|
|
602
598
|
if (subscription.status === 'active' || subscription.status === 'trialing') {
|
|
603
599
|
if (subscription.cancel_at) {
|
|
604
600
|
return null;
|
|
605
601
|
}
|
|
606
602
|
if (subscription.cancel_at_period_end) {
|
|
607
|
-
|
|
603
|
+
if (subscription.cancelation_details?.reason === 'payment_failed') {
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return { action: 'recover', variant: 'contained', color: 'primary', canRenew: false };
|
|
608
608
|
}
|
|
609
609
|
|
|
610
|
-
return { action: 'cancel', variant: 'outlined', color: 'inherit' };
|
|
610
|
+
return { action: 'cancel', variant: 'outlined', color: 'inherit', canRenew: false };
|
|
611
611
|
}
|
|
612
612
|
|
|
613
613
|
if (subscription.status === 'past_due') {
|
|
614
|
-
|
|
614
|
+
const canRenew = subscription.cancel_at && subscription.cancel_at !== subscription.current_period_end;
|
|
615
|
+
return { action: 'pastDue', variant: 'contained', color: 'primary', canRenew };
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if (subscription.status !== 'canceled' && subscription.cancel_at_period_end) {
|
|
619
|
+
return { action: 'recover', variant: 'contained', color: 'primary', canRenew: false };
|
|
615
620
|
}
|
|
616
621
|
|
|
617
622
|
return null;
|