xpay-redirect 0.4.0 → 1.1.0

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,377 +0,0 @@
1
- import { CalendarMonth, Https, Person, Phone } from '@mui/icons-material';
2
- import { LoadingButton } from '@mui/lab';
3
- import { Box, Grid, InputAdornment, TextField, Typography } from '@mui/material';
4
- import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
5
- import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
6
- import { MobileDatePicker } from '@mui/x-date-pickers/MobileDatePicker';
7
- import axios from 'axios';
8
- import React from 'react';
9
- // images
10
- import FTBAccountVerify from '../../../assets/ai Icon/ai Icon-3.png';
11
-
12
- export default function RegNewAccount(props) {
13
- const { config, baseurl, sessionid, setAcctOrCardNumber, regSentOTP, setRegSentOTP, setOpenCreateAccount, startTimer } = props;
14
- const [regUserError, setRegUserError] = React.useState('');
15
- const [regAccountNum, setRegAccountNum] = React.useState('');
16
- const [regDOB, setRegDOB] = React.useState(null);
17
- const [regMobileNum, setRegMobileNum] = React.useState('');
18
- const [regAcctLoading, setRegAcctLoading] = React.useState(false);
19
- const [regOTPNum, setRegOTPNum] = React.useState('');
20
- const [regOTPConfirming, setRegOTPConfirming] = React.useState(false);
21
-
22
- const onResponse = config?.onResponse
23
- ? config.onResponse
24
- : (data) => {
25
- console.log("Xpay account register Response ::> ", data);
26
- };
27
- const onError = config?.onError
28
- ? config.onError
29
- : (err) => {
30
- throw err;
31
- };
32
-
33
- const newRegisterSubmit = (event) => {
34
- event.preventDefault();
35
-
36
- let jobj = {
37
- "sessionid": sessionid,
38
- "accountNumber": regAccountNum,
39
- "mobileNumber": regMobileNum,
40
- "dateOfBirth": Number(regDOB.toISOString().split('T')[0].replaceAll('-',''))
41
- };
42
- setRegAcctLoading(true);
43
-
44
- axios({
45
- method: "post",
46
- url: `${baseurl}/RequestEnrollUser`,
47
- timeout: 1000 * 40, // Wait for 40 seconds
48
- headers: {
49
- "Content-Type": "application/json"
50
- },
51
- data: jobj
52
- })
53
- .then(response => {
54
- onResponse({"at":"/RequestEnrollUser", "response":response.data});
55
- if (response.data.result === 0) {
56
- setRegSentOTP(true);
57
- setRegUserError('');
58
- } else {
59
- setRegSentOTP(false);
60
- setRegUserError(response.data.message);
61
- }
62
- setRegAcctLoading(false);
63
- })
64
- .catch(error => {
65
- onError({"at":"/RequestEnrollUser", "error":error?.response?.data || error?.message || error});
66
- setRegSentOTP(false);
67
- setRegAcctLoading(false);
68
- });
69
- };
70
-
71
- const confirmNewReg = (event) => {
72
- event.preventDefault();
73
-
74
- let jobj = {
75
- "sessionid": sessionid || '',
76
- "otp": regOTPNum,
77
- "accountNumber": regAccountNum
78
- };
79
- setRegOTPConfirming(true);
80
-
81
- axios({
82
- method: "post",
83
- url: `${baseurl}/VerifyandEnrollUser`,
84
- // timeout: 1000 * 40, // Wait for 40 seconds
85
- headers: {
86
- "Content-Type": "application/json"
87
- },
88
- data: jobj
89
- })
90
- .then(response => {
91
- onResponse({"at":"/VerifyandEnrollUser", "response":response.data});
92
- // ----------------
93
- setRegSentOTP(false);
94
- setAcctOrCardNumber(response?.data?.accountNumber || '');
95
- setRegOTPConfirming(false);
96
- startTimer();
97
- setOpenCreateAccount(false);
98
- })
99
- .catch(error => {
100
- onError({"at":"/VerifyandEnrollUser", "error":error?.response?.data || error?.message || error})
101
- // ----------------
102
- setRegOTPConfirming(false);
103
- });
104
- };
105
-
106
- return (
107
- <div>
108
- {regSentOTP ? (<>
109
- <Typography variant='h6' component={'div'} style={{ color:'#0a4e9c',textAlign:'center',fontWeight:'bold' }}>
110
- Account Verification
111
- </Typography>
112
-
113
- <Box
114
- sx={{
115
- flexGrow: 1,
116
- backgroundColor: '#fff',
117
- p: 2,
118
- mx: 'auto',
119
- minWidth: 300,
120
- maxWidth: 400,
121
- }}
122
- >
123
- <Box
124
- sx={{
125
- flexGrow: 1,
126
- backgroundColor: '#0a4e9c',
127
- p:2,
128
- my: 2,
129
- mx: 3,
130
- borderRadius:3,
131
- color:'#fff'
132
- }}
133
- >
134
- <center>
135
- <img src={FTBAccountVerify} alt='Account Profile' />
136
- <div style={{ lineHeight:2 }}>Customer Name: <b>Pen Dara</b></div>
137
- <div style={{ lineHeight:2 }}>Account Number: <b>USD-00131</b></div>
138
- </center>
139
- </Box>
140
-
141
- {/* --------- FORM ERROR DISPLAY --------- */}
142
- <div
143
- style={{
144
- color:'#ff0000',
145
- padding:'12px 40px ',
146
- fontSize:'12px',
147
- textAlign:'center',
148
- }}
149
- >Please input OTP send to your registered phone {'0xxxx xxx02'}.
150
- </div>
151
-
152
- <form onSubmit={(e)=>confirmNewReg(e)}>
153
- <Grid container spacing={2}>
154
- <Grid item xs={12}>
155
- <TextField
156
- required
157
- fullWidth
158
- autoFocus
159
- variant={'outlined'}
160
- id="input-with-icon-otp-number"
161
- label={regOTPNum?"OTP Number":''}
162
- InputProps={{
163
- startAdornment: (
164
- <InputAdornment position="start">
165
- <Https sx={{ color:'#0a4e9c' }}/>
166
- </InputAdornment>
167
- ),
168
- }}
169
- value={regOTPNum}
170
- size="small"
171
- autoComplete='off'
172
- onKeyPress={(event) => {
173
- if (!/[0-9.]/.test(event.key)) {
174
- event.preventDefault();
175
- }
176
- }}
177
- placeholder="OTP number"
178
- onChange={(event) => {
179
- setRegOTPNum(event.target.value);
180
- }}
181
- sx={{
182
- '& fieldset': {
183
- borderRadius: '30px',
184
- },
185
- }}
186
- />
187
- </Grid>
188
-
189
- {/* --------- OTP CONFIRM BUTTON --------- */}
190
- <Grid item xs={12}>
191
- <center>
192
- <LoadingButton
193
- variant='contained'
194
- type='submit'
195
- loading={regOTPConfirming}
196
- sx={{
197
- borderRadius: '30px',
198
- backgroundColor:'#0a4e9c',
199
- '&:active, &:focus, &:hover': {
200
- backgroundColor:'#053e88'
201
- }
202
- }}
203
- >
204
- &nbsp;Confirm&nbsp;
205
- </LoadingButton>
206
- </center>
207
- </Grid>
208
- </Grid>
209
- </form>
210
- </Box>
211
- </>):(<>
212
- <Typography variant='h6' component={'div'} style={{ color:'#0a4e9c',textAlign:'center',fontWeight:'bold' }}>
213
- Account Registration
214
- </Typography>
215
-
216
- <Box
217
- sx={{
218
- flexGrow: 1,
219
- backgroundColor: '#fff',
220
- p: 2,
221
- mt: 2,
222
- mx: 'auto',
223
- minWidth: 300,
224
- maxWidth: 400,
225
- }}
226
- >
227
- {/* --------- NEW ACCOUNT REGISTER --------- */}
228
- <form onSubmit={(e)=>newRegisterSubmit(e)}>
229
- <Grid container spacing={2}>
230
- <Grid item xs={12}>
231
- <TextField
232
- required
233
- fullWidth
234
- autoFocus
235
- variant={'outlined'}
236
- id="input-with-icon-account-number"
237
- label={regAccountNum?"Account Number":''}
238
- InputProps={{
239
- startAdornment: (
240
- <InputAdornment position="start">
241
- <Person sx={{ color:'#0a4e9c' }}/>
242
- </InputAdornment>
243
- ),
244
- }}
245
- value={regAccountNum}
246
- size="small"
247
- autoComplete='off'
248
- onKeyPress={(event) => {
249
- if (!/[0-9.]/.test(event.key)) {
250
- event.preventDefault();
251
- }
252
- }}
253
- placeholder="Account number"
254
- onChange={(event) => {
255
- setRegAccountNum(event.target.value);
256
- }}
257
- sx={{
258
- '& fieldset': {
259
- borderRadius: '30px',
260
- },
261
- }}
262
- />
263
- </Grid>
264
-
265
- <Grid item xs={12}>
266
- <LocalizationProvider dateAdapter={AdapterDateFns}>
267
- <MobileDatePicker
268
- label={regDOB?"Date Of Birth":''}
269
- inputFormat="MM/dd/yyyy"
270
- value={regDOB}
271
- disableFuture
272
- onChange={(newValue) => {
273
- setRegDOB(newValue);
274
- }}
275
- InputProps={{
276
- startAdornment: (
277
- <InputAdornment position="start">
278
- <CalendarMonth sx={{ color:'#0a4e9c' }}/>
279
- </InputAdornment>
280
- ),
281
- }}
282
- error={false}
283
- helperText={null}
284
- renderInput={(params) =>
285
- <TextField
286
- {...params}
287
- required
288
- fullWidth
289
- size='small'
290
- placeholder="Date Of Birth"
291
- sx={{
292
- '& fieldset': {
293
- borderRadius: '30px',
294
- },
295
- }}
296
- />
297
- }
298
-
299
- />
300
- </LocalizationProvider>
301
- </Grid>
302
-
303
- <Grid item xs={12}>
304
- <TextField
305
- required
306
- fullWidth
307
- variant={'outlined'}
308
- id="input-with-icon-mobile-number"
309
- label={regMobileNum?"Mobile Number":''}
310
- InputProps={{
311
- startAdornment: (
312
- <InputAdornment position="start">
313
- <Phone sx={{ color:'#0a4e9c' }}/>
314
- </InputAdornment>
315
- ),
316
- }}
317
- value={regMobileNum}
318
- size="small"
319
- autoComplete='off'
320
- onKeyPress={(event) => {
321
- if (!/[0-9.]/.test(event.key)) {
322
- event.preventDefault();
323
- }
324
- }}
325
- placeholder="Mobile number"
326
- onChange={(event) => {
327
- setRegMobileNum(event.target.value);
328
- }}
329
- sx={{
330
- '& fieldset': {
331
- borderRadius: '30px',
332
- },
333
- }}
334
- />
335
- </Grid>
336
-
337
- {/* --------- FORM ERROR DISPLAY --------- */}
338
- <Grid item xs={12}>
339
- <div
340
- style={{
341
- color:'#ff0000',
342
- padding:'0px 40px ',
343
- fontSize:'12px',
344
- textAlign:'center',
345
- display:!regUserError?'none':'block'
346
- }}
347
- >
348
- {regUserError}
349
- </div>
350
- </Grid>
351
-
352
- {/* --------- FORM SUBMIT BUTTON --------- */}
353
- <Grid item xs={12}>
354
- <center>
355
- <LoadingButton
356
- variant='contained'
357
- type='submit'
358
- loading={regAcctLoading}
359
- sx={{
360
- borderRadius: '30px',
361
- backgroundColor:'#0a4e9c',
362
- '&:active, &:focus, &:hover': {
363
- backgroundColor:'#053e88'
364
- }
365
- }}
366
- >
367
- &nbsp;Submit&nbsp;
368
- </LoadingButton>
369
- </center>
370
- </Grid>
371
- </Grid>
372
- </form>
373
- </Box>
374
- </>)}
375
- </div>
376
- )
377
- };
@@ -1,107 +0,0 @@
1
- import React from 'react';
2
- import FTBxPAYPage from './FTB/FTBTransactionPage';
3
- import FTBName from '../../assets/ai Icon/ai Icon-2.png';
4
- import { useMediaQuery } from '@mui/material';
5
- import axios from 'axios';
6
-
7
- export function FtbScreenIndex({config}) {
8
- // consumer data
9
- const { baseurl } = config;
10
- // for calling only once (react18 useEffect calls twice)
11
- const callingOnce = React.useRef(true);
12
- // If its reloaded
13
- const [pageReloaded, setPageReloaded] = React.useState(false);
14
- // make page fullScreen or not
15
- const largeScreen = useMediaQuery('(min-width:480px)');
16
-
17
- // session id and payment token id
18
- const sessionid = sessionStorage.getItem("sessionid");
19
- const paymenttokenid = sessionStorage.getItem("paymenttokenid");
20
- // allow user to access payment gateway
21
- const allowUser = sessionid && paymenttokenid
22
-
23
- const onResponse = config?.onResponse
24
- ? config.onResponse
25
- : (data) => {
26
- console.log("Page Response ::> ", data);
27
- };
28
- const onError = config?.onError
29
- ? config.onError
30
- : (err) => {
31
- throw err;
32
- };
33
-
34
- // cancel session
35
- const CancelSession = async() => {
36
- let text = {
37
- "sessionid": sessionid
38
- };
39
- try {
40
- const res = await axios({
41
- method: 'post',
42
- url: `${baseurl}/CloseSession`,
43
- data: text
44
- });
45
- onResponse({"at":"/CloseSession", "response":res.data});
46
- } catch (error) {
47
- onError({"at":"/CloseSession", "error":error?.response?.data || error?.message || error});
48
- }
49
- }
50
-
51
- React.useEffect(() => {
52
- if (performance?.navigation?.type === 1) {
53
- setPageReloaded(true);
54
- if(callingOnce.current) {
55
- callingOnce.current=false;
56
- CancelSession();
57
- }
58
- console.log("This page is reloaded");
59
- } else if (performance?.navigation?.type === 2) {
60
- setPageReloaded(true);
61
- if(callingOnce.current) {
62
- callingOnce.current=false;
63
- CancelSession();
64
- }
65
- console.log("This page is back forwarded");
66
- } else {
67
- console.log("This page is navigated");
68
- }
69
-
70
- return()=>{}
71
- });
72
-
73
- return (<center>
74
- {pageReloaded?
75
- <div style={{ padding:'2rem' }}>
76
- <img src={FTBName} alt='FTB Name' width={300} />
77
- <div style={{ color:'red',fontWeight:'600',padding:'2rem' }}>
78
- Session has been closed. Please don't refresh/reload and back forward the page again!
79
- </div>
80
- <a href={config?.merchantUrl}>
81
- Back to Merchant
82
- </a>
83
- </div>:<>
84
- {allowUser ?
85
- <FTBxPAYPage
86
- config={config}
87
- baseurl={baseurl}
88
- largeScreen={largeScreen}
89
- sessionid={sessionid}
90
- paymenttokenid={paymenttokenid}
91
- initialHours={0} // default zero
92
- initialMinutes={3} // default three
93
- initialSeconds={0} // default zero
94
- />
95
- :
96
- <div style={{ padding:'2rem' }}>
97
- <img src={FTBName} alt='FTB Name' width={300} />
98
- <div style={{ color:'red',fontWeight:'600',padding:'2rem' }}>
99
- Please come through clicking the pay-now btn from Merchant Site!
100
- </div>
101
- <a href={config?.merchantUrl}>
102
- Back to Merchant
103
- </a>
104
- </div>}
105
- </>}
106
- </center>);
107
- }
@@ -1,2 +0,0 @@
1
- export * from './FTBScreen';
2
- export * from './BtnScreen';
Binary file
Binary file
Binary file
Binary file
Binary file
package/src/index.css DELETED
@@ -1,40 +0,0 @@
1
- *,
2
- *::before,
3
- *::after {
4
- box-sizing: border-box;
5
- }
6
-
7
- body {
8
- margin: 0;
9
- font-family: Inter, Avenir, -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
10
- -webkit-font-smoothing: antialiased;
11
- -moz-osx-font-smoothing: grayscale;
12
- font-size: 14px;
13
-
14
- }
15
-
16
- code {
17
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
18
- }
19
-
20
- p {
21
- font-family: 'Source Sans Pro', sans-serif;
22
- }
23
-
24
- ::-webkit-scrollbar{
25
- width: 8px;
26
- }
27
-
28
- /* ::-webkit-scrollbar-track {
29
- -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
30
- box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
31
- border-radius: 10px;
32
- background-color: #f1f1f1;
33
- } */
34
-
35
- ::-webkit-scrollbar-thumb {
36
- border-radius: 10px;
37
- -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
38
- box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
39
- background-color: #f1f1f1;
40
- }
package/src/main.jsx DELETED
@@ -1,10 +0,0 @@
1
- import React from 'react'
2
- import ReactDOM from 'react-dom/client'
3
- import App from './App';
4
- import './index.css'
5
-
6
- ReactDOM.createRoot(document.getElementById('root')).render(
7
- <React.StrictMode>
8
- <App />
9
- </React.StrictMode>
10
- )
package/vite.config.js DELETED
@@ -1,31 +0,0 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react'
3
- import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
4
-
5
- // https://vitejs.dev/config/
6
- export default defineConfig({
7
- plugins: [react(), cssInjectedByJsPlugin()],
8
- server: {
9
- port: 3040
10
- },
11
- build: {
12
- lib: {
13
- entry: "src/Screens/index.jsx",
14
- name: "xpayroute",
15
- fileName: "xpayroute",
16
- },
17
-
18
- rollupOptions: {
19
- external: ["react", "react-dom"],
20
- output: {
21
- globals: {
22
- react: "React",
23
- "react-dom": "ReactDOM",
24
- },
25
- manualChunks: undefined,
26
-
27
- // This is the important part
28
- },
29
- },
30
- },
31
- })