Skip to content

Commit 6f6b44e

Browse files
committed
refactor: remove unused validation and formatting methods in BraintreeBase class
1 parent a21d6a2 commit 6f6b44e

1 file changed

Lines changed: 0 additions & 33 deletions

File tree

plugins/braintree-payment/src/providers/payment-braintree/src/core/braintree-base.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ const validateString = (value: unknown, fieldName: string): string => {
9191
return value;
9292
};
9393

94-
const validateOptionalString = (value: unknown, fieldName: string): string | undefined => {
95-
if (value === undefined || value === null) return undefined;
96-
return validateString(value, fieldName);
97-
};
98-
9994
// Error handling utility that preserves full error context
10095
export const buildBraintreeError = (
10196
error: unknown,
@@ -206,34 +201,6 @@ class BraintreeBase extends AbstractPaymentProvider<BraintreeOptions> {
206201
});
207202
}
208203

209-
private formatToTwoDecimalStringIfFinite(amount: unknown): string | undefined {
210-
const n = Number(amount);
211-
if (!Number.isFinite(n)) return undefined;
212-
return formatToTwoDecimalString(n);
213-
}
214-
215-
private truncate(value: unknown, max: number): string | undefined {
216-
if (value === null || value === undefined) return undefined;
217-
const str = String(value);
218-
if (!str.length) return undefined;
219-
return str.length > max ? str.slice(0, max) : str;
220-
}
221-
222-
private sanitizeCountryCodeAlpha2(value: unknown): string | undefined {
223-
const v = typeof value === 'string' ? value.trim().toUpperCase() : undefined;
224-
return v ? this.truncate(v, 2) : undefined;
225-
}
226-
227-
private sanitizeCustomFields(fields?: Record<string, unknown>): Record<string, string> | undefined {
228-
if (!fields) return undefined;
229-
const out: Record<string, string> = {};
230-
for (const [k, v] of Object.entries(fields)) {
231-
const val = this.truncate(v, 255);
232-
if (val !== undefined) out[k] = val;
233-
}
234-
return Object.keys(out).length ? out : undefined;
235-
}
236-
237204
static validateOptions(options: BraintreeOptions): void {
238205
const requiredFields = ['merchantId', 'publicKey', 'privateKey', 'webhookSecret', 'environment'];
239206

0 commit comments

Comments
 (0)