Example #1
0
        public static IGateways RegisterWechatpay(this IGateways gateways)
        {
            var merchants = (List <Hashtable>)ConfigurationManager.GetSection("paySharp/wechatpays");

            if (merchants == null)
            {
                return(gateways);
            }

            foreach (var item in merchants)
            {
                var WechatpayGateway = new WechatpayGateway(new Merchant
                {
                    AppId           = item["appId"].ToString(),
                    MchId           = item["mchId"].ToString(),
                    NotifyUrl       = item["notifyUrl"].ToString(),
                    Key             = item["key"].ToString(),
                    AppSecret       = item["appSecret"].ToString(),
                    SslCertPath     = item["sslCertPath"].ToString(),
                    SslCertPassword = item["sslCertPassword"].ToString(),
                    PublicKey       = item["publicKey"].ToString()
                });

                var gatewayUrl = item["gatewayUrl"].ToString();
                if (!string.IsNullOrEmpty(gatewayUrl))
                {
                    WechatpayGateway.GatewayUrl = gatewayUrl;
                }

                gateways.Add(WechatpayGateway);
            }

            return(gateways);
        }
Example #2
0
        public static IGateways RegisterAllinpay(this IGateways gateways)
        {
            var merchants = (List <Hashtable>)ConfigurationManager.GetSection("paySharp/allinpays");

            if (merchants == null)
            {
                return(gateways);
            }

            foreach (var item in merchants)
            {
                var allinpayGateway = new AllinpayGateway(new Merchant
                {
                    AppId     = item["appId"].ToString(),
                    SubAppId  = item["subAppId"].ToString(),
                    MchId     = item["mchId"].ToString(),
                    Key       = item["key"].ToString(),
                    NotifyUrl = item["notifyUrl"].ToString()
                });

                var gatewayUrl = item["gatewayUrl"].ToString();
                if (!string.IsNullOrEmpty(gatewayUrl))
                {
                    allinpayGateway.GatewayUrl = gatewayUrl;
                }

                gateways.Add(allinpayGateway);
            }

            return(gateways);
        }
Example #3
0
        public static IGateways RegisterUnionpay(this IGateways gateways)
        {
            var merchants = (List <Hashtable>)ConfigurationManager.GetSection("paySharp/unionpays");

            if (merchants == null)
            {
                return(gateways);
            }

            foreach (var item in merchants)
            {
                var unionpayGateway = new UnionpayGateway(new Merchant
                {
                    AppId     = item["appId"].ToString(),
                    CertPwd   = item["certPwd"].ToString(),
                    NotifyUrl = item["notifyUrl"].ToString(),
                    CertPath  = item["certPath"].ToString(),
                    ReturnUrl = item["returnUrl"].ToString()
                });

                var gatewayUrl = item["gatewayUrl"].ToString();
                if (!string.IsNullOrEmpty(gatewayUrl))
                {
                    unionpayGateway.GatewayUrl = gatewayUrl;
                }

                gateways.Add(unionpayGateway);
            }

            return(gateways);
        }
Example #4
0
        public static IGateways RegisterAllinpay(this IGateways gateways, Action <Merchant> action)
        {
            if (action != null)
            {
                var merchant = new Merchant();
                action(merchant);
                gateways.Add(new AllinpayGateway(merchant));
            }

            return(gateways);
        }
        public static IGateways UseWechatpay(this IGateways gateways, Action <Merchant> action)
        {
            if (action != null)
            {
                var merchant = new Merchant();
                action(merchant);
                gateways.Add(new WechatpayGateway(merchant));
            }

            return(gateways);
        }
Example #6
0
        public static IGateways UseAlipay(this IGateways gateways, IConfiguration configuration)
        {
            var merchants = configuration.GetSection("Alipay").Get <Merchant[]>();

            if (merchants != null)
            {
                for (int i = 0; i < merchants.Length; i++)
                {
                    gateways.Add(new AlipayGateway(merchants[i]));
                }
            }

            return(gateways);
        }
        public static IGateways UseWechatpay(this IGateways gateways, IConfiguration configuration)
        {
            var merchants = configuration.GetSection("PaySharp:Wechatpays").Get <Merchant[]>();

            if (merchants != null)
            {
                for (int i = 0; i < merchants.Length; i++)
                {
                    var wechatpayGateway = new WechatpayGateway(merchants[i]);
                    var gatewayUrl       = configuration.GetSection($"PaySharp:Wechatpays:{i}:GatewayUrl").Value;
                    if (!string.IsNullOrEmpty(gatewayUrl))
                    {
                        wechatpayGateway.GatewayUrl = gatewayUrl;
                    }

                    gateways.Add(wechatpayGateway);
                }
            }

            return(gateways);
        }