mirror of
https://github.com/Varorbc/PaySharp.git
synced 2026-10-29 12:41:43 +08:00
修复bug
This commit is contained in:
@@ -57,9 +57,15 @@ namespace ICanPay.Demo
|
||||
FrontUrl = "http://localhost:61377/Notify"
|
||||
};
|
||||
|
||||
gateways.Add(new AlipayGateway(alipayMerchant));
|
||||
gateways.Add(new AlipayGateway(alipayMerchant)
|
||||
{
|
||||
GatewayUrl = "https://openapi.alipaydev.com/"
|
||||
});
|
||||
gateways.Add(new WechatpayGateway(wechatpayMerchant));
|
||||
gateways.Add(new UnionpayGateway(unionpayMerchant));
|
||||
gateways.Add(new UnionpayGateway(unionpayMerchant)
|
||||
{
|
||||
GatewayUrl= "https://gateway.test.95516.com/"
|
||||
});
|
||||
|
||||
return gateways;
|
||||
});
|
||||
|
||||
@@ -18,11 +18,7 @@ namespace ICanPay.Alipay
|
||||
{
|
||||
|
||||
#region 私有字段
|
||||
#if DEBUG
|
||||
private const string GATEWAYURL = "https://openapi.alipaydev.com/gateway.do?charset=UTF-8";
|
||||
#else
|
||||
private const string GATEWAYURL = "https://openapi.alipay.com/gateway.do?charset=UTF-8";
|
||||
#endif
|
||||
|
||||
private readonly Merchant _merchant;
|
||||
|
||||
#endregion
|
||||
@@ -43,7 +39,9 @@ namespace ICanPay.Alipay
|
||||
|
||||
#region 属性
|
||||
|
||||
public override string GatewayUrl { get; set; } = GATEWAYURL;
|
||||
public override string GatewayUrl { get; set; } = "https://openapi.alipay.com/";
|
||||
|
||||
private string RequestUrl => GatewayUrl + "gateway.do?charset=UTF-8";
|
||||
|
||||
public new Merchant Merchant => _merchant;
|
||||
|
||||
@@ -75,7 +73,7 @@ namespace ICanPay.Alipay
|
||||
{
|
||||
InitFormPayment();
|
||||
|
||||
return GatewayData.ToForm(GatewayUrl);
|
||||
return GatewayData.ToForm(RequestUrl);
|
||||
}
|
||||
|
||||
public void InitFormPayment()
|
||||
@@ -94,7 +92,7 @@ namespace ICanPay.Alipay
|
||||
{
|
||||
InitUrlPayment();
|
||||
|
||||
return $"{GatewayUrl}&{GetPaymentQueryString()}";
|
||||
return $"{RequestUrl}&{GetPaymentQueryString()}";
|
||||
}
|
||||
|
||||
public void InitUrlPayment()
|
||||
@@ -426,7 +424,7 @@ namespace ICanPay.Alipay
|
||||
Task.Run(async () =>
|
||||
{
|
||||
result = await HttpUtil
|
||||
.PostAsync(GatewayUrl, GatewayData.ToUrl());
|
||||
.PostAsync(RequestUrl, GatewayData.ToUrl());
|
||||
})
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace ICanPay.Unionpay
|
||||
public double Amount
|
||||
{
|
||||
get => _amount;
|
||||
set => _amount = value * 100;
|
||||
set => _amount = value / 100;
|
||||
}
|
||||
private double _amount;
|
||||
|
||||
|
||||
@@ -20,18 +20,10 @@ namespace ICanPay.Unionpay
|
||||
|
||||
#if DEBUG
|
||||
|
||||
private const string FRONTGATEWAYURL = "https://gateway.test.95516.com/gateway/api/frontTransReq.do";
|
||||
private const string APPGATEWAYURL = "https://gateway.test.95516.com/gateway/api/appTransReq.do";
|
||||
private const string BACKGATEWAYURL = "https://gateway.test.95516.com/gateway/api/backTransReq.do";
|
||||
private const string QUERYGATEWAYURL = "https://gateway.test.95516.com/gateway/api/queryTrans.do";
|
||||
private const string FILEGATEWAYURL = "https://filedownload.test.95516.com/";
|
||||
private string FILEGATEWAYURL = "https://filedownload.test.95516.com/";
|
||||
|
||||
#else
|
||||
|
||||
private const string FRONTGATEWAYURL = "https://gateway.95516.com/gateway/api/frontTransReq.do";
|
||||
private const string APPGATEWAYURL = "https://gateway.95516.com/gateway/api/appTransReq.do";
|
||||
private const string BACKGATEWAYURL = "https://gateway.95516.com/gateway/api/backTransReq.do";
|
||||
private const string QUERYGATEWAYURL = "https://gateway.95516.com/gateway/api/queryTrans.do";
|
||||
private const string FILEGATEWAYURL = "https://filedownload.95516.com/";
|
||||
|
||||
#endif
|
||||
@@ -59,7 +51,17 @@ namespace ICanPay.Unionpay
|
||||
|
||||
#region 属性
|
||||
|
||||
public override string GatewayUrl { get; set; } = FRONTGATEWAYURL;
|
||||
public override string GatewayUrl { get; set; } = "https://gateway.95516.com/";
|
||||
|
||||
private string FrontUrl => GatewayUrl + "gateway/api/frontTransReq.do";
|
||||
|
||||
private string AppUrl => GatewayUrl + "gateway/api/appTransReq.do";
|
||||
|
||||
private string BackUrl => GatewayUrl + "gateway/api/backTransReq.do";
|
||||
|
||||
private string QueryUrl => GatewayUrl + "gateway/api/queryTrans.do";
|
||||
|
||||
private string RequestUrl { get; set; }
|
||||
|
||||
public new Merchant Merchant => _merchant;
|
||||
|
||||
@@ -97,13 +99,13 @@ namespace ICanPay.Unionpay
|
||||
{
|
||||
InitFormPayment();
|
||||
|
||||
return GatewayData.ToForm(GatewayUrl);
|
||||
return GatewayData.ToForm(RequestUrl);
|
||||
}
|
||||
|
||||
public void InitFormPayment()
|
||||
{
|
||||
InitOrderParameter();
|
||||
GatewayUrl = FRONTGATEWAYURL;
|
||||
RequestUrl = FrontUrl;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -122,7 +124,7 @@ namespace ICanPay.Unionpay
|
||||
public void InitAppPayment()
|
||||
{
|
||||
InitOrderParameter();
|
||||
GatewayUrl = APPGATEWAYURL;
|
||||
RequestUrl = AppUrl;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -143,7 +145,7 @@ namespace ICanPay.Unionpay
|
||||
Merchant.TxnSubType = "07";
|
||||
Merchant.BizType = "000000";
|
||||
InitOrderParameter();
|
||||
GatewayUrl = BACKGATEWAYURL;
|
||||
RequestUrl = BackUrl;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -163,7 +165,7 @@ namespace ICanPay.Unionpay
|
||||
Merchant.BizType = "000000";
|
||||
Merchant.ChannelType = "07";
|
||||
InitOrderParameter();
|
||||
GatewayUrl = BACKGATEWAYURL;
|
||||
RequestUrl = BackUrl;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -183,7 +185,7 @@ namespace ICanPay.Unionpay
|
||||
{
|
||||
Merchant.TxnType = "00";
|
||||
Merchant.BizType = "000000";
|
||||
GatewayUrl = QUERYGATEWAYURL;
|
||||
RequestUrl = QueryUrl;
|
||||
|
||||
InitAuxiliaryParameter(auxiliary);
|
||||
}
|
||||
@@ -204,7 +206,7 @@ namespace ICanPay.Unionpay
|
||||
public void InitCancel(IAuxiliary auxiliary)
|
||||
{
|
||||
Merchant.TxnType = "31";
|
||||
GatewayUrl = BACKGATEWAYURL;
|
||||
RequestUrl = BackUrl;
|
||||
|
||||
InitAuxiliaryParameter(auxiliary);
|
||||
}
|
||||
@@ -225,7 +227,7 @@ namespace ICanPay.Unionpay
|
||||
public void InitRefund(IAuxiliary auxiliary)
|
||||
{
|
||||
Merchant.TxnType = "04";
|
||||
GatewayUrl = BACKGATEWAYURL;
|
||||
RequestUrl = BackUrl;
|
||||
|
||||
InitAuxiliaryParameter(auxiliary);
|
||||
}
|
||||
@@ -255,7 +257,7 @@ namespace ICanPay.Unionpay
|
||||
GatewayData.Remove(Constant.BACKURL);
|
||||
GatewayData.Remove(Constant.FRONTURL);
|
||||
GatewayData.Add(Constant.SIGNATURE, BuildSign());
|
||||
GatewayUrl = FILEGATEWAYURL;
|
||||
RequestUrl = FILEGATEWAYURL;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -298,7 +300,7 @@ namespace ICanPay.Unionpay
|
||||
Task.Run(async () =>
|
||||
{
|
||||
result = await HttpUtil
|
||||
.PostAsync(GatewayUrl, GatewayData.ToUrl());
|
||||
.PostAsync(RequestUrl, GatewayData.ToUrl());
|
||||
})
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace ICanPay.Wechatpay
|
||||
public double TotalFee
|
||||
{
|
||||
get => _totalFee;
|
||||
set => _totalFee = value * 100;
|
||||
set => _totalFee = value / 100;
|
||||
}
|
||||
private double _totalFee;
|
||||
|
||||
|
||||
@@ -21,18 +21,7 @@ namespace ICanPay.Wechatpay
|
||||
#region 私有字段
|
||||
|
||||
private readonly Merchant _merchant;
|
||||
private const string UNIFIEDORDERGATEWAYURL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
|
||||
private const string QUERYGATEWAYURL = "https://api.mch.weixin.qq.com/pay/orderquery";
|
||||
private const string CANCELGATEWAYURL = "https://api.mch.weixin.qq.com/secapi/pay/reverse";
|
||||
private const string CLOSEORDERGATEWAYURL = "https://api.mch.weixin.qq.com/pay/closeorder";
|
||||
private const string REFUNDGATEWAYURL = "https://api.mch.weixin.qq.com/secapi/pay/refund";
|
||||
private const string REFUNDQUERYGATEWAYURL = "https://api.mch.weixin.qq.com/pay/refundquery";
|
||||
private const string DOWNLOADBILLGATEWAYURL = "https://api.mch.weixin.qq.com/pay/downloadbill";
|
||||
private const string REPORTGATEWAYURL = "https://api.mch.weixin.qq.com/payitil/report";
|
||||
private const string BATCHQUERYCOMMENTGATEWAYURL = "https://api.mch.weixin.qq.com/billcommentsp/batchquerycomment";
|
||||
private const string BARCODEGATEWAYURL = "https://api.mch.weixin.qq.com/pay/micropay";
|
||||
private const string ACCESSTOKENURL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code";
|
||||
private const string AUTHCODETOOPENIDURL = "https://api.mch.weixin.qq.com/tools/authcodetoopenid";
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -52,7 +41,31 @@ namespace ICanPay.Wechatpay
|
||||
|
||||
#region 属性
|
||||
|
||||
public override string GatewayUrl { get; set; } = UNIFIEDORDERGATEWAYURL;
|
||||
public override string GatewayUrl { get; set; } = "https://api.mch.weixin.qq.com/";
|
||||
|
||||
private string UnifiedOrderUrl => GatewayUrl + "pay/unifiedorder";
|
||||
|
||||
private string QueryUrl => GatewayUrl + "pay/orderquery";
|
||||
|
||||
private string CancelUrl => GatewayUrl + "secapi/pay/reverse";
|
||||
|
||||
private string CloseUrl => GatewayUrl + "pay/closeorder";
|
||||
|
||||
private string RefundUrl => GatewayUrl + "secapi/pay/refund";
|
||||
|
||||
private string RefundQueryUrl => GatewayUrl + "pay/refundquery";
|
||||
|
||||
private string DownloadBillUrl => GatewayUrl + "pay/downloadbill";
|
||||
|
||||
private string ReportUrl => GatewayUrl + "payitil/report";
|
||||
|
||||
private string BatchQueryCommentUrl => GatewayUrl + "billcommentsp/batchquerycomment";
|
||||
|
||||
private string BarcodeUrl => GatewayUrl + "pay/micropay";
|
||||
|
||||
private string AuthCodeToOpenIdUrl => GatewayUrl + "tools/authcodetoopenid";
|
||||
|
||||
private string RequestUrl { get; set; }
|
||||
|
||||
public new Merchant Merchant => _merchant;
|
||||
|
||||
@@ -64,7 +77,7 @@ namespace ICanPay.Wechatpay
|
||||
|
||||
public new Notify Notify => (Notify)base.Notify;
|
||||
|
||||
protected override bool IsSuccessPay => Notify.TradeState.ToLower() == SUCCESS;
|
||||
protected override bool IsSuccessPay => Notify.ResultCode.ToLower() == SUCCESS;
|
||||
|
||||
protected override bool IsWaitPay => Notify.TradeState.ToLower() == Constant.USERPAYING;
|
||||
|
||||
@@ -202,7 +215,7 @@ namespace ICanPay.Wechatpay
|
||||
|
||||
Commit();
|
||||
|
||||
if (Notify.ReturnCode == SUCCESS.ToUpper())
|
||||
if (Notify.ReturnCode.ToLower() == SUCCESS)
|
||||
{
|
||||
OnPaymentSucceed(new PaymentSucceedEventArgs(this));
|
||||
return;
|
||||
@@ -232,7 +245,7 @@ namespace ICanPay.Wechatpay
|
||||
{
|
||||
Order.SpbillCreateIp = HttpUtil.LocalIpAddress;
|
||||
UnifiedOrder();
|
||||
GatewayUrl = BARCODEGATEWAYURL;
|
||||
RequestUrl = BarcodeUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -244,7 +257,7 @@ namespace ICanPay.Wechatpay
|
||||
{
|
||||
Thread.Sleep(5000);
|
||||
BuildQuery(auxiliary);
|
||||
if (IsSuccessPay)
|
||||
if (Notify.TradeState.ToLower() == SUCCESS)
|
||||
{
|
||||
OnPaymentSucceed(new PaymentSucceedEventArgs(this));
|
||||
return;
|
||||
@@ -276,7 +289,7 @@ namespace ICanPay.Wechatpay
|
||||
|
||||
public void InitQuery(IAuxiliary auxiliary)
|
||||
{
|
||||
GatewayUrl = QUERYGATEWAYURL;
|
||||
RequestUrl = QueryUrl;
|
||||
InitAuxiliaryParameter(GatewayAuxiliaryType.Query, auxiliary);
|
||||
}
|
||||
|
||||
@@ -295,7 +308,7 @@ namespace ICanPay.Wechatpay
|
||||
|
||||
public void InitCancel(IAuxiliary auxiliary)
|
||||
{
|
||||
GatewayUrl = CANCELGATEWAYURL;
|
||||
RequestUrl = CancelUrl;
|
||||
InitAuxiliaryParameter(GatewayAuxiliaryType.Cancel, auxiliary);
|
||||
}
|
||||
|
||||
@@ -323,7 +336,7 @@ namespace ICanPay.Wechatpay
|
||||
|
||||
public void InitClose(IAuxiliary auxiliary)
|
||||
{
|
||||
GatewayUrl = CLOSEORDERGATEWAYURL;
|
||||
RequestUrl = CloseUrl;
|
||||
InitAuxiliaryParameter(GatewayAuxiliaryType.Close, auxiliary);
|
||||
}
|
||||
|
||||
@@ -342,7 +355,7 @@ namespace ICanPay.Wechatpay
|
||||
|
||||
public void InitRefund(IAuxiliary auxiliary)
|
||||
{
|
||||
GatewayUrl = REFUNDGATEWAYURL;
|
||||
RequestUrl = RefundUrl;
|
||||
InitAuxiliaryParameter(GatewayAuxiliaryType.Refund, auxiliary);
|
||||
}
|
||||
|
||||
@@ -361,7 +374,7 @@ namespace ICanPay.Wechatpay
|
||||
|
||||
public void InitRefundQuery(IAuxiliary auxiliary)
|
||||
{
|
||||
GatewayUrl = REFUNDQUERYGATEWAYURL;
|
||||
RequestUrl = RefundQueryUrl;
|
||||
InitAuxiliaryParameter(GatewayAuxiliaryType.RefundQuery, auxiliary);
|
||||
}
|
||||
|
||||
@@ -382,7 +395,7 @@ namespace ICanPay.Wechatpay
|
||||
|
||||
public void InitBillDownload(IAuxiliary auxiliary)
|
||||
{
|
||||
GatewayUrl = DOWNLOADBILLGATEWAYURL;
|
||||
RequestUrl = DownloadBillUrl;
|
||||
InitAuxiliaryParameter(GatewayAuxiliaryType.BillDownload, auxiliary);
|
||||
}
|
||||
|
||||
@@ -448,7 +461,7 @@ namespace ICanPay.Wechatpay
|
||||
/// <returns></returns>
|
||||
private void UnifiedOrder()
|
||||
{
|
||||
GatewayUrl = UNIFIEDORDERGATEWAYURL;
|
||||
RequestUrl = UnifiedOrderUrl;
|
||||
InitOrderParameter();
|
||||
|
||||
Commit();
|
||||
@@ -493,7 +506,7 @@ namespace ICanPay.Wechatpay
|
||||
GatewayData.Add(Constant.AUTH_CODE, Merchant.AppId);
|
||||
GatewayData.Add(Constant.NONCE_STR, Merchant.NonceStr);
|
||||
GatewayData.Add(Constant.SIGN, BuildSign());
|
||||
GatewayUrl = AUTHCODETOOPENIDURL;
|
||||
RequestUrl = AuthCodeToOpenIdUrl;
|
||||
|
||||
Commit();
|
||||
|
||||
@@ -559,7 +572,7 @@ namespace ICanPay.Wechatpay
|
||||
Task.Run(async () =>
|
||||
{
|
||||
result = await HttpUtil
|
||||
.PostAsync(GatewayUrl, GatewayData.ToXml(), cert);
|
||||
.PostAsync(RequestUrl, GatewayData.ToXml(), cert);
|
||||
})
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
||||
Reference in New Issue
Block a user