Move Billwerk URLs into global constants

Created on 24 November 2023, over 1 year ago

Problem/Motivation

These should be global constants instead, in a separate class:

  /**
   * Returns the remote service URL of the SaaS with an optional specific
   * service stub.
   *
   * @param string $service
   *   The additional uri part of the specific service endpoint stub.
   * @param string $system
   *   The additional uri part of the specific service endpoint stub.
   *
   * @return string
   *   The generated remote service url.
   */
  public function serviceUrl(string $service = '', string $system = 'main'): string {
    $url = $this->utils->config('service_url', 'sandbox');
    switch ($url) {
      case 'production':
        $urls = [
          // @todo: These should be global constants:
          'main' => 'https://app.billwerk.com/',
          'selfservice' => 'https://selfservice.billwerk.com/',
        ];
        break;

      case 'sandbox':
        $urls = [
          // @todo: These should be global constants:
          'main' => 'https://sandbox.billwerk.com/',
          'selfservice' => 'https://selfservice.sandbox.billwerk.com/',
        ];
        break;

      default:
        throw new \Exception('Unknown service_url "' . $url . '". Allowed values are "production" or "sandbox". Please check your subman.settings!');
    }

    if (!isset($urls[$system])) {
      throw new \Exception('Service URL could not be determined from URL: "' . $url . '", Service: "' . $service . '"' . ', System: "' . $system . '"');
    }

    return $urls[$system] . $service;
  }

BillwerkApi.php

Also we should watch out for other variables (or setting candidates: Add a settings page for general (non-security relevant) settings Closed: won't fix ) in code of Subman and Billwerk

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024