/// <summary> /// 在线支付 /// </summary> /// <param name="platform">支付平台配置信息</param> protected OnlinePay(PaymentPlatform platform) { Platform = platform; Name = platform.Name; Client = new HttpClient { BaseAddress = new Uri(platform.GatewayUrl) }; if (Platform.NotifyUrl.EndsWith("notify/")) { Platform.NotifyUrl = Platform.NotifyUrl + Platform.Id; } if (Platform.CallbackUrl.EndsWith("callback/")) { Platform.CallbackUrl = Platform.CallbackUrl + Platform.Id; } }
public static IOnlinePay Create(PaymentPlatform platform) { switch (platform.Id) { case 2: return(new AliPay(platform)); case 3: return(new WeixinPay(platform)); case 4: return(new AliAppPay(platform)); case 5: return(new TenPay(platform)); default: throw new NotSupportedException(); } }
public async Task <IActionResult> PaymentPlatformDetail(int?id, PaymentPlatform model) { var now = DateTime.Now; var result = new Result(); if (model.Name.IsNullOrEmpty()) { result.Error("请输入名称"); return(Json(result)); } if (model.MerchantId.IsNullOrEmpty()) { result.Error("请输入商户号"); return(Json(result)); } if (model.GatewayUrl.IsNullOrEmpty()) { result.Error("请输入网关URL"); return(Json(result)); } if (model.CallbackUrl.IsNullOrEmpty()) { result.Error("请输入回调RUL"); return(Json(result)); } if (model.NotifyUrl.IsNullOrEmpty()) { result.Error("请输入通知URL"); return(Json(result)); } if (id.HasValue && id.Value > 0) { var old = DefaultStorage.PaymentPlatformGet(id.Value); if (old == null) { result.Message = "数据不存在"; return(Json(result)); } var status = await TryUpdateModelAsync(old); if (status) { result.Status = DefaultStorage.PaymentPlatformUpdate(old); if (!result.Status) { result.Message = "更新失败"; } } else { result.Message = "参数有误"; } return(Json(result)); } model.CreatedOn = now; model.ModifiedBy = string.Empty; model.ModifiedOn = now; var newId = DefaultStorage.PaymentPlatformCreate(model); result.Status = newId > 0; if (result.Status) { result.Success(); } return(Json(result)); }
/// <summary> /// 财富通支付 /// </summary> /// <param name="platform">支付平台配置信息</param> public TenPay(PaymentPlatform platform) : base(platform) { }
private static string PaymentType => "1"; //支付类型 默认值为 1 商品购买 /// <summary> /// 支付宝支付 /// </summary> /// <param name="platform">支付平台配置信息</param> public AliAppPay(PaymentPlatform platform) : base(platform) { }
/// <summary> /// 微信支付 /// </summary> /// <param name="platform">支付平台配置信息</param> public WeixinPay(PaymentPlatform platform) : base(platform) { }