Ask Your Question
2

How can we prevent the shipping address option using react-paypal-js?

asked 2023-07-17 11:51:32 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-17 12:06:02 +0000

nofretete gravatar image

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;
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-17 11:51:32 +0000

Seen: 11 times

Last updated: Jul 17 '23