@mintmoney/react 0.1.0-alpha.11 → 0.1.0-alpha.12
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/dist/esm/api/checkouts.js +9 -9
- package/dist/esm/api/generated.js +544 -592
- package/dist/esm/api/index.js +10 -10
- package/dist/esm/api/payments.js +17 -21
- package/dist/esm/api/types.js +8 -2
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/checkout/container.js +2 -2
- package/dist/esm/checkout/index.js +18 -38
- package/dist/esm/checkout/modal.js +52 -63
- package/dist/esm/checkout/views/back.js +3 -7
- package/dist/esm/checkout/views/card-intent/details.js +4 -21
- package/dist/esm/checkout/views/crypto-intent/curreny.js +18 -43
- package/dist/esm/checkout/views/crypto-intent/curreny.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/direct-details.js +16 -60
- package/dist/esm/checkout/views/crypto-intent/methods.js +19 -27
- package/dist/esm/checkout/views/crypto-intent/processing.js +31 -39
- package/dist/esm/checkout/views/crypto-intent/processing.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/success.js +14 -32
- package/dist/esm/checkout/views/initial.js +24 -29
- package/dist/esm/checkout/views/method-select.js +10 -24
- package/dist/esm/components/buttons/index.js +11 -20
- package/dist/esm/components/icons/checkMark.js +4 -16
- package/dist/esm/components/icons/close.js +4 -19
- package/dist/esm/components/icons/index.js +1 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/lists/empty.js +2 -5
- package/dist/esm/components/lists/index.js +8 -47
- package/dist/esm/components/loading/index.js +6 -47
- package/dist/esm/components/modals/index.js +1 -1
- package/dist/esm/components/modals/modal-with-views.js +23 -62
- package/dist/esm/components/modals/modal.js +11 -67
- package/dist/esm/components/modals/use-modal-with-views.js +22 -25
- package/dist/esm/components/text/index.js +21 -21
- package/dist/esm/config.js +14 -5
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/context.js +10 -18
- package/dist/esm/index.js +1 -1
- package/dist/esm/state/checkout/store.js +144 -144
- package/dist/esm/state/checkout/store.js.map +1 -1
- package/dist/esm/themes/default.js +55 -55
- package/dist/esm/themes/index.js +1 -1
- package/dist/esm/themes/types.js +1 -1
- package/dist/esm/utils/cn.js +1 -1
- package/dist/types/api/checkouts.d.ts +5 -5
- package/dist/types/api/generated.d.ts +835 -924
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/api/payments.d.ts +3 -10
- package/dist/types/api/types.d.ts +16 -14
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/checkout/container.d.ts +2 -12
- package/dist/types/checkout/index.d.ts +6 -10
- package/dist/types/checkout/modal.d.ts +5 -7
- package/dist/types/checkout/views/back.d.ts +3 -5
- package/dist/types/checkout/views/card-intent/details.d.ts +1 -1
- package/dist/types/checkout/views/crypto-intent/curreny.d.ts +1 -1
- package/dist/types/checkout/views/crypto-intent/curreny.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/direct-details.d.ts +2 -4
- package/dist/types/checkout/views/crypto-intent/methods.d.ts +1 -1
- package/dist/types/checkout/views/crypto-intent/processing.d.ts +1 -1
- package/dist/types/checkout/views/crypto-intent/processing.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/success.d.ts +3 -5
- package/dist/types/checkout/views/initial.d.ts +3 -5
- package/dist/types/checkout/views/method-select.d.ts +1 -1
- package/dist/types/components/buttons/index.d.ts +6 -16
- package/dist/types/components/icons/checkMark.d.ts +3 -5
- package/dist/types/components/icons/close.d.ts +3 -5
- package/dist/types/components/icons/index.d.ts +1 -1
- package/dist/types/components/index.d.ts +1 -1
- package/dist/types/components/lists/empty.d.ts +3 -5
- package/dist/types/components/lists/index.d.ts +9 -17
- package/dist/types/components/loading/index.d.ts +4 -4
- package/dist/types/components/modals/index.d.ts +1 -1
- package/dist/types/components/modals/modal-with-views.d.ts +18 -23
- package/dist/types/components/modals/modal.d.ts +9 -17
- package/dist/types/components/modals/use-modal-with-views.d.ts +6 -9
- package/dist/types/components/text/index.d.ts +7 -17
- package/dist/types/config.d.ts +16 -12
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/context.d.ts +4 -7
- package/dist/types/index.d.ts +1 -1
- package/dist/types/state/checkout/store.d.ts +51 -74
- package/dist/types/state/checkout/store.d.ts.map +1 -1
- package/dist/types/themes/default.d.ts +1 -1
- package/dist/types/themes/index.d.ts +1 -1
- package/dist/types/themes/types.d.ts +26 -25
- package/dist/types/utils/cn.d.ts +1 -1
- package/package.json +1 -1
package/dist/esm/api/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Api } from "./generated.js";
|
|
2
2
|
const api = new Api({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
securityWorker: (publicKey) => {
|
|
4
|
+
const headers = {};
|
|
5
|
+
headers["x-api-key"] = publicKey;
|
|
6
|
+
return { headers };
|
|
7
|
+
},
|
|
8
|
+
baseUrl: "https://api.getmint.money",
|
|
9
|
+
baseApiParams: {
|
|
10
|
+
secure: true,
|
|
11
|
+
},
|
|
12
12
|
});
|
|
13
13
|
export { api };
|
|
14
14
|
export * from "./generated.js";
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
package/dist/esm/api/payments.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
import { api } from "./index.js";
|
|
2
2
|
const paymentDTO = (data) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
return {
|
|
4
|
+
...data.data,
|
|
5
|
+
};
|
|
6
6
|
};
|
|
7
|
-
export async function createPayment({ amount, checkoutId }) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export async function createPayment({ amount, checkoutId, }) {
|
|
8
|
+
const resp = await api.v1.paymentsCreate({
|
|
9
|
+
currency: "USD",
|
|
10
|
+
amount: amount,
|
|
11
|
+
checkout_id: checkoutId,
|
|
12
|
+
});
|
|
13
|
+
return paymentDTO(resp.data);
|
|
14
14
|
}
|
|
15
|
-
export async function createPaymentAttempt(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
) {
|
|
20
|
-
const data = { ...currency, required_confirmations: confirmations };
|
|
21
|
-
const resp = await api.v1.paymentsCryptoPayCreate(paymentId, data);
|
|
22
|
-
return resp.data.data;
|
|
15
|
+
export async function createPaymentAttempt(paymentId, currency, confirmations = 1) {
|
|
16
|
+
const data = { ...currency, required_confirmations: confirmations };
|
|
17
|
+
const resp = await api.v1.paymentsCryptoPayCreate(paymentId, data);
|
|
18
|
+
return resp.data.data;
|
|
23
19
|
}
|
|
24
20
|
export async function getPaymentById(id) {
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const resp = await api.v1.paymentsDetail(id);
|
|
22
|
+
return resp.data.data;
|
|
27
23
|
}
|
|
28
|
-
//# sourceMappingURL=payments.js.map
|
|
24
|
+
//# sourceMappingURL=payments.js.map
|
package/dist/esm/api/types.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export var PaymentStatus;
|
|
2
|
+
(function (PaymentStatus) {
|
|
3
|
+
PaymentStatus["PENDING"] = "pending";
|
|
4
|
+
PaymentStatus["CONFIRMING_PAYMENT"] = "confirming_payment";
|
|
5
|
+
PaymentStatus["PAID"] = "paid";
|
|
6
|
+
PaymentStatus["FAILED"] = "failed";
|
|
7
|
+
})(PaymentStatus || (PaymentStatus = {}));
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/types.ts"],"names":[],"mappings":"AAQA,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,0DAAyC,CAAA;IACzC,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { styled } from "styled-components";
|
|
2
|
-
export const ModalViewContainer = styled.div`
|
|
2
|
+
export const ModalViewContainer = styled.div `
|
|
3
3
|
position: relative;
|
|
4
4
|
display: flex;
|
|
5
5
|
flex: 1;
|
|
@@ -7,4 +7,4 @@ export const ModalViewContainer = styled.div`
|
|
|
7
7
|
gap: 24px;
|
|
8
8
|
width: 100%;
|
|
9
9
|
`;
|
|
10
|
-
//# sourceMappingURL=container.js.map
|
|
10
|
+
//# sourceMappingURL=container.js.map
|
|
@@ -1,44 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
jsx as _jsx,
|
|
4
|
-
Fragment as _Fragment,
|
|
5
|
-
jsxs as _jsxs,
|
|
6
|
-
} from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
3
|
import { useState, cloneElement } from "react";
|
|
8
4
|
import { StyledButton } from "../components/index.js";
|
|
9
5
|
import { CheckoutModal } from "./modal.js";
|
|
10
6
|
export function Checkout({ createPayment, asChild, children }) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
asChild && children
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
: _jsx(StyledButton, {
|
|
28
|
-
variant: "primary",
|
|
29
|
-
onClick: handleCheckout,
|
|
30
|
-
children: "Pay Now",
|
|
31
|
-
});
|
|
32
|
-
return _jsxs(_Fragment, {
|
|
33
|
-
children: [
|
|
34
|
-
trigger,
|
|
35
|
-
payment &&
|
|
36
|
-
_jsx(CheckoutModal, {
|
|
37
|
-
open: isOpen,
|
|
38
|
-
onOpenChange: openModal,
|
|
39
|
-
payment: payment,
|
|
40
|
-
}),
|
|
41
|
-
],
|
|
42
|
-
});
|
|
7
|
+
const [isOpen, openModal] = useState(false);
|
|
8
|
+
const [payment, setPayment] = useState(null);
|
|
9
|
+
const handleCheckout = async () => {
|
|
10
|
+
try {
|
|
11
|
+
const payment = await createPayment();
|
|
12
|
+
setPayment(payment);
|
|
13
|
+
openModal(true);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error("Error creating payment:", error);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const trigger = asChild && children ? (cloneElement(children, {
|
|
20
|
+
onClick: handleCheckout,
|
|
21
|
+
})) : (_jsx(StyledButton, { variant: "primary", onClick: handleCheckout, children: "Pay Now" }));
|
|
22
|
+
return (_jsxs(_Fragment, { children: [trigger, payment && (_jsx(CheckoutModal, { open: isOpen, onOpenChange: openModal, payment: payment }))] }));
|
|
43
23
|
}
|
|
44
|
-
//# sourceMappingURL=index.js.map
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -10,67 +10,56 @@ import { CryptoIntentPaymentSuccessViewContent } from "./views/crypto-intent/suc
|
|
|
10
10
|
import { InitialiseCheckoutViewContent } from "./views/initial.js";
|
|
11
11
|
import { MethodSelectViewContent } from "./views/method-select.js";
|
|
12
12
|
export const CheckoutModal = (props) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
footer: () => _jsx("button", { className: "", children: "Success" }),
|
|
65
|
-
},
|
|
66
|
-
failed: {
|
|
67
|
-
title: "Payment Failed",
|
|
68
|
-
header: () => _jsx("p", { className: "", children: "Failed" }),
|
|
69
|
-
content: () => _jsx(_Fragment, {}),
|
|
70
|
-
navigateButtonPosition: "center",
|
|
71
|
-
navigateShouldGoToView: "methods",
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
});
|
|
13
|
+
return (_jsx(ModalWithView, { className: "mm-checkout-modal", initialView: "initial", isOpen: props.open, onOpenChange: props.onOpenChange, views: {
|
|
14
|
+
initial: {
|
|
15
|
+
title: "",
|
|
16
|
+
content: () => (_jsx(InitialiseCheckoutViewContent, { payment: props.payment })),
|
|
17
|
+
},
|
|
18
|
+
methods: {
|
|
19
|
+
title: "Order Summary",
|
|
20
|
+
content: () => _jsx(MethodSelectViewContent, {}),
|
|
21
|
+
},
|
|
22
|
+
cryptoIntent: {
|
|
23
|
+
title: "Pay with Crypto",
|
|
24
|
+
content: () => _jsx(CryptoIntentViewContent, {}),
|
|
25
|
+
footer: () => _jsx(ModalBackButton, { view: "methods" }),
|
|
26
|
+
},
|
|
27
|
+
cryptoIntentSelectCurrency: {
|
|
28
|
+
title: "Select Currency",
|
|
29
|
+
content: () => _jsx(CryptontentSelectCurrencyViewContent, {}),
|
|
30
|
+
footer: () => _jsx(ModalBackButton, { view: "cryptoIntent" }),
|
|
31
|
+
},
|
|
32
|
+
cryptoIntentDirectDetails: {
|
|
33
|
+
title: "Pay Direct",
|
|
34
|
+
content: () => _jsx(CryptoIntentDirectDetailsViewContent, {}),
|
|
35
|
+
footer: () => _jsx(ModalBackButton, { view: "cryptoIntent" }),
|
|
36
|
+
},
|
|
37
|
+
cryptoIntentPaymentStatus: {
|
|
38
|
+
title: "Payment Processing",
|
|
39
|
+
content: () => _jsx(CryptoIntentPaymentStatusViewContent, {}),
|
|
40
|
+
},
|
|
41
|
+
cryptoIntentPaymentSuccess: {
|
|
42
|
+
title: "Payment Successful",
|
|
43
|
+
content: () => (_jsx(CryptoIntentPaymentSuccessViewContent, { onClose: props.onOpenChange })),
|
|
44
|
+
},
|
|
45
|
+
cardIntent: {
|
|
46
|
+
title: "Pay by Card",
|
|
47
|
+
content: () => _jsx(CardIntentViewContent, {}),
|
|
48
|
+
footer: () => _jsx(ModalBackButton, { view: "methods" }),
|
|
49
|
+
},
|
|
50
|
+
success: {
|
|
51
|
+
title: "Payment Successful",
|
|
52
|
+
header: () => _jsx("p", { className: "", children: "Transfer complete" }),
|
|
53
|
+
content: () => _jsx(_Fragment, {}),
|
|
54
|
+
footer: () => _jsx("button", { className: "", children: "Success" }),
|
|
55
|
+
},
|
|
56
|
+
failed: {
|
|
57
|
+
title: "Payment Failed",
|
|
58
|
+
header: () => _jsx("p", { className: "", children: "Failed" }),
|
|
59
|
+
content: () => _jsx(_Fragment, {}),
|
|
60
|
+
navigateButtonPosition: "center",
|
|
61
|
+
navigateShouldGoToView: "methods",
|
|
62
|
+
},
|
|
63
|
+
} }));
|
|
75
64
|
};
|
|
76
|
-
//# sourceMappingURL=modal.js.map
|
|
65
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useModalWithView, StyledButton } from "../../components/index.js";
|
|
3
3
|
const ModalBackButton = ({ view }) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
onClick: () => goToView(view),
|
|
7
|
-
variant: "secondary",
|
|
8
|
-
children: "Back",
|
|
9
|
-
});
|
|
4
|
+
const { goToView } = useModalWithView();
|
|
5
|
+
return (_jsx(StyledButton, { onClick: () => goToView(view), variant: "secondary", children: "Back" }));
|
|
10
6
|
};
|
|
11
7
|
export { ModalBackButton };
|
|
12
|
-
//# sourceMappingURL=back.js.map
|
|
8
|
+
//# sourceMappingURL=back.js.map
|
|
@@ -4,26 +4,9 @@ import { StyledButton } from "../../../components/buttons/index.js";
|
|
|
4
4
|
import { useMintMoneyConfig } from "../../../context.js";
|
|
5
5
|
import { ModalViewContainer } from "../../container.js";
|
|
6
6
|
const CardIntentViewContent = () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ref: modalRef,
|
|
11
|
-
children: _jsxs("div", {
|
|
12
|
-
className: "button-group",
|
|
13
|
-
children: [
|
|
14
|
-
_jsx(StyledButton, {
|
|
15
|
-
variant: "primary",
|
|
16
|
-
theme: config.theme,
|
|
17
|
-
children: "Connect Wallet",
|
|
18
|
-
}),
|
|
19
|
-
_jsx(StyledButton, {
|
|
20
|
-
variant: "primary",
|
|
21
|
-
theme: config.theme,
|
|
22
|
-
children: "Direct Payment",
|
|
23
|
-
}),
|
|
24
|
-
],
|
|
25
|
-
}),
|
|
26
|
-
});
|
|
7
|
+
const modalRef = useRef(null);
|
|
8
|
+
const config = useMintMoneyConfig();
|
|
9
|
+
return (_jsx(ModalViewContainer, { ref: modalRef, children: _jsxs("div", { className: "button-group", children: [_jsx(StyledButton, { variant: "primary", theme: config.theme, children: "Connect Wallet" }), _jsx(StyledButton, { variant: "primary", theme: config.theme, children: "Direct Payment" })] }) }));
|
|
27
10
|
};
|
|
28
11
|
export { CardIntentViewContent };
|
|
29
|
-
//# sourceMappingURL=details.js.map
|
|
12
|
+
//# sourceMappingURL=details.js.map
|
|
@@ -1,50 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useRef } from "react";
|
|
3
|
-
import {
|
|
4
|
-
useModalWithView,
|
|
5
|
-
SelectableList,
|
|
6
|
-
Text,
|
|
7
|
-
Loader,
|
|
8
|
-
} from "../../../components/index.js";
|
|
3
|
+
import { useModalWithView, SelectableList, Text, Loader, } from "../../../components/index.js";
|
|
9
4
|
import { useMintMoneyConfig } from "../../../context.js";
|
|
10
|
-
import {
|
|
11
|
-
useCheckoutStore,
|
|
12
|
-
ACTIONS,
|
|
13
|
-
createCheckoutCryptoPaymentAttempt,
|
|
14
|
-
} from "../../../state/checkout/store.js";
|
|
5
|
+
import { useCheckoutStore, ACTIONS, createCheckoutCryptoPaymentAttempt, } from "../../../state/checkout/store.js";
|
|
15
6
|
import { ModalViewContainer } from "../../container.js";
|
|
16
7
|
const CryptontentSelectCurrencyViewContent = () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
ref: modalRef,
|
|
33
|
-
children: [
|
|
34
|
-
_jsx(Text, {
|
|
35
|
-
size: "base",
|
|
36
|
-
color: config.theme.font.color.tertiary,
|
|
37
|
-
weight: "normal",
|
|
38
|
-
children: "Select a currency to complete payment with.",
|
|
39
|
-
}),
|
|
40
|
-
_jsx(SelectableList, {
|
|
41
|
-
items: cryptoCurrencies ?? [],
|
|
42
|
-
getKey: (currency) => currency.asset,
|
|
43
|
-
getLabel: (currency) => `${currency.chain_name} ${currency.asset_name}`,
|
|
44
|
-
onSelect: handleSelectCurrency,
|
|
45
|
-
}),
|
|
46
|
-
],
|
|
47
|
-
});
|
|
8
|
+
const modalRef = useRef(null);
|
|
9
|
+
const { goToView } = useModalWithView();
|
|
10
|
+
const { checkout, cryptoCurrencies, loading } = useCheckoutStore();
|
|
11
|
+
const config = useMintMoneyConfig();
|
|
12
|
+
const isLoading = loading[ACTIONS.GET_CRYPTO_CURRENCIES] ||
|
|
13
|
+
loading[ACTIONS.CREATE_PAYMENT_ATTEMPT];
|
|
14
|
+
if (checkout && !checkout.checkout_config.crypto?.enabled)
|
|
15
|
+
goToView("failed", { reason: "crypto_not_enabled" });
|
|
16
|
+
const handleSelectCurrency = async (currency) => {
|
|
17
|
+
await createCheckoutCryptoPaymentAttempt(currency, config.cryptoCheckoutConfig.numBlockConfirmations);
|
|
18
|
+
goToView("cryptoIntentDirectDetails");
|
|
19
|
+
};
|
|
20
|
+
if (isLoading)
|
|
21
|
+
return _jsx(Loader, {});
|
|
22
|
+
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(Text, { size: "base", color: config.theme.font.color.tertiary, weight: "normal", children: "Select a currency to complete payment with." }), _jsx(SelectableList, { items: cryptoCurrencies ?? [], getKey: (currency) => currency.asset, getLabel: (currency) => `${currency.chain_name} ${currency.asset_name}`, onSelect: handleSelectCurrency })] }));
|
|
48
23
|
};
|
|
49
24
|
export { CryptontentSelectCurrencyViewContent };
|
|
50
|
-
//# sourceMappingURL=curreny.js.map
|
|
25
|
+
//# sourceMappingURL=curreny.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curreny.js","sourceRoot":"","sources":["../../../../../src/checkout/views/crypto-intent/curreny.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG/B,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,IAAI,EACJ,MAAM,GACP,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,kCAAkC,GACnC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MA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2
2
|
import { useRef } from "react";
|
|
3
3
|
//@ts-expect-error import error
|
|
4
4
|
import { QRCode } from "react-qr-code";
|
|
5
|
-
import {
|
|
6
|
-
useModalWithView,
|
|
7
|
-
StyledButton,
|
|
8
|
-
Text,
|
|
9
|
-
} from "../../../components/index.js";
|
|
5
|
+
import { useModalWithView, StyledButton, Text, } from "../../../components/index.js";
|
|
10
6
|
import { useMintMoneyConfig } from "../../../context.js";
|
|
11
7
|
import { useCheckoutStore } from "../../../state/checkout/store.js";
|
|
12
8
|
import { ModalViewContainer } from "../../container.js";
|
|
13
9
|
const CryptoIntentDirectDetailsViewContent = () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
return _jsxs(ModalViewContainer, {
|
|
30
|
-
ref: modalRef,
|
|
31
|
-
children: [
|
|
32
|
-
_jsx(Text, {
|
|
33
|
-
size: "base",
|
|
34
|
-
weight: "normal",
|
|
35
|
-
color: config.theme.font.color.secondary,
|
|
36
|
-
children: "Scan the QR code or copy the address to send payment.",
|
|
37
|
-
}),
|
|
38
|
-
_jsx("div", {
|
|
39
|
-
className: "mm-qr-container",
|
|
40
|
-
children: _jsx(QRCode, {
|
|
41
|
-
value: cryptoPaymentAttempt.destination_address,
|
|
42
|
-
size: 160,
|
|
43
|
-
}),
|
|
44
|
-
}),
|
|
45
|
-
_jsxs("div", {
|
|
46
|
-
className: "mm-address-container",
|
|
47
|
-
children: [
|
|
48
|
-
_jsx(Text, {
|
|
49
|
-
size: "sm",
|
|
50
|
-
weight: "light",
|
|
51
|
-
color: config.theme.font.color.tertiary,
|
|
52
|
-
children: cryptoPaymentAttempt.destination_address,
|
|
53
|
-
}),
|
|
54
|
-
_jsx("button", {
|
|
55
|
-
className: "copy-button",
|
|
56
|
-
onClick: copyToClipboard,
|
|
57
|
-
children: "Copy",
|
|
58
|
-
}),
|
|
59
|
-
],
|
|
60
|
-
}),
|
|
61
|
-
_jsx(StyledButton, {
|
|
62
|
-
onClick: handleConfirm,
|
|
63
|
-
variant: "primary",
|
|
64
|
-
children: "Confirm",
|
|
65
|
-
}),
|
|
66
|
-
],
|
|
67
|
-
});
|
|
10
|
+
const modalRef = useRef(null);
|
|
11
|
+
const { goToView } = useModalWithView();
|
|
12
|
+
const { cryptoPaymentAttempt } = useCheckoutStore();
|
|
13
|
+
const config = useMintMoneyConfig();
|
|
14
|
+
const handleConfirm = () => {
|
|
15
|
+
goToView("cryptoIntentPaymentStatus");
|
|
16
|
+
};
|
|
17
|
+
if (!cryptoPaymentAttempt) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const copyToClipboard = async () => {
|
|
21
|
+
await navigator.clipboard.writeText(cryptoPaymentAttempt.destination_address);
|
|
22
|
+
};
|
|
23
|
+
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(Text, { size: "base", weight: "normal", color: config.theme.font.color.secondary, children: "Scan the QR code or copy the address to send payment." }), _jsx("div", { className: "mm-qr-container", children: _jsx(QRCode, { value: cryptoPaymentAttempt.destination_address, size: 160 }) }), _jsxs("div", { className: "mm-address-container", children: [_jsx(Text, { size: "sm", weight: "light", color: config.theme.font.color.tertiary, children: cryptoPaymentAttempt.destination_address }), _jsx("button", { className: "copy-button", onClick: copyToClipboard, children: "Copy" })] }), _jsx(StyledButton, { onClick: handleConfirm, variant: "primary", children: "Confirm" })] }));
|
|
68
24
|
};
|
|
69
25
|
export { CryptoIntentDirectDetailsViewContent };
|
|
70
|
-
//# sourceMappingURL=direct-details.js.map
|
|
26
|
+
//# sourceMappingURL=direct-details.js.map
|
|
@@ -3,32 +3,24 @@ import { useRef } from "react";
|
|
|
3
3
|
import { useModalWithView, SelectableList } from "../../../components/index.js";
|
|
4
4
|
import { ModalViewContainer } from "../../container.js";
|
|
5
5
|
const CryptoIntentViewContent = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
ref: modalRef,
|
|
25
|
-
children: _jsx(SelectableList, {
|
|
26
|
-
items: methods,
|
|
27
|
-
getKey: (method) => method.key,
|
|
28
|
-
getLabel: (method) => method.label,
|
|
29
|
-
onSelect: handleMethodSelect,
|
|
30
|
-
}),
|
|
31
|
-
});
|
|
6
|
+
const modalRef = useRef(null);
|
|
7
|
+
const { goToView } = useModalWithView();
|
|
8
|
+
const methods = [
|
|
9
|
+
{
|
|
10
|
+
key: "wallet",
|
|
11
|
+
label: "Connect Wallet",
|
|
12
|
+
view: "cryptoIntentSelectCurrency",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
key: "direct",
|
|
16
|
+
label: "Direct Payment",
|
|
17
|
+
view: "cryptoIntentSelectCurrency",
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
const handleMethodSelect = () => {
|
|
21
|
+
goToView("cryptoIntentSelectCurrency");
|
|
22
|
+
};
|
|
23
|
+
return (_jsx(ModalViewContainer, { ref: modalRef, children: _jsx(SelectableList, { items: methods, getKey: (method) => method.key, getLabel: (method) => method.label, onSelect: handleMethodSelect }) }));
|
|
32
24
|
};
|
|
33
25
|
export { CryptoIntentViewContent };
|
|
34
|
-
//# sourceMappingURL=methods.js.map
|
|
26
|
+
//# sourceMappingURL=methods.js.map
|
|
@@ -1,48 +1,40 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
+
import { PaymentStatus } from "../../../api/types.js";
|
|
3
4
|
import { useModalWithView, Loader, Text } from "../../../components/index.js";
|
|
4
5
|
import { useMintMoneyConfig } from "../../../context.js";
|
|
5
6
|
import { getPayment } from "../../../state/checkout/store.js";
|
|
6
7
|
const POLL_INTERVAL = 5000;
|
|
7
8
|
const CryptoIntentPaymentStatusViewContent = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
className: "loading-container",
|
|
37
|
-
children: [
|
|
38
|
-
_jsx(Loader, { asChild: true }),
|
|
39
|
-
_jsx(Text, {
|
|
40
|
-
size: "base",
|
|
41
|
-
color: config.theme.font.color.tertiary,
|
|
42
|
-
children: "Payment pending...",
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
45
|
-
});
|
|
9
|
+
const { goToView } = useModalWithView();
|
|
10
|
+
const config = useMintMoneyConfig();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
let isMounted = true;
|
|
13
|
+
const pollPaymentStatus = async () => {
|
|
14
|
+
try {
|
|
15
|
+
const updatedPayment = await getPayment();
|
|
16
|
+
if (!updatedPayment || !isMounted)
|
|
17
|
+
return;
|
|
18
|
+
if (updatedPayment.status ===
|
|
19
|
+
config.cryptoCheckoutConfig.paymentConfirmationStatus) {
|
|
20
|
+
goToView("cryptoIntentPaymentSuccess");
|
|
21
|
+
}
|
|
22
|
+
else if (updatedPayment.status === PaymentStatus.FAILED) {
|
|
23
|
+
goToView("failed");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error("Error fetching payment status:", error);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
void pollPaymentStatus();
|
|
31
|
+
const interval = setInterval(async () => await pollPaymentStatus(), POLL_INTERVAL);
|
|
32
|
+
return () => {
|
|
33
|
+
isMounted = false;
|
|
34
|
+
clearInterval(interval);
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
return (_jsxs("div", { className: "loading-container", children: [_jsx(Loader, { asChild: true }), _jsx(Text, { size: "base", color: config.theme.font.color.tertiary, children: "Payment pending..." })] }));
|
|
46
38
|
};
|
|
47
39
|
export { CryptoIntentPaymentStatusViewContent };
|
|
48
|
-
//# sourceMappingURL=processing.js.map
|
|
40
|
+
//# sourceMappingURL=processing.js.map
|