UNPROCESSABLE_ENTITY

GerdNL
New Community Member

 

I keep getting this UNPROCESSABLE_ENTITY error when I try to create an order, strongly the first time I tried I worked, after that It didn't work anymore, I deleted the app and create new credentials but that didn't work either, anyone have an idea?

 

the error is

 

 

 

 

{"name":"UNPROCESSABLE_ENTITY","details":[{"location":"body","issue":"VALIDATION_ERROR","description":"VALIDATION_ERROR"}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"30a12b8b72e34","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-VALIDATION_ERROR","rel":"information_link","method":"GET"}]}

 

 

 

 

 

 

 

class Command(BaseCommand):
    def handle(self, *args, **options):
        clientid = "xxx"
        secret = "xxx"

        #do an paypal authentication
        url = "https://api.sandbox.paypal.com/v1/oauth2/token"
        headers = {'Accept': 'application/json', 'Accept-Language': 'en_US'}
        data = {'grant_type': 'client_credentials'}
        r = requests.post(url, headers=headers, data=data, auth=(clientid, secret))
        print(r.json())
        access_token = r.json()['access_token']
        print(access_token)


        url = 'https://api-m.sandbox.paypal.com/v2/checkout/orders'
        headers = {
            'PayPal-Request-Id': '0ed5f89f718b',
            'Content-Type': 'application/json',
            'Authorization': 'Bearer '+access_token
        }
        payload = {
            "intent": "CAPTURE",
            "purchase_units": [
                {
                    "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
                    "amount": {
                        "currency_code": "EUR",
                        "value": "1.00"
                    }
                }
            ],
            "payment_source": {
                "ideal": {
                    "country_code": "NL",
                    "name": "John Doe",
                    "bic": "INGBNL2A"
                }
            },
            "processing_instruction": "ORDER_COMPLETE_ON_PAYMENT_APPROVAL",
            "application_context": {
                "locale": "en-NL",
                "return_url": "https://example.com/returnUrl",
                "cancel_url": "https://example.com/cancelUrl"
            }
        }

        response = requests.post(url, headers=headers, json=payload)
        print(response.status_code)
        print(response.text)

 

 

 

the code: 

Login to Me Too
1 REPLY 1

MTS_Chiranjeevi
Moderator
Moderator

Good day @GerdNL,

 

Thank you for posting to the PayPal community.

 

The Create order API calls failed due to "Bad Request" with HTTP_RESPONSE_CODE=422 via Sandbox environment.

 

https://developer.paypal.com/api/rest/reference/orders/v2/errors/#create-order 

 

I would suggest to cross check and pass valid request in your Create order API.

 

If your still facing any issues, please create a MTS ticket via -  https://www.paypal-support.com/s/?language=en_US with the detail information and error details.

 

Sincerely,

Chiranjeevi

PayPal/Braintree MTS

 

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

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.