Skip to content

Commit f42198d

Browse files
committed
Feedback updates
1 parent 90ece4d commit f42198d

File tree

13 files changed

+177
-56
lines changed

13 files changed

+177
-56
lines changed

src/Umbraco.Forms.Integrations.Commerce.EMerchantPay/App_Plugins/UmbracoForms.Integrations/Commerce/eMerchantPay/customer-details-mapper.controller.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function CustomerDetailsMapperController($scope, notificationsService, emerchantpayService) {
1+
function CustomerDetailsMapperController($scope, notificationsService, emerchantpayService, umbracoFormsIntegrationsCommerceEMerchantPayResource) {
22

33
var vm = this;
44

@@ -31,7 +31,10 @@
3131

3232

3333
function init() {
34-
vm.customerProperties = ["Email", "FirstName", "LastName", "Phone", "Address", "ZipCode", "City", "State", "Country"];
34+
35+
umbracoFormsIntegrationsCommerceEMerchantPayResource.getMappingFields().then(function (response) {
36+
vm.customerProperties = response;
37+
});
3538

3639
vm.fields = [];
3740

src/Umbraco.Forms.Integrations.Commerce.EMerchantPay/App_Plugins/UmbracoForms.Integrations/Commerce/eMerchantPay/emerchantpay.resource.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
$http.get(`${apiEndpoint}/GetCurrencies`),
99
"Failed to get resource");
1010
},
11+
getMappingFields: function () {
12+
return umbRequestHelper.resourcePromise(
13+
$http.get(`${apiEndpoint}/GetMappingFields`),
14+
"Failed to get resource");
15+
}
1116
};
1217
}
1318

src/Umbraco.Forms.Integrations.Commerce.EMerchantPay/Configuration/PaymentProviderSettings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public PaymentProviderSettings(NameValueCollection appSettings)
2323

2424
Usage = appSettings[Constants.Configuration.UsageKey];
2525

26+
TransactionTypes = appSettings[Constants.Configuration.TransactionTypesKey];
27+
28+
MappingFields = appSettings[Constants.Configuration.MappingFieldsKey];
29+
2630
UmbracoBaseUrl = appSettings[Constants.Configuration.UmbracoBaseUrlKey];
2731
}
2832

@@ -41,5 +45,9 @@ public PaymentProviderSettings(NameValueCollection appSettings)
4145
public string UmbracoBaseUrl { get; set; }
4246

4347
public string Currencies { get; set; }
48+
49+
public string TransactionTypes { get; set; }
50+
51+
public string MappingFields { get; set; }
4452
}
4553
}

src/Umbraco.Forms.Integrations.Commerce.EMerchantPay/Constants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public static class Configuration
2323

2424
public const string CurrenciesKey = "Umbraco.Forms.Integrations.Commerce.eMerchantPay.Currencies";
2525

26+
public const string TransactionTypesKey = "Umbraco.Forms.Integrations.Commerce.eMerchantPay.TransactionTypes";
27+
28+
public const string MappingFieldsKey = "Umbraco.Forms.Integrations.Commerce.eMerchantPay.MappingFields";
29+
2630
public const string UmbracoBaseUrlKey = "Umbraco.Forms.Integrations.Commerce.eMerchantPay.UmbracoBaseUrl";
2731
}
2832

src/Umbraco.Forms.Integrations.Commerce.EMerchantPay/Controllers/EmerchantPayController.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,18 @@ public class EmerchantPayController : UmbracoAuthorizedApiController
3030
{
3131
private readonly CurrencyHelper _currencyHelper;
3232

33-
public EmerchantPayController(CurrencyHelper currencyHelper)
33+
private readonly MappingFieldHelper _mappingFieldHelper;
34+
35+
public EmerchantPayController(CurrencyHelper currencyHelper, MappingFieldHelper mappingFieldHelper)
3436
{
3537
_currencyHelper = currencyHelper;
38+
_mappingFieldHelper = mappingFieldHelper;
3639
}
3740

3841
[HttpGet]
3942
public IEnumerable<CurrencyDto> GetCurrencies() => _currencyHelper.GetCurrencies();
43+
44+
[HttpGet]
45+
public IEnumerable<string> GetMappingFields() => _mappingFieldHelper.GetMappings();
4046
}
4147
}

src/Umbraco.Forms.Integrations.Commerce.EMerchantPay/Controllers/PaymentProviderController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public HttpResponseMessage NotifyPayment(string formId, string recordUniqueId, s
5555
{
5656
// reconcile
5757
var reconcileTask =
58-
Task.Run(async () => await _paymentService.Reconcile(notificationDto.wpf_unique_id));
58+
Task.Run(async () => await _paymentService.Reconcile(notificationDto.UniqueId));
5959

6060
var reconcileResponse = reconcileTask.Result;
6161

@@ -75,7 +75,7 @@ public HttpResponseMessage NotifyPayment(string formId, string recordUniqueId, s
7575
if (reconcileResponse.Status == Constants.ErrorCode.WorkflowError)
7676
return new HttpResponseMessage(HttpStatusCode.BadRequest);
7777

78-
string notificationXml = $"<notification_echo><wpf_unique_id>{notificationDto.wpf_unique_id}</wpf_unique_id></notification_echo>";
78+
string notificationXml = $"<notification_echo><wpf_unique_id>{notificationDto.UniqueId}</wpf_unique_id></notification_echo>";
7979
return new HttpResponseMessage()
8080
{
8181
Content = new StringContent(notificationXml, Encoding.UTF8, "application/xml")

src/Umbraco.Forms.Integrations.Commerce.EMerchantPay/ExtensionMethods/CustomerDetailsMappingsExtensions.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#if NETCOREAPP
2+
using Microsoft.Extensions.Options;
3+
#else
4+
using System.Configuration;
5+
#endif
6+
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
10+
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Configuration;
11+
12+
namespace Umbraco.Forms.Integrations.Commerce.EMerchantPay.Helpers
13+
{
14+
public class MappingFieldHelper
15+
{
16+
private readonly PaymentProviderSettings _paymentProviderSettings;
17+
18+
#if NETCOREAPP
19+
public MappingFieldHelper(IOptions<PaymentProviderSettings> options)
20+
{
21+
_paymentProviderSettings = options.Value;
22+
}
23+
#else
24+
public MappingFieldHelper()
25+
{
26+
_paymentProviderSettings = new PaymentProviderSettings(ConfigurationManager.AppSettings);
27+
}
28+
#endif
29+
30+
public IEnumerable<string> GetMappings()
31+
{
32+
if (string.IsNullOrEmpty(_paymentProviderSettings.MappingFields))
33+
return Enumerable.Empty<string>();
34+
35+
try
36+
{
37+
return _paymentProviderSettings.MappingFields.Split(';');
38+
}
39+
catch
40+
{
41+
return Enumerable.Empty<string>();
42+
}
43+
44+
}
45+
46+
}
47+
}
48+
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
using System.ComponentModel;
2-
using System.Runtime.Serialization;
3-
using System.Xml.Serialization;
4-
1+

52
namespace Umbraco.Forms.Integrations.Commerce.EMerchantPay.Models.Dtos
63
{
74
public class NotificationDto
85
{
9-
public string TransactionId { get; set; }
6+
/// <summary>
7+
/// Alias for TransactionId
8+
/// </summary>
9+
public string wpf_transaction_id { get; set; }
10+
11+
public string TransactionId => wpf_transaction_id;
1012

13+
/// <summary>
14+
/// Alias for Unique ID
15+
/// </summary>
1116
public string wpf_unique_id { get; set; }
1217

13-
public string Status { get; set; }
18+
public string UniqueId => wpf_unique_id;
19+
20+
public string wpf_status { get; set; }
21+
22+
/// <summary>
23+
/// Alias for Status
24+
/// </summary>
25+
public string Status => wpf_status;
1426
}
1527
}

src/Umbraco.Forms.Integrations.Commerce.EMerchantPay/PaymentProviderComposer.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
using Umbraco.Cms.Core.DependencyInjection;
66
using Umbraco.Forms.Core.Providers;
77
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Configuration;
8-
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Helpers;
9-
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Services;
8+
109
#else
1110
using Umbraco.Core;
1211
using Umbraco.Core.Composing;
12+
#endif
13+
14+
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Models.Dtos;
1315
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Helpers;
1416
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Services;
15-
#endif
1617

1718
namespace Umbraco.Forms.Integrations.Commerce.EMerchantPay
1819
{
@@ -35,6 +36,10 @@ public void Compose(IUmbracoBuilder builder)
3536
builder.Services.AddSingleton<UrlHelper>();
3637

3738
builder.Services.AddSingleton<CurrencyHelper>();
39+
40+
builder.Services.AddSingleton<MappingFieldHelper>();
41+
42+
builder.Services.AddSingleton<IMappingService<Mapping>, MappingService>();
3843
}
3944
#else
4045
public void Compose(Composition composition)
@@ -46,6 +51,10 @@ public void Compose(Composition composition)
4651
composition.Register<UrlHelper>(Lifetime.Singleton);
4752

4853
composition.Register<CurrencyHelper>(Lifetime.Singleton);
54+
55+
composition.Register<MappingFieldHelper>(Lifetime.Singleton);
56+
57+
composition.Register<IMappingService<Mapping>, MappingService>(Lifetime.Singleton);
4958
}
5059
#endif
5160
}

0 commit comments

Comments
 (0)