Created
September 22, 2017 20:55
-
-
Save ChaseWiseman/f64b955308606d4b6a9637c71cff9b9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Sets a unique Merchant ID depending on the order currency for Bambora transaction requests. | |
| * | |
| * @param array $request_data transaction request data | |
| * @param \WC_Order $order order object | |
| * @return array | |
| */ | |
| function sv_wc_bambora_set_currency_merchant_id( $request_data, $order ) { | |
| $wc_version = defined( 'WC_VERSION' ) && WC_VERSION ? WC_VERSION : null; | |
| $currency = ( $wc_version && version_compare( $wc_version, '3.0', '>=' ) ) ? $order->get_currency() : $order->get_order_currency(); | |
| switch ( $currency ) { | |
| case 'CAD': | |
| $request_data['merchant_id'] = 'CAD_Merchant_ID'; // Your CAD merchant ID here | |
| break; | |
| // repeat ^ for any other currencies that need their own Merchant ID | |
| } | |
| return $request_data; | |
| } | |
| add_filter( 'wc_beanstream_credit_card_legacy_request_data', 'sv_wc_bambora_set_currency_merchant_id', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment