@blocklet/payment-react 1.13.113
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/LICENSE +13 -0
- package/README.md +29 -0
- package/babel.config.es.js +8 -0
- package/build.config.ts +29 -0
- package/es/api.d.ts +2 -0
- package/es/api.js +18 -0
- package/es/checkout/index.d.ts +15 -0
- package/es/checkout/index.js +61 -0
- package/es/components/input.d.ts +23 -0
- package/es/components/input.js +44 -0
- package/es/components/livemode.d.ts +2 -0
- package/es/components/livemode.js +24 -0
- package/es/components/pricing-table.d.ts +18 -0
- package/es/components/pricing-table.js +175 -0
- package/es/components/status.d.ts +3 -0
- package/es/components/status.js +20 -0
- package/es/components/switch.d.ts +6 -0
- package/es/components/switch.js +42 -0
- package/es/contexts/payment.d.ts +29 -0
- package/es/contexts/payment.js +45 -0
- package/es/dayjs.d.ts +2 -0
- package/es/dayjs.js +14 -0
- package/es/index.d.ts +16 -0
- package/es/index.js +29 -0
- package/es/locales/en.d.ts +2 -0
- package/es/locales/en.js +213 -0
- package/es/locales/index.d.ts +10 -0
- package/es/locales/index.js +20 -0
- package/es/locales/zh.d.ts +2 -0
- package/es/locales/zh.js +213 -0
- package/es/payment/amount.d.ts +12 -0
- package/es/payment/amount.js +22 -0
- package/es/payment/error.d.ts +13 -0
- package/es/payment/error.js +12 -0
- package/es/payment/footer.d.ts +4 -0
- package/es/payment/footer.js +9 -0
- package/es/payment/form/addon.d.ts +2 -0
- package/es/payment/form/addon.js +14 -0
- package/es/payment/form/address.d.ts +7 -0
- package/es/payment/form/address.js +119 -0
- package/es/payment/form/index.d.ts +9 -0
- package/es/payment/form/index.js +337 -0
- package/es/payment/form/phone.d.ts +4 -0
- package/es/payment/form/phone.js +97 -0
- package/es/payment/form/stripe.d.ts +13 -0
- package/es/payment/form/stripe.js +158 -0
- package/es/payment/header.d.ts +7 -0
- package/es/payment/header.js +29 -0
- package/es/payment/index.d.ts +28 -0
- package/es/payment/index.js +327 -0
- package/es/payment/product-card.d.ts +21 -0
- package/es/payment/product-card.js +34 -0
- package/es/payment/product-item.d.ts +19 -0
- package/es/payment/product-item.js +107 -0
- package/es/payment/product-skeleton.d.ts +4 -0
- package/es/payment/product-skeleton.js +34 -0
- package/es/payment/skeleton/overview.d.ts +2 -0
- package/es/payment/skeleton/overview.js +13 -0
- package/es/payment/skeleton/payment.d.ts +2 -0
- package/es/payment/skeleton/payment.js +19 -0
- package/es/payment/success.d.ts +8 -0
- package/es/payment/success.js +164 -0
- package/es/payment/summary.d.ts +12 -0
- package/es/payment/summary.js +178 -0
- package/es/theme.d.ts +1 -0
- package/es/theme.js +17 -0
- package/es/types/index.d.ts +19 -0
- package/es/types/index.js +0 -0
- package/es/types/shims.d.ts +18 -0
- package/es/util.d.ts +52 -0
- package/es/util.js +390 -0
- package/lib/api.d.ts +2 -0
- package/lib/api.js +26 -0
- package/lib/checkout/index.d.ts +15 -0
- package/lib/checkout/index.js +83 -0
- package/lib/components/input.d.ts +23 -0
- package/lib/components/input.js +72 -0
- package/lib/components/livemode.d.ts +2 -0
- package/lib/components/livemode.js +29 -0
- package/lib/components/pricing-table.d.ts +18 -0
- package/lib/components/pricing-table.js +232 -0
- package/lib/components/status.d.ts +3 -0
- package/lib/components/status.js +23 -0
- package/lib/components/switch.d.ts +6 -0
- package/lib/components/switch.js +51 -0
- package/lib/contexts/payment.d.ts +29 -0
- package/lib/contexts/payment.js +73 -0
- package/lib/dayjs.d.ts +2 -0
- package/lib/dayjs.js +21 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +143 -0
- package/lib/locales/en.d.ts +2 -0
- package/lib/locales/en.js +220 -0
- package/lib/locales/index.d.ts +10 -0
- package/lib/locales/index.js +33 -0
- package/lib/locales/zh.d.ts +2 -0
- package/lib/locales/zh.js +220 -0
- package/lib/payment/amount.d.ts +12 -0
- package/lib/payment/amount.js +28 -0
- package/lib/payment/error.d.ts +13 -0
- package/lib/payment/error.js +52 -0
- package/lib/payment/footer.d.ts +4 -0
- package/lib/payment/footer.js +25 -0
- package/lib/payment/form/addon.d.ts +2 -0
- package/lib/payment/form/addon.js +37 -0
- package/lib/payment/form/address.d.ts +7 -0
- package/lib/payment/form/address.js +152 -0
- package/lib/payment/form/index.d.ts +9 -0
- package/lib/payment/form/index.js +464 -0
- package/lib/payment/form/phone.d.ts +4 -0
- package/lib/payment/form/phone.js +133 -0
- package/lib/payment/form/stripe.d.ts +13 -0
- package/lib/payment/form/stripe.js +213 -0
- package/lib/payment/header.d.ts +7 -0
- package/lib/payment/header.js +58 -0
- package/lib/payment/index.d.ts +28 -0
- package/lib/payment/index.js +382 -0
- package/lib/payment/product-card.d.ts +21 -0
- package/lib/payment/product-card.js +81 -0
- package/lib/payment/product-item.d.ts +19 -0
- package/lib/payment/product-item.js +160 -0
- package/lib/payment/product-skeleton.d.ts +4 -0
- package/lib/payment/product-skeleton.js +71 -0
- package/lib/payment/skeleton/overview.d.ts +2 -0
- package/lib/payment/skeleton/overview.js +48 -0
- package/lib/payment/skeleton/payment.d.ts +2 -0
- package/lib/payment/skeleton/payment.js +54 -0
- package/lib/payment/success.d.ts +8 -0
- package/lib/payment/success.js +215 -0
- package/lib/payment/summary.d.ts +12 -0
- package/lib/payment/summary.js +225 -0
- package/lib/theme.d.ts +1 -0
- package/lib/theme.js +19 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/index.js +1 -0
- package/lib/types/shims.d.ts +18 -0
- package/lib/util.d.ts +52 -0
- package/lib/util.js +487 -0
- package/package.json +104 -0
- package/src/api.ts +24 -0
- package/src/checkout/index.tsx +74 -0
- package/src/components/input.tsx +58 -0
- package/src/components/livemode.tsx +23 -0
- package/src/components/pricing-table.tsx +207 -0
- package/src/components/status.tsx +19 -0
- package/src/components/switch.tsx +48 -0
- package/src/contexts/payment.tsx +74 -0
- package/src/dayjs.ts +17 -0
- package/src/index.ts +32 -0
- package/src/locales/en.tsx +218 -0
- package/src/locales/index.tsx +30 -0
- package/src/locales/zh.tsx +214 -0
- package/src/payment/amount.tsx +24 -0
- package/src/payment/error.tsx +29 -0
- package/src/payment/footer.tsx +12 -0
- package/src/payment/form/addon.tsx +24 -0
- package/src/payment/form/address.tsx +119 -0
- package/src/payment/form/index.tsx +401 -0
- package/src/payment/form/phone.tsx +103 -0
- package/src/payment/form/stripe.tsx +195 -0
- package/src/payment/header.tsx +40 -0
- package/src/payment/index.tsx +367 -0
- package/src/payment/product-card.tsx +55 -0
- package/src/payment/product-item.tsx +121 -0
- package/src/payment/product-skeleton.tsx +39 -0
- package/src/payment/skeleton/overview.tsx +21 -0
- package/src/payment/skeleton/payment.tsx +35 -0
- package/src/payment/success.tsx +186 -0
- package/src/payment/summary.tsx +198 -0
- package/src/theme.ts +18 -0
- package/src/types/index.ts +29 -0
- package/src/types/shims.d.ts +18 -0
- package/src/util.ts +543 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = ProductSkeleton;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
function ProductSkeleton({
|
|
10
|
+
count
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
13
|
+
in: true,
|
|
14
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
15
|
+
direction: "column",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
padding: 4,
|
|
18
|
+
spacing: 1,
|
|
19
|
+
sx: {
|
|
20
|
+
width: 320,
|
|
21
|
+
border: "1px solid #eee",
|
|
22
|
+
borderRadius: 1,
|
|
23
|
+
transition: "border-color 0.3s ease 0s, box-shadow 0.3s ease 0s",
|
|
24
|
+
boxShadow: "0 4px 8px rgba(0, 0, 0, 20%)",
|
|
25
|
+
"&:hover": {
|
|
26
|
+
borderColor: "#ddd",
|
|
27
|
+
boxShadow: "0 8px 16px rgba(0, 0, 0, 20%)"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
31
|
+
component: "div",
|
|
32
|
+
variant: "h4",
|
|
33
|
+
sx: {
|
|
34
|
+
width: "50%"
|
|
35
|
+
},
|
|
36
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
37
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
|
|
38
|
+
variant: "text",
|
|
39
|
+
sx: {
|
|
40
|
+
fontSize: "1rem",
|
|
41
|
+
width: "60%"
|
|
42
|
+
}
|
|
43
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
44
|
+
component: "div",
|
|
45
|
+
variant: "h3",
|
|
46
|
+
sx: {
|
|
47
|
+
width: "60%"
|
|
48
|
+
},
|
|
49
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
50
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
51
|
+
component: "div",
|
|
52
|
+
variant: "h3",
|
|
53
|
+
sx: {
|
|
54
|
+
width: "100%"
|
|
55
|
+
},
|
|
56
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
57
|
+
}), Array.from({
|
|
58
|
+
length: count
|
|
59
|
+
}).map((_, i) =>
|
|
60
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
61
|
+
/* @__PURE__ */
|
|
62
|
+
(0, _jsxRuntime.jsx)(_material.Skeleton, {
|
|
63
|
+
variant: "text",
|
|
64
|
+
sx: {
|
|
65
|
+
fontSize: "1rem",
|
|
66
|
+
width: "60%"
|
|
67
|
+
}
|
|
68
|
+
}, i))]
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = OverviewSkeleton;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
function OverviewSkeleton() {
|
|
10
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
11
|
+
in: true,
|
|
12
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
13
|
+
direction: "column",
|
|
14
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
15
|
+
direction: "row",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
spacing: 2,
|
|
18
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
|
|
19
|
+
variant: "circular",
|
|
20
|
+
width: 32,
|
|
21
|
+
height: 32
|
|
22
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
|
|
23
|
+
variant: "text",
|
|
24
|
+
sx: {
|
|
25
|
+
fontSize: "2rem",
|
|
26
|
+
width: "40%"
|
|
27
|
+
}
|
|
28
|
+
})]
|
|
29
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
30
|
+
mt: 3,
|
|
31
|
+
component: "div",
|
|
32
|
+
variant: "h4",
|
|
33
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
34
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
35
|
+
component: "div",
|
|
36
|
+
variant: "h2",
|
|
37
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
38
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
|
|
39
|
+
sx: {
|
|
40
|
+
mt: 3
|
|
41
|
+
},
|
|
42
|
+
variant: "rounded",
|
|
43
|
+
width: 200,
|
|
44
|
+
height: 200
|
|
45
|
+
})]
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = PaymentSkeleton;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
function PaymentSkeleton() {
|
|
10
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
11
|
+
in: true,
|
|
12
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
13
|
+
direction: "column",
|
|
14
|
+
spacing: 3,
|
|
15
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
|
|
16
|
+
variant: "text",
|
|
17
|
+
sx: {
|
|
18
|
+
fontSize: "2rem",
|
|
19
|
+
width: "40%"
|
|
20
|
+
}
|
|
21
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
22
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
23
|
+
component: "div",
|
|
24
|
+
variant: "h4",
|
|
25
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
26
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
27
|
+
component: "div",
|
|
28
|
+
variant: "h1",
|
|
29
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
30
|
+
})]
|
|
31
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
32
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
33
|
+
component: "div",
|
|
34
|
+
variant: "h4",
|
|
35
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
36
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
37
|
+
component: "div",
|
|
38
|
+
variant: "h1",
|
|
39
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
40
|
+
})]
|
|
41
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
42
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
43
|
+
component: "div",
|
|
44
|
+
variant: "h4",
|
|
45
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
46
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
47
|
+
component: "div",
|
|
48
|
+
variant: "h1",
|
|
49
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {})
|
|
50
|
+
})]
|
|
51
|
+
})]
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = PaymentSuccess;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
var _system = require("@mui/system");
|
|
11
|
+
var _ufo = require("ufo");
|
|
12
|
+
var _payment = require("../contexts/payment");
|
|
13
|
+
function PaymentSuccess({
|
|
14
|
+
message,
|
|
15
|
+
action,
|
|
16
|
+
payee
|
|
17
|
+
}) {
|
|
18
|
+
const {
|
|
19
|
+
t
|
|
20
|
+
} = (0, _context.useLocaleContext)();
|
|
21
|
+
const {
|
|
22
|
+
prefix
|
|
23
|
+
} = (0, _payment.usePaymentContext)();
|
|
24
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Grow, {
|
|
25
|
+
in: true,
|
|
26
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
27
|
+
direction: "column",
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "center",
|
|
30
|
+
sx: {
|
|
31
|
+
height: 360
|
|
32
|
+
},
|
|
33
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(Div, {
|
|
34
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)("div", {
|
|
35
|
+
className: "check-icon",
|
|
36
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
|
|
37
|
+
className: "icon-line line-tip"
|
|
38
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
|
|
39
|
+
className: "icon-line line-long"
|
|
40
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)("div", {
|
|
41
|
+
className: "icon-circle"
|
|
42
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)("div", {
|
|
43
|
+
className: "icon-fix"
|
|
44
|
+
})]
|
|
45
|
+
})
|
|
46
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
47
|
+
variant: "h5",
|
|
48
|
+
color: "text.primary",
|
|
49
|
+
mb: 3,
|
|
50
|
+
children: message
|
|
51
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
52
|
+
variant: "body1",
|
|
53
|
+
color: "text.secondary",
|
|
54
|
+
textAlign: "center",
|
|
55
|
+
children: t("payment.checkout.completed.tip", {
|
|
56
|
+
payee
|
|
57
|
+
})
|
|
58
|
+
}), ["subscription", "setup"].includes(action) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
59
|
+
textAlign: "center",
|
|
60
|
+
sx: {
|
|
61
|
+
mt: 2
|
|
62
|
+
},
|
|
63
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Link, {
|
|
64
|
+
href: (0, _ufo.joinURL)(prefix, "/customer"),
|
|
65
|
+
children: t("payment.checkout.portal", {
|
|
66
|
+
payee
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
})]
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const Div = (0, _system.styled)("div")`
|
|
74
|
+
width: 80px;
|
|
75
|
+
height: 115px;
|
|
76
|
+
|
|
77
|
+
.check-icon {
|
|
78
|
+
width: 80px;
|
|
79
|
+
height: 80px;
|
|
80
|
+
position: relative;
|
|
81
|
+
border-radius: 50%;
|
|
82
|
+
box-sizing: content-box;
|
|
83
|
+
border: 4px solid ${props => props.theme.palette.success.main};
|
|
84
|
+
}
|
|
85
|
+
.check-icon::before {
|
|
86
|
+
top: 3px;
|
|
87
|
+
left: -2px;
|
|
88
|
+
width: 30px;
|
|
89
|
+
transform-origin: 100% 50%;
|
|
90
|
+
border-radius: 100px 0 0 100px;
|
|
91
|
+
}
|
|
92
|
+
.check-icon::after {
|
|
93
|
+
top: 0;
|
|
94
|
+
left: 30px;
|
|
95
|
+
width: 60px;
|
|
96
|
+
transform-origin: 0 50%;
|
|
97
|
+
border-radius: 0 100px 100px 0;
|
|
98
|
+
animation: rotate-circle 4.25s ease-in;
|
|
99
|
+
}
|
|
100
|
+
.check-icon::before,
|
|
101
|
+
.check-icon::after {
|
|
102
|
+
content: '';
|
|
103
|
+
height: 100px;
|
|
104
|
+
position: absolute;
|
|
105
|
+
background: #ffffff;
|
|
106
|
+
transform: rotate(-45deg);
|
|
107
|
+
}
|
|
108
|
+
.check-icon .icon-line {
|
|
109
|
+
height: 5px;
|
|
110
|
+
background-color: ${props => props.theme.palette.success.main};
|
|
111
|
+
display: block;
|
|
112
|
+
border-radius: 2px;
|
|
113
|
+
position: absolute;
|
|
114
|
+
z-index: 10;
|
|
115
|
+
}
|
|
116
|
+
.check-icon .icon-line.line-tip {
|
|
117
|
+
top: 46px;
|
|
118
|
+
left: 14px;
|
|
119
|
+
width: 25px;
|
|
120
|
+
transform: rotate(45deg);
|
|
121
|
+
animation: icon-line-tip 0.75s;
|
|
122
|
+
}
|
|
123
|
+
.check-icon .icon-line.line-long {
|
|
124
|
+
top: 38px;
|
|
125
|
+
right: 8px;
|
|
126
|
+
width: 47px;
|
|
127
|
+
transform: rotate(-45deg);
|
|
128
|
+
animation: icon-line-long 0.75s;
|
|
129
|
+
}
|
|
130
|
+
.check-icon .icon-circle {
|
|
131
|
+
top: -4px;
|
|
132
|
+
left: -4px;
|
|
133
|
+
z-index: 10;
|
|
134
|
+
width: 80px;
|
|
135
|
+
height: 80px;
|
|
136
|
+
border-radius: 50%;
|
|
137
|
+
position: absolute;
|
|
138
|
+
box-sizing: content-box;
|
|
139
|
+
border: 4px solid rgba(76, 175, 80, 0.5);
|
|
140
|
+
}
|
|
141
|
+
.check-icon .icon-fix {
|
|
142
|
+
top: 8px;
|
|
143
|
+
width: 5px;
|
|
144
|
+
left: 26px;
|
|
145
|
+
z-index: 1;
|
|
146
|
+
height: 85px;
|
|
147
|
+
position: absolute;
|
|
148
|
+
transform: rotate(-45deg);
|
|
149
|
+
background-color: #ffffff;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@keyframes rotate-circle {
|
|
153
|
+
0% {
|
|
154
|
+
transform: rotate(-45deg);
|
|
155
|
+
}
|
|
156
|
+
5% {
|
|
157
|
+
transform: rotate(-45deg);
|
|
158
|
+
}
|
|
159
|
+
12% {
|
|
160
|
+
transform: rotate(-405deg);
|
|
161
|
+
}
|
|
162
|
+
100% {
|
|
163
|
+
transform: rotate(-405deg);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
@keyframes icon-line-tip {
|
|
167
|
+
0% {
|
|
168
|
+
width: 0;
|
|
169
|
+
left: 1px;
|
|
170
|
+
top: 19px;
|
|
171
|
+
}
|
|
172
|
+
54% {
|
|
173
|
+
width: 0;
|
|
174
|
+
left: 1px;
|
|
175
|
+
top: 19px;
|
|
176
|
+
}
|
|
177
|
+
70% {
|
|
178
|
+
width: 50px;
|
|
179
|
+
left: -8px;
|
|
180
|
+
top: 37px;
|
|
181
|
+
}
|
|
182
|
+
84% {
|
|
183
|
+
width: 17px;
|
|
184
|
+
left: 21px;
|
|
185
|
+
top: 48px;
|
|
186
|
+
}
|
|
187
|
+
100% {
|
|
188
|
+
width: 25px;
|
|
189
|
+
left: 14px;
|
|
190
|
+
top: 45px;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
@keyframes icon-line-long {
|
|
194
|
+
0% {
|
|
195
|
+
width: 0;
|
|
196
|
+
right: 46px;
|
|
197
|
+
top: 54px;
|
|
198
|
+
}
|
|
199
|
+
65% {
|
|
200
|
+
width: 0;
|
|
201
|
+
right: 46px;
|
|
202
|
+
top: 54px;
|
|
203
|
+
}
|
|
204
|
+
84% {
|
|
205
|
+
width: 55px;
|
|
206
|
+
right: 0px;
|
|
207
|
+
top: 35px;
|
|
208
|
+
}
|
|
209
|
+
100% {
|
|
210
|
+
width: 47px;
|
|
211
|
+
right: 8px;
|
|
212
|
+
top: 38px;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
`;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TCheckoutSessionExpanded, TPaymentCurrency } from '@blocklet/payment-types';
|
|
3
|
+
type Props = {
|
|
4
|
+
checkoutSession: TCheckoutSessionExpanded;
|
|
5
|
+
currency: TPaymentCurrency;
|
|
6
|
+
onUpsell: Function;
|
|
7
|
+
onDownsell: Function;
|
|
8
|
+
onApplyCrossSell: Function;
|
|
9
|
+
onCancelCrossSell: Function;
|
|
10
|
+
};
|
|
11
|
+
export default function PaymentSummary({ checkoutSession, currency, onUpsell, onDownsell, onApplyCrossSell, onCancelCrossSell, }: Props): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = PaymentSummary;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
|
+
var _lab = require("@mui/lab");
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
var _ahooks = require("ahooks");
|
|
12
|
+
var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
13
|
+
var _useBus = _interopRequireDefault(require("use-bus"));
|
|
14
|
+
var _api = _interopRequireDefault(require("../api"));
|
|
15
|
+
var _status = _interopRequireDefault(require("../components/status"));
|
|
16
|
+
var _util = require("../util");
|
|
17
|
+
var _amount = _interopRequireDefault(require("./amount"));
|
|
18
|
+
var _productItem = _interopRequireDefault(require("./product-item"));
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
const shake = (0, _material.keyframes)`
|
|
21
|
+
0% {
|
|
22
|
+
transform: rotate(0deg);
|
|
23
|
+
}
|
|
24
|
+
25% {
|
|
25
|
+
transform: rotate(2deg);
|
|
26
|
+
}
|
|
27
|
+
50% {
|
|
28
|
+
transform: rotate(0eg);
|
|
29
|
+
}
|
|
30
|
+
75% {
|
|
31
|
+
transform: rotate(-2deg);
|
|
32
|
+
}
|
|
33
|
+
100% {
|
|
34
|
+
transform: rotate(0deg);
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
async function fetchCrossSell(id) {
|
|
38
|
+
try {
|
|
39
|
+
const {
|
|
40
|
+
data
|
|
41
|
+
} = await _api.default.get(`/api/checkout-sessions/${id}/cross-sell`);
|
|
42
|
+
if (!data.error) {
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
} catch (err) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function PaymentSummary({
|
|
51
|
+
checkoutSession,
|
|
52
|
+
currency,
|
|
53
|
+
onUpsell,
|
|
54
|
+
onDownsell,
|
|
55
|
+
onApplyCrossSell,
|
|
56
|
+
onCancelCrossSell
|
|
57
|
+
}) {
|
|
58
|
+
const {
|
|
59
|
+
t,
|
|
60
|
+
locale
|
|
61
|
+
} = (0, _context.useLocaleContext)();
|
|
62
|
+
const [state, setState] = (0, _ahooks.useSetState)({
|
|
63
|
+
loading: false,
|
|
64
|
+
shake: false
|
|
65
|
+
});
|
|
66
|
+
const {
|
|
67
|
+
data,
|
|
68
|
+
runAsync
|
|
69
|
+
} = (0, _ahooks.useRequest)(() => fetchCrossSell(checkoutSession.id));
|
|
70
|
+
const headlines = (0, _util.formatCheckoutHeadlines)(checkoutSession, currency, locale);
|
|
71
|
+
(0, _useBus.default)("error.REQUIRE_CROSS_SELL", () => {
|
|
72
|
+
setState({
|
|
73
|
+
shake: true
|
|
74
|
+
});
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
setState({
|
|
77
|
+
shake: false
|
|
78
|
+
});
|
|
79
|
+
}, 1e3);
|
|
80
|
+
}, []);
|
|
81
|
+
const handleUpsell = async (from, to) => {
|
|
82
|
+
await onUpsell(from, to);
|
|
83
|
+
runAsync();
|
|
84
|
+
};
|
|
85
|
+
const handleDownsell = async from => {
|
|
86
|
+
await onDownsell(from);
|
|
87
|
+
runAsync();
|
|
88
|
+
};
|
|
89
|
+
const handleApplyCrossSell = async () => {
|
|
90
|
+
if (data) {
|
|
91
|
+
try {
|
|
92
|
+
setState({
|
|
93
|
+
loading: true
|
|
94
|
+
});
|
|
95
|
+
await onApplyCrossSell(data.id);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error(err);
|
|
98
|
+
} finally {
|
|
99
|
+
setState({
|
|
100
|
+
loading: false
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const handleCancelCrossSell = async () => {
|
|
106
|
+
try {
|
|
107
|
+
setState({
|
|
108
|
+
loading: true
|
|
109
|
+
});
|
|
110
|
+
await onCancelCrossSell();
|
|
111
|
+
} catch (err) {
|
|
112
|
+
console.error(err);
|
|
113
|
+
} finally {
|
|
114
|
+
setState({
|
|
115
|
+
loading: false
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
120
|
+
in: true,
|
|
121
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
122
|
+
className: "cko-product",
|
|
123
|
+
direction: "column",
|
|
124
|
+
sx: {
|
|
125
|
+
mt: 8
|
|
126
|
+
},
|
|
127
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
128
|
+
className: "cko-product-summary",
|
|
129
|
+
direction: "column",
|
|
130
|
+
alignItems: "flex-start",
|
|
131
|
+
sx: {
|
|
132
|
+
mb: 4
|
|
133
|
+
},
|
|
134
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
135
|
+
sx: {
|
|
136
|
+
fontWeight: 500,
|
|
137
|
+
fontSize: "1.15rem",
|
|
138
|
+
color: "text.secondary"
|
|
139
|
+
},
|
|
140
|
+
children: headlines.action
|
|
141
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_amount.default, {
|
|
142
|
+
amount: headlines.amount
|
|
143
|
+
}), headlines.then && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
144
|
+
sx: {
|
|
145
|
+
fontSize: "0.9rem",
|
|
146
|
+
color: "text.secondary"
|
|
147
|
+
},
|
|
148
|
+
children: headlines.then
|
|
149
|
+
})]
|
|
150
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
151
|
+
spacing: 2,
|
|
152
|
+
children: checkoutSession.line_items.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_productItem.default, {
|
|
153
|
+
item: x,
|
|
154
|
+
session: checkoutSession,
|
|
155
|
+
currency,
|
|
156
|
+
onUpsell: handleUpsell,
|
|
157
|
+
onDownsell: handleDownsell,
|
|
158
|
+
children: x.cross_sell && /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
|
|
159
|
+
size: "small",
|
|
160
|
+
loadingPosition: "end",
|
|
161
|
+
color: "error",
|
|
162
|
+
variant: "text",
|
|
163
|
+
loading: state.loading,
|
|
164
|
+
onClick: handleCancelCrossSell,
|
|
165
|
+
children: t("payment.checkout.cross_sell.remove")
|
|
166
|
+
})
|
|
167
|
+
}, x.price_id))
|
|
168
|
+
}), data && checkoutSession.line_items.some(x => x.price_id === data.id) === false && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Grow, {
|
|
169
|
+
in: true,
|
|
170
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
171
|
+
direction: "column",
|
|
172
|
+
alignItems: "flex-end",
|
|
173
|
+
spacing: 0.5,
|
|
174
|
+
sx: {
|
|
175
|
+
border: "1px solid #eee",
|
|
176
|
+
borderRadius: 1,
|
|
177
|
+
padding: 1,
|
|
178
|
+
animation: state.shake ? `${shake} 0.2s 5 ease-in-out` : "none",
|
|
179
|
+
mt: {
|
|
180
|
+
xs: 4,
|
|
181
|
+
md: 8
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_productItem.default, {
|
|
185
|
+
item: {
|
|
186
|
+
quantity: 1,
|
|
187
|
+
price: data,
|
|
188
|
+
price_id: data.id,
|
|
189
|
+
cross_sell: true
|
|
190
|
+
},
|
|
191
|
+
session: checkoutSession,
|
|
192
|
+
currency,
|
|
193
|
+
onUpsell: _noop.default,
|
|
194
|
+
onDownsell: _noop.default
|
|
195
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
196
|
+
direction: "row",
|
|
197
|
+
alignItems: "center",
|
|
198
|
+
justifyContent: "space-between",
|
|
199
|
+
sx: {
|
|
200
|
+
width: 1
|
|
201
|
+
},
|
|
202
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
203
|
+
children: checkoutSession.cross_sell_behavior === "required" && /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
204
|
+
label: t("payment.checkout.required"),
|
|
205
|
+
color: "info",
|
|
206
|
+
variant: "outlined",
|
|
207
|
+
sx: {
|
|
208
|
+
mr: 1
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
|
|
212
|
+
size: "small",
|
|
213
|
+
loadingPosition: "end",
|
|
214
|
+
color: checkoutSession.cross_sell_behavior === "required" ? "info" : "info",
|
|
215
|
+
variant: checkoutSession.cross_sell_behavior === "required" ? "text" : "text",
|
|
216
|
+
loading: state.loading,
|
|
217
|
+
onClick: handleApplyCrossSell,
|
|
218
|
+
children: t("payment.checkout.cross_sell.add")
|
|
219
|
+
})]
|
|
220
|
+
})]
|
|
221
|
+
})
|
|
222
|
+
})]
|
|
223
|
+
})
|
|
224
|
+
});
|
|
225
|
+
}
|
package/lib/theme.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function create(settings?: any): any;
|
package/lib/theme.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = create;
|
|
7
|
+
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
8
|
+
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function create(settings = {}) {
|
|
11
|
+
return (0, _Theme.createTheme)((0, _merge.default)({
|
|
12
|
+
typography: {
|
|
13
|
+
fontSize: 14,
|
|
14
|
+
allVariants: {
|
|
15
|
+
textTransform: "none"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}, settings));
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TCheckoutSessionExpanded, TCustomer, TPaymentIntent, TPaymentLink, TPaymentMethodExpanded } from '@blocklet/payment-types';
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
export type CheckoutContext = {
|
|
4
|
+
checkoutSession: TCheckoutSessionExpanded;
|
|
5
|
+
paymentMethods: TPaymentMethodExpanded[];
|
|
6
|
+
paymentLink?: TPaymentLink;
|
|
7
|
+
paymentIntent?: TPaymentIntent;
|
|
8
|
+
customer?: TCustomer;
|
|
9
|
+
mode: LiteralUnion<'standalone' | 'inline' | 'popup', string>;
|
|
10
|
+
};
|
|
11
|
+
export type CheckoutProps = Partial<CheckoutCallbacks> & {
|
|
12
|
+
id: string;
|
|
13
|
+
extraParams?: Record<string, any>;
|
|
14
|
+
mode?: LiteralUnion<'standalone' | 'inline' | 'popup', string>;
|
|
15
|
+
};
|
|
16
|
+
export type CheckoutCallbacks = {
|
|
17
|
+
onPaid: (res: CheckoutContext) => void;
|
|
18
|
+
onError: (err: Error) => void;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|