@blocklet/payment-react 1.13.168 → 1.13.169
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/history/mini-invoice/list.js +1 -1
- package/es/payment/index.js +2 -2
- package/es/payment/summary.js +1 -1
- package/es/util.js +4 -1
- package/lib/history/mini-invoice/list.js +1 -1
- package/lib/payment/index.js +5 -1
- package/lib/payment/summary.js +1 -1
- package/lib/util.js +4 -1
- package/package.json +3 -3
- package/src/history/mini-invoice/list.tsx +1 -1
- package/src/payment/index.tsx +2 -2
- package/src/payment/summary.tsx +1 -1
- package/src/util.ts +4 -1
|
@@ -45,7 +45,7 @@ export default function MiniInvoiceList() {
|
|
|
45
45
|
value: /* @__PURE__ */ jsx(Status, { label: subscription.status, color: getSubscriptionStatusColor(subscription.status) })
|
|
46
46
|
}
|
|
47
47
|
];
|
|
48
|
-
if (subscription.status === "active" || subscription.status === "
|
|
48
|
+
if (subscription.status === "active" || subscription.status === "trialing") {
|
|
49
49
|
infoList.push({
|
|
50
50
|
name: t("payment.customer.subscriptions.nextInvoice"),
|
|
51
51
|
value: /* @__PURE__ */ jsx(
|
package/es/payment/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Box, Fade, Stack } from "@mui/material";
|
|
|
6
6
|
import { styled } from "@mui/system";
|
|
7
7
|
import { useSetState } from "ahooks";
|
|
8
8
|
import { useEffect, useState } from "react";
|
|
9
|
-
import { FormProvider, useForm } from "react-hook-form";
|
|
9
|
+
import { FormProvider, useForm, useWatch } from "react-hook-form";
|
|
10
10
|
import api from "../api.js";
|
|
11
11
|
import { usePaymentContext } from "../contexts/payment.js";
|
|
12
12
|
import { findCurrency, formatError, getStatementDescriptor, isValidCountry } from "../util.js";
|
|
@@ -138,7 +138,7 @@ export function PaymentInner({
|
|
|
138
138
|
)
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
|
-
const currencyId = methods.
|
|
141
|
+
const currencyId = useWatch({ control: methods.control, name: "payment_currency", defaultValue: defaultCurrencyId });
|
|
142
142
|
const currency = findCurrency(paymentMethods, currencyId) || settings.baseCurrency;
|
|
143
143
|
const onUpsell = async (from, to) => {
|
|
144
144
|
try {
|
package/es/payment/summary.js
CHANGED
|
@@ -132,7 +132,7 @@ export default function PaymentSummary({
|
|
|
132
132
|
}
|
|
133
133
|
)
|
|
134
134
|
},
|
|
135
|
-
x.price_id
|
|
135
|
+
`${x.price_id}-${currency.id}`
|
|
136
136
|
)) }),
|
|
137
137
|
data && items.some((x) => x.price_id === data.id) === false && /* @__PURE__ */ jsx(Grow, { in: true, children: /* @__PURE__ */ jsxs(
|
|
138
138
|
Stack,
|
package/es/util.js
CHANGED
|
@@ -120,7 +120,10 @@ export function getPriceUintAmountByCurrency(price, currency) {
|
|
|
120
120
|
if (option) {
|
|
121
121
|
return option.unit_amount;
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
if (price.currency_id === currency.id) {
|
|
124
|
+
return price.unit_amount;
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Currency option ${currency.id} not configured for price ${price.id}`);
|
|
124
127
|
}
|
|
125
128
|
export function getPriceCurrencyOptions(price) {
|
|
126
129
|
if (Array.isArray(price.currency_options)) {
|
|
@@ -62,7 +62,7 @@ function MiniInvoiceList() {
|
|
|
62
62
|
color: (0, _util2.getSubscriptionStatusColor)(subscription.status)
|
|
63
63
|
})
|
|
64
64
|
}];
|
|
65
|
-
if (subscription.status === "active" || subscription.status === "
|
|
65
|
+
if (subscription.status === "active" || subscription.status === "trialing") {
|
|
66
66
|
infoList.push({
|
|
67
67
|
name: t("payment.customer.subscriptions.nextInvoice"),
|
|
68
68
|
value: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
package/lib/payment/index.js
CHANGED
|
@@ -162,7 +162,11 @@ function PaymentInner({
|
|
|
162
162
|
})
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
|
-
const currencyId =
|
|
165
|
+
const currencyId = (0, _reactHookForm.useWatch)({
|
|
166
|
+
control: methods.control,
|
|
167
|
+
name: "payment_currency",
|
|
168
|
+
defaultValue: defaultCurrencyId
|
|
169
|
+
});
|
|
166
170
|
const currency = (0, _util.findCurrency)(paymentMethods, currencyId) || settings.baseCurrency;
|
|
167
171
|
const onUpsell = async (from, to) => {
|
|
168
172
|
try {
|
package/lib/payment/summary.js
CHANGED
|
@@ -175,7 +175,7 @@ function PaymentSummary({
|
|
|
175
175
|
onClick: handleCancelCrossSell,
|
|
176
176
|
children: t("payment.checkout.cross_sell.remove")
|
|
177
177
|
})
|
|
178
|
-
}, x.price_id))
|
|
178
|
+
}, `${x.price_id}-${currency.id}`))
|
|
179
179
|
}), data && items.some(x => x.price_id === data.id) === false && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Grow, {
|
|
180
180
|
in: true,
|
|
181
181
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
package/lib/util.js
CHANGED
|
@@ -170,7 +170,10 @@ function getPriceUintAmountByCurrency(price, currency) {
|
|
|
170
170
|
if (option) {
|
|
171
171
|
return option.unit_amount;
|
|
172
172
|
}
|
|
173
|
-
|
|
173
|
+
if (price.currency_id === currency.id) {
|
|
174
|
+
return price.unit_amount;
|
|
175
|
+
}
|
|
176
|
+
throw new Error(`Currency option ${currency.id} not configured for price ${price.id}`);
|
|
174
177
|
}
|
|
175
178
|
function getPriceCurrencyOptions(price) {
|
|
176
179
|
if (Array.isArray(price.currency_options)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.169",
|
|
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.169",
|
|
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": "77c7dea2d2c9dda8754c29fec007ffbc4ba0d442"
|
|
122
122
|
}
|
|
@@ -64,7 +64,7 @@ export default function MiniInvoiceList() {
|
|
|
64
64
|
},
|
|
65
65
|
];
|
|
66
66
|
|
|
67
|
-
if (subscription.status === 'active' || subscription.status === '
|
|
67
|
+
if (subscription.status === 'active' || subscription.status === 'trialing') {
|
|
68
68
|
infoList.push({
|
|
69
69
|
name: t('payment.customer.subscriptions.nextInvoice'),
|
|
70
70
|
value: (
|
package/src/payment/index.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import { Box, Fade, Stack } from '@mui/material';
|
|
|
12
12
|
import { styled } from '@mui/system';
|
|
13
13
|
import { useSetState } from 'ahooks';
|
|
14
14
|
import { useEffect, useState } from 'react';
|
|
15
|
-
import { FormProvider, useForm } from 'react-hook-form';
|
|
15
|
+
import { FormProvider, useForm, useWatch } from 'react-hook-form';
|
|
16
16
|
import { LiteralUnion } from 'type-fest';
|
|
17
17
|
|
|
18
18
|
import api from '../api';
|
|
@@ -173,7 +173,7 @@ export function PaymentInner({
|
|
|
173
173
|
},
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
-
const currencyId = methods.
|
|
176
|
+
const currencyId = useWatch({ control: methods.control, name: 'payment_currency', defaultValue: defaultCurrencyId });
|
|
177
177
|
const currency =
|
|
178
178
|
(findCurrency(paymentMethods as TPaymentMethodExpanded[], currencyId as string) as TPaymentCurrency) ||
|
|
179
179
|
settings.baseCurrency;
|
package/src/payment/summary.tsx
CHANGED
package/src/util.ts
CHANGED
|
@@ -192,7 +192,10 @@ export function getPriceUintAmountByCurrency(price: TPrice, currency: TPaymentCu
|
|
|
192
192
|
return option.unit_amount;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
if (price.currency_id === currency.id) {
|
|
196
|
+
return price.unit_amount;
|
|
197
|
+
}
|
|
198
|
+
throw new Error(`Currency option ${currency.id} not configured for price ${price.id}`);
|
|
196
199
|
}
|
|
197
200
|
|
|
198
201
|
export function getPriceCurrencyOptions(price: TPrice): PriceCurrency[] {
|