public async Task <IActionResult> AppPay(WeChatPayAppPayViewModel viewModel) { var request = new WeChatPayUnifiedOrderRequest() { Body = viewModel.Body, OutTradeNo = viewModel.OutTradeNo, TotalFee = viewModel.TotalFee, SpbillCreateIp = viewModel.SpbillCreateIp, NotifyUrl = viewModel.NotifyUrl, TradeType = viewModel.TradeType, }; var response = await _client.ExecuteAsync(request); if (response.ReturnCode == "SUCCESS" && response.ResultCode == "SUCCESS") { var req = new WeChatPayAppCallPaymentRequest() { PrepayId = response.PrepayId, }; var parameter = await _client.ExecuteAsync(req); // 将参数(parameter)给 ios/android端 让他调起微信APP(https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5) ViewData["parameter"] = JsonConvert.SerializeObject(parameter); ViewData["response"] = response.Body; return(View()); } ViewData["response"] = response.Body; return(View()); }
public async Task <IActionResult> AppPay(WeChatPayAppPayViewModel viewModel) { var request = new WeChatPayUnifiedOrderRequest { Body = viewModel.Body, OutTradeNo = viewModel.OutTradeNo, TotalFee = viewModel.TotalFee, SpBillCreateIp = viewModel.SpBillCreateIp, NotifyUrl = viewModel.NotifyUrl, TradeType = viewModel.TradeType }; var response = await _client.ExecuteAsync(request, _optionsAccessor.Value); if (response.ReturnCode == WeChatPayCode.Success && response.ResultCode == WeChatPayCode.Success) { var req = new WeChatPayAppSdkRequest { PrepayId = response.PrepayId }; var parameter = await _client.ExecuteAsync(req, _optionsAccessor.Value); // 将参数(parameter)给 ios/android端 // 让他调起微信APP(https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5) // ViewData["parameter"] = JsonSerializer.Serialize(parameter); ViewData["response"] // = response.Body; return(Ok(response.Body)); } return(Ok(response.Body)); }