@blocklet/payment-react 1.15.7 → 1.15.8
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/libs/api.js +2 -2
- package/es/payment/form/index.js +2 -1
- package/es/payment/form/stripe.d.ts +8 -2
- package/es/payment/form/stripe.js +16 -3
- package/lib/libs/api.js +2 -2
- package/lib/payment/form/index.js +2 -1
- package/lib/payment/form/stripe.d.ts +8 -2
- package/lib/payment/form/stripe.js +11 -4
- package/package.json +3 -3
- package/src/libs/api.ts +3 -2
- package/src/payment/form/index.tsx +1 -0
- package/src/payment/form/stripe.tsx +17 -2
package/es/libs/api.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getLocale } from "@arcblock/ux/lib/Locale/context";
|
|
2
|
-
import
|
|
2
|
+
import { createAxios } from "@blocklet/js-sdk";
|
|
3
3
|
import isNull from "lodash/isNull";
|
|
4
4
|
import { getPrefix } from "./util.js";
|
|
5
|
-
const api =
|
|
5
|
+
const api = createAxios();
|
|
6
6
|
api.interceptors.request.use(
|
|
7
7
|
(config) => {
|
|
8
8
|
const prefix = getPrefix();
|
package/es/payment/form/index.js
CHANGED
|
@@ -356,7 +356,8 @@ export default function PaymentForm({
|
|
|
356
356
|
customer: state.customer,
|
|
357
357
|
mode: checkoutSession.mode,
|
|
358
358
|
onConfirm: onStripeConfirm,
|
|
359
|
-
onCancel: onStripeCancel
|
|
359
|
+
onCancel: onStripeCancel,
|
|
360
|
+
returnUrl: checkoutSession?.success_url
|
|
360
361
|
}
|
|
361
362
|
)
|
|
362
363
|
] }) }),
|
|
@@ -8,6 +8,12 @@ type StripeCheckoutProps = {
|
|
|
8
8
|
customer: TCustomer;
|
|
9
9
|
onConfirm: Function;
|
|
10
10
|
onCancel: Function;
|
|
11
|
+
returnUrl?: string;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
declare function StripeCheckout({ clientSecret, intentType, publicKey, mode, customer, onConfirm, onCancel, returnUrl, }: StripeCheckoutProps): import("react").JSX.Element;
|
|
14
|
+
declare namespace StripeCheckout {
|
|
15
|
+
var defaultProps: {
|
|
16
|
+
returnUrl: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export default StripeCheckout;
|
|
@@ -9,7 +9,14 @@ import { Elements, PaymentElement, useElements, useStripe } from "@stripe/react-
|
|
|
9
9
|
import { loadStripe } from "@stripe/stripe-js";
|
|
10
10
|
import { useSetState } from "ahooks";
|
|
11
11
|
import { useEffect, useCallback } from "react";
|
|
12
|
-
function StripeCheckoutForm({
|
|
12
|
+
function StripeCheckoutForm({
|
|
13
|
+
clientSecret,
|
|
14
|
+
intentType,
|
|
15
|
+
customer,
|
|
16
|
+
mode,
|
|
17
|
+
onConfirm,
|
|
18
|
+
returnUrl = ""
|
|
19
|
+
}) {
|
|
13
20
|
const stripe = useStripe();
|
|
14
21
|
const elements = useElements();
|
|
15
22
|
const { t } = useLocaleContext();
|
|
@@ -54,6 +61,7 @@ function StripeCheckoutForm({ clientSecret, intentType, customer, mode, onConfir
|
|
|
54
61
|
elements,
|
|
55
62
|
redirect: "if_required",
|
|
56
63
|
confirmParams: {
|
|
64
|
+
return_url: returnUrl || window.location.href,
|
|
57
65
|
payment_method_data: {
|
|
58
66
|
billing_details: {
|
|
59
67
|
name: customer.name,
|
|
@@ -124,7 +132,8 @@ export default function StripeCheckout({
|
|
|
124
132
|
mode,
|
|
125
133
|
customer,
|
|
126
134
|
onConfirm,
|
|
127
|
-
onCancel
|
|
135
|
+
onCancel,
|
|
136
|
+
returnUrl = ""
|
|
128
137
|
}) {
|
|
129
138
|
const stripePromise = loadStripe(publicKey);
|
|
130
139
|
const { t } = useLocaleContext();
|
|
@@ -154,9 +163,13 @@ export default function StripeCheckout({
|
|
|
154
163
|
intentType,
|
|
155
164
|
mode,
|
|
156
165
|
customer,
|
|
157
|
-
onConfirm
|
|
166
|
+
onConfirm,
|
|
167
|
+
returnUrl
|
|
158
168
|
}
|
|
159
169
|
) })
|
|
160
170
|
}
|
|
161
171
|
);
|
|
162
172
|
}
|
|
173
|
+
StripeCheckout.defaultProps = {
|
|
174
|
+
returnUrl: ""
|
|
175
|
+
};
|
package/lib/libs/api.js
CHANGED
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
8
|
-
var
|
|
8
|
+
var _jsSdk = require("@blocklet/js-sdk");
|
|
9
9
|
var _isNull = _interopRequireDefault(require("lodash/isNull"));
|
|
10
10
|
var _util = require("./util");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
const api =
|
|
12
|
+
const api = (0, _jsSdk.createAxios)();
|
|
13
13
|
api.interceptors.request.use(config => {
|
|
14
14
|
const prefix = (0, _util.getPrefix)();
|
|
15
15
|
config.baseURL = prefix || "";
|
|
@@ -420,7 +420,8 @@ function PaymentForm({
|
|
|
420
420
|
customer: state.customer,
|
|
421
421
|
mode: checkoutSession.mode,
|
|
422
422
|
onConfirm: onStripeConfirm,
|
|
423
|
-
onCancel: onStripeCancel
|
|
423
|
+
onCancel: onStripeCancel,
|
|
424
|
+
returnUrl: checkoutSession?.success_url
|
|
424
425
|
})]
|
|
425
426
|
})
|
|
426
427
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
@@ -8,6 +8,12 @@ type StripeCheckoutProps = {
|
|
|
8
8
|
customer: TCustomer;
|
|
9
9
|
onConfirm: Function;
|
|
10
10
|
onCancel: Function;
|
|
11
|
+
returnUrl?: string;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
declare function StripeCheckout({ clientSecret, intentType, publicKey, mode, customer, onConfirm, onCancel, returnUrl, }: StripeCheckoutProps): import("react").JSX.Element;
|
|
14
|
+
declare namespace StripeCheckout {
|
|
15
|
+
var defaultProps: {
|
|
16
|
+
returnUrl: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export default StripeCheckout;
|
|
@@ -21,7 +21,8 @@ function StripeCheckoutForm({
|
|
|
21
21
|
intentType,
|
|
22
22
|
customer,
|
|
23
23
|
mode,
|
|
24
|
-
onConfirm
|
|
24
|
+
onConfirm,
|
|
25
|
+
returnUrl = ""
|
|
25
26
|
}) {
|
|
26
27
|
const stripe = (0, _reactStripeJs.useStripe)();
|
|
27
28
|
const elements = (0, _reactStripeJs.useElements)();
|
|
@@ -79,6 +80,7 @@ function StripeCheckoutForm({
|
|
|
79
80
|
elements,
|
|
80
81
|
redirect: "if_required",
|
|
81
82
|
confirmParams: {
|
|
83
|
+
return_url: returnUrl || window.location.href,
|
|
82
84
|
payment_method_data: {
|
|
83
85
|
billing_details: {
|
|
84
86
|
name: customer.name,
|
|
@@ -172,7 +174,8 @@ function StripeCheckout({
|
|
|
172
174
|
mode,
|
|
173
175
|
customer,
|
|
174
176
|
onConfirm,
|
|
175
|
-
onCancel
|
|
177
|
+
onCancel,
|
|
178
|
+
returnUrl = ""
|
|
176
179
|
}) {
|
|
177
180
|
const stripePromise = (0, _stripeJs.loadStripe)(publicKey);
|
|
178
181
|
const {
|
|
@@ -209,8 +212,12 @@ function StripeCheckout({
|
|
|
209
212
|
intentType,
|
|
210
213
|
mode,
|
|
211
214
|
customer,
|
|
212
|
-
onConfirm
|
|
215
|
+
onConfirm,
|
|
216
|
+
returnUrl
|
|
213
217
|
})
|
|
214
218
|
})
|
|
215
219
|
});
|
|
216
|
-
}
|
|
220
|
+
}
|
|
221
|
+
StripeCheckout.defaultProps = {
|
|
222
|
+
returnUrl: ""
|
|
223
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.8",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@babel/core": "^7.25.2",
|
|
93
93
|
"@babel/preset-env": "^7.25.2",
|
|
94
94
|
"@babel/preset-react": "^7.24.7",
|
|
95
|
-
"@blocklet/payment-types": "1.15.
|
|
95
|
+
"@blocklet/payment-types": "1.15.8",
|
|
96
96
|
"@storybook/addon-essentials": "^7.6.20",
|
|
97
97
|
"@storybook/addon-interactions": "^7.6.20",
|
|
98
98
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
"vite-plugin-babel": "^1.2.0",
|
|
123
123
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
124
124
|
},
|
|
125
|
-
"gitHead": "
|
|
125
|
+
"gitHead": "d0e3c23bed5a41a9b16554fc3b7458e8dee4fd60"
|
|
126
126
|
}
|
package/src/libs/api.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getLocale } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
-
|
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
+
import { createAxios } from '@blocklet/js-sdk';
|
|
3
4
|
import isNull from 'lodash/isNull';
|
|
4
5
|
|
|
5
6
|
import { getPrefix } from './util';
|
|
6
7
|
|
|
7
|
-
const api =
|
|
8
|
+
const api = createAxios();
|
|
8
9
|
|
|
9
10
|
api.interceptors.request.use(
|
|
10
11
|
(config) => {
|
|
@@ -16,10 +16,18 @@ type StripeCheckoutFormProps = {
|
|
|
16
16
|
customer: TCustomer;
|
|
17
17
|
mode: string;
|
|
18
18
|
onConfirm: Function;
|
|
19
|
+
returnUrl: string;
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
// @doc https://stripe.com/docs/js/elements_object/create_payment_element
|
|
22
|
-
function StripeCheckoutForm({
|
|
23
|
+
function StripeCheckoutForm({
|
|
24
|
+
clientSecret,
|
|
25
|
+
intentType,
|
|
26
|
+
customer,
|
|
27
|
+
mode,
|
|
28
|
+
onConfirm,
|
|
29
|
+
returnUrl = '',
|
|
30
|
+
}: StripeCheckoutFormProps) {
|
|
23
31
|
const stripe = useStripe();
|
|
24
32
|
const elements = useElements();
|
|
25
33
|
const { t } = useLocaleContext();
|
|
@@ -72,6 +80,7 @@ function StripeCheckoutForm({ clientSecret, intentType, customer, mode, onConfir
|
|
|
72
80
|
elements,
|
|
73
81
|
redirect: 'if_required',
|
|
74
82
|
confirmParams: {
|
|
83
|
+
return_url: returnUrl || window.location.href,
|
|
75
84
|
payment_method_data: {
|
|
76
85
|
billing_details: {
|
|
77
86
|
name: customer.name,
|
|
@@ -82,7 +91,6 @@ function StripeCheckoutForm({ clientSecret, intentType, customer, mode, onConfir
|
|
|
82
91
|
},
|
|
83
92
|
},
|
|
84
93
|
});
|
|
85
|
-
|
|
86
94
|
setState({ confirming: false });
|
|
87
95
|
if (error) {
|
|
88
96
|
if (error.type === 'validation_error') {
|
|
@@ -150,6 +158,7 @@ type StripeCheckoutProps = {
|
|
|
150
158
|
customer: TCustomer;
|
|
151
159
|
onConfirm: Function;
|
|
152
160
|
onCancel: Function;
|
|
161
|
+
returnUrl?: string;
|
|
153
162
|
};
|
|
154
163
|
|
|
155
164
|
export default function StripeCheckout({
|
|
@@ -160,6 +169,7 @@ export default function StripeCheckout({
|
|
|
160
169
|
customer,
|
|
161
170
|
onConfirm,
|
|
162
171
|
onCancel,
|
|
172
|
+
returnUrl = '',
|
|
163
173
|
}: StripeCheckoutProps) {
|
|
164
174
|
const stripePromise = loadStripe(publicKey);
|
|
165
175
|
const { t } = useLocaleContext();
|
|
@@ -191,8 +201,13 @@ export default function StripeCheckout({
|
|
|
191
201
|
mode={mode}
|
|
192
202
|
customer={customer}
|
|
193
203
|
onConfirm={onConfirm}
|
|
204
|
+
returnUrl={returnUrl}
|
|
194
205
|
/>
|
|
195
206
|
</Elements>
|
|
196
207
|
</Dialog>
|
|
197
208
|
);
|
|
198
209
|
}
|
|
210
|
+
|
|
211
|
+
StripeCheckout.defaultProps = {
|
|
212
|
+
returnUrl: '',
|
|
213
|
+
};
|