Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment