public bool CreatePayment(CustomerInformation customerInfo) { //Save Order var order = _shoppingCartService.CreateOrder(new CustomerOrderDetails( customerInfo.ShippingAddress2, customerInfo.ShippingAddress1, "US", customerInfo.ShippingFirstName, customerInfo.ShippingCity, customerInfo.ShippingLastName, customerInfo.ShippingState, customerInfo.ShippingZip)); if (order != null) { //Use order to create payment var payment = new Payment() { intent = "sale", payer = CreatePayer(customerInfo), transactions = new List<Transaction>() { Transaction(order) } }; return MakePayment(payment); } return false; }
public async Task<ActionResult> CheckOut(CustomerInformation information) { return await Task.Run<ActionResult>(() => { if (_payPalService.CreatePayment(information)) { return View("OrderCompleted"); } else { return View("OrderDeclined"); } }); }
public Payer CreatePayer(CustomerInformation customerInfo) { // A resource representing a Payer that funds a payment. return new Payer() { payment_method = "credit_card", funding_instruments = new List<FundingInstrument>() { new FundingInstrument() { credit_card = new CreditCard() { billing_address = new Address() { city = customerInfo.BillingCity, country_code = "US", line1 = customerInfo.BillingAddress, postal_code = customerInfo.BillingPostalCode, state = customerInfo.BillingState }, cvv2 = customerInfo.CVV, expire_month = customerInfo.ExpireMonth, expire_year = customerInfo.ExpireYear, first_name = customerInfo.FirstNameOnCard, last_name = customerInfo.LastNameOnCard, number = customerInfo.CreditCardNumber, type = customerInfo.CreditCardType } } }, payer_info = new PayerInfo { email = customerInfo.CustomerEmail } }; }