@autobusal/order-process 1.3.0 → 1.3.1
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/Content.tsx +4 -0
- package/Nexi/Nexi.tsx +28 -0
- package/package.json +1 -1
- package/services.ts +14 -1
- package/types.ts +4 -0
package/Content.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import Bkt from './BKT/Bkt';
|
|
|
4
4
|
import Stripe from './Stripe/Stripe';
|
|
5
5
|
import Mollie from './Mollie/Mollie';
|
|
6
6
|
import Raiffeisen from './Reiffeisen/Raiffeisen';
|
|
7
|
+
import Nexi from './Nexi/Nexi';
|
|
7
8
|
|
|
8
9
|
interface Props {
|
|
9
10
|
type?: string
|
|
@@ -25,6 +26,9 @@ const Content = ({ type, hash, t }: Props): JSX.Element => {
|
|
|
25
26
|
case 'raiffeisen':
|
|
26
27
|
return <Raiffeisen hash={ hash } t={ t } />;
|
|
27
28
|
|
|
29
|
+
case 'nexi':
|
|
30
|
+
return <Nexi hash={ hash } t={ t } />;
|
|
31
|
+
|
|
28
32
|
default:
|
|
29
33
|
return <Standard type={ type } hash={ hash } t={ t } />;
|
|
30
34
|
}
|
package/Nexi/Nexi.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { TFunction } from 'i18next';
|
|
3
|
+
import { Inline } from '@autobusal/common';
|
|
4
|
+
import { Container } from '../styles';
|
|
5
|
+
import { useMakeNexi } from '../services';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
hash?: string
|
|
9
|
+
t: TFunction<'common'>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Nexi = ({ hash, t }: Props): JSX.Element => {
|
|
13
|
+
const { data, isSuccess } = useMakeNexi(String(hash));
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (isSuccess) {
|
|
17
|
+
window.location.href = data.redirect;
|
|
18
|
+
}
|
|
19
|
+
}, [data, isSuccess]);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Container>
|
|
23
|
+
<Inline text={ t('order_process.nexi') } />
|
|
24
|
+
</Container>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default Nexi;
|
package/package.json
CHANGED
package/services.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery, UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { apiClient } from '@autobusal/providers';
|
|
3
|
-
import { BKTData, StripeData, MollieData, RaiffeisenData } from './types';
|
|
3
|
+
import { BKTData, StripeData, MollieData, RaiffeisenData, NexiData } from './types';
|
|
4
4
|
|
|
5
5
|
export const useMakeStandard = (type: string, hash: string): UseQueryResult<string> => (
|
|
6
6
|
useQuery({
|
|
@@ -68,4 +68,17 @@ export const useMakeRaiffeisen = (hash: string): UseQueryResult<RaiffeisenData>
|
|
|
68
68
|
))
|
|
69
69
|
)
|
|
70
70
|
})
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
export const useMakeNexi = (hash: string): UseQueryResult<NexiData> => (
|
|
74
|
+
useQuery({
|
|
75
|
+
queryKey: ['process-payment-nexi', { hash }],
|
|
76
|
+
queryFn: async () => (
|
|
77
|
+
await apiClient
|
|
78
|
+
.post('/api/payment/nexi', { hash })
|
|
79
|
+
.then(response => (
|
|
80
|
+
response?.data ?? ''
|
|
81
|
+
))
|
|
82
|
+
)
|
|
83
|
+
})
|
|
71
84
|
);
|