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; | |
} |
This example appears to be assigning the return value to $request_params
but then returns $params
Yes it was, good catch
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Guys,
Can I use this snippet to add extendedOptions ?
what am I doing wrong ?
`// Normal order
add_filter( 'wc_paysafe_request_params', 'prefix_add_account_number', 10, 2 );
/**
@param $params
@param WC_Order $order
@return mixed
*/
function prefix_add_account_number( $params, $order ) {
$account_number = True;
$request_params['extendedOptions'][] = array(
'key' => 'emailNotEditable',
'value' => 'true',
);
return $params;
}`