From 17e006f7b89a1c9fea6cffe7e8ba8ff195de7989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=C3=BCel=20van=20der=20Steege?= Date: Mon, 27 May 2024 17:00:34 +0200 Subject: [PATCH] Add consumer bank account name and IBAN merge tags. --- phpstan.neon.dist | 2 +- src/Admin.php | 12 +++++++++++- src/Extension.php | 19 ++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8d5aa2a..4211441 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,4 +4,4 @@ parameters: - src/ - views/ scanDirectories: - - vendor/pronamic/gravityforms + - wp-content/plugins/gravityforms diff --git a/src/Admin.php b/src/Admin.php index 5a2c7fe..ca594b3 100644 --- a/src/Admin.php +++ b/src/Admin.php @@ -167,6 +167,16 @@ public static function custom_merge_tags( $merge_tags ) { 'tag' => '{pronamic_payment_bank_transfer_recipient_account_number}', ]; + $merge_tags[] = [ + 'label' => __( 'Pronamic consumer bank account name', 'pronamic_ideal' ), + 'tag' => '{pronamic_payment_consumer_bank_account_name}', + ]; + + $merge_tags[] = [ + 'label' => __( 'Pronamic consumer IBAN', 'pronamic_ideal' ), + 'tag' => '{pronamic_payment_consumer_iban}', + ]; + // Subscription. $merge_tags[] = [ 'label' => __( 'Pronamic Subscription ID', 'pronamic_ideal' ), @@ -203,7 +213,7 @@ public static function custom_merge_tags( $merge_tags ) { /** * Maybe redirect to Gravity Forms entry. - * + * * @return void */ public static function maybe_redirect_to_entry() { diff --git a/src/Extension.php b/src/Extension.php index d416c7a..d8753bd 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -1205,7 +1205,7 @@ public function replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html /** * Bank transfer recipient details. - * + * * Use bank transfer details from last subscription payment if available. */ $payment = null; @@ -1247,6 +1247,21 @@ public function replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html } } + /** + * Consumer bank account details. + */ + $consumer_bank_account_name = ''; + $consumer_iban = ''; + + if ( null !== $payment ) { + $consumer_bank_details = $payment->get_consumer_bank_details(); + + if ( null !== $consumer_bank_details ) { + $consumer_bank_account_name = \strval( $consumer_bank_details->get_name() ); + $consumer_iban = \strval( $consumer_bank_details->get_iban() ); + } + } + // Pay again URL. $pay_again_url = \rgar( $entry, 'source_url' ); @@ -1276,6 +1291,8 @@ public function replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html '{pronamic_payment_bank_transfer_recipient_city}' => $bank_transfer_recipient_city, '{pronamic_payment_bank_transfer_recipient_country}' => $bank_transfer_recipient_country, '{pronamic_payment_bank_transfer_recipient_account_number}' => $bank_transfer_recipient_account_number, + '{pronamic_payment_consumer_bank_account_name}' => $consumer_bank_account_name, + '{pronamic_payment_consumer_iban}' => $consumer_iban, '{pronamic_subscription_id}' => $subscription_id, '{pronamic_subscription_payment_id}' => $subscription_payment_id, '{pronamic_subscription_amount}' => $subscription_amount,