Archive

Archive for March, 2019

Charge a Credit card using #Stripe and #Node

stripe

Stripe makes it super-easy to charge a credit card, here is an example from the command line:

var stripe = require(‘stripe’)(‘sk_test_…..’);

stripe.tokens.create({
card: {
number: ‘4242424242424242’,
exp_month: 12,
exp_year: 2020,
cvc: ‘123’
}
}, function(err, token) {
if (err != null)
{
console.log(“err:” + err);
}
else
{
console.log(“tokenid:” + token.id);
stripe.charges.create({
amount: 2000,
currency: “usd”,
source: token.id,
description: “Charge for 4242424242424242”
}, function(err, charge) {
if (err != null)
{
console.log(“err:” + err);
}
else {
console.log(“charge:” + charge.id);
}
});
}
});

 

Categories: Uncategorized

Proxy testing script in #NodeJs

img_56f57e1899a0f

Not going to win any awards, but here is a little script in Node.js to test if a proxy is working or not

const request = require(‘request’);
request({
‘url’:’http://icanhazip.com’,
‘proxy’:process.argv[2]
}, function (error, response, body) {
console.log(‘error:’, error); // Print the error if one occurred
console.log(‘statusCode:’, response && response.statusCode); // Print the response status code if a response was received
console.log(‘ip:’, body); // Print the HTML for the Google homepage.
});

It requires npm install request 

and is run like node proxycheck.js <ProxyAddress>

Categories: Uncategorized