payment-kit 1.16.18 → 1.16.19
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/api/src/libs/overdraft-protection.ts +3 -2
- package/blocklet.yml +1 -1
- package/package.json +4 -4
- package/src/components/product/edit-price.tsx +2 -2
- package/src/pages/admin/index.tsx +3 -1
- package/src/pages/admin/products/prices/detail.tsx +1 -1
- package/src/pages/admin/products/products/detail.tsx +6 -2
|
@@ -6,7 +6,8 @@ export const overdraftProtectionKey = 'overdraft-protection';
|
|
|
6
6
|
|
|
7
7
|
export async function ensureOverdraftProtectionPrice(livemode = true) {
|
|
8
8
|
try {
|
|
9
|
-
const
|
|
9
|
+
const lookUpKey = livemode ? overdraftProtectionKey : `${overdraftProtectionKey}-test`;
|
|
10
|
+
const exist = await Price.findOne({ where: { lookup_key: lookUpKey, livemode } });
|
|
10
11
|
if (exist) {
|
|
11
12
|
const product = await Product.findByPk(exist.product_id);
|
|
12
13
|
return {
|
|
@@ -44,7 +45,7 @@ export async function ensureOverdraftProtectionPrice(livemode = true) {
|
|
|
44
45
|
nickname: '',
|
|
45
46
|
type: 'one_time',
|
|
46
47
|
unit_amount: '1',
|
|
47
|
-
lookup_key:
|
|
48
|
+
lookup_key: lookUpKey,
|
|
48
49
|
recurring: {},
|
|
49
50
|
transform_quantity: { divide_by: 1, round: 'up' },
|
|
50
51
|
tiers: [],
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.19",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@arcblock/validator": "^1.18.165",
|
|
54
54
|
"@blocklet/js-sdk": "^1.16.36",
|
|
55
55
|
"@blocklet/logger": "^1.16.36",
|
|
56
|
-
"@blocklet/payment-react": "1.16.
|
|
56
|
+
"@blocklet/payment-react": "1.16.19",
|
|
57
57
|
"@blocklet/sdk": "^1.16.36",
|
|
58
58
|
"@blocklet/ui-react": "^2.11.15",
|
|
59
59
|
"@blocklet/uploader": "^0.1.60",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@abtnode/types": "^1.16.36",
|
|
122
122
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
123
|
-
"@blocklet/payment-types": "1.16.
|
|
123
|
+
"@blocklet/payment-types": "1.16.19",
|
|
124
124
|
"@types/cookie-parser": "^1.4.7",
|
|
125
125
|
"@types/cors": "^2.8.17",
|
|
126
126
|
"@types/debug": "^4.1.12",
|
|
@@ -166,5 +166,5 @@
|
|
|
166
166
|
"parser": "typescript"
|
|
167
167
|
}
|
|
168
168
|
},
|
|
169
|
-
"gitHead": "
|
|
169
|
+
"gitHead": "a033985b46d5c80b56f2ed9dc86d808fb60d9db1"
|
|
170
170
|
}
|
|
@@ -27,7 +27,7 @@ export default function EditPrice({
|
|
|
27
27
|
mode: 'onChange',
|
|
28
28
|
defaultValues: {
|
|
29
29
|
...price,
|
|
30
|
-
unit_amount: fromUnitToToken(price.unit_amount, price.currency
|
|
30
|
+
unit_amount: fromUnitToToken(price.unit_amount, price.currency?.decimal),
|
|
31
31
|
// @ts-ignore
|
|
32
32
|
model: getPricingModel(price as any),
|
|
33
33
|
metadata: isEmpty(price.metadata)
|
|
@@ -40,7 +40,7 @@ export default function EditPrice({
|
|
|
40
40
|
}
|
|
41
41
|
: DEFAULT_PRICE.recurring,
|
|
42
42
|
currency_options: cloneDeep(price.currency_options).map((x: any) => {
|
|
43
|
-
x.unit_amount = fromUnitToToken(x.unit_amount, x.currency
|
|
43
|
+
x.unit_amount = fromUnitToToken(x.unit_amount, x.currency?.decimal);
|
|
44
44
|
return x;
|
|
45
45
|
}),
|
|
46
46
|
},
|
|
@@ -122,7 +122,9 @@ function Admin() {
|
|
|
122
122
|
</label>
|
|
123
123
|
</Stack>
|
|
124
124
|
</Stack>
|
|
125
|
-
<div className="page-content"
|
|
125
|
+
<div className="page-content" key={settings.livemode ? 'live' : 'test'}>
|
|
126
|
+
{isValidElement(TabComponent) ? TabComponent : <TabComponent />}
|
|
127
|
+
</div>
|
|
126
128
|
</>
|
|
127
129
|
);
|
|
128
130
|
}
|
|
@@ -294,7 +294,7 @@ export default function PriceDetail(props: { id: string }) {
|
|
|
294
294
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
295
295
|
customBodyRenderLite: (_: any, index: number) => {
|
|
296
296
|
const item = data.currency_options[index] as any;
|
|
297
|
-
return <Currency logo={item.currency
|
|
297
|
+
return <Currency logo={item.currency?.logo} name={item.currency?.symbol} />;
|
|
298
298
|
},
|
|
299
299
|
},
|
|
300
300
|
},
|
|
@@ -46,7 +46,7 @@ export default function ProductDetail(props: { id: string }) {
|
|
|
46
46
|
const { t, locale } = useLocaleContext();
|
|
47
47
|
const { isMobile } = useMobile();
|
|
48
48
|
const navigate = useNavigate();
|
|
49
|
-
const { settings } = usePaymentContext();
|
|
49
|
+
const { settings, setLivemode } = usePaymentContext();
|
|
50
50
|
const [state, setState] = useSetState({
|
|
51
51
|
adding: {
|
|
52
52
|
price: false,
|
|
@@ -62,7 +62,11 @@ export default function ProductDetail(props: { id: string }) {
|
|
|
62
62
|
},
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
const { loading, error, data, runAsync } = useRequest(() => getProduct(props.id)
|
|
65
|
+
const { loading, error, data, runAsync } = useRequest(() => getProduct(props.id), {
|
|
66
|
+
onSuccess: (res) => {
|
|
67
|
+
setLivemode(!!res.livemode);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
66
70
|
|
|
67
71
|
if (error) {
|
|
68
72
|
return <Alert severity="error">{error.message}</Alert>;
|