Skip to content

Commit 3701274

Browse files
authored
Add shared iDEAL payment method and reuse images (#251)
* Add shared iDEAL payment method and reuse images Introduce a single $payment_method_ideal instance with name, description and image paths and register it earlier in Plugin::init. Reuse its images for the direct-debit-ideal payment method instead of duplicating the image array, and remove the later duplicate iDEAL block. This deduplicates code and ensures consistent iDEAL/Wero branding assets while keeping existing behavior. * Consolidate iDEAL rebranding block Move the iDEAL logo rebranding conditional to immediately after creating $payment_method_ideal so the name/images are set before adding the payment method, and remove the duplicated block later in the file. This ensures the iDEAL branding (effective 2026-01-29) is applied once and avoids redundant assignments.
1 parent 21a46f3 commit 3701274

1 file changed

Lines changed: 31 additions & 33 deletions

File tree

src/Plugin.php

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,36 @@ public function register_payment_methods(): void {
829829

830830
$this->payment_methods->add( $payment_method_credit_card );
831831

832+
// Payment method iDEAL | Wero.
833+
$payment_method_ideal = new PaymentMethod( PaymentMethods::IDEAL );
834+
835+
$payment_method_ideal->descriptions = [
836+
'customer' => \__( 'With iDEAL you can easily pay online in the secure environment of your own bank.', 'pronamic_ideal' ),
837+
];
838+
839+
$payment_method_ideal->name = \__( 'iDEAL | Wero', 'pronamic_ideal' );
840+
841+
$payment_method_ideal->images = [
842+
'640x360' => $image_service->get_path( 'other/ideal-wero/ideal-wero-640x360.svg' ),
843+
'woocommerce' => $image_service->get_path( 'other/ideal-wero/method-ideal-wero-wc-51x32.svg' ),
844+
];
845+
846+
/**
847+
* The iDEAL logo rebranding takes effect on January 29, 2026.
848+
*
849+
* @link https://ideal.nl/en/ideal-wero-branding
850+
*/
851+
if ( \time() < \strtotime( '2026-01-29 00:00:00' ) ) {
852+
$payment_method_ideal->name = \__( 'iDEAL', 'pronamic_ideal' );
853+
854+
$payment_method_ideal->images = [
855+
'640x360' => $image_service->get_path( 'methods/ideal/method-ideal-640x360.svg' ),
856+
'woocommerce' => $image_service->get_path( 'methods/ideal/method-ideal-wc-51x32.svg' ),
857+
];
858+
}
859+
860+
$this->payment_methods->add( $payment_method_ideal );
861+
832862
// Direct debit.
833863
$payment_method_direct_debit = new PaymentMethod( PaymentMethods::DIRECT_DEBIT );
834864

@@ -861,9 +891,7 @@ public function register_payment_methods(): void {
861891
'customer' => \sprintf( $description_template, $payment_method_direct_debit_ideal->name ),
862892
];
863893

864-
$payment_method_direct_debit_ideal->images = [
865-
'woocommerce' => $image_service->get_path( 'methods/direct-debit-ideal/method-direct-debit-ideal-wc-107x32.svg' ),
866-
];
894+
$payment_method_direct_debit_ideal->images = $payment_method_ideal->images;
867895

868896
$this->payment_methods->add( $payment_method_direct_debit_ideal );
869897

@@ -903,36 +931,6 @@ public function register_payment_methods(): void {
903931

904932
$this->payment_methods->add( $payment_method_gift_card );
905933

906-
// IDEAL.
907-
$payment_method_ideal = new PaymentMethod( PaymentMethods::IDEAL );
908-
909-
$payment_method_ideal->descriptions = [
910-
'customer' => \__( 'With iDEAL you can easily pay online in the secure environment of your own bank.', 'pronamic_ideal' ),
911-
];
912-
913-
$payment_method_ideal->name = \__( 'iDEAL | Wero', 'pronamic_ideal' );
914-
915-
$payment_method_ideal->images = [
916-
'640x360' => $image_service->get_path( 'other/ideal-wero/ideal-wero-640x360.svg' ),
917-
'woocommerce' => $image_service->get_path( 'other/ideal-wero/method-ideal-wero-wc-51x32.svg' ),
918-
];
919-
920-
/**
921-
* The iDEAL logo rebranding takes effect on January 29, 2026.
922-
*
923-
* @link https://ideal.nl/en/ideal-wero-branding
924-
*/
925-
if ( \time() < \strtotime( '2026-01-29 00:00:00' ) ) {
926-
$payment_method_ideal->name = \__( 'iDEAL', 'pronamic_ideal' );
927-
928-
$payment_method_ideal->images = [
929-
'640x360' => $image_service->get_path( 'methods/ideal/method-ideal-640x360.svg' ),
930-
'woocommerce' => $image_service->get_path( 'methods/ideal/method-ideal-wc-51x32.svg' ),
931-
];
932-
}
933-
934-
$this->payment_methods->add( $payment_method_ideal );
935-
936934
// IDEAL QR.
937935
$payment_method_ideal_qr = new PaymentMethod( PaymentMethods::IDEALQR );
938936

0 commit comments

Comments
 (0)