Ejemplo n.º 1
0
        public void PayParkingAsyncTest()
        {
            // 若没有创建停车入场, 则创建停车入场
            if (createParkingResult is null)
            {
                CreateParkingAsyncTest();
            }

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

            var out_order_no = string.Format("{0}{1}{2}", TenPayV3Info.MchId /*10位*/, SystemTime.Now.ToString("yyyyMMddHHmmss"), TenPayV3Util.BuildRandomStr(6));

            var parking_info = new PayParkingRequestData.Parking_Info(createParkingResult);

            // 停车场设备id
            parking_info.device_id = "{device_id}";
            // 每小时收费
            var price = 1;
            // 根据停车时间计算收费
            var amount      = new PayParkingRequestData.Amount(price * parking_info.charging_duration, "CNY");
            var requestData = new PayParkingRequestData(TenPayV3Info.AppId, "Senparc单元测试停车场扣费", null, out_order_no, "PARKING", null, notify_url, null, amount, parking_info);

            var vehicleParkingApis = new VehicleParkingApis();

            payParkingResult = vehicleParkingApis.PayParkingAsync(requestData).GetAwaiter().GetResult();

            Console.WriteLine("微信支付 V3 扣费受理接口测试结果:" + payParkingResult.ToJson(true));

            Assert.IsNotNull(payParkingResult);
            Assert.IsTrue(payParkingResult.ResultCode.Success);
            Assert.IsTrue(payParkingResult.VerifySignSuccess == true);//通过验证
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 扣费受理接口
        /// <para>商户请求扣费受理接口,会完成订单受理。微信支付进行异步扣款,支付完成后,会将订单支付结果发送给商户。</para>
        /// <para>更多详细请参考 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_8_3.shtml </para>
        /// </summary>
        /// <param name="data">微信支付需要POST的Data数据</param>
        /// <param name="timeOut">超时时间,单位为ms</param>
        /// <returns></returns>
        public async Task <PayParkingReturnJson> PayParkingAsync(PayParkingRequestData data, int timeOut = Config.TIME_OUT)
        {
            //TODO: 方法名是否恰当?
            var url = ReurnPayApiUrl(Senparc.Weixin.Config.TenPayV3Host + "/{0}v3/vehicle/transactions/parking");
            TenPayApiRequest tenPayApiRequest = new(_tenpayV3Setting);

            return(await tenPayApiRequest.RequestAsync <PayParkingReturnJson>(url, data, timeOut));
        }