Last active
September 9, 2019 08:54
-
-
Save vanbo/80a9c3a621265f3a119889878a1ef597 to your computer and use it in GitHub Desktop.
WC Paysafe: Add account number based on order currency
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
// Normal order | |
add_filter( 'wc_paysafe_request_params', 'prefix_add_account_number', 10, 2 ); | |
// Subscriptions/Pre-Orders order | |
add_filter( 'wc_paysafe_addons_request_params', 'prefix_add_account_number', 10, 2 ); | |
/** | |
* @param $params | |
* @param WC_Order $order | |
* | |
* @return mixed | |
*/ | |
function prefix_add_account_number( $params, $order ) { | |
// Check the order currency and add the appropriate account number | |
if ( 'USD' == $order->get_currency() ) { | |
$account_number = '[USD_account_number_value]'; | |
} elseif ( 'CAD' == $order->get_currency() ) { | |
$account_number = '[CAD_account_number_value]'; | |
} else { | |
$account_number = '[GBP_account_number_value]'; | |
} | |
$params['extendedOptions'][] = array( | |
'key' => 'merchantAccount', | |
'value' => $account_number, | |
); | |
return $params; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes it was, good catch