I'm hacking hard at Battle Hack London and I've stumbled in an annoying problem. The PayPal SDK for c# doesn't seem to work quite right.
I'm trying to do my first transaction and here's my code (which I put together fixing the broken online docs:
var tokenCredential = new OAuthTokenCredential(something, someother);
var accessToken = tokenCredential.GetAccessToken();
Payment createdPayment = new Payment
{
intent = "sale",
transactions = new List<Transaction>
{
new Transaction
{
amount = new Amount
{
total = value.ToString("R"),
currency = "GBP"
},
description = forWhat
}
}
}.Create(accessToken);
This results in
Cannot parse *.Config file. Ensure you have configured the 'paypal' section correctly.
which I've traced down to this line of code but I don't know how to configure that section correctly and I can't find the correct documentation.
How is tthe csharp REST SDK supposed to be configured?
I was running into this same error. I tried Skliwz's solution but it did not work for me.
Instead I was able to get a result by passing a dictionary object with the call.
Dictionary<string, string> payPalConfig = new Dictionary<string, string>();
payPalConfig.Add("mode", "sandbox");
OAuthTokenCredential tokenCredential = new AuthTokenCredential("myCliedId", "myClientSecret", payPalConfig);
string accessToken = tokenCredential.GetAccessToken();
Still working on get my Log In to work...
I've worked this out with the support of a PayPal dev. One needs to add:
<configSections>
<section name="paypal" type="PayPal.Manager.SDKConfigHandler, PayPalCoreSDK"/>
</configSections>
<paypal>
<accounts>
<account apiUsername="xxx"
apiPassword="yyy"
applicationId="APP-80W284485P519543T"
apiSignature="zzz"
/>
</accounts>
<settings>
<add name="mode" value="sandbox"/>
</settings>
</paypal>
where xxx
, yyy
, zzz
you are values that you get from the "Account details" of your main sandbox test account.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With