Fixed e00007 error
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
import logging
|
||||
import authorizenet.apicontrollers as controllers
|
||||
from authorizenet import apicontractsv1
|
||||
from .. import crud, database, schemas
|
||||
from config import load_config
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Load Authorize.net credentials
|
||||
ApplicationConfig = load_config()
|
||||
API_LOGIN_ID = ApplicationConfig.API_LOGIN_ID
|
||||
@@ -60,7 +57,7 @@ def verify_customer_authorize_account(db: Session, customer_id: int) -> dict:
|
||||
# Enhanced profile validation - check multiple conditions for profile existence
|
||||
profile_valid = _is_profile_valid(response)
|
||||
if not profile_valid:
|
||||
logger.info(f"Profile {customer.auth_net_profile_id} for customer {customer_id} is invalid/not found. Nulling out in database.")
|
||||
print(f"Profile {customer.auth_net_profile_id} for customer {customer_id} is invalid/not found. Nulling out in database.")
|
||||
|
||||
# Profile not found or invalid - set auth_net_profile_id to NULL in database
|
||||
try:
|
||||
@@ -68,9 +65,9 @@ def verify_customer_authorize_account(db: Session, customer_id: int) -> dict:
|
||||
customer.auth_net_profile_id = None
|
||||
db.add(customer) # Mark for update
|
||||
db.commit() # Persist the change
|
||||
logger.info(f"Successfully nulled out auth_net_profile_id for customer {customer_id}")
|
||||
print(f"Successfully nulled out auth_net_profile_id for customer {customer_id}")
|
||||
except Exception as update_error:
|
||||
logger.error(f"Failed to update customer auth_net_profile_id to NULL: {update_error}")
|
||||
print(f"Failed to update customer auth_net_profile_id to NULL: {update_error}")
|
||||
db.rollback() # Rollback on error
|
||||
|
||||
return {
|
||||
@@ -99,7 +96,7 @@ def verify_customer_authorize_account(db: Session, customer_id: int) -> dict:
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error verifying customer authorize account for customer {customer_id}: {str(e)}")
|
||||
print(f"Error verifying customer authorize account for customer {customer_id}: {str(e)}")
|
||||
return {
|
||||
"profile_exists": False,
|
||||
"has_payment_methods": False,
|
||||
@@ -150,7 +147,7 @@ def _is_profile_valid(response) -> bool:
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error validating profile response: {str(e)}")
|
||||
print(f"Error validating profile response: {str(e)}")
|
||||
return False
|
||||
|
||||
|
||||
@@ -176,11 +173,12 @@ def _get_customer_profile(profile_id: str):
|
||||
)
|
||||
|
||||
controller = controllers.getCustomerProfileController(request)
|
||||
controller.setenvironment(constants.PRODUCTION)
|
||||
controller.execute()
|
||||
response = controller.getresponse()
|
||||
|
||||
return response
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting customer profile {profile_id}: {str(e)}")
|
||||
print(f"Error getting customer profile {profile_id}: {str(e)}")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user