-1

Problem

Hi, when a user submits a payment form on my site I need to populate two variables $comment1 and $comment2 with the values of other information the user supplied but I'm unsure how to accomplish this in Drupal so that those variables get sent to PayPal.

Example Scenario

So, for example, a user enters their name in the checkout form and their organization in another field. When the user submits the form to paypal for payment processing we want the $comment1 field to get their $organization value and for the $comment2 field to get their $fullname value.

We want these to be sent to PayPal along with all the other information that gets sent to PayPal because the PayPal manager can read and utilize values in variables called $comment1 and $comment2.

Question

My question is, what's the best way to accomplish this?

Assumption

I assume it involves hooking into and changing some code in a function in the contributed module somewhere. Any guidance is appreciated.

1

assuming you're using commerce_paypal WPS, you'll need to hook

HOOK_commerce_paypal_wps_order_form_data_alter(&$data, $order){}

in a custom module. there you can extend the $data array like

$data['on3'] = 'your_property_name';
$data['os3'] = 'your_property_value';
$data['on4'] = 'your_other_property_name';
$data['os4'] = 'your_other_property_value';

or exchange data like

$data['organization'] = $data['fullname'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.