Comparing version 0.1.5 to 0.1.6
@@ -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" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
206
0
4
+ Addedsocket.io-client@^2.3.0
+ Addedafter@0.8.2(transitive)
+ Addedarraybuffer.slice@0.0.7(transitive)
+ Addedbacko2@1.0.2(transitive)
+ Addedbase64-arraybuffer@0.1.4(transitive)
+ Addedblob@0.0.5(transitive)
+ Addedcomponent-bind@1.0.0(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedcomponent-inherit@0.0.3(transitive)
+ Addedengine.io-client@3.5.4(transitive)
+ Addedengine.io-parser@2.2.1(transitive)
+ Addedhas-binary2@1.0.3(transitive)
+ Addedhas-cors@1.1.0(transitive)
+ Addedindexof@0.0.1(transitive)
+ Addedisarray@2.0.1(transitive)
+ Addedparseqs@0.0.6(transitive)
+ Addedparseuri@0.0.6(transitive)
+ Addedsocket.io-client@2.5.0(transitive)
+ Addedsocket.io-parser@3.3.4(transitive)
+ Addedto-array@0.1.4(transitive)
+ Addedws@7.5.10(transitive)
+ Addedxmlhttprequest-ssl@1.6.3(transitive)
+ Addedyeast@0.1.2(transitive)