@darkpos/payment
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -9,5 +9,3 @@ const model = require('./model'); | ||
if (data.message) client.ccToken = data.message; | ||
console.log('data.message =>', data.message); | ||
} catch (e) { | ||
// console.log("cardConenct listener => ", e.message); | ||
} | ||
@@ -14,0 +12,0 @@ }; |
@@ -64,3 +64,2 @@ // | ||
success(tokenResponse) { | ||
console.log(tokenResponse); | ||
if (fn) fn('success', tokenResponse.token); | ||
@@ -67,0 +66,0 @@ self.cayanClient.restore(); |
@@ -1,24 +0,50 @@ | ||
const importFile = require; | ||
// | ||
const connectors = { | ||
stripe: null, | ||
mxmerchant: null, | ||
square: null, | ||
bluepay: null, | ||
authorizeNet: null, | ||
cardConnect: null, | ||
cardKnox: null, | ||
cayan: null, | ||
payroc: null, | ||
payrocACH: null, | ||
darkGift: null, | ||
}; | ||
/** | ||
* Generate Connectors | ||
* | ||
* @returns | ||
*/ | ||
Object.keys(connectors).forEach(key => { | ||
connectors[key] = importFile(`./connectors/${key}`); | ||
}); | ||
let connectors; | ||
const getConnectors = async () => { | ||
try { | ||
const connectors = { | ||
stripe: null, | ||
mxmerchant: null, | ||
square: null, | ||
bluepay: null, | ||
authorizeNet: null, | ||
cardConnect: null, | ||
cardKnox: null, | ||
cayan: null, | ||
payroc: null, | ||
payrocACH: null, | ||
darkGift: null, | ||
}; | ||
const promises = Object.keys(connectors).map(async key => { | ||
const connector = await import(`./connectors/${key}`) | ||
return { | ||
key, | ||
connector | ||
} | ||
}) | ||
const connectorsArr = await Promise.all(promises) | ||
return connectorsArr.reduce((acc, { key, connector }) => { | ||
acc[key] = connector | ||
return acc | ||
}, {}) | ||
} catch (err) { | ||
console.log(`Error importing connector: ${err.message}`) | ||
} | ||
} | ||
// | ||
module.exports = class PaymentClient { | ||
init(config) { | ||
async init(config) { | ||
if (!connectors) | ||
connectors = await getConnectors(); | ||
const self = this; | ||
@@ -94,2 +120,3 @@ self.provider = config.script; | ||
) { | ||
if (!this.client.customerTokenCreate) throw new Error('Customer token is not supported!'); | ||
return new Promise((resolve, reject) => | ||
@@ -96,0 +123,0 @@ this.client.customerTokenCreate(customerToken, source, (status, data) => { |
@@ -18,3 +18,2 @@ const request = require('axios'); | ||
console.log(payload); | ||
request(payload) | ||
@@ -25,3 +24,2 @@ .then(res => { | ||
response = response.data || {}; | ||
console.log(response); | ||
if (status === 'error') throw new Error(response.message); | ||
@@ -28,0 +26,0 @@ |
{ | ||
"name": "@darkpos/payment", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Payment client", | ||
@@ -30,11 +30,11 @@ "author": "Dark POS", | ||
"devDependencies": { | ||
"eslint": "^4.19.1", | ||
"eslint-config-airbnb": "^16.1.0", | ||
"eslint-config-airbnb-base": "^12.1.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-import": "^2.12.0", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"prettier": "^1.13.5" | ||
"eslint": "^8.44.0", | ||
"eslint-config-airbnb": "^19.0.4", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"prettier": "^3.0.0" | ||
}, | ||
"gitHead": "bf3a7192dac5f4ba290e46546d9e17579ac83d74" | ||
"gitHead": "20c3625c9bf6f2fd8f81cecc722d635642c28cd2" | ||
} |
@@ -6,3 +6,3 @@ # @dark/payment | ||
``` | ||
$ npm i dark-payment | ||
$ yarn add @darkpos/payment | ||
``` | ||
@@ -12,3 +12,3 @@ | ||
``` | ||
import PaymentClient from 'dark-payment'; | ||
import PaymentClient from '@darkpos/payment'; | ||
const paymentClient = new PaymentClient(); | ||
@@ -15,0 +15,0 @@ |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
40416
1360
0