redirect_urls vs onAuthorize/onCancel callbacks

nylemi
Contributor
Contributor

Hello!

 

I have a question regarding the Create Payment API. I'm a little bit confused about the redirect_urls. If I'm using PayPal Checkout components (https://github.com/paypal/paypal-checkout), under what circumstances would the user be redirected to the provided return_url / cancel_url?

 

As far as I understand, with these components the buyer approval flow will open up in a new browser window (pop-up) and close upon completion. After the flow is completed, the onAuthorize or onCancel callback will be fired on the window where the button was rendered. I don't see any place in this flow where any of the redirect_urls would be used though? Nevertheless, creating a payment using the API requires me to provide them.

 

Could someone shed light on this? Is there some kind of fallback for scenarios where the browser blocks popups that users would get full-page redirected to the payment approval page on paypal.com and then back to the provided return_url? Or is it just "legacy" field and I can trust it to never be used?

 

I'm wondering if I need to implement the "on authorize" / "on cancel" logic in two places, both in the onAuthorize callback and on the pages referred in redirect_urls.

 

For reference, this is the payload I'm sending:

 

 

{
      intent: "sale",
      payer: {
        payment_method: "paypal"
      },
      transactions: [{
        amount: {
          total: "99.99",
          currency: "USD"
        }
      }],
      redirect_urls: {
        return_url: "https://mysite.com/thanks",
        cancel_url: "https://mysite.com/cancel"
      }
    }

 

 

Login to Me Too
1 REPLY 1

nylemi
Contributor
Contributor
Anyone? In my testing, the redirect_urls are never invoked, so I'm not sure what logic I should implement on them...
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.