From 860ae10d41943210212503d8b6d71a4ff843fefb Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 12 Jun 2019 23:00:33 -0500 Subject: [PATCH] feat: add payment information validation messages --- .../Components/NmiViewComponent.cs | 11 +------- .../Views/PaymentInfo.cshtml | 26 +++++++++++++++++-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Nixtus.Plugin.Payments.Nmi/Components/NmiViewComponent.cs b/Nixtus.Plugin.Payments.Nmi/Components/NmiViewComponent.cs index 79f0acc..4be6145 100644 --- a/Nixtus.Plugin.Payments.Nmi/Components/NmiViewComponent.cs +++ b/Nixtus.Plugin.Payments.Nmi/Components/NmiViewComponent.cs @@ -1,5 +1,4 @@ -using System.Net; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Nixtus.Plugin.Payments.Nmi.Models; using Nop.Web.Framework.Components; @@ -12,14 +11,6 @@ public IViewComponentResult Invoke() { var model = new PaymentInfoModel(); - //set postback values (we cannot access "Form" with "GET" requests) - if (Request.Method == WebRequestMethods.Http.Get) - return View("~/Plugins/Payments.Nmi/Views/PaymentInfo.cshtml", model); - - var form = Request.Form; - model.CardNumber = form["CardNumber"]; - model.CardCode = form["CardCode"]; - return View("~/Plugins/Payments.Nmi/Views/PaymentInfo.cshtml", model); } } diff --git a/Nixtus.Plugin.Payments.Nmi/Views/PaymentInfo.cshtml b/Nixtus.Plugin.Payments.Nmi/Views/PaymentInfo.cshtml index f95a647..0a31c19 100644 --- a/Nixtus.Plugin.Payments.Nmi/Views/PaymentInfo.cshtml +++ b/Nixtus.Plugin.Payments.Nmi/Views/PaymentInfo.cshtml @@ -8,6 +8,11 @@ @using Nixtus.Plugin.Payments.Nmi @model Nixtus.Plugin.Payments.Nmi.Models.PaymentInfoModel + @@ -16,18 +21,30 @@ + + + + + + + + + + + +
@Html.LabelFor(model => model.ExpireMonth, false):
@Html.LabelFor(model => model.CardCode, false):
@@ -51,6 +68,13 @@ formSubmitted = true; $("input.payment-info-next-step-button").click(); } + }, + validationCallback: (field, status, message) => { + if (!status) { + $("#" + field + "-error").html(message); + } else { + $("#" + field + "-error").html(""); + } } }); }; @@ -61,8 +85,6 @@ //remove handler so we dont validate the form $('.payment-info-next-step-button').attr('onclick', null); - console.log('start'); - addScript(); $(".payment-info-next-step-button").on('click', (event) => {