Closed sfmskywalker closed 10 years ago
You can skip Web.Config altogether. All REST methods in the SDK have a overloaded variant that takes a APIContext object as a argument. See here for an example.
Here's a payment create call that uses web.config
Payment.Create(<access token>);
while here's a call that uses a dynamic config dictionary instead
Dictionary<string, string> config = new Dictionary<string, string>();
config.Add("mode", "sandbox");
APIContext context = new APIContext();
context.Config = config;
context.AccessToken = <accessToken>;
Payment.Create(context);
That's great. Thanks!
https://github.com/paypal/rest-api-sdk-dotnet/blob/master/Visual%20Studio%202008/RestApiSDK/PayPal/Api/Payments/Payment.cs#L120 -> 404 context.AccessToken is readonly
@werddomain APIContext can be found in the sdk-core-dotnet repository.
Here is an updated example of how to use it with a dynamic config dictionary:
var config = new Dictionary<string, string>();
config.Add("mode", "sandbox");
var context = new APIContext(<accessToken>);
context.Config = config;
Payment.Create(context);`
Is there a way to use the REST API SDK without requiring me to configure settings (ClientID, Secret & Endpoint) via web.config? I'd like to store these settings in a database instead (use case: I'm writing an Orchard CMS module).
I could obviously talk with the REST API directly via HttpClient, but it saves a lot of time being able to use your dot net SDK instead.