Comparing version 0.1.0 to 0.1.2
@@ -1,24 +0,22 @@ | ||
var getKey = require('./scripts/getKey'); | ||
// var initialize = require('./scripts/initialize'); | ||
var tokenize = require('./scripts/tokenize'); | ||
var chargeCard = require('./scripts/chargeCard'); | ||
// var chargeEth = require('./scripts/chargeEth'); | ||
var chargeEth = require('./scripts/chargeEth'); | ||
var newToken = require('./scripts/newToken'); | ||
var getKey = require('./scripts/getKey'); | ||
module.exports = { | ||
getKey: function(email, password, callback) { | ||
getKey(email, password, callback); | ||
}, | ||
tokenize: function(key, secret, token, callback) { | ||
tokenize(key, secret, token, callback); | ||
}, | ||
chargeCard: function(key, secret, token, amount, callback) { | ||
chargeCard(key, secret, token, amount, callback); | ||
}, | ||
// chargeEth: function(key, secret, to, from, from_key, amount, callback) { | ||
// chargeEth(key, secret, to, from, from_key, amount, callback); | ||
// }, | ||
newToken: function(callback){ | ||
newToken(callback); | ||
module.exports = function(key, secret) { | ||
return { | ||
getKey: function(email, password, callback) { | ||
getKey(email, password, callback); | ||
}, | ||
tokenize: function(token, callback) { | ||
tokenize(key, secret, token, callback); | ||
}, | ||
chargeCard: function(token, amount, callback) { | ||
chargeCard(key, secret, token, amount, callback); | ||
}, | ||
newToken: function(callback){ | ||
newToken(callback); | ||
} | ||
} | ||
} | ||
} |
{ | ||
"name": "connext", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "Connext is a payment api for Ethereum applications", | ||
@@ -5,0 +5,0 @@ "main": "connext.js", |
@@ -6,19 +6,27 @@ # Connext | ||
`npm install connext` | ||
`npm install connext --save` | ||
Then require it in your js file | ||
Best practices: | ||
`var connext = require('connext');` | ||
1) Call Connext functions only from your client-side code. To ensure that you remain PCI compliant, credit card data must not directly touch your servers | ||
2) Construct your connext object in a separate connext.js file and export it. This will reduce the risk of key and secret information being leaked. | ||
``` | ||
//connext.js | ||
var Connext = require('connext'); | ||
var connext = new Connext(ApiKey, ApiSecret); | ||
module.exports = connext; | ||
``` | ||
## Reference | ||
### getKey() | ||
### getKey() [to be deprecated soon for security reasons] | ||
Inputs: email, password | ||
Outputs: key, secret | ||
Inputs: (email, password, [callback]) | ||
Outputs: (error, {key, secret}) | ||
Retrieves your key and secret if you already have an account. If you dont have an account, creates a new one and returns a key/secret. Outputs get returned into a callback. | ||
Retrieves your key and secret if you already have an account. Outputs get returned into a callback. | ||
_Note: We *dont* reccomend putting in a real password, auth details aren't being encrypted until they hit our api, do so at your own peril._ | ||
Usage: | ||
@@ -35,4 +43,4 @@ | ||
Inputs: | ||
Outputs: token object | ||
Inputs: ([callback]) | ||
Outputs: (error, token) | ||
@@ -43,4 +51,4 @@ Generates an empty token object to be filled out into a callback. You can ```console.log()``` it to find out what the possible data fields are. You should call this on your client side and fill out the data fields there so that no credit card info touches your servers. | ||
Inputs: key, secret, token | ||
Outputs: updated token object | ||
Inputs: (token, [callback]) | ||
Outputs: (error, updated_token) | ||
@@ -51,13 +59,13 @@ Sends the card info to connext servers and returns a token in a callback. The token is a redacted version of the information which is saveable on your servers without violating PCI compliancy. Like above, call only from the client side to make sure credit card info never touches your servers. | ||
Inputs: key, secret, token, amount | ||
Outputs: receipt | ||
Inputs: (token, amount, [callback]) | ||
Outputs: (error, receipt) | ||
Actually charges the card. The tokenization and charge process are separated to facilitate recurring payments or a second attempt at a payment if the payment fails. Returns a receipt object in the callback. For now, the receipt object only has a success field. | ||
Actually charges the card. *Amount must be written as payment(in dollars)x100*. Eg: $30.10 becomes 3010. The tokenization and charge process are separated to facilitate recurring payments or a second attempt at a payment if the payment fails. Returns a receipt object in the callback. For now, the receipt object only has a success field. | ||
### chargeEth() [COMING SOON] | ||
Inputs: key, secret, to, from, from_key, amount | ||
Outputs: 1st callback(transaction hash), 2nd callback(transaction receipt) | ||
Inputs: (key, secret, to, from, from_key, amount, [callback]) | ||
Outputs: 1st callback(error, transaction hash), 2nd callback(error, transaction receipt) | ||
Not deployed yet because of some minor ```eth.filter()``` issues. This will eventually be an easy to integrate "Pay with Eth" button that works with metamask out of the box! | ||
Not deployed yet. This will eventually be an easy to integrate "Pay with Eth" button that works with metamask out of the box! | ||
@@ -67,20 +75,29 @@ ## Example usage: | ||
``` | ||
connext.getKey("email", "password", function(results){ | ||
var key = results.key; | ||
var secret = results.secret; | ||
//connext.js | ||
var Connext = require('connext'); | ||
var connext = new Connext(ApiKey, ApiSecret); | ||
connext.newToken(function(token){ | ||
token.cardnumber = "123456789101112"; | ||
token.cvv = "123"; | ||
module.exports = connext; | ||
connext.tokenize(key, secret, token, function(token) { | ||
var amount = 100 | ||
console.log("key" + key) | ||
//index.js | ||
var connext = require('./path/to/connext.js'); | ||
connext.newToken(function(err, token){ | ||
if (err) return (err); | ||
//add payment info here from input fields | ||
//... | ||
//tokenize the card data | ||
connext.tokenize(token, function(err, updated_token) { | ||
if (err) return (err); | ||
//actually charge the card | ||
connext.chargeCard(updated_token, 101, function(err, receipt) { | ||
if (err) return (err); | ||
connext.chargeCard(key, secret, token, amount, function(receipt) { | ||
console.log(receipt); | ||
}) | ||
}); | ||
console.log(receipt); //logs "success" | ||
}) | ||
}) | ||
}) | ||
``` |
@@ -5,9 +5,14 @@ var request = require('request'); | ||
if(token.cvv === null) { | ||
if(!token || token.cvv == null) { | ||
console.log("Error: check card information"); | ||
return "error"; | ||
return callback({error: "check card information"}, null); | ||
} | ||
if(!amount) { | ||
console.log("Error: no amount entered"); | ||
return callback({error: "no amount entered"}, null); | ||
} | ||
var options = { | ||
url: 'http://api.connextapi.com/chargeCard/', | ||
url: 'http://api.connextapi.com:3000/chargeCard/', | ||
method: 'POST', | ||
@@ -17,8 +22,5 @@ json: true, | ||
"token": token, | ||
"amount": amount, | ||
"key": key, | ||
"secret": secret, | ||
"amount": amount | ||
}, | ||
headers: { | ||
'Authentication': secret | ||
"secret": secret | ||
} | ||
@@ -30,4 +32,4 @@ }; | ||
console.log(body) | ||
callback(body.receipt); | ||
} else callback(error); | ||
callback(error, body); | ||
} else callback(error, null); | ||
}) | ||
@@ -34,0 +36,0 @@ } |
@@ -1,15 +0,21 @@ | ||
var request = require('request'); | ||
var request = require('request'); | ||
var getKey = function(email, password, callback) { | ||
if(!email){ | ||
console.log("Error: no email provided"); | ||
return callback({error: "no email provided"}, null); | ||
} | ||
if(!password){ | ||
console.log("Error: no password provided"); | ||
return callback({error: "no password provided"}, null); | ||
} | ||
var options = { | ||
url: 'http://api.connextapi.com/getKey/', | ||
url: 'http://api.connextapi.com:3000/getKey/', | ||
json: true, | ||
qs: { | ||
email: email, | ||
password: password | ||
}, | ||
headers: { | ||
'Authentication': password | ||
body: { | ||
"key": email, | ||
"secret": password | ||
} | ||
@@ -20,4 +26,4 @@ }; | ||
if (!error && response.statusCode == 200) { | ||
callback(body); | ||
} else console.log(error); | ||
callback(error, body); | ||
} else console.log(error, null); | ||
}); | ||
@@ -24,0 +30,0 @@ |
@@ -18,5 +18,5 @@ var newToken = function(callback) { | ||
callback(token); | ||
callback(null, token); | ||
} | ||
module.exports = newToken; |
@@ -5,4 +5,9 @@ var request = require('request'); | ||
if(!token){ | ||
console.log("Error: no token provided"); | ||
return callback({error: "no token provided"}, null) | ||
} | ||
var options = { | ||
url: 'http://api.connextapi.com/tokenize/', | ||
url: 'http://api.connextapi.com:3000/tokenize/', | ||
method: 'POST', | ||
@@ -14,5 +19,2 @@ json: true, | ||
"secret": secret | ||
}, | ||
headers: { | ||
'Authentication': secret | ||
} | ||
@@ -22,7 +24,5 @@ }; | ||
request(options, function(error, response, body) { | ||
token = body.token; | ||
if(!error && response.statusCode == 200) { | ||
token.cardnumber = "****************"; | ||
callback(token); | ||
} else console.log(error); | ||
callback(error, body); | ||
} else console.log(error, null); | ||
}) | ||
@@ -29,0 +29,0 @@ } |
@@ -6,11 +6,6 @@ var request = require('request'); | ||
var options = { | ||
url: 'http://api.connextapi.com/validateKey/', | ||
url: 'http://api.connextapi.com:3000/validateKey/', | ||
method: 'POST', | ||
json: true, | ||
body: { | ||
"key": key, | ||
"secret": secret | ||
}, | ||
headers: { | ||
'Authentication': secret | ||
} | ||
@@ -17,0 +12,0 @@ }; |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
10420
99
11
164