Archive

Archive for March, 2019

Charge a Credit card using #Stripe and #Node

March 13, 2019 Leave a comment

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);
}
});
}
});

 

Advertisements
Categories: Uncategorized

Proxy testing script in #NodeJs

March 13, 2019 Leave a comment

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