user2921885
user2921885

Reputation: 189

Disable shipping address with react-paypal-js

Hi I am using this module to integrate the Paypal solution in my site: https://www.npmjs.com/package/@paypal/react-paypal-js

However even though it seems to be developed by paypal officially, there seems to be no option to disable the shipping address during checkout

<PayPalScriptProvider options={{ "client-id": clientId, currency: "GBP", "disable-funding": "sofort", shippingPreference: "NO_SHIPPING" }}>

Doesn't seem to have any effect at the checkout page as it still shows the delivery address

Doesn't seem to have any effect at the checkout page as it still shows the delivery address

Upvotes: 3

Views: 987

Answers (1)

user2921885
user2921885

Reputation: 189

After digging through the source code you can supply many options.. I was able to set no shipping address like this:

 const createOrder = (data, actions) => {
          return actions.order
              .create({
                  purchase_units: [
                      {
                          amount: {
                              value: donationAmount,
                          },
                      },
                  ],
                  application_context: {
                      shipping_preference: "NO_SHIPPING"
                  }
              })
              .then((orderID) => {
                  setOrderID(orderID);
                  return orderID;
              });
      }

<PayPalButtons style={{ layout: "vertical" }} createOrder={createOrder} />

Upvotes: 8

Related Questions