Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To prevent the shipping address option from showing up during checkout using react-paypal-js, you can set the "no_shipping" parameter to 1 in the PayPal script options.

Here is an example:

import { PayPalButton } from "react-paypal-button-v2";

const PayPalCheckoutButton = () => {
  const paymentOptions = {
    clientId: "your_client_id",
    currency: "USD",
    intent: "capture",
    "no-shipping": 1 // Set no_shipping to 1 to disable the shipping address option
  };

  return (
    <PayPalButton
      options={paymentOptions}
      // Your payPal function for creating the order
      createOrder={(data, actions) => {
        return actions.order.create({
          purchase_units: [
            {
              amount: {
                value: "10.00"
              }
            }
          ]
        });
      }}
      // Your payPal function for capturing the payment
      onApprove={(data, actions) => {
        return actions.order.capture().then(function(details) {
          // Congratulation you have successfully captured the payment!
        });
      }}
    />
  );
};

export default PayPalCheckoutButton;