Capturing payments: The requested action could not be performed, semantically incorrect, or failed business validation
Asked Answered
S

4

9

I have a problem with the new PayPal API (v2) and sandbox

1- Create an order https://api.sandbox.paypal.com/v2/checkout/orders

{
    "intent": "CAPTURE",
    "purchase_units": [
        {
            "amount": {
                "currency_code": "USD",
                "value": 10
            },
            "payee": {
                "email": "[email protected]",
                "merchant_id": "xxxx"
            }
        }
    ],
    "application_context": {
        "shipping_preference": "NO_SHIPPING"
    }
}

2- Go to the approve link in the response

If the sandbox account has a credit card, PayPal shows: "Sorry, we are not able to process your request. Please try again later"

3- Log in and approve the order

The sandbox account doesn't have a credit card

Approve order image

When the continue button is clicked, the page show the loading indicator and it disappears again and nothing happens

4- Check the order's status and it's APPROVED

{
    ...
    "status": "APPROVED"
    ...
}

5- Try to capture the payment https://api.sandbox.paypal.com/v2/checkout/orders/xxx/capture

{
    "name": "UNPROCESSABLE_ENTITY",
    "details": [
        {
            "issue": "TRANSACTION_REFUSED",
            "description": "The request was refused"
        }
    ],
    "message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
    "debug_id": "939b641049ad2",
    "links": [
        {
            "href": "https://developer.paypal.com/docs/api/orders/v2/#error-TRANSACTION_REFUSED",
            "rel": "information_link",
            "method": "GET"
        }
    ]
}
Siltstone answered 22/4, 2019 at 17:13 Comment(2)
have you tried the older API?Plataea
they say it's deprecated in the documentation of v1Siltstone
S
7

I figured it out. It's quite simple. The body payload was missing the return_url in application_context. PayPal really needs to document errors better.

Siltstone answered 1/5, 2019 at 13:34 Comment(1)
How to pass the return URL in the body parameter while using capture API?Catgut
M
1

Took me 5 hours to debug. As in Ziad's case my trouble was application_context, but unlike Ziad I had both cancel_url and return_url defined. I had previously changed payment_method though, to what I understood was a better configuration.

These are changes that helped me.

payment_method": {
    "payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
}

to

payment_method": {
    "payee_preferred": "UNRESTRICTED"
}

Paypal is to blame here for not helping us narrow down these unforgiving territories.

Melentha answered 23/4, 2020 at 21:45 Comment(0)
R
1

The UNPROCESSABLE_ENTITY error covers a huge swathe of issues, as covered in their docs here: https://developer.paypal.com/docs/api/reference/orders-v2-errors/#capture-order

In my instance it was that I was using the old test Visa 4111 1111 1111 1111. These days you have to use a test card number that you generate in your developer account here: https://developer.paypal.com/developer/creditCardGenerator

Retrogression answered 4/11, 2021 at 11:1 Comment(1)
The stupid test card problem was my problem that I spent days trying to figure out since their documentation wasn't clear.Casteel
A
0

Better late than never :)

I found that this error is usually caused when users don't respond to PayPal's email to verify their identity! PayPal sends emails occasionally to verify your identity, which some of us might've mark them as spam perviously! And when you don't respond and verify your identity they limit your account and then you get this error:

description: "The merchant account is restricted."
field: "/purchase_units/@reference_id=='default'/payee"
issue: "PAYEE_ACCOUNT_RESTRICTED"

The requested action could not be performed, semantically incorrect, or failed business validation.

You'll have to login to you PayPal account and go to https://www.paypal.com/restore/dashboard

Ardussi answered 4/5, 2021 at 9:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.