stripe client js create customer code example
Example 1: create a customer in stripe node.js
const stripe = require('stripe')('api_key');
stripe.customers.create({ email: 'email_address' }, (error, customer) => {
if (error) {
console.error(error);
} else {
console.log(customer);
}
});
Example 2: stripe customer subscription creation
Stripe.apiKey = "sk_test_51GxVwbJ4s7XuDwiBI9WcRYmSuSJihNlMtIaZNZv5G2UvFAdGbj5VHvhwhSODsF4xsd1jYOPqWlORLUMpXkiX4Hhf00PgGFcKqp";
List<Object> items = new ArrayList<>();
Map<String, Object> item1 = new HashMap<>();
item1.put(
"price",
"price_1GyXO4J4s7XuDwiBgZuarsP8"
);
items.add(item1);
Map<String, Object> params = new HashMap<>();
params.put("customer", "cus_HXPA4Dd7nRTM5W");
params.put("items", items);
Subscription subscription =
Subscription.create(params);