123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.OAShopManagement
- {
- public partial class frmActionPay : LYFZ.Software.UI.OAShopManagement.frmActionPay
- {
- public string AppId { get; set; }
- public string MchId { get; set; }
- public string subMchId { get; set; }
- public string Key { get; set; }
- public string TypeData { get; set; }
- public string SerialNumber { get; set; }
- string OrderNumber { get; set; }
- public string signtype = "RSA";
- public frmActionPay()
- {
- InitializeComponent();
- }
- public void BindInfoData(string payType, decimal amount, string _AppId, string _MchId, string _Key, string _subMchId, string _orderNumber = "",string typeData="0")
- {
- OrderNumber = _orderNumber;
- AppId = _AppId;
- MchId = _MchId;
- Key = _Key;
- subMchId = _subMchId;
- TypeData = typeData;
- if(string.IsNullOrEmpty(_orderNumber))
- {
- OrderNumber = DateTime.Now.ToString("yyMMddHHmmssffff");
- }
- base.BindInfoData(payType, amount);
- }
- protected override void WeiXinPay(string txtCode, decimal amount)
- {
- txt_AuCode.Enabled = false;
- btn_Close.Enabled = false;
- btn_OK.Enabled = false;
- LYFZ.WxPayAPI.Result<LYFZ.WxPayAPI.WxPayData> resultData;
- if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
- {
- resultData = WxPayAPI.MicroPay.Run(OrderNumber, Convert.ToInt32((amount) * 100).ToString(), txtCode
- , AppId
- , MchId
- , Key
- , subMchId, LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay);
- }
- else
- {
- if (TypeData == "0")
- {
- resultData = WxPayAPI.MicroPay.Run(OrderNumber, Convert.ToInt32((amount) * 100).ToString(), txtCode
- , LYFZ.WinAPI.SDKSecurity.DESDecrypt(AppId, frmThridPayConfig.EncryptKey)
- , LYFZ.WinAPI.SDKSecurity.DESDecrypt(MchId, frmThridPayConfig.EncryptKey)
- , LYFZ.WinAPI.SDKSecurity.DESDecrypt(Key, frmThridPayConfig.EncryptKey)
- , subMchId, LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay);
- }
- else
- {
- if (string.IsNullOrEmpty(MchId))
- {
- MchId = subMchId;
- }
-
- subMchId = "";
- resultData = WxPayAPI.MicroPay.Run(OrderNumber, Convert.ToInt32((amount) * 100).ToString(), txtCode
- , AppId
- , MchId
- , Key
- , subMchId, true);
- }
- }
- string PayMessage = resultData.Message;
-
-
- if (resultData.Data!=null)
- {
- if (!resultData.Status)
- {
- try
- {
- PayMessage = resultData.Data.GetValue("err_code_des").ToString();
- }
- catch
- {
- PayMessage = resultData.Message;
- }
-
- }
- else
- {
- PayMessage = resultData.Data.ToXml();
- }
- }
- lab_payMsg.Text = PayMessage;
- base.WeiXinPay(txtCode, amount);
- if(resultData.Status)
- {
- SerialNumber = resultData.Data.GetValue("transaction_id").ToString();
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- this.Close();
- }
- else
- {
- txt_AuCode.Text = "";
- txt_AuCode.Focus();
- txt_AuCode.Enabled = true;
- btn_Close.Enabled = true;
- btn_OK.Enabled = true;
- //this.DialogResult = System.Windows.Forms.DialogResult.No;
- }
- }
- protected override void AliyPay(string txtCode, decimal amount)
- {
- txt_AuCode.Enabled = false;
- btn_Close.Enabled = false;
- btn_OK.Enabled = false;
- LYFZ.AliF2F.Model.OrderInfo orderInfo = new AliF2F.Model.OrderInfo()
- {
- TotalSellValue = amount,
- PayAuthCode = txtCode,
- BodyInfo="付款测试",
- SerialNumber = OrderNumber+"_"+DateTime.Now.ToString("HHmmssffff"),
- Operator_id="",
- SellerAccount="",
- StoreName=""
- };
- LYFZ.AliF2F.Config.appId = this.AppId;
- LYFZ.AliF2F.Config.pid = this.MchId;
- LYFZ.AliF2F.Config.sign_type = signtype;
- if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
- {
- }
- else
- {
- if (TypeData == "0")
- {
- LYFZ.AliF2F.Config.servicePid = LYFZ.WinAPI.SDKSecurity.DESDecrypt(this.subMchId, frmThridPayConfig.EncryptKey);
- }
- }
- LYFZ.AliF2F.BarcodePayControl payControl = new LYFZ.AliF2F.BarcodePayControl();
- LYFZ.AliF2F.Result<LYFZ.AliF2F.Business.AlipayF2FPayResult> AliResult = payControl.AlipayDsPosOrder(orderInfo);
- string PayMessage = AliResult.Message;
- //string PayMessage = Json.JsonTool.ObjectToJson(AliResult.Data.response);
- if (AliResult.Data != null)
- {
- if (!AliResult.Status)
- {
- PayMessage = AliResult.Data.response.SubMsg;
- }
- else
- {
- PayMessage = LYFZ.PhotoSelectSystem.JsonTools.ObjectToJson(AliResult.Data.response);
- }
- }
- lab_payMsg.Text = PayMessage;
- if (AliResult.Status)
- {
- SerialNumber = AliResult.Data.response.TradeNo;
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- this.Close();
- }
- else
- {
- txt_AuCode.Text = "";
- txt_AuCode.Focus();
- txt_AuCode.Enabled = true;
- btn_Close.Enabled = true;
- btn_OK.Enabled = true;
- //this.DialogResult = System.Windows.Forms.DialogResult.No;
- }
- base.AliyPay(txtCode, amount);
- }
- }
- }
|