Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
fix(Payment methods): get payment methods when buy quote baseCurrency…
Browse files Browse the repository at this point in the history
… is btc (#298)

* fix(Payment methods): get payment methods when buy quote baseCurrency is btc

* tests(Payment methods): fix tests
  • Loading branch information
plondon authored and Sjors committed Oct 19, 2016
1 parent e01bced commit 8a61f3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/coinify/payment-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ PaymentMethod.fetchAll = function (inCurrency, outCurrency, api) {
};

PaymentMethod.prototype.calculateFee = function (quote) {
this._fee = Math.round(this.inFixedFee + -quote.baseAmount * (this.inPercentageFee / 100));
this._total = -quote.baseAmount + this._fee;
let amt = quote.baseCurrency === 'BTC' ? quote.quoteAmount : quote.baseAmount;
this._fee = Math.round(this.inFixedFee + -amt * (this.inPercentageFee / 100));
this._total = -amt + this._fee;
};
9 changes: 8 additions & 1 deletion src/coinify/quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,17 @@ Quote.prototype.getPaymentMethods = function () {
return self.paymentMethods;
};

let inCurrency = this.baseCurrency;
let outCurrency = this.quoteCurrency;
if (this.baseCurrency === 'BTC' && this.baseAmount > 0) {
inCurrency = this.quoteCurrency;
outCurrency = this.baseCurrency;
}

if (this.paymentMethods) {
return Promise.resolve(this.paymentMethods);
} else {
return PaymentMethod.fetchAll(this.baseCurrency, this.quoteCurrency, this._api)
return PaymentMethod.fetchAll(inCurrency, outCurrency, this._api)
.then(setPaymentMethods);
}
};
Expand Down

0 comments on commit 8a61f3b

Please sign in to comment.