lundi 28 décembre 2020

PayPal's JavaScript API is forcing “Shipping same as billing address”?

Sandbox

First be advised there is a testing sandbox provided by PayPal for you to try these code samples.

What I have tried

return actions.order.create({
  purchase_units: [{
    amount: { value: '88.44' },
    shipping: {
      name: { full_name: 'Ship Name' },
      address: {
        address_line_1: 'Ship Address',
        address_line_2: '',
        admin_area_2: 'Ship City',
        admin_area_1: 'SC',
        postal_code: 'SHP ZIP',
        country_code: 'US',
      },
    }
  }],
  payer: {
    name: { given_name: 'Bill', surname: 'Name' },
    address: {
      address_line_1: 'Bill Address',
      address_line_2: '',
      admin_area_2: 'Bill City',
      admin_area_1: 'MS',
      postal_code: 'BIL 0H0',
      country_code: 'US',
    }
  },
})

Reproducing the issue

Click the PayPal checkout button

Then, in the popup, click Pay with Credit or Debit Card

You will notice the correct billing option is present. Billing Address is Bill Name/Address

However, the Shipping Address is hidden behind the checkbox. Shipping same as billing address

This could lead to the user accidentally shipping the product to the wrong address!

How can I fix this?

That checkbox should ideally be unchecked because we are clearly passing a different address in the source code above.

As a side note

If the user does uncheck the box, they do get the correct address.




Aucun commentaire:

Enregistrer un commentaire