Lambru
asked on
Paypal RESTful API ASP.NET C#
I am trying to implement the Paypal RESTful API to be able to receive payments on my website. At this stage I have been able to make the sample code work.
More specifically I have created a brand new application in VS2013 and copy pasted the following files from the sample API's: PaymentWithCreditCard.aspx , Response.aspx and Configuration.cs. The result is that I can successfully post payments to the sandbox and get a response of an approved payment. So far so good.
Problem N1 - retrieving an access token
I have replaced in the configuration class file the sample standard access token:
with the following:
and i have also added in web.config the following:
however I get a
The sample files are from
https://github.com/paypal/rest-api-sdk-dotnet/tree/master/Samples/RestApiSample
More specifically I have created a brand new application in VS2013 and copy pasted the following files from the sample API's: PaymentWithCreditCard.aspx
Problem N1 - retrieving an access token
I have replaced in the configuration class file the sample standard access token:
private static string GetAccessToken()
{
OAuthTokenCredential("EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM", "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM", GetConfig()).GetAccessToken();
return accessToken;
}
with the following:
private static string GetAccessToken()
{
var clientId = System.Configuration.ConfigurationManager.AppSettings["clientId"];
var secretToken = System.Configuration.ConfigurationManager.AppSettings["secretToken"];
var config = new Dictionary<string, string> { { "mode", "sandbox" } };
OAuthTokenCredential tokenCredential = new OAuthTokenCredential(clientId, secretToken, config);
string accessToken = tokenCredential.GetAccessToken();
return accessToken;
}
and i have also added in web.config the following:
<configSections>
<section name="paypal" type="PayPal.Manager.SDKConfigHandler, PayPalCoreSDK"/>
</configSections>
<paypal>
<accounts>
<account apiUsername="" apiPassword="" applicationId="" apiSignature="" />
</accounts>
<settings>
<add name="mode" value="sandbox" />
</settings>
</paypal>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="clientId" value="***********" />
<add key="secretToken" value="***********" />
</appSettings>
</configuration>
however I get a
Exception in HttpConnection Execute: Invalid HTTP response The remote server returned an error: (401) Unauthorized.
The sample files are from
https://github.com/paypal/rest-api-sdk-dotnet/tree/master/Samples/RestApiSample
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER