private void payAccount(object sender, EventArgs e) { try { if (Double.TryParse(payTextBox.Text, out double payment)) { SaleController saleController = new SaleController(); double verifyPayment = VerifyPayment.Verify(payment, sale); if (verifyPayment < 0) { throw new Exception($"Ainda faltam R${Math.Abs(verifyPayment).ToString("0.00")} reais"); } saleController.finishSale(sale, payment); MessageBox.Show("Compra realizada com sucesso!"); if (verifyPayment > 0) { MessageBox.Show($"Troco de: {verifyPayment.ToString("0.00")}"); } Close(); } else { MessageBox.Show("Por favor, insira um valor válido"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public IActionResult Verify(PaymentResponseViewModel model) { if (model.status == 1) { VerifyPayment verifyResult = payment.Verify(model.token.ToString()); if (verifyResult.Status == 1) { orderService.PaymentDone(model.token, verifyResult.transId); return(Content($"پرداخت با موفقیت انجام شد شماره پیگیری {verifyResult.transId}")); } } return(View(model)); }
public async Task <ActionResult> VerifyPaymentForOrder([FromRoute] int courseId, [FromBody] VerifyPayment command, CancellationToken cancellationToken) { var data = new { token = command.Token, amount = command.Amount }; using (HttpClient httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Key", key); var payload = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); using (HttpResponseMessage res = await httpClient.PostAsync(baseurl, payload)) { if (res.IsSuccessStatusCode) { using (HttpContent content = res.Content) { string response = await content.ReadAsStringAsync(); Console.WriteLine(response); // update course as paid var studentCourse = _context.CourseStudents.FirstOrDefault( x => x.CourseId == courseId && x.UserId == _authenticatedUser.UserId ); if (studentCourse == null) { return(BadRequest(new { Message = "Course not found" })); } studentCourse.Status = "purchased"; _context.CourseStudents.Update(studentCourse); _context.SaveChanges(); } } else { return(BadRequest(new { Message = "Something went wrong while making a payment, please try again" })); } } } return(Ok(new { Message = "Payment made successfull" })); }
public VerifyPayment GetVerifyPaymentRecord(int recordID, string UserID) { try { string proc = ""; VerifyPayment dp = new VerifyPayment(); SqlParameter[] Parameters = { new SqlParameter("@SNo", Convert.ToInt32(recordID)), new SqlParameter("@UserID", Convert.ToInt32(UserID)) }; if (System.Web.HttpContext.Current.Request.QueryString.ToString().Split('=')[4] == "O") { proc = "GetRecordDirectPayment_Office"; } else { proc = "GetRecordDirectPayment"; } SqlDataReader dr = SqlHelper.ExecuteReader(ReadConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, proc, Parameters); if (dr.Read()) { dp.AccountSNo = Convert.ToInt32(dr["SNo"]); dp.OfficeSNo = Convert.ToInt32(dr["OfficeSNo"]); dp.Office = dr["Office"].ToString().ToUpper(); dp.Agent = dr["Agent"].ToString().ToUpper(); dp.Amount = Convert.ToString(dr["Amount"]); dp.CreditLimit = Convert.ToString(dr["Credit"]); dp.UpdateTypeText = dr["UpdateType"].ToString(); dp.TransactionType = dr["Transaction"].ToString(); if (dp.Agent != "") { dp.CreatedUser = dr["CreatedUser"].ToString(); } if (dp.Office != "") { dp.CreatedUser = dr["OfficeCreatedUser"].ToString(); } dp.UpdatedUser = dr["UpdatedUser"].ToString(); dp.Airline = dr["Airline"].ToString(); dp.City = dr["City"].ToString(); dp.AccountNo = dr["AccountNo"].ToString(); dp.ExistingCreditLimit = Convert.ToString(dr["ExistingCreditLimit"]); dp.BankGaranteeValidFrom = dr["ValidFrom"].ToString(); dp.BankGaranteeValidTo = dr["validTo"].ToString(); dp.PaymentDate = dr["PaymentDate"].ToString(); dp.TransectionModeSNo = dr["Mode"].ToString(); dp.Remarks = dr["Remarks"].ToString(); dp.BankName = dr["BankName"].ToString(); dp.BranchName = dr["BranchName"].ToString(); dp.ChequeAccountName = dr["ChequeAccountName"].ToString(); dp.IsVerified = int.Parse(dr["IsVerified"].ToString()); dp.VerifiedRemarks = dr["VerifiedRemarks"].ToString(); dp.BankAccountNo = dr["BankAccountNo"].ToString(); if (dr["ChequeDate"].ToString() != "") { dp.ChequeDate = Convert.ToDateTime(dr["ChequeDate"].ToString()); } if (dr["TransectionDate"].ToString() != "") { dp.ChequeDate = Convert.ToDateTime(dr["TransectionDate"].ToString()); } dp.ReferenceNo = dr["ReferenceNo"].ToString(); dp.AwbNumber = dr["AwbNumber"].ToString(); // Add Awb Number by umar on 31-Aug-2018 dp.ChequeNo = dr["ChequeNo"].ToString(); dp.RefNo = dr["RefNo"].ToString(); } dr.Close(); return(dp); } catch (Exception ex)// { throw ex; } }