Esempio n. 1
0
        public IActionResult Alipay(TradeType type = TradeType.Web)
        {
            var order = new Order
            {
                Amount     = 0.01,
                OutTradeNo = _outTradeNo,
                Subject    = "测测看支付宝",
                //AuthCode = "12323",
                //Scene = Alipay.Constant.BAR_CODE
                //Body = "1234",
                //ExtendParams = new ExtendParam()
                //{
                //    HbFqNum = "3"
                //},
                //GoodsDetail = new Goods[] {
                //    new Goods()
                //    {
                //        Id = "12"
                //    }
                //}
            };

            var gateway = _gateways.Get <AlipayGateway>(type);
            //(gateway as AlipayGateway).BuildRefund(new DataAction());

            //gateway.PaymentFailed += Gateway_BarcodePaymentFailed;
            var result = gateway.Payment(order);

            return(Content(result));
        }
Esempio n. 2
0
        /// <summary>
        /// 创建支付宝的支付订单
        /// </summary>
        private string CreateAlipayOrder()
        {
            var order = new Alipay.Order()
            {
                Amount     = 0.01,
                OutTradeNo = outTradeNo,
                Subject    = "测测看支付宝",
                //AuthCode = "12323",
                //Scene = Alipay.Constant.BAR_CODE
                //Body = "1234",
                //ExtendParams = new ExtendParam()
                //{
                //    HbFqNum = "3"
                //},
                //GoodsDetail = new Goods[] {
                //    new Goods()
                //    {
                //        Id = "12"
                //    }
                //}
            };

            var gateway = gateways.Get <Alipay.AlipayGateway>(GatewayTradeType.Web);

            //gateway.PaymentFailed += Gateway_BarcodePaymentFailed;

            return(gateway.Payment(order));
        }
Esempio n. 3
0
        /// <summary>
        /// 关闭支付宝的订单
        /// </summary>
        private Alipay.Notify CloseAlipayOrder(string id)
        {
            var gateway = gateways.Get(GatewayType.Alipay);

            return((Alipay.Notify)gateway.Close(new Alipay.Auxiliary
            {
                OutTradeNo = id
            }));
        }
Esempio n. 4
0
        /// <summary>
        /// 查询支付宝的订单
        /// </summary>
        private Alipay.Notify QueryAlipayOrder(string id)
        {
            var gateway = gateways.Get <Alipay.AlipayGateway>();

            return((Alipay.Notify)gateway.Query(new Alipay.Auxiliary
            {
                OutTradeNo = id
            }));
        }
        /// <summary>
        /// 查询支付宝的订单
        /// </summary>
        private Alipay.Notify RefundQueryAlipayOrder(string id)
        {
            var gateway = gateways.Get <Alipay.AlipayGateway>();

            return((Alipay.Notify)gateway.RefundQuery(new Alipay.Auxiliary
            {
                OutTradeNo = id,
                OutRefundNo = "13"
            }));
        }
Esempio n. 6
0
        /// <summary>
        /// 支付宝对账单下载
        /// </summary>
        private void AlipayBillDownload()
        {
            var gateway = gateways.Get <Alipay.AlipayGateway>();

            gateway.BillDownload(new Alipay.Auxiliary
            {
                BillType = "trade",
                BillDate = "2017-10-31"
            });
        }
Esempio n. 7
0
        /// <summary>
        /// 支付宝的订单的退款
        /// </summary>
        private Alipay.Notify RefundAlipayOrder(string id)
        {
            var gateway = gateways.Get(GatewayType.Alipay);

            return((Alipay.Notify)gateway.Refund(new Alipay.Auxiliary
            {
                OutTradeNo = id,
                RefundAmount = 123,
                OutRefundNo = "13"
            }));
        }
