-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathpaypal_account_gateway.js
40 lines (31 loc) · 1.26 KB
/
paypal_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
35
36
37
38
39
40
'use strict';
let Gateway = require('./gateway').Gateway;
let PayPalAccount = require('./paypal_account').PayPalAccount;
let exceptions = require('./exceptions');
let wrapPrototype = require('@braintree/wrap-promise').wrapPrototype;
class PayPalAccountGateway 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/paypal_account/${token}`).then((response) => {
return new PayPalAccount(response.paypalAccount);
});
}
update(token, attributes) {
return this.gateway.http.put(`${this.config.baseMerchantPath()}/payment_methods/paypal_account/${token}`, {paypalAccount: attributes}).then(this.responseHandler());
}
delete(token) {
let path = `${this.config.baseMerchantPath()}/payment_methods/paypal_account/${token}`;
return this.gateway.http.delete(path);
}
responseHandler() {
return this.createResponseHandler('paypalAccount', PayPalAccount);
}
}
module.exports = {PayPalAccountGateway: wrapPrototype(PayPalAccountGateway)};