Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've been toying around with checkout on the PayPal sandbox, and the billing information I enter doesn't show up pre-entered on PayPal when I'm redirected there. Is this something that's possible?
Thanku,
Diwant
Comments
Comment #1
qwales1 CreditAttribution: qwales1 commentedYes it is possible. PayPal WPS doesn't send that info by default. There may be a better way to do this, but you can populate the PayPal guest account form by doing something like this:
Use hook_commerce_paypal_wps_order_form_data_alter().
You will then need to fetch the customer shipping profile for the order using commerce_customer_profile_load().
Add the values you need from the shipping profile to the $data array. You can find the available names for the keys here.
Comment #2
diwant CreditAttribution: diwant commentedThanks qwales1. I'm going to try this now. Happy New Year!
Comment #3
diwant CreditAttribution: diwant commentedI found this hook and although I solved my problem a different way, qwales1 has a correct solution if this is your problem as well. Implement hook_commerce_paypal_wps_order_form_data_alter and modify the variables you get in that function to modify what is sent to Paypal.
Comment #4
farse CreditAttribution: farse commentedI'm a relative newb, and this worked like a charm! My code looks like this for anyone wondering:
Comment #5
stongo CreditAttribution: stongo commentedShould the code from comment #4 fill in the billing address if one clicks "New to Paypal?" on the paypal site?
I can verify in watchdog that $data is being altered correctly in hook_commerce_paypal_wps_order_form_data_alter() but it doesn't seem to do anything on the paypal site.
Comment #6
johannez CreditAttribution: johannez commentedThank you for the hook and API info. I had troubles with the address fields, because the state field was missing.
Comment #7
Jason Dean CreditAttribution: Jason Dean commentedThanks for the code snippet in #4. Works a treat :)
Comment #8
benjarlett CreditAttribution: benjarlett commentedSo where do I put the code in #4? I want this functionality too... and would be great if it was just part of the module.
Comment #9
agileadamI've got a hybrid solution from #1872804: Billing Address to PayPal and #1494586: Add the option to collect a shipping address at PayPal. It did not work until I added the no_shipping value of 0.
@benjarlett, this code would go in a custom module that you would create and enable. See https://drupal.org/node/1074360.
Comment #10
benjarlett CreditAttribution: benjarlett commentedthanks for the pointer.. I created a module with a .module with your code in, and a .info, and enabled it... but doesn't send
looking a bit further I realise I'm not collecting shipping info, I'm wondering now if there were shipping fields that I've deleted for this project (it was going to be a download only store, but things changed and now they want to ship things) that arent being sent cos they're not existing.
do I need to create another drupal install to help me work out what fields were there so I can recreate them?
or...
have I missed the collect shipping tickbox somewhere?
or..
can i modify this info to send the billing info as shipping info (as that'd be fine for my customer).
help much appreciated
Ben
Comment #11
agileadamHi Ben,
If you setup Drupal Commerce manually you probably didn't setup a shipping profile.
I'm not exactly sure what PayPal's policies are, but technically you can pass the billing information to PayPal (instead of shipping).
If you do want to introduce shipping into your site I believe you can achieve this by simply installing commerce_shipping. That'll create the customer profile if I recall correctly.
If your site is already setup for shipping maybe you did delete that customer profile type?
Comment #12
benjarlett CreditAttribution: benjarlett commentedso would this work to send billing address?
- my clients after a simple fix
Comment #13
agileadamI imagine that'd work, but don't have time to test. Have you tried it yet?
Don't forget to change the function name to match your module (heli » yourmodule).
Comment #14
ptmkenny CreditAttribution: ptmkenny commented#1301570: Send itemized shopping cart to PayPal WPS will fix this once it is committed
Comment #15
gebiss CreditAttribution: gebiss commentedI understand that the fix applies to Commerce PayPal 7.x-1.0. Is there a fix to version 7.x-2.3? The shipping address is still not passed to PayPal using WPS... or am I missing something?
Comment #16
imclean CreditAttribution: imclean commented@gebiss see this issue: #2239805: Provide a default billing address to Paypal during checkout
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commented@gebiss I have applied this fix in #9 to paypal_commerce_wps 7.x2-3 module and it works.
All I did was: Create a custom module with the code in #9, changing the word "heli" for the name of my custom module and omitting the closing php tag. Create a info file placed in the module folder with correct details. Turn on the module in Drupal.
Comment #18
imclean CreditAttribution: imclean commented@gebiss, sorry, I missed you were asking about the shipping address. See: #1494586: Add the option to collect a shipping address at PayPal