Skip to content

Commit

Permalink
Add consumer bank account name and IBAN merge tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed May 27, 2024
1 parent 878dd88 commit 17e006f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ parameters:
- src/
- views/
scanDirectories:
- vendor/pronamic/gravityforms
- wp-content/plugins/gravityforms
12 changes: 11 additions & 1 deletion src/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down Expand Up @@ -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() {
Expand Down
19 changes: 18 additions & 1 deletion src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' );

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 17e006f

Please sign in to comment.