Keep getting a Internal 500 Error and PayPal Exceptions

YushaPreston
Contributor
Contributor

Hello, I keep getting these exceptions when trying to test sending a payment to my own email in the sandbox environment.

 

Exceptions

Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'PayPal.HttpException' in PayPal.dll
Exception thrown: 'PayPal.HttpException' in PayPal.dll
Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll
Exception thrown: 'PayPal.IdentityException' in PayPal.dll
Exception thrown: 'PayPal.IdentityException' in System.Web.Mvc.dll
Exception thrown: 'PayPal.IdentityException' in System.Web.Mvc.dll

 

I am simply just trying to test out the Payouts API. I followed the exhausting instructions and finally received a Client ID, Secret, and a Access Token.

 

I installed the PayPal nuget package in my VS project. I am using MVC ASP.NET 

 

The Payout object is being filled correctly but the issue is either with 

apiContext

 or with the accessToken / clientId / clientSecret.

 

I am also getting a Internal 500 Error in the browser.

 

It seems like my credentials are invalid. Here is a snipper of my code, I have tried both with and without the accessToken being passed in the parameter because I think I read that they actually generate a access token for you if one is not supplied.

 

        public void PayoutSomeRandomPerson(string email, string rewardedAmount)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(rewardedAmount))
            {
                return;
            }

            // Authenticate
            var apiContext = Utilities.Configuration.GetAPIContext();

            Payout payout = GetPayoutDetails(email, rewardedAmount);

             // For single payouts pass true into the Create method
// For multiple payouts pass false into the Create method PayoutBatch createdPayout = payout.Create(apiContext, false); // Payout was created }

It looks like I am getting the error on 

payout.Create(apiContext)

 

Here is my Web.config file 

 

  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
  </configSections>

  <!-- PayPal SDK settings -->
  <paypal>
    <settings>
      <!-- Replace the mode to `security-test-sandbox` to test if your server supports TLSv1.2. For more information follow README instructions.-->
      <add name="mode" value="sandbox"/>
      <add name="connectionTimeout" value="360000"/>
      <add name="requestRetries" value="1"/>
      <add name="clientId" value="abcdefghijklmnopqrstuvwxyandz"/>
      <add name="clientSecret" value="nowiknowmyabcsnexttimewontusingwithme"/>
    </settings>
  </paypal>

 

UPDATE: So, I started playing around with the project a little more, for some reason it throws these exceptions on my clientId and clientSecret I'm almost sure of it now. I generated a new secret and it still threw these weird exceptions. I put my clientId and clientSecret in the Postman app and it worked fine! I also used the clientId and clientSecret from the example PayPal solution found on the developer website and it worked fine! The problem is though that the example clientId and clientSecret from the PayPal solution wont work because I can't see any API calls I have made since my clientId and clientSecret is tied to my app on the developer website..

 

I am also getting this error when I try to create payouts with the credentials provided that PayPal has given me for my sandbox account:

 

{"The remote server returned an error: (401) Unauthorized."}

 

Why do these example credentials provided here work but mine get a error?

 

Example Credentials:

 

      <add name="clientId" value="AUASNhD7YM7dc5Wmc5YE9pEsC0o4eVOyYWO9ezXWBu2XTc63d3Au_s9c-v-U"/>
      <add name="clientSecret" value="EBq0TRAE-4R9kgCDKzVh09sm1TeNcuY-xJirid7LNtheUh5t5vlOhR0XSHt3"/>

 

SOLUTION: I have no idea why, but after creating a new Sandbox Account, all of a sudden everything works like magic. 

Login to Me Too
1 REPLY 1

MTS_Justin
Moderator
Moderator

Thanks for the update to advise the issue is now resolved for you


Was my post helpful? If so, please give me a kudos!
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.