@autobusal/order-process 0.0.2 → 1.0.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/BKT/Bkt.tsx CHANGED
@@ -1,10 +1,10 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  import { TFunction } from 'i18next';
3
- import { Inline } from '@autobusal/common';
4
3
  import { useForm } from 'react-hook-form';
4
+ import { Inline } from '@autobusal/common';
5
5
  import { Container } from '../styles';
6
6
  import { BKTFormData } from '../types';
7
- import { PostBkt } from '../services';
7
+ import { MakeBkt } from '../services';
8
8
 
9
9
  interface Props {
10
10
  hash?: string
@@ -16,9 +16,7 @@ const Bkt = ({ hash, t }: Props): JSX.Element => {
16
16
 
17
17
  const ref = useRef<HTMLFormElement>(null);
18
18
 
19
- const { data, isLoading, isSuccess } = PostBkt(
20
- String(hash)
21
- );
19
+ const { data, isLoading, isSuccess } = MakeBkt(String(hash));
22
20
 
23
21
  const onSubmit = (): void => {
24
22
  ref.current?.submit();
@@ -28,7 +26,7 @@ const Bkt = ({ hash, t }: Props): JSX.Element => {
28
26
  if (isSuccess) {
29
27
  handleSubmit(onSubmit)();
30
28
  }
31
- }, [isSuccess]);
29
+ }, [isSuccess, handleSubmit]);
32
30
 
