public static IGateways RegisterQpay(this IGateways gateways) { var merchants = (List <Hashtable>)ConfigurationManager.GetSection("paySharp/qpays"); if (merchants == null) { return(gateways); } foreach (var item in merchants) { var QpayGateway = new QpayGateway(new Merchant { AppId = item["appId"].ToString(), MchId = item["mchId"].ToString(), NotifyUrl = item["notifyUrl"].ToString(), Key = item["key"].ToString(), SslCertPath = item["sslCertPath"].ToString(), SslCertPassword = item["sslCertPassword"].ToString() }); var gatewayUrl = item["gatewayUrl"].ToString(); if (!string.IsNullOrEmpty(gatewayUrl)) { QpayGateway.GatewayUrl = gatewayUrl; } gateways.Add(QpayGateway); } return(gateways); }
public static IGateways UseQpay(this IGateways gateways, IConfiguration configuration) { var merchants = configuration.GetSection("PaySharp:Qpays").Get <Merchant[]>(); if (merchants != null) { for (var i = 0; i < merchants.Length; i++) { var qpayGateway = new QpayGateway(merchants[i]); var gatewayUrl = configuration.GetSection($"PaySharp:Qpays:{i}:GatewayUrl").Value; if (!string.IsNullOrEmpty(gatewayUrl)) { qpayGateway.GatewayUrl = gatewayUrl; } gateways.Add(qpayGateway); } } return(gateways); }