Disable shipping address option in PayPal Express Checkout

42,597

Solution 1

If you're using the newer API, you could also pass NOSHIPPING=1 (not no_shipping)

Further details about all possible parameters to the SetExpressCheckout here:

https://developer.paypal.com/docs/nvp-soap-api/nvp/

Or lookup for Payment experience in new REST API

Solution 2

For others looking for this, because PayPals documentation is so GREAT (cough, cough).

NO web experience profile REQUIRED!

Using REST API V2 with Javascript/JQuery and turning "Ship To" off for an ORDER, here is the correct code example:

    createOrder: function(data, actions) {
        $('#paypalmsg').html('<b>' + 'WAITING ON AUTHORIZATION TO RETURN...' + '</b>');
        $('#chkoutmsg').hide()
        return actions.order.create({
            purchase_units: [{
                description: 'GnG Order',
                amount: {
                    value: cartTotal
                }
            }],
            application_context: {
              shipping_preference: 'NO_SHIPPING'
            }

        });
    },

Solution 3

Hey Ergec, just pass along the no_shipping parameter with a value of 1.

From PayPal's documentation:

no_shipping

Do not prompt payers for shipping address. Allowable values:
0 – prompt for an address, but do not require one
1 – do not prompt for an address
2 – prompt for an address, and require one
The default is 0.

Solution 4

The current right answer is depracated. To fix the issue in new API we should create Payment web experience profile resource with needed parameters and attach it to request Payment .

Example in PHP:

/** Note: Define some variables yourself. */

$inputFields = new InputFields();
$inputFields->setAllowNote(true)
    ->setNoShipping(1) // Important step
    ->setAddressOverride(0);

$webProfile = new WebProfile();
$webProfile->setName(uniqid())
    ->setInputFields($inputFields)
    ->setTemporary(true);

$createProfile = $webProfile->create($apiContext);

$payment = new Payment();

$payment->setPayer($payer);
$payment->setIntent($intent);
$payment->setRedirectUrls($redirectUrls)
$payment->setTransactions(array($transaction));
$payment->setExperienceProfileId($createProfile->getId()); // Important step.

$payment->create($apiContext);

if ($payment->getState() === "created") {
    $approvalLink = $payment->getApprovalLink()

    header("Location: $approvalLink"); // Redirects user to PayPal page.
}

Note: You can find all above used classes by link: https://github.com/paypal/PayPal-PHP-SDK/tree/master/lib/PayPal/Api

Solution 5

To solve for this from current (2019) web client .JS, add the application_context block to the request body.

Below is an example for createSubscription() call; and I'm thinking this will work with createOrder() as well

paypal.Buttons({
          createSubscription: function (data, actions) {

              return actions.subscription.create({

                  'plan_id'            : 'P-123',
                  'application_context': {
                      'shipping_preference': 'NO_SHIPPING'
                  }
              });
          },

          onApprove: function (data, actions) {

              // ...
          }
      })
      .render('#paypal-button-container');

Thanks to the example code here:

Here's where the field enums are listed:

Share:
42,597
Ergec
Author by

Ergec

:)

Updated on July 09, 2022

Comments