|
|
|
|
@ -25,12 +25,13 @@ class StripeService: |
|
|
|
|
mode_str = "TEST" if self.is_test_mode else "LIVE" |
|
|
|
|
logger.debug(f"Initialized StripeService in {mode_str} mode") |
|
|
|
|
|
|
|
|
|
def create_checkout_session(self, line_items, success_url, cancel_url, metadata=None): |
|
|
|
|
def create_checkout_session(self, customer_email, line_items, success_url, cancel_url, metadata=None): |
|
|
|
|
"""Create a Stripe Checkout Session for one-time payments""" |
|
|
|
|
if self.is_test_mode: |
|
|
|
|
logger.info(f"Creating checkout session in TEST mode with metadata: {metadata}") |
|
|
|
|
|
|
|
|
|
session = stripe.checkout.Session.create( |
|
|
|
|
customer_email=customer_email, |
|
|
|
|
payment_method_types=['card'], |
|
|
|
|
line_items=line_items, |
|
|
|
|
mode='payment', |
|
|
|
|
@ -67,24 +68,3 @@ class StripeService: |
|
|
|
|
|
|
|
|
|
# Create a singleton instance for import and use throughout the app |
|
|
|
|
stripe_service = StripeService() |
|
|
|
|
|
|
|
|
|
# For backward compatibility, expose some functions directly |
|
|
|
|
def create_payment_intent(amount, currency=None, metadata=None): |
|
|
|
|
"""Legacy function for backward compatibility""" |
|
|
|
|
if currency is None: |
|
|
|
|
currency = stripe_service.currency |
|
|
|
|
|
|
|
|
|
return stripe.PaymentIntent.create( |
|
|
|
|
amount=amount, |
|
|
|
|
currency=currency, |
|
|
|
|
metadata=metadata or {}, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
def create_checkout_session(line_items, success_url, cancel_url, metadata=None): |
|
|
|
|
"""Legacy function for backward compatibility""" |
|
|
|
|
return stripe_service.create_checkout_session( |
|
|
|
|
line_items=line_items, |
|
|
|
|
success_url=success_url, |
|
|
|
|
cancel_url=cancel_url, |
|
|
|
|
metadata=metadata or {}, |
|
|
|
|
) |
|
|
|
|
|