@springmicro/cart 0.7.0 → 0.7.2

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.
@@ -1,145 +1,145 @@
1
- import { AddCard, type AddCardProps } from "./AddCard";
2
- import { postCheckout } from "../../utils/api";
3
- import React from "react";
4
- import {
5
- Alert,
6
- Container,
7
- Typography,
8
- CircularProgress,
9
- TableContainer,
10
- Table,
11
- TableHead,
12
- TableRow,
13
- TableCell,
14
- Paper,
15
- TableBody,
16
- } from "@mui/material";
17
-
18
- type CheckoutProps = AddCardProps & {
19
- order: any;
20
- invoiceId?: string;
21
- successData;
22
- };
23
-
24
- export default function Invoice({
25
- order,
26
- invoiceId,
27
- successData,
28
- }: CheckoutProps) {
29
- const currentUrl = new URL(window.location.href);
30
- const formatter = new Intl.NumberFormat("en-US", {
31
- style: "currency",
32
- currency: "USD",
33
- });
34
-
35
- if (
36
- successData !== null ||
37
- // currentUrl.searchParams.get("showReceipt")
38
- order.charge_id ||
39
- !["pending", "awaiting_payment"].includes(order.status)
40
- ) {
41
- const print = (
42
- <a
43
- href="#"
44
- onClick={() => {
45
- window.print();
46
- return false;
47
- }}
48
- style={{ textDecoration: "underline" }}
49
- >
50
- print
51
- </a>
52
- );
53
- const text =
54
- successData !== null ? (
55
- <>
56
- Payment received! An email was sent to{" "}
57
- <strong>{successData.billing_information.email}</strong>. You can also{" "}
58
- {print} this page for your records.
59
- </>
60
- ) : (
61
- <>Payment received! You can {print} this page for your records.</>
62
- );
63
- return (
64
- <>
65
- <Container>
66
- <Alert severity="success">{text}</Alert>
67
- </Container>
68
- <Container>
69
- <Typography variant="h4" gutterBottom>
70
- {invoiceId ? `Invoice #${invoiceId}` : "Order"}
71
- </Typography>
72
- <Typography variant="subtitle1">
73
- Reference: {order.reference}
74
- </Typography>
75
- <Typography variant="subtitle1">
76
- Date: {new Date(order.date).toLocaleDateString()}
77
- </Typography>
78
- <Typography variant="subtitle1">Status: {order.status}</Typography>
79
- {order.customer ? (
80
- <Typography variant="subtitle1">
81
- {order.customer.first_name} {order.customer.last_name}
82
- </Typography>
83
- ) : (
84
- <Typography variant="subtitle1">
85
- Customer ID: {order.customer_id}
86
- </Typography>
87
- )}
88
-
89
- <TableContainer component={Paper} sx={{ my: 2 }}>
90
- <Table>
91
- <TableHead>
92
- <TableRow>
93
- <TableCell>Item ID</TableCell>
94
- <TableCell>Name</TableCell>
95
- <TableCell>Description</TableCell>
96
- <TableCell>Quantity</TableCell>
97
- <TableCell>Unit Price</TableCell>
98
- <TableCell>Total Price</TableCell>
99
- </TableRow>
100
- </TableHead>
101
- <TableBody>
102
- {order.basket.map((item) => (
103
- <TableRow key={item.item_id}>
104
- <TableCell>{item.item_id}</TableCell>
105
- <TableCell>{item.name}</TableCell>
106
- <TableCell>{item.description || "-"}</TableCell>
107
- <TableCell>{item.quantity}</TableCell>
108
- <TableCell>
109
- {formatter.format(item.unit_price_cents / 100)}
110
- </TableCell>
111
- <TableCell>
112
- {formatter.format(
113
- (item.quantity * item.unit_price_cents) / 100
114
- )}
115
- </TableCell>
116
- </TableRow>
117
- ))}
118
- </TableBody>
119
- </Table>
120
- </TableContainer>
121
- </Container>
122
- </>
123
- );
124
- }
125
-
126
- // return (
127
- // <>
128
- // <Order order={order} invoiceId={invoiceId} />
129
- // {isSubmitting ? (
130
- // <Container>
131
- // <Typography>
132
- // <CircularProgress color="primary" /> Submitting...
133
- // </Typography>
134
- // </Container>
135
- // ) : (
136
- // <AddCard
137
- // contact={order.customer}
138
- // onSubmit={onSubmit}
139
- // PriceDetails={PriceDetails}
140
- // />
141
- // )
142
- // }
143
- // </>
144
- // );
145
- }
1
+ import { AddCard, type AddCardProps } from "./AddCard";
2
+ import { postCheckout } from "../../utils/api";
3
+ import React from "react";
4
+ import {
5
+ Alert,
6
+ Container,
7
+ Typography,
8
+ CircularProgress,
9
+ TableContainer,
10
+ Table,
11
+ TableHead,
12
+ TableRow,
13
+ TableCell,
14
+ Paper,
15
+ TableBody,
16
+ } from "@mui/material";
17
+
18
+ type CheckoutProps = AddCardProps & {
19
+ order: any;
20
+ invoiceId?: string;
21
+ successData;
22
+ };
23
+
24
+ export default function Invoice({
25
+ order,
26
+ invoiceId,
27
+ successData,
28
+ }: CheckoutProps) {
29
+ const currentUrl = new URL(window.location.href);
30
+ const formatter = new Intl.NumberFormat("en-US", {
31
+ style: "currency",
32
+ currency: "USD",
33
+ });
34
+
35
+ if (
36
+ successData !== null ||
37
+ // currentUrl.searchParams.get("showReceipt")
38
+ order.charge_id ||
39
+ !["pending", "awaiting_payment"].includes(order.status)
40
+ ) {
41
+ const print = (
42
+ <a
43
+ href="#"
44
+ onClick={() => {
45
+ window.print();
46
+ return false;
47
+ }}
48
+ style={{ textDecoration: "underline" }}
49
+ >
50
+ print
51
+ </a>
52
+ );
53
+ const text =
54
+ successData !== null ? (
55
+ <>
56
+ Payment received! An email was sent to{" "}
57
+ <strong>{successData.billing_information.email}</strong>. You can also{" "}
58
+ {print} this page for your records.
59
+ </>
60
+ ) : (
61
+ <>Payment received! You can {print} this page for your records.</>
62
+ );
63
+ return (
64
+ <>
65
+ <Container>
66
+ <Alert severity="success">{text}</Alert>
67
+ </Container>
68
+ <Container>
69
+ <Typography variant="h4" gutterBottom>
70
+ {invoiceId ? `Invoice #${invoiceId}` : "Order"}
71
+ </Typography>
72
+ <Typography variant="subtitle1">
73
+ Reference: {order.reference}
74
+ </Typography>
75
+ <Typography variant="subtitle1">
76
+ Date: {new Date(order.date).toLocaleDateString()}
77
+ </Typography>
78
+ <Typography variant="subtitle1">Status: {order.status}</Typography>
79
+ {order.customer ? (
80
+ <Typography variant="subtitle1">
81
+ {order.customer.first_name} {order.customer.last_name}
82
+ </Typography>
83
+ ) : (
84
+ <Typography variant="subtitle1">
85
+ Customer ID: {order.customer_id}
86
+ </Typography>
87
+ )}
88
+
89
+ <TableContainer component={Paper} sx={{ my: 2 }}>
90
+ <Table>
91
+ <TableHead>
92
+ <TableRow>
93
+ <TableCell>Item ID</TableCell>
94
+ <TableCell>Name</TableCell>
95
+ <TableCell>Description</TableCell>
96
+ <TableCell>Quantity</TableCell>
97
+ <TableCell>Unit Price</TableCell>
98
+ <TableCell>Total Price</TableCell>
99
+ </TableRow>
100
+ </TableHead>
101
+ <TableBody>
102
+ {order.basket.map((item) => (
103
+ <TableRow key={item.item_id}>
104
+ <TableCell>{item.item_id}</TableCell>
105
+ <TableCell>{item.name}</TableCell>
106
+ <TableCell>{item.description || "-"}</TableCell>
107
+ <TableCell>{item.quantity}</TableCell>
108
+ <TableCell>
109
+ {formatter.format(item.unit_price_cents / 100)}
110
+ </TableCell>
111
+ <TableCell>
112
+ {formatter.format(
113
+ (item.quantity * item.unit_price_cents) / 100
114
+ )}
115
+ </TableCell>
116
+ </TableRow>
117
+ ))}
118
+ </TableBody>
119
+ </Table>
120
+ </TableContainer>
121
+ </Container>
122
+ </>
123
+ );
124
+ }
125
+
126
+ // return (
127
+ // <>
128
+ // <Order order={order} invoiceId={invoiceId} />
129
+ // {isSubmitting ? (
130
+ // <Container>
131
+ // <Typography>
132
+ // <CircularProgress color="primary" /> Submitting...
133
+ // </Typography>
134
+ // </Container>
135
+ // ) : (
136
+ // <AddCard
137
+ // contact={order.customer}
138
+ // onSubmit={onSubmit}
139
+ // PriceDetails={PriceDetails}
140
+ // />
141
+ // )
142
+ // }
143
+ // </>
144
+ // );
145
+ }
@@ -1,93 +1,93 @@
1
- import { createSvgIcon } from "@mui/material";
2
- // Source: https://brandfolder.com/s/99gctvbpwgvzbc7mz3j9g4x
3
-
4
- export const PoweredByStripe = createSvgIcon(
5
- <svg
6
- id="Layer_1"
7
- data-name="Layer 1"
8
- xmlns="http://www.w3.org/2000/svg"
9
- viewBox="0 0 150 34"
10
- >
11
- <defs>
12
- <style>{`.cls-1{fill: #635bff}`}</style>
13
- </defs>
14
- <title>Powered by Stripe - blurple</title>
15
- <path
16
- className="cls-1"
17
- d="M146,0H3.73A3.73,3.73,0,0,0,0,3.73V30.27A3.73,3.73,0,0,0,3.73,34H146a4,4,0,0,0,4-4V4A4,4,0,0,0,146,0Zm3,30a3,3,0,0,1-3,3H3.73A2.74,2.74,0,0,1,1,30.27V3.73A2.74,2.74,0,0,1,3.73,1H146a3,3,0,0,1,3,3Z"
18
- />
19
- <path
20
- className="cls-1"
21
- d="M17.07,11.24h-4.3V22h1.92V17.84h2.38c2.4,0,3.9-1.16,3.9-3.3S19.47,11.24,17.07,11.24Zm-.1,5H14.69v-3.3H17c1.38,0,2.11.59,2.11,1.65S18.35,16.19,17,16.19Z"
22
- />
23
- <path
24
- className="cls-1"
25
- d="M25.1,14a3.77,3.77,0,0,0-3.8,4.09,3.81,3.81,0,1,0,7.59,0A3.76,3.76,0,0,0,25.1,14Zm0,6.67c-1.22,0-2-1-2-2.58s.76-2.58,2-2.58,2,1,2,2.58S26.31,20.66,25.1,20.66Z"
26
- />
27
- <polygon
28
- className="cls-1"
29
- points="36.78 19.35 35.37 14.13 33.89 14.13 32.49 19.35 31.07 14.13 29.22 14.13 31.59 22.01 33.15 22.01 34.59 16.85 36.03 22.01 37.59 22.01 39.96 14.13 38.18 14.13 36.78 19.35"
30
- />
31
- <path
32
- className="cls-1"
33
- d="M44,14a3.83,3.83,0,0,0-3.75,4.09,3.79,3.79,0,0,0,3.83,4.09A3.47,3.47,0,0,0,47.49,20L46,19.38a1.78,1.78,0,0,1-1.83,1.26A2.12,2.12,0,0,1,42,18.47h5.52v-.6C47.54,15.71,46.32,14,44,14Zm-1.93,3.13A1.92,1.92,0,0,1,44,15.5a1.56,1.56,0,0,1,1.69,1.62Z"
34
- />
35
- <path
36
- className="cls-1"
37
- d="M50.69,15.3V14.13h-1.8V22h1.8V17.87a1.89,1.89,0,0,1,2-2,4.68,4.68,0,0,1,.66,0v-1.8c-.14,0-.3,0-.51,0A2.29,2.29,0,0,0,50.69,15.3Z"
38
- />
39
- <path
40
- className="cls-1"
41
- d="M57.48,14a3.83,3.83,0,0,0-3.75,4.09,3.79,3.79,0,0,0,3.83,4.09A3.47,3.47,0,0,0,60.93,20l-1.54-.59a1.78,1.78,0,0,1-1.83,1.26,2.12,2.12,0,0,1-2.1-2.17H61v-.6C61,15.71,59.76,14,57.48,14Zm-1.93,3.13a1.92,1.92,0,0,1,1.92-1.62,1.56,1.56,0,0,1,1.69,1.62Z"
42
- />
43
- <path
44
- className="cls-1"
45
- d="M67.56,15a2.85,2.85,0,0,0-2.26-1c-2.21,0-3.47,1.85-3.47,4.09s1.26,4.09,3.47,4.09a2.82,2.82,0,0,0,2.26-1V22h1.8V11.24h-1.8Zm0,3.35a2,2,0,0,1-2,2.28c-1.31,0-2-1-2-2.52s.7-2.52,2-2.52c1.11,0,2,.81,2,2.29Z"
46
- />
47
- <path
48
- className="cls-1"
49
- d="M79.31,14A2.88,2.88,0,0,0,77,15V11.24h-1.8V22H77v-.83a2.86,2.86,0,0,0,2.27,1c2.2,0,3.46-1.86,3.46-4.09S81.51,14,79.31,14ZM79,20.6a2,2,0,0,1-2-2.28v-.47c0-1.48.84-2.29,2-2.29,1.3,0,2,1,2,2.52S80.25,20.6,79,20.6Z"
50
- />
51
- <path
52
- className="cls-1"
53
- d="M86.93,19.66,85,14.13H83.1L86,21.72l-.3.74a1,1,0,0,1-1.14.79,4.12,4.12,0,0,1-.6,0v1.51a4.62,4.62,0,0,0,.73.05,2.67,2.67,0,0,0,2.78-2l3.24-8.62H88.82Z"
54
- />
55
- <path
56
- className="cls-1"
57
- d="M125,12.43a3,3,0,0,0-2.13.87l-.14-.69h-2.39V25.53l2.72-.59V21.81a3,3,0,0,0,1.93.7c1.94,0,3.72-1.59,3.72-5.11C128.71,14.18,126.91,12.43,125,12.43Zm-.65,7.63a1.61,1.61,0,0,1-1.28-.52l0-4.11a1.64,1.64,0,0,1,1.3-.55c1,0,1.68,1.13,1.68,2.58S125.36,20.06,124.35,20.06Z"
58
- />
59
- <path
60
- className="cls-1"
61
- d="M133.73,12.43c-2.62,0-4.21,2.26-4.21,5.11,0,3.37,1.88,5.08,4.56,5.08a6.12,6.12,0,0,0,3-.73V19.64a5.79,5.79,0,0,1-2.7.62c-1.08,0-2-.39-2.14-1.7h5.38c0-.15,0-.74,0-1C137.71,14.69,136.35,12.43,133.73,12.43Zm-1.47,4.07c0-1.26.77-1.79,1.45-1.79s1.4.53,1.4,1.79Z"
62
- />
63
- <path
64
- className="cls-1"
65
- d="M113,13.36l-.17-.82h-2.32v9.71h2.68V15.67a1.87,1.87,0,0,1,2.05-.58V12.54A1.8,1.8,0,0,0,113,13.36Z"
66
- />
67
- <path
68
- className="cls-1"
69
- d="M99.46,15.46c0-.44.36-.61.93-.61a5.9,5.9,0,0,1,2.7.72V12.94a7,7,0,0,0-2.7-.51c-2.21,0-3.68,1.18-3.68,3.16,0,3.1,4.14,2.6,4.14,3.93,0,.52-.44.69-1,.69a6.78,6.78,0,0,1-3-.9V22a7.38,7.38,0,0,0,3,.64c2.26,0,3.82-1.15,3.82-3.16C103.62,16.12,99.46,16.72,99.46,15.46Z"
70
- />
71
- <path
72
- className="cls-1"
73
- d="M107.28,10.24l-2.65.58v8.93a2.77,2.77,0,0,0,2.82,2.87,4.16,4.16,0,0,0,1.91-.37V20c-.35.15-2.06.66-2.06-1V15h2.06V12.66h-2.06Z"
74
- />
75
- <polygon
76
- className="cls-1"
77
- points="116.25 11.7 118.98 11.13 118.98 8.97 116.25 9.54 116.25 11.7"
78
- />
79
- <rect className="cls-1" x="116.25" y="12.61" width="2.73" height="9.64" />
80
- </svg>,
81
- "PoweredByStripe"
82
- );
83
-
84
- export const StripeLogoLink = ({ height }: { height?: string }) => {
85
- return (
86
- <a href="https://stripe.com" target="_blank">
87
- <PoweredByStripe
88
- sx={{ width: "unset", height: height || "1em" }}
89
- viewBox="0 0 150 34"
90
- />
91
- </a>
92
- );
93
- };
1
+ import { createSvgIcon } from "@mui/material";
2
+ // Source: https://brandfolder.com/s/99gctvbpwgvzbc7mz3j9g4x
3
+
4
+ export const PoweredByStripe = createSvgIcon(
5
+ <svg
6
+ id="Layer_1"
7
+ data-name="Layer 1"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 150 34"
10
+ >
11
+ <defs>
12
+ <style>{`.cls-1{fill: #635bff}`}</style>
13
+ </defs>
14
+ <title>Powered by Stripe - blurple</title>
15
+ <path
16
+ className="cls-1"
17
+ d="M146,0H3.73A3.73,3.73,0,0,0,0,3.73V30.27A3.73,3.73,0,0,0,3.73,34H146a4,4,0,0,0,4-4V4A4,4,0,0,0,146,0Zm3,30a3,3,0,0,1-3,3H3.73A2.74,2.74,0,0,1,1,30.27V3.73A2.74,2.74,0,0,1,3.73,1H146a3,3,0,0,1,3,3Z"
18
+ />
19
+ <path
20
+ className="cls-1"
21
+ d="M17.07,11.24h-4.3V22h1.92V17.84h2.38c2.4,0,3.9-1.16,3.9-3.3S19.47,11.24,17.07,11.24Zm-.1,5H14.69v-3.3H17c1.38,0,2.11.59,2.11,1.65S18.35,16.19,17,16.19Z"
22
+ />
23
+ <path
24
+ className="cls-1"
25
+ d="M25.1,14a3.77,3.77,0,0,0-3.8,4.09,3.81,3.81,0,1,0,7.59,0A3.76,3.76,0,0,0,25.1,14Zm0,6.67c-1.22,0-2-1-2-2.58s.76-2.58,2-2.58,2,1,2,2.58S26.31,20.66,25.1,20.66Z"
26
+ />
27
+ <polygon
28
+ className="cls-1"
29
+ points="36.78 19.35 35.37 14.13 33.89 14.13 32.49 19.35 31.07 14.13 29.22 14.13 31.59 22.01 33.15 22.01 34.59 16.85 36.03 22.01 37.59 22.01 39.96 14.13 38.18 14.13 36.78 19.35"
30
+ />
31
+ <path
32
+ className="cls-1"
33
+ d="M44,14a3.83,3.83,0,0,0-3.75,4.09,3.79,3.79,0,0,0,3.83,4.09A3.47,3.47,0,0,0,47.49,20L46,19.38a1.78,1.78,0,0,1-1.83,1.26A2.12,2.12,0,0,1,42,18.47h5.52v-.6C47.54,15.71,46.32,14,44,14Zm-1.93,3.13A1.92,1.92,0,0,1,44,15.5a1.56,1.56,0,0,1,1.69,1.62Z"
34
+ />
35
+ <path
36
+ className="cls-1"
37
+ d="M50.69,15.3V14.13h-1.8V22h1.8V17.87a1.89,1.89,0,0,1,2-2,4.68,4.68,0,0,1,.66,0v-1.8c-.14,0-.3,0-.51,0A2.29,2.29,0,0,0,50.69,15.3Z"
38
+ />
39
+ <path
40
+ className="cls-1"
41
+ d="M57.48,14a3.83,3.83,0,0,0-3.75,4.09,3.79,3.79,0,0,0,3.83,4.09A3.47,3.47,0,0,0,60.93,20l-1.54-.59a1.78,1.78,0,0,1-1.83,1.26,2.12,2.12,0,0,1-2.1-2.17H61v-.6C61,15.71,59.76,14,57.48,14Zm-1.93,3.13a1.92,1.92,0,0,1,1.92-1.62,1.56,1.56,0,0,1,1.69,1.62Z"
42
+ />
43
+ <path
44
+ className="cls-1"
45
+ d="M67.56,15a2.85,2.85,0,0,0-2.26-1c-2.21,0-3.47,1.85-3.47,4.09s1.26,4.09,3.47,4.09a2.82,2.82,0,0,0,2.26-1V22h1.8V11.24h-1.8Zm0,3.35a2,2,0,0,1-2,2.28c-1.31,0-2-1-2-2.52s.7-2.52,2-2.52c1.11,0,2,.81,2,2.29Z"
46
+ />
47
+ <path
48
+ className="cls-1"
49
+ d="M79.31,14A2.88,2.88,0,0,0,77,15V11.24h-1.8V22H77v-.83a2.86,2.86,0,0,0,2.27,1c2.2,0,3.46-1.86,3.46-4.09S81.51,14,79.31,14ZM79,20.6a2,2,0,0,1-2-2.28v-.47c0-1.48.84-2.29,2-2.29,1.3,0,2,1,2,2.52S80.25,20.6,79,20.6Z"
50
+ />
51
+ <path
52
+ className="cls-1"
53
+ d="M86.93,19.66,85,14.13H83.1L86,21.72l-.3.74a1,1,0,0,1-1.14.79,4.12,4.12,0,0,1-.6,0v1.51a4.62,4.62,0,0,0,.73.05,2.67,2.67,0,0,0,2.78-2l3.24-8.62H88.82Z"
54
+ />
55
+ <path
56
+ className="cls-1"
57
+ d="M125,12.43a3,3,0,0,0-2.13.87l-.14-.69h-2.39V25.53l2.72-.59V21.81a3,3,0,0,0,1.93.7c1.94,0,3.72-1.59,3.72-5.11C128.71,14.18,126.91,12.43,125,12.43Zm-.65,7.63a1.61,1.61,0,0,1-1.28-.52l0-4.11a1.64,1.64,0,0,1,1.3-.55c1,0,1.68,1.13,1.68,2.58S125.36,20.06,124.35,20.06Z"
58
+ />
59
+ <path
60
+ className="cls-1"
61
+ d="M133.73,12.43c-2.62,0-4.21,2.26-4.21,5.11,0,3.37,1.88,5.08,4.56,5.08a6.12,6.12,0,0,0,3-.73V19.64a5.79,5.79,0,0,1-2.7.62c-1.08,0-2-.39-2.14-1.7h5.38c0-.15,0-.74,0-1C137.71,14.69,136.35,12.43,133.73,12.43Zm-1.47,4.07c0-1.26.77-1.79,1.45-1.79s1.4.53,1.4,1.79Z"
62
+ />
63
+ <path
64
+ className="cls-1"
65
+ d="M113,13.36l-.17-.82h-2.32v9.71h2.68V15.67a1.87,1.87,0,0,1,2.05-.58V12.54A1.8,1.8,0,0,0,113,13.36Z"
66
+ />
67
+ <path
68
+ className="cls-1"
69
+ d="M99.46,15.46c0-.44.36-.61.93-.61a5.9,5.9,0,0,1,2.7.72V12.94a7,7,0,0,0-2.7-.51c-2.21,0-3.68,1.18-3.68,3.16,0,3.1,4.14,2.6,4.14,3.93,0,.52-.44.69-1,.69a6.78,6.78,0,0,1-3-.9V22a7.38,7.38,0,0,0,3,.64c2.26,0,3.82-1.15,3.82-3.16C103.62,16.12,99.46,16.72,99.46,15.46Z"
70
+ />
71
+ <path
72
+ className="cls-1"
73
+ d="M107.28,10.24l-2.65.58v8.93a2.77,2.77,0,0,0,2.82,2.87,4.16,4.16,0,0,0,1.91-.37V20c-.35.15-2.06.66-2.06-1V15h2.06V12.66h-2.06Z"
74
+ />
75
+ <polygon
76
+ className="cls-1"
77
+ points="116.25 11.7 118.98 11.13 118.98 8.97 116.25 9.54 116.25 11.7"
78
+ />
79
+ <rect className="cls-1" x="116.25" y="12.61" width="2.73" height="9.64" />
80
+ </svg>,
81
+ "PoweredByStripe"
82
+ );
83
+
84
+ export const StripeLogoLink = ({ height }: { height?: string }) => {
85
+ return (
86
+ <a href="https://stripe.com" target="_blank">
87
+ <PoweredByStripe
88
+ sx={{ width: "unset", height: height || "1em" }}
89
+ viewBox="0 0 150 34"
90
+ />
91
+ </a>
92
+ );
93
+ };
File without changes
@@ -11,8 +11,9 @@ import { FormikConfig } from "formik";
11
11
  export type CheckoutFieldsType = {
12
12
  name: string;
13
13
  label?: string; // Defaults to a formated version of the name
14
- required?: boolean; // Defaults to true
14
+ required?: boolean | string; // Defaults to true
15
15
  type?: "string"; // Defaults to "string" (text)
16
+ hidden?: boolean | string; // Defaults to true
16
17
  };
