@autobusal/order-process 1.1.0 → 1.3.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.
- package/Content.tsx +8 -0
- package/Mollie/Mollie.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
|
@@ -2,6 +2,8 @@ import { TFunction } from 'i18next';
|
|
|
2
2
|
import Standard from './Standard/Standard';
|
|
3
3
|
import Bkt from './BKT/Bkt';
|
|
4
4
|
import Stripe from './Stripe/Stripe';
|
|
5
|
+
import Mollie from './Mollie/Mollie';
|
|
6
|
+
import Raiffeisen from './Reiffeisen/Raiffeisen';
|
|
5
7
|
|
|
6
8
|
interface Props {
|
|
7
9
|
type?: string
|
|
@@ -17,6 +19,12 @@ const Content = ({ type, hash, t }: Props): JSX.Element => {
|
|
|
17
19
|
case 'stripe':
|
|
18
20
|
return <Stripe hash={ hash } t={ t } />;
|
|
19
21
|
|
|
22
|
+
case 'mollie':
|
|
23
|
+
return <Mollie hash={ hash } t={ t } />;
|
|
24
|
+
|
|
25
|
+
case 'raiffeisen':
|
|
26
|
+
return <Raiffeisen hash={ hash } t={ t } />;
|
|
27
|
+
|
|
20
28
|
default:
|
|
21
29
|
return <Standard type={ type } hash={ hash } t={ t } />;
|
|
22
30
|
}
|
|
@@ -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 { useMakeMollie } from '../services';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
hash?: string
|
|
9
|
+
t: TFunction<'common'>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Mollie = ({ hash, t }: Props): JSX.Element => {
|
|
13
|
+
const { data, isSuccess } = useMakeMollie(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.mollie') } />
|
|
24
|
+
</Container>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default Mollie;
|
|
@@ -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 } from './types';
|
|
3
|
+
import { BKTData, StripeData, MollieData, RaiffeisenData } from './types';
|
|
4
4
|
|
|
5
5
|
export const useMakeStandard = (type: string, hash: string): UseQueryResult<string> => (
|
|
6
6
|
useQuery({
|
|
@@ -42,4 +42,30 @@ export const useMakeStripe = (hash: string): UseQueryResult<StripeData> => (
|
|
|
42
42
|
))
|
|
43
43
|
)
|
|
44
44
|
})
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const useMakeMollie = (hash: string): UseQueryResult<MollieData> => (
|
|
48
|
+
useQuery({
|
|
49
|
+
queryKey: ['process-payment-mollie', { hash }],
|
|
50
|
+
queryFn: async () => (
|
|
51
|
+
await apiClient
|
|
52
|
+
.post('/api/payment/mollie', { hash })
|
|
53
|
+
.then(response => (
|
|
54
|
+
response?.data ?? ''
|
|
55
|
+
))
|
|
56
|
+
)
|
|
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
|
+
})
|
|
45
71
|
);
|