Skip to content

Commit df13b12

Browse files
authored
Merge pull request #735 from maxmind/kevin/fix-was-3d-secure-successful
Fix was3DSecureSuccessful conversion to snakecase
2 parents b7f6f99 + 947e219 commit df13b12

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
------------------
66

77
* Added `ShopifyPayments` to the `Processor` enum.
8+
* Fix `creditCard.was3DSecureSuccessful` snakecase conversion.
89

910
4.5.0 (2022-03-28)
1011
------------------

src/request/transaction.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ describe('Transaction()', () => {
255255
const test = new Transaction({
256256
creditCard: new CreditCard({
257257
last4digits: '1234',
258+
was3DSecureSuccessful: true,
258259
}),
259260
device: new Device({
260261
ipAddress: '1.1.1.1',
@@ -266,7 +267,9 @@ describe('Transaction()', () => {
266267

267268
expect(test.toString()).toContain(deviceString);
268269

269-
expect(test.toString()).toContain('"credit_card":{"last_digits":"1234"}');
270+
expect(test.toString()).toContain(
271+
'"credit_card":{"last_digits":"1234","was_3d_secure_successful":true}'
272+
);
270273
});
271274

272275
it('it handles optional order field', () => {

src/request/transaction.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,6 @@ export default class Transaction {
119119
// eslint-disable-next-line @typescript-eslint/no-explicit-any
120120
const sanitized = Object.assign({}, this) as any;
121121

122-
if (
123-
sanitized.creditCard &&
124-
Object.prototype.hasOwnProperty.call(sanitized.creditCard, 'lastDigits')
125-
) {
126-
sanitized.creditCard.last_digits = sanitized.creditCard.lastDigits;
127-
delete sanitized.creditCard.lastDigits;
128-
}
129-
130122
if (
131123
sanitized.billing &&
132124
Object.prototype.hasOwnProperty.call(sanitized.billing, 'address2')
@@ -143,6 +135,18 @@ export default class Transaction {
143135
delete sanitized.shipping.address2;
144136
}
145137

138+
if (
139+
sanitized.creditCard &&
140+
Object.prototype.hasOwnProperty.call(
141+
sanitized.creditCard,
142+
'was3DSecureSuccessful'
143+
)
144+
) {
145+
sanitized.creditCard.was_3d_secure_successful =
146+
sanitized.creditCard.was3DSecureSuccessful;
147+
delete sanitized.creditCard.was3DSecureSuccessful;
148+
}
149+
146150
return sanitized;
147151
}
148152

0 commit comments

Comments
 (0)