@blocklet/payment-react 1.13.237 → 1.13.238
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/payment/form/index.js +13 -14
- package/lib/payment/form/index.js +12 -13
- package/package.json +3 -3
- package/src/payment/form/index.tsx +15 -15
package/es/payment/form/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useTheme } from "@arcblock/ux/lib/Theme";
|
|
|
5
5
|
import Toast from "@arcblock/ux/lib/Toast";
|
|
6
6
|
import { LoadingButton } from "@mui/lab";
|
|
7
7
|
import { Fade, InputAdornment, Stack, Typography } from "@mui/material";
|
|
8
|
-
import { useCreation, useSetState, useSize } from "ahooks";
|
|
8
|
+
import { useCreation, useMemoizedFn, useSetState, useSize } from "ahooks";
|
|
9
9
|
import { PhoneNumberUtil } from "google-libphonenumber";
|
|
10
10
|
import pWaitFor from "p-wait-for";
|
|
11
11
|
import { useEffect, useState } from "react";
|
|
@@ -99,6 +99,17 @@ export default function PaymentForm({
|
|
|
99
99
|
}
|
|
100
100
|
return false;
|
|
101
101
|
}, [domSize, theme]);
|
|
102
|
+
const afterUserLoggedIn = useMemoizedFn(() => {
|
|
103
|
+
if (hasDidWallet(session.user)) {
|
|
104
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
105
|
+
} else {
|
|
106
|
+
session.bindWallet(() => {
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
109
|
+
}, 2e3);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
102
113
|
const payee = getStatementDescriptor(checkoutSession.line_items);
|
|
103
114
|
let buttonText = "";
|
|
104
115
|
if (paymentLink?.donation_settings) {
|
|
@@ -237,19 +248,7 @@ export default function PaymentForm({
|
|
|
237
248
|
} else {
|
|
238
249
|
session?.login(() => {
|
|
239
250
|
setState({ submitting: true });
|
|
240
|
-
onUserLoggedIn().then(() => {
|
|
241
|
-
if (hasDidWallet(session.user)) {
|
|
242
|
-
setTimeout(() => {
|
|
243
|
-
handleSubmit(onFormSubmit, onFormError)();
|
|
244
|
-
}, 80);
|
|
245
|
-
} else {
|
|
246
|
-
session.bindWallet(() => {
|
|
247
|
-
setTimeout(() => {
|
|
248
|
-
handleSubmit(onFormSubmit, onFormError)();
|
|
249
|
-
}, 2e3);
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}).catch((err) => {
|
|
251
|
+
onUserLoggedIn().then(afterUserLoggedIn).catch((err) => {
|
|
253
252
|
console.error(err);
|
|
254
253
|
setState({ submitting: false });
|
|
255
254
|
});
|
|
@@ -121,6 +121,17 @@ function PaymentForm({
|
|
|
121
121
|
}
|
|
122
122
|
return false;
|
|
123
123
|
}, [domSize, theme]);
|
|
124
|
+
const afterUserLoggedIn = (0, _ahooks.useMemoizedFn)(() => {
|
|
125
|
+
if (hasDidWallet(session.user)) {
|
|
126
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
127
|
+
} else {
|
|
128
|
+
session.bindWallet(() => {
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
131
|
+
}, 2e3);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
124
135
|
const payee = (0, _util.getStatementDescriptor)(checkoutSession.line_items);
|
|
125
136
|
let buttonText = "";
|
|
126
137
|
if (paymentLink?.donation_settings) {
|
|
@@ -292,19 +303,7 @@ function PaymentForm({
|
|
|
292
303
|
setState({
|
|
293
304
|
submitting: true
|
|
294
305
|
});
|
|
295
|
-
onUserLoggedIn().then((
|
|
296
|
-
if (hasDidWallet(session.user)) {
|
|
297
|
-
setTimeout(() => {
|
|
298
|
-
handleSubmit(onFormSubmit, onFormError)();
|
|
299
|
-
}, 80);
|
|
300
|
-
} else {
|
|
301
|
-
session.bindWallet(() => {
|
|
302
|
-
setTimeout(() => {
|
|
303
|
-
handleSubmit(onFormSubmit, onFormError)();
|
|
304
|
-
}, 2e3);
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}).catch(err => {
|
|
306
|
+
onUserLoggedIn().then(afterUserLoggedIn).catch(err => {
|
|
308
307
|
console.error(err);
|
|
309
308
|
setState({
|
|
310
309
|
submitting: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.238",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@babel/core": "^7.24.4",
|
|
91
91
|
"@babel/preset-env": "^7.24.4",
|
|
92
92
|
"@babel/preset-react": "^7.24.1",
|
|
93
|
-
"@blocklet/payment-types": "1.13.
|
|
93
|
+
"@blocklet/payment-types": "1.13.238",
|
|
94
94
|
"@storybook/addon-essentials": "^7.6.17",
|
|
95
95
|
"@storybook/addon-interactions": "^7.6.17",
|
|
96
96
|
"@storybook/addon-links": "^7.6.17",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"vite-plugin-babel": "^1.2.0",
|
|
120
120
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "3476a64bdb10cf042551f55f087c5e1b30717894"
|
|
123
123
|
}
|
|
@@ -6,7 +6,7 @@ import Toast from '@arcblock/ux/lib/Toast';
|
|
|
6
6
|
import type { TCustomer, TPaymentIntent, TPaymentMethodExpanded } from '@blocklet/payment-types';
|
|
7
7
|
import { LoadingButton } from '@mui/lab';
|
|
8
8
|
import { Fade, InputAdornment, Stack, Typography } from '@mui/material';
|
|
9
|
-
import { useCreation, useSetState, useSize } from 'ahooks';
|
|
9
|
+
import { useCreation, useMemoizedFn, useSetState, useSize } from 'ahooks';
|
|
10
10
|
import { PhoneNumberUtil } from 'google-libphonenumber';
|
|
11
11
|
import pWaitFor from 'p-wait-for';
|
|
12
12
|
import { useEffect, useState } from 'react';
|
|
@@ -146,6 +146,19 @@ export default function PaymentForm({
|
|
|
146
146
|
return false;
|
|
147
147
|
}, [domSize, theme]);
|
|
148
148
|
|
|
149
|
+
const afterUserLoggedIn = useMemoizedFn(() => {
|
|
150
|
+
if (hasDidWallet(session.user)) {
|
|
151
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
152
|
+
} else {
|
|
153
|
+
session.bindWallet(() => {
|
|
154
|
+
// timeout required because https://github.com/ArcBlock/ux/issues/1241
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
157
|
+
}, 2000);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
149
162
|
const payee = getStatementDescriptor(checkoutSession.line_items);
|
|
150
163
|
let buttonText = '';
|
|
151
164
|
if (paymentLink?.donation_settings) {
|
|
@@ -294,20 +307,7 @@ export default function PaymentForm({
|
|
|
294
307
|
session?.login(() => {
|
|
295
308
|
setState({ submitting: true });
|
|
296
309
|
onUserLoggedIn()
|
|
297
|
-
.then(
|
|
298
|
-
if (hasDidWallet(session.user)) {
|
|
299
|
-
setTimeout(() => {
|
|
300
|
-
handleSubmit(onFormSubmit, onFormError)();
|
|
301
|
-
}, 80);
|
|
302
|
-
} else {
|
|
303
|
-
session.bindWallet(() => {
|
|
304
|
-
// timeout required because https://github.com/ArcBlock/ux/issues/1241
|
|
305
|
-
setTimeout(() => {
|
|
306
|
-
handleSubmit(onFormSubmit, onFormError)();
|
|
307
|
-
}, 2000);
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
})
|
|
310
|
+
.then(afterUserLoggedIn)
|
|
311
311
|
.catch((err) => {
|
|
312
312
|
console.error(err);
|
|
313
313
|
setState({ submitting: false });
|