33
31
  if (isLoading) {
34
32
  return (
@@ -43,45 +41,47 @@ const Bkt = ({ hash, t }: Props): JSX.Element => {
43
41
  <Inline text={ t('order_process.bkt') } />
44
42
 
45
43
  <form ref={ ref } action="https://pgw.bkt.com.al/fim/est3Dgate" method="POST" onSubmit={ handleSubmit(onSubmit) }>
46
- <input type="hidden" defaultValue={ data?.clientid } { ...register('clientid') } />
47
- <input type="hidden" defaultValue="3d_pay_hosting" { ...register('storetype') } />
44
+ <input type="hidden" defaultValue={ data?.clientId } { ...register('clientid') } />
45
+ <input type="hidden" defaultValue={ data?.storetype } { ...register('storetype') } />
48
46
  <input type="hidden" defaultValue={ data?.trantype } { ...register('trantype') } />
49
47
  <input type="hidden" defaultValue={ data?.currency } { ...register('currency') } />
50
48
  <input type="hidden" defaultValue={ data?.okUrl } { ...register('okUrl') } />
51
49
  <input type="hidden" defaultValue={ data?.failUrl } { ...register('failUrl') } />
52
- <input type="hidden" defaultValue={ data?.oId } { ...register('oId') } />
50
+ <input type="hidden" defaultValue={ data?.orderId } { ...register('oid') } />
53
51
  <input type="hidden" defaultValue={ data?.amount } { ...register('amount') } />
54
52
  <input type="hidden" defaultValue={ data?.lang } { ...register('lang') } />
55
53
 
56
- <input type="hidden" defaultValue={ data?.Email } { ...register('Email') } />
57
- <input type="hidden" defaultValue={ data?.tel } { ...register('tel') } />
54
+ <input type="hidden" defaultValue={ data?.email } { ...register('Email') } />
55
+ <input type="hidden" defaultValue={ data?.phone } { ...register('tel') } />
56
+
57
+ <input type="hidden" defaultValue={ data?.company } { ...register('ShipToCompany') } />
58
+ <input type="hidden" defaultValue={ data?.fullName } { ...register('ShippingNameSurname') } />
59
+ <input type="hidden" defaultValue={ data?.address } { ...register('ShipToStreet1') } />
60
+ <input type="hidden" defaultValue={ data?.city } { ...register('ShipToCity') } />
61
+ <input type="hidden" defaultValue={ data?.postalCode } { ...register('ShipToPostalCode') } />
62
+ <input type="hidden" defaultValue={ data?.country } { ...register('ShipToCountry') } />
58
63
 
59
- <input type="hidden" defaultValue={ data?.ShipToCompany } { ...register('ShipToCompany') } />
60
- <input type="hidden" defaultValue={ data?.ShippingNameSurname } { ...register('ShippingNameSurname') } />
61
- <input type="hidden" defaultValue={ data?.ShipToStreet1 } { ...register('ShipToStreet1') } />
62
- <input type="hidden" defaultValue={ data?.ShipToCity } { ...register('ShipToCity') } />
63
- <input type="hidden" defaultValue={ data?.ShipToPostalCode } { ...register('ShipToPostalCode') } />
64
- <input type="hidden" defaultValue={ data?.ShipToCountry } { ...register('ShipToCountry') } />
64
+ <input type="hidden" defaultValue={ data?.company } { ...register('BillToCompany') } />
65
+ <input type="hidden" defaultValue={ data?.fullName } { ...register('BillToName') } />
66
+ <input type="hidden" defaultValue={ data?.address } { ...register('BillToStreet1') } />
67
+ <input type="hidden" defaultValue={ data?.city } { ...register('BillToCity') } />
68
+ <input type="hidden" defaultValue={ data?.postalCode } { ...register('BillToPostalCode') } />
69
+ <input type="hidden" defaultValue={ data?.country } { ...register('BillToCountry') } />
65
70
 
66
- <input type="hidden" defaultValue={ data?.ShipToCompany } { ...register('BillToCompany') } />
67
- <input type="hidden" defaultValue={ data?.ShippingNameSurname } { ...register('BillToName') } />
68
- <input type="hidden" defaultValue={ data?.ShipToStreet1 } { ...register('BillToStreet1') } />
69
- <input type="hidden" defaultValue={ data?.ShipToCity } { ...register('BillToCity') } />
70
- <input type="hidden" defaultValue={ data?.ShipToPostalCode } { ...register('BillToPostalCode') } />
71
- <input type="hidden" defaultValue={ data?.ShipToCountry } { ...register('BillToCountry') } />
71
+ <input type="hidden" defaultValue={ data?.description } { ...register('description') } />
72
72
 
73
73
  <input type="hidden" defaultValue={ data?.rnd } { ...register('rnd') } />
74
74
  <input type="hidden" defaultValue={ data?.hash } { ...register('hash') } />
75
- <input type="hidden" defaultValue="utf-8" { ...register('encoding') } />
76
75
 
77
- <input type="hidden" defaultValue={ data?.ObtBktId } { ...register('ObtBktId') } />
78
- <input type="hidden" defaultValue={ data?.ObtBktPrice } { ...register('ObtBktPrice') } />
76
+ <input type="hidden" defaultValue={ data?.orderId } { ...register('ObtBktId') } />
77
+ <input type="hidden" defaultValue={ data?.amount } { ...register('ObtBktPrice') } />
79
78
 
80
- <input type="hidden" defaultValue={ data?.ObtBktDomain } { ...register('ObtBktDomain') } />
81
- <input type="hidden" defaultValue={ data?.ObtBktLabelId } { ...register('ObtBktLabelId') } />
79
+ <input type="hidden" defaultValue={ data?.domain } { ...register('ObtBktDomain') } />
80
+ <input type="hidden" defaultValue={ data?.labelId } { ...register('ObtBktLabelId') } />
82
81
 
83
- <input type="hidden" defaultValue={ data?.ObtBktUid } { ...register('ObtBktUid') } />
84
- <input type="hidden" defaultValue={ 0 } { ...register('refreshtime') } />
82
+ <input type="hidden" defaultValue={ data?.user_id } { ...register('ObtBktUid') } />
83
+ <input type="hidden" defaultValue={ data?.refreshtime } { ...register('refreshtime') } />
84
+ <input type="hidden" defaultValue={ data?.algorithm } { ...register('hashAlgorithm') } />
85
85
  </form>
86
86
  </Container>
87
87
  );
@@ -1,9 +1,8 @@
1
- import { useEffect } from 'react';
2
1
  import { TFunction } from 'i18next';
3
- import { useNavigate } from 'react-router-dom';
2
+ import { Navigate } from 'react-router-dom';
4
3
  import { Inline } from '@autobusal/common';
5
4
  import { Container } from '../styles';
6
- import { PostStandard } from '../services';
5
+ import { MakeStandard } from '../services';
7
6
 
8
7
  interface Props {
9
8
  type?: string
@@ -12,17 +11,11 @@ interface Props {
12
11
  }
13
12
 
14
13
  const Standard = ({ type, hash, t }: Props): JSX.Element => {
15
- const { data, isSuccess } = PostStandard(
16
- String(type), String(hash)
17
- );
18
-
19
- const navigate = useNavigate();
14
+ const { data, isSuccess } = MakeStandard(String(type), String(hash));
20
15
 
21
- useEffect(() => {
22
- if (isSuccess) {
23
- navigate(data);
24
- }
25
- }, [isSuccess]);
16
+ if (isSuccess) {
17
+ return <Navigate to={ data } />;
18
+ }
26
19
 
27
20
  return (
28
21
  <Container>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/order-process",
3
- "version": "0.0.2",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "main": "index.ts"
6
6
  }
package/services.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { useQuery, UseQueryResult } from '@tanstack/react-query';
2
2
  import { apiClient } from '@autobusal/providers';
3
- import { BKTFormData } from './types';
3
+ import { BKTData } from './types';
4
4
 
5
- export const PostStandard = (type: string, hash: string): UseQueryResult<string> => (
5
+ export const MakeStandard = (type: string, hash: string): UseQueryResult<string> => (
6
6
  useQuery({
7
7
  queryKey: ['process-payment-standard', { type, hash }],
8
8
  queryFn: async () => (
@@ -18,14 +18,12 @@ export const PostStandard = (type: string, hash: string): UseQueryResult<string>
18
18
  })
19
19
  );
20
20
 
21
- export const PostBkt = (hash: string): UseQueryResult<BKTFormData> => (
21
+ export const MakeBkt = (hash: string): UseQueryResult<BKTData> => (
22
22
  useQuery({
23
23
  queryKey: ['process-payment-bkt', { hash }],
24
24
  queryFn: async () => (
25
25
  await apiClient
26
- .post('/api/payment/bkt', {
27
- hash
28
- })
26
+ .post('/api/payment/bkt', { hash })
29
27
  .then(response => (
30
28
  response?.data ?? ''
31
29
  ))
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
9
9
  amount: number
10
10
  lang: string
11
11
  Email: string
@@ -22,13 +22,42 @@ export interface BKTFormData {
22
22
  BillToCity: string
23
23
  BillToPostalCode: string
24
24
  BillToCountry: string
25
+ description: string
25
26
  hash: string
26
27
  rnd: string
27
- encoding: string
28
28
  ObtBktId: number
29
29
  ObtBktPrice: number
30
30
  ObtBktDomain: string
31
31
  ObtBktLabelId: number
32
32
  ObtBktUid: number
33
- refreshtime: string
33
+ refreshtime: number
34
+ hashAlgorithm: string
35
+ }
36
+
37
+ export interface BKTData {
38
+ fullName: string
39
+ company: string
40
+ email: string
41
+ address: string
42
+ postalCode: string
43
+ phone: string
44
+ city: string
45
+ country: number
46
+ description: string
47
+ amount: number
48
+ orderId: number
49
+ labelId: number
50
+ domain: string
51
+ currency: number
52
+ clientId: number
53
+ okUrl: string
54
+ failUrl: string
55
+ algorithm: string
56
+ lang: string
57
+ refreshtime: number
58
+ rnd: string
59
+ storetype: string
60
+ trantype: string
61
+ user_id: number
62
+ hash: string
34
63
  }