//public override DApiResult<string> Pay(long orderNo, decimal price, string subject) //{ // var dict = Config.BaseParams("alipay.trade.pay"); // //业务参数 // var item = new Dictionary<string, object> // { // {"out_trade_no", orderNo}, // {"product_code", "QUICK_MSECURITY_PAY"}, // {"auth_code", "28763443825664394"}, // {"subject", subject}, // {"total_amount", price} // }; // dict.Add("biz_content", JsonHelper.ToJson(item)); // dict.Add("sign", dict.RsaSign(Config.PrivateKey, Config.Charset)); // var url = $"{Config.Gateway}?{dict.ParamsUrl()}"; // Logger.Info(JsonHelper.ToJson(dict, indented: true)); // using (var http = new HttpHelper(url, Encoding.GetEncoding(Config.Charset))) // { // var html = http.GetHtml(); // Logger.Info(html); // var dto = JsonHelper.Json<ReturnAlipayDto>(html); // if (dto?.alipay_trade_pay_response == null) // return DApiResult.Error<string>("支付接口异常"); // var result = dto.alipay_trade_pay_response; // if (result.code != "10000") // return DApiResult.Error<string>($"{result.msg}:{result.sub_msg}"); // return DApiResult.Succ(string.Empty); // } //} public override DResult <VerifyDto> Verify() { var paramDict = OnlinePayHelper.GetParams(); Logger.Info(JsonHelper.ToJson(paramDict, indented: true)); var signVerified = AlipaySignature.RsaCheck(paramDict, Config.PublicKey, Config.Charset); if (!signVerified) { return(DResult.Error <VerifyDto>("验证签名失败")); } if (paramDict.GetValue <string>("app_id") != Config.AppId) { return(DResult.Error <VerifyDto>("AppId异常")); } var dto = new VerifyDto { Id = paramDict.GetValue <string>("out_trade_no"), TradeNo = paramDict.GetValue <string>("trade_no"), TradeStatus = paramDict.GetValue <string>("trade_status"), Amount = paramDict.GetValue <decimal>("total_amount"), BuyerId = paramDict.GetValue <string>("buyer_id"), BuyerAccount = paramDict.GetValue <string>("buyer_logon_id") }; return(DResult.Succ(dto)); }
public async Task <ApiResult> VerifyCode(VerifyDto model) { if (!ModelState.IsValid) { return(BadRequest()); } var result = await _signInManager.TwoFactorSignInAsync( model.Provider, model.Code, model.RememberMe, model.RememberBrowser); if (result.Succeeded) { Ok(); } if (result.IsLockedOut) { _logger.LogWarning(7, "User account locked out."); return(BadRequest("Locked out")); } ModelState.AddModelError(string.Empty, "کد وارد شده غیر معتبر است."); return(BadRequest("Not valid code")); }
public async Task ProductDepositRequestVerifyConditionAsync(VerifyDto dto) { if (dto.Verify.HasValue && dto.Verify.Value) { var entityDto = await genericProductDepositRequestService.GetByIdAsync <ProductDepositRequestDto>(dto.Id); var walletDto = await genericWalletService.GetByUserIdAsync <WalletDto>(entityDto.CreatedUserId); var productItem = await productItemService.GetByProductIdWithWalletIdAsync(walletDto.Id, entityDto.ProductId); if (productItem == null) { productItem = await genericProductItemService.AddAsync(new ProductItemCreateDto() { CreatedUserId = entityDto.CreatedUserId, ProductId = entityDto.ProductId, WalletId = walletDto.Id, Amount = entityDto.Amount }); } else { productItem.Amount += entityDto.Amount; productItem.UpdateUserId = dto.UpdateUserId; var updateDto = mapper.Map <ProductItemUpdateDto>(productItem); await genericProductItemService.UpdateAsync(updateDto); } await genericProductItemService.Commit(); } }
public override DResult <VerifyDto> Verify() { var paramDict = OnlinePayHelper.GetParams(); Logger.Info(JsonHelper.ToJson(paramDict, indented: true)); var sign = paramDict.GetValue <string>("sign"); var checkSign = paramDict.Md5Sign(Config.PrivateKey); if (sign != checkSign) { return(DResult.Error <VerifyDto>("验证签名失败")); } if (Config.AppId != paramDict.GetValue <string>("appid")) { return(DResult.Error <VerifyDto>("AppId异常")); } var dto = new VerifyDto { Id = paramDict.GetValue <string>("out_trade_no"), TradeNo = paramDict.GetValue <string>("transaction_id"), TradeStatus = paramDict.GetValue <string>("result_code"), Amount = paramDict.GetValue <decimal>("total_fee"), BuyerId = paramDict.GetValue <string>("openid") }; return(DResult.Succ(dto)); }
public async Task DepositRequestVerifyConditionAsync(VerifyDto dto) { if (dto.Verify.HasValue && dto.Verify.Value) { var entityDto = await genericDepositRequestService.GetByIdAsync <DepositRequestDto>(dto.Id); var walletDto = await genericWalletService.GetByUserIdAsync <WalletDto>(entityDto.CreatedUserId); var exchangeResponse = await httpClient.GetFromJsonAsync <ExchangeResponse>("https://api.exchangerate.host/latest?base=TRY&symbols=USD,EUR,GBP,TRY"); var ratio = exchangeResponse.Rates.GetMoney(entityDto.MoneyType); walletDto.Money += entityDto.Amount / ratio; var updateDto = mapper.Map <WalletUpdateDto>(walletDto); updateDto.UpdateUserId = dto.UpdateUserId; await genericWalletService.UpdateAsync(updateDto); await genericWalletService.Commit(); } }