|
@@ -10,6 +10,7 @@ using Aop.Api.Response;
|
|
|
using Aop.Api.Util;
|
|
|
using System.Collections;
|
|
|
using MySystem.MainModels;
|
|
|
+using Newtonsoft.Json;
|
|
|
|
|
|
namespace MySystem
|
|
|
{
|
|
@@ -19,7 +20,7 @@ namespace MySystem
|
|
|
private string AppId = "2021003116616751";
|
|
|
private string PrivateKey = "MIIEpAIBAAKCAQEA1KjMzZJIRG6QQ3+c/euVrc+8RR0xMw6A+EONSKhJq4Bg+rtxQPCfdF2bpZ4NMaSqfalSiLoxrZSYBYOZhpDP67i9LXGUoFCWdRL7ROTqJvuU6KyEeMplQ6Q3uwWbuKbh9COt0vhqn/pjlUsomTwq+DRQv10awynkZikqceXdP0EH4iGZG0hyerEP5yLHpHiggf4f7TOsovHX+fGLPmWFO1zUTHHbz7HxU4BQKn3yuje4yMhoyv5h/wZzeVwvj+Qti8Hlh351rF0f5BHwN1YMGIrWuPU5bF8OMHS/UXPxh7Bs795ZZyplYztTz26QfKfLWVVsLOng4pvgPS+OgzZydwIDAQABAoIBAEu6mMQT9Zw46zK+PP/HZxPwSBEsphqSbab7F1LqauGh4+cl3NzNU1szAnxl3jjxdK0vIO8DrzErGz/Lb16WLxS4QtXt/olgaVPjoIsWIbQkHxEEbmA9YvZFgnsdMij9dLVmBz57rCywE8pUa262GG8u4hpjY2Zggq9GtZC91J3zOeETBG828gU+FLHGcDpfz7pD1jC0noDfDRxmIImOMZvChIvvY+tm6MpySXN8lw1vxhLc0aZbKSQkuVyCyB4fIsdJJvh2dRPiY+BA0jXNK3mWwnnHzac/9JXqWFlwk6iPIIjXPUldz7Zq3EpCI+9p+UqLtIu6BAUbk1biFTt8xMECgYEA+2iIxZfdl1N1suA/aEbUdjd0kxeeOsGv7Ps0rOYn+4/q1dkUukg2V6VRy3E8BUt+9zLPTR8DmL7oBi+kDsGehjHlH7U6Pe8qKszB4ufQBDHc71yg9liqOWa4s9VoBD0VIU9CO0HtYjRor7rVuUzp+j58SLP7wIEPG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795ZZyplYztTz26QfKfLWVVsLOng4pvgPS+OgzZydwIDAQAB";
|
|
|
- private string AlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxycehrmnTl2IaIAECP+0HWc1eWGM/T6x022K7K6fdf+xoyC97TBJaG4G3Bcon4gsJX+Sad5IA9OJIQ4eN1joM35hIlwcFZ6MmCuVXx/SMAKThIjK0jsRc6aTxVQG+GVCgS7dXMKb4Sm+vK2wEM6xtDeqcfYMB0BqGZRvxbIV59a2ooPrha4FkV6nNC9DQefzC0picHXV64oYUjMM2ed4ASTQVds7HP9BZfalz//APZcWdBV08f+xv7n79Twz/gNtVAadfuTAlcjsS6aK+G/OrZtr/diuemeRPRUKlVhcr5xOQDhqBgtdIw8M9Wp6I4ULXRlthKVBWToH9j6n9vDIiwIDAQAB";
|
|
|
+ public string AlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxycehrmnTl2IaIAECP+0HWc1eWGM/T6x022K7K6fdf+xoyC97TBJaG4G3Bcon4gsJX+Sad5IA9OJIQ4eN1joM35hIlwcFZ6MmCuVXx/SMAKThIjK0jsRc6aTxVQG+GVCgS7dXMKb4Sm+vK2wEM6xtDeqcfYMB0BqGZRvxbIV59a2ooPrha4FkV6nNC9DQefzC0picHXV64oYUjMM2ed4ASTQVds7HP9BZfalz//APZcWdBV08f+xv7n79Twz/gNtVAadfuTAlcjsS6aK+G/OrZtr/diuemeRPRUKlVhcr5xOQDhqBgtdIw8M9Wp6I4ULXRlthKVBWToH9j6n9vDIiwIDAQAB";
|
|
|
public AlipayFunction(HttpContext context)
|
|
|
{
|
|
|
_context = context;
|
|
@@ -194,22 +195,36 @@ namespace MySystem
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public string CreateTrade(string OrderNo, string Subject, string Amount, string BuyerId, string Notify_Url, string Token)
|
|
|
+ public string CreateTrade(string OrderNo, string Subject, decimal Amount, string BuyerId, string MerPid, string Notify_Url)
|
|
|
{
|
|
|
IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
|
|
|
AlipayTradeCreateRequest request = new AlipayTradeCreateRequest();
|
|
|
request.SetNotifyUrl(Notify_Url);
|
|
|
- request.BizContent = "{" +
|
|
|
- "\"out_trade_no\":\"" + OrderNo + "\"," +
|
|
|
- "\"total_amount\":" + Amount + "," +
|
|
|
- "\"subject\":\"" + Subject + "\"," +
|
|
|
- "\"buyer_id\":\"" + BuyerId + "\"," +
|
|
|
- "\"timeout_express\":\"10m\"" +
|
|
|
- "}";
|
|
|
+ Dictionary<string, object> bizContent = new Dictionary<string, object>();
|
|
|
+ bizContent.Add("out_trade_no", OrderNo);
|
|
|
+ bizContent.Add("total_amount", Amount);
|
|
|
+ bizContent.Add("subject", Subject);
|
|
|
+ // bizContent.Add("seller_id", MerPid);
|
|
|
+ bizContent.Add("buyer_id", BuyerId);
|
|
|
+ bizContent.Add("timeout_express", "10m");
|
|
|
+
|
|
|
+ // 结算信息,按需传入
|
|
|
+ // Dictionary<string, object> settleInfo = new Dictionary<string, object>();
|
|
|
+ // List<object> settleDetailInfos = new List<object>();
|
|
|
+ // Dictionary<string, object> settleDetail = new Dictionary<string, object>();
|
|
|
+ // settleDetail.Add("trans_in_type", "userId");
|
|
|
+ // settleDetail.Add("trans_in", MerPid);
|
|
|
+ // settleDetail.Add("amount", Amount);
|
|
|
+ // settleDetailInfos.Add(settleDetail);
|
|
|
+ // settleInfo.Add("settle_detail_infos", settleDetailInfos);
|
|
|
+ // bizContent.Add("settle_info", settleInfo);
|
|
|
+
|
|
|
+ string Contentjson = JsonConvert.SerializeObject(bizContent);
|
|
|
+ request.BizContent = Contentjson;
|
|
|
string result = "";
|
|
|
try
|
|
|
{
|
|
|
- AlipayTradeCreateResponse response = client.Execute(request, null, Token);
|
|
|
+ AlipayTradeCreateResponse response = client.Execute(request, null, "202306BB117e046cfc29434c8f4acfd2a43aeX03");
|
|
|
result = response.Body;
|
|
|
function.WriteLog(DateTime.Now.ToString() + "\n" + result, "支付宝统一收单交易创建");
|
|
|
}
|