no_shipping option in new Smart Buttons API

MikeKrzyzaniak
Contributor
Contributor

I'm integrating the new Smart Buttons into my website. Using the older (prior to Feb 2019) API, I could specify a no_shipping option, so that the user would not be prompted for their address on PayPal pages, as in the following snippet:

 

paypal.Button.render({

  payment: function (data, actions) {
    return actions.payment.create({
    experience: {
       input_fields: {no_shipping: 1}
    }});},}, '#paypal-button');

 

The new API evidently uses actions.order.create() instead of actions.payment.create(), and specifying experience: {input_fields: {no_shipping: 1}}} there doesn't seem to have any effect.  So how do I hide the shipping address on paypal pages during checkout?

Login to Me Too
8 REPLIES 8

rahul-dighe
PayPal Employee
PayPal Employee

Use https://developer.paypal.com/docs/api/orders/v2/#definition-application_context 

 

pass shipping_preference as NO_SHIPPING

 

it should look something like

 

"application_context" : { 

     "shipping_preference":"NO_SHIPPING"

}

Senior Product Manager - PayPal Checkout API Product
Login to Me Too

iXStudios
Contributor
Contributor

I tried this as well, though in my Paypal dashboard, new orders still have shipment options and i can/must still apply orders as 'shipped' manually.
Anybody else with more luck?
PS. i'm using this particular Paypal account for donations and digital goods.

Login to Me Too

MTS_Jennifer
Moderator
Moderator

Hello,

Can you please comment your Sandbox Merchant ID? I can review your Sandbox account to ensure that it is setup correctly. Also I will review the requests and responses that is coming in.

Your request should look something like this to suppress the shipping. I also need to check and see if the account is enabled for Digital Goods as well.

{
  "intent": "CAPTURE",
  "purchase_units": [
    {
      "amount": {
        "currency_code": "USD",
        "value": "100.00"
      }


    }
  ],
  "application_context" :  { 
   "shipping_preference":"NO_SHIPPING"
}

 
}

Thank you,

Jennifer

PayPal

Login to Me Too

BeyondAllReason
Contributor
Contributor

Hi Jennifer,

 

I'm replying on the account I've set-up. (I've posted the question under the name "iX Studios".
Where can i find the "merchant ID"?
I only have Client ID.

This is the script i'm using:

(major difference is i don't use is the intent = CAPTURE - is that needed?)

 

 

 

<script>
  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({
        reference_id: 'BAR 10',
        description: 'BAR Donation $10',
        purchase_units: [{
        amount: {
            value: '10.00',
            currency_code: 'USD',
            breakdown: {
                        item_total: {value: '10', currency_code: 'USD'}
                    }
          },
          items: [{
                    name: 'BAR Donation 10',
                    unit_amount: {value: '10.00', currency_code: 'USD'},
                    quantity: '1',
                    category: 'DIGITAL_GOODS'
                }]
        }],
        application_context: {
        	shipping_preference: 'NO_SHIPPING',
          return_url: 'https://www.beyondallreason.info/thank-you',
          cancel_url: 'https://www.beyondallreason.info/too-bad'
      	}
      });
    },
    onApprove: function(data, actions) {
                return actions.order.capture().then(function(details) {
                    // Show a success message to the 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>

 

 

 

 

At the moment we don't have explicit "digital goods" - for now it's 99% donations.
We do like to setup some 'digital rewards' like naming donateurs or giving them a special badge in our (free) game.

I hope you can help me improve this, because currently, donations/transactions all get blocked by default and take a long time to get 'free'.
And i think i have to manually "send the digital goods" for each transaction, which i would like be automated.

PS. Side question: is it also possible to do recurring donations, like $5 each month or each year?

Login to Me Too

nineproof
Member
Member

The NO_SHIPPING option won't hide shipping fields for credit card payments (choose PayPal from Smart Payment Buttons then "Pay with a card").

Too, for Sofort and MyBank payments (not working, btw) it will asks again Name, Surname, e-mail address and phone (I didn't ask the phone to my customers). At least you can prefill them. 

 

Login to Me Too

nineproof
Member
Member

Too, the Paypal popup shows the Ship to for a moment, while loading (will disappear when loading finished). Very poor UI experience

 

nineproof_0-1586985186416.png

 

Login to Me Too

SteveStuartDJ
Contributor
Contributor
I've put the NO _SHIPPING code in my merchant page, now I want to ask if I can be enabled to sell digital goods. There's no obvious link for that except downloading the Joomla extension, is that the way to go now? Or should I download a shopping cart? I'm grateful for your support, Steve
Login to Me Too

MikeKrzyzaniak
Contributor
Contributor

Thanks to the moderatos for their prompt responses. For posterity I want to say that I sell physical goods and collect shipping addresses directly on my site, and then pass that information along to PayPal to complete the payment. I later manually purchase the shipping label on PayPal. In my case, the original answer ("shipping_preference":"NO_SHIPPING") behaves exactly as I desire (does not re-prompt the user for their address). I have never tried to sell non-physical goods, but conceptually it seems like the PayPal API should handle that separately so that vendors do not need to manually mark these goods as shipped. If somebody knows how to do that, this might be a good place to post it, although I personally do not need an answer to this.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.