From d9724ff07d825213fea2198b6bde7ac750d74879 Mon Sep 17 00:00:00 2001 From: kilian Date: Sun, 19 Oct 2025 22:20:54 +0200 Subject: [PATCH] more cleaning and added the url in API endpoint --- backend/src/payments/payment_handler.py | 12 ++++++++---- backend/src/payments/payment_router.py | 6 ++++-- backend/src/tests/test_trip_generation.py | 3 --- backend/src/tests/test_utils.py | 3 --- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/src/payments/payment_handler.py b/backend/src/payments/payment_handler.py index 79f22ed..0fe93d0 100644 --- a/backend/src/payments/payment_handler.py +++ b/backend/src/payments/payment_handler.py @@ -231,7 +231,12 @@ class PaypalClient: return access_token - def order(self, order_request: OrderRequest): + def order( + self, + order_request: OrderRequest, + return_url_success: str, + return_url_failure: str + ): """ Creates a new PayPal order. @@ -263,10 +268,9 @@ class PaypalClient: } } ], - # TODO: add these to anydev website 'application_context': { - 'return_url': 'https://anydev.info', - 'cancel_url': 'https://anydev.info' + 'return_url': return_url_success, + 'cancel_url': return_url_failure } } diff --git a/backend/src/payments/payment_router.py b/backend/src/payments/payment_router.py index cc42d60..048678c 100644 --- a/backend/src/payments/payment_router.py +++ b/backend/src/payments/payment_router.py @@ -23,7 +23,9 @@ logger = logging.getLogger(__name__) def create_order( user_id: str, basket: list, - currency: Literal['CHF', 'EUR', 'USD'] + currency: Literal['CHF', 'EUR', 'USD'], + return_url_success: str = 'https://anydev.info', + return_url_failure: str = 'https://anydev.info' ): """ Creates a new PayPal order. @@ -45,7 +47,7 @@ def create_order( ) # Process the order and return the details - return paypal_client.order(order_request = order) + return paypal_client.order(order_request=order, return_url_success=return_url_success, return_url_failure=return_url_failure) diff --git a/backend/src/tests/test_trip_generation.py b/backend/src/tests/test_trip_generation.py index 2b7814e..881f50f 100644 --- a/backend/src/tests/test_trip_generation.py +++ b/backend/src/tests/test_trip_generation.py @@ -1,14 +1,11 @@ """Collection of tests to ensure correct implementation and track progress.""" -import os import time -import yaml from fastapi.testclient import TestClient import pytest from .test_utils import load_trip_landmarks, log_trip_details from ..supabase.supabase import SupabaseClient from ..structs.preferences import Preferences, Preference -from ..constants import PARAMETERS_DIR from ..main import app diff --git a/backend/src/tests/test_utils.py b/backend/src/tests/test_utils.py index aeb45fd..a47fa6e 100644 --- a/backend/src/tests/test_utils.py +++ b/backend/src/tests/test_utils.py @@ -1,12 +1,9 @@ """Helper methods for testing.""" -import time import logging -from functools import wraps from fastapi import HTTPException from ..cache import client as cache_client from ..structs.landmark import Landmark -from ..structs.preferences import Preferences, Preference def landmarks_to_osmid(landmarks: list[Landmark]) -> list[int] :