Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions _define.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
name: 'Galette Helloasso', //Name
desc: 'Helloasso integration', //Short description
author: 'Guillaume AGNIERAY', //Author
version: '1.0.0', //Version
version: '1.1.0-dev', //Version
compver: '1.3.0', //Galette compatible version
route: 'helloasso', //Routing name and translation domain
date: '2026-01-10', //Release date
date: '2026-08-08', //Release date
acls: [ //Permissions needed
'helloasso_preferences' => 'staff',
'store_helloasso_preferences' => 'staff',
'helloasso_history' => 'staff',
'filter_helloasso_history' => 'staff'
],
dbver: 1.00 //DB version
dbver: 1.10 //DB version
);

$this->setCsrfExclusions(
Expand Down
12 changes: 12 additions & 0 deletions lib/GaletteHelloasso/Controllers/HelloassoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ public function logs(
string|int|null $value = null
): Response {
$helloasso_history = new HelloassoHistory($this->zdb, $this->login, $this->preferences);
if ($this->session->helloasso !== null) {
$helloasso = $this->session->helloasso;
$this->session->helloasso = null;
} else {
$helloasso = new Helloasso($this->zdb, $this->preferences);
}

$filters = [];
if (isset($this->session->filter_helloasso_history)) {
Expand Down Expand Up @@ -182,6 +188,7 @@ public function logs(
$params = [
'page_title' => _T("Helloasso History", "helloasso"),
'helloasso_history' => $helloasso_history,
'helloasso' => $helloasso,
'logs' => $logs,
'nb' => $logs_count,
'module_id' => $this->getModuleId()
Expand Down Expand Up @@ -267,6 +274,11 @@ public function storePreferences(Request $request, Response $response): Response
} else {
$helloasso->setTestMode(false);
}
if (array_key_exists('helloasso_sepa_option', $post)) {
$helloasso->setSepaOption(true);
} else {
$helloasso->setSepaOption(false);
}
if (isset($post['helloasso_organization_slug'])) {
$helloasso->setOrganizationSlug($post['helloasso_organization_slug']);
}
Expand Down
40 changes: 39 additions & 1 deletion lib/GaletteHelloasso/Helloasso.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Helloasso
/** @var array<int, array<string,mixed>> */
private array $prices;
private bool $test_mode;
private bool $sepa_option;
private ?string $organization_slug;
private ?string $client_id;
private ?string $client_secret;
Expand Down Expand Up @@ -74,6 +75,7 @@ public function __construct(Db $zdb, Preferences $preferences)
$this->prices = [];
$this->inactives = [];
$this->test_mode = false;
$this->sepa_option = false;
$this->organization_slug = null;
$this->client_id = null;
$this->client_secret = null;
Expand All @@ -95,6 +97,9 @@ public function load(): void
case 'helloasso_test_mode':
$this->test_mode = $row->val_pref === '1' ? true : false;
break;
case 'helloasso_sepa_option':
$this->sepa_option = $row->val_pref === '1' ? true : false;
break;
case 'helloasso_organization_slug':
$this->organization_slug = $row->val_pref;
break;
Expand Down Expand Up @@ -179,6 +184,21 @@ public function store(): bool

$this->zdb->execute($update);

//store SEPA transfers option
$values = [
'nom_pref' => 'helloasso_sepa_option',
'val_pref' => $this->sepa_option ? '1' : ''
];
$update = $this->zdb->update(HELLOASSO_PREFIX . self::TABLE);
$update->set($values)
->where(
[
'nom_pref' => 'helloasso_sepa_option'
]
);

$this->zdb->execute($update);

//store Helloasso organization slug
$values = [
'nom_pref' => 'helloasso_organization_slug',
Expand Down Expand Up @@ -340,7 +360,7 @@ public function checkout(array $metadata, float $amount, ?bool $contains_donatio
],
'metadata' => $metadata,
'paymentOptions' => [
'enableSepa' => false
'enableSepa' => $this->getSepaOption()
]
];

Expand Down Expand Up @@ -537,6 +557,14 @@ public function getTestMode(): bool
return $this->test_mode;
}

/**
* Get SEPA transfers option
*/
public function getSepaOption(): bool
{
return $this->sepa_option;
}

/**
* Get Helloasso organization slug
*/
Expand Down Expand Up @@ -618,6 +646,16 @@ public function setTestMode(bool $enabled): void
$this->test_mode = $enabled;
}

/**
* Set SEPA transfers option
*
* @param bool $enabled True to enable SEPA transfers option
*/
public function setSepaOption(bool $enabled): void
{
$this->sepa_option = $enabled;
}

/**
* Set Helloasso organization slug
*
Expand Down
1 change: 1 addition & 0 deletions scripts/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CREATE TABLE galette_helloasso_preferences (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_test_mode', '');
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_sepa_option', '');
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_organization_slug', '');
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_client_id', '');
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_client_secret', '');
Expand Down
1 change: 1 addition & 0 deletions scripts/pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CREATE TABLE galette_helloasso_preferences (
CREATE UNIQUE INDEX galette_helloasso_preferences_unique_idx ON galette_helloasso_preferences (nom_pref);

INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_test_mode', '');
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_sepa_option', '');
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_organization_slug', '');
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_client_id', '');
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_client_secret', '');
Expand Down
1 change: 1 addition & 0 deletions scripts/upgrade-to-1.1.0-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
--

UPDATE galette_helloasso_history SET state = 3 WHERE state = 0;
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_sepa_option', '');
1 change: 1 addition & 0 deletions scripts/upgrade-to-1.1.0-pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
--

UPDATE galette_helloasso_history SET state = 3 WHERE state = 0;
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_sepa_option', '');
7 changes: 7 additions & 0 deletions templates/default/helloasso_preferences.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
label: _T("Your clientSecret", "helloasso"),
required: true
} %}

{% include "components/forms/checkbox.html.twig" with {
id: 'helloasso_sepa_option',
value: '1',
checked: helloasso.getSepaOption() ? true : false,
label: _T("Accept SEPA transfers", "helloasso")
} %}
{% endif %}
{% if helloasso.isLoaded() and amounts|length > 0 %}
<table class="listing ui celled helloassod table">
Expand Down