Skip to content

Instantly share code, notes, and snippets.

@aydiv
Last active December 23, 2015 23:59
Show Gist options
  • Save aydiv/6713303 to your computer and use it in GitHub Desktop.
Save aydiv/6713303 to your computer and use it in GitHub Desktop.
Sample API call using the sdk-core-dotnet library
using PayPal;
using PayPal.Api.Payments;
using System.Collections.Generic;
CreditCard credtCard = new CreditCard();
credtCard.expire_month = 11;
credtCard.expire_year = 2018;
credtCard.number = "4417119669820331";
credtCard.type = "visa";
Dictionary<string, string> config = new Dictionary<string, string>();
config.Add("endpoint", "http://api.mydomain.com");
try
{
// Create APIContext, passing in optional accesstoken for APIs that require OAuth based authentication.
string accessToken = new OAuthTokenCredential("Oauth clientid", "Oauth clientsecret", config).GetAccessToken();
APIContext apiContext = new APIContext(accessToken);
// Pass in SDK configuration parameters as required
apiContext.Config = config;
// Shoot an API request
CreditCard createdCreditCard = credtCard.Create(apiContext);
}
catch (PayPal.Exception.PayPalException ex)
{
// Handle error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment