diff --git a/Nop.Plugin.Payments.PayGate/Controllers/PaymentPayGateController.cs b/Nop.Plugin.Payments.PayGate/Controllers/PaymentPayGateController.cs index 124cfc8..bfe9776 100644 --- a/Nop.Plugin.Payments.PayGate/Controllers/PaymentPayGateController.cs +++ b/Nop.Plugin.Payments.PayGate/Controllers/PaymentPayGateController.cs @@ -1,318 +1,333 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Web.Mvc; -using Nop.Core; -using Nop.Core.Domain.Orders; -using Nop.Core.Domain.Payments; -using Nop.Plugin.Payments.PayGate.Models; -using Nop.Services.Configuration; -using Nop.Services.Localization; -using Nop.Services.Logging; -using Nop.Services.Orders; -using Nop.Services.Payments; -using Nop.Services.Stores; -using Nop.Web.Framework.Controllers; -using System.IO; -using System.Diagnostics; -using System.Collections.Specialized; - -namespace Nop.Plugin.Payments.PayGate.Controllers -{ - public class PaymentPayGateController : BasePaymentController - { - private readonly IWorkContext _workContext; - private readonly IStoreService _storeService; - private readonly ISettingService _settingService; - private readonly IPaymentService _paymentService; - private readonly IOrderService _orderService; - private readonly IOrderProcessingService _orderProcessingService; - private readonly ILocalizationService _localizationService; - private readonly IStoreContext _storeContext; - private readonly ILogger _logger; - private readonly IWebHelper _webHelper; - private readonly PaymentSettings _paymentSettings; - private readonly PayGatePaymentSettings _payGatePaymentSettings; - - public PaymentPayGateController(IWorkContext workContext, - IStoreService storeService, - ISettingService settingService, - IPaymentService paymentService, - IOrderService orderService, - IOrderProcessingService orderProcessingService, - ILocalizationService localizationService, - IStoreContext storeContext, - ILogger logger, - IWebHelper webHelper, - PaymentSettings paymentSettings, - PayGatePaymentSettings payGatePaymentSettings) - { - this._workContext = workContext; - this._storeService = storeService; - this._settingService = settingService; - this._paymentService = paymentService; - this._orderService = orderService; - this._orderProcessingService = orderProcessingService; - this._localizationService = localizationService; - this._storeContext = storeContext; - this._logger = logger; - this._webHelper = webHelper; - this._paymentSettings = paymentSettings; - this._payGatePaymentSettings = payGatePaymentSettings; - } - - [AdminAuthorize] - [ChildActionOnly] - public ActionResult Configure() - { - //load settings for a chosen store scope - var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); - var payGatePaymentSettings = _settingService.LoadSetting(storeScope); - - var model = new ConfigurationModel(); - model.UseSandbox = payGatePaymentSettings.UseSandbox; - model.PayGateID = payGatePaymentSettings.PayGateID; - model.EncryptionKey = payGatePaymentSettings.EncryptionKey; - model.EnableIpn = payGatePaymentSettings.EnableIpn; - model.ActiveStoreScopeConfiguration = storeScope; - if (storeScope > 0) - { - model.UseSandbox_OverrideForStore = _settingService.SettingExists(payGatePaymentSettings, x => x.UseSandbox, storeScope); - model.PayGateID_OverrideForStore = _settingService.SettingExists(payGatePaymentSettings, x => x.PayGateID, storeScope); - model.EncryptionKey_OverrideForStore = _settingService.SettingExists(payGatePaymentSettings, x => x.EncryptionKey, storeScope); - model.EnableIpn_OverrideForStore = _settingService.SettingExists(payGatePaymentSettings, x => x.EnableIpn, storeScope); - - } - - return View("~/Plugins/Payments.PayGate/Views/PaymentPayGate/Configure.cshtml", model); - } - - [HttpPost] - [AdminAuthorize] - [ChildActionOnly] - public ActionResult Configure(ConfigurationModel model) - { - if (!ModelState.IsValid) - return Configure(); - - //load settings for a chosen store scope - var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); - var payGatePaymentSettings = _settingService.LoadSetting(storeScope); - - //save settings - payGatePaymentSettings.UseSandbox = model.UseSandbox; - payGatePaymentSettings.PayGateID = model.PayGateID; - payGatePaymentSettings.EncryptionKey = model.EncryptionKey; - payGatePaymentSettings.EnableIpn = model.EnableIpn; - - /* We do not clear cache after each setting update. - * This behavior can increase performance because cached settings will not be cleared - * and loaded from database after each update */ - if (model.UseSandbox_OverrideForStore || storeScope == 0) - _settingService.SaveSetting(payGatePaymentSettings, x => x.UseSandbox, storeScope, false); - else if (storeScope > 0) - _settingService.DeleteSetting(payGatePaymentSettings, x => x.UseSandbox, storeScope); - - if (model.PayGateID_OverrideForStore || storeScope == 0) - _settingService.SaveSetting(payGatePaymentSettings, x => x.PayGateID, storeScope, false); - else if (storeScope > 0) - _settingService.DeleteSetting(payGatePaymentSettings, x => x.PayGateID, storeScope); - - if (model.EncryptionKey_OverrideForStore || storeScope == 0) - _settingService.SaveSetting(payGatePaymentSettings, x => x.EncryptionKey, storeScope, false); - else if (storeScope > 0) - _settingService.DeleteSetting(payGatePaymentSettings, x => x.EncryptionKey, storeScope); - - if (model.EnableIpn_OverrideForStore || storeScope == 0) - _settingService.SaveSetting(payGatePaymentSettings, x => x.EnableIpn, storeScope, false); - else if (storeScope > 0) - _settingService.DeleteSetting(payGatePaymentSettings, x => x.EnableIpn, storeScope); - - //now clear settings cache - _settingService.ClearCache(); - - SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); - - return Configure(); - } - - [ChildActionOnly] - public ActionResult PaymentInfo() - { - return View("~/Plugins/Payments.PayGate/Views/PaymentPayGate/PaymentInfo.cshtml"); - } - - [NonAction] - public override IList ValidatePaymentForm(FormCollection form) - { - var warnings = new List(); - return warnings; - } - - [NonAction] - public override ProcessPaymentRequest GetPaymentInfo(FormCollection form) - { - var paymentInfo = new ProcessPaymentRequest(); - return paymentInfo; - } - - [ValidateInput(false)] - public ActionResult PayGateReturnHandler(FormCollection form) - { - string[] keys = Request.Form.AllKeys; - String transaction_status = ""; - String pay_request_id = ""; - String transaction_status_desc = ""; - Order order = _orderService.GetOrderById(Int32.Parse(Request.QueryString["pgnopcommerce"])); - var sBuilder = new StringBuilder(); - var query_status = PaymentStatus.Pending; - for (int i = 0; i < keys.Length; i++){ - if (keys[i] == "TRANSACTION_STATUS") { - transaction_status = Request.Form[keys[i]]; - } - - if (keys[i] == "PAY_REQUEST_ID"){ - pay_request_id = Request.Form[keys[i]]; - } - } - - using (var client = new System.Net.WebClient()) - { - var queryData = new NameValueCollection(); - queryData["PAYGATE_ID"] = _payGatePaymentSettings.PayGateID; - queryData["PAY_REQUEST_ID"] = pay_request_id; - queryData["REFERENCE"] = Request.QueryString["pgnopcommerce"]; - string queryValues = string.Join("", queryData.AllKeys.Select(key => queryData[key])); - queryData["CHECKSUM"] = new PayGateHelper().CalculateMD5Hash(queryValues + _payGatePaymentSettings.EncryptionKey); - var response = client.UploadValues("https://secure.paygate.co.za/payweb3/query.trans", queryData); - - var responseString = Encoding.Default.GetString(response); - if(responseString != null) - { - Dictionary dict = - responseString.Split('&') - .Select(x => x.Split('=')) - .ToDictionary(y => y[0], y => y[1]); - - try - { - String trans_id = dict["TRANSACTION_STATUS"].ToString(); - String query_status_desc = ""; - switch (trans_id) - { - case "1": - query_status = PaymentStatus.Paid; - query_status_desc = "Approved"; - break; - - case "2": - query_status_desc = "Declined"; - break; - - case "4": - query_status_desc = "Cancelled By Customer with back button on payment page"; - break; - - case "0": - query_status_desc = "Not Done"; - break; - default: - break; - } - - sBuilder.AppendLine("PayGate Query Data"); - sBuilder.AppendLine("======================="); - sBuilder.AppendLine("PayGate Transaction_Id: " + dict["TRANSACTION_ID"]); - sBuilder.AppendLine("PayGate Status Desc: " + query_status_desc); - sBuilder.AppendLine(""); - - } catch (Exception e) - { - sBuilder.AppendLine("PayGate Query Data"); - sBuilder.AppendLine("======================="); - sBuilder.AppendLine("PayGate Query Response: " + responseString); - sBuilder.AppendLine(""); - } - - } - - } - - var new_payment_status = PaymentStatus.Pending; - switch(transaction_status){ - case "1": - new_payment_status = PaymentStatus.Paid; - transaction_status_desc = "Approved"; - break; - - case "2": - transaction_status_desc = "Declined"; - break; - - case "4": - transaction_status_desc = "Cancelled By Customer with back button on payment page"; - break; - - case "0": - transaction_status_desc = "Not Done"; - break; - default: - break; - } - - sBuilder.AppendLine("PayGate Return Data"); - sBuilder.AppendLine("======================="); - sBuilder.AppendLine("PayGate PayRequestId: " + pay_request_id); - sBuilder.AppendLine("PayGate Status Desc: " + transaction_status_desc); - - //order note - order.OrderNotes.Add(new OrderNote - { - Note = sBuilder.ToString(),//sbbustring.Format("Order status has been changed to {0}", PaymentStatus.Paid), - DisplayToCustomer = false, - CreatedOnUtc = DateTime.UtcNow - }); - - - _orderService.UpdateOrder(order); - //load settings for a chosen store scope - var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); - var payGatePaymentSettings = _settingService.LoadSetting(storeScope); - - //mark order as paid - if (query_status == PaymentStatus.Paid){ - if (_orderProcessingService.CanMarkOrderAsPaid(order)) - { - order.AuthorizationTransactionId = pay_request_id; - _orderService.UpdateOrder(order); - - _orderProcessingService.MarkOrderAsPaid(order); - } - return RedirectToRoute("CheckoutCompleted", new { orderId = order.Id }); - } else if (new_payment_status == PaymentStatus.Paid){ - if (_orderProcessingService.CanMarkOrderAsPaid(order)) - { - order.AuthorizationTransactionId = pay_request_id; - _orderService.UpdateOrder(order); - - _orderProcessingService.MarkOrderAsPaid(order); - } - return RedirectToRoute("CheckoutCompleted", new { orderId = order.Id }); - } else { - - order.AuthorizationTransactionId = pay_request_id; - OrderNote _note = new OrderNote(); - _note.CreatedOnUtc = DateTime.Now; - _note.DisplayToCustomer = true; - _note.Note = "Payment failed with the following description: " + transaction_status_desc; - _orderProcessingService.CancelOrder(order, false); - order.OrderNotes.Add(_note); - _orderService.UpdateOrder(order); - return RedirectToAction(order.Id.ToString().Trim(), "orderdetails"); - } - //return RedirectToAction("Index", "Home", new { area = "" }); - } - } +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Web.Mvc; +using Nop.Core; +using Nop.Core.Domain.Orders; +using Nop.Core.Domain.Payments; +using Nop.Plugin.Payments.PayGate.Models; +using Nop.Services.Configuration; +using Nop.Services.Localization; +using Nop.Services.Logging; +using Nop.Services.Orders; +using Nop.Services.Payments; +using Nop.Services.Stores; +using Nop.Web.Framework.Controllers; +using System.IO; +using System.Diagnostics; +using System.Collections.Specialized; + +namespace Nop.Plugin.Payments.PayGate.Controllers +{ + public class PaymentPayGateController : BasePaymentController + { + private readonly IWorkContext _workContext; + private readonly IStoreService _storeService; + private readonly ISettingService _settingService; + private readonly IPaymentService _paymentService; + private readonly IOrderService _orderService; + private readonly IOrderProcessingService _orderProcessingService; + private readonly ILocalizationService _localizationService; + private readonly IStoreContext _storeContext; + private readonly ILogger _logger; + private readonly IWebHelper _webHelper; + private readonly PaymentSettings _paymentSettings; + private readonly PayGatePaymentSettings _payGatePaymentSettings; + private readonly IShoppingCartService _shoppingCartService; + + public PaymentPayGateController(IWorkContext workContext, + IStoreService storeService, + ISettingService settingService, + IPaymentService paymentService, + IOrderService orderService, + IOrderProcessingService orderProcessingService, + ILocalizationService localizationService, + IStoreContext storeContext, + ILogger logger, + IWebHelper webHelper, + PaymentSettings paymentSettings, + PayGatePaymentSettings payGatePaymentSettings, + IShoppingCartService shoppingCartService) + { + this._workContext = workContext; + this._storeService = storeService; + this._settingService = settingService; + this._paymentService = paymentService; + this._orderService = orderService; + this._orderProcessingService = orderProcessingService; + this._localizationService = localizationService; + this._storeContext = storeContext; + this._logger = logger; + this._webHelper = webHelper; + this._paymentSettings = paymentSettings; + this._payGatePaymentSettings = payGatePaymentSettings; + this._shoppingCartService = shoppingCartService; + } + + [AdminAuthorize] + [ChildActionOnly] + public ActionResult Configure() + { + //load settings for a chosen store scope + var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); + var payGatePaymentSettings = _settingService.LoadSetting(storeScope); + + var model = new ConfigurationModel(); + model.UseSandbox = payGatePaymentSettings.UseSandbox; + model.PayGateID = payGatePaymentSettings.PayGateID; + model.EncryptionKey = payGatePaymentSettings.EncryptionKey; + model.EnableIpn = payGatePaymentSettings.EnableIpn; + model.ActiveStoreScopeConfiguration = storeScope; + if (storeScope > 0) + { + model.UseSandbox_OverrideForStore = _settingService.SettingExists(payGatePaymentSettings, x => x.UseSandbox, storeScope); + model.PayGateID_OverrideForStore = _settingService.SettingExists(payGatePaymentSettings, x => x.PayGateID, storeScope); + model.EncryptionKey_OverrideForStore = _settingService.SettingExists(payGatePaymentSettings, x => x.EncryptionKey, storeScope); + model.EnableIpn_OverrideForStore = _settingService.SettingExists(payGatePaymentSettings, x => x.EnableIpn, storeScope); + + } + + return View("~/Plugins/Payments.PayGate/Views/PaymentPayGate/Configure.cshtml", model); + } + + [HttpPost] + [AdminAuthorize] + [ChildActionOnly] + public ActionResult Configure(ConfigurationModel model) + { + if (!ModelState.IsValid) + return Configure(); + + //load settings for a chosen store scope + var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); + var payGatePaymentSettings = _settingService.LoadSetting(storeScope); + + //save settings + payGatePaymentSettings.UseSandbox = model.UseSandbox; + payGatePaymentSettings.PayGateID = model.PayGateID; + payGatePaymentSettings.EncryptionKey = model.EncryptionKey; + payGatePaymentSettings.EnableIpn = model.EnableIpn; + + /* We do not clear cache after each setting update. + * This behavior can increase performance because cached settings will not be cleared + * and loaded from database after each update */ + if (model.UseSandbox_OverrideForStore || storeScope == 0) + _settingService.SaveSetting(payGatePaymentSettings, x => x.UseSandbox, storeScope, false); + else if (storeScope > 0) + _settingService.DeleteSetting(payGatePaymentSettings, x => x.UseSandbox, storeScope); + + if (model.PayGateID_OverrideForStore || storeScope == 0) + _settingService.SaveSetting(payGatePaymentSettings, x => x.PayGateID, storeScope, false); + else if (storeScope > 0) + _settingService.DeleteSetting(payGatePaymentSettings, x => x.PayGateID, storeScope); + + if (model.EncryptionKey_OverrideForStore || storeScope == 0) + _settingService.SaveSetting(payGatePaymentSettings, x => x.EncryptionKey, storeScope, false); + else if (storeScope > 0) + _settingService.DeleteSetting(payGatePaymentSettings, x => x.EncryptionKey, storeScope); + + if (model.EnableIpn_OverrideForStore || storeScope == 0) + _settingService.SaveSetting(payGatePaymentSettings, x => x.EnableIpn, storeScope, false); + else if (storeScope > 0) + _settingService.DeleteSetting(payGatePaymentSettings, x => x.EnableIpn, storeScope); + + //now clear settings cache + _settingService.ClearCache(); + + SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); + + return Configure(); + } + + [ChildActionOnly] + public ActionResult PaymentInfo() + { + return View("~/Plugins/Payments.PayGate/Views/PaymentPayGate/PaymentInfo.cshtml"); + } + + [NonAction] + public override IList ValidatePaymentForm(FormCollection form) + { + var warnings = new List(); + return warnings; + } + + [NonAction] + public override ProcessPaymentRequest GetPaymentInfo(FormCollection form) + { + var paymentInfo = new ProcessPaymentRequest(); + return paymentInfo; + } + + [ValidateInput(false)] + public ActionResult PayGateReturnHandler(FormCollection form) + { + string[] keys = Request.Form.AllKeys; + String transaction_status = ""; + String pay_request_id = ""; + String transaction_status_desc = ""; + Order order = _orderService.GetOrderById(Int32.Parse(Request.QueryString["pgnopcommerce"])); + var sBuilder = new StringBuilder(); + var query_status = PaymentStatus.Pending; + for (int i = 0; i < keys.Length; i++){ + if (keys[i] == "TRANSACTION_STATUS") { + transaction_status = Request.Form[keys[i]]; + } + + if (keys[i] == "PAY_REQUEST_ID"){ + pay_request_id = Request.Form[keys[i]]; + } + } + + using (var client = new System.Net.WebClient()) + { + var queryData = new NameValueCollection(); + queryData["PAYGATE_ID"] = _payGatePaymentSettings.PayGateID; + queryData["PAY_REQUEST_ID"] = pay_request_id; + queryData["REFERENCE"] = Request.QueryString["pgnopcommerce"]; + string queryValues = string.Join("", queryData.AllKeys.Select(key => queryData[key])); + queryData["CHECKSUM"] = new PayGateHelper().CalculateMD5Hash(queryValues + _payGatePaymentSettings.EncryptionKey); + var response = client.UploadValues("https://secure.paygate.co.za/payweb3/query.trans", queryData); + + var responseString = Encoding.Default.GetString(response); + if(responseString != null) + { + Dictionary dict = + responseString.Split('&') + .Select(x => x.Split('=')) + .ToDictionary(y => y[0], y => y[1]); + + try + { + String trans_id = dict["TRANSACTION_STATUS"].ToString(); + String query_status_desc = ""; + switch (trans_id) + { + case "1": + query_status = PaymentStatus.Paid; + query_status_desc = "Approved"; + break; + + case "2": + query_status_desc = "Declined"; + break; + + case "4": + query_status_desc = "Cancelled By Customer with back button on payment page"; + break; + + case "0": + query_status_desc = "Not Done"; + break; + default: + break; + } + + sBuilder.AppendLine("PayGate Query Data"); + sBuilder.AppendLine("======================="); + sBuilder.AppendLine("PayGate Transaction_Id: " + dict["TRANSACTION_ID"]); + sBuilder.AppendLine("PayGate Status Desc: " + query_status_desc); + sBuilder.AppendLine(""); + + } catch (Exception e) + { + sBuilder.AppendLine("PayGate Query Data"); + sBuilder.AppendLine("======================="); + sBuilder.AppendLine("PayGate Query Response: " + responseString); + sBuilder.AppendLine(""); + } + + } + + } + + var new_payment_status = PaymentStatus.Pending; + switch(transaction_status){ + case "1": + new_payment_status = PaymentStatus.Paid; + transaction_status_desc = "Approved"; + break; + + case "2": + transaction_status_desc = "Declined"; + break; + + case "4": + transaction_status_desc = "Cancelled By Customer with back button on payment page"; + break; + + case "0": + transaction_status_desc = "Not Done"; + break; + default: + break; + } + + sBuilder.AppendLine("PayGate Return Data"); + sBuilder.AppendLine("======================="); + sBuilder.AppendLine("PayGate PayRequestId: " + pay_request_id); + sBuilder.AppendLine("PayGate Status Desc: " + transaction_status_desc); + + //order note + order.OrderNotes.Add(new OrderNote + { + Note = sBuilder.ToString(),//sbbustring.Format("Order status has been changed to {0}", PaymentStatus.Paid), + DisplayToCustomer = false, + CreatedOnUtc = DateTime.UtcNow + }); + + + _orderService.UpdateOrder(order); + //load settings for a chosen store scope + var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); + var payGatePaymentSettings = _settingService.LoadSetting(storeScope); + + //mark order as paid + if (query_status == PaymentStatus.Paid){ + if (_orderProcessingService.CanMarkOrderAsPaid(order)) + { + order.AuthorizationTransactionId = pay_request_id; + _orderService.UpdateOrder(order); + + _orderProcessingService.MarkOrderAsPaid(order); + } + return RedirectToRoute("CheckoutCompleted", new { orderId = order.Id }); + } else if (new_payment_status == PaymentStatus.Paid){ + if (_orderProcessingService.CanMarkOrderAsPaid(order)) + { + order.AuthorizationTransactionId = pay_request_id; + _orderService.UpdateOrder(order); + + _orderProcessingService.MarkOrderAsPaid(order); + } + return RedirectToRoute("CheckoutCompleted", new { orderId = order.Id }); + } else { + + order.AuthorizationTransactionId = pay_request_id; + OrderNote _note = new OrderNote(); + _note.CreatedOnUtc = DateTime.Now; + _note.DisplayToCustomer = true; + _note.Note = "Payment failed with the following description: " + transaction_status_desc; + _orderProcessingService.CancelOrder(order, false); + order.OrderNotes.Add(_note); + _orderService.UpdateOrder(order); + + var customer = order.Customer; + + // Recreate cart contents + var items = order.OrderItems.ToArray(); + for (int i = 0; i < order.OrderItems.Count; i++) + { + OrderItem item = items[i]; + var product = item.Product; + int OrderItemQuantity = item.Quantity; + this._shoppingCartService.AddToCart(customer, product, ShoppingCartType.ShoppingCart, order.StoreId, null, (decimal)0.0 , null, null, OrderItemQuantity); + } + return RedirectToAction(order.Id.ToString().Trim(), "orderdetails"); + } + //return RedirectToAction("Index", "Home", new { area = "" }); + } + } } \ No newline at end of file diff --git a/Nop.Plugin.Payments.PayGate/Description.txt b/Nop.Plugin.Payments.PayGate/Description.txt index c528bcb..ee470ed 100644 --- a/Nop.Plugin.Payments.PayGate/Description.txt +++ b/Nop.Plugin.Payments.PayGate/Description.txt @@ -1,9 +1,9 @@ -Group: Payment methods -FriendlyName: PayGate -SystemName: Payments.PayGate -Version: 1.1.1 -SupportedVersions: 3.90 -Author: App Inlet (Pty) Ltd -DisplayOrder: 1 -FileName: Nop.Plugin.Payments.PayGate.dll +Group: Payment methods +FriendlyName: PayGate +SystemName: Payments.PayGate +Version: 1.1.1 +SupportedVersions: 3.90 +Author: App Inlet (Pty) Ltd +DisplayOrder: 1 +FileName: Nop.Plugin.Payments.PayGate.dll Description: PayGate Payment Gateway Plugin for nopCommerce 3.9 by App Inlet (Pty) Ltd \ No newline at end of file diff --git a/Nop.Plugin.Payments.PayGate/Models/ConfigurationModel.cs b/Nop.Plugin.Payments.PayGate/Models/ConfigurationModel.cs index a6b69e0..dea029b 100644 --- a/Nop.Plugin.Payments.PayGate/Models/ConfigurationModel.cs +++ b/Nop.Plugin.Payments.PayGate/Models/ConfigurationModel.cs @@ -1,28 +1,28 @@ -using Nop.Web.Framework; -using Nop.Web.Framework.Mvc; - -namespace Nop.Plugin.Payments.PayGate.Models -{ - public class ConfigurationModel : BaseNopModel - { - public int ActiveStoreScopeConfiguration { get; set; } - - [NopResourceDisplayName("Plugins.Payments.PayGate.Fields.UseSandbox")] - public bool UseSandbox { get; set; } - public bool UseSandbox_OverrideForStore { get; set; } - - [NopResourceDisplayName("Plugins.Payments.PayGate.Fields.PayGateID")] - public string PayGateID { get; set; } - public bool PayGateID_OverrideForStore { get; set; } - - [NopResourceDisplayName("Plugins.Payments.PayGate.Fields.EncryptionKey")] - public string EncryptionKey { get; set; } - public bool EncryptionKey_OverrideForStore { get; set; } - - [NopResourceDisplayName("Plugins.Payments.PayGate.Fields.EnableIpn")] - public bool EnableIpn { get; set; } - public bool EnableIpn_OverrideForStore { get; set; } - - - } +using Nop.Web.Framework; +using Nop.Web.Framework.Mvc; + +namespace Nop.Plugin.Payments.PayGate.Models +{ + public class ConfigurationModel : BaseNopModel + { + public int ActiveStoreScopeConfiguration { get; set; } + + [NopResourceDisplayName("Plugins.Payments.PayGate.Fields.UseSandbox")] + public bool UseSandbox { get; set; } + public bool UseSandbox_OverrideForStore { get; set; } + + [NopResourceDisplayName("Plugins.Payments.PayGate.Fields.PayGateID")] + public string PayGateID { get; set; } + public bool PayGateID_OverrideForStore { get; set; } + + [NopResourceDisplayName("Plugins.Payments.PayGate.Fields.EncryptionKey")] + public string EncryptionKey { get; set; } + public bool EncryptionKey_OverrideForStore { get; set; } + + [NopResourceDisplayName("Plugins.Payments.PayGate.Fields.EnableIpn")] + public bool EnableIpn { get; set; } + public bool EnableIpn_OverrideForStore { get; set; } + + + } } \ No newline at end of file diff --git a/Nop.Plugin.Payments.PayGate/Nop.Plugin.Payments.PayGate.csproj b/Nop.Plugin.Payments.PayGate/Nop.Plugin.Payments.PayGate.csproj index fea0baf..ccb8e21 100644 --- a/Nop.Plugin.Payments.PayGate/Nop.Plugin.Payments.PayGate.csproj +++ b/Nop.Plugin.Payments.PayGate/Nop.Plugin.Payments.PayGate.csproj @@ -1,137 +1,137 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {9E6044C8-0952-4733-9C96-051EC434F3E1} - Library - Properties - Nop.Plugin.Payments.PayGate - Nop.Plugin.Payments.PayGate - v4.5.1 - 512 - - - - true - full - false - ..\..\Presentation\Nop.Web\Plugins\Payments.PayGate\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - ..\..\Presentation\Nop.Web\Plugins\Payments.PayGate\ - TRACE - prompt - 4 - false - - - - False - ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - - - - - False - ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll - False - - - ..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll - False - False - - - False - ..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll - False - - - False - ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll - False - - - False - ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll - False - - - False - ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll - False - - - - - - - - - - - - - - - - - - - {6BDA8332-939F-45B7-A25E-7A797260AE59} - Nop.Core - False - - - {210541AD-F659-47DA-8763-16F36C5CD2F4} - Nop.Services - False - - - {75FD4163-333C-4DD5-854D-2EF294E45D94} - Nop.Web.Framework - False - - - - - PreserveNewest - - - PreserveNewest - - - - - PreserveNewest - Designer - - - - - PreserveNewest - - - Always - - - - - + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {9E6044C8-0952-4733-9C96-051EC434F3E1} + Library + Properties + Nop.Plugin.Payments.PayGate + Nop.Plugin.Payments.PayGate + v4.5.1 + 512 + + + + true + full + false + ..\..\Presentation\Nop.Web\Plugins\Payments.PayGate\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\..\Presentation\Nop.Web\Plugins\Payments.PayGate\ + TRACE + prompt + 4 + false + + + + False + ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + + + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll + False + + + ..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll + False + False + + + False + ..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll + False + + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll + False + + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll + False + + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll + False + + + + + + + + + + + + + + + + + + + {6BDA8332-939F-45B7-A25E-7A797260AE59} + Nop.Core + False + + + {210541AD-F659-47DA-8763-16F36C5CD2F4} + Nop.Services + False + + + {75FD4163-333C-4DD5-854D-2EF294E45D94} + Nop.Web.Framework + False + + + + + PreserveNewest + + + PreserveNewest + + + + + PreserveNewest + Designer + + + + + PreserveNewest + + + Always + + + + + \ No newline at end of file diff --git a/Nop.Plugin.Payments.PayGate/Notes.txt b/Nop.Plugin.Payments.PayGate/Notes.txt index 04cffc4..e77c643 100644 --- a/Nop.Plugin.Payments.PayGate/Notes.txt +++ b/Nop.Plugin.Payments.PayGate/Notes.txt @@ -1,5 +1,5 @@ -1. Set project output path to ..\..\Presentation\Nop.Web\Plugins\{PluginName}\ (both 'Release' and 'Debug' configurations) - - -2. All views (cshtml files) and web.config file should have "Build action" set to "Content" and "Copy to output directory" set to "Copy if newer" - +1. Set project output path to ..\..\Presentation\Nop.Web\Plugins\{PluginName}\ (both 'Release' and 'Debug' configurations) + + +2. All views (cshtml files) and web.config file should have "Build action" set to "Content" and "Copy to output directory" set to "Copy if newer" + diff --git a/Nop.Plugin.Payments.PayGate/PayGateHelper.cs b/Nop.Plugin.Payments.PayGate/PayGateHelper.cs index 9db0132..786a4b0 100644 --- a/Nop.Plugin.Payments.PayGate/PayGateHelper.cs +++ b/Nop.Plugin.Payments.PayGate/PayGateHelper.cs @@ -1,43 +1,43 @@ -using Nop.Core.Domain.Payments; -using System.Text; - -namespace Nop.Plugin.Payments.PayGate -{ - /// - /// Represents pagate helper - /// - public class PayGateHelper{ - /// - /// Gets a payment status - /// - /// PayGate payment status - /// PayGate pending reason - /// Payment status - public static PaymentStatus GetPaymentStatus(string paymentStatus, string pendingReason) - { - var result = PaymentStatus.Pending; - - return result; - } - - public string CalculateMD5Hash(string input){ - - System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create(); - - byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input); - - byte[] hash = md5.ComputeHash(inputBytes); - - // step 2, convert byte array to hex string - - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < hash.Length; i++) { - sb.Append(hash[i].ToString("X2")); - } - return sb.ToString(); - - } - } -} - +using Nop.Core.Domain.Payments; +using System.Text; + +namespace Nop.Plugin.Payments.PayGate +{ + /// + /// Represents pagate helper + /// + public class PayGateHelper{ + /// + /// Gets a payment status + /// + /// PayGate payment status + /// PayGate pending reason + /// Payment status + public static PaymentStatus GetPaymentStatus(string paymentStatus, string pendingReason) + { + var result = PaymentStatus.Pending; + + return result; + } + + public string CalculateMD5Hash(string input){ + + System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create(); + + byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input); + + byte[] hash = md5.ComputeHash(inputBytes); + + // step 2, convert byte array to hex string + + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < hash.Length; i++) { + sb.Append(hash[i].ToString("X2")); + } + return sb.ToString(); + + } + } +} + diff --git a/Nop.Plugin.Payments.PayGate/PayGatePaymentProcessor.cs b/Nop.Plugin.Payments.PayGate/PayGatePaymentProcessor.cs index 10f4a1c..207e6c7 100644 --- a/Nop.Plugin.Payments.PayGate/PayGatePaymentProcessor.cs +++ b/Nop.Plugin.Payments.PayGate/PayGatePaymentProcessor.cs @@ -1,453 +1,485 @@ -using System; -using System.Collections.Generic; -using System.Net; -using System.Text; -using System.Web; -using System.Web.Routing; -using Nop.Core; -using Nop.Core.Domain.Directory; -using Nop.Core.Domain.Orders; -using Nop.Core.Domain.Payments; -using Nop.Core.Plugins; -using Nop.Plugin.Payments.PayGate.Controllers; -using Nop.Services.Configuration; -using Nop.Services.Directory; -using Nop.Services.Localization; -using Nop.Services.Orders; -using Nop.Services.Payments; -using Nop.Services.Tax; - -using System.Collections.Specialized; -using System.Linq; -using System.Security.Cryptography; -using Nop.Core.Domain.Logging; -using Nop.Services.Logging; -using Nop.Web.Framework; - -namespace Nop.Plugin.Payments.PayGate -{ - /// - /// PayGate payment processor - /// - public class PayGatePaymentProcessor : BasePlugin, IPaymentMethod - { - #region Fields - - private readonly PayGatePaymentSettings _payGatePaymentSettings; - private readonly ISettingService _settingService; - private readonly ICurrencyService _currencyService; - private readonly CurrencySettings _currencySettings; - private readonly IWebHelper _webHelper; - private readonly ICheckoutAttributeParser _checkoutAttributeParser; - private readonly ITaxService _taxService; - private readonly IOrderTotalCalculationService _orderTotalCalculationService; - private readonly ILocalizationService _localizationService; - private readonly HttpContextBase _httpContext; - private Dictionary dictionaryResponse; - private readonly ILogger _logger; - private readonly IOrderService _orderService; - private readonly IStoreContext _storeContext; - #endregion - - #region Ctor - - public PayGatePaymentProcessor(PayGatePaymentSettings payGatePaymentSettings, - ISettingService settingService, ICurrencyService currencyService, - CurrencySettings currencySettings, IWebHelper webHelper, - ICheckoutAttributeParser checkoutAttributeParser, ITaxService taxService, - IOrderTotalCalculationService orderTotalCalculationService, ILocalizationService localizationService, - HttpContextBase httpContext, ILogger logger, IOrderService orderService, - IStoreContext storeContext) - { - this._storeContext = storeContext; - this._logger = logger; - this._payGatePaymentSettings = payGatePaymentSettings; - this._settingService = settingService; - this._currencyService = currencyService; - this._currencySettings = currencySettings; - this._webHelper = webHelper; - this._checkoutAttributeParser = checkoutAttributeParser; - this._taxService = taxService; - this._orderTotalCalculationService = orderTotalCalculationService; - this._localizationService = localizationService; - this._httpContext = httpContext; - this._orderService = orderService; - } - - #endregion - - #region Utilities - - #endregion - - #region Methods - - /// - /// Process a payment - /// - /// Payment info required for an order processing - /// Process payment result - public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest) - { - var result = new ProcessPaymentResult(); - result.NewPaymentStatus = PaymentStatus.Pending; - return result; - } - - /// - /// Post process payment (used by payment gateways that require redirecting to a third-party URL) - /// - /// Payment info required for an order processing - public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest) - { - var orderTotal = Math.Round(postProcessPaymentRequest.Order.OrderTotal, 2); - var currentOrder = _orderService.GetOrderById(postProcessPaymentRequest.Order.Id); - using (var client = new WebClient()) - { - var initiateData = new NameValueCollection(); - initiateData["PAYGATE_ID"] = _payGatePaymentSettings.PayGateID; - initiateData["REFERENCE"] = postProcessPaymentRequest.Order.Id.ToString(); - initiateData["AMOUNT"] = (Convert.ToDouble(orderTotal) * 100).ToString(); - initiateData["CURRENCY"] = - _currencyService.GetCurrencyByCode(currentOrder.CustomerCurrencyCode).CurrencyCode; - initiateData["RETURN_URL"] = _webHelper.GetStoreLocation(false) + "Plugins/PaymentPayGate/PayGateReturnHandler?pgnopcommerce=" + postProcessPaymentRequest.Order.Id.ToString(); - initiateData["TRANSACTION_DATE"] = String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now).ToString(); - initiateData["LOCALE"] = "en-za"; - initiateData["COUNTRY"] = postProcessPaymentRequest.Order.BillingAddress.Country.ThreeLetterIsoCode; - initiateData["EMAIL"] = postProcessPaymentRequest.Order.BillingAddress.Email; - initiateData["NOTIFY_URL"] = _webHelper.GetStoreLocation(false) + "Plugins/PaymentPayGate/PayGateNotifyHandler?pgnopcommerce=" + postProcessPaymentRequest.Order.Id.ToString(); - initiateData["USER3"] = "nopcommerce-v1.0.0"; - - string initiateValues = string.Join("", initiateData.AllKeys.Select(key => initiateData[key])); - - initiateData["CHECKSUM"] = new PayGateHelper().CalculateMD5Hash(initiateValues + _payGatePaymentSettings.EncryptionKey); - var initiateResponse = client.UploadValues("https://secure.paygate.co.za/payweb3/initiate.trans", "POST", initiateData); - var responseText = Encoding.Default.GetString(initiateResponse); - - if (responseText.Contains("PGID_NOT_EN") || responseText.Contains("DATA_CUR") || - responseText.Contains("DATA_PW") || responseText.Contains("DATA_CHK")) - { - string Error = "Checksum posted does not match the one calculated by PayGate, either due to an incorrect encryption key used or a field that has been excluded from the checksum calculation"; - if (Encoding.Default.GetString(initiateResponse).Contains("PGID_NOT_EN")) - { - Error = "The PayGate ID being used to post data to PayGate has not yet been enabled, or there are no payment methods setup on it."; - } - else if (Encoding.Default.GetString(initiateResponse).Contains("DATA_CUR")) - { - Error = "The currency that has been posted to PayGate is not supported."; - } - else if (Encoding.Default.GetString(initiateResponse).Contains("DATA_PW")) - { - Error = "Mandatory fields have been excluded from the post to PayGate, refer to page 9 of the documentation as to what fields should be posted."; - } - - _logger.InsertLog(LogLevel.Debug, "Paygate response for order number " + postProcessPaymentRequest.Order.Id.ToString(), Error); - - - currentOrder.OrderStatus = OrderStatus.Cancelled; - _orderService.UpdateOrder(currentOrder); - - - var url = _storeContext.CurrentStore.Url; - if (!url.EndsWith("/")) - url += "/"; - var stringBuilder = ""; - - _httpContext.Response.Write(stringBuilder); - _httpContext.Response.End(); - } - else - { - dictionaryResponse = Encoding.Default.GetString(initiateResponse) - .Split('&') - .Select(p => p.Split('=')) - .ToDictionary(p => p[0], p => p.Length > 1 ? Uri.UnescapeDataString(p[1]) : null); - - if (dictionaryResponse["PAY_REQUEST_ID"] != null && dictionaryResponse["CHECKSUM"] != null) - { - RemotePost remotePost = new RemotePost - { - FormName = "PayGate", - Method = "POST", - Url = "https://secure.paygate.co.za/payweb3/process.trans" - }; - remotePost.Add("PAY_REQUEST_ID", dictionaryResponse["PAY_REQUEST_ID"]); - remotePost.Add("CHECKSUM", dictionaryResponse["CHECKSUM"]); - remotePost.Post(); - } - } - } - } - - /// - /// Returns a value indicating whether payment method should be hidden during checkout - /// - /// Shoping cart - /// true - hide; false - display. - public bool HidePaymentMethod(IList cart) - { - //you can put any logic here - //for example, hide this payment method if all products in the cart are downloadable - //or hide this payment method if current customer is from certain country - return false; - } - - /// - /// Gets additional handling fee - /// - /// Shoping cart - /// Additional handling fee - public decimal GetAdditionalHandlingFee(IList cart) { return 0; } - - /// - /// Captures payment - /// - /// Capture payment request - /// Capture payment result - public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest) - { - var result = new CapturePaymentResult(); - result.AddError("Capture method not supported"); - return result; - } - - /// - /// Refunds a payment - /// - /// Request - /// Result - public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest) - { - var result = new RefundPaymentResult(); - result.AddError("Refund method not supported"); - return result; - } - - /// - /// Voids a payment - /// - /// Request - /// Result - public VoidPaymentResult Void(VoidPaymentRequest voidPaymentRequest) - { - var result = new VoidPaymentResult(); - result.AddError("Void method not supported"); - return result; - } - - /// - /// Process recurring payment - /// - /// Payment info required for an order processing - /// Process payment result - public ProcessPaymentResult ProcessRecurringPayment(ProcessPaymentRequest processPaymentRequest) - { - var result = new ProcessPaymentResult(); - result.AddError("Recurring payment not supported"); - return result; - } - - /// - /// Cancels a recurring payment - /// - /// Request - /// Result - public CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurringPaymentRequest cancelPaymentRequest) - { - var result = new CancelRecurringPaymentResult(); - result.AddError("Recurring payment not supported"); - return result; - } - - /// - /// Gets a value indicating whether customers can complete a payment after order is placed but not completed (for redirection payment methods) - /// - /// Order - /// Result - public bool CanRePostProcessPayment(Order order) - { - if (order == null) - throw new ArgumentNullException("order"); - - //let's ensure that at least 5 seconds passed after order is placed - //P.S. there's no any particular reason for that. we just do it - if ((DateTime.UtcNow - order.CreatedOnUtc).TotalSeconds < 5) - return false; - - return true; - } - - /// - /// Gets a route for provider configuration - /// - /// Action name - /// Controller name - /// Route values - public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues) - { - actionName = "Configure"; - controllerName = "PaymentPayGate"; - routeValues = new RouteValueDictionary { { "Namespaces", "Nop.Plugin.Payments.PayGate.Controllers" }, { "area", null } }; - } - - /// - /// Gets a route for payment info - /// - /// Action name - /// Controller name - /// Route values - public void GetPaymentInfoRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues) - { - actionName = "PaymentInfo"; - controllerName = "PaymentPayGate"; - routeValues = new RouteValueDictionary { { "Namespaces", "Nop.Plugin.Payments.PayGate.Controllers" }, { "area", null } }; - } - - public Type GetControllerType() - { - return typeof(PaymentPayGateController); - } - - public override void Install() - { - //settings - var settings = new PayGatePaymentSettings - { - UseSandbox = true, - PayGateID = "10011072130", - EncryptionKey = "secret", - }; - _settingService.SaveSetting(settings); - - //locales - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.RedirectionTip", "You will be redirected to PayGate site to complete the order."); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.UseSandbox", "Use Sandbox"); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.UseSandbox.Hint", "Check to enable Sandbox (testing environment)."); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.PayGateID", "PayGate ID"); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.PayGateID.Hint", "Specify your PayGate ID."); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EncryptionKey", "Encryption Key"); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EncryptionKey.Hint", "Specify Encryption Key"); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn", "Enable IPN (Instant Payment Notification)"); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn.Hint", "Check if IPN is enabled."); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn.Hint2", "Leave blank to use the default IPN handler URL."); - this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.PaymentMethodDescription", "Pay by Credit/Debit Card"); - - base.Install(); - } - - public override void Uninstall() - { - //settings - _settingService.DeleteSetting(); - - //locales - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.RedirectionTip"); - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.UseSandbox"); - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.UseSandbox.Hint"); - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.PayGateID"); - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.PayGateID.Hint"); - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EncryptionKey"); - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EncryptionKey.Hint"); - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn"); - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn.Hint"); - this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn.Hint2"); - - base.Uninstall(); - } - - #endregion - - #region Properties - - /// - /// Gets a payment method description that will be displayed on checkout pages in the public store - /// - public string PaymentMethodDescription - { - //return description of this payment method to be display on "payment method" checkout step. good practice is to make it localizable - //for example, for a redirection payment method, description may be like this: "You will be redirected to PayGate site to complete the payment" - get { return _localizationService.GetResource("Plugins.Payments.PayGate.PaymentMethodDescription"); } - } - - /// - /// Gets a value indicating whether capture is supported - /// - public bool SupportCapture - { - get - { - return false; - } - } - - /// - /// Gets a value indicating whether partial refund is supported - /// - public bool SupportPartiallyRefund - { - get - { - return false; - } - } - - /// - /// Gets a value indicating whether refund is supported - /// - public bool SupportRefund - { - get - { - return false; - } - } - - /// - /// Gets a value indicating whether void is supported - /// - public bool SupportVoid - { - get - { - return false; - } - } - - /// - /// Gets a recurring payment type of payment method - /// - public RecurringPaymentType RecurringPaymentType - { - get - { - return RecurringPaymentType.NotSupported; - } - } - - /// - /// Gets a payment method type - /// - public PaymentMethodType PaymentMethodType - { - get - { - return PaymentMethodType.Redirection; - } - } - - /// - /// Gets a value indicating whether we should display a payment information page for this plugin - /// - public bool SkipPaymentInfo - { - get - { - return false; - } - } - - public string X2 { get; private set; } - - #endregion - } -} +using System; +using System.Collections.Generic; +using System.Net; +using System.Text; +using System.Web; +using System.Web.Routing; +using Nop.Core; +using Nop.Core.Domain.Directory; +using Nop.Core.Domain.Orders; +using Nop.Core.Domain.Payments; +using Nop.Core.Plugins; +using Nop.Plugin.Payments.PayGate.Controllers; +using Nop.Services.Configuration; +using Nop.Services.Directory; +using Nop.Services.Localization; +using Nop.Services.Orders; +using Nop.Services.Payments; +using Nop.Services.Tax; + +using System.Collections.Specialized; +using System.Linq; +using System.Security.Cryptography; +using Nop.Core.Domain.Logging; +using Nop.Services.Logging; +using Nop.Web.Framework; + +namespace Nop.Plugin.Payments.PayGate +{ + /// + /// PayGate payment processor + /// + public class PayGatePaymentProcessor : BasePlugin, IPaymentMethod + { + #region Fields + + private readonly PayGatePaymentSettings _payGatePaymentSettings; + private readonly ISettingService _settingService; + private readonly ICurrencyService _currencyService; + private readonly CurrencySettings _currencySettings; + private readonly IWebHelper _webHelper; + private readonly ICheckoutAttributeParser _checkoutAttributeParser; + private readonly ITaxService _taxService; + private readonly IOrderTotalCalculationService _orderTotalCalculationService; + private readonly ILocalizationService _localizationService; + private readonly HttpContextBase _httpContext; + private Dictionary dictionaryResponse; + private readonly ILogger _logger; + private readonly IOrderService _orderService; + private readonly IStoreContext _storeContext; + private IShoppingCartService _shoppingCartService; + #endregion + + #region Ctor + + public PayGatePaymentProcessor(PayGatePaymentSettings payGatePaymentSettings, + ISettingService settingService, ICurrencyService currencyService, + CurrencySettings currencySettings, IWebHelper webHelper, + ICheckoutAttributeParser checkoutAttributeParser, ITaxService taxService, + IOrderTotalCalculationService orderTotalCalculationService, ILocalizationService localizationService, + HttpContextBase httpContext, ILogger logger, IOrderService orderService, + IStoreContext storeContext, IShoppingCartService shoppingCartService) + { + this._storeContext = storeContext; + this._logger = logger; + this._payGatePaymentSettings = payGatePaymentSettings; + this._settingService = settingService; + this._currencyService = currencyService; + this._currencySettings = currencySettings; + this._webHelper = webHelper; + this._checkoutAttributeParser = checkoutAttributeParser; + this._taxService = taxService; + this._orderTotalCalculationService = orderTotalCalculationService; + this._localizationService = localizationService; + this._httpContext = httpContext; + this._orderService = orderService; + this._shoppingCartService = shoppingCartService; + } + + #endregion + + #region Utilities + + #endregion + + #region Methods + + /// + /// Process a payment + /// + /// Payment info required for an order processing + /// Process payment result + public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest) + { + var result = new ProcessPaymentResult(); + result.NewPaymentStatus = PaymentStatus.Pending; + return result; + } + + /// + /// Post process payment (used by payment gateways that require redirecting to a third-party URL) + /// + /// Payment info required for an order processing + public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest) + { + var orderTotal = Math.Round(postProcessPaymentRequest.Order.OrderTotal, 2); + var currentOrder = _orderService.GetOrderById(postProcessPaymentRequest.Order.Id); + //_logger.InsertLog(LogLevel.Debug, "In process payment. Order ID " + postProcessPaymentRequest.Order.Id + " Order value: " + orderTotal); + using (var client = new WebClient()) + { + var initiateData = new NameValueCollection(); + initiateData["PAYGATE_ID"] = _payGatePaymentSettings.PayGateID; + initiateData["REFERENCE"] = postProcessPaymentRequest.Order.Id.ToString(); + initiateData["AMOUNT"] = (Convert.ToDouble(orderTotal) * 100).ToString(); + initiateData["CURRENCY"] = + _currencyService.GetCurrencyByCode(currentOrder.CustomerCurrencyCode).CurrencyCode; + initiateData["RETURN_URL"] = _webHelper.GetStoreLocation(false) + "Plugins/PaymentPayGate/PayGateReturnHandler?pgnopcommerce=" + postProcessPaymentRequest.Order.Id.ToString(); + initiateData["TRANSACTION_DATE"] = String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now).ToString(); + initiateData["LOCALE"] = "en-za"; + try + { + initiateData["COUNTRY"] = postProcessPaymentRequest.Order.BillingAddress.Country.ThreeLetterIsoCode; + + } catch (Exception ex) + { + _logger.InsertLog(LogLevel.Error, ex.Message); + initiateData["COUNTRY"] = "ZAF"; + } + try + { + initiateData["EMAIL"] = postProcessPaymentRequest.Order.BillingAddress.Email; + } catch (Exception ex) + { + _logger.InsertLog(LogLevel.Error, ex.Message); + initiateData["EMAIL"] = "test@tom.com"; + } + initiateData["USER3"] = "nopcommerce-v1.0.0"; + + var initiateValues = string.Join("", initiateData.AllKeys.Select(key => initiateData[key])); + //_logger.InsertLog(LogLevel.Debug, "Initiate values " + initiateValues); + + initiateData["CHECKSUM"] = new PayGateHelper().CalculateMD5Hash(initiateValues + _payGatePaymentSettings.EncryptionKey); + //string initiateValuesCheck = string.Join("", initiateData.AllKeys.Select(key => initiateData[key])); + //_logger.InsertLog(LogLevel.Debug, "Initiate values check " + initiateValuesCheck); + + var responseText = ""; + + try + { + _logger.InsertLog(LogLevel.Debug, "Trying initiate trans with values " + initiateValues); + var initiateResponse = client.UploadValues("https://secure.paygate.co.za/payweb3/initiate.trans", "POST", initiateData); + responseText = Encoding.Default.GetString(initiateResponse); + _logger.InsertLog(LogLevel.Debug, "Response text " + responseText); + } catch (Exception excep) + { + _logger.InsertLog(LogLevel.Error, "Exception in initiate: " + excep.Message); + } + + if (responseText.Contains("PGID_NOT_EN") || responseText.Contains("DATA_CUR") || + responseText.Contains("DATA_PW") || responseText.Contains("DATA_CHK")) + { + string Error = "Checksum posted does not match the one calculated by PayGate, either due to an incorrect encryption key used or a field that has been excluded from the checksum calculation"; + if (responseText.Contains("PGID_NOT_EN")) + { + Error = "The PayGate ID being used to post data to PayGate has not yet been enabled, or there are no payment methods setup on it."; + } + else if (responseText.Contains("DATA_CUR")) + { + Error = "The currency that has been posted to PayGate is not supported."; + } + else if (responseText.Contains("DATA_PW")) + { + Error = "Mandatory fields have been excluded from the post to PayGate, refer to page 9 of the documentation as to what fields should be posted."; + } + + _logger.InsertLog(LogLevel.Debug, "Paygate response for order number " + postProcessPaymentRequest.Order.Id.ToString(), Error); + + + currentOrder.OrderStatus = OrderStatus.Cancelled; + _orderService.UpdateOrder(currentOrder); + + + var url = _storeContext.CurrentStore.Url; + if (!url.EndsWith("/")) + url += "/"; + var stringBuilder = ""; + + _httpContext.Response.Write(stringBuilder); + _httpContext.Response.End(); + } + else + { + dictionaryResponse = responseText + .Split('&') + .Select(p => p.Split('=')) + .ToDictionary(p => p[0], p => p.Length > 1 ? Uri.UnescapeDataString(p[1]) : null); + + if (dictionaryResponse["PAY_REQUEST_ID"] != null && dictionaryResponse["CHECKSUM"] != null) + { + _logger.InsertLog(LogLevel.Debug, "Attempting remote post"); + RemotePost remotePost = new RemotePost + { + FormName = "PayGate", + Method = "POST", + Url = "https://secure.paygate.co.za/payweb3/process.trans" + }; + remotePost.Add("PAY_REQUEST_ID", dictionaryResponse["PAY_REQUEST_ID"]); + remotePost.Add("CHECKSUM", dictionaryResponse["CHECKSUM"]); + remotePost.Post(); + } + } + } + } + + /// + /// Returns a value indicating whether payment method should be hidden during checkout + /// + /// Shoping cart + /// true - hide; false - display. + public bool HidePaymentMethod(IList cart) + { + //you can put any logic here + //for example, hide this payment method if all products in the cart are downloadable + //or hide this payment method if current customer is from certain country + return false; + } + + /// + /// Gets additional handling fee + /// + /// Shoping cart + /// Additional handling fee + public decimal GetAdditionalHandlingFee(IList cart) { return 0; } + + /// + /// Captures payment + /// + /// Capture payment request + /// Capture payment result + public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest) + { + var result = new CapturePaymentResult(); + result.AddError("Capture method not supported"); + return result; + } + + /// + /// Refunds a payment + /// + /// Request + /// Result + public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest) + { + var result = new RefundPaymentResult(); + result.AddError("Refund method not supported"); + return result; + } + + /// + /// Voids a payment + /// + /// Request + /// Result + public VoidPaymentResult Void(VoidPaymentRequest voidPaymentRequest) + { + var result = new VoidPaymentResult(); + result.AddError("Void method not supported"); + return result; + } + + /// + /// Process recurring payment + /// + /// Payment info required for an order processing + /// Process payment result + public ProcessPaymentResult ProcessRecurringPayment(ProcessPaymentRequest processPaymentRequest) + { + var result = new ProcessPaymentResult(); + result.AddError("Recurring payment not supported"); + return result; + } + + /// + /// Cancels a recurring payment + /// + /// Request + /// Result + public CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurringPaymentRequest cancelPaymentRequest) + { + var result = new CancelRecurringPaymentResult(); + result.AddError("Recurring payment not supported"); + return result; + } + + /// + /// Gets a value indicating whether customers can complete a payment after order is placed but not completed (for redirection payment methods) + /// + /// Order + /// Result + public bool CanRePostProcessPayment(Order order) + { + if (order == null) + throw new ArgumentNullException("order"); + + //let's ensure that at least 5 seconds passed after order is placed + //P.S. there's no any particular reason for that. we just do it + if ((DateTime.UtcNow - order.CreatedOnUtc).TotalSeconds < 5) + return false; + + return true; + } + + /// + /// Gets a route for provider configuration + /// + /// Action name + /// Controller name + /// Route values + public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues) + { + actionName = "Configure"; + controllerName = "PaymentPayGate"; + routeValues = new RouteValueDictionary { { "Namespaces", "Nop.Plugin.Payments.PayGate.Controllers" }, { "area", null } }; + } + + /// + /// Gets a route for payment info + /// + /// Action name + /// Controller name + /// Route values + public void GetPaymentInfoRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues) + { + actionName = "PaymentInfo"; + controllerName = "PaymentPayGate"; + routeValues = new RouteValueDictionary { { "Namespaces", "Nop.Plugin.Payments.PayGate.Controllers" }, { "area", null } }; + } + + public Type GetControllerType() + { + return typeof(PaymentPayGateController); + } + + public override void Install() + { + //settings + var settings = new PayGatePaymentSettings + { + UseSandbox = true, + PayGateID = "10011072130", + EncryptionKey = "secret", + }; + _settingService.SaveSetting(settings); + + //locales + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.RedirectionTip", "You will be redirected to PayGate site to complete the order."); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.UseSandbox", "Use Sandbox"); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.UseSandbox.Hint", "Check to enable Sandbox (testing environment)."); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.PayGateID", "PayGate ID"); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.PayGateID.Hint", "Specify your PayGate ID."); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EncryptionKey", "Encryption Key"); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EncryptionKey.Hint", "Specify Encryption Key"); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn", "Enable IPN (Instant Payment Notification)"); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn.Hint", "Check if IPN is enabled."); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn.Hint2", "Leave blank to use the default IPN handler URL."); + this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayGate.PaymentMethodDescription", "Pay by Credit/Debit Card"); + + base.Install(); + } + + public override void Uninstall() + { + //settings + _settingService.DeleteSetting(); + + //locales + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.RedirectionTip"); + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.UseSandbox"); + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.UseSandbox.Hint"); + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.PayGateID"); + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.PayGateID.Hint"); + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EncryptionKey"); + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EncryptionKey.Hint"); + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn"); + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn.Hint"); + this.DeletePluginLocaleResource("Plugins.Payments.PayGate.Fields.EnableIpn.Hint2"); + + base.Uninstall(); + } + + #endregion + + #region Properties + + /// + /// Gets a payment method description that will be displayed on checkout pages in the public store + /// + public string PaymentMethodDescription + { + //return description of this payment method to be display on "payment method" checkout step. good practice is to make it localizable + //for example, for a redirection payment method, description may be like this: "You will be redirected to PayPal site to complete the payment" + get { return _localizationService.GetResource("Plugins.Payments.PayGate.PaymentMethodDescription"); } + } + + /// + /// Gets a value indicating whether capture is supported + /// + public bool SupportCapture + { + get + { + return false; + } + } + + /// + /// Gets a value indicating whether partial refund is supported + /// + public bool SupportPartiallyRefund + { + get + { + return false; + } + } + + /// + /// Gets a value indicating whether refund is supported + /// + public bool SupportRefund + { + get + { + return false; + } + } + + /// + /// Gets a value indicating whether void is supported + /// + public bool SupportVoid + { + get + { + return false; + } + } + + /// + /// Gets a recurring payment type of payment method + /// + public RecurringPaymentType RecurringPaymentType + { + get + { + return RecurringPaymentType.NotSupported; + } + } + + /// + /// Gets a payment method type + /// + public PaymentMethodType PaymentMethodType + { + get + { + return PaymentMethodType.Redirection; + } + } + + /// + /// Gets a value indicating whether we should display a payment information page for this plugin + /// + public bool SkipPaymentInfo + { + get + { + return false; + } + } + + public string X2 { get; private set; } + + #endregion + } +} diff --git a/Nop.Plugin.Payments.PayGate/PayGatePaymentSettings.cs b/Nop.Plugin.Payments.PayGate/PayGatePaymentSettings.cs index f6d8e56..128f038 100644 --- a/Nop.Plugin.Payments.PayGate/PayGatePaymentSettings.cs +++ b/Nop.Plugin.Payments.PayGate/PayGatePaymentSettings.cs @@ -1,13 +1,13 @@ -using Nop.Core.Configuration; - -namespace Nop.Plugin.Payments.PayGate -{ - public class PayGatePaymentSettings : ISettings - { - public bool UseSandbox { get; set; } - public string PayGateID { get; set; } - public string EncryptionKey { get; set; } - public bool EnableIpn { get; set; } - - } -} +using Nop.Core.Configuration; + +namespace Nop.Plugin.Payments.PayGate +{ + public class PayGatePaymentSettings : ISettings + { + public bool UseSandbox { get; set; } + public string PayGateID { get; set; } + public string EncryptionKey { get; set; } + public bool EnableIpn { get; set; } + + } +} diff --git a/Nop.Plugin.Payments.PayGate/Properties/AssemblyInfo.cs b/Nop.Plugin.Payments.PayGate/Properties/AssemblyInfo.cs index 245904c..d2f9d99 100644 --- a/Nop.Plugin.Payments.PayGate/Properties/AssemblyInfo.cs +++ b/Nop.Plugin.Payments.PayGate/Properties/AssemblyInfo.cs @@ -1,35 +1,35 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Nop.Plugin.Payments.PayGate")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nop Solutions, Ltd")] -[assembly: AssemblyProduct("Nop.Plugin.Payments.PayGate")] -[assembly: AssemblyCopyright("Copyright © Nop Solutions, Ltd")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a8f29f77-1893-4eff-882b-3f86885279e4")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Nop.Plugin.Payments.PayGate")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Nop Solutions, Ltd")] +[assembly: AssemblyProduct("Nop.Plugin.Payments.PayGate")] +[assembly: AssemblyCopyright("Copyright © Nop Solutions, Ltd")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a8f29f77-1893-4eff-882b-3f86885279e4")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Nop.Plugin.Payments.PayGate/RouteProvider.cs b/Nop.Plugin.Payments.PayGate/RouteProvider.cs index 53086dc..9b87ce7 100644 --- a/Nop.Plugin.Payments.PayGate/RouteProvider.cs +++ b/Nop.Plugin.Payments.PayGate/RouteProvider.cs @@ -1,32 +1,32 @@ -using System.Web.Mvc; -using System.Web.Routing; -using Nop.Web.Framework.Mvc.Routes; - -namespace Nop.Plugin.Payments.PayGate -{ - public partial class RouteProvider : IRouteProvider - { - public void RegisterRoutes(RouteCollection routes) - { - //PayGateReturnHandler - routes.MapRoute("Plugin.Payments.PayGate.PayGateReturnHandler", - "Plugins/PaymentPayGate/PayGateReturnHandler", - new { controller = "PaymentPayGate", action = "PayGateReturnHandler" }, - new[] { "Nop.Plugin.Payments.PayGate.Controllers" } - ); - //PayGateNotifyHandler - routes.MapRoute("Plugin.Payments.PayGate.PayGateNotifyHandler", - "Plugins/PaymentPayGate/PayGateNotifyHandler", - new { controller = "PaymentPayGate", action = "PayGateNotifyHandler" }, - new[] { "Nop.Plugin.Payments.PayGate.Controllers" } - ); - } - public int Priority - { - get - { - return 0; - } - } - } -} +using System.Web.Mvc; +using System.Web.Routing; +using Nop.Web.Framework.Mvc.Routes; + +namespace Nop.Plugin.Payments.PayGate +{ + public partial class RouteProvider : IRouteProvider + { + public void RegisterRoutes(RouteCollection routes) + { + //PayGateReturnHandler + routes.MapRoute("Plugin.Payments.PayGate.PayGateReturnHandler", + "Plugins/PaymentPayGate/PayGateReturnHandler", + new { controller = "PaymentPayGate", action = "PayGateReturnHandler" }, + new[] { "Nop.Plugin.Payments.PayGate.Controllers" } + ); + //PayGateNotifyHandler + routes.MapRoute("Plugin.Payments.PayGate.PayGateNotifyHandler", + "Plugins/PaymentPayGate/PayGateNotifyHandler", + new { controller = "PaymentPayGate", action = "PayGateNotifyHandler" }, + new[] { "Nop.Plugin.Payments.PayGate.Controllers" } + ); + } + public int Priority + { + get + { + return 0; + } + } + } +} diff --git a/Nop.Plugin.Payments.PayGate/Views/PaymentPayGate/Configure.cshtml b/Nop.Plugin.Payments.PayGate/Views/PaymentPayGate/Configure.cshtml index 39a10d9..2e60bc0 100644 --- a/Nop.Plugin.Payments.PayGate/Views/PaymentPayGate/Configure.cshtml +++ b/Nop.Plugin.Payments.PayGate/Views/PaymentPayGate/Configure.cshtml @@ -1,93 +1,93 @@ -@{ - Layout = ""; -} -@model ConfigurationModel -@using Nop.Plugin.Payments.PayGate.Models; -@using Nop.Web.Framework; -@Html.Action("StoreScopeConfiguration", "Setting", new { area = "Admin" }) - - - -@using (Html.BeginForm()) -{ - @Html.AntiForgeryToken() - - - - - - - - - - - - - - - - - - - - - - - -
- Open an Account: -
-
- 1. You need a Merchant Account with PayGate to accept online payments. Register a new - Merchant Account with PayGate by completing the online registration form at - https://www.paygate.co.za/get-started-with-paygate/ -
-
- 2. One of our sales agents will contact you to complete the registration process. -
- 3. You will be provided with your Paygate Merchant Credentials required to set up your Store. -
- 4. PayGate Supports only ZAR, EUR, USD currencies for Testing. -
-
-
- @Html.OverrideStoreCheckboxFor(model => model.UseSandbox_OverrideForStore, model => model.UseSandbox, Model.ActiveStoreScopeConfiguration) - @Html.NopLabelFor(model => model.UseSandbox) - - @Html.EditorFor(model => model.UseSandbox) - @Html.ValidationMessageFor(model => model.UseSandbox) -
- @Html.OverrideStoreCheckboxFor(model => model.PayGateID_OverrideForStore, model => model.PayGateID, Model.ActiveStoreScopeConfiguration) - @Html.NopLabelFor(model => model.PayGateID) - - @Html.EditorFor(model => model.PayGateID) - @Html.ValidationMessageFor(model => model.PayGateID) -
- @Html.OverrideStoreCheckboxFor(model => model.EncryptionKey_OverrideForStore, model => model.EncryptionKey, Model.ActiveStoreScopeConfiguration) - @Html.NopLabelFor(model => model.EncryptionKey) - - @Html.EditorFor(model => model.EncryptionKey) - @Html.ValidationMessageFor(model => model.EncryptionKey) -
- -
- +@{ + Layout = ""; +} +@model ConfigurationModel +@using Nop.Plugin.Payments.PayGate.Models; +@using Nop.Web.Framework; +@Html.Action("StoreScopeConfiguration", "Setting", new { area = "Admin" }) + + + +@using (Html.BeginForm()) +{ + @Html.AntiForgeryToken() + + + + + + + + + + + + + + + + + + + + + + + +
+ Open an Account: +
+
+ 1. You need a Merchant Account with PayGate to accept online payments. Register a new + Merchant Account with PayGate by completing the online registration form at + https://www.paygate.co.za/get-started-with-paygate/ +
+
+ 2. One of our sales agents will contact you to complete the registration process. +
+ 3. You will be provided with your Paygate Merchant Credentials required to set up your Store. +
+ 4. PayGate Supports only ZAR, EUR, USD currencies for Testing. +
+
+
+ @Html.OverrideStoreCheckboxFor(model => model.UseSandbox_OverrideForStore, model => model.UseSandbox, Model.ActiveStoreScopeConfiguration) + @Html.NopLabelFor(model => model.UseSandbox) + + @Html.EditorFor(model => model.UseSandbox) + @Html.ValidationMessageFor(model => model.UseSandbox) +
+ @Html.OverrideStoreCheckboxFor(model => model.PayGateID_OverrideForStore, model => model.PayGateID, Model.ActiveStoreScopeConfiguration) + @Html.NopLabelFor(model => model.PayGateID) + + @Html.EditorFor(model => model.PayGateID) + @Html.ValidationMessageFor(model => model.PayGateID) +
+ @Html.OverrideStoreCheckboxFor(model => model.EncryptionKey_OverrideForStore, model => model.EncryptionKey, Model.ActiveStoreScopeConfiguration) + @Html.NopLabelFor(model => model.EncryptionKey) + + @Html.EditorFor(model => model.EncryptionKey) + @Html.ValidationMessageFor(model => model.EncryptionKey) +
+ +
+ } \ No newline at end of file diff --git a/Nop.Plugin.Payments.PayGate/Views/PaymentPayGate/PaymentInfo.cshtml b/Nop.Plugin.Payments.PayGate/Views/PaymentPayGate/PaymentInfo.cshtml index c65c50c..5531305 100644 --- a/Nop.Plugin.Payments.PayGate/Views/PaymentPayGate/PaymentInfo.cshtml +++ b/Nop.Plugin.Payments.PayGate/Views/PaymentPayGate/PaymentInfo.cshtml @@ -1,10 +1,10 @@ -@{ - Layout = ""; -} - - - - -
- @T("Plugins.Payments.PayGate.Fields.RedirectionTip") -
+@{ + Layout = ""; +} + + + + +
+ @T("Plugins.Payments.PayGate.Fields.RedirectionTip") +
diff --git a/Nop.Plugin.Payments.PayGate/app.config b/Nop.Plugin.Payments.PayGate/app.config index b10d304..9ee87a0 100644 --- a/Nop.Plugin.Payments.PayGate/app.config +++ b/Nop.Plugin.Payments.PayGate/app.config @@ -1,39 +1,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Nop.Plugin.Payments.PayGate/packages.config b/Nop.Plugin.Payments.PayGate/packages.config index 6f1006d..4d690b0 100644 --- a/Nop.Plugin.Payments.PayGate/packages.config +++ b/Nop.Plugin.Payments.PayGate/packages.config @@ -1,7 +1,7 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/Nop.Plugin.Payments.PayGate/web.config b/Nop.Plugin.Payments.PayGate/web.config index a0898da..46451d8 100644 --- a/Nop.Plugin.Payments.PayGate/web.config +++ b/Nop.Plugin.Payments.PayGate/web.config @@ -1,47 +1,47 @@ - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index da5bf0e..6dcee62 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # PayWeb_NopCommerce_3 -## PayGate PayWeb3 NopCommerce plugin v1.1.1 for NopCommerce v3.90 +## PayGate PayWeb3 NopCommerce plugin v1.1.2 for NopCommerce v3.90 This is the PayGate PayWeb3 plugin for NopCommerce. Please feel free to contact the PayGate support team at support@paygate.co.za should you require any assistance. ## Installation [![How To Setup PayGate PayWeb for NopCommerce 3.9](https://appinlet.com/wp-content/uploads/2021/01/How-To-Setup-PayGate-PayWeb-for-NopCommerce-3.9.jpg)](http://www.youtube.com/watch?v=QXE6lnb3lfc "How To Setup PayGate PayWeb for NopCommerce 3.9") -Please navigate to the [releases page](https://github.com/PayGate/PayWeb_NopCommerce_3/releases), download the latest release (v1.1.1) and unzip. You will then be able to follow the integration guide PDF which is included in the zip. +Please navigate to the [releases page](https://github.com/PayGate/PayWeb_NopCommerce_3/releases), download the latest release (v1.1.2) and unzip. You will then be able to follow the integration guide PDF which is included in the zip. ## Collaboration