Commit 47068c42 authored by Robert Kasza's avatar Robert Kasza Committed by Róbert Kasza
Browse files

Issue #3281082 by kaszarobert: Add possibility to use sandbox API

parent 44c876fd
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -83,6 +83,17 @@ class SettingsForm extends ConfigFormBase {
      '#description' => $this->t("Enter the specific identification for the issued invoices."),
      '#required' => FALSE,
    ];

    $form['environment'] = [
      '#type' => 'radios',
      '#title' => $this->t('Environment'),
      '#options' => [
        'sandbox' => $this->t('Sandbox'),
        'live' => $this->t('Live'),
      ],
      '#default_value' => $config->get('environment') ?? 'live',
    ];

    return parent::buildForm($form, $form_state);
  }

@@ -98,6 +109,7 @@ class SettingsForm extends ConfigFormBase {
      ->set('constant', $form_state->getValue('constant'))
      ->set('specific', $form_state->getValue('specific'))
      ->set('maturity', $form_state->getValue('maturity'))
      ->set('environment', $form_state->getValue('environment'))
      ->save();
    parent::submitForm($form, $form_state);
  }
+4 −0
Original line number Diff line number Diff line
@@ -216,6 +216,10 @@ class InvoiceService {
    $api = new \SFAPIclient($values['email'], $values['api_key'], '', 'API', $company_id);
    if ($api) {
      $this->logger->info('Succesfully created Superfaktura API object.');

      if ($config->get('environment') === 'sandbox') {
        $api->useSandBox();
      }
    }
    else {
      $this->logger->alert('Could not create the Superfaktura object');