Paypal HATEOAS approval link loops back to same page and does not approve payment (SANDBOX)

Vanblerk1
Contributor
Contributor

Hi,

I am having an issue when following the HATEOAS link to approve an order after successfully creating the order. The issue is that I am continually redirected back to the same page and my order is never approved

Environment:

Scenario:

  • I create an order and receive the following object with HATEAOS links:

 

 

 

 

{
    "id": "59H23879RL605900S",
    "status": "CREATED",
    "links": [
        {
            "href": "https://api.sandbox.paypal.com/v2/checkout/orders/59H23879RL605900S",
            "rel": "self",
            "method": "GET"
        },
        {
            "href": "https://www.sandbox.paypal.com/checkoutnow?token=59H23879RL605900S",
            "rel": "approve",
            "method": "GET"
        },
        {
            "href": "https://api.sandbox.paypal.com/v2/checkout/orders/59H23879RL605900S",
            "rel": "update",
            "method": "PATCH"
        },
        {
            "href": "https://api.sandbox.paypal.com/v2/checkout/orders/59H23879RL605900S/capture",
            "rel": "capture",
            "method": "POST"
        }
    ]
}

 

 

I then follow the approval link which brings me to this page:

Screenshot from 2021-06-14 11-01-46.png

 

I hit continue and it says "Processing" followed by: "We're sending you back to Test Store to complete this purchase."

Screenshot from 2021-06-14 11-01-53.png

 I'm then redirected back to the same page as in my first screenshot.

When I then make a call to my spring boot back-end to capture the payment with the order ID, The following log is printed in my terminal:

 

{"name":"UNPROCESSABLE_ENTITY","details":[{"issue":"ORDER_NOT_APPROVED","description":"Payer has not yet approved the Order for payment. Please redirect the payer to the 'rel':'approve' url returned as part of the HATEOAS links within the Create Order call or provide a valid payment_source in the request."}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"c980b3c23bf4b","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-ORDER_NOT_APPROVED","rel":"information_link","method":"GET"}]}

 

 

So clearly the approval was not completed by following the HATEOAS link that was provided.

Am I missing some sort of configuration step that needs to happen in order for the approval to succeed?

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

MTS_Justin
Moderator
Moderator
Hello,

You never shared the order creation request you submitted, which is the most important part as it contains all the information on how you want the transaction setup.

Below is the request I can see for this order :

{
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "0.1"
}
}
]
}

You're missing the "redirect_urls" and values which are required for redirection to successfully occur.

"application_context": {
"return_url": "https://yourdomain.com/return",
"cancel_url": "https://yourdomain.com/cancel",

They must be included within the "application_context" object : https://developer.paypal.com/docs/api/orders/v2/#definition-order_application_context

Thanks !


Was my post helpful? If so, please give me a kudos!

View solution in original post

Login to Me Too
2 REPLIES 2
Solved

MTS_Justin
Moderator
Moderator
Hello,

You never shared the order creation request you submitted, which is the most important part as it contains all the information on how you want the transaction setup.

Below is the request I can see for this order :

{
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "0.1"
}
}
]
}

You're missing the "redirect_urls" and values which are required for redirection to successfully occur.

"application_context": {
"return_url": "https://yourdomain.com/return",
"cancel_url": "https://yourdomain.com/cancel",

They must be included within the "application_context" object : https://developer.paypal.com/docs/api/orders/v2/#definition-order_application_context

Thanks !


Was my post helpful? If so, please give me a kudos!
Login to Me Too

Vanblerk1
Contributor
Contributor

Hi,

This was exactly what my request needed. Issue resolved.

Thank you very much!

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.