Configure PayPal integration and cart checkout error display

This commit is contained in:
Zach committed 2026-12-01 04:20:38 +00:00
1 parent 62065828e1
commit cf07fc5d9b
98 files changed
+1430 -281

No files matched your search

+7 -5
View File
@@ -9,11 +9,12 @@ from django.utils import timezone
import stripe
from catalog.paypal import CheckoutError, access_token, checkout_origin, request_json, safe_approval_url
from catalog.shop_stripe import origin as stripe_origin
from .models import Order, Product, Subscription
def stripe_ready():
return bool(settings.SLX_STRIPE_SECRET_KEY and checkout_origin())
return bool(settings.SLX_STRIPE_SECRET_KEY and (stripe_origin() or checkout_origin()))
def paypal_ready():
@@ -23,7 +24,7 @@ def paypal_ready():
and checkout_origin())
def fulfill_order(order, payment_id=''):
def fulfill_order(order, payment_id='', stripe_live=None):
with transaction.atomic():
order = Order.objects.select_for_update().get(pk=order.pk)
if order.status != Order.Status.PENDING:
@@ -32,7 +33,8 @@ def fulfill_order(order, payment_id=''):
order.paid_at = timezone.now()
if payment_id:
order.gateway_payment_id = payment_id[:200]
order.save(update_fields=['status', 'paid_at', 'gateway_payment_id'])
order.stripe_live = stripe_live
order.save(update_fields=['status', 'paid_at', 'gateway_payment_id', 'stripe_live'])
for item in order.items.select_related('product'):
prod = item.product
@@ -47,7 +49,7 @@ def fulfill_order(order, payment_id=''):
def create_stripe_order_session(order):
stripe.api_key = settings.SLX_STRIPE_SECRET_KEY
origin = checkout_origin()
origin = stripe_origin() or checkout_origin()
line_items = []
for item in order.items.select_related('product'):
line_items.append({
@@ -88,7 +90,7 @@ def create_stripe_order_session(order):
def create_stripe_subscription_session(sub):
stripe.api_key = settings.SLX_STRIPE_SECRET_KEY
origin = checkout_origin()
origin = stripe_origin() or checkout_origin()
prod = sub.product
if prod.stripe_price_id:
line_item = {'price': prod.stripe_price_id, 'quantity': 1}