-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathus_bank_account_gateway.js
34 lines (28 loc) · 1.19 KB
/
us_bank_account_gateway.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
'use strict';
let Gateway = require('./gateway').Gateway;
let UsBankAccount = require('./us_bank_account').UsBankAccount;
let TransactionGateway = require('./transaction_gateway').TransactionGateway;
let exceptions = require('./exceptions');
let wrapPrototype = require('@braintree/wrap-promise').wrapPrototype;
class UsBankAccountGateway extends Gateway {
constructor(gateway) {
super();
this.gateway = gateway;
this.config = this.gateway.config;
}
find(token) {
if (token.trim() === '') {
return Promise.reject(exceptions.NotFoundError('Not Found'), null); // eslint-disable-line new-cap
}
return this.gateway.http.get(`${this.config.baseMerchantPath()}/payment_methods/us_bank_account/${token}`).then(function (response) {
return new UsBankAccount(response.usBankAccount);
});
}
sale(token, transactionRequest) {
transactionRequest.paymentMethodToken = token;
if (!transactionRequest.options) { transactionRequest.options = {}; }
transactionRequest.options.submitForSettlement = true;
return new TransactionGateway(this.gateway).sale(transactionRequest);
}
}
module.exports = {UsBankAccountGateway: wrapPrototype(UsBankAccountGateway)};