cancel
Showing results for 
Search instead for 
Did you mean: 

How to call Paypal API URI using C#

Options
MOHAN2
New Community Member
Posted on

Hi,

 I am integrating Paypal API using ASP.Net C#,

I am able get Access Token using API URI

 

using (var client = new HttpClient())
{
var byteArray = Encoding.UTF8.GetBytes(ClientId + ":" + ClientSecret);
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

var url = new Uri("https://api.sandbox.paypal.com/v1/oauth2/token", UriKind.Absolute);

client.DefaultRequestHeaders.IfModifiedSince = DateTime.UtcNow;

var requestParams = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("grant_type", "client_credentials")
};

var content = new FormUrlEncodedContent(requestParams);
var webresponse = await client.PostAsync(url, content);
var resp = await webresponse.Content.ReadAsStringAsync();
AuthResult acc = JsonConvert.DeserializeObject<AuthResult>(resp);

 

but Same thing I want to create Payment URI

like 

 

string strURL = "https://api.sandbox.paypal.com/v1/payments/payment/";

Payment payment = new Payment();
payment.transactions = translist;   //Translist is Transaction all details I have done

using (var client = new HttpClient())
{
//I am unable to call here please help me
}

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.