Skip to content

Commit 1e8ca76

Browse files
committed
Remove unnecessary sanitization
1 parent 37beb18 commit 1e8ca76

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/request/transaction.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,12 @@ export default class Transaction {
117117
private sanitizeKeys() {
118118
const sanitized = Object.assign({}, this) as any;
119119

120-
if (sanitized.creditCard != null) {
121-
if (sanitized.creditCard.last4digits != null) {
122-
sanitized.creditCard.last_digits = this.creditCard!.last4digits;
123-
delete sanitized.creditCard.last4digits;
124-
}
125-
126-
if (sanitized.creditCard.lastDigits != null) {
127-
sanitized.creditCard.last_digits = this.creditCard!.lastDigits;
128-
delete sanitized.creditCard.lastDigits;
129-
}
120+
if (
121+
sanitized.creditCard &&
122+
Object.prototype.hasOwnProperty.call(sanitized.creditCard, 'lastDigits')
123+
) {
124+
sanitized.creditCard.last_digits = sanitized.creditCard.lastDigits;
125+
delete sanitized.creditCard.lastDigits;
130126
}
131127

132128
if (

0 commit comments

Comments
 (0)