예제 #1
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);
        }
예제 #2
0
        public UnionpayGatewayTest(ITestOutputHelper output)
        {
            _output = output;

            _merchant = new Merchant
            {
                AppId     = "777290058110048",
                CertPwd   = "000000",
                CertPath  = Environment.CurrentDirectory + "\\acp_test_sign.pfx",
                NotifyUrl = "http://localhost:61337/Notify",
                FrontUrl  = "http://localhost:61337/Notify"
            };

            _order = new Order()
            {
                Amount = 0.01,
            };

            _unionGateway = new UnionpayGateway(_merchant);
        }
예제 #3
0
        public static IGateways UseUnionpay(this IGateways gateways, IConfiguration configuration)
        {
            var merchants = configuration.GetSection("PaySharp:Unionpays").Get <Merchant[]>();

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

                    gateways.Add(unionpayGateway);
                }
            }

            return(gateways);
        }