feat(wxapi): 新增小程序虚拟支付相关接口

This commit is contained in:
Fu Diwei
2023-08-27 18:53:52 +08:00
parent f8347ef9ef
commit f93d6139d1
67 changed files with 1980 additions and 16 deletions

View File

@@ -0,0 +1,21 @@
{
"ToUserName": "",
"FromUserName": "",
"CreateTime": 0,
"MsgType": "event",
"Event": "xpay_coin_pay_notify",
"OpenId": "",
"OutTradeNo": "",
"Env": 0,
"WeChatPayInfo": {
"MchOrderNo": "",
"TransactionId": "",
"PaidTime": 0
},
"CoinInfo": {
"Quantity": 0,
"OrigPrice": 0,
"ActualPrice": 0,
"Attach": ""
}
}

View File

@@ -0,0 +1,22 @@
{
"ToUserName": "",
"FromUserName": "",
"CreateTime": 0,
"MsgType": "event",
"Event": "xpay_goods_deliver_notify",
"OpenId": "",
"OutTradeNo": "",
"Env": 0,
"WeChatPayInfo": {
"MchOrderNo": "",
"TransactionId": "",
"PaidTime": 0
},
"GoodsInfo": {
"ProductId": "",
"Quantity": 0,
"OrigPrice": 0,
"ActualPrice": 0,
"Attach": ""
}
}

View File

@@ -0,0 +1,9 @@
{
"openid": "",
"env": 0,
"user_ip": "",
"pay_order_id": "",
"order_id": "",
"amount": 0,
"device_type": 0
}

View File

@@ -0,0 +1,5 @@
{
"errcode": 0,
"errmsg": "ok",
"order_id": ""
}

View File

@@ -0,0 +1,5 @@
{
"withdraw_no": "",
"withdraw_amount": "0",
"env": 0
}

View File

@@ -0,0 +1,6 @@
{
"errcode": 0,
"errmsg": "ok",
"withdraw_no": "",
"wx_withdraw_no": ""
}

View File

@@ -0,0 +1,10 @@
{
"openid": "",
"env": 0,
"user_ip": "",
"amount": 0,
"order_id": "",
"payitem": "",
"remark": "",
"device_type": 0
}

View File

@@ -0,0 +1,7 @@
{
"errcode": 0,
"errmsg": "ok",
"order_id": "",
"balance": 0,
"used_present_amount": 0
}

View File

@@ -0,0 +1,4 @@
{
"begin_ds": "20230801",
"end_ds": "20230810"
}

View File

@@ -0,0 +1,5 @@
{
"errcode": 0,
"errmsg": "ok",
"url": ""
}

View File

@@ -0,0 +1,5 @@
{
"order_id": "",
"wx_order_id": "",
"env": 0
}

View File

@@ -0,0 +1,7 @@
{
"openid": "",
"env": 0,
"order_id": "",
"amount": 0,
"device_type": 0
}

View File

@@ -0,0 +1,7 @@
{
"errcode": 0,
"errmsg": "ok",
"order_id": "",
"balance": 0,
"present_balance": 0
}

View File

@@ -0,0 +1,6 @@
{
"openid": "",
"env": 0,
"order_id": "",
"wx_order_id": ""
}

View File

@@ -0,0 +1,25 @@
{
"errcode": 0,
"errmsg": "ok",
"order": {
"order_id": "",
"create_time": 0,
"update_time": 0,
"status": 0,
"biz_type": 0,
"order_fee": 0,
"coupon_fee": 0,
"paid_fee": 0,
"order_type": 0,
"refund_fee": 0,
"paid_time": 0,
"provide_time": 0,
"biz_meta": "",
"env_type": 0,
"token": "",
"left_fee": 0,
"wx_order_id": "",
"channel_order_id": "",
"wxpay_order_id": ""
}
}

View File

@@ -0,0 +1,12 @@
{
"errcode": 0,
"errmsg": "ok",
"publish_item": [
{
"id": "",
"publish_status": 0,
"errmsg": ""
}
],
"status": 0
}

View File

