/// <summary> /// 扩展方法:获取支付网关类型编码 /// </summary> /// <param name="pCaller"></param> /// <returns></returns> public static string GetCode(this GatewayTypes pCaller) { switch (pCaller) { case GatewayTypes.WAP: return("01"); case GatewayTypes.IVR: return("03"); default: throw new NotImplementedException(); } }
public static GatewayAccount CreateSaveGatewayAccount(CMSDataContext db, GatewayTypes gatewayType) { var gatewayAccount = new GatewayAccount(); var gateway = db.Gateways.FirstOrDefault(p => p.GatewayId == (int)gatewayType); if (gateway != null) { gatewayAccount.GatewayAccountName = DatabaseTestBase.RandomString(); gatewayAccount.GatewayId = gateway.GatewayId; db.GatewayAccount.InsertOnSubmit(gatewayAccount); db.SubmitChanges(); var template = db.GatewayConfigurationTemplate.Where(p => p.GatewayId == gateway.GatewayId); CreateSaveGatewayDetails(db, gatewayAccount, template); db.SubmitChanges(); } return(gatewayAccount); }
public static GatewayAccount CreateMockPaymentProcessor(CMSDataContext db, PaymentProcessTypes processType, GatewayTypes gatewayType) { GatewayAccount account = null; var paymentProcess = db.PaymentProcess.Single(x => x.ProcessId == (int)processType); if (paymentProcess.GatewayAccountId.HasValue) { account = db.GatewayAccount.First(a => a.GatewayAccountId == paymentProcess.GatewayAccountId); } if (account == null) { account = db.GatewayAccount.First(a => a.GatewayAccountId == (int)gatewayType); paymentProcess.GatewayAccountId = account.GatewayAccountId; var details = db.GatewayDetails.Where(d => d.GatewayAccountId == account.GatewayAccountId).ToList(); foreach (var d in details) { if (d.GatewayDetailName == "GatewayTesting") { d.GatewayDetailValue = "true"; } else if (!d.IsBoolean && !d.GatewayDetailValue.HasValue()) { d.GatewayDetailValue = DatabaseTestBase.RandomString(); } } db.SubmitChanges(); } return(account); }