17
18
 
18
19
  export default function Checkout({
@@ -23,6 +24,7 @@ export default function Checkout({
23
24
  disableMissingImage = false,
24
25
  CollectExtraInfo,
25
26
  defaultValues,
27
+ hideFields = [],
26
28
  dev,
27
29
  }: {
28
30
  apiBaseUrl: string;
@@ -32,6 +34,7 @@ export default function Checkout({
32
34
  disableMissingImage?: boolean;
33
35
  CollectExtraInfo?: React.FC<{ formik: FormikConfig<any> }>;
34
36
  defaultValues?: Record<string, any>;
37
+ hideFields?: string[];
35
38
  dev?: boolean;
36
39
  }) {
37
40
  const store = useStore(cartStore);
@@ -58,15 +61,20 @@ export default function Checkout({
58
61
  if (oid && or) {
59
62
  fetch(`${apiBaseUrl}/api/ecommerce/orders/${oid}/reference/${or}`).then(
60
63
  async (res) =>
61
- await res.json().then((order) => {
62
- setOrder(order);
63
- setStatus(
64
- order.charge_id ||
65
- !["pending", "awaiting_payment"].includes(order.status)
66
- ? 2
67
- : 0 // normally this should be set to 1 but we need to ensure it sends card data to the payment provider and that data is likely lost on refresh.
68
- );
69
- })
64
+ await res
65
+ .json()
66
+ .then((order) => {
67
+ setOrder(order);
68
+ setStatus(
69
+ order.charge_id ||
70
+ !["pending", "awaiting_payment"].includes(order.status)
71
+ ? 2
72
+ : 0 // normally this should be set to 1 but we need to ensure it sends card data to the payment provider and that data is likely lost on refresh.
73
+ );
74
+ })
75
+ .catch(() => {
76
+ console.error("Failed to get order");
77
+ })
70
78
  );
71
79
  }
72
80
  }, []);
@@ -221,6 +229,7 @@ export default function Checkout({
221
229
  CollectExtraInfo={CollectExtraInfo}
222
230
  defaultValues={defaultValues}
223
231
  dev={dev}
232
+ hideFields={hideFields}
224
233
  />
225
234
  )}
226
235
  {status === 2 && order !== undefined && (
package/src/index.css CHANGED
@@ -1,5 +1,5 @@
1
- @media print {
2
- #paymentMethodForm {
3
- display: none !important;
4
- }
5
- }
1
+ @media print {
2
+ #paymentMethodForm {
3
+ display: none !important;
4
+ }
5
+ }
package/src/index.ts CHANGED
File without changes