-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathtransaction.js
127 lines (112 loc) · 4.3 KB
/
transaction.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
'use strict';
let AttributeSetter = require('./attribute_setter').AttributeSetter;
let ApplePayCard = require('./apple_pay_card').ApplePayCard;
let AndroidPayCard = require('./android_pay_card').AndroidPayCard;
let CreditCard = require('./credit_card').CreditCard;
let PayPalAccount = require('./paypal_account').PayPalAccount;
let CoinbaseAccount = require('./coinbase_account').CoinbaseAccount;
let DisbursementDetails = require('./disbursement_details').DisbursementDetails;
let Dispute = require('./dispute').Dispute;
let FacilitatorDetails = require('./facilitator_details').FacilitatorDetails;
let RiskData = require('./risk_data').RiskData;
let ThreeDSecureInfo = require('./three_d_secure_info').ThreeDSecureInfo;
let UsBankAccount = require('./us_bank_account').UsBankAccount;
let IdealPayment = require('./ideal_payment').IdealPayment;
let VisaCheckoutCard = require('./visa_checkout_card').VisaCheckoutCard;
let MasterpassCard = require('./masterpass_card').MasterpassCard;
class Transaction extends AttributeSetter {
static initClass() {
this.CreatedUsing = {
FullInformation: 'full_information',
Token: 'token'
};
this.EscrowStatus = {
HoldPending: 'hold_pending',
Held: 'held',
ReleasePending: 'release_pending',
Released: 'released',
Refunded: 'refunded'
};
this.Source = {
Api: 'api',
ControlPanel: 'control_panel',
Recurring: 'recurring'
};
this.Type = {
Credit: 'credit',
Sale: 'sale',
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.GatewayRejectionReason = {
ApplicationIncomplete: 'application_incomplete',
Avs: 'avs',
Cvv: 'cvv',
AvsAndCvv: 'avs_and_cvv',
Duplicate: 'duplicate',
Fraud: 'fraud',
ThreeDSecure: 'three_d_secure'
};
this.IndustryData = {
Lodging: 'lodging',
TravelAndCruise: 'travel_cruise'
};
this.Status = {
AuthorizationExpired: 'authorization_expired',
Authorizing: 'authorizing',
Authorized: 'authorized',
GatewayRejected: 'gateway_rejected',
Failed: 'failed',
ProcessorDeclined: 'processor_declined',
Settled: 'settled',
Settling: 'settling',
SettlementConfirmed: 'settlement_confirmed',
SettlementDeclined: 'settlement_declined',
SettlementPending: 'settlement_pending',
SubmittedForSettlement: 'submitted_for_settlement',
Voided: 'voided',
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;
}
};
}
constructor(attributes) {
super(attributes);
this.creditCard = new CreditCard(attributes.creditCard);
this.paypalAccount = new PayPalAccount(attributes.paypal);
this.coinbaseAccount = new CoinbaseAccount(attributes.coinbaseAccount);
this.applePayCard = new ApplePayCard(attributes.applePay);
this.androidPayCard = new AndroidPayCard(attributes.androidPayCard);
this.disbursementDetails = new DisbursementDetails(attributes.disbursementDetails);
this.visaCheckoutCard = new VisaCheckoutCard(attributes.visaCheckoutCard);
this.masterpassCard = new MasterpassCard(attributes.masterpassCard);
if (attributes.disputes != null) { this.disputes = attributes.disputes.map((disputeAttributes) => new Dispute(disputeAttributes)); }
if (attributes.facilitatorDetails) { this.facilitatorDetails = new FacilitatorDetails(attributes.facilitatorDetails); }
if (attributes.riskData) { this.riskData = new RiskData(attributes.riskData); }
if (attributes.threeDSecureInfo) { this.threeDSecureInfo = new ThreeDSecureInfo(attributes.threeDSecureInfo); }
if (attributes.usBankAccount) { this.usBankAccount = new UsBankAccount(attributes.usBankAccount); }
if (attributes.idealPayment) { this.idealPaymentDetails = new IdealPayment(attributes.idealPayment); }
}
isDisbursed() {
return this.disbursementDetails.isValid();
}
}
Transaction.initClass();
module.exports = {Transaction: Transaction};