.NET Core/Payment/Controllers/PaymentController.cs
(开头部分) 8KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Payment.Model;
namespace Payment.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class PaymentController : ControllerBase
{
//所需值
public readonly static string _appid = "";//小程序ID
public readonly static string _secret = "";//小程序App/Secret
public readonly static string _mch_id = "";//商户号
public readonly static string _key = "";//微信支付的Key/Secret
/// <summary>
/// 模拟wx统一下单
/// </summary>
/// <param name="openid">前台获取用户标识</param>
/// <returns></returns>
[HttpGet]
public string GetAll(string openid, decimal amount)
{
if (openid == null)
{
return "";
}
return Getprepay_id(_appid, "支付测试", "JSAPI支付测试", _mch_id, GetRandomString(30), "http://www.weixin.qq.com/wxpay/pay.php", openid, getRandomTime(), Convert.ToInt32(amount * 100));
}
[HttpGet("{js_code}")]
public string GetOpenId(string js_code)
{
if (js_code == null)
{
return "";
}
return sendGet(js_code);
}
//微信统一下单获取prepay_id & 再次签名返回数据
private static string Getprepay_id(string appid, string attach, string body, string mch_id, string nonce_str, string notify_url, string openid, string bookingNo, int total_fee)
{
var url = "https://api.mch.weixin.qq.com/pay/unifiedorder";//微信统一下单请求地址
string strA = "appid=" + appid + "&attach=" + attach + "&body=" + body + "&mch_id=" + mch_id + "&nonce_str=" + nonce_str + "¬ify_url=" + notify_url + "&openid=" + openid + "&out_trade_no=" + bookingNo + "&spbill_create_ip=61.50.221.43&total_fee=" + total_fee + "&trade_type=JSAPI";
string strk = strA + "&key=" + _key; //key为商户平台设置的密钥key(假)
string strMD5 = MD5(strk).ToUpper();//MD5签名
后面还有 155 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
