调用微信小程序的发货接口
做的公司项目,小程序卖东西,都要接入微信的那个自己的发货接口了,对着文档用那个SKIT的做了下,直接就调相关接口就行了,不错不错,
2024年12月6日测试成功
/// <summary> /// 调用微信小程序的发货接口 /// using SKIT.FlurlHttpClient.Wechat.Api; ///using SKIT.FlurlHttpClient.Wechat.Api.Models; ///https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3 /// </summary> /// <returns></returns> /// <exception cref="Exception"></exception> public async Task<IActionResult> WxFaHuo() { var options = new WechatApiClientOptions() { AppId = "wxd64fd8b6ce00000", AppSecret = "7800000feb000000ee88c6c", }; var client = new WechatApiClient(options); //先取token var aaa = await client.ExecuteCgibinTokenAsync(new SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinTokenRequest() { GrantType = "client_credential" }); if (aaa.ErrorCode != 0) { throw new Exception("取accesstoken出错:" + aaa.ErrorMessage); } //调正式的接口 var bbb = await client.ExecuteWxaSecOrderUploadShippingInfoAsync(new SKIT.FlurlHttpClient.Wechat.Api.Models.WxaSecOrderUploadShippingInfoRequest() { AccessToken = aaa.AccessToken, OrderKey = new SKIT.FlurlHttpClient.Wechat.Api.Models.WxaSecOrderUploadShippingInfoRequest.Types.OrderKey() { OrderNumberType = 2, TransactionId = "4200000000258501830", }, LogisticsType = 3, DeliveryMode = 1, ShippingList = new List<WxaSecOrderUploadShippingInfoRequest.Types.Shipping>() { new WxaSecOrderUploadShippingInfoRequest.Types.Shipping(){ ItemDescription = "虚拟商品" } }, UploadTime = DateTimeOffset.Now, Payer = new WxaSecOrderUploadShippingInfoRequest.Types.Payer() { OpenId = "oOGeG63Rl000oybS0Fu7tDo" } }); return Content($"code:{bbb.ErrorCode}, msg:{bbb.ErrorMessage}"); }