Comparing version
@@ -6,3 +6,3 @@ const env = 'dev' | ||
const host = (env == 'development') ? `http://localhost:${port+1}` : 'https://alemey.com' | ||
const aloborio = (env == 'development') ? `http://localhost:${port+2}` : `https://api.alobor.io` | ||
// const aloborio = (env == 'development') ? `http://localhost:${port+2}` : `https://api.alobor.io` | ||
@@ -12,4 +12,4 @@ module.exports = { | ||
getLink: `${apihost}/link?params=`, | ||
api: apihost, | ||
qrCodeRedirect: `${host}/crypttp`, | ||
aloborio: aloborio | ||
} |
72
index.js
const axios = require('axios') | ||
const env = require('./env') | ||
const io = require('socket.io-client') | ||
class isMobile { | ||
@@ -49,5 +51,56 @@ constructor () {} | ||
this.companyAccount = {} | ||
this.subscribeToTransactionConfirmed() | ||
} | ||
subscribeToTransactionConfirmed () { | ||
axios({ | ||
method:"get", | ||
url: `${env.api}/find_service/blockchain` | ||
}) | ||
.then(response => { | ||
this.blockchain_service = response.data | ||
this.io = io(this.blockchain_service); | ||
this.io.on('transaction_paid', (msg) => { | ||
this.saveStats(msg, this.orderDetails) | ||
/** | ||
* @dev here probably i can add showing success pop | ||
*/ | ||
}) | ||
}) | ||
} | ||
saveStats (receipt, order) { | ||
try { | ||
const data = { | ||
type: "payment", | ||
isNative: true, | ||
order: order, | ||
tx: receipt | ||
} | ||
Axios({ | ||
method: "post", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
url: `${env.api}/aqr/setConfirmedOrder`, | ||
data: data | ||
}) | ||
} | ||
catch (e) { | ||
console.log(e) | ||
} | ||
} | ||
startListening () { | ||
io.emit('start_listening', { | ||
order_id: this.order_id, | ||
merchant_id: this.merchant_id, | ||
wallets: this.companyAccount, | ||
amount: this.amount | ||
}) | ||
} | ||
convertRates (input, output) { | ||
@@ -86,5 +139,5 @@ return new Promise(async (resolve, reject) => { | ||
*/ | ||
getWalletsOfMerchant (merchant_id, order_id) { | ||
getWalletsOfMerchant () { | ||
return new Promise((resolve, reject) => { | ||
axios({ method:"post", url:`${env.aloborio}/b2b/company_wallets?merchant_id=${merchant_id}&order_id=${order_id}` }) | ||
axios({ method:"post", url:`${env.aloborio}/b2b/company_wallets?merchant_id=${this.merchant_id}&order_id=${this.order_id}` }) | ||
.then(response => { | ||
@@ -130,3 +183,3 @@ if (!Object.keys(response.data).length) | ||
this.validateInputs({ merchant_id, country_currency, amount }) | ||
country_currency = (country_currency) ? country_currency.replace("#/", "") : '' | ||
@@ -139,4 +192,15 @@ amount = (amount) ? amount.replace("#/", "") : '' | ||
const data_order_id = await axios({ method:"post", url: `https://api.alobor.io/aqr/pay?total=${amount}¤cy=${country_currency}` }) | ||
await this.getWalletsOfMerchant(merchant_id, data_order_id.id) | ||
this.merchant_id = merchant_id | ||
this.order_id = data_order_id.id | ||
this.amount = { | ||
ETHEREUM: (amount / this.rates["ETH"]).toString(), | ||
MINTER: (amount / this.rates["BIP"]).toString(), | ||
STELLAR: (amount / this.rates["XLM"]).toString() | ||
} | ||
await this.getWalletsOfMerchant() | ||
this.startListening() | ||
let list = [] | ||
@@ -143,0 +207,0 @@ |
{ | ||
"name": "crypttp", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Module to call APIs of crypttp powered by alemey", | ||
@@ -9,3 +9,4 @@ "main": "index.js", | ||
"axios": "^0.19.0", | ||
"dev": "^0.1.3" | ||
"dev": "^0.1.3", | ||
"socket.io-client": "^2.3.0" | ||
}, | ||
@@ -21,7 +22,5 @@ "devDependencies": { | ||
}, | ||
"scripts": { | ||
"build": "rm -rf dist/ && webpack --config webpack.config.js" | ||
}, | ||
"scripts": {}, | ||
"author": "Bogdan Sizov, Alemey", | ||
"license": "ISC" | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8148
26.09%206
36.42%0
-100%4
33.33%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added