xxxxxxxxxx
var stripe = require('stripe')('sk_test_FceQdct2QZpFfQZC4Wx9hGeo00ghaTeqAc');
stripe.subscriptions.create(
{
customer: 'cus_HKZRMeUnGPOb66',
items: [{price: 'gold'}],
},
function(err, subscription) {
// asynchronously called
}
);
xxxxxxxxxx
// Install the Stripe library using npm
npm install stripe
// Import the Stripe library
const stripe = require('stripe')('your_stripe_secret_key');
// Create a new customer
stripe.customers.create(
{ email: 'customer@example.com' },
function(err, customer) {
if (err) {
console.log('Error creating customer:', err);
} else {
console.log('Customer:', customer);
}
}
);
// Create a charge
stripe.charges.create(
{
amount: 2000,
currency: 'usd',
source: 'tok_visa',
description: 'Charge for customer@example.com'
},
function(err, charge) {
if (err) {
console.log('Error creating charge:', err);
} else {
console.log('Charge:', charge);
}
}
);
xxxxxxxxxx
const stripe = require('stripe')('api_key');
stripe.customers.create({ email: 'email_address' }, (error, customer) => {
if (error) {
console.error(error);
} else {
console.log(customer);
}
});