protected void Page_Load(object sender, EventArgs e)
{
//https://stackoverflow.com/questions/30095448/paypal-rest-api-with-credit-cart-payment-method
//https://tutorials.tinyappco.com/ASPNET/PayPal
#region Authenticate with PayPal
var config = ConfigManager.Instance.GetProperties();
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken);
#endregion
//var apiContext = GetApiContext(clientId, clientSecret);
CreditCard creditCard = new CreditCard();
creditCard.number = " XXXXXXXXXXXXXXXX";
creditCard.type = "Visa";
creditCard.expire_month = 08;
creditCard.expire_year = 2021;
creditCard.cvv2 = "145";
creditCard.first_name = "Ric";
creditCard.last_name = "Chan";
Amount amount = new Amount();
amount.total = "7.47";
amount.currency = "USD";
Transaction transaction = new Transaction();
transaction.amount = amount;
transaction.description = "This is the payment transaction description.";
List<Transaction> transactions = new List<Transaction>();
transactions.Add(transaction);
FundingInstrument fundingInstrument = new FundingInstrument();
fundingInstrument.credit_card = creditCard;
List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
fundingInstruments.Add(fundingInstrument);
Payer payer = new Payer();
payer.funding_instruments = fundingInstruments;
payer.payment_method = "credit_card";
var redirectUrls = new RedirectUrls();
redirectUrls.return_url = "Default.aspx";
Payment payment = new Payment();
payment.intent = "sale";
payment.payer = payer;
payment.transactions = transactions;
//payment.redirect_urls = redirectUrls;
var createdPayment = payment.Create(apiContext);
//Response.Write(createdPayment.state);
//Payment createdPayment = payment.Create(apiContext);
Response.Write("Payment ID " + payment.id);
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.