public IActionResult Pay(PaypalOrder order) { PaypalRedirect redirect = PaypalLogic.ExpressCheckout(order); HttpContext.Session.SetString("Token", redirect.Token); return(new RedirectResult(redirect.Url)); }
public IActionResult Pay(PaypalOrder po) { PaypalRedirect redirect = PaypalLogic.ExpressCheckout(po); //Session["token"] = redirect.Token; HttpContext.Session.SetString("token", redirect.Token); return(new RedirectResult(redirect.Url)); }
private async Task <HttpResponseMessage> MakeOrder(string token, DepositReq model) { using (var client = new HttpClient()) { var content = new PaypalOrder(model); var json = JsonConvert.SerializeObject(content); var req = new HttpRequestMessage(HttpMethod.Post, "https://api-m.sandbox.paypal.com/v2/checkout/orders") { Content = new StringContent(json, Encoding.UTF8, "application/json") }; req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); var response = await client.SendAsync(req); return(response); } }
public async Task <PaypalOrder> makeOrder(ItemBought[] items) //, IConfigurationRoot config) { float taxRate = _configRoot.Tax; // float.Parse(_configRoot["OnlineStore:tax"]); float shipping = _configRoot.Shipping; // float.Parse(_configRoot["OnlineStore:shipping"]); float subTotal = 0; for (int i = 0; i < items.Length; i++) { var item = await _itemRepo.GetById(items[i].id); subTotal += items[i].quantity * item.price; } subTotal = float.Parse(String.Format("{0:0.00}", subTotal)); float tax = float.Parse(String.Format("{0:0.00}", (taxRate * subTotal) / 100)); float total = float.Parse(String.Format("{0:0.00}", tax + shipping + subTotal)); PaypalOrder order = new PaypalOrder(); order.intent = "CAPTURE".ToUpper(); order.application_context = new PaypalOrderApplicationContext { brand_name = "bestpricedaily", return_url = string.Format(_configRoot.Paypal_success_url, _configRoot.BaseAddress), // _configRoot["Paypal:sandbox:RETURN_URL"]; cancel_url = string.Format(_configRoot.Paypal_cancel_url, _configRoot.BaseAddress), // _configRoot["Paypal:sandbox:CANCEL_URL"]; user_action = "CONTINUE", }; order.purchase_units = new PaypalOrderPurchaseUnit[1]; order.purchase_units[0] = new PaypalOrderPurchaseUnit(); order.purchase_units[0].invoice_id = "BestPriceDaily.net " + Guid.NewGuid(); order.purchase_units[0].amount = new PaypalOrderPurchaseUnitAmount(); order.purchase_units[0].amount.currency_code = "USD"; order.purchase_units[0].amount.value = total; order.purchase_units[0].amount.breakdown = new PaypalOrderPurchaseUnitAmountBreakdown(); order.purchase_units[0].amount.breakdown.item_total = new UnitAmount(); order.purchase_units[0].amount.breakdown.item_total.currency_code = "USD"; order.purchase_units[0].amount.breakdown.item_total.value = subTotal; order.purchase_units[0].amount.breakdown.shipping = new UnitAmount(); order.purchase_units[0].amount.breakdown.shipping.currency_code = "USD"; order.purchase_units[0].amount.breakdown.shipping.value = shipping; order.purchase_units[0].amount.breakdown.tax_total = new UnitAmount(); order.purchase_units[0].amount.breakdown.tax_total.currency_code = "USD"; order.purchase_units[0].amount.breakdown.tax_total.value = tax; order.purchase_units[0].items = new PaypalOrderPurchaseUnitItem[items.Length]; for (int i = 0; i < items.Length; i++) { var item = await _itemRepo.GetById(items[i].id); order.purchase_units[0].items[i] = new PaypalOrderPurchaseUnitItem { name = item.name, quantity = items[i].quantity, sku = items[i].id.ToString(), unit_amount = new UnitAmount { currency_code = "USD", value = item.price, } }; } /* * * order.purchase_units[0].items[0] = new Item(); * order.purchase_units[0].items[0].name = "Kim Cuong"; * order.purchase_units[0].items[0].quantity = 1; * order.purchase_units[0].items[0].sku = "123456"; * order.purchase_units[0].items[0].unit_amount = new UnitAmount(); * order.purchase_units[0].items[0].unit_amount.currency_code = "USD"; * order.purchase_units[0].items[0].unit_amount.value = 1; * * order.purchase_units[0].items[1] = new Item(); * order.purchase_units[0].items[1].name = "Ngoc Trai"; * order.purchase_units[0].items[1].quantity = 1; * order.purchase_units[0].items[1].sku = "654321"; * order.purchase_units[0].items[1].unit_amount = new UnitAmount(); * order.purchase_units[0].items[1].unit_amount.currency_code = "USD"; * order.purchase_units[0].items[1].unit_amount.value = 1; */ return(order); }
public CardIndexViewModel() { CardProductVMList = new List <CardProductViewModel>(); PayOrder = new PaypalOrder(); }
public CardIndexVM() { CardProductVMList = new List <CardProductVM>(); PayOrder = new PaypalOrder(); }