@autobusal/order-process 1.5.0 → 1.5.2
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/BKT/Bkt.tsx +4 -1
- package/Content.tsx +3 -0
- package/Mgpay/Mgpay.tsx +49 -0
- package/package.json +1 -1
- package/services.ts +16 -2
- package/types.ts +9 -2
package/BKT/Bkt.tsx
CHANGED
|
@@ -76,7 +76,10 @@ const Bkt = ({ hash, t }: Props): JSX.Element => {
|
|
|
76
76
|
<input type="hidden" defaultValue={ data?.currency } { ...register('currency') } />
|
|
77
77
|
<input type="hidden" defaultValue={ data?.okUrl } { ...register('okUrl') } />
|
|
78
78
|
<input type="hidden" defaultValue={ data?.failUrl } { ...register('failUrl') } />
|
|
79
|
-
|
|
79
|
+
{ /* Claude - 2026-09-25 (audit): the hash is signed over data.oid (the
|
|
80
|
+
per-attempt order-number reference), not the database id - posting
|
|
81
|
+
orderId made BKT reject the signature. orderId stays as ObtBktId. */ }
|
|
82
|
+
<input type="hidden" defaultValue={ data?.oid ?? data?.orderId } { ...register('oid') } />
|
|
80
83
|
<input type="hidden" defaultValue={ data?.amount } { ...register('amount') } />
|
|
81
84
|
<input type="hidden" defaultValue={ data?.lang } { ...register('lang') } />
|
|
82
85
|
|
package/Content.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import Stripe from './Stripe/Stripe';
|
|
|
5
5
|
import Mollie from './Mollie/Mollie';
|
|
6
6
|
import Raiffeisen from './Reiffeisen/Raiffeisen';
|
|
7
7
|
import Nexi from './Nexi/Nexi';
|
|
8
|
+
import Mgpay from './Mgpay/Mgpay';
|
|
8
9
|
|
|
9
10
|
interface Props {
|
|
10
11
|
type?: string
|
|
@@ -28,6 +29,8 @@ const Content = ({ type, hash, t }: Props): JSX.Element => {
|
|
|
28
29
|
|
|
29
30
|
case 'nexi':
|
|
30
31
|
return <Nexi hash={ hash } t={ t } />;
|
|
32
|
+
case 'mgpay':
|
|
33
|
+
return <Mgpay hash={ hash } t={ t } />;
|
|
31
34
|
|
|
32
35
|
default:
|
|
33
36
|
return <Standard type={ type } hash={ hash } t={ t } />;
|
package/Mgpay/Mgpay.tsx
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { TFunction } from 'i18next';
|
|
3
|
+
import { useNavigate } from 'react-router-dom';
|
|
4
|
+
import { Inline } from '@autobusal/common';
|
|
5
|
+
import { Container } from '../styles';
|
|
6
|
+
import { useMakeMgpay } from '../services';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
hash?: string
|
|
10
|
+
t: TFunction<'common'>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The Magus Pay Hub - Claude, 2026-09-07.
|
|
15
|
+
*
|
|
16
|
+
* Same shape as Raiffeisen: one call to obtapi registers the order with the
|
|
17
|
+
* hub and answers with its pay_url; the browser goes there and comes back
|
|
18
|
+
* to /orders/purchased or /orders/cancelled, which are hints - the booking
|
|
19
|
+
* is marked paid only by the hub's signed notification to obtapi.
|
|
20
|
+
*/
|
|
21
|
+
const Mgpay = ({ hash, t }: Props): JSX.Element => {
|
|
22
|
+
const { data, isSuccess, isError, error } = useMakeMgpay(String(hash));
|
|
23
|
+
|
|
24
|
+
const navigate = useNavigate();
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (isSuccess) {
|
|
28
|
+
window.location.href = data.redirect;
|
|
29
|
+
}
|
|
30
|
+
}, [data, isSuccess]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (isError) {
|
|
34
|
+
const message = (error as { response?: { data?: { message?: string } } })?.response?.data?.message;
|
|
35
|
+
|
|
36
|
+
const reason = message ?? t('order_process.error', { ns: 'common', defaultValue: 'We could not complete your payment. Please try again.' });
|
|
37
|
+
|
|
38
|
+
navigate(hash ? `/orders/cancelled/${ hash }?msg=${ encodeURIComponent(reason) }` : '/', { replace: true });
|
|
39
|
+
}
|
|
40
|
+
}, [isError, error, hash, navigate, t]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Container>
|
|
44
|
+
<Inline text={ t('order_process.mgpay', { defaultValue: t('order_process.raiffeisen') }) } />
|
|
45
|
+
</Container>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default Mgpay;
|
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, NexiData } from './types';
|
|
3
|
+
import { BKTData, StripeData, MollieData, RaiffeisenData, NexiData, MgpayData } from './types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Starting a payment must happen EXACTLY ONCE per attempt.
|
|
@@ -116,4 +116,18 @@ export const useMakeNexi = (hash: string): UseQueryResult<NexiData> => (
|
|
|
116
116
|
))
|
|
117
117
|
)
|
|
118
118
|
})
|
|
119
|
-
);
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
export const useMakeMgpay = (hash: string): UseQueryResult<MgpayData> => (
|
|
122
|
+
useQuery({
|
|
123
|
+
queryKey: ['process-payment-mgpay', { hash }],
|
|
124
|
+
...ONCE,
|
|
125
|
+
queryFn: async () => (
|
|
126
|
+
await apiClient
|
|
127
|
+
.post('/api/payment/mgpay', { hash })
|
|
128
|
+
.then(response => (
|
|
129
|
+
response?.data ?? ''
|
|
130
|
+
))
|
|
131
|
+
)
|
|
132
|
+
})
|
|
133
|
+
);
|
package/types.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface BKTFormData {
|
|
|
5
5
|
currency: number
|
|
6
6
|
okUrl: string
|
|
7
7
|
failUrl: string
|
|
8
|
-
oid: number
|
|
8
|
+
oid: number | string // Claude - 2026-09-25 (audit): the order-number reference is a string
|
|
9
9
|
amount: number
|
|
10
10
|
lang: string
|
|
11
11
|
Email: string
|
|
@@ -47,6 +47,9 @@ export interface BKTData {
|
|
|
47
47
|
description: string
|
|
48
48
|
amount: number
|
|
49
49
|
orderId: number
|
|
50
|
+
// Claude - 2026-09-25 (audit): the per-attempt order-number reference
|
|
51
|
+
// obtapi signs into the hash (BKT Prepare) - what BKT must receive as oid
|
|
52
|
+
oid?: string
|
|
50
53
|
labelId: number
|
|
51
54
|
domain: string
|
|
52
55
|
currency: number
|
|
@@ -77,4 +80,8 @@ export interface RaiffeisenData {
|
|
|
77
80
|
|
|
78
81
|
export interface NexiData {
|
|
79
82
|
redirect: string
|
|
80
|
-
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface MgpayData {
|
|
86
|
+
redirect: string
|
|
87
|
+
}
|