Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge 9086ffa into f25441f
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Nov 16, 2017
2 parents f25441f + 9086ffa commit e4c06bc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/models/payment-processor-adapters/coinpayments.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const coinpaymentsAdapter = {

addPaymentMethod: function (token) {
return new Promise((resolve, reject) => {
coinpayments.getCallbackAddress(token, function(err, data) {
coinpayments().getCallbackAddress(token, function(err, data) {
if (err) {
reject(err);
}
Expand Down
19 changes: 8 additions & 11 deletions lib/vendor/coinpayments.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ const options = {

let client;

try {
client = new Coinpayments(options);
} catch (err) {
if (err.message === 'Missing public key and/or secret') {
console.error(err.message);
return;
} else {
throw(err);
}
}
const getClient = function () {
if (client) {
return client;
}

client = new Coinpayments(options);
return client;
};

module.exports = client;
module.exports = getClient;
24 changes: 16 additions & 8 deletions test/payment-processor-adapters/coinpayments.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ describe('Storage/models/PaymentProcessor/coinpayments', function () {
address: '0x703faaa2f42291e0aaa9ffdbd74ae81172895bc7'
};
const Adapter = proxyquire(libPath, {
'../../vendor/coinpayments': {
getCallbackAddress: sinon.stub().callsArgWith(1, null, data)
'../../vendor/coinpayments': function () {
return {
getCallbackAddress: sinon.stub().callsArgWith(1, null, data)
}
}
});
const paymentProcessor = {
Expand All @@ -41,8 +43,10 @@ describe('Storage/models/PaymentProcessor/coinpayments', function () {
address: '0x703faaa2f42291e0aaa9ffdbd74ae81172895bc7'
};
const Adapter = proxyquire(libPath, {
'../../vendor/coinpayments': {
getCallbackAddress: sinon.stub().callsArgWith(1, null, data)
'../../vendor/coinpayments': function () {
return {
getCallbackAddress: sinon.stub().callsArgWith(1, null, data)
}
}
});
const paymentProcessor = {
Expand All @@ -67,8 +71,10 @@ describe('Storage/models/PaymentProcessor/coinpayments', function () {
address: '0x703faaa2f42291e0aaa9ffdbd74ae81172895bc7'
};
const Adapter = proxyquire(libPath, {
'../../vendor/coinpayments': {
getCallbackAddress: sinon.stub().callsArgWith(1, null, data)
'../../vendor/coinpayments': function () {
return {
getCallbackAddress: sinon.stub().callsArgWith(1, null, data)
}
}
});
const paymentProcessor = {
Expand Down Expand Up @@ -99,8 +105,10 @@ describe('Storage/models/PaymentProcessor/coinpayments', function () {
address: '0x703faaa2f42291e0aaa9ffdbd74ae81172895bc7'
};
const Adapter = proxyquire(libPath, {
'../../vendor/coinpayments': {
getCallbackAddress: sinon.stub().callsArgWith(1, null, data)
'../../vendor/coinpayments': function () {
return {
getCallbackAddress: sinon.stub().callsArgWith(1, null, data)
}
}
});
const paymentProcessor = {
Expand Down

0 comments on commit e4c06bc

Please sign in to comment.