How to know if the approve url succeeded (Orders API v2)

Nagesh2
Contributor
Contributor

I am integrating the Paypal REST api in a Flutter app and am successfully getting the "Approve" url when creating order. When I copy this link and open it in a browser it correctly shows me the details. But when I press 'Continue' for the payment I get redirected to the same 'approve' link again. The order does get authorised, but I am not sure how will I know if the authorisation was successful. I have mentioned the "Reply Url" in the Sandbox App Settings.

 

This is a sample response I get when I create order. Then the approve link is opened in the browser for further processing but it doesn't redirect back to another url.

 

{
    "id": "xxxxxxxx",
    "links": [
        {
            "href": "<a href="https://api.sandbox.paypal.com/v2/checkout/orders/xxxxxxx" target="_blank">https://api.sandbox.paypal.com/v2/checkout/orders/xxxxxxx</a>",
            "rel": "self",
            "method": "GET"
        },
        {
            "href": "<a href="https://www.sandbox.paypal.com/checkoutnow?token=xxxxxxxx" target="_blank">https://www.sandbox.paypal.com/checkoutnow?token=xxxxxxxx</a>",
            "rel": "approve",
            "method": "GET"
        },
        {
            "href": "<a href="https://api.sandbox.paypal.com/v2/checkout/orders/xxxxxxxx" target="_blank">https://api.sandbox.paypal.com/v2/checkout/orders/xxxxxxxx</a>",
            "rel": "update",
            "method": "PATCH"
        },
        {
            "href": "<a href="https://api.sandbox.paypal.com/v2/checkout/orders/xxxxxxxxxx/capture" target="_blank">https://api.sandbox.paypal.com/v2/checkout/orders/xxxxxxxxxx/capture</a>",
            "rel": "capture",
            "method": "POST"
        }
    ],
    "status": "CREATED"
}

 

 

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

rahul-dighe
PayPal Employee
PayPal Employee

if you are not using any client JS then you need to include return_url as part of the create order request - that's the only way it will redirect to the URL and one would know if the order was approved by the buyer/payer.

 

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

 

Let me know if you have any more questions.

Senior Product Manager - PayPal Checkout API Product

View solution in original post

Login to Me Too
4 REPLIES 4

sean-steele
New Community Member

We are having similar issue. Trying to integrate Flutter using the Rest API's but not sure how to know of the success without a redirect url.

Login to Me Too
Solved

rahul-dighe
PayPal Employee
PayPal Employee

if you are not using any client JS then you need to include return_url as part of the create order request - that's the only way it will redirect to the URL and one would know if the order was approved by the buyer/payer.

 

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

 

Let me know if you have any more questions.

Senior Product Manager - PayPal Checkout API Product
Login to Me Too

yong_san
Contributor
Contributor

I having the same problem. I already put the return url and it still keep staying in the payment page  after finish loading. This is my request body

paypalRequest.requestBody({
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": value,
"value": currency_code
}
}
],
"application_context": {
"user_action": "PAY_NOW",
"return_url ": "paypal://xxx.co",
"shipping_preference": "NO_SHIPPING"
},
});

.

Login to Me Too

barsawi1994
Contributor
Contributor

same issue 

pleaase How to pass redirect_URL in ApplicationContext with Java

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.