no_shipping option in new Smart Buttons API

Viewed 80

I'm integrating the new Smart Buttons into my website. I want to specify a no_shipping option, so that the user would not be prompted for their address on PayPal pages

  paypal.Buttons({
    createOrder: function(data, actions) {
      // This function sets up the details of the transaction, including the amount and line item details.
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: '0.01'
          }
        }]
      });
    },
    onApprove: function(data, actions) {
      // This function captures the funds from the transaction.
      return actions.order.capture().then(function(details) {
        // This function shows a transaction success message to your buyer.
        alert('Transaction completed by ' + details.payer.name.given_name);
      });
    }
  }).render('#paypal-button-container');
  //This function displays Smart Payment Buttons on your web page.
</script>

How do I implement it? I do not get it.

1 Answers

The v2/orders application_context object is documented here.

  purchase_units: [{
    amount: {
      value: '0.01'
    },
  }],
  application_context: {
    shipping_preference: 'NO_SHIPPING'
  }
Related