-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathcredit_card.js
66 lines (56 loc) · 1.8 KB
/
credit_card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
let AttributeSetter = require('./attribute_setter').AttributeSetter;
let CreditCardVerification = require('./credit_card_verification').CreditCardVerification;
class CreditCard extends AttributeSetter {
static initClass() {
this.CardType = {
AmEx: 'American Express',
CarteBlanche: 'Carte Blanche',
ChinaUnionPay: 'China UnionPay',
DinersClubInternational: 'Diners Club',
Discover: 'Discover',
JCB: 'JCB',
Laser: 'Laser',
UKMaestro: 'UK Maestro',
Maestro: 'Maestro',
MasterCard: 'MasterCard',
Solo: 'Solo',
Switch: 'Switch',
Visa: 'Visa',
Unknown: 'Unknown',
All() {
let all = [];
for (let key in this) {
if (!this.hasOwnProperty(key)) {
continue;
}
let value = this[key];
if (key !== 'All') { all.push(value); }
}
return all;
}
};
this.CustomerLocation = {
International: 'international',
US: 'us'
};
this.CardTypeIndicator = {
Yes: 'Yes',
No: 'No',
Unknown: 'Unknown'
};
this.Prepaid = this.Commercial = this.Payroll = this.Healthcare = this.DurbinRegulated =
this.Debit = this.CountryOfIssuance = this.IssuingBank = this.ProductId = this.CardTypeIndicator;
}
constructor(attributes) {
super(attributes);
this.maskedNumber = `${this.bin}******${this.last4}`;
this.expirationDate = `${this.expirationMonth}/${this.expirationYear}`;
if (attributes) {
let sortedVerifications = (attributes.verifications || []).sort((a, b) => b.created_at - a.created_at);
if (sortedVerifications[0]) { this.verification = new CreditCardVerification(sortedVerifications[0]); }
}
}
}
CreditCard.initClass();
module.exports = {CreditCard: CreditCard};