/// <summary> /// Handle click event PermitBut when process rent bike transaction /// </summary> private async void PermitButWhenRentBike() { Config.RENT_BIKE_STATUS = Config.RENT_BIKE.RENTING_BIKE; ProcessTransactionResponse result = await InterbankService.ProcessTransaction(Config.CARD_INFO, Config.API_INFO.COMMAND.PAY, this.deposit, DateTime.Now, noteTxt.Text == ""? "Transaction content" : noteTxt.Text); string error = result.errorCode; if (error == "00") { Transaction transaction = rentBikeController.CreateDepositTransaction(1, Config.RENTAL_BIKE.QRCode, 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; } this.transactionId = transaction.TransactionId; rentBikeForm.FillRentingBikeForm(); rentBikeController.BeginRentingBike(Config.RENTAL_BIKE.BikeId); rentBikeForm.Show(this, Config.RENT_BIKE_STATUS); } else if (error == "01" || error == "02" || error == "05") { MessageBox.Show(API_INFO.ERROR_CODE[result.errorCode], "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); cardInformationForm.Show(this); } else { MessageBox.Show(API_INFO.ERROR_CODE[result.errorCode], "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Hide(); }
/// <summary> /// Handle click event PermitBut when process pay rental money transaction /// </summary> private async void PermitButWhenPay() { Config.RENT_BIKE_STATUS = Config.RENT_BIKE.RENT_BIKE; ProcessTransactionResponse response = null; if (this.deposit < this.rentalMoney) { response = await InterbankService.ProcessTransaction(Config.CARD_INFO, API_INFO.COMMAND.PAY, this.rentalMoney - this.deposit, DateTime.Now, "Pay Rental Money"); } else if (this.deposit > this.rentalMoney) { response = await InterbankService.ProcessTransaction(Config.CARD_INFO, API_INFO.COMMAND.REFUND, this.deposit - this.rentalMoney, DateTime.Now, "Refund deposit"); } string error = response.errorCode; if (error == "00") { Transaction transaction = returnBikeController.UpdatePaymentTransaction(transactionId, this.rentalMoney); returnBikeController.UpdateStationAfterReturnbike(this.stationId, RENTAL_BIKE_CATEGORY); MessageBox.Show("giao dịch thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); homePageForm.Show(this); } this.Hide(); }
public void ProcessTransactionNotEnoughMoneyTest() { Task <ProcessTransactionResponse> response = InterbankService.ProcessTransaction(testCard, COMMAND.PAY, 700000, DateTime.Now, "Pay Deposit"); response.Wait(); ProcessTransactionResponse result = response.Result; Assert.AreEqual("02", result.errorCode); }