-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathideal_payment_gateway.js
37 lines (29 loc) · 1.2 KB
/
ideal_payment_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
'use strict';
let Gateway = require('./gateway').Gateway;
let IdealPayment = require('./ideal_payment').IdealPayment;
let TransactionGateway = require('./transaction_gateway').TransactionGateway;
let exceptions = require('./exceptions');
let wrapPrototype = require('@braintree/wrap-promise').wrapPrototype;
class IdealPaymentGateway extends Gateway {
constructor(gateway) {
super();
this.gateway = gateway;
this.config = this.gateway.config;
}
find(idealPaymentId) {
if (idealPaymentId.trim() === '') {
return Promise.reject(exceptions.NotFoundError('Not Found'), null); // eslint-disable-line new-cap
}
return this.gateway.http.get(`${this.config.baseMerchantPath()}/ideal_payments/${idealPaymentId}`).then(function (response) {
return new IdealPayment(response.idealPayment);
});
}
sale(idealPaymentId, transactionRequest) {
const request = Object.assign({}, transactionRequest);
request.paymentMethodNonce = idealPaymentId;
request.options = request.options || {};
request.options.submitForSettlement = true;
return new TransactionGateway(this.gateway).sale(request);
}
}
module.exports = {IdealPaymentGateway: wrapPrototype(IdealPaymentGateway)};