woocommerce / woocommerce-gateway-paypal-express-checkout

58 stars 65 forks source link

Confusing creditcard billing/shipping address #749

Open FritzHerbers opened 4 years ago

FritzHerbers commented 4 years ago

Describe the bug

Version 2.0.1 We have WooCommerce "Shipping Options / Shipping Destination" set to "Force shipping to the customer billing address". The customer only fills out the billing address. We only ship to this address. When the customer selects to use PayPal and clicks the "Debit and Credit Card" options, the billing address is empty. Shipped to "Billing Address" is ticked, unticking it, it shows the billing address information from the Cart.

Expected behavior

It would be great when in the "Debit and Credit Card" section no shipping address is visible. Also, the Carts billing address should/could be copied to the billing address section.

As what I see on many online stores, for credit card information they use only the Cardnumber, Expires, CSC and sometimes a cardholders name. I never saw that a whole address and phone number has to be entered. On the credit card itself there are only the 4 above mentioned data items, asking more doesn't make sense.

The current implementation is very confusing, also in our reduced setup. When shops allowing a different Cart shipping address, then they end up with 4 addresses (2x Cart, 2x Credit Card section). Which one will be used is unclear.

As the (visuell) behavior changed, it would be nice to have a release note, explaining the changes.

Environment (please complete the following information):

FritzHerbers commented 4 years ago

We had a second look at the issue. What we haven't noticed is that this behavior also exists on 1.6.21. We also haven't noticed that the credit card information form is shown below the icons and that no PayPal screen opens anymore.

An explanation of such changes would be nice to have in the change log or a reference to some release notes or a "What's new" section. https://docs.woocommerce.com/document/paypal-express-checkout/ Some screenshots are updated, some still show the old icons. From this document no new behavior is described or visualized.

We found the following support request: https://wordpress.org/support/topic/billing-address-required-something-went-wrong/

On 1.6.21 we can produce the same effect, that on pressing around on the credit card icons, the error “something went wrong. we’ll take you back to checkout so you can try again" comes and PayPal opens:

https://imgur.com/PJghtRs

On the PayPal page no shipping information is asked.

Why is a shipping checkbox available when the form opens below the black credit card icon? Also, why is the billing information not copied to the credit card billing information?

FritzHerbers commented 4 years ago

https://wordpress.org/support/topic/redirect-to-cart-after-closing-paypal-checkout-popup/ Did a checkout on the website in the issue, and noticed that the credit card fields only show some fields:

20200530_paypal_creditcard

Why are only some fields shown, and not like ours:

20200530_paypal_creditcard-1

On what does it depend, which fields are shown? The Italian site credit card form would be OK for us, how/what do we have to configure?

dsmithweb commented 4 years ago

Just to further describe this behavior: If "Require Billing Address" is set on the merchant's PayPal account, then at checkout when the customer fills in the Billing Address area within WooCommerce checkout, then clicks the "Credit/Debit" button, the resultant windowshade dropdown auto-enters the Woo Checkout area's Billing Address into the Shipping Address area of the PayPal dropdown, leaving the Billing Address of the dropdown blank.

BenceSzalai commented 3 years ago

Hi! I'm apparently facing a related issue, although under somewhat simpler circumstances. I've asked about it on wordpress.org support forum and got redirected here, so I'll share my findings here.

(Un)fortunately I had another (unrelated) issue where shipping costs were not added to the PayPal total, and while debugging that I've took a deeper dive into how this payment plugin works.

Apparently it uses the NVP API to send the payment details to PayPal. When the payment process is initiated the SetExpressCheckout method is called to provide PayPal with the details for the purchase and payment. This includes API user and password, settings, the price of the cart, and the shipping address. This can be seen as well in the logs under wp-content/uploads/wc-logs/wc_gateway_ppec-*.log files, once Debug Log is enabled under settings.

Long story short, the thing is - as far as I can see - the NVP API does not have a way to provide the Billing Address. The SetExpressCheckout only has shipping fields, but I've been browsing through the other methods as well and found no reference to billing address or any details to be used for the billing fields.

When the Debit/Credit card form is loaded, the details sent by the WordPress server in the background are coming back to the browser. Look for a request starting with https://www.paypal.com/smart/card-fields?... in the network inspector in your browser. The response to this request contains the information used to initialise the payment form. If you look at the definition of the window.__INITIAL_STATE__ object, it contains an initialFormValues object, and that contains a billingAddress object, which to no surprise for me looks like this:

{"line1":null,"line2":null,"city":null,"state":null,"country":null,"postalCode":null,"isFullAddress":false,"lastName":null,"firstName":null}

So right now I think the situation is this:

Any other differences in our experience with the billing fileds must be down to other reasons, e.g. (only speculating):

So I think as long as the whole payment process is built around an API without explicit support to provide the Billing details it is not really an issue with the implementation of WooCommerce PayPal Checkout Payment Gateway, even though it could in theory use a different API, which would allow the handling of the Billing details, but after all that would be a substantial rework of the plugin, not really just a few fixes here and there.

For example there is another one, the REST API for PayPal, which apparently supports sending the billing address. See the Create order method, which allows to pass a Payer object, which in turn contains an Address object, which according to the linked docs:

Also referred to as the billing address of the customer.

This is the API referenced in the walkthrough to set up Paypal Checkout in general, while the NVP/SOAP API is marked as deprecated since 2017, even though the deprecation may only refer to the client side (JS) usage...

donmarkon commented 3 years ago

Any update regarding this?

tcivie commented 2 years ago

Having the same issue, Any updates on this? The shipping information is passed when using the PayPal gold button but not when using the "Debit or Credit Card" option.

ntrpnr commented 2 years ago

I'm facing the same issue as @tcivie Edit: The shipping info is passed if a user is logged in to WP

ifnull commented 2 years ago

It probably doesn't matter at this point because this plugin appears to be end-of-life, but I think this is similar to an issue my team encountered. The solution was to apply a filter to woocommerce_paypal_express_checkout_request_body to remove PAYMENTREQUEST_0_SHIPTO* params when NOSHIPPING is present.

add_filter('woocommerce_paypal_express_checkout_request_body', array($this, 'correct_paypal_params_for_no_shipping'), 9999, 1);

public function correct_paypal_params_for_no_shipping($params){
    if (array_key_exists('NOSHIPPING', $params) && 1 == $params['NOSHIPPING']){
        $params = array_filter($params, function($key){
            return !(0 === strpos($key, 'PAYMENTREQUEST_0_SHIPTO'));
        }, ARRAY_FILTER_USE_KEY);
    }
    return $params;
}

Related ticket: https://github.com/woocommerce/woocommerce-gateway-paypal-express-checkout/issues/878