示例#1
0
        /// <summary>
        /// 修改订单金额接口
        /// <para>完结订单总金额与实际金额不符时,可通过该接口修改订单金额。</para>
        /// <para>充电宝场景,由于机器计费问题导致商户完结订单时扣除用户99元,用户客诉成功后,商户需要按照实际的消费金额(如10元)扣费,当服务订单支付状态处于“待支付”时,商户可使用此能力修改订单金额。</para>
        /// <para>更多详细请参考 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_17.shtml </para>
        /// </summary>
        /// <param name="data">微信支付需要POST的Data数据</param>
        /// <param name="timeOut">超时时间,单位为ms</param>
        /// <returns></returns>
        public async Task <ModifyServiceOrderReturnJson> ModifyServiceOrderAsync(ModifyServiceOrderRequestData data, int timeOut = Config.TIME_OUT)
        {
            var url = ReurnPayApiUrl($"https://api.mch.weixin.qq.com/{{0}}v3/payscore/serviceorder/{data.out_order_no}/modify");
            TenPayApiRequest tenPayApiRequest = new(_tenpayV3Setting);

            return(await tenPayApiRequest.RequestAsync <ModifyServiceOrderReturnJson>(url, data, timeOut));
        }
示例#2
0
        /// <summary>
        /// 修改订单金额测试
        /// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_17.shtml
        /// </summary>
        public void ModifyServiceOrderAsyncTest()
        {
            //如果未创建支付分订单 则创建支付分订单
            if (createServiceOrderResult is null)
            {
                CreateServiceOrderAsyncTest();
            }

            var key          = TenPayHelper.GetRegisterKey(Config.SenparcWeixinSetting);
            var TenPayV3Info = TenPayV3InfoCollection.Data[key];

            //付款项目列表
            var post_payments = new ModifyServiceOrderRequestData.Post_Payment[] { new ModifyServiceOrderRequestData.Post_Payment("SenparcUnitTest名称测试", 1, "单元测试1分", null) };
            var requestData   = new ModifyServiceOrderRequestData(createServiceOrderResult.out_order_no, TenPayV3Info.AppId, createServiceOrderResult.service_id, post_payments, null, 1, "SenparcUnitTest");

            PayScoreApis payScoreApis = new PayScoreApis();
            var          result       = payScoreApis.ModifyServiceOrderAsync(requestData).GetAwaiter().GetResult();

            Console.WriteLine("微信支付 V3 修改订单金额测试:" + result.ToJson(true));

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ResultCode.Success);
            Assert.IsTrue(result.VerifySignSuccess == true);//通过验证
        }