public async Task <IActionResult> SearchReservation(PaymentSearchUserViewModel valModel) { PaymentResponseViewModel vPaymentResponse = new PaymentResponseViewModel(); List <PaymentViewModel> vListPayment = new List <PaymentViewModel>(); try { string vIdLanguageCookie = GetCookie(Constants.NameCookieIdLanguage, Constants.LanguageDefault); string vInitialsDefaultLanguage = GetCookie(Constants.NameCookieInitialsLanguage, Constants.InitialsLanguageDefault); ViewData["LanguageInitialDefault"] = vInitialsDefaultLanguage; UserViewModel vUserSession = HttpContext.Session.Get <UserViewModel>("UserSesion"); ViewData["UserDataSession"] = vUserSession; GetFilterReservation(Guid.Parse(vIdLanguageCookie), vUserSession.Id, valModel.PageNumber); vPaymentResponse = await _vPaymentService.SearchPayByUser(Startup._vFilterReservation); vListPayment = vPaymentResponse.Payments; double vRows = 1; if (vListPayment != null && vListPayment.Count > 0) { vRows = Math.Ceiling(Convert.ToDouble(vPaymentResponse.TotalRows) / Convert.ToDouble(_vRowsPerPage)); } Startup._vPageNumberReservation = valModel.PageNumber; ViewData["PageNumber"] = valModel.PageNumber; ViewData["RowsPerPage"] = vRows; if (vListPayment != null && vListPayment.Count > 0) { return(PartialView("_ReservationList", vListPayment)); } } catch (Exception) { return(RedirectToAction("Error", "Home")); } return(View(new List <PaymentViewModel>())); }
public async Task <ActionResult> Feedback(string guid = "") { var payRes = new PaymentResponseViewModel(); var userId = Functions.User.GetUserId(); var user = _db.AspNetUsers.FirstOrDefault(w => w.Id == userId); PaymentResponse payment = await _paymentClient.GetPaymentAsync(user.UniquePaymentReference); if (user.PassThrougReference == guid && user.UniquePaymentReference == payment.Id) { switch (payment.Status) { case Mollie.Api.Models.Payment.PaymentStatus.Paid: //This is our happy path, everything went well, show a successmessage to the user. Subscription subscription = new Subscription() { UserId = Functions.User.GetUserId(), Number = 10, DatePurchased = DateTime.Now, PaymentReference = payment.Id, PaymentMethod = payment.Method.ToString() }; Subscriptions.AddSubscription(_db, subscription, Server.MapPath("~\\MailTemplates\\BetalingOntvangen.html")); await _db.SaveChangesAsync(); //update user to avoid double subscriptions! var userToUpdate = _db.AspNetUsers.FirstOrDefault(w => w.Id == userId); userToUpdate.UniquePaymentReference = ""; userToUpdate.PassThrougReference = ""; await _db.SaveChangesAsync(); payRes.PassThroughId = guid; payRes.PaymentSucceeded = true; payRes.PaymentReference = user.UniquePaymentReference; payRes.SuccessMessage = "Proficiat, uw betaling is geslaagd! U hebt nu 10 lessen beschikbaar!"; break; case Mollie.Api.Models.Payment.PaymentStatus.Open: payRes.ErrorMessage = "Payment is still open, we have to reconnect to mollie"; //The payment hasn't started yet, try to relaunch the link to mollie here; break; case Mollie.Api.Models.Payment.PaymentStatus.Pending: payRes.ErrorMessage = "Payment is started, just wait a little..."; //The payment has started, wait for it. break; default: //The payment isn't paid, pending or open, we assume it's aborted: propose some actions here payRes.ErrorMessage = "Er is helaas iets misgelopen, klik op onderstaande knop om opnieuw te proberen."; break; } } else { //the guid we passed to Mollie is not mapped correctly, show an error payRes.ErrorMessage = "Er is reeds een nieuwe betaling gestart, u kan dit scherm sluiten."; } return(View(payRes)); }
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> GetPaytmResponse(PaymentResponseViewModel model) { try { string paytmChecksum = ""; Dictionary <string, string> paytmParams = new Dictionary <string, string>(); foreach (string key in Request.Form.Keys) { if (key.Equals("CHECKSUMHASH")) { paytmChecksum = Request.Form[key]; } else { paytmParams.Add(key.Trim(), Request.Form[key].Trim()); } } bool isValidChecksum = CheckSum.verifyCheckSum(ConfigurationKeys.MerchantKey, paytmParams, paytmChecksum); if (isValidChecksum) { if (model.RESPCODE == "01") { ViewBag.Message = "Payment Successfull"; } else { ViewBag.Message = "Payment Failed"; ViewBag.ErrorDetail = model.RESPMSG; } } else { ViewBag.Message = "Checksum Mismatched"; } } catch (Exception ex) { } return(View(model)); }
public async Task <PaymentResponseViewModel> SearchPayByUser(PaymentSearchUserViewModel valPaymentSearch) { PaymentResponseViewModel vResult = null; try { var vResponse = await _vApiClient.ExecuteGetWithJson <ClientResponseViewModel>("payment/ByUser", valPaymentSearch); if (vResponse == null) { return(vResult); } if (vResponse.Status == HttpStatusCode.OK) { var vClientResponse = (ClientResponseViewModel)vResponse.Content; vResult = JsonConvert.DeserializeObject <PaymentResponseViewModel>(vClientResponse.Result); } } catch (Exception ex) { string vMessage = ex.Message; vResult = null; } return(vResult); }