Migrate to global currency system in commerce app
Removed per-product currency in favor of a global site currency managed via SiteConfiguration. Updated models, views, templates, and Stripe integration to use the global currency. Added migration, management command for migration, and API endpoint for currency info. Improved permissions and filtering for orders, reviews, and carts. Expanded supported currencies in configuration.
This commit is contained in:
12
backend/thirdparty/stripe/client.py
vendored
12
backend/thirdparty/stripe/client.py
vendored
@@ -20,7 +20,11 @@ class StripeClient:
|
||||
Returns:
|
||||
stripe.checkout.Session: Vytvořená Stripe Checkout Session.
|
||||
"""
|
||||
|
||||
from configuration.models import SiteConfiguration
|
||||
|
||||
# Use order currency or fall back to site configuration
|
||||
currency = order.get_currency().lower()
|
||||
|
||||
session = stripe.checkout.Session.create(
|
||||
mode="payment",
|
||||
payment_method_types=["card"],
|
||||
@@ -31,11 +35,11 @@ class StripeClient:
|
||||
client_reference_id=str(order.id),
|
||||
line_items=[{
|
||||
"price_data": {
|
||||
"currency": "czk",
|
||||
"currency": currency,
|
||||
"product_data": {
|
||||
"name": f"Objednávka {order.id}",
|
||||
"name": f"Order #{order.id}",
|
||||
},
|
||||
"unit_amount": int(order.total_price * 100), # cena v haléřích
|
||||
"unit_amount": int(order.total_price * 100), # amount in smallest currency unit
|
||||
},
|
||||
"quantity": 1,
|
||||
}],
|
||||
|
||||
Reference in New Issue
Block a user