@weweb/backend-stripe
v1.1.3
Published
Stripe integration for WeWeb backend services
Readme
WeWeb Stripe Integration
This package provides a Stripe integration for WeWeb backend services, allowing you to easily integrate Stripe's payment processing capabilities into your WeWeb applications.
Features
- Payment processing with PaymentIntents
- Customer management
- Subscription handling
- Product and pricing management
- Refund processing
Installation
npm install @weweb/backend-stripeConfiguration
The integration can be configured either through environment variables or by passing options when creating the integration:
import { createStripeIntegration } from '@weweb/backend-stripe';
// Using environment variables
// Set STRIPE_SECRET_KEY in your environment
// OR using options
const stripeIntegration = createStripeIntegration({
secretKey: 'sk_your_secret_key',
apiVersion: '2023-10-16' // optional
});Environment Variables
STRIPE_SECRET_KEY: Your Stripe Secret Key (starts with 'sk_')
Usage Examples
Creating a Payment Intent
const paymentIntent = await stripe.methods.create_payment_intent({
amount: 2000, // Amount in cents
currency: 'usd',
payment_method_types: ['card']
});Creating a Customer
const customer = await stripe.methods.create_customer({
email: '[email protected]',
name: 'John Doe'
});Creating a Subscription
const subscription = await stripe.methods.create_subscription({
customer: 'cus_xxx',
items: [
{ price: 'price_xxx' }
]
});Creating a Product
const product = await stripe.methods.create_product({
name: 'Premium Plan',
description: 'Premium subscription plan'
});Available Methods
create_payment_intent: Create a new PaymentIntentget_payment_intent: Retrieve a PaymentIntentcreate_customer: Create a new customerget_customer: Retrieve a customerupdate_customer: Update a customercreate_subscription: Create a new subscriptionget_subscription: Retrieve a subscriptionupdate_subscription: Update a subscriptioncreate_product: Create a new productcreate_price: Create a new pricecreate_refund: Create a refundlist_customers: List customerslist_subscriptions: List subscriptionslist_products: List productslist_prices: List prices
Security
Never expose your Stripe secret key in client-side code. Always keep it secure and use it only in your backend services.
License
MIT
