mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2026-02-11 10:16:20 +08:00
feat(wxapi): 新增小游戏虚拟支付 2.0 相关接口
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<xml>
|
||||
<CreateTime>1583202606</CreateTime>
|
||||
<MsgType><![CDATA[event]]></MsgType>
|
||||
<Event><![CDATA[minigame_coin_deliver_completed]]></Event>
|
||||
<MiniGame>
|
||||
<Payload>{"OpenId":"to_user_openid","OutTradeNo":"xxxxxxx","WeChatPayInfo":{"MchOrderNo":"xxxxxxx","TransactionId":"xxxxxxx"},"Env":0,"CoinInfo":{"ZoneId":"1","TotalPrice":100,"BuyQuantity":1,"OrigPrice":100}}</Payload>
|
||||
<PayEventSig>f749f67b751fa80f27ddc0b7c8d2821aeda162ea22b323cd64a2c8056c2736f0</PayEventSig>
|
||||
<IsMock>true</IsMock>
|
||||
</MiniGame>
|
||||
</xml>
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"offer_id": "12345678",
|
||||
"openid": "oUrsfxxxxxxxxxx",
|
||||
"ts": 1668512806,
|
||||
"zone_id": "1",
|
||||
"env": 0,
|
||||
"bill_no": "test_cancel_pay_1668512806",
|
||||
"pay_bill_no": "test_pay_1668512428",
|
||||
"amount": 1
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"bill_no": "test_cancel_pay_1668512806"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"offer_id": "12345678",
|
||||
"openid": "oUrsfxxxxxxxxxx",
|
||||
"ts": 1668512543,
|
||||
"zone_id": "1",
|
||||
"env": 0
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"balance": 11,
|
||||
"present_balance": 1,
|
||||
"sum_save": 10,
|
||||
"sum_present": 1,
|
||||
"sum_balance": 11,
|
||||
"sum_cost": 0,
|
||||
"first_save": false
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"offer_id": "12345678",
|
||||
"openid": "oUrsfxxxxxxxxxx",
|
||||
"ts": 1668512428,
|
||||
"zone_id": "1",
|
||||
"env": 0,
|
||||
"bill_no": "test_pay_1668512428",
|
||||
"amount": 1,
|
||||
"payitem": "钻石",
|
||||
"remark": "测试"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"bill_no": "test_pay_1668512428",
|
||||
"balance": 10,
|
||||
"used_present_amount": 1
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"offer_id": "12345678",
|
||||
"openid": "oUrsfxxxxxxxxxx",
|
||||
"ts": 1668512716,
|
||||
"zone_id": "1",
|
||||
"env": 0,
|
||||
"bill_no": "test_present_1668512716",
|
||||
"amount": 1
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"bill_no": "test_present_1668512716",
|
||||
"balance": 11
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class TestCase_DeliveryRequestSignatureTests
|
||||
{
|
||||
[Fact(DisplayName = "测试用例:即时配送请求签名")]
|
||||
public async Task TestDeliveryRequestSignature()
|
||||
{
|
||||
var client = new WechatApiClient(new WechatApiClientOptions()
|
||||
{
|
||||
AppId = "",
|
||||
AppSecret = "",
|
||||
ImmeDeliveryAppKey = "test_shop_id",
|
||||
ImmeDeliveryAppSecret = "test_app_secrect"
|
||||
});
|
||||
var request = new Models.CgibinExpressLocalBusinessTestUpdateOrderRequest()
|
||||
{
|
||||
ShopOrderId = "test_shop_order_id"
|
||||
};
|
||||
var response = await client.ExecuteCgibinExpressLocalBusinessTestUpdateOrderAsync(request);
|
||||
|
||||
Assert.Equal("a93d8d6bae9a9483c1b1d4e8670e7f6226ec94cb", request.DeliverySignature, ignoreCase: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class TestCase_MidasRequestSignatureTests
|
||||
{
|
||||
[Fact(DisplayName = "测试用例:米大师请求签名")]
|
||||
public async Task TestMidasRequestSignature()
|
||||
{
|
||||
var client = new WechatApiClient(new WechatApiClientOptions()
|
||||
{
|
||||
AppId = "wx1234567",
|
||||
AppSecret = "",
|
||||
MidasAppKey = "zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u"
|
||||
});
|
||||
var request = new Models.CgibinMidasGetBalanceRequest()
|
||||
{
|
||||
OpenId = "odkx20ENSNa2w5y3g_qOkOvBNM1g",
|
||||
MidasOfferId = "12345678",
|
||||
MidasZoneId = "1",
|
||||
Platform = "android",
|
||||
Timestamp = 1507530737
|
||||
};
|
||||
var response = await client.ExecuteCgibinMidasGetBalanceAsync(request);
|
||||
|
||||
Assert.Equal("1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b", request.Signature, ignoreCase: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class TestCase_RequestSignatureTests
|
||||
{
|
||||
[Fact(DisplayName = "测试用例:即时配送请求签名")]
|
||||
public async Task TestImmeDeliveryRequestSignature()
|
||||
{
|
||||
var mockClient = new WechatApiClient(new WechatApiClientOptions()
|
||||
{
|
||||
AppId = "",
|
||||
AppSecret = "",
|
||||
ImmeDeliveryAppKey = "test_shop_id",
|
||||
ImmeDeliveryAppSecret = "test_app_secrect"
|
||||
});
|
||||
|
||||
var request = new Models.CgibinExpressLocalBusinessTestUpdateOrderRequest()
|
||||
{
|
||||
ShopOrderId = "test_shop_order_id"
|
||||
};
|
||||
var response = await mockClient.ExecuteCgibinExpressLocalBusinessTestUpdateOrderAsync(request); // 这里不关心响应结果,只为获得预处理请求
|
||||
|
||||
Assert.Equal("a93d8d6bae9a9483c1b1d4e8670e7f6226ec94cb", request.DeliverySignature, ignoreCase: true);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:米大师虚拟支付 1.0 请求签名")]
|
||||
public async Task TestMidasRequestSignature()
|
||||
{
|
||||
var mockClient = new WechatApiClient(new WechatApiClientOptions()
|
||||
{
|
||||
AppId = "wx1234567",
|
||||
AppSecret = "",
|
||||
MidasOfferId = "12345678",
|
||||
MidasAppKey = "zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u"
|
||||
});
|
||||
|
||||
var request = new Models.CgibinMidasGetBalanceRequest()
|
||||
{
|
||||
OpenId = "odkx20ENSNa2w5y3g_qOkOvBNM1g",
|
||||
MidasZoneId = "1",
|
||||
Platform = "android",
|
||||
Timestamp = 1507530737
|
||||
};
|
||||
var response = await mockClient.ExecuteCgibinMidasGetBalanceAsync(request); // 这里不关心响应结果,只为获得预处理请求
|
||||
|
||||
Assert.Equal("1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b", request.Signature, ignoreCase: true);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:米大师虚拟支付 2.0 请求签名")]
|
||||
public async Task TestMidasRequestSignatureV2()
|
||||
{
|
||||
var mockClient = new WechatApiClient(new WechatApiClientOptions()
|
||||
{
|
||||
AppId = "wx1234567",
|
||||
AppSecret = "",
|
||||
MidasOfferIdV2 = "12345678",
|
||||
MidasAppKeyV2 = "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.WxaGameGetBalanceRequest()
|
||||
{
|
||||
OpenId = "oUrsfxxxxxxxxxx",
|
||||
OfferId = "12345678",
|
||||
ZoneId = "1",
|
||||
Environment = 0,
|
||||
Timestamp = 1668136271,
|
||||
SessionKey = "9hAb/NEYUlkaMBEsmFgzig=="
|
||||
};
|
||||
var response = await mockClient.ExecuteWxaGameGetBalanceAsync(request); // 这里不关心响应结果,只为获得预处理请求
|
||||
|
||||
Assert.Equal("7ec6d737f118b0c898de39ef1b6b199c48290e699495364fe9d069597a7da125", request.Signature, ignoreCase: true);
|
||||
Assert.Equal("5fc5460b23b2589efb8adbc2cf08d7a9cd8892b33e084249a26455b7880741a8", request.PaySign, ignoreCase: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user