Skip to content

Commit

Permalink
Restored previous logic with improved URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
lmonari committed Mar 1, 2023
1 parent c6aeaa7 commit 597ecd7
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions mangopay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,38 @@
client_id = None
apikey = None

PLENTIFIC_NAMESPACE = os.getenv("PLENTIFIC_NAMESPACE", "uk")
PLENTIFIC_IS_E2E = env_to_bool("PLENTIFIC_IS_E2E", False)

MANGOPAY_URL = os.getenv("MANGOPAY_URL", "https://api.mangopay.com")
MANGOPAY_SANDBOX_URL = os.getenv("MANGOPAY_URL", "https://api.sandbox.mangopay.com")

api_url = f'{MANGOPAY_URL}/v2.01/'
api_sandbox_url = f'{MANGOPAY_SANDBOX_URL}/v2.01/'
MANGOPAY_DEFAULT_LOCAL_MOCK_SERVER_URL = f"http://localhost:1081/mock-server/{PLENTIFIC_NAMESPACE}/mangopay"
MANGOPAY_DEFAULT_E2E_MOCK_SERVER_URL = "http://mock-server:1081/mangopay"
MANGOPAY_IS_MOCK_SERVER_ENABLED = env_to_bool("MANGOPAY_IS_MOCK_SERVER_ENABLED", False)

MANGOPAY_MOCK_SERVER_URL = os.environ.get(
"MANGOPAY_MOCK_SERVER_URL",
MANGOPAY_DEFAULT_E2E_MOCK_SERVER_URL
if PLENTIFIC_IS_E2E
else MANGOPAY_DEFAULT_LOCAL_MOCK_SERVER_URL,
)


def _get_api_url():
if MANGOPAY_IS_MOCK_SERVER_ENABLED:
return MANGOPAY_MOCK_SERVER_URL
return MANGOPAY_URL


def _get_sandbox_url():
if MANGOPAY_IS_MOCK_SERVER_ENABLED:
return MANGOPAY_MOCK_SERVER_URL
return MANGOPAY_SANDBOX_URL


api_url = f'{_get_api_url()}/v2.01/'
api_sandbox_url = f'{_get_sandbox_url()}/v2.01/'
temp_dir = None
api_version = 2.01
sandbox = True
Expand Down

0 comments on commit 597ecd7

Please sign in to comment.