paypalpaypal-nvp

PayPal API permissions request takes user to PayPal home page


I am using the PayPal Permissions SDK (Classic/NVP) to seek authorisation for third party payments.

The first time someone clicks on my button that redirects them to PayPal to login and authorise the request they get end up at the PayPal home page. If they go back and click my button again, it works this time and takes them to the right PayPal page.

Here is my code:

RequestPermissionsRequest rp = new RequestPermissionsRequest();
rp.scope = new List<string>();
rp.scope.Add("EXPRESS_CHECKOUT");
rp.callback = "my return url here";
rp.requestEnvelope = new RequestEnvelope("en_US");
RequestPermissionsResponse rpr = null;
PermissionsService service = new PermissionsService(PayPalClassicHelpers.Configuration.GetAcctAndConfig());
rpr = service.RequestPermissions(rp);
Response.Redirect("https://www.paypal.com/webscr&cmd=_grant-permission&request_token=" + rpr.token);

This redirects them to the PayPal URL:

https://www.paypal.com/webscr&cmd=_grant-permission&request_token=***rpr.token value***

But the first time they end up here:

https://www.paypal.com/us/home

Looking at the request and response headers, the first time I see this:

  1. GET: https://www.paypal.com/webscr&cmd=_grant-permission&request_token=***
  2. Response: HTTP/2.0 200 OK
  3. Various CSS, JS and image requests
  4. POST: https://www.paypal.com/auth/validatecaptcha
  5. Response: HTTP/2.0 302 Found Location: /webscr&cmd=_grant-permission&request_token=***
  6. GET: https://www.paypal.com/webscr&cmd=_grant-permission&request_token=***
  7. Response: HTTP/2.0 302 Found Location: https://www.paypal.com/home

On subsequent requests there is no POST to https://www.paypal.com/auth/validatecaptcha.

I have tried this on a few networks and computers and it is always the same.

Has anyone experienced this and know of the cause and a solution?


Solution

  • Just use '?' symbol after the webscr.

    For example, change

    https://www.paypal.com/webscr&cmd=_grant-permission&request_token= to

    https://www.paypal.com/webscr?cmd=_grant-permission&request_token=