public static PaymentSetting GetPaymentSettingInfoByID(int payTypeID) { PaymentSetting info = new PaymentSetting(); info.PaymentBase = new PaymentBase(); XDocument doc = XDocument.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configuration/Payment.config")); if (null != doc) { XElement root = doc.Root; XElement paymentBase = root.Element("paymentBase"); info.PaymentBase.BaseUrl = GetElementValue(paymentBase, "baseUrl"); XElement paymentModes = root.Element("paymentModes"); foreach (XElement item in paymentModes.Elements("paymentMode")) { if (payTypeID > 0) { if (item.Attribute("id").Value == payTypeID.ToString()) { info.PaymentMode = GetPaymentMode(item); break; } } } } return(info); }
public async Task <int> Update(PaymentSetting obj) { using (var con = DbHelper.GetSqlConnection()) { return(await con.ExecuteAsync(UpdateSP, new { obj.Id, obj.Tax, obj.ShippingCharge, obj.Credit_Ratio }, commandType : CommandType.StoredProcedure)); } }
public async Task <IActionResult> Setting(PaymentSettingModel model) { if (!ModelState.IsValid) { return(Operation(false, "数据验证失败")); } PaymentSetting ps = await _paymentSettingApp.GetAsync(model.Id); if (ps == null) { return(Operation(false, "数据错误")); } ps = MapperHelper.Map <PaymentSettingModel, PaymentSetting>(model, ps); var r = await _paymentSettingApp.UpdateAsync(ps, CurrentUser); if (!r.IsSuc) { return(Operation(false, r.Msg)); } return(Operation(true, "操作成功")); }
public async Task <MessengerProfileAPIResponse> SetPaymentSettingsAsync(PaymentSetting paymentSettings) { return(await SetSettings(new MessengerProfileSetting { PaymentSettings = paymentSettings })); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ProfileId,AccessKey,SecuritySign,PaymentType,RecurringFrequency")] PaymentSetting paymentSetting) { if (id != paymentSetting.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(paymentSetting); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentSettingExists(paymentSetting.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(paymentSetting)); }
/// <summary> /// 创建支付宝的支付订单 /// </summary> private string CreateAlipayOrder() { var order = new Alipay.Order() { Amount = 0.01, OutTradeNo = "35", Subject = "测测看支付宝", Body = "1234", ExtendParams = new ExtendParam() { HbFqNum = "3" }, GoodsDetail = new Goods[] { new Goods() { Id = "12" } } }; var gateway = gatewayList.GetGateway(GatewayType.Alipay); gateway.GatewayTradeType = GatewayTradeType.Web; PaymentSetting paymentSetting = new PaymentSetting(gateway, order); return(paymentSetting.Payment()); }
public void CreateRefund(GatewayType gatewayType) { var gateway = gateways.Get(gatewayType); var paymentSetting = new PaymentSetting(gateway); var refund = new Refund(); refund.OutRefundNo = "000000000000000"; paymentSetting.BuildRefund(refund); paymentSetting.BuildRefundQuery(refund); }
public async Task <IActionResult> Create([Bind("Id,ProfileId,AccessKey,SecuritySign,PaymentType,RecurringFrequency")] PaymentSetting paymentSetting) { if (ModelState.IsValid) { _context.Add(paymentSetting); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(paymentSetting)); }
public async Task <IActionResult> PrepareOrder() { if (!signInManager.IsSignedIn(User)) { return(Redirect("/account/login")); } var model = new PrepareProductViewModel(); var countries = await shippingPriceCrud.GetAll(); ViewData["Countries"] = new SelectList(countries.OrderBy(m => m.Country), "Id", "Country"); var user = await userManager.GetUserAsync(User); var carts = await context.Carts.Where(m => m.UserId.Equals(user.Id)) .Include(m => m.Product).ThenInclude(m => m.Images).ToListAsync(); List <Models.Product.Product> products = new List <Models.Product.Product>(); foreach (var item in carts) { products.Add(await productCrud.GetById(m => m.Id == item.ProductId)); model.TotalPrice += item.TotalPrice; model.Quantity.Add(item.Quantity); } if (products.Count() == 0) { return(RedirectToAction("Index", "Cart")); } model.Products = products; model.FirstName = user.FirstName; model.LastName = user.LastName; model.Email = user.Email; model.PhoneNumber = user.PhoneNumber; PaymentSetting paymentCredential = await context.PaymentManages.FirstOrDefaultAsync(); PayPal paypal = new PayPal(httpContextAccessor, context, paymentCredential.IsLive); ViewData["OrderId"] = await paypal.CreateOrder(decimal.Round(model.TotalPrice, 2, MidpointRounding.AwayFromZero), "GBP"); ViewData["ClientId"] = paymentCredential.ClientId; ViewData["ClientToken"] = HttpContext.Request.Cookies["client_token"] ?? await paypal.GenerateClientToken(); ViewData["Currency"] = "GBP"; return(View(model)); }
private void CreateTenpayOrder() { PaymentSetting paymentSetting = new PaymentSetting(GatewayType.Tenpay); paymentSetting.Merchant.UserName = "******"; paymentSetting.Merchant.Key = "000000000000000000000000000000000000000000"; paymentSetting.Merchant.NotifyUrl = new Uri("http://yourwebsite.com/Notify.aspx"); paymentSetting.Order.Amount = 0.01; paymentSetting.Order.Id = "93"; paymentSetting.Order.Subject = "测测看"; paymentSetting.Payment(); }
public JsonResult CreateOrder(GatewayType gatewayType) { var gateway = gateways.Get(gatewayType, GatewayTradeType.APP); var paymentSetting = new PaymentSetting(gateway); paymentSetting.Order = new Order() { OrderAmount = 0.01, OrderNo = DateTime.Now.ToString("yyyyMMddhhmmss"), Subject = "AppPayment", PaymentDate = DateTime.Now }; return(Json(paymentSetting.Payment())); }
// GET: QueryPayment public void QueryOrder(GatewayType gatewayType) { var gateway = gateways.Get(gatewayType); var querySetting = new PaymentSetting(gateway); // 查询时需要设置订单的Id与金额,在查询结果中将会核对订单的Id与金额,如果不相符会返回查询失败。 querySetting.Order.OrderNo = "20"; querySetting.Order.OrderAmount = 0.01; if (querySetting.QueryNow()) { // 订单已支付 } }
public void CreateOrder(GatewayType gatewayType) { var gateway = gateways.Get(gatewayType, GatewayTradeType.Wap); var paymentSetting = new PaymentSetting(gateway); paymentSetting.Order = new Order() { OrderAmount = 0.01, OrderNo = DateTime.Now.ToString("yyyyMMddhhmmss"), Subject = "WapPayment", PaymentDate = DateTime.Now }; paymentSetting.Payment(); }
public void Refund() { PaymentSetting querySetting = new PaymentSetting(GatewayType.WeChatPayment); querySetting.Merchant.AppId = "wx000000000000000"; querySetting.Merchant.Partner = "000000000000000"; querySetting.Merchant.Key = "0000000000000000000000000000000000000000"; if (querySetting.CanRefund) { var refund = new Refund(); refund.OutRefundNo = "000000000000000"; querySetting.BuildRefund(refund); querySetting.BuildRefundQuery(refund); } }
/// <summary> /// 创建支付宝的支付订单 /// </summary> private void CreateAlipayOrder() { PaymentSetting paymentSetting = new PaymentSetting(GatewayType.Alipay); paymentSetting.SetGatewayParameterValue("seller_email", "*****@*****.**"); paymentSetting.Merchant.UserName = "******"; paymentSetting.Merchant.Key = "000000000000000000000000000000000000000000"; paymentSetting.Merchant.NotifyUrl = new Uri("http://yourwebsite.com/Notify.aspx"); paymentSetting.Order.Amount = 0.01; paymentSetting.Order.Id = "35"; paymentSetting.Order.Subject = "测测看支付宝"; paymentSetting.Payment(); }
/// <summary> /// 查询财付通的订单支付状态 /// </summary> private void QueryTenpayOrder() { PaymentSetting querySetting = new PaymentSetting(GatewayType.Tenpay); querySetting.Merchant.UserName = "******"; querySetting.Merchant.Key = "0000000000000000000000000000000000000000"; // 查询时需要设置订单的Id与金额,在查询结果中将会核对订单的Id与金额,如果不相符会返回查询失败。 querySetting.Order.Id = "885"; querySetting.Order.Amount = 0.01; if (querySetting.CanQueryNow && querySetting.QueryNow()) { // 订单已支付 } }
/// <summary> /// 创建微信的支付订单 /// </summary> private void CreateWeChatPayOrder() { PaymentSetting paymentSetting = new PaymentSetting(GatewayType.WeChatPay); paymentSetting.SetGatewayParameterValue("appid", "wx000000000000000"); paymentSetting.Merchant.UserName = "******"; paymentSetting.Merchant.Key = "000000000000000000000000000000000000000000"; paymentSetting.Merchant.NotifyUrl = new Uri("http://yourwebsite.com/Notify.aspx"); paymentSetting.Order.Amount = 0.01; paymentSetting.Order.Id = "31"; paymentSetting.Order.Subject = "测测看微信"; paymentSetting.Payment(); }
private void CreateTenpayOrder() { var gateway = new TenpayGateway(); PaymentSetting paymentSetting = new PaymentSetting(gateway); //paymentSetting.Merchant.UserName = "******"; //paymentSetting.Merchant.Key = "000000000000000000000000000000000000000000"; //paymentSetting.Merchant.NotifyUrl = new Uri("http://yourwebsite.com/Notify.aspx"); paymentSetting.Order.Amount = 0.01; paymentSetting.Order.OutTradeNo = "93"; paymentSetting.Order.Body = "测测看"; paymentSetting.Payment(); }
public void CreateOrder(GatewayType gatewayType) { PaymentSetting paymentSetting = new PaymentSetting(gatewayType); paymentSetting.Merchant.AppId = "appid000000000000000"; paymentSetting.Merchant.Email = "*****@*****.**"; paymentSetting.Merchant.Partner = "000000000000000"; paymentSetting.Merchant.Key = "000000000000000000000000000000000000000000"; paymentSetting.Merchant.NotifyUrl = new Uri("http://yourwebsite.com/Notify.aspx"); paymentSetting.Merchant.ReturnUrl = new Uri("http://yourwebsite.com/Return.aspx"); paymentSetting.Order.OrderAmount = 0.01; paymentSetting.Order.OrderNo = "35"; paymentSetting.Order.Subject = "WebPayment"; paymentSetting.Payment(); }
/// <summary> /// 查询微信的订单支付状态 /// </summary> private void QueryWeChatPaymentOrder() { PaymentSetting querySetting = new PaymentSetting(GatewayType.WeChatPayment); querySetting.SetGatewayParameterValue("appid", "wx000000000000000"); querySetting.Merchant.UserName = "******"; querySetting.Merchant.Key = "0000000000000000000000000000000000000000"; // 查询时需要设置订单的Id与金额,在查询结果中将会核对订单的Id与金额,如果不相符会返回查询失败。 querySetting.Order.Id = "20"; querySetting.Order.Amount = 0.01; if (querySetting.CanQueryNow && querySetting.QueryNow()) { // 订单已支付 } }
/// <summary> /// 创建二维码订单 /// </summary> /// <param name="gatewayType">支付网关类型</param> public void CreateOrder(GatewayType gatewayType) { //通过网关类型,交易类型获取网关 var gateway = gateways.Get(gatewayType, GatewayTradeType.QRCode); //设置需要支付的订单的数据,创建支付订单URL地址或HTML表单 var paymentSetting = new PaymentSetting(gateway); paymentSetting.Order = new Order() { OrderAmount = 0.01, //订单总金额 OrderNo = DateTime.Now.ToString("yyyyMMddhhmmss"), //订单编号 Subject = "QRCodePayment", //订单主题 PaymentDate = DateTime.Now //订单支付时间 }; paymentSetting.Payment(); }
public async Task <IActionResult> PaymentSetting(PaymentSetting model) { if (!ModelState.IsValid) { return(View(model)); } model.ClientId = model.ClientId.Trim(); model.ClientSecret = model.ClientSecret.Trim(); await paymentManageCrud.Update(model); ViewData["Success"] = "Payment has been updated"; return(RedirectToAction(nameof(PaymentSetting))); }
/// <summary> /// 创建微信的支付订单 /// </summary> private string CreateWechatpayOrder() { var order = new Wechatpay.Order() { Amount = 0.01, OutTradeNo = "35", Body = "测测看微信支付", }; var gateway = gatewayList.GetGateway(GatewayType.Wechatpay); gateway.GatewayTradeType = GatewayTradeType.App; PaymentSetting paymentSetting = new PaymentSetting(gateway, order); return(paymentSetting.Payment()); }
/// <summary> /// 查询财付通的订单支付状态 /// </summary> private void QueryTenpayOrder() { var gateway = new TenpayGateway(); PaymentSetting querySetting = new PaymentSetting(gateway); //querySetting.Merchant.UserName = "******"; //querySetting.Merchant.Key = "0000000000000000000000000000000000000000"; // 查询时需要设置订单的Id与金额,在查询结果中将会核对订单的Id与金额,如果不相符会返回查询失败。 querySetting.Order.OutTradeNo = "885"; querySetting.Order.Amount = 0.01; if (querySetting.CanQueryNow && querySetting.QueryNow()) { // 订单已支付 } }
// GET: QueryPayment public void QueryOrder() { PaymentSetting querySetting = new PaymentSetting(GatewayType.WeChatPayment); querySetting.Merchant.AppId = "wx000000000000000"; querySetting.Merchant.Partner = "000000000000000"; querySetting.Merchant.Key = "0000000000000000000000000000000000000000"; // 查询时需要设置订单的Id与金额,在查询结果中将会核对订单的Id与金额,如果不相符会返回查询失败。 querySetting.Order.OrderNo = "20"; querySetting.Order.OrderAmount = 0.01; if (querySetting.CanQueryNow && querySetting.QueryNow()) { // 订单已支付 } }
public JsonResult CreateOrder(GatewayType gatewayType) { PaymentSetting paymentSetting = new PaymentSetting(gatewayType); paymentSetting.Merchant.AppId = "appid000000000000000"; paymentSetting.Merchant.Email = "*****@*****.**"; paymentSetting.Merchant.Partner = "000000000000000"; paymentSetting.Merchant.Key = "000000000000000000000000000000000000000000"; paymentSetting.Merchant.PrivateKeyPem = "yourrsa_private_key.pem"; paymentSetting.Merchant.PublicKeyPem = "yourrsa_public_key.pem"; paymentSetting.Merchant.NotifyUrl = new Uri("http://yourwebsite.com/Notify.aspx"); paymentSetting.Order.OrderAmount = 0.01; paymentSetting.Order.OrderNo = "35"; paymentSetting.Order.Subject = "AppPayment"; return(Json(paymentSetting.BuildPayParams())); }
/// <summary> /// 支付方式更新 /// </summary> /// <param name="entity"></param> /// <param name="currentUser"></param> /// <returns></returns> public async Task <R> UpdateAsync(PaymentSetting entity, CurrentUser currentUser) { var r = await _paymentSettingRep.UpdateAsync(entity); if (!r) { return(R.Err("更新失败")); } if (currentUser != null) { await _operateLogApp.InsertAsync <PaymentSetting>(currentUser, "更新支付方式", entity); } //await RemoveCacheAsync(entity.Id); return(R.Suc(entity)); }
/// <summary> /// 支付方式添加 /// </summary> /// <param name="entity"></param> /// <returns></returns> public async Task <R> CreateAsync(PaymentSetting entity, CurrentUser currentUser) { entity.Id = entity.CreateId(); entity.CreatorTime = DateTime.Now; var r = await _paymentSettingRep.InsertAsync(entity); if (r != 1) { return(R.Err("添加失败")); } if (currentUser != null) { await _operateLogApp.InsertAsync <PaymentSetting>(currentUser, "添加支付方式", entity); } return(R.Suc(entity)); }
public async Task <bool> SaveNewPaymentTerm(int invoiceDiscountOffer, int invoiceDiscountDaysOffer, int invoiceDiscountDueDate, int tenantId) { string str; bool flag = true; str = (invoiceDiscountOffer > 0 || invoiceDiscountDaysOffer > 0 ? "{0}% {1}, Net {2}" : "Net {0}"); string str1 = str; str1 = (!str1.Contains(",") ? string.Format(str1, invoiceDiscountDueDate) : string.Format(str1, invoiceDiscountOffer, invoiceDiscountDaysOffer, invoiceDiscountDueDate)); PaymentSetting paymentSetting = new PaymentSetting() { TenantId = tenantId, Setting = str1 }; await this._paymentSettingRepository.InsertAsync(paymentSetting); return(flag); }
/// <summary> /// 根据id或者商品编号获取PaymentInfo /// </summary> /// <param name="paymentModeId">id</param> /// <param name="merchantNO">商户编号</param> /// <returns></returns> private static PaymentSetting GetPaymentInfo(int paymentModeId, string merchantNO) { PaymentSetting info = new PaymentSetting(); info.PaymentBase = new PaymentBase(); XDocument doc = XDocument.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configuration/Payment.config")); if (null != doc) { XElement root = doc.Root; XElement paymentBase = root.Element("paymentBase"); info.PaymentBase.BaseUrl = GetElementValue(paymentBase, "baseUrl"); XElement paymentModes = root.Element("paymentModes"); foreach (XElement item in paymentModes.Elements("paymentMode")) { if (paymentModeId > 0) { if (item.Attribute("id").Value == paymentModeId.ToString()) { info.PaymentMode = GetPaymentMode(item); break; } } else if (!string.IsNullOrEmpty(merchantNO)) { string merchantId = GetElementValue(item, "merchantNO"); if (merchantNO == merchantId) { info.PaymentMode = GetPaymentMode(item); break; } } } } if (info.PaymentMode == null) { info.PaymentMode = new PaymentMode(); } return(info); }
/// <summary> /// Submit button click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { StoreSettingsAdmin settingsAdmin = new StoreSettingsAdmin(); PaymentSetting paymentSetting = new PaymentSetting(); //If edit mode then retrieve data first if (ItemId > 0) { paymentSetting = settingsAdmin.GetPaymentSettingByID(ItemId); if (paymentSetting.ProfileID.HasValue) { if ((paymentSetting.ProfileID != int.Parse(lstProfile.SelectedValue)) || (paymentSetting.PaymentTypeID != int.Parse(lstPaymentType.SelectedValue))) { //check if this setting already exists for this profile bool settingExists = PaymentSettingExists(); if (settingExists) { lblMsg.Text = "This Payment Option already exists for this Profile. Please select a different Payment Option."; return; } } } else { if (lstProfile.SelectedValue != "-1") { //check if this setting already exists for this profile bool settingExists = PaymentSettingExists(); if (settingExists) { lblMsg.Text = "This Payment Option already exists for this Profile. Please select a different Payment Option."; return; } } } } //set values based on user input paymentSetting.ActiveInd = chkActiveInd.Checked; paymentSetting.PaymentTypeID = int.Parse(lstPaymentType.SelectedValue); if (lstProfile.SelectedValue == "-1") { paymentSetting.ProfileID = null;//If All profiles is selected } else { paymentSetting.ProfileID = int.Parse(lstProfile.SelectedValue); } paymentSetting.DisplayOrder = Convert.ToInt32(txtDisplayOrder.Text); //paymentSetting.OfflineMode = false; //if credit card if (paymentSetting.PaymentTypeID == 0) { paymentSetting.GatewayTypeID = int.Parse(lstGateway.SelectedValue); paymentSetting.EnableAmex = chkEnableAmex.Checked; paymentSetting.EnableDiscover = chkEnableDiscover.Checked; paymentSetting.EnableMasterCard = chkEnableMasterCard.Checked; paymentSetting.EnableVisa = chkEnableVisa.Checked; paymentSetting.TestMode = chkTestMode.Checked; paymentSetting.PreAuthorize = chkPreAuthorize.Checked; paymentSetting.GatewayPassword = string.Empty; paymentSetting.TransactionKey = string.Empty; ZNodeEncryption encrypt = new ZNodeEncryption(); paymentSetting.GatewayUsername = encrypt.EncryptData(txtGatewayUserName.Text); //if authorize.net if (paymentSetting.GatewayTypeID == 1) { paymentSetting.TransactionKey = encrypt.EncryptData(txtTransactionKey.Text); } //If Verisign PayFlow pro gateway is selected else if (paymentSetting.GatewayTypeID == 2) { paymentSetting.GatewayPassword = encrypt.EncryptData(txtGatewayPassword.Text); paymentSetting.Partner = txtPartner.Text.Trim(); paymentSetting.Vendor = txtVendor.Text.Trim(); } //If Nova gateway is selected else if (paymentSetting.GatewayTypeID == 5) { paymentSetting.GatewayPassword = encrypt.EncryptData(txtGatewayPassword.Text); paymentSetting.TransactionKey = encrypt.EncryptData(txtTransactionKey.Text); } //If Paypal direct payment gateway is selected else if (paymentSetting.GatewayTypeID == 6) { paymentSetting.GatewayPassword = encrypt.EncryptData(txtGatewayPassword.Text); paymentSetting.TransactionKey = txtTransactionKey.Text; } // If World Pay gateway is selected else if (paymentSetting.GatewayTypeID == 10) { // Authorization password paymentSetting.GatewayPassword = encrypt.EncryptData(txtGatewayPassword.Text); // Installation Id paymentSetting.TransactionKey = encrypt.EncryptData(txtTransactionKey.Text); } else { paymentSetting.TransactionKey = ""; paymentSetting.GatewayPassword = encrypt.EncryptData(txtGatewayPassword.Text); } } // if Paypal else if (paymentSetting.PaymentTypeID == 2) { paymentSetting.GatewayTypeID = null; ZNodeEncryption encrypt = new ZNodeEncryption(); paymentSetting.GatewayUsername = encrypt.EncryptData(txtGatewayUserName.Text); paymentSetting.TransactionKey = txtTransactionKey.Text; paymentSetting.GatewayPassword = encrypt.EncryptData(txtGatewayPassword.Text); paymentSetting.TestMode = chkTestMode.Checked; } //if Google Checkout else if (paymentSetting.PaymentTypeID == 3) { paymentSetting.GatewayTypeID = null; //Set null value to Google ZNodeEncryption encrypt = new ZNodeEncryption(); paymentSetting.GatewayUsername = encrypt.EncryptData(txtGatewayUserName.Text); paymentSetting.GatewayPassword = encrypt.EncryptData(txtGatewayPassword.Text); paymentSetting.TestMode = chkTestMode.Checked; } else // Purchase Order { paymentSetting.GatewayTypeID = null; } bool retval = false; //Update Payment setting into database if (ItemId > 0) { retval = settingsAdmin.UpdatePaymentSetting(paymentSetting); } else { bool settingExists = settingsAdmin.PaymentSettingExists(int.Parse(lstProfile.SelectedValue), int.Parse(lstPaymentType.SelectedValue)); if (settingExists) { lblMsg.Text = "This Payment Option already exists for this Profile. Please select a different Payment Option."; return; } retval = settingsAdmin.AddPaymentSetting(paymentSetting); } if (retval) { //redirect to main page Response.Redirect("~/admin/secure/settings/payment/"); } else { //display error message lblMsg.Text = "An error occurred while updating. Please try again."; } }