Skip to content

Instantly share code, notes, and snippets.

@vanbo
Last active September 9, 2019 08:54
Show Gist options
  • Save vanbo/80a9c3a621265f3a119889878a1ef597 to your computer and use it in GitHub Desktop.
Save vanbo/80a9c3a621265f3a119889878a1ef597 to your computer and use it in GitHub Desktop.
WC Paysafe: Add account number based on order currency
// 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;
}
@pogpog
Copy link

pogpog commented Sep 8, 2019

This example appears to be assigning the return value to $request_params but then returns $params

@vanbo
Copy link
Author

vanbo commented Sep 9, 2019

Yes it was, good catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment