Skip to content

Commit

Permalink
Merge pull request #8 from appinlet/release/4.4.1
Browse files Browse the repository at this point in the history
Release/4.4.1
  • Loading branch information
appinlet authored Oct 4, 2021
2 parents a51ffc9 + 9526e32 commit 32d99ba
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ public class PaymentPayGateController : BasePaymentController
private readonly IPermissionService _permissionService;
private ILogger _logger;
private INotificationService _notificationService;
private IStoreContext _storeContext;

#endregion

#region Ctor

public PaymentPayGateController(IWorkContext workContext,
public PaymentPayGateController(
IWorkContext workContext,
IStoreService storeService,
ISettingService settingService,
IOrderService orderService,
Expand All @@ -52,7 +54,9 @@ public PaymentPayGateController(IWorkContext workContext,
IPermissionService permissionService,
ILogger logger,
PayGatePaymentSettings payGatePaymentSettings,
INotificationService notificationService)
INotificationService notificationService,
IStoreContext storeContext
)
{
this._workContext = workContext;
this._storeService = storeService;
Expand All @@ -64,6 +68,7 @@ public PaymentPayGateController(IWorkContext workContext,
this._payGatePaymentSettings = payGatePaymentSettings;
this._logger = logger;
this._notificationService = notificationService;
this._storeContext = storeContext;
}

#endregion
Expand All @@ -84,7 +89,7 @@ public async void PayGateNotifyHandler(IFormCollection form)
await _logger.InformationAsync("PayGateNotifyHandler start. Order no.: " + reference);

//Order order = _orderService.GetOrderById(Int32.Parse(Request.Query["pgnopcommerce"]));
Order order = await _orderService.GetOrderByIdAsync(Int32.Parse(Request.Form["USER1"]));
Order order = await _orderService.GetOrderByIdAsync(Int32.Parse(reference));

int orderId = 0;
if (order != null)
Expand Down Expand Up @@ -114,21 +119,23 @@ public async void PayGateNotifyHandler(IFormCollection form)
//Validate checksum for the posted form fields
var formData = new NameValueCollection();
var formDataJS = "";
string[] keys = Request.Form.Keys.ToArray();
for (int i = 0; i < keys.Length; i++)
var checkstring = "";

foreach(var entry in form)
{
formData[keys[i]] = Request.Form[keys[i]];
formDataJS += keys[i] + "=" + formData[keys[i]] + "&";
var key = entry.Key;
var val = entry.Value;
formData[key] = val;
if (key != "CHECKSUM")
{
checkstring += val;
formDataJS += key + "=" + val + "&";
}
}

await _logger.InformationAsync("PayGateNotifyHandler: POST: " + formDataJS);

var checksum = formData["CHECKSUM"];
var checkstring = "";
for (var i = 0; i < formData.Count - 1; i++)
{
checkstring += formData[i];
}
checkstring += encryptionKey;

var ourChecksum = new PayGateHelper().CalculateMD5Hash(checkstring);
Expand Down Expand Up @@ -414,7 +421,7 @@ await _orderService.InsertOrderNoteAsync(new OrderNote
}
await _orderService.UpdateOrderAsync(order);
await _logger.InformationAsync("PayGateReturnHandler: Order marked paid");
return (IActionResult)Task.FromResult(RedirectToRoute("CheckoutCompleted", new { orderId = order.Id }));
return RedirectToRoute("CheckoutCompleted", new { orderId = order.Id });
}
else
{
Expand Down Expand Up @@ -469,8 +476,7 @@ public async Task<IActionResult> Configure()
return AccessDeniedView();

//load settings for a chosen store scope
var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
var payGatePaymentSettings = await _settingService.LoadSettingAsync<PayGatePaymentSettings>(storeScope);
var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync(); var payGatePaymentSettings = await _settingService.LoadSettingAsync<PayGatePaymentSettings>(storeScope);

var model = new ConfigurationModel();
model.TestMode = payGatePaymentSettings.TestMode;
Expand Down Expand Up @@ -506,7 +512,7 @@ public async Task<IActionResult> Configure(ConfigurationModel model)
return await Configure();

//load settings for a chosen store scope
var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync();
var payGatePaymentSettings = await _settingService.LoadSettingAsync<PayGatePaymentSettings>(storeScope);

//save settings
Expand All @@ -520,38 +526,18 @@ public async Task<IActionResult> Configure(ConfigurationModel model)
/* 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 */

await _settingService.ClearCacheAsync();

if (model.TestMode_OverrideForStore || storeScope == 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.TestMode, storeScope, false);
else if (storeScope > 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.TestMode, storeScope);

if (model.PayGateID_OverrideForStore || storeScope == 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.PayGateID, storeScope, false);
else if (storeScope > 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.PayGateID, storeScope);

if (model.EncryptionKey_OverrideForStore || storeScope == 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.EncryptionKey, storeScope, false);
else if (storeScope > 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.EncryptionKey, storeScope);

if (model.EnableIpn_OverrideForStore || storeScope == 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.EnableIpn, storeScope, false);
else if (storeScope > 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.EnableIpn, storeScope);

if (model.EnableRedirect_OverrideForStore || storeScope == 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.EnableRedirect, storeScope, false);
else if (storeScope > 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.EnableRedirect, storeScope);

if (model.UseSSL_OverrideForStore || storeScope == 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.UseSSL, storeScope, false);
else if (storeScope > 0)
await _settingService.SaveSettingAsync(payGatePaymentSettings, x => x.UseSSL, storeScope);
await _settingService.SaveSettingOverridablePerStoreAsync
(payGatePaymentSettings, x => x.TestMode, model.TestMode_OverrideForStore, storeScope, false);
await _settingService.SaveSettingOverridablePerStoreAsync
(payGatePaymentSettings, x => x.PayGateID, model.PayGateID_OverrideForStore, storeScope, false);
await _settingService.SaveSettingOverridablePerStoreAsync
(payGatePaymentSettings, x => x.EncryptionKey, model.EncryptionKey_OverrideForStore, storeScope, false);
await _settingService.SaveSettingOverridablePerStoreAsync
(payGatePaymentSettings, x => x.EnableIpn, model.EnableIpn_OverrideForStore, storeScope, false);
await _settingService.SaveSettingOverridablePerStoreAsync
(payGatePaymentSettings, x => x.EnableRedirect, model.EnableRedirect_OverrideForStore, storeScope, false);
await _settingService.SaveSettingOverridablePerStoreAsync
(payGatePaymentSettings, x => x.UseSSL, model.UseSSL_OverrideForStore, storeScope, false);

//now clear settings cache
await _settingService.ClearCacheAsync();
Expand Down
20 changes: 10 additions & 10 deletions Nop4.4/Nop.Plugin.Payments.PayGate/Views/Configure.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
@await Component.InvokeAsync("StoreScopeConfiguration")

<form asp-controller="PaymentPayGate" asp-action="Configure" method="post">
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-body">
<div class="cards-group">
<div class="card card-default">
<div class="card-body">
@Html.Raw(T("Plugins.Payments.PayGate.Instructions"))

<div class="form-group">
<div class="form-group row">
<div class="col-md-3">
<nop-override-store-checkbox asp-for="TestMode_OverrideForStore" asp-input="TestMode" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
<nop-label asp-for="TestMode" />
Expand All @@ -23,7 +23,7 @@
<span asp-validation-for="TestMode"></span>
</div>
</div>
<div class="form-group">
<div class="form-group row">
<div class="col-md-3">
<nop-override-store-checkbox asp-for="UseSSL_OverrideForStore" asp-input="UseSSL" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
<nop-label asp-for="UseSSL" />
Expand All @@ -33,7 +33,7 @@
<span asp-validation-for="UseSSL"></span>
</div>
</div>
<div class="form-group">
<div class="form-group row">
<div class="col-md-3">
<nop-override-store-checkbox asp-for="PayGateID_OverrideForStore" asp-input="PayGateID" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
<nop-label asp-for="PayGateID" />
Expand All @@ -43,7 +43,7 @@
<span asp-validation-for="PayGateID"></span>
</div>
</div>
<div class="form-group">
<div class="form-group row">
<div class="col-md-3">
<nop-override-store-checkbox asp-for="EncryptionKey_OverrideForStore" asp-input="EncryptionKey" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
<nop-label asp-for="EncryptionKey" />
Expand All @@ -54,7 +54,7 @@
</div>
</div>
<h3>Enable one of the following methods. If neither is enabled, default will be "Redirect"</h3>
<div class="form-group">
<div class="form-group row">
<div class="col-md-3">
<nop-override-store-checkbox asp-for="EnableIpn_OverrideForStore" asp-input="EnableIpn" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
<nop-label asp-for="EnableIpn" />
Expand All @@ -64,7 +64,7 @@
<span asp-validation-for="EnableIpn"></span>
</div>
</div>
<div class="form-group">
<div class="form-group row">
<div class="col-md-3">
<nop-override-store-checkbox asp-for="EnableRedirect_OverrideForStore" asp-input="EnableRedirect" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
<nop-label asp-for="EnableRedirect" />
Expand All @@ -75,7 +75,7 @@
</div>
</div>

<div class="form-group">
<div class="form-group row">
<div class="col-md-9 col-md-offset-3">
<input type="submit" name="save" class="btn bg-primary" value="@T("Admin.Common.Save")" />
</div>
Expand Down
2 changes: 2 additions & 0 deletions Nop4.4/Nop.Plugin.Payments.PayGate/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
Date : Version: Description
=====================================

2021-10-04: v4.4.1 : Fix an issue with IPN support.

2021-09-29: v4.4.0 : Initial release.
2 changes: 1 addition & 1 deletion Nop4.4/Nop.Plugin.Payments.PayGate/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Group": "Payment methods",
"FriendlyName": "PayGate",
"SystemName": "Payments.PayGate",
"Version": "4.4.0",
"Version": "4.4.1",
"SupportedVersions": [ "4.40" ],
"Author": "App Inlet (Pty) Ltd",
"DisplayOrder": 1,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Group": "Payment methods",
"FriendlyName": "PayGate",
"SystemName": "Payments.PayGate",
"Version": "4.4.0",
"Version": "4.4.1",
"SupportedVersions": [ "4.40" ],
"Author": "App Inlet (Pty) Ltd",
"DisplayOrder": 1,
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# PayWeb_NopCommerce_4
## PayGate PayWeb3 NopCommerce plugin v4.4.0 for NopCommerce v4.40
## PayGate PayWeb3 NopCommerce plugin v4.4.1 for NopCommerce v4.40

This is the PayGate PayWeb3 plugin for NopCommerce. Please feel free to contact the PayGate support team at [email protected] should you require any assistance.

## Installation
[![How To Setup PayGate PayWeb for NopCommerce 4](https://appinlet.com/wp-content/uploads/2021/02/NopCommerce-4-Integration.jpg)](http://www.youtube.com/watch?v=RfBpKRJi9HA "How To Setup PayGate PayWeb for NopCommerce 4")

Please navigate to the [releases page](https://github.com/PayGate/PayWeb_NopCommerce_4/releases), download the latest release (v4.4.0) 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_4/releases), download the latest release (v4.4.1) and unzip. You will then be able to follow the integration guide PDF which is included in the zip.

## Collaboration

Expand Down

0 comments on commit 32d99ba

Please sign in to comment.