Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Turn off shipping with new PayPal JavaScript SDK

I'm playing around with the new PayPal Javascript SDK buttons here https://developer.paypal.com/docs/checkout/reference/customize-sdk

Our app sells digital goods and doesn't require a shipping address. Is there any way to turn that off?

// render paypal buttons
paypal.Buttons({
    createOrder: function (data, actions) {
        // Set up the transaction
        return actions.order.create({
            purchase_units: [{
                amount: {
                    value: $scope.total
                }
            }],
            application_context: {
                shipping_preference: "NO_SHIPPING"
            }
        });
    },
    onApprove: function (data, actions) {
        // Capture the funds from the transaction
        return actions.order.capture().then(function (details) {
            // Show a success message to your buyer
            alert('Transaction completed by ' + details.payer.name.given_name + ' order ID: ' + data.orderID);


        });
    }
}).render('#paypal-button-container');
like image 551
Brandon McAlees Avatar asked Mar 11 '19 00:03

Brandon McAlees


1 Answers

Yes, you will need to pass the shipping_preference object.

array(
 'shipping_preference' => 'NO_SHIPPING'
),

Reference : https://developer.paypal.com/docs/api/payments/v1/?mark=shipping_preference%20#definition-application_context

like image 172
Vimalnath Avatar answered Oct 17 '22 09:10

Vimalnath