@sikka/hawa 0.0.1 → 0.0.4
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/.github/workflows/hawa-publish-push.yml +45 -0
- package/.github/workflows/hawa-publish.yml +45 -0
- package/.prettierrc +28 -28
- package/README.md +149 -119
- package/es/index.es.js +1 -0
- package/lib/index.js +1 -0
- package/package.json +59 -47
- package/rollup.config.js +30 -40
- package/src/Assets/images/card-background/1.jpeg +0 -0
- package/src/Assets/images/card-background/10.jpeg +0 -0
- package/src/Assets/images/card-background/11.jpeg +0 -0
- package/src/Assets/images/card-background/12.jpeg +0 -0
- package/src/Assets/images/card-background/13.jpeg +0 -0
- package/src/Assets/images/card-background/14.jpeg +0 -0
- package/src/Assets/images/card-background/15.jpeg +0 -0
- package/src/Assets/images/card-background/16.jpeg +0 -0
- package/src/Assets/images/card-background/17.jpeg +0 -0
- package/src/Assets/images/card-background/18.jpeg +0 -0
- package/src/Assets/images/card-background/19.jpeg +0 -0
- package/src/Assets/images/card-background/2.jpeg +0 -0
- package/src/Assets/images/card-background/20.jpeg +0 -0
- package/src/Assets/images/card-background/21.jpeg +0 -0
- package/src/Assets/images/card-background/22.jpeg +0 -0
- package/src/Assets/images/card-background/23.jpeg +0 -0
- package/src/Assets/images/card-background/24.jpeg +0 -0
- package/src/Assets/images/card-background/25.jpeg +0 -0
- package/src/Assets/images/card-background/3.jpeg +0 -0
- package/src/Assets/images/card-background/4.jpeg +0 -0
- package/src/Assets/images/card-background/5.jpeg +0 -0
- package/src/Assets/images/card-background/6.jpeg +0 -0
- package/src/Assets/images/card-background/7.jpeg +0 -0
- package/src/Assets/images/card-background/8.jpeg +0 -0
- package/src/Assets/images/card-background/9.jpeg +0 -0
- package/src/Assets/images/card-type/amex.png +0 -0
- package/src/Assets/images/card-type/diners.png +0 -0
- package/src/Assets/images/card-type/discover.png +0 -0
- package/src/Assets/images/card-type/mastercard.png +0 -0
- package/src/Assets/images/card-type/troy.png +0 -0
- package/src/Assets/images/card-type/unionpay.png +0 -0
- package/src/Assets/images/card-type/visa.png +0 -0
- package/src/blocks/Account/UserProfile.js +15 -0
- package/src/blocks/Account/UserSettings.js +15 -0
- package/src/blocks/Account/index.js +2 -0
- package/src/blocks/AuthForms/NewPasswordForm.js +17 -0
- package/src/blocks/AuthForms/ResetPasswordForm.js +14 -0
- package/src/blocks/AuthForms/SignInForm.js +19 -0
- package/src/blocks/AuthForms/SignUpForm.js +20 -0
- package/src/blocks/AuthForms/index.js +4 -0
- package/src/blocks/AuthForms/viaFacebook.js +0 -0
- package/src/blocks/AuthForms/viaGithub.js +0 -0
- package/src/blocks/AuthForms/viaGoogle.js +0 -0
- package/src/blocks/AuthForms/viaTwitter.js +0 -0
- package/src/blocks/Payment/Form/CForm.js +326 -0
- package/src/blocks/Payment/Form/Card.js +242 -0
- package/src/blocks/Payment/Gateway/GooglePay.js +251 -0
- package/src/blocks/Payment/Gateway/Payfort.js +90 -0
- package/src/blocks/Payment/Gateway/Paypal.js +138 -0
- package/src/blocks/Payment/Gateway/Wallet.js +149 -0
- package/src/blocks/Payment/PaymentMethod.js +132 -0
- package/src/blocks/index.js +13 -0
- package/src/index.js +2 -1
- package/src/layout/Box.js +25 -0
- package/src/layout/index.js +1 -0
- package/src/stories/ActionButton.stories.js +49 -0
- package/src/stories/AdaptiveButton.stories.js +80 -84
- package/src/stories/Alert.stories.js +41 -0
- package/src/stories/AuthForm.stories.js +79 -0
- package/src/stories/Box.stories.js +64 -0
- package/src/stories/CheckBox.stories.js +35 -33
- package/src/stories/GlobalVariables.stories.js +101 -108
- package/src/stories/HawaProvider.stories.js +23 -23
- package/src/stories/InputLabel.stories.js +92 -100
- package/src/stories/Introduction.stories.js +211 -0
- package/src/stories/RadioSelector.stories.js +69 -69
- package/src/stories/TextField.stories.js +50 -59
- package/src/stories/UserAccount.stories.js +46 -0
- package/src/styles.css +400 -403
- package/src/styles.scss +679 -0
- package/src/themes/HawaProvider.js +45 -0
- package/src/ui/ActionButton.js +15 -0
- package/src/{components/Hawa/AdaptiveButton/AdaptiveButton.jsx → ui/AdaptiveButton.js} +252 -261
- package/src/{components/Hawa/AutoCompleteField/AutoCompleteField.jsx → ui/AutoCompleteField.js} +33 -33
- package/src/{components/Hawa/Checkbox/Checkbox.jsx → ui/Checkbox.js} +21 -20
- package/src/{components/Hawa/DragDropImages/DragDropImages.jsx → ui/DragDropImages.js} +180 -180
- package/src/{components/Hawa/Hawa.jsx → ui/Hawa.js} +3 -3
- package/src/{components/Hawa/RadioBox/RadioBox.jsx → ui/RadioBox.js} +29 -29
- package/src/{components/Hawa/RadioSelector/RadioSelector.jsx → ui/RadioSelector.js} +51 -51
- package/src/ui/Row.js +21 -0
- package/src/{components/Hawa/SelectedField/SelectedField.jsx → ui/SelectedField.js} +46 -46
- package/src/ui/StyledAlert.js +30 -0
- package/src/ui/StyledInputLabel.js +19 -0
- package/src/ui/StyledTooltip.js +46 -0
- package/src/{components/Hawa/TabPanel/TabPanel.jsx → ui/TabPanel.js} +37 -38
- package/src/{components/Hawa/TextArea/TextArea.jsx → ui/TextArea.js} +38 -39
- package/src/ui/TextField.js +62 -0
- package/src/{components/Hawa → ui}/index.js +13 -11
- package/src/util.js +20 -0
- package/storybook-static/0.d3bc3395610cf5d3ee94.manager.bundle.js +1 -0
- package/storybook-static/0.dd3d47f5.iframe.bundle.js +1 -0
- package/storybook-static/1.4e43f671.iframe.bundle.js +3 -0
- package/storybook-static/{4.f6eb74f4.iframe.bundle.js.LICENSE.txt → 1.4e43f671.iframe.bundle.js.LICENSE.txt} +8 -8
- package/storybook-static/1.4e43f671.iframe.bundle.js.map +1 -0
- package/storybook-static/2.9a757207.iframe.bundle.js +1 -0
- package/storybook-static/3.c1dc7159.iframe.bundle.js +1 -0
- package/storybook-static/4.8c311a6b48cad9f29317.manager.bundle.js +2 -0
- package/storybook-static/{5.fa71488e730c5c7f885f.manager.bundle.js.LICENSE.txt → 4.8c311a6b48cad9f29317.manager.bundle.js.LICENSE.txt} +8 -8
- package/storybook-static/5.88fe62ee92ff5ca67829.manager.bundle.js +1 -0
- package/storybook-static/6.96d184f368dea006cb52.manager.bundle.js +2 -0
- package/storybook-static/{11.49c687eaa6261f8b7be2.manager.bundle.js.LICENSE.txt → 6.96d184f368dea006cb52.manager.bundle.js.LICENSE.txt} +12 -12
- package/storybook-static/{7.a806a38f.iframe.bundle.js → 7.5ec31f3702b08ab0b71c.manager.bundle.js} +1 -1
- package/storybook-static/7.69d2e532.iframe.bundle.js +1 -0
- package/storybook-static/8.5ce13be7612bd3a6b864.manager.bundle.js +1 -0
- package/storybook-static/8.68cd1217.iframe.bundle.js +3 -0
- package/storybook-static/{6.fbc7b90b.iframe.bundle.js.LICENSE.txt → 8.68cd1217.iframe.bundle.js.LICENSE.txt} +12 -12
- package/storybook-static/8.68cd1217.iframe.bundle.js.map +1 -0
- package/storybook-static/9.488e3969.iframe.bundle.js +1 -0
- package/storybook-static/iframe.html +348 -138
- package/storybook-static/index.html +59 -47
- package/storybook-static/main.65cb2769.iframe.bundle.js +1 -0
- package/storybook-static/main.7e391cf7bf72b0d18ea5.manager.bundle.js +1 -0
- package/storybook-static/runtime~main.6e2e1544.iframe.bundle.js +1 -0
- package/storybook-static/runtime~main.cc29f4c2175f187a3707.manager.bundle.js +1 -0
- package/storybook-static/vendors~main.d144d840.iframe.bundle.js +3 -0
- package/storybook-static/{vendors~main.73411ca9.iframe.bundle.js.LICENSE.txt → vendors~main.d144d840.iframe.bundle.js.LICENSE.txt} +148 -148
- package/storybook-static/vendors~main.d144d840.iframe.bundle.js.map +1 -0
- package/storybook-static/vendors~main.f228d62e92b69563cefb.manager.bundle.js +2 -0
- package/storybook-static/{vendors~main.d3455eed64b243c89325.manager.bundle.js.LICENSE.txt → vendors~main.f228d62e92b69563cefb.manager.bundle.js.LICENSE.txt} +104 -88
- package/tools/build-styles.js +17 -0
- package/yarn-error.log +10910 -0
- package/src/components/Hawa/AdaptiveButton/index.js +0 -1
- package/src/components/Hawa/AutoCompleteField/index.js +0 -1
- package/src/components/Hawa/Checkbox/index.js +0 -1
- package/src/components/Hawa/DragDropImages/index.js +0 -1
- package/src/components/Hawa/HawaProvider/HawaProvider.js +0 -19
- package/src/components/Hawa/HawaProvider/index.js +0 -1
- package/src/components/Hawa/InputLabel/StyledInputLabel.jsx +0 -36
- package/src/components/Hawa/InputLabel/index.js +0 -1
- package/src/components/Hawa/RadioBox/index.js +0 -1
- package/src/components/Hawa/RadioSelector/index.js +0 -1
- package/src/components/Hawa/Row/Row.jsx +0 -23
- package/src/components/Hawa/Row/index.js +0 -1
- package/src/components/Hawa/SelectedField/index.js +0 -1
- package/src/components/Hawa/TabPanel/index.js +0 -1
- package/src/components/Hawa/TextArea/index.js +0 -1
- package/src/components/Hawa/TextField/TextField.jsx +0 -41
- package/src/components/Hawa/TextField/index.js +0 -1
- package/storybook-static/0.86a7edfd.iframe.bundle.js +0 -1
- package/storybook-static/0.b73eaee9a88f178d62ed.manager.bundle.js +0 -1
- package/storybook-static/1.f296d183a17268696d73.manager.bundle.js +0 -1
- package/storybook-static/10.9998ba67d65d81d20896.manager.bundle.js +0 -1
- package/storybook-static/11.49c687eaa6261f8b7be2.manager.bundle.js +0 -2
- package/storybook-static/12.c9538ed3766c96f289e7.manager.bundle.js +0 -1
- package/storybook-static/4.f6eb74f4.iframe.bundle.js +0 -3
- package/storybook-static/4.f6eb74f4.iframe.bundle.js.map +0 -1
- package/storybook-static/5.ec6f37af.iframe.bundle.js +0 -1
- package/storybook-static/5.fa71488e730c5c7f885f.manager.bundle.js +0 -2
- package/storybook-static/6.8096ae4aadde0743697b.manager.bundle.js +0 -1
- package/storybook-static/6.fbc7b90b.iframe.bundle.js +0 -3
- package/storybook-static/6.fbc7b90b.iframe.bundle.js.map +0 -1
- package/storybook-static/7.b34baecbd082bc7b188d.manager.bundle.js +0 -1
- package/storybook-static/8.15577edffecf900a8de2.manager.bundle.js +0 -1
- package/storybook-static/9.d7d85aa0a49a98f17218.manager.bundle.js +0 -1
- package/storybook-static/main.355ffc59.iframe.bundle.js +0 -1
- package/storybook-static/main.ce406c7e93b98325390e.manager.bundle.js +0 -1
- package/storybook-static/runtime~main.3d81579b.iframe.bundle.js +0 -1
- package/storybook-static/runtime~main.909d038f912f063e8837.manager.bundle.js +0 -1
- package/storybook-static/vendors~main.73411ca9.iframe.bundle.js +0 -3
- package/storybook-static/vendors~main.73411ca9.iframe.bundle.js.map +0 -1
- package/storybook-static/vendors~main.d3455eed64b243c89325.manager.bundle.js +0 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyledTextField, ActionButton } from "../../ui";
|
|
3
|
+
import { Box } from '../../layout'
|
|
4
|
+
|
|
5
|
+
export const UserProfile = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<Box maxWidth={400}>
|
|
8
|
+
<StyledTextField type="text" inputLabel="First Name" />
|
|
9
|
+
<StyledTextField type="text" inputLabel="Last Name" />
|
|
10
|
+
<StyledTextField type="email" inputLabel="Email" />
|
|
11
|
+
<StyledTextField type="password" inputLabel="Password" />
|
|
12
|
+
<ActionButton last text="Update Account" />
|
|
13
|
+
</Box>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyledTextField, ActionButton } from "../../ui";
|
|
3
|
+
import { Box } from '../../layout'
|
|
4
|
+
|
|
5
|
+
export const UserSettings = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<Box maxWidth={400}>
|
|
8
|
+
<StyledTextField type="text" inputLabel="First Name" />
|
|
9
|
+
<StyledTextField type="text" inputLabel="Last Name" />
|
|
10
|
+
<StyledTextField type="email" inputLabel="Email" />
|
|
11
|
+
<StyledTextField type="password" inputLabel="Password" />
|
|
12
|
+
<ActionButton last text="Update Account" />
|
|
13
|
+
</Box>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { Box } from "../../layout";
|
|
3
|
+
import { ThemeProvider } from "../../themes/HawaProvider";
|
|
4
|
+
import { StyledTextField, StyledInputLabel } from "../../ui";
|
|
5
|
+
export const NewPasswordForm = (props) => {
|
|
6
|
+
const theme = useContext(ThemeProvider);
|
|
7
|
+
return (
|
|
8
|
+
<Box maxWidth={400} >
|
|
9
|
+
|
|
10
|
+
<StyledInputLabel label="Password" />
|
|
11
|
+
<StyledTextField type="password" />
|
|
12
|
+
<StyledInputLabel label="Confirm Password" />
|
|
13
|
+
<StyledTextField type="password" />
|
|
14
|
+
{props.children}
|
|
15
|
+
</Box>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { Box } from "../../layout";
|
|
3
|
+
import { ThemeProvider } from "../../themes/HawaProvider";
|
|
4
|
+
import { StyledTextField, StyledInputLabel } from "../../ui";
|
|
5
|
+
export const ResetPasswordForm = (props) => {
|
|
6
|
+
const theme = useContext(ThemeProvider);
|
|
7
|
+
return (
|
|
8
|
+
<Box maxWidth={400} >
|
|
9
|
+
<StyledInputLabel label="Email" />
|
|
10
|
+
<StyledTextField type="text" />
|
|
11
|
+
{props.children}
|
|
12
|
+
</Box>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { ThemeProvider } from "../../themes/HawaProvider";
|
|
3
|
+
import { StyledTextField, StyledInputLabel } from "../../ui";
|
|
4
|
+
import { Box } from '../../layout'
|
|
5
|
+
export const SignInForm = (props) => {
|
|
6
|
+
const theme = useContext(ThemeProvider);
|
|
7
|
+
return (
|
|
8
|
+
<Box maxWidth={400}>
|
|
9
|
+
|
|
10
|
+
<StyledInputLabel label="Email" />
|
|
11
|
+
<StyledTextField type="text" />
|
|
12
|
+
<StyledInputLabel label="Password" />
|
|
13
|
+
<StyledTextField type="text" />
|
|
14
|
+
|
|
15
|
+
{props.children}
|
|
16
|
+
|
|
17
|
+
</Box>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { Box } from "../../layout";
|
|
3
|
+
import { ThemeProvider } from "../../themes/HawaProvider";
|
|
4
|
+
import { StyledTextField, StyledInputLabel } from "../../ui";
|
|
5
|
+
|
|
6
|
+
export const SignUpForm = (props) => {
|
|
7
|
+
const theme = useContext(ThemeProvider);
|
|
8
|
+
return (
|
|
9
|
+
<Box maxWidth={400}>
|
|
10
|
+
|
|
11
|
+
<StyledInputLabel label="Email" />
|
|
12
|
+
<StyledTextField type="text" />
|
|
13
|
+
<StyledInputLabel label="Password" />
|
|
14
|
+
<StyledTextField type="text" />
|
|
15
|
+
<StyledInputLabel label="Confirm Password" />
|
|
16
|
+
<StyledTextField type="text" />
|
|
17
|
+
{props.children}
|
|
18
|
+
</Box>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from "react";
|
|
2
|
+
import sha256 from "crypto-js/sha256";
|
|
3
|
+
import Button from "@material-ui/core/Button";
|
|
4
|
+
import CircularProgress from "@material-ui/core/CircularProgress";
|
|
5
|
+
import useTranslation from "next-translate/useTranslation";
|
|
6
|
+
import axios from "axios";
|
|
7
|
+
|
|
8
|
+
const currentYear = new Date().getFullYear();
|
|
9
|
+
const monthsArr = Array.from({ length: 12 }, (x, i) => {
|
|
10
|
+
const month = i + 1;
|
|
11
|
+
return month <= 9 ? "0" + month : month;
|
|
12
|
+
});
|
|
13
|
+
const yearsArr = Array.from({ length: 9 }, (_x, i) => currentYear + i);
|
|
14
|
+
|
|
15
|
+
export default function CForm({
|
|
16
|
+
cardHolder,
|
|
17
|
+
cardMonth,
|
|
18
|
+
cardYear,
|
|
19
|
+
cardCvv,
|
|
20
|
+
onUpdateState,
|
|
21
|
+
cardNumberRef,
|
|
22
|
+
cardHolderRef,
|
|
23
|
+
cardDateRef,
|
|
24
|
+
cardCvvRef,
|
|
25
|
+
onCardInputFocus,
|
|
26
|
+
onCardInputBlur,
|
|
27
|
+
children,
|
|
28
|
+
selectedPaymentMethod,
|
|
29
|
+
transaction
|
|
30
|
+
}) {
|
|
31
|
+
const payfortFormref = useRef();
|
|
32
|
+
const [loading, setLoading] = useState(false);
|
|
33
|
+
const [cardNumber, setCardNumber] = useState("");
|
|
34
|
+
const [accessCode, setAccessCode] = useState("");
|
|
35
|
+
const [merchantIdentifier, setMerchantIdentifier] = useState("");
|
|
36
|
+
const [shaRequestPassphrase, setSHARequestPassphrase] = useState("");
|
|
37
|
+
const [expiryDate, setExpiryDate] = useState("");
|
|
38
|
+
const [signature, setSignature] = useState("");
|
|
39
|
+
const [ip, setIP] = useState("");
|
|
40
|
+
const { t, lang } = useTranslation("common");
|
|
41
|
+
|
|
42
|
+
const handleFormChange = (event) => {
|
|
43
|
+
const { name, value } = event.target;
|
|
44
|
+
|
|
45
|
+
onUpdateState(name, value);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const getData = async () => {
|
|
49
|
+
const res = await axios.get("https://geolocation-db.com/json/");
|
|
50
|
+
console.log(res.data);
|
|
51
|
+
setIP(res.data.IPv4);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const generateSignature = () => {
|
|
55
|
+
// Calculate request signature
|
|
56
|
+
let shaString = "";
|
|
57
|
+
|
|
58
|
+
// array request
|
|
59
|
+
let arrData = {
|
|
60
|
+
access_code: process.env.NEXT_PUBLIC_QAWAIM_SOFTWARE_PAYFOR_ACCESS_TOKEN,
|
|
61
|
+
language: lang,
|
|
62
|
+
merchant_identifier:
|
|
63
|
+
process.env.NEXT_PUBLIC_QAWAIM_SOFTWARE_PAYFOR_MERCHANT_ID,
|
|
64
|
+
merchant_reference: "",
|
|
65
|
+
return_url: `${process.env.NEXT_PUBLIC_QAWAIM_USER_PORTAL_URL}/aps_online/response`,
|
|
66
|
+
service_command: "TOKENIZATION"
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (
|
|
70
|
+
transaction &&
|
|
71
|
+
transaction?.getTransactionByIDInvoice?.transaction_payment_token
|
|
72
|
+
) {
|
|
73
|
+
arrData.token_name =
|
|
74
|
+
transaction?.getTransactionByIDInvoice?.transaction_payment_token;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log("arrData=", arrData);
|
|
78
|
+
|
|
79
|
+
shaString = `${process.env.NEXT_PUBLIC_QAWAIM_SOFTWARE_PAYFOR_SHA_REQUEST_PHRASE}${shaString}`;
|
|
80
|
+
for (const [key, value] of Object.entries(arrData)) {
|
|
81
|
+
shaString = `${shaString}${key}=${value}`;
|
|
82
|
+
}
|
|
83
|
+
shaString = `${shaString}${process.env.NEXT_PUBLIC_QAWAIM_SOFTWARE_PAYFOR_SHA_REQUEST_PHRASE}`;
|
|
84
|
+
|
|
85
|
+
console.log("shaString=", shaString);
|
|
86
|
+
|
|
87
|
+
// your request signature
|
|
88
|
+
let signature = sha256(shaString);
|
|
89
|
+
|
|
90
|
+
console.log("signature=", signature);
|
|
91
|
+
setSignature(signature);
|
|
92
|
+
};
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (selectedPaymentMethod && selectedPaymentMethod !== "APPLEPAY") {
|
|
95
|
+
getData();
|
|
96
|
+
generateSignature();
|
|
97
|
+
}
|
|
98
|
+
}, [selectedPaymentMethod, accessCode, shaRequestPassphrase]);
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (cardMonth && cardYear) {
|
|
102
|
+
setExpiryDate(`${cardYear.substring(2)}${cardMonth}`);
|
|
103
|
+
}
|
|
104
|
+
}, [cardMonth, cardYear]);
|
|
105
|
+
|
|
106
|
+
// TODO: We can improve the regex check with a better approach like in the card component.
|
|
107
|
+
const onCardNumberChange = (event) => {
|
|
108
|
+
let { value, name } = event.target;
|
|
109
|
+
let cardNumber = value;
|
|
110
|
+
value = value.replace(/\D/g, "");
|
|
111
|
+
if (/^3[47]\d{0,13}$/.test(value)) {
|
|
112
|
+
cardNumber = value
|
|
113
|
+
.replace(/(\d{4})/, "$1 ")
|
|
114
|
+
.replace(/(\d{4}) (\d{6})/, "$1 $2 ");
|
|
115
|
+
} else if (/^3(?:0[0-5]|[68]\d)\d{0,11}$/.test(value)) {
|
|
116
|
+
// diner's club, 14 digits
|
|
117
|
+
cardNumber = value
|
|
118
|
+
.replace(/(\d{4})/, "$1 ")
|
|
119
|
+
.replace(/(\d{4}) (\d{6})/, "$1 $2 ");
|
|
120
|
+
} else if (/^\d{0,16}$/.test(value)) {
|
|
121
|
+
// regular cc number, 16 digits
|
|
122
|
+
cardNumber = value
|
|
123
|
+
.replace(/(\d{4})/, "$1 ")
|
|
124
|
+
.replace(/(\d{4}) (\d{4})/, "$1 $2 ")
|
|
125
|
+
.replace(/(\d{4}) (\d{4}) (\d{4})/, "$1 $2 $3 ");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
setCardNumber(cardNumber.trimRight());
|
|
129
|
+
onUpdateState(name, cardNumber);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const onCvvFocus = (event) => {
|
|
133
|
+
onUpdateState("isCardFlipped", true);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const onCvvBlur = (event) => {
|
|
137
|
+
onUpdateState("isCardFlipped", false);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const handlePayfortForm = (e) => {
|
|
141
|
+
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// NOTE: Currently the cursor on the card number field gets reset if we remove a number, the code bellow was used
|
|
145
|
+
// in class components, need to transform this to work with functional components.
|
|
146
|
+
// getSnapshotBeforeUpdate() {
|
|
147
|
+
// return this.props.cardNumberRef.current.selectionStart;
|
|
148
|
+
// }
|
|
149
|
+
|
|
150
|
+
// const componentDidUpdate = function (prevProps, prevState, cursorIdx) {
|
|
151
|
+
// const node = cardNumberRef.current;
|
|
152
|
+
// const { cardNumber: cardNum } = state;
|
|
153
|
+
// const { cardNumber: prevCardNum } = prevState;
|
|
154
|
+
// if (
|
|
155
|
+
// cardNum.length > prevCardNum.length &&
|
|
156
|
+
// cardNum[cursorIdx - 1] === ' '
|
|
157
|
+
// ) {
|
|
158
|
+
// cursorIdx += 1;
|
|
159
|
+
// } else if (prevCardNum[cursorIdx - 1] === ' ') {
|
|
160
|
+
// cursorIdx -= 1;
|
|
161
|
+
// }
|
|
162
|
+
// node.selectionStart = node.selectionEnd = cursorIdx;
|
|
163
|
+
// };
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<div className="card-form">
|
|
167
|
+
<div className="card-list">{children}</div>
|
|
168
|
+
<div className="card-form__inner">
|
|
169
|
+
<div className="card-input">
|
|
170
|
+
<label htmlFor="cardNumber" className="card-input__label">
|
|
171
|
+
{t("cardNumber")}
|
|
172
|
+
</label>
|
|
173
|
+
<input
|
|
174
|
+
type="tel"
|
|
175
|
+
name="cardNumber"
|
|
176
|
+
className="card-input__input"
|
|
177
|
+
autoComplete="off"
|
|
178
|
+
onChange={onCardNumberChange}
|
|
179
|
+
maxLength="19"
|
|
180
|
+
ref={cardNumberRef}
|
|
181
|
+
onFocus={(e) => onCardInputFocus(e, "cardNumber")}
|
|
182
|
+
onBlur={onCardInputBlur}
|
|
183
|
+
value={cardNumber}
|
|
184
|
+
/>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div className="card-input">
|
|
188
|
+
<label htmlFor="cardName" className="card-input__label">
|
|
189
|
+
{t("cardHolder")}
|
|
190
|
+
</label>
|
|
191
|
+
<input
|
|
192
|
+
type="text"
|
|
193
|
+
className="card-input__input"
|
|
194
|
+
autoComplete="off"
|
|
195
|
+
name="cardHolder"
|
|
196
|
+
onChange={handleFormChange}
|
|
197
|
+
ref={cardHolderRef}
|
|
198
|
+
onFocus={(e) => onCardInputFocus(e, "cardHolder")}
|
|
199
|
+
onBlur={onCardInputBlur}
|
|
200
|
+
/>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<div className="card-form__row">
|
|
204
|
+
<div className="card-form__col">
|
|
205
|
+
<div className="card-form__group">
|
|
206
|
+
<label htmlFor="cardMonth" className="card-input__label">
|
|
207
|
+
{t("cardExpiration")}
|
|
208
|
+
</label>
|
|
209
|
+
<select
|
|
210
|
+
className="card-input__input -select"
|
|
211
|
+
value={cardMonth}
|
|
212
|
+
name="cardMonth"
|
|
213
|
+
onChange={handleFormChange}
|
|
214
|
+
ref={cardDateRef}
|
|
215
|
+
onFocus={(e) => onCardInputFocus(e, "cardDate")}
|
|
216
|
+
onBlur={onCardInputBlur}
|
|
217
|
+
>
|
|
218
|
+
<option value="" disabled>
|
|
219
|
+
{t("cardMonth")}
|
|
220
|
+
</option>
|
|
221
|
+
|
|
222
|
+
{monthsArr.map((val, index) => (
|
|
223
|
+
<option key={index} value={val}>
|
|
224
|
+
{val}
|
|
225
|
+
</option>
|
|
226
|
+
))}
|
|
227
|
+
</select>
|
|
228
|
+
<select
|
|
229
|
+
name="cardYear"
|
|
230
|
+
className="card-input__input -select"
|
|
231
|
+
value={cardYear}
|
|
232
|
+
onChange={handleFormChange}
|
|
233
|
+
onFocus={(e) => onCardInputFocus(e, "cardDate")}
|
|
234
|
+
onBlur={onCardInputBlur}
|
|
235
|
+
>
|
|
236
|
+
<option value="" disabled>
|
|
237
|
+
{t("cardYear")}
|
|
238
|
+
</option>
|
|
239
|
+
|
|
240
|
+
{yearsArr.map((val, index) => (
|
|
241
|
+
<option key={index} value={val}>
|
|
242
|
+
{val}
|
|
243
|
+
</option>
|
|
244
|
+
))}
|
|
245
|
+
</select>
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
<div className="card-form__col -cvv">
|
|
249
|
+
<div className="card-input">
|
|
250
|
+
<label htmlFor="cardCvv" className="card-input__label">
|
|
251
|
+
{t("cvv")}
|
|
252
|
+
</label>
|
|
253
|
+
<input
|
|
254
|
+
type="tel"
|
|
255
|
+
className="card-input__input"
|
|
256
|
+
maxLength="4"
|
|
257
|
+
autoComplete="off"
|
|
258
|
+
name="cardCvv"
|
|
259
|
+
onChange={handleFormChange}
|
|
260
|
+
onFocus={onCvvFocus}
|
|
261
|
+
onBlur={onCvvBlur}
|
|
262
|
+
ref={cardCvvRef}
|
|
263
|
+
/>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
<div className="card-input" style={{ marginTop: "20px" }}>
|
|
268
|
+
<form
|
|
269
|
+
ref={payfortFormref}
|
|
270
|
+
action={`${process.env.NEXT_PUBLIC_QAWAIM_SOFTWARE_PAYFOR_ENVIRONMENT_URL}`}
|
|
271
|
+
method="POST"
|
|
272
|
+
>
|
|
273
|
+
<input type="hidden" name="access_code" value={`${accessCode}`} />
|
|
274
|
+
<input type="hidden" name="card_holder_name" value={cardHolder} />
|
|
275
|
+
<input
|
|
276
|
+
type="hidden"
|
|
277
|
+
name="card_number"
|
|
278
|
+
value={cardNumber.replace(/\s/g, "")}
|
|
279
|
+
/>
|
|
280
|
+
<input type="hidden" name="card_security_code" value={cardCvv} />
|
|
281
|
+
<input type="hidden" name="expiry_date" value={expiryDate} />
|
|
282
|
+
<input type="hidden" name="language" value={lang} />
|
|
283
|
+
<input
|
|
284
|
+
type="hidden"
|
|
285
|
+
name="merchant_identifier"
|
|
286
|
+
value={`${merchantIdentifier}`}
|
|
287
|
+
/>
|
|
288
|
+
<input type="hidden" name="merchant_reference" value={""} />
|
|
289
|
+
<input type="hidden" name="remember_me" value="NO" />
|
|
290
|
+
<input
|
|
291
|
+
type="hidden"
|
|
292
|
+
name="return_url"
|
|
293
|
+
value={`${process.env.NEXT_PUBLIC_QAWAIM_USER_PORTAL_URL}/aps_online/register`}
|
|
294
|
+
/>
|
|
295
|
+
<input type="hidden" name="service_command" value="TOKENIZATION" />
|
|
296
|
+
<input type="hidden" name="signature" value={signature} />
|
|
297
|
+
{transaction &&
|
|
298
|
+
transaction?.getTransactionByIDInvoice
|
|
299
|
+
?.transaction_payment_token && (
|
|
300
|
+
<input
|
|
301
|
+
type="hidden"
|
|
302
|
+
name="token_name"
|
|
303
|
+
value={
|
|
304
|
+
transaction?.getTransactionByIDInvoice
|
|
305
|
+
?.transaction_payment_token
|
|
306
|
+
}
|
|
307
|
+
/>
|
|
308
|
+
)}
|
|
309
|
+
</form>
|
|
310
|
+
<Button variant="contained" color="primary" fullWidth onClick={handlePayfortForm}>
|
|
311
|
+
{loading ? (
|
|
312
|
+
<CircularProgress
|
|
313
|
+
variant="indeterminate"
|
|
314
|
+
style={{ color: "white", display: "none" }}
|
|
315
|
+
size={25}
|
|
316
|
+
/>
|
|
317
|
+
) : (
|
|
318
|
+
<span className="pay-new-btn-txt">{t("pay-now")}</span>
|
|
319
|
+
)}
|
|
320
|
+
</Button>
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|