Esempio n. 8
0
        /// <summary>
        /// 查询支付宝的订单
        /// </summary>
        private Alipay.Notify RefundQueryAlipayOrder(string id)
        {
            var gateway = gateways.Get(GatewayType.Alipay);

            return((Alipay.Notify)gateway.RefundQuery(new Alipay.Auxiliary
            {
                OutTradeNo = id,
                TradeNo = "12",
                OutRefundNo = "123"
            }));
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        /// <summary>
        /// 获取网关
        /// </summary>
        /// <param name="gateways">网关列表</param>
        /// <returns></returns>
        public static GatewayBase GetGateway(IGateways gateways)
        {
            var         gatewayData = ReadNotifyData();
            GatewayBase gateway;

            if (IsAlipayGateway(gatewayData))
            {
                gateway = gateways.Get(GatewayType.Alipay);
            }
            else if (IsWechatpayGateway(gatewayData))
            {
                gateway = gateways.Get(GatewayType.Wechatpay);
            }
            else
            {
                gateway = new NullGateway();
            }

            gateway.GatewayData = gatewayData;
            return(gateway);
        }
Esempio n. 11
0
        /// <summary>
        /// 创建支付宝的支付订单
        /// </summary>
        private string CreateAlipayOrder()
        {
            var order = new Alipay.Order()
            {
                Amount     = 0.01,
                OutTradeNo = outTradeNo,
                Subject    = "测测看支付宝"
            };

            var gateway = _gateways.Get <Alipay.AlipayGateway>(GatewayTradeType.Web);

            return(gateway.Payment(order));
        }
Esempio n. 12
0
        public async Task AddWeChatPaymentNotifyMessage(WeChatPaymentNotifyMessageDTO model)
        {
            var orderDTO = await _orderServiceProxy.GetByOrderNo(model.OutTradeNo);

            if (orderDTO == null)
            {
                return;
            }
            var      organizationId = "";
            IGateway gateway        = null;

            organizationId = orderDTO.OrganizationId ?? "";
            WeChatAppConfiguration appConfig = null;

            if (!string.IsNullOrEmpty(organizationId))
            {
                appConfig = _wechatAppConfigurationRepository.GetFiltered(o => o.OrganizationId == organizationId).FirstOrDefault();
            }

            if (appConfig != null)
            {
                var wechatpayMerchant = new Merchant
                {
                    AppId           = appConfig.AppId,
                    MchId           = appConfig.MchId,
                    Key             = appConfig.Key,
                    AppSecret       = appConfig.AppSecret,
                    SslCertPath     = appConfig.SslCertPath,
                    SslCertPassword = appConfig.SslCertPassword,
                    NotifyUrl       = appConfig.NotifyUrl
                };

                gateway = new WechatpayGateway(wechatpayMerchant);
            }
            else
            {
                gateway = _gateways.Get <WechatpayGateway>();
            }

            var key = ((WechatpayGateway)(gateway)).Merchant.Key;

            //if (model.Sign.ToUpper() != model.ToSign(key).ToUpper()) return;

            _wechatPaymentNotifyMessageRepository.Add(new WeChatPaymentNotifyMessage
            {
                CreatedOn      = DateTime.Now,
                NotifyApiName  = "AddWeChatPaymentNotifyMessage",
                MessageContent = JsonConvert.SerializeObject(model)
            });
            _dbUnitOfWork.Commit();
        }
Esempio n. 13
0
        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();
        }
        // 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())
            {
                // 订单已支付
            }
        }
Esempio n. 15
0
        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()));
        }
        /// <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();
        }
Esempio n. 17
0
        public void Post([FromBody] string value)
        {
            var order = new Order()
            {
                Amount     = 0.01,
                OutTradeNo = "订单号",
                ProductId  = "No124",
                Body       = "夹克衫",
                Detail     = "灰色夹克衫",
                OpenId     = "kjjdlkfjsjfd",
                TradeType  = "JSAPI"
            };
            var gateway = _gateways.Get <WechatpayGateway>(GatewayTradeType.Applet);

            gateway.Payment(order);
        }
Esempio n. 18
0
        public async Task <string> GetOpenId(string code, string organizationId = null)
        {
            WeChatOpenIdResponseDTO result = null;

            BaseGateway gateway = null;

            if (string.IsNullOrEmpty(organizationId))
            {
                gateway = _gateways.Get <WechatpayGateway>();
            }
            else
            {
                WeChatAppConfiguration appConfig = _wechatAppConfigurationRepository.GetFiltered(o => o.OrganizationId == organizationId).FirstOrDefault();
                if (appConfig != null)
                {
                    var wechatpayMerchant = new PaySharp.Wechatpay.Merchant
                    {
                        AppId           = appConfig.AppId,
                        MchId           = appConfig.MchId,
                        Key             = appConfig.Key,
                        AppSecret       = appConfig.AppSecret,
                        SslCertPath     = appConfig.SslCertPath,
                        SslCertPassword = appConfig.SslCertPassword,
                        NotifyUrl       = appConfig.NotifyUrl
                    };

                    gateway = new WechatpayGateway(wechatpayMerchant);
                }
                else
                {
                    gateway = _gateways.Get <WechatpayGateway>();
                }
            }

            var reqModel = new WeChatOpenIdRequestDTO {
                AppId = gateway.Merchant.AppId, Code = code, Secret = _configuration.WeChatAppSecret
            };

            result = await _wechatApiProxy.CheckAuthCode(reqModel);

            //TODO:验签

            return(result?.OpenId ?? string.Empty);
        }
 public WechatpayController(IGateways gateways)
 {
     _gateway = gateways.Get <WechatpayGateway>();
 }
Esempio n. 20
0
 public UnionpayController(IGateways gateways)
 {
     _gateway = gateways.Get <UnionpayGateway>();
 }
Esempio n. 21
0
 public AllinpayController(IGateways gateways)
 {
     _gateway = gateways.Get <AllinpayGateway>();
 }
Esempio n. 22
0
 /// <summary>
 ///
 /// </summary>
 public CourseOrderController(IGateways gateways)
 {
     courseOrderBLL = new CourseOrderBLL();
     _gateway       = gateways.Get <WechatpayGateway>();
 }
Esempio n. 23
0
 public QpayController(IGateways gateways)
 {
     _gateway = gateways.Get <QpayGateway>();
 }
Esempio n. 24
0
 public WPController(IGateways gw)
 {
     _gateway = gw.Get <WechatpayGateway>();
 }