3
Answers
Vote up!
0
Vote down!

Default Billing Information on PayPal site using WPS

I'm looking for a way to default the Billing Information on the PayPal site when using PayPal WPS to process my payments in Drupal Commerce (v7). Currently, I have the Billing Information defaulted correctly on my Drupal site from the user profile so the customers do not have to enter it again during checkout (already entered when they registered), but do not want them to have to fill their Billing Information on the PayPal site once redirected during payment processing.

I have done this before when creating my own "home-grown" solution using the simple Pay Now button at PayPal by setting input form fields on the page that submits the form to PayPal.

<input name="first_name" type="hidden" value="frank" />

It would be a far better experience for users that do not have PayPal accounts to have this information defaulted on the "Pay with a debit or credit card" section of the PayPal page.

Thanks for any help!
Frank

Asked by: fnikola
on December 6, 2013

Comments

3 Answers

Vote up!
0
Vote down!

After a little more thorough review of the commerce_paypal_wps module I was able to successfully pass default billing information (name, address, email, etc) from my site to the PayPal site. This is helpful if some users may not already have a PayPal account nor want to create one. In this case when they select the "Pay with a debit or credit card" option on the PayPal payment page all their billing information is defaulted from my site as seen on the checkout/review pages so they do not have to enter it again.

The *commerce_paypal_wps_order_form* function in the commerce_paypal_wps.module creates a hook that you can use:

// Allow modules to alter parameters of the API request.
drupal_alter('commerce_paypal_wps_order_form_data', $data, $order);

In my *hook_commerce_paypal_wps_order_form_data_alter* function (in my custom module) I set the additional billing address fields as described by PayPal at https://developer.paypal.com/webapps/developer/docs/classic/paypal-payme... (in the "Sample HTML Code for Filling Out FORMs Automatically for Buyers" section).

function hook_commerce_paypal_wps_order_form_data_alter(&$data, $order) {
$profile = user_load($order->uid);
$data['first_name'] = $profile->field_first_name['und'][0]['value'];
$data['last_name'] = $profile->field_last_name['und'][0]['value'];
$data['address1'] = $profile->field_address_1['und'][0]['value'];
...
}
Thanks for an extensible commerce_paypal module and I hope this helps someone else.

Answer by: fnikola
Posted: Dec 13, 2013
Vote up!
0
Vote down!

After a little more thorough review of the commerce_paypal_wps module I was able to successfully pass default billing information (name, address, email, etc) from my site to the PayPal site. This is helpful if some users may not already have a PayPal account nor want to create one. In this case when they select the "Pay with a debit or credit card" option on the PayPal payment page all their billing information is defaulted from my site as seen on the checkout/review pages so they do not have to enter it again.

The *commerce_paypal_wps_order_form* function in the commerce_paypal_wps.module creates a hook that you can use:

// Allow modules to alter parameters of the API request.
drupal_alter('commerce_paypal_wps_order_form_data', $data, $order);

In my *hook_commerce_paypal_wps_order_form_data_alter* function (in my custom module) I set the additional billing address fields as described by PayPal at https://developer.paypal.com/webapps/developer/docs/classic/paypal-payme... (in the "Sample HTML Code for Filling Out FORMs Automatically for Buyers" section).

function hook_commerce_paypal_wps_order_form_data_alter(&$data, $order) {
  $profile = user_load($order->uid);
  $data['first_name'] = $profile->field_first_name['und'][0]['value'];
  $data['last_name'] = $profile->field_last_name['und'][0]['value'];
  $data['address1'] = $profile->field_address_1['und'][0]['value'];
  ...
}

Thanks for an extensible commerce_paypal module and I hope this helps someone else.

Answer by: fnikola
Posted: Jan 14, 2014