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.
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"]));
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