from paypalcheckoutsdk.core import PayPalHttpClient, SandboxEnvironment, LiveEnvironment from dbsettings.functions import getValue class PaypalAPI: def __init__(self, client_id=None, client_secret=None, mode=None): mode = SandboxEnvironment if (client_secret == "sandbox" or getValue("paypal.mode") == "sandbox") else LiveEnvironment environment = mode(client_id=(client_id or getValue("paypal.client_id")), client_secret=(client_secret or getValue("paypal.client_secret"))) self.client = PayPalHttpClient(environment)