@@ -0,0 +1,16 @@
{
"errcode": 0,
"errmsg": "ok",
"upload_item": [
{
"id": "",
"name": "",
"price": 0,
"remark": "",
"item_url": "",
"upload_status": 0,
"errmsg": ""
}
],
"status": 0
}

View File

@@ -0,0 +1,5 @@
{
"openid": "",
"env": 0,
"user_ip": ""
}

View File

@@ -0,0 +1,11 @@
{
"errcode": 0,
"errmsg": "ok",
"balance": 0,
"present_balance": 0,
"sum_save": 0,
"sum_present": 0,
"sum_balance": 0,
"sum_cost": 0,
"first_save_flag": 1
}

View File

@@ -0,0 +1,4 @@
{
"withdraw_no": "",
"env": 0
}

View File

@@ -0,0 +1,11 @@
{
"errcode": 0,
"errmsg": "ok",
"withdraw_no": "",
"status": 0,
"withdraw_amount": "0",
"wx_withdraw_no": "",
"withdraw_success_timestamp": 0,
"create_time": 0,
"fail_reason": ""
}

View File

@@ -0,0 +1,12 @@
{
"openid": "",
"order_id": "",
"wx_order_id": "",
"refund_order_id": "",
"left_fee": 0,
"refund_fee": 0,
"biz_meta": "",
"refund_reason": "",
"req_from": "",
"env": 0
}

View File

@@ -0,0 +1,8 @@
{
"errcode": 0,
"errmsg": "ok",
"refund_order_id": "",
"refund_wx_order_id": "",
"pay_order_id": "",
"pay_wx_order_id": ""
}

View File

@@ -0,0 +1,8 @@
{
"publish_item": [
{
"id": ""
}
],
"env": 0
}

View File

@@ -0,0 +1,12 @@
{
"upload_item": [
{
"id": "",
"name": "",
"price": 0,
"remark": "",
"item_url": ""
}
],
"env": 0
}

View File

@@ -25,7 +25,38 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
Assert.Equal("a93d8d6bae9a9483c1b1d4e8670e7f6226ec94cb", request.DeliverySignature, ignoreCase: true);
}
[Fact(DisplayName = "测试用例:米大师虚拟支付 1.0 请求签名")]
[Fact(DisplayName = "测试用例:虚拟支付请求签名")]
public async Task TestVirtualPaymentRequestSignature()
{
var mockClient = new WechatApiClient(new WechatApiClientOptions()
{
AppId = "wxtest",
AppSecret = "",
VirtualPaymentAppKey = "12345"
});
mockClient.Configure(settings =>
{
var jsonOptions = FlurlSystemTextJsonSerializer.GetDefaultSerializerOptions();
jsonOptions.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull;
jsonOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.Strict;
jsonOptions.WriteIndented = false;
settings.JsonSerializer = new FlurlSystemTextJsonSerializer(jsonOptions);
});
var request = new Models.XPayQueryUserBalanceRequest()
{
OpenId = "xxx",
Environment = 0,
UserIp = "127.0.0.1",
SessionKey = "9hAb/NEYUlkaMBEsmFgzig=="
};
var response = await mockClient.ExecuteXPayQueryUserBalanceAsync(request); // 这里不关心响应结果,只为获得预处理请求
Assert.Equal("e690cc22b6378ca9d70fe61727fabf65f0273d436813447816951989867a134c", request.Signature, ignoreCase: true);
Assert.Equal("fb4703e6b7da545a7f43428f02f2a9fa42e895704c6319d01a0aa859cf63253c", request.PaySign, ignoreCase: true);
}
[Fact(DisplayName = "测试用例:米大师 1.0 请求签名")]
public async Task TestMidasRequestSignature()
{
var mockClient = new WechatApiClient(new WechatApiClientOptions()
@@ -48,8 +79,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
Assert.Equal("1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b", request.Signature, ignoreCase: true);
}
[Fact(DisplayName = "测试用例:米大师虚拟支付 2.0 请求签名")]
public async Task TestMidasRequestSignatureV2()
[Fact(DisplayName = "测试用例:米大师 2.0 请求签名")]
public async Task TestMidasV2RequestSignature()
{
var mockClient = new WechatApiClient(new WechatApiClientOptions()
{