Skip to content

Commit 282e15f

Browse files
committed
fix: linting fixes
1 parent 9e21655 commit 282e15f

File tree

6 files changed

+112
-115
lines changed

6 files changed

+112
-115
lines changed

src/common/observe.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
tokenizePaymentMethod,
1717
activateCardPresentDevice,
1818
} from '../field-set/actions';
19-
import { defaultElementIds, ElementTypes } from './data';
19+
import { defaultElementIds } from './data';
2020

2121
export const errorObserver = (cb: (error: string) => void) =>
2222
messaging.handleMessage(
@@ -44,23 +44,23 @@ export const readyObserver = (cb: (ready: true) => void) =>
4444
cb(true);
4545
});
4646

47-
export const tokenizeObserver = (cb: (value: any) => void) =>
47+
export const tokenizeObserver = (cb: (value: unknown) => void) =>
4848
messaging.handleMessage(
4949
messaging.confirmTypeMessage,
5050
(message: { type: string; body: ConfirmationObject }) => {
5151
cb(message.body);
5252
},
5353
);
5454

55-
export const captureObserver = (cb: (value: any) => void) =>
55+
export const captureObserver = (cb: (value: unknown) => void) =>
5656
messaging.handleMessage(
5757
messaging.confirmationCompleteTypeMessage,
5858
(message: { type: string; body: SuccessfulTransactionMessage | FailedTransactionMessage }) => {
5959
cb(message.body);
6060
},
6161
);
6262

63-
export const transactedObserver = (cb: (value: any) => void) =>
63+
export const transactedObserver = (cb: (value: unknown) => void) =>
6464
messaging.handleMessage(
6565
messaging.completeTypeMessage,
6666
(message: {
@@ -71,18 +71,18 @@ export const transactedObserver = (cb: (value: any) => void) =>
7171
},
7272
);
7373

74-
export const cashObserver = (cb: (value: any) => void) =>
74+
export const cashObserver = (cb: (value: unknown) => void) =>
7575
messaging.handleMessage(
7676
messaging.cashTypeMessage,
7777
(message: { type: string; body: CashBarcodeObject }) => {
7878
cb(message.body);
7979
},
8080
);
8181

82-
export const cardPresentObserver = (cb: (value: any) => void) =>
83-
messaging.handleHostedFieldMessage(messaging.cardPresentTypeMessage, (message: any) => {
84-
cb(message.body);
85-
});
82+
// export const cardPresentObserver = (cb: (value: any) => void) =>
83+
// messaging.handleHostedFieldMessage(messaging.cardPresentTypeMessage, (message: any) => {
84+
// cb(message.body);
85+
// });
8686

8787
export const generateReturn = (
8888
mount: (props: {
@@ -108,6 +108,5 @@ export const generateReturn = (
108108
tokenizeObserver,
109109
transactedObserver,
110110
stateObserver,
111-
cardPresentObserver,
112111
};
113112
};

src/common/pay_theory_types.ts

+54-52
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// noinspection JSUnusedGlobalSymbols
2+
13
import { defaultElementIds, ElementTypes, MERCHANT_FEE, SERVICE_FEE } from './data';
24

35
export enum ResponseMessageTypes {
@@ -10,43 +12,43 @@ export enum ResponseMessageTypes {
1012
READY = 'READY',
1113
}
1214

13-
export type AddressObject = {
15+
export interface AddressObject {
1416
line1?: string;
1517
line2?: string;
1618
city?: string;
1719
region?: string;
1820
postal_code?: string;
1921
country?: string;
20-
};
22+
}
2123

22-
export type PayorInfo = {
24+
export interface PayorInfo {
2325
first_name?: string;
2426
last_name?: string;
2527
email?: string;
2628
phone?: string;
2729
personal_address?: AddressObject;
28-
};
30+
}
2931

30-
export type BillingInfo = {
32+
export interface BillingInfo {
3133
name?: string;
3234
address?: AddressObject;
33-
};
35+
}
3436

35-
export type ConfirmationObject = {
37+
export interface ConfirmationObject {
3638
first_six: string;
3739
last_four: string;
3840
brand: string;
3941
receipt_number: string;
4042
amount: number;
4143
service_fee: number;
42-
};
44+
}
4345

44-
export type ConfirmationResponse = {
46+
export interface ConfirmationResponse {
4547
type: ResponseMessageTypes.CONFIRMATION;
4648
body: ConfirmationObject;
47-
};
49+
}
4850

49-
export type SuccessfulTransactionObject = {
51+
export interface SuccessfulTransactionObject {
5052
receipt_number: string;
5153
last_four: string;
5254
brand: string;
@@ -55,23 +57,23 @@ export type SuccessfulTransactionObject = {
5557
service_fee: number;
5658
state: string;
5759
// Keeping tags in the response for backwards compatibility
58-
tags: { [keys: string | number]: string | number | boolean };
59-
metadata: { [keys: string | number]: string | number | boolean };
60+
tags: Record<string | number, string | number | boolean>;
61+
metadata: Record<string | number, string | number | boolean>;
6062
payor_id: string;
6163
payment_method_id: string;
62-
};
64+
}
6365

64-
export type SuccessfulTransactionResponse = {
66+
export interface SuccessfulTransactionResponse {
6567
type: ResponseMessageTypes.SUCCESS;
6668
body: SuccessfulTransactionObject;
67-
};
69+
}
6870

69-
export type ReadyResponse = {
71+
export interface ReadyResponse {
7072
type: ResponseMessageTypes.READY;
7173
body: true;
72-
};
74+
}
7375

74-
export type FailedTransactionObject = {
76+
export interface FailedTransactionObject {
7577
receipt_number: string;
7678
last_four: string;
7779
brand: string;
@@ -82,37 +84,37 @@ export type FailedTransactionObject = {
8284
failure_code: string;
8385
failure_text: string;
8486
};
85-
};
87+
}
8688

87-
export type FailedTransactionResponse = {
89+
export interface FailedTransactionResponse {
8890
type: ResponseMessageTypes.FAILED;
8991
body: FailedTransactionObject;
90-
};
92+
}
9193

92-
export type CashBarcodeObject = {
94+
export interface CashBarcodeObject {
9395
barcodeUrl: string;
9496
mapUrl: string;
95-
};
97+
}
9698

97-
export type CashBarcodeResponse = {
99+
export interface CashBarcodeResponse {
98100
type: ResponseMessageTypes.CASH;
99101
body: CashBarcodeObject;
100-
};
102+
}
101103

102-
export type TokenizedPaymentMethodObject = {
104+
export interface TokenizedPaymentMethodObject {
103105
payment_method_id: string;
104106
payor_id: string;
105107
last_four: string;
106108
brand: string;
107109
expiration: string;
108110
payment_type: 'card' | 'ach';
109111
metadata: { [keys: string | number]: string | number | boolean };
110-
};
112+
}
111113

112-
export type TokenizedPaymentMethodResponse = {
114+
export interface TokenizedPaymentMethodResponse {
113115
type: ResponseMessageTypes.TOKENIZED;
114116
body: TokenizedPaymentMethodObject;
115-
};
117+
}
116118

117119
// Error Types
118120
export enum ErrorType {
@@ -130,20 +132,20 @@ export enum ErrorType {
130132
NOT_READY = 'NOT_READY',
131133
}
132134

133-
export type ErrorResponse = {
135+
export interface ErrorResponse {
134136
type: ResponseMessageTypes.ERROR;
135137
error: string;
136-
};
138+
}
137139

138140
// Function Prop Types
139-
export type TokenizeProps = {
141+
export interface TokenizeProps {
140142
payorInfo?: PayorInfo;
141143
payorId?: string;
142144
metadata?: { [keys: string | number]: string | number | boolean };
143145
billingInfo?: BillingInfo;
144-
};
146+
}
145147

146-
export type TransactProps = {
148+
export interface TransactProps {
147149
amount: number;
148150
payorInfo?: PayorInfo;
149151
billingInfo?: BillingInfo;
@@ -161,18 +163,18 @@ export type TransactProps = {
161163
recurringId?: string;
162164
healthExpenseType?: HealthExpenseType;
163165
level3DataSummary?: Level3DataSummary;
164-
};
166+
}
165167

166-
export type PayTheoryPaymentFieldsInput = {
168+
export interface PayTheoryPaymentFieldsInput {
167169
apiKey: string;
168170
styles?: StyleObject;
169-
metadata?: { [key: string | number]: string | number | boolean };
171+
metadata?: Record<string | number, string | number | boolean>;
170172
placeholders?: PlaceholderObject;
171173
elementIds?: typeof defaultElementIds;
172174
session?: string; // This is used for internal use to connect a button and qr code to a hosted checkout page
173175
feeMode?: typeof MERCHANT_FEE | typeof SERVICE_FEE;
174176
amount?: number;
175-
};
177+
}
176178

177179
export enum AcceptedPaymentMethods {
178180
ALL = 'ALL',
@@ -198,41 +200,41 @@ export enum ButtonColor {
198200
GREY = 'GREY',
199201
}
200202

201-
export type CheckoutDetails = {
203+
export interface CheckoutDetails {
202204
amount: number;
203205
paymentName: string;
204206
paymentDescription?: string;
205207
requirePhone?: boolean;
206208
callToAction?: CallToAction;
207209
acceptedPaymentMethods?: AcceptedPaymentMethods;
208210
payorId?: string;
209-
metadata?: { [keys: string | number]: string | number | boolean };
211+
metadata?: Record<string | number, string | number | boolean>;
210212
feeMode?: typeof MERCHANT_FEE | typeof SERVICE_FEE;
211213
accountCode?: string;
212214
paymentParameters?: string;
213215
invoiceId?: string;
214216
recurringId?: string;
215217
healthExpenseType?: HealthExpenseType;
216218
level3DataSummary?: Level3DataSummary;
217-
};
219+
}
218220

219-
export type PayTheoryQRInput = {
221+
export interface PayTheoryQRInput {
220222
apiKey: string;
221223
checkoutDetails: CheckoutDetails;
222224
size: number;
223225
onReady: (ready: true) => void;
224226
onError: (error: string) => void;
225227
onSuccess: (result: SuccessfulTransactionObject) => void;
226-
};
228+
}
227229

228-
export type ButtonStyle = {
230+
export interface ButtonStyle {
229231
color: ButtonColor;
230232
callToAction: CallToAction;
231233
pill: boolean;
232234
height: number;
233-
};
235+
}
234236

235-
export type PayTheoryButtonInput = {
237+
export interface PayTheoryButtonInput {
236238
apiKey: string;
237239
checkoutDetails: CheckoutDetails;
238240
style?: ButtonStyle;
@@ -242,20 +244,20 @@ export type PayTheoryButtonInput = {
242244
onCancel?: () => void;
243245
onSuccess?: (result: SuccessfulTransactionObject) => void;
244246
onBarcode?: (result: CashBarcodeObject) => void;
245-
};
247+
}
246248

247-
export type FieldState = {
249+
export interface FieldState {
248250
isFocused: boolean;
249251
isDirty: boolean;
250252
errorMessages: string[];
251-
};
253+
}
252254

253255
export type StateObject = Record<ElementTypes, FieldState> &
254256
Record<'service_fee', { amount?: number; ach_fee?: number; card_fee?: number }>;
255257

256258
export type PlaceholderObject = Partial<Record<ElementTypes, string>>;
257259

258-
export type StyleObject = {
260+
export interface StyleObject {
259261
default: object;
260262
success: object;
261263
error: object;
@@ -269,7 +271,7 @@ export type StyleObject = {
269271
};
270272
};
271273
hidePlaceholder?: boolean;
272-
};
274+
}
273275

274276
export interface Level3DataSummary {
275277
tax_amt: number;

src/components/pay-theory-checkout-qr/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class PayTheoryCheckoutQR extends HTMLElement {
7777

7878
set size(value: number) {
7979
this._size = value;
80-
const iframe = document.getElementById(`${common.checkoutQRField}-iframe`) as HTMLIFrameElement;
80+
const iframe = document.getElementById(`${common.checkoutQRField}-iframe`) as
81+
| HTMLIFrameElement
82+
| undefined;
8183
if (iframe) {
8284
iframe.height = `${this._size}px`;
8385
iframe.width = `${this._size}px`;

0 commit comments

Comments
 (0)