@autobusal/order-process 1.2.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 +8 -0
- package/Nexi/Nexi.tsx +28 -0
- package/Reiffeisen/Raiffeisen.tsx +28 -0
- package/package.json +1 -1
- package/services.ts +27 -1
- package/types.ts +8 -0
package/Content.tsx
CHANGED
|
@@ -3,6 +3,8 @@ import Standard from './Standard/Standard';
|
|
|
3
3
|
import Bkt from './BKT/Bkt';
|
|
4
4
|
import Stripe from './Stripe/Stripe';
|
|
5
5
|
import Mollie from './Mollie/Mollie';
|
|
6
|
+
import Raiffeisen from './Reiffeisen/Raiffeisen';
|
|
7
|
+
import Nexi from './Nexi/Nexi';
|
|
6
8
|
|
|
7
9
|
interface Props {
|
|
8
10
|
type?: string
|
|
@@ -21,6 +23,12 @@ const Content = ({ type, hash, t }: Props): JSX.Element => {
|
|
|
21
23
|
case 'mollie':
|
|
22
24
|
return <Mollie hash={ hash } t={ t } />;
|
|
23
25
|
|
|
26
|
+
case 'raiffeisen':
|
|
27
|
+
return <Raiffeisen hash={ hash } t={ t } />;
|
|
28
|
+
|
|
29
|
+
case 'nexi':
|
|
30
|
+
return <Nexi hash={ hash } t={ t } />;
|
|
31
|
+
|
|
24
32
|
default:
|
|
25
33
|
return <Standard type={ type } hash={ hash } t={ t } />;
|
|
26
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;
|
|
@@ -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 { useMakeRaiffeisen } from '../services';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
hash?: string
|
|
9
|
+
t: TFunction<'common'>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Raiffeisen = ({ hash, t }: Props): JSX.Element => {
|
|
13
|
+
const { data, isSuccess } = useMakeRaiffeisen(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.raiffeisen') } />
|
|
24
|
+
</Container>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default Raiffeisen;
|
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 } 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({
|
|
@@ -55,4 +55,30 @@ export const useMakeMollie = (hash: string): UseQueryResult<MollieData> => (
|
|
|
55
55
|
))
|
|
56
56
|
)
|
|
57
57
|
})
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
export const useMakeRaiffeisen = (hash: string): UseQueryResult<RaiffeisenData> => (
|
|
61
|
+
useQuery({
|
|
62
|
+
queryKey: ['process-payment-raiffeisen', { hash }],
|
|
63
|
+
queryFn: async () => (
|
|
64
|
+
await apiClient
|
|
65
|
+
.post('/api/payment/raiffeisen', { hash })
|
|
66
|
+
.then(response => (
|
|
67
|
+
response?.data ?? ''
|
|
68
|
+
))
|
|
69
|
+
)
|
|
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
|
+
})
|
|
58
84
|
);
|