paypalpaypal-rest-sdk

PayPal: Experience Context causes "Create order" API call to fail


I want to set the shipping preference during a "Create order " POST /v2/checkout/orders call.

If I use the deprecated method of using application_context then it works fine:

{
  "intent": "CAPTURE",
  "purchase_units": [
    {
      "amount": {
        "currency_code": "GBP",
        "value": "110.62"
      }
    }
  ],
  "application_context": {
    "shipping_preference": "NO_SHIPPING"
  }
}

However, if I use the recommended method of using experience_context then I don't get back a status of CREATED but of PAYER_ACTION_REQUIRED.

{
  "intent": "CAPTURE",
  "purchase_units": [
    {
      "amount": {
        "currency_code": "GBP",
        "value": "110.62"
      }
     }
  ],
  "payment_source": {
    "paypal": {
      "experience_context": {
        "shipping_preference": "NO_SHIPPING"
      }
    }
  }
}

Why is that?

Note: The same problem was also asked one year ago in the PayPal community:

https://www.paypal-community.com/t5/REST-APIs/PAYER-ACTION-REQUIRED-when-creating-order-using-REST-API/td-p/3051720

But it was never solved.


Solution

  • There is no issue, you are simply describing the updated API's behavior.

    CREATED was always the old response when using deprecated parameters.

    PAYER_ACTION_REQUIRED is the new status response, if indeed such action is required (depending on which new parameters are used, for example when using a different payment_source object, it may not be).

    Basically don't worry about this, the order has been created as before and you're now being explicitly told if and when payer action is required. Carry on:


    To be clear, what has not changed is what you need to do next. Payer action has always been required. Either use standard integration JS SDK buttons to obtain in-context approval -- or use an old integration pattern (not recommended) of redirecting the buyer completely away from your site and then having them return back.