@@ -26,7 +26,7 @@ export const COMPLETE_STEP = 'pt-static:complete';
26
26
export const ERROR_STEP = 'pt-static:error' ;
27
27
export const FIELDS_READY_STEP = 'pt-static:fields-ready' ;
28
28
29
- export type PayTheoryDataObject = {
29
+ export interface PayTheoryDataObject {
30
30
account_code : string | number ;
31
31
reference : string | number ;
32
32
payment_parameters : string ;
@@ -40,7 +40,7 @@ export type PayTheoryDataObject = {
40
40
billing_info ?: BillingInfo ;
41
41
healthExpenseType ?: HealthExpenseType ;
42
42
level3DataSummary ?: Level3DataSummary ;
43
- } ;
43
+ }
44
44
45
45
export interface ModifiedTransactProps extends TransactProps {
46
46
payTheoryData : PayTheoryDataObject ;
@@ -56,23 +56,23 @@ export interface ModifiedCheckoutDetails extends CheckoutDetails {
56
56
export const parseInputParams = (
57
57
inputParams : TransactProps | CheckoutDetails ,
58
58
) : ModifiedTransactProps | ModifiedCheckoutDetails => {
59
- //@ts -ignore this will just set billingInfo and fee to undefined if they don't exist
60
- const { payorId, invoiceId, recurringId, fee, metadata = { } , billingInfo } = inputParams ;
59
+ const { payorId, invoiceId, recurringId, metadata = { } } = inputParams ;
61
60
const inputCopy = JSON . parse ( JSON . stringify ( inputParams ) ) as ModifiedTransactProps ;
62
61
inputCopy . payTheoryData = {
63
- account_code : inputParams . accountCode || ( metadata [ 'pay-theory-account-code' ] as string ) ,
64
- billing_info : billingInfo ,
65
- fee : fee ,
66
- invoice_id : invoiceId ,
62
+ account_code : inputParams . accountCode ?? ( metadata [ 'pay-theory-account-code' ] as string ) ,
63
+ billing_info : ( inputParams as TransactProps ) . billingInfo as BillingInfo | undefined ,
64
+ fee : ( inputParams as TransactProps ) . fee as number | undefined ,
65
+ invoice_id : invoiceId as string | undefined ,
67
66
payment_parameters :
68
- inputParams . paymentParameters || ( metadata [ 'payment-parameters-name' ] as string ) ,
69
- payor_id : payorId ,
67
+ inputParams . paymentParameters ?? ( metadata [ 'payment-parameters-name' ] as string ) ,
68
+ payor_id : payorId as string | undefined ,
70
69
receipt_description :
71
- // @ts -expect-error this will just set receipt description to undefined if it doesn't exist
72
- inputParams . receiptDescription || ( metadata [ 'pay-theory-receipt-description' ] as string ) ,
73
- recurring_id : recurringId , //@ts -ignore this will just set reference to undefined if it doesn't exist
74
- reference : inputParams . reference || ( metadata [ 'pay-theory-reference' ] as string ) , //@ts -ignore this will just set send receipt to undefined if it doesn't exist
75
- send_receipt : inputParams . sendReceipt || ! ! metadata [ 'pay-theory-receipt' ] ,
70
+ ( inputParams as TransactProps ) . receiptDescription ??
71
+ ( metadata [ 'pay-theory-receipt-description' ] as string ) ,
72
+ recurring_id : recurringId ,
73
+ reference :
74
+ ( inputParams as TransactProps ) . reference ?? ( metadata [ 'pay-theory-reference' ] as string ) ,
75
+ send_receipt : ( inputParams as TransactProps ) . sendReceipt ?? ! ! metadata [ 'pay-theory-receipt' ] ,
76
76
timezone : Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ,
77
77
healthExpenseType : inputCopy . healthExpenseType ,
78
78
level3DataSummary : inputCopy . level3DataSummary ,
@@ -81,17 +81,17 @@ export const parseInputParams = (
81
81
return inputCopy ;
82
82
} ;
83
83
84
- export type FieldsReadyMessage = {
84
+ export interface FieldsReadyMessage {
85
85
type : typeof FIELDS_READY_STEP ;
86
- } ;
86
+ }
87
87
88
- export type ErrorMessage = {
88
+ export interface ErrorMessage {
89
89
type : typeof ERROR_STEP ;
90
90
error : string ;
91
91
element : ElementTypes ;
92
- } ;
92
+ }
93
93
94
- export type ConfirmationMessage = {
94
+ export interface ConfirmationMessage {
95
95
type : typeof CONFIRMATION_STEP ;
96
96
body : {
97
97
fee_mode : typeof MERCHANT_FEE | typeof SERVICE_FEE ;
@@ -102,7 +102,7 @@ export type ConfirmationMessage = {
102
102
amount : number ;
103
103
fee : number ;
104
104
} ;
105
- } ;
105
+ }
106
106
107
107
export const parseConfirmationMessage = ( message : ConfirmationMessage ) : ConfirmationResponse => {
108
108
const fee = message . body . fee_mode === data . SERVICE_FEE ? message . body . fee : 0 ;
@@ -119,7 +119,7 @@ export const parseConfirmationMessage = (message: ConfirmationMessage): Confirma
119
119
} ;
120
120
} ;
121
121
122
- export type SuccessfulTransactionMessage = {
122
+ export interface SuccessfulTransactionMessage {
123
123
type : typeof COMPLETE_STEP ;
124
124
paymentType : 'transfer' ;
125
125
body : {
@@ -130,11 +130,11 @@ export type SuccessfulTransactionMessage = {
130
130
amount : number ;
131
131
service_fee : number ;
132
132
state : 'PENDING' | 'SUCCESS' ;
133
- metadata : { [ keys : string | number ] : string | number | boolean } ;
133
+ metadata : Record < string | number , string | number | boolean > ;
134
134
payor_id : string ;
135
135
payment_method_id : string ;
136
136
} ;
137
- } ;
137
+ }
138
138
139
139
export const parseSuccessfulTransactionMessage = (
140
140
message : SuccessfulTransactionMessage ,
@@ -158,7 +158,7 @@ export const parseSuccessfulTransactionMessage = (
158
158
} ;
159
159
} ;
160
160
161
- export type FailedTransactionMessage = {
161
+ export interface FailedTransactionMessage {
162
162
type : typeof COMPLETE_STEP ;
163
163
paymentType : 'transfer' ;
164
164
body : {
@@ -176,7 +176,7 @@ export type FailedTransactionMessage = {
176
176
} ;
177
177
} ;
178
178
} ;
179
- } ;
179
+ }
180
180
181
181
export const parseFailedTransactionMessage = (
182
182
message : FailedTransactionMessage ,
@@ -198,16 +198,16 @@ export const parseFailedTransactionMessage = (
198
198
} ;
199
199
} ;
200
200
201
- export type CashBarcodeMessage = {
201
+ export interface CashBarcodeMessage {
202
202
type : typeof CASH_BARCODE_STEP ;
203
203
body : CashBarcodeObject ;
204
- } ;
204
+ }
205
205
206
- export type TokenizedPaymentMethodMessage = {
206
+ export interface TokenizedPaymentMethodMessage {
207
207
type : typeof COMPLETE_STEP ;
208
208
paymentType : 'tokenize' ;
209
209
body : TokenizedPaymentMethodObject ;
210
- } ;
210
+ }
211
211
212
212
export const parseResponse = (
213
213
message :
@@ -268,9 +268,9 @@ export const localizeCashBarcodeUrl = (
268
268
resolve ( response ) ;
269
269
} ;
270
270
271
- function error ( ) {
271
+ const error = ( ) => {
272
272
resolve ( response ) ;
273
- }
273
+ } ;
274
274
275
275
navigator . geolocation . getCurrentPosition ( success , error , options ) ;
276
276
}
0 commit comments