PAYER_ACTION_REQUIRED when creating order using REST API

lwimble
Contributor
Contributor

Hello, I am integrating the Paypal Standard Checkout using Javascript SDK on the front end, with calls to the REST API on the backend; pretty standard stuff that's covered by the integration tutorials.  I am using Paypal to receive donations to my site.  I'm currently using the Sandbox environment.  It's relevant that my site is a single-page-application.

 

I have successfully integrated the entire thing and it works great.  The problem is that since I'm only collecting donations, there is absolutely no reason to collect my customer's shipping address.  So, I added an "experience_context" to the order, and when I do, it ALWAYS returns with a status PAYER_ACTION_REQUIRED rather than CREATED.  It does not seem to matter what's in the experience_context object.  The mere presence of this object causes the PAYER_ACTION_REQUIRED status when POSTing to /v2/checkout/orders.  The REST API documentation suggests that when that status is generated, it is required that you redirect the user to the "approve" link in the HATEOAS links in the returned object, but my site is a single-page-application, so I am definitely no up for  redirecting the user anywhere to make an "approval".

 

Here is the content of my order:

{
"intent": "CAPTURE",
"payment_source": {
"paypal": {
"experience_context": {
"brand_name": "Redacted for this Post",
"landing_page": "NO_PREFERENCE",
"locale": "en-US",
"payment_method_preference": "IMMEDIATE_PAYMENT_REQUIRED",
"payment_method_selected": "PAYPAL",
"shipping_preference": "GET_FROM_FILE",
"user_action": "PAY_NOW"
}
}
},
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "5.00"
}
}
]
}

Any thoughts on what I might do to prevent this behavior ?

Login to Me Too
6 REPLIES 6

MTS_Jennifer
Moderator
Moderator

Hello @lwimble ,

Thank you for posting to the PayPal Community.

There is an option for a shipping_preference of no_shipping. This will redact the shipping address from the transaction.

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

{
  "brand_name": "string",
  "shipping_preference": "NO_SHIPPING",
  "locale": "string",
  "return_url": "string",
  "cancel_url": "string"
}

 

Thank you,

Jennifer

MTS

PayPal

Login to Me Too

lwimble
Contributor
Contributor

I'm aware of that and I've tried it (and it does in fact redact the shipping info).  That's not the problem.  The problem is that merely providing an experience_context object produces a status of PAYER_ACTION_REQUIRED when trying to create the order.  I need a status of CREATED.

 

Larry

Login to Me Too

Cerealkilo
Contributor
Contributor

I have the same problem. 

{
            "intent": "CAPTURE",
            "purchase_units": [
                {
                    "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
                    "items": [
                        {
                            "name": "Test",
                            "quantity": "1",
                            "unit_amount": {
                                "currency_code": "USD",
                                "value": "10"
                            }
                        }
                    ],
                    "amount": {
                        "currency_code": "USD",
                        "value": "10.00",
                        "breakdown": {
                            "item_total": {
                                "currency_code": "USD",
                                "value": "10.00"
                            }
                        }
                    }
                }
            ],
            "payment_source": {
                "paypal": {
                    "experience_context": {
                        "payment_method_preference": "IMMEDIATE_PAYMENT_REQUIRED",
                        "brand_name": "XXX",
                        "user_action": "PAY_NOW",
                        "return_url": "http://google.com",
                        "cancel_url": "http://google.com"
                    }
                }
            }
        }
       



Without the block payment_source --> status created
Witht the block payment-source --> 

  "status" => "PAYER_ACTION_REQUIRED"
  "payment_source" => array:1 [
    "paypal" => []
  ]

 

Login to Me Too

jafii
Contributor
Contributor

Any updates?

Login to Me Too

Neokit
Contributor
Contributor
Any Update? Would be great to get a workaround or explanation from Paypal experts.
Login to Me Too

ollie_new
New Community Member

Same issue. Anybody have any news or a workaround?

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.