Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal C# SDK Endpoint

Tags:

c#

paypal

I'm looking for a way to set the PayPal SOAP API endpoint in the code rather than specifying it in the web.config or app.config. I need to read & use the endpoint from an environment-specific configuration that is not the web.config/app.config.

Is this possible? I've read some of the code for the SDK on their github repo and it does not appear possible but I'm hoping I missed something.

I'm using the PayPal Merchant SDK for .Net, ver 2.1.96.0.

like image 522
Tony Ranieri Avatar asked Jan 24 '13 18:01

Tony Ranieri


1 Answers

I needed to be able to specify all important settings outside of the .config file. I'm lazy so here's how I did it:

paypalConfig = new Dictionary<string, string>();
paypalConfig.Add("apiUsername", "xxxxx");
paypalConfig.Add("apiPassword", "xxxxx");
paypalConfig.Add("apiSignature", "xxxxx");
==>paypalConfig.Add("mode","live|sandbox");

And then you need to call your method by specifying again the credentials (haven't investigated much why this is necessary):

var service = new PayPalAPIInterfaceServiceService(paypalConfig);
var doCaptureResponse = service.DoCapture(amount, new SignatureCredential(paypalConfig["apiUsername"], paypalConfig["apiPassword"], paypalConfig["apiSignature"]));
like image 127
Simon Labrecque Avatar answered Sep 21 '22 11:09

Simon Labrecque