Started stripe
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import stripe
|
||||
import json
|
||||
import logging
|
||||
from app.config import settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
stripe.api_key = settings.STRIPE_PRIV_KEY
|
||||
|
||||
class StripeIntegration:
|
||||
|
||||
def create_customer(self, data):
|
||||
customer = stripe.Customer.create(
|
||||
email="customer@example.com",
|
||||
description="Customer for subscription",
|
||||
payment_method="pm_card_visa", # Replace with a valid payment method ID or attach one later
|
||||
invoice_settings={"default_payment_method": "pm_card_visa"},
|
||||
)
|
||||
|
||||
def create_product(self, data):
|
||||
# Example of creating a Product and Price
|
||||
product = stripe.Product.create(name="Premium Plan")
|
||||
price = stripe.Price.create(
|
||||
unit_amount=1000, # Amount in cents (e.g., $10.00)
|
||||
currency="usd",
|
||||
recurring={"interval": "month"},
|
||||
product=product.id,
|
||||
)
|
||||
|
||||
def create_subscription(self, data):
|
||||
subscription = stripe.Subscription.create(
|
||||
customer='customer.id',
|
||||
items=[
|
||||
{"price": 'price.id'},
|
||||
],
|
||||
payment_behavior="default_incomplete", # Recommended for handling initial payment
|
||||
expand=["latest_invoice.payment_intent"], # To get details for payment confirmation
|
||||
)
|
||||
Reference in New Issue
Block a user