Ejemplo n.º 1
0
        public void TestFailOnMissingCountryCodeOfCloseOrder()
        {
            CreateOrderEuResponse response = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig())
                                             .AddOrderRow(TestingTool.CreateExVatBasedOrderRow())
                                             .AddCustomerDetails(Item.IndividualCustomer()
                                                                 .SetNationalIdNumber(TestingTool.DefaultTestIndividualNationalIdNumber))
                                             .SetCountryCode(TestingTool.DefaultTestCountryCode)
                                             .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber)
                                             .SetOrderDate(TestingTool.DefaultTestDate)
                                             .SetCurrency(TestingTool.DefaultTestCurrency)
                                             .UseInvoicePayment()
                                             .DoRequest();

            long orderId = response.CreateOrderResult.SveaOrderId;

            Assert.That(response.ResultCode, Is.EqualTo(0));
            Assert.That(response.Accepted, Is.True);

            CloseOrder closeOrder = WebpayConnection.CloseOrder(SveaConfig.GetDefaultConfig())
                                    .SetOrderId(orderId)
                                    .CloseInvoiceOrder();

            const string expectedMsg = "MISSING VALUE - CountryCode is required, use SetCountryCode(...).\n";

            Assert.That(closeOrder.ValidateRequest(), Is.EqualTo(expectedMsg));
        }
Ejemplo n.º 2
0
        public void CloseOrderConstructorTest()
        {
            Order order = new Order(1, BrokerDateTime.Make(DateTime.Now), "BP12345-RF-01", "RTS-9.13_FT", TradeAction.Sell, OrderType.Market, 10, 0, 0);

            CloseOrder closeOrder = new CloseOrder(order);

            Assert.AreEqual(order, closeOrder.Order);
            Assert.AreEqual(order.Id, closeOrder.OrderId);
            Assert.AreEqual(order.Id, closeOrder.Id);
        }
Ejemplo n.º 3
0
        static CloseOrderBack CloseOrder(string str)
        {
            var apps       = File.ReadAllLines(@"D:\cert.txt");
            var payHandle  = new PayHandle();
            var closeOrder = new CloseOrder
            {
                AppID      = apps[0],
                MchID      = apps[1],
                Key        = apps[3],
                OutTradeNO = str
            };
            var closeOrderBack = payHandle.Send(closeOrder) as CloseOrderBack;

            return(closeOrderBack);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            DatabaseInterface db = new DatabaseInterface("BANGAZONCLI_DB");

            db.CheckDatabaseTable("Customer", DbTables.Customer);
            db.CheckDatabaseTable("Product", DbTables.Product);
            db.CheckDatabaseTable("PaymentType", DbTables.PaymentType);
            db.CheckDatabaseTable("[Order]", DbTables.Order);
            db.CheckDatabaseTable("OrderProduct", DbTables.OrderProduct);
            DbInitializer.Initialize(db);

            MainMenu        menu            = new MainMenu();
            CustomerManager customerManager = new CustomerManager(db);
            OrderManager    orderManager    = new OrderManager(db);

            // Choice will hold the number entered by the user
            // after main menu ws displayed
            int choice;

            do
            {
                // Show the main menu
                choice = menu.Show();

                switch (choice)
                {
                case 1:
                    AddCustomer.DoAction(customerManager);
                    break;

                case 2:
                    ChooseActiveCustomer.DoAction(customerManager);
                    break;

                case 3:
                    AddPaymentType.DoAction(customerManager);
                    break;

                case 5:
                    AddProductToCart.DoAction(orderManager);
                    break;

                case 6:
                    CloseOrder.DoAction(orderManager);
                    break;
                }
            } while (choice != 7);
        }
Ejemplo n.º 5
0
 public JsonResult CloseOrder([FromBody] CloseOrder closeOrder)
 {
     try
     {
         _log.Info("关闭订单");
         SKCloseOrderBack closeOrderBack;
         string           message;
         var result = wxHandle.CloseOrder(closeOrder, out closeOrderBack, out message);
         return(BuildJsonResult(closeOrderBack, result, message));
     }
     catch (Exception exc)
     {
         _log.Fatal(exc, $"关闭订单:{exc.Message}");
         return(BuildJsonResult <CloseOrderBack>(null, false, exc.Message));
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 刷卡撤销订单
        /// </summary>
        /// <param name="closeOrder">撤销订单实体</param>
        /// <param name="closeOrderBack">撤销订单返回实体</param>
        /// <param name="message">错误消息</param>
        /// <returns>交易是否成功</returns>
        internal bool CloseOrder(CloseOrder closeOrder, out SKCloseOrderBack closeOrderBack, out string message)
        {
            _log.Info("刷卡撤销订单 CloseOrder 开始");
            var data = new WxPayData();

            if (string.IsNullOrEmpty(closeOrder.Out_Trade_No))
            {
                message = "商户订单号 不能为空";
                _log.Error(message);
                closeOrderBack = null;
                return(false);
            }
            data.SetValue("out_trade_no", closeOrder.Out_Trade_No);
            //刷卡撤销订单
            _log.Info("WxPayApi.Reverse");
            var result = WxPayApi.Reverse(data);

            _log.Info("CloseOrder", "CloseOrder process complete, result : " + result.ToXml());
            var return_code = result.GetValue("return_code")?.ToString().ToUpper();
            var result_code = result.GetValue("result_code")?.ToString().ToUpper();

            if (return_code == "SUCCESS" && result_code == "SUCCESS")
            {
                _log.Info("刷卡撤销订单成功!");
                closeOrderBack = new SKCloseOrderBack()
                {
                    Err_Code     = result.GetValue("err_code")?.ToString(),
                    Err_Code_Des = result.GetValue("err_code_des")?.ToString(),
                    Result_Code  = result.GetValue("return_code")?.ToString(),
                    Result_Msg   = result.GetValue("return_msg")?.ToString(),
                    Return_Code  = result.GetValue("result_code")?.ToString(),
                    Return_Msg   = result.GetValue("result_msg")?.ToString(),
                    Recall       = result.GetValue("recall")?.ToString()
                };
                message = "";
                return(true);
            }
            else
            {
                var return_msg   = result.GetValue("return_msg");
                var err_code_des = result.GetValue("err_code_des");
                message = $"{return_msg},{err_code_des}";
                _log.Error($"刷卡撤销订单失败:{message}");
                closeOrderBack = null;
                return(false);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 关闭订单
        /// </summary>
        /// <param name="close"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static CloseOrderRes CloseOrder(CloseOrder close, string key)
        {
            var url = "https://api.mch.weixin.qq.com/pay/closeorder";

            return(PayRequest <CloseOrderRes>(close, key, url));
        }
 public void TestCloseOrder()
 {
     //Testing CloseOrder function
     TestCloseOrder closeOrder = new CloseOrder();
 }
        private void Process(CommonOrderRelation commonOrderRelation)
        {
            Order order = null;
            if (this._Orders.ContainsKey(commonOrderRelation.OrderId))
            {
                order = this._Orders[commonOrderRelation.OrderId];

                if (commonOrderRelation.RelationType == OrderRelationType.Close)
                {
                    OrderRelation relation = new OrderRelation(commonOrderRelation);

                    Order openOrder = this._Orders.ContainsKey(relation.OpenOrderId) ? this._Orders[relation.OpenOrderId] : null;

                    if (openOrder != null)
                    {
                        string openOrderInfo = string.Format("{0}x{1}x{2}", openOrder.Transaction.SubmitTime.ToString("yyyy-MM-dd"), openOrder.Lot, openOrder.SetPrice);
                        relation.OpenOrderInfo = openOrderInfo;

                        CloseOrder closerOrder = new CloseOrder(order, relation.ClosedLot);
                        order.CloseOrders.Add(closerOrder);
                    }

                    order.Transaction.AddOrderRelation(relation);
                }
            }
        }
Ejemplo n.º 10
0
        public async Task HandleAsync(ICommandContext context, CloseOrder command)
        {
            var order = await context.GetAsync <Order>(command.AggregateRootId);

            order.Close();
        }
Ejemplo n.º 11
0
 public void Handle(ICommandContext context, CloseOrder command)
 {
     context.Get <Order>(command.AggregateRootId).Close();
 }