Skip to content

Commit

Permalink
Merge pull request #17 from plentific/lmonari/test_fix_pipeline
Browse files Browse the repository at this point in the history
lmonari/ATA2-832 Restored previous logic with improved URLs
  • Loading branch information
lmonari authored Mar 1, 2023
2 parents c6aeaa7 + 51444f8 commit db85b63
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions mangopay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,36 @@
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/'

# This logic will affect the URL used by this SDK only!
# On payments service we have similar settings (settings/mangopay.py) that applies
# to the MangopayAPIClient instead
PLENTIFIC_NAMESPACE = os.getenv("PLENTIFIC_NAMESPACE", "uk")
PLENTIFIC_IS_E2E = env_to_bool("PLENTIFIC_IS_E2E", False)
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 db85b63

Please sign in to comment.