コード例 #1
0
        private InterbankResponse MakeResponse(string result)
        {
            InterbankResponse response = JsonConvert.DeserializeObject <InterbankResponse>(result);

            switch (response.errorCode)
            {
            case "00":
                return(response);

            case "01":
                throw new InvalidCardException();

            case "02":
                throw new NotEnoughBalanceException();

            case "03":
                throw new InternalServerErrorException();

            case "04":
                throw new SuspiciousTransactionException();

            case "05":
                throw new NotEnoughTransactionInfoException();

            case "06":
                throw new InvalidVersionException();

            case "07":
                throw new InvalidTransactionAmountException();

            default:
                throw new UnrecognizedException();
            }
        }
コード例 #2
0
        public void ResetAccountTest()
        {
            Task <InterbankResponse> response = paymentController.ResetAccount(testCard);

            response.Wait();
            InterbankResponse result = response.Result;

            Assert.AreEqual("00", result.errorCode);
        }
コード例 #3
0
        public void ProcessTransactionNotEnoughMoneyTest()
        {
            Task <InterbankResponse> response = paymentController.Pay(testCard, 700000, DateTime.Now, "Pay Deposit");

            response.Wait();
            InterbankResponse result = response.Result;

            Assert.AreEqual("02", result.errorCode);
        }
コード例 #4
0
 /// <summary>
 /// Handle click event PermitBut when process pay rental money transaction
 /// </summary>
 private async void PermitButWhenPay()
 {
     try
     {
         if (card == null)
         {
             card = rentBikeController.GetCardInformation("Group 13");
         }
         if (this.deposit == 0)
         {
             this.deposit = bike.CalculateDeposit();
         }
         InterbankResponse response = null;
         Transaction       transaction;
         if (this.deposit == this.rentalMoney)
         {
             transaction = returnBikeController.UpdatePaymentTransaction(bike.BikeId, this.rentalMoney);
             returnBikeController.UpdateStationAfterReturnbike(this.stationId, bike.BikeId);
             MessageBox.Show("giao dịch thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             homePageForm.Show(this);
             this.Hide();
             return;
         }
         if (this.deposit < this.rentalMoney)
         {
             response = await paymentController.Pay(card, this.rentalMoney - this.deposit, DateTime.Now, "Pay Rental Money");
         }
         else if (this.deposit > this.rentalMoney)
         {
             response = await paymentController.Refund(card, this.deposit - this.rentalMoney, DateTime.Now, "Refund deposit");
         }
         string error = response.errorCode;
         transaction = returnBikeController.UpdatePaymentTransaction(bike.BikeId, this.rentalMoney);
         returnBikeController.UpdateStationAfterReturnbike(this.stationId, bike.BikeId);
         MessageBox.Show("giao dịch thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         homePageForm.Show(this);
         this.Hide();
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #5
0
        /// <summary>
        /// Handle click event PermitBut when process rent bike transaction
        /// </summary>
        private async void PermitButWhenRentBike()
        {
            try
            {
                InterbankResponse result = await paymentController.Pay(card, this.deposit, DateTime.Now, noteTxt.Text == ""? "Transaction content" : noteTxt.Text);

                Transaction transaction = rentBikeController.CreateDepositTransaction(1, bike.BikeId, this.deposit);
                if (transaction == null)
                {
                    MessageBox.Show("Hệ thống không thể lưu thông tin giao dịch", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                rentingBikeForm.FillRentingBikeForm(this.bike);
                rentBikeController.BeginRentingBike(bike.BikeId);
                rentingBikeForm.Show(this, null);
                this.Hide();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }