diff --git a/server/config/settings/base.py b/server/config/settings/base.py index 0cbf3972..36740741 100644 --- a/server/config/settings/base.py +++ b/server/config/settings/base.py @@ -650,11 +650,11 @@ SENDGRID_API_KEY = env("IT_SENDGRID_API_KEY", default="") # Datatrans (payment) # See https://admin.sandbox.datatrans.com/MerchSecurAdmin.jsp) -DATATRANS_HMAC_KEY = env("DATATRANS_HMAC_KEY") +DATATRANS_HMAC_KEY = env("DATATRANS_HMAC_KEY", default="") # See https://admin.sandbox.datatrans.com/MenuDispatch.jsp?main=1&sub=4) # => echo -n "Username:Password" | base64 -DATATRANS_BASIC_AUTH_KEY = env("DATATRANS_BASIC_AUTH_KEY") +DATATRANS_BASIC_AUTH_KEY = env("DATATRANS_BASIC_AUTH_KEY", default="") if APP_ENVIRONMENT.startswith("prod"): DATATRANS_API_ENDPOINT = "https://api.datatrans.com" diff --git a/server/vbv_lernwelt/shop/views.py b/server/vbv_lernwelt/shop/views.py index 52751823..20488dec 100644 --- a/server/vbv_lernwelt/shop/views.py +++ b/server/vbv_lernwelt/shop/views.py @@ -114,9 +114,11 @@ def checkout_vv(request): # already initialized -> redirect to payment page again if checkout := checkouts.filter(state=CheckoutState.INITIALIZED).first(): - return JsonResponse( - {"next_step_url": get_payment_url(transaction_id=checkout.transaction_id)} - ) + # FIXME: Ask datatrans how they advice to handle this case: + # - 1. Why is the payment url not reusable? Calling the payment url again + # with the same transaction id results in a blank page. + # - 2. After 30 minutes, the transaction is fails but our webhook is not called? + return JsonResponse({"next_step_url": get_payment_url(checkout.transaction_id)}) # not yet initialized at all, or canceled/failed base_redirect_url = request.data["redirect_url"] @@ -143,9 +145,7 @@ def checkout_vv(request): **request.data["address"], ) - return JsonResponse( - {"next_step_url": get_payment_url(transaction_id=transaction_id)} - ) + return JsonResponse({"next_step_url": get_payment_url(transaction_id)}) def webhook_url(base_url: str) -> str: