Skip to content

Commit 9a52a9a

Browse files
add filter to allow hooking into transaction data before signing
1 parent 80465ea commit 9a52a9a

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

includes/abstracts/class-wc-banklink-ipizza.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ function generate_submit_form( $order_id ) {
239239
'VK_DATETIME' => $datetime->format( DateTime::ISO8601 )
240240
);
241241

242+
// Allow hooking into the data
243+
$mac_fields = $this->hookable_transaction_data( $mac_fields, $order );
244+
242245
// Generate MAC string from the private key
243246
$key = openssl_pkey_get_private( $this->get_option( 'vk_privkey' ), $this->get_option( 'vk_pass' ) );
244247
$signature = '';

includes/abstracts/class-wc-banklink-solo.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ function generate_submit_form( $order_id ) {
100100
'SOLOPMT_CUR' => get_woocommerce_currency(),
101101
);
102102

103+
// Allow hooking into the data
104+
$mac_fields = $this->hookable_transaction_data( $mac_fields, $order );
105+
103106
// Generate MAC string
104107
$mac_fields['SOLOPMT_MAC'] = $this->generate_mac_string( $mac_fields );
105108

includes/abstracts/class-wc-banklink.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,15 @@ function debug( $data, $level = 'debug' ) {
181181
}
182182
}
183183
}
184+
185+
/**
186+
* Creates a filter for altering transaction data
187+
*
188+
* @param array $data Transaction data
189+
* @param WC_Order $order Order
190+
* @return array Modified transaction data
191+
*/
192+
function hookable_transaction_data( $data, $order ) {
193+
return apply_filters( 'woocommerce_' . $this->id . '_gateway_transaction_fields', $data, $order );
194+
}
184195
}

includes/gateways/class-wc-banklink-estcard-gateway.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function generate_submit_form( $order_id ) {
8383
$lang_code = in_array( $lang, $accepted_lang_codes ) ? $lang : 'en';
8484

8585
// Set MAC fields
86-
$mac_fields = array(
86+
$mac_fields = array(
8787
'action' => 'gaf',
8888
'ver' => '004',
8989
'id' => $this->get_option( 'merchant_id' ),
@@ -98,6 +98,9 @@ function generate_submit_form( $order_id ) {
9898
'charEncoding' => 'utf-8'
9999
);
100100

101+
// Allow hooking into the data
102+
$mac_fields = $this->hookable_transaction_data( $mac_fields, $order );
103+
101104
$key = openssl_pkey_get_private( $this->get_option( 'private_key' ), $this->get_option( 'private_key_pass' ) );
102105
$signature = '';
103106
$mac_string = $this->generate_mac_string( $mac_fields );

includes/gateways/class-wc-banklink-maksekeskus-redirect-gateway.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ function generate_submit_form( $order_id ) {
9797
)
9898
);
9999

100+
// Allow hooking into the data
101+
$request = $this->hookable_transaction_data( $request, $order );
102+
100103
// Generate MAC code
101104
$mac_code = $this->get_signature( $request );
102105

0 commit comments

Comments
 (0)