Smart button without shipping

Mo1111
Contributor
Contributor

Hello All,

 

This new smart button jdk is making my life difficult ...

 

All I need is the code to add for a paypal checkout button that doesn't inquire shipping address (we are selling digital goods), and with a variable amount (I will instruct the cart amount through JS.

 

That's what I have for now :

 

<script src="https://www.paypal.com/sdk/js?client-id=sb&currency=EUR" data-sdk-integration-source="button-factory"></script>
<script>
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',

},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '1'
}
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>

 

Can anyone help with that? I spend 3 hours today reading the manuel without finding any concrete help.

 

Thanks

Login to Me Too
6 REPLIES 6

MTS_Chiranjeevi
Moderator
Moderator

Hi @Mo1111,

 

Thank you for contacting PayPal community.

 

We apologize for any inconvenience.

 

Yes, you can able to handle the shipping address fields during PayPal checkout using parameter "NOSHIPPING".

 

I request to please contact your website developer, to cross check your website payment request  API calls and modify the value "NOSHIPPING to "1" in your payment calls. Since you have confirmed that your website doesn't ship any physical goods/products to the customers.

Once this settings is done, PayPal system will not show/provide the shipping address option to the customers and resolves the issue.

shipping_preference enum
The shipping preference:
  • Displays the shipping address to the customer.
  • Enables the customer to choose an address on the PayPal site.
  • Restricts the customer from changing the address during the payment-approval process.
The possible values are:
  • GET_FROM_FILE. Use the customer-provided shipping address on the PayPal site.
  • NO_SHIPPING. Redact the shipping address from the PayPal site. Recommended for digital goods.
  • SET_PROVIDED_ADDRESS. Use the merchant-provided address. The customer cannot change this address on the PayPal site.

Default: GET_FROM_FILE.

 

Guide link for reference - 

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


Note - This parameter will disable shipping address during PayPal checkout flow. Please use this parameter if your website doesn't ship any physical products to the customers/clients.

Thank you so much for your patience and understanding.

Sincerely,

Chiranjeevi

PayPal, Inc.

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

 
Login to Me Too

Mo1111
Contributor
Contributor

Hello Chiranjeevi,

 

Thanks for your reply.

You manual doesn't provide any code examples, so I do not know how to use this parameter.

 

Could you please show me how to use it concretely?

 

var purchase_value = '100';
paypal.Buttons({
style: {
     shape: 'rect',
     color: 'gold',
     layout: 'vertical',
     label: 'paypal',
},
createOrder: function(data, actions) {
     return actions.order.create({
          purchase_units: [{
               amount: {
               value: purchase_value,
               }
          }]
     });
},
onApprove: function(data, actions) {
     return actions.order.capture().then(function(details) {
          alert('Transaction completed by ' + details.payer.name.given_name + '!');
     });
}
}).render('#paypal-button-container');

 

Also, OnAprove I would like to redirect the user to a success page, how can I assure the access to that page is done by your system? do I receive any variable or other element?

 

Thanks

Login to Me Too

Mo1111
Contributor
Contributor

Hello Chiranjeevi,

 

Could you please follow up?

 

Thanks in advance

 

 

Login to Me Too

smile108
Member
Member
It's much too late for @Mo1111 but this works for me and someone might find it useful.
 
ppButtonComponent = paypal.Buttons({
        style: {
            shape: 'pill',
            color: 'blue',
            layout: 'vertical',
            label: 'paypal'
        },
        createOrder: function (dataactions) {
            return actions.order.create({
                purchase_units: [{
                    amount: {
                        value: '2',
                        currency: 'EUR'
                    }
                }],
                application_context: {
                    shipping_preference: "NO_SHIPPING"
                }

            });
        },
        onApprove: function (dataactions) {
            return actions.order.capture().then(function (details) {
                alert('Transaction completed by ' + details.payer.name.given_name + '!');
            });
        }
    });
ppButtonComponent.render('#paypal-button-container');
 
Login to Me Too

Andras98
Contributor
Contributor

It works for me, but removes the city name, street name and house number input fields. This way it is not a full billing information, because it contains only first name, last name and postal code. Is there anything else to solve this problem?

Login to Me Too

TonysTechFix
Contributor
Contributor

Thank you! @smile108 That worked for me too .  The smart button documentation seems badly lacking.

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.