From 34260e89e47c0da2bb69489e71bb79d9065bc446 Mon Sep 17 00:00:00 2001 From: Guillaume AGNIERAY Date: Sat, 8 Aug 2026 15:13:08 +0200 Subject: [PATCH 1/2] Enable SEPA payment option --- lib/GaletteHelloasso/Helloasso.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/GaletteHelloasso/Helloasso.php b/lib/GaletteHelloasso/Helloasso.php index 79e86ba..7aaaf18 100644 --- a/lib/GaletteHelloasso/Helloasso.php +++ b/lib/GaletteHelloasso/Helloasso.php @@ -340,7 +340,7 @@ public function checkout(array $metadata, float $amount, ?bool $contains_donatio ], 'metadata' => $metadata, 'paymentOptions' => [ - 'enableSepa' => false + 'enableSepa' => true ] ]; From 6bb4762b9e26d75c866ad4d86d2607f94f1ddae1 Mon Sep 17 00:00:00 2001 From: Guillaume AGNIERAY Date: Thu, 13 Aug 2026 12:09:39 +0200 Subject: [PATCH 2/2] Add SEPA transfers option in the preferences --- _define.php | 6 +-- .../Controllers/HelloassoController.php | 12 ++++++ lib/GaletteHelloasso/Helloasso.php | 40 ++++++++++++++++++- scripts/mysql.sql | 1 + scripts/pgsql.sql | 1 + scripts/upgrade-to-1.1.0-mysql.sql | 1 + scripts/upgrade-to-1.1.0-pgsql.sql | 1 + .../default/helloasso_preferences.html.twig | 7 ++++ 8 files changed, 65 insertions(+), 4 deletions(-) diff --git a/_define.php b/_define.php index 1bf1112..7ea3cda 100644 --- a/_define.php +++ b/_define.php @@ -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( diff --git a/lib/GaletteHelloasso/Controllers/HelloassoController.php b/lib/GaletteHelloasso/Controllers/HelloassoController.php index d8f2950..d89047f 100644 --- a/lib/GaletteHelloasso/Controllers/HelloassoController.php +++ b/lib/GaletteHelloasso/Controllers/HelloassoController.php @@ -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)) { @@ -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() @@ -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']); } diff --git a/lib/GaletteHelloasso/Helloasso.php b/lib/GaletteHelloasso/Helloasso.php index 7aaaf18..54542c5 100644 --- a/lib/GaletteHelloasso/Helloasso.php +++ b/lib/GaletteHelloasso/Helloasso.php @@ -38,6 +38,7 @@ class Helloasso /** @var array> */ private array $prices; private bool $test_mode; + private bool $sepa_option; private ?string $organization_slug; private ?string $client_id; private ?string $client_secret; @@ -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; @@ -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; @@ -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', @@ -340,7 +360,7 @@ public function checkout(array $metadata, float $amount, ?bool $contains_donatio ], 'metadata' => $metadata, 'paymentOptions' => [ - 'enableSepa' => true + 'enableSepa' => $this->getSepaOption() ] ]; @@ -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 */ @@ -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 * diff --git a/scripts/mysql.sql b/scripts/mysql.sql index ddabf3c..1c0f57a 100644 --- a/scripts/mysql.sql +++ b/scripts/mysql.sql @@ -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', ''); diff --git a/scripts/pgsql.sql b/scripts/pgsql.sql index c6a0b2e..458ca2f 100644 --- a/scripts/pgsql.sql +++ b/scripts/pgsql.sql @@ -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', ''); diff --git a/scripts/upgrade-to-1.1.0-mysql.sql b/scripts/upgrade-to-1.1.0-mysql.sql index 41f7b36..3936250 100644 --- a/scripts/upgrade-to-1.1.0-mysql.sql +++ b/scripts/upgrade-to-1.1.0-mysql.sql @@ -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', ''); diff --git a/scripts/upgrade-to-1.1.0-pgsql.sql b/scripts/upgrade-to-1.1.0-pgsql.sql index 41f7b36..3936250 100644 --- a/scripts/upgrade-to-1.1.0-pgsql.sql +++ b/scripts/upgrade-to-1.1.0-pgsql.sql @@ -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', ''); diff --git a/templates/default/helloasso_preferences.html.twig b/templates/default/helloasso_preferences.html.twig index 8596008..5414201 100644 --- a/templates/default/helloasso_preferences.html.twig +++ b/templates/default/helloasso_preferences.html.twig @@ -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 %}