Comparing version 0.2.1 to 0.2.2
76
index.js
@@ -36,21 +36,27 @@ const axios = require('axios') | ||
constructor () { | ||
this.isMobile = new isMobile() | ||
this.chains = [ "ETHEREUM", "MINTER", "STELLAR" ] | ||
this.nativeCurrency = { | ||
ETHEREUM: "ETH", | ||
MINTER: "BIP", | ||
STELLAR: "XLM" | ||
} | ||
this.currencies = ["ETH", "BIP", "XLM"] | ||
this.currency_to_chain = { | ||
ETH: "ETHEREUM", | ||
BIP: "MINTER", | ||
XLM: "STELLAR" | ||
} | ||
this.rates = {} | ||
this.companyAccount = {} | ||
this.isMobile = new isMobile() | ||
this.chains = [] | ||
this.nativeCurrency = {} | ||
this.currencies = [] | ||
this.currency_to_chain = {} | ||
this.rates = {} | ||
this.companyAccount = {} | ||
this.fetchSupportedProtocols() | ||
this.subscribeToTransactionConfirmed() | ||
} | ||
fetchSupportedProtocols() { | ||
axios({ | ||
method:"get", | ||
url: `${env.api}/link/supported_protocols` | ||
}) | ||
.then(response => { | ||
this.chains = response.data.chains | ||
this.nativeCurrency = response.data.nativeCurrency | ||
this.currencies = response.data.currencies | ||
this.currency_to_chain = response.data.currency_to_chain | ||
}) | ||
} | ||
subscribeToTransactionConfirmed () { | ||
@@ -175,2 +181,3 @@ axios({ | ||
* @param {string} amount amount to charge in native currency numeration | ||
* @param {Object} to object that should contain wallets of merchant for each currency {ETH:"0x1234"} | ||
* @param {string} payload any extra data that you want to send with cryptocurrency transaction | ||
@@ -193,2 +200,13 @@ * @param {string} memo a special tag for specific blockchains | ||
}) { | ||
type = (typeof type != "undefined") ? type.toString().replace("#/", "") : "" | ||
merchant_id = (typeof merchant_id != "undefined") ? merchant_id.toString().replace("#/", "") : "" | ||
country_currency = (typeof country_currency != "undefined") ? country_currency.toString().replace("#/", "") : "" | ||
currency = (typeof currency != "undefined") ? currency.toString().replace("#/", "") : "" | ||
amount = (typeof amount != "undefined") ? amount.toString().replace("#/", "") : "" | ||
to = (typeof to != "undefined") ? to.toString().replace("#/", "") : "" | ||
payload = (typeof payload != "undefined") ? payload.toString().replace("#/", "") : "" | ||
memo = (typeof memo != "undefined") ? memo.toString().replace("#/", "") : "" | ||
onsuccess = (typeof onsuccess != "undefined") ? onsuccess.toString().replace("#/", "") : "" | ||
onerror = (typeof onerror != "undefined") ? onerror.toString().replace("#/", "") : "" | ||
this.navigation = () => { | ||
@@ -203,7 +221,7 @@ return new Promise(async (resolve, reject) => { | ||
if (typeof currency != 'undefined') { | ||
if (currency) { | ||
list.push([ | ||
currency, | ||
(amount / this.rates[currency]).toString(), | ||
to, | ||
to[currency], | ||
payload, | ||
@@ -216,7 +234,10 @@ memo, | ||
else { | ||
this.currencies.map((el) => { | ||
/** | ||
* this will map by wallets given by Payment gateway | ||
*/ | ||
Object.keys(to).map((el) => { | ||
list.push([ | ||
el, | ||
(amount / this.rates[el]).toString(), | ||
to, | ||
to[el], | ||
payload, | ||
@@ -252,3 +273,3 @@ memo, | ||
if (typeof currency != 'undefined') { | ||
if (currency) { | ||
list.push([ | ||
@@ -265,7 +286,7 @@ currency, | ||
else { | ||
this.currencies.map((el) => { | ||
Object.keys(this.companyAccount).map((el) => { | ||
list.push([ | ||
el, | ||
(amount / this.rates[el]).toString(), | ||
this.companyAccount[this.currency_to_chain[el]], | ||
this.nativeCurrency[el], | ||
(amount / this.rates[this.nativeCurrency[el]]).toString(), | ||
this.companyAccount[el], | ||
payload, | ||
@@ -301,9 +322,4 @@ memo, | ||
let list = [] | ||
let list = []; | ||
country_currency = (country_currency) ? country_currency.replace("#/", "") : '' | ||
amount = (amount) ? amount.replace("#/", "") : '' | ||
payload = (payload) ? payload.replace("#/", "") : '' | ||
memo = (memo) ? memo.replace("#/", "") : '' | ||
await this.updateRates(country_currency) | ||
@@ -310,0 +326,0 @@ |
{ | ||
"name": "crypttp", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Module to call APIs of crypttp powered by alemey", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
12740
303