Problem
I need to use the following hook function to edit a similarly-named function in a contributed module (PayPal WPP), but I don't understand how to use it.
hook_commerce_paypal_api_request_alter(&$nvp, $order, $payment_method) { }
When this function is called I need to pass some variables to PayPal, based off user-supplied input in a form. By the time this function is called the user has already supplied their input in the form and clicked 'submit'. The form is now ready to send it's data to PayPal and this hook alters what is being sent.
So I need to figure out how to add additional data. Specifically I want to alter a variable $nvp['custom']. The main problem is I don't know how to get the values the user entered in the form into this function so I can pass them on.
I'm told I need to get the user-supplied values using $form_state['values']
but I have no idea how to get those inside this function, which isn't passed $form_state
as a parameter. I was hoping to do something like this:
$name = $form_state['values']['field_name'];
$organization = $form_state['values']['field_organization'];
$arr = array($name, $organization);
$allthedata = implode('+', $arr);
$nvp['CUSTOM'] = $allthedata;
As it may be obvious I don't even know how to refer correctly to the passed $form_state values, which is probably a large part of my problem.
Question
How do i get my user-supplied form values into this function so I can use them (and then pass them on to PayPal as part of the $nvp['custom'] variable?