Last active
December 23, 2015 23:59
-
-
Save aydiv/6713303 to your computer and use it in GitHub Desktop.
Sample API call using the sdk-core-dotnet library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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