diff --git a/Dockerfile.local b/Dockerfile.local index a9e93e0..a1c00e6 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -1,14 +1,23 @@ FROM python:3.9 ENV PYTHONFAULTHANDLER=1 - ENV PYTHONUNBUFFERED=1 - ENV MODE="LOCAL" + WORKDIR /app +# Install Chrony (modern NTP implementation) +RUN apt-get update && apt-get install -y chrony + +# Configure Chrony NTP servers +RUN echo "server time.nist.gov iburst" >> /etc/chrony/chrony.conf +RUN echo "server pool.ntp.org iburst" >> /etc/chrony/chrony.conf + +# Copy and install Python dependencies COPY requirements.txt requirements.txt RUN pip install -r requirements.txt +# Copy source code COPY . . -CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file +# Start Chrony service and then run the application +CMD chronyd -d && uvicorn app.main:app --host 0.0.0.0 --port 8000 diff --git a/app/services/payment_service.py b/app/services/payment_service.py index bc8072e..3fa44b0 100644 --- a/app/services/payment_service.py +++ b/app/services/payment_service.py @@ -135,7 +135,11 @@ def create_customer_profile(customer: schemas.Customer, card_info: schemas.CardC else: controller.execute() response = controller.getresponse() - + + # Check if response is None (API call failed) + if response is None: + print("ERROR: Authorize.net API call returned None - likely a network/connectivity issue") + raise ValueError("Could not connect to the payment gateway. Please check network connectivity.") try: if response.messages.resultCode == "Ok": @@ -389,6 +393,12 @@ def add_payment_profile_to_customer(customer_profile_id: str, customer: schemas. controller.execute() response = controller.getresponse() + + # Check if response is None (API call failed) + if response is None: + print("ERROR: Authorize.net API call returned None - likely a network/connectivity issue") + raise ValueError("Could not connect to the payment gateway. Please check network connectivity.") + if response.messages.resultCode == "Ok": # Fix: Proper payment profile ID extraction (same bug fix as above) if hasattr(response, 'customerPaymentProfileId') and response.customerPaymentProfileId: @@ -440,6 +450,11 @@ def get_customer_payment_profiles(customer_profile_id: str): response = controller.getresponse() + # Check if response is None (API call failed) + if response is None: + print("ERROR: Authorize.net API call returned None - likely a network/connectivity issue") + raise ValueError("Could not connect to the payment gateway. Please check network connectivity.") + if response.messages.resultCode == "Ok": payment_profile_ids = [] if response.profile.paymentProfiles is not None: