Skip to content

Commit 1737619

Browse files
committed
Notifications endpoint, reconcile and workflow mapping updates.
1 parent 5432a17 commit 1737619

File tree

20 files changed

+429
-56
lines changed

20 files changed

+429
-56
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"code": "USD",
4+
"name": "US Dollar"
5+
},
6+
{
7+
"code": "EUR",
8+
"name": "Euro"
9+
},
10+
{
11+
"code": "GBP",
12+
"name": "British Pound"
13+
},
14+
{
15+
"code": "DKK",
16+
"name": "Danish Krone"
17+
}
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function CurrencyController($scope, umbracoFormsIntegrationsCommerceEMerchantPayResource) {
2+
3+
var vm = this;
4+
5+
umbracoFormsIntegrationsCommerceEMerchantPayResource.getCurrencies().then(function (response) {
6+
vm.currencies = response;
7+
});
8+
9+
vm.saveCurrency = function () {
10+
$scope.setting.value = vm.selectedCurrency;
11+
}
12+
}
13+
14+
angular.module("umbraco")
15+
.controller("UmbracoForms.Integrations.Commerce.eMerchantPay.CurrencyController", CurrencyController);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div ng-controller="UmbracoForms.Integrations.Commerce.eMerchantPay.CurrencyController as vm">
2+
3+
<div>
4+
<select ng-model="vm.selectedCurrency" ng-click="vm.saveCurrency()">
5+
<option value="">Select currency</option>
6+
<option ng-repeat="currency in vm.currencies" value="{{ currency.code }}">{{ currency.name }}</option>
7+
</select>
8+
</div>
9+
10+
</div>

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

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

33
var vm = this;
44

@@ -28,8 +28,9 @@
2828
$scope.setting.value = JSON.stringify(vm.mappings);
2929
}
3030

31+
3132
function init() {
32-
vm.customerProperties = ["Email", "FirstName", "LastName", "Phone", "Address", "ZipCode", "City", "State", "Country"];
33+
vm.customerProperties = ["Email", "FirstName", "LastName", "Phone", "Address", "ZipCode", "City", "State", "Country", "Status", "UniqueId"];
3334

3435
vm.fields = [];
3536
vm.selectedCustomerProperty = "";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function eMerchantPayResource($http, umbRequestHelper) {
2+
3+
const apiEndpoint = "backoffice/UmbracoFormsIntegrationsCommerceEmerchantPay/EmerchantPay";
4+
5+
return {
6+
getCurrencies: function () {
7+
return umbRequestHelper.resourcePromise(
8+
$http.get(`${apiEndpoint}/GetCurrencies`),
9+
"Failed to get resource");
10+
},
11+
};
12+
}
13+
14+
angular.module('umbraco.resources').factory('umbracoFormsIntegrationsCommerceEMerchantPayResource', eMerchantPayResource);
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"javascript": [
3-
"~/App_Plugins/UmbracoForms.Integrations/Commerce/eMerchantPay/customer-details-mapper.controller.js"
4-
],
3+
"~/App_Plugins/UmbracoForms.Integrations/Commerce/eMerchantPay/customer-details-mapper.controller.js",
4+
"~/App_Plugins/UmbracoForms.Integrations/Commerce/eMerchantPay/currency.controller.js",
5+
"~/App_Plugins/UmbracoForms.Integrations/Commerce/eMerchantPay/emerchantpay.resource.js"
6+
],
57
"css": [ "" ]
68
}

src/Umbraco.Forms.Integrations.Commerce.EMerchantPay/Builders/MappingBuilder.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44

55
using Umbraco.Forms.Core.Persistence.Dtos;
6+
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Helpers;
67
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Models.Dtos;
78

89
namespace Umbraco.Forms.Integrations.Commerce.EMerchantPay.Builders
@@ -22,18 +23,15 @@ public MappingBuilder SetValues(Record record, List<Mapping> mappings)
2223
Values.State = GetValue(nameof(MappingValues.State), record, mappings);
2324
Values.Country = GetValue(nameof(MappingValues.Country), record, mappings);
2425
Values.Phone = GetValue(nameof(MappingValues.Phone), record, mappings);
26+
Values.Status = GetValue(nameof(MappingValues.Status), record, mappings);
27+
Values.UniqueId = GetValue(nameof(MappingValues.UniqueId), record, mappings);
2528

2629
return this;
2730
}
2831

29-
public MappingBuilder SetSuccessUrl()
32+
private string GetValue(string propertyName, Record record, List<Mapping> mappings)
3033
{
31-
return this;
32-
}
33-
34-
private string GetValue(string property, Record record, List<Mapping> mappings)
35-
{
36-
var key = mappings.First(p => p.CustomerProperty == nameof(property)).Field.Id;
34+
var key = mappings.First(p => p.CustomerProperty == propertyName).Field.Id;
3735
return record.RecordFields[Guid.Parse(key)].ValuesAsString();
3836
}
3937

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public PaymentProviderSettings(NameValueCollection appSettings)
1818
Username = appSettings[Constants.Configuration.UsernameKey];
1919

2020
Password = appSettings[Constants.Configuration.PasswordKey];
21+
22+
UmbracoBaseUrl = appSettings[Constants.Configuration.UmbracoBaseUrlKey];
2123
}
2224

2325
public string GatewayBaseUrl { get; set; }
@@ -27,5 +29,7 @@ public PaymentProviderSettings(NameValueCollection appSettings)
2729
public string Username { get; set; }
2830

2931
public string Password { get; set; }
32+
33+
public string UmbracoBaseUrl { get; set; }
3034
}
3135
}

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,21 @@ public class Constants
55
{
66
public const string WorkflowId = "b2731255-2e48-4345-9ae5-aaf5b8bfb10a";
77

8-
public const int RequiredMappingsNo = 9;
8+
/// <summary>
9+
/// Fields mandatory for mapping:
10+
/// 1. FirstName
11+
/// 2. LastName
12+
/// 3. Address
13+
/// 4. ZipCode
14+
/// 5. City
15+
/// 6. State
16+
/// 7. Country
17+
/// 8. Email
18+
/// 9. Phone
19+
/// 10. Status
20+
/// 11. UniqueId
21+
/// </summary>
22+
public const int RequiredMappingsNo = 11;
923

1024
public static class Configuration
1125
{
@@ -18,11 +32,15 @@ public static class Configuration
1832
public const string UsernameKey = "Umbraco.Forms.Integrations.Commerce.eMerchantPay.Username";
1933

2034
public const string PasswordKey = "Umbraco.Forms.Integrations.Commerce.eMerchantPay.Password";
35+
36+
public const string UmbracoBaseUrlKey = "Umbraco.Forms.Integrations.Commerce.eMerchantPay.UmbracoBaseUrl";
2137
}
2238

2339
public static class ErrorCode
2440
{
2541
public const string ConsumerExists = "701";
42+
43+
public const string WorkflowError = "400";
2644
}
2745

2846
public static class RootNode
@@ -36,6 +54,8 @@ public static class RootNode
3654
public const string RetrieveConsumerResponse = "retrieve_consumer_response";
3755

3856
public const string WpfPayment = "wpf_payment";
57+
58+
public const string WpfReconcile = "wpf_reconcile";
3959
}
4060
}
4161
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading;
6+
7+
#if NETCOREAPP
8+
using Microsoft.AspNetCore.Hosting;
9+
using Microsoft.AspNetCore.Mvc;
10+
11+
using Umbraco.Cms.Web.BackOffice.Controllers;
12+
using Umbraco.Cms.Web.Common.Attributes;
13+
#else
14+
using System.Web;
15+
using System.Web.Http;
16+
17+
using Umbraco.Web.Mvc;
18+
using Umbraco.Web.WebApi;
19+
#endif
20+
using Newtonsoft.Json;
21+
22+
using Umbraco.Forms.Integrations.Commerce.EMerchantPay.Models.Dtos;
23+
24+
25+
namespace Umbraco.Forms.Integrations.Commerce.EMerchantPay.Controllers
26+
{
27+
[PluginController("UmbracoFormsIntegrationsCommerceEmerchantPay")]
28+
public class EmerchantPayController : UmbracoAuthorizedApiController
29+
{
30+
private static readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();
31+
32+
#if NETCOREAPP
33+
private readonly IWebHostEnvironment _webHostEnvironment;
34+
35+
public EmerchantPayController(IWebHostEnvironment webHostEnvironment)
36+
{
37+
_webHostEnvironment = webHostEnvironment;
38+
}
39+
#endif
40+
41+
[HttpGet]
42+
public IEnumerable<CurrencyDto> GetCurrencies()
43+
{
44+
#if NETCOREAPP
45+
string currenciesFilePath =
46+
$"{_webHostEnvironment.ContentRootPath}/App_Plugins/UmbracoForms.Integrations/Commerce/eMerchantPay/currencies.json";
47+
#else
48+
string currenciesFilePath =
49+
HttpContext.Current.Server.MapPath(
50+
"~/App_Plugins/UmbracoForms.Integrations/Commerce/eMerchantPay/currencies.json");
51+
#endif
52+
53+
_lock.EnterReadLock();
54+
55+
try
56+
{
57+
var content = System.IO.File.ReadAllText(currenciesFilePath);
58+
59+
var d = JsonConvert.DeserializeObject<IEnumerable<CurrencyDto>>(content);
60+
61+
return d;
62+
}
63+
catch (FileNotFoundException ex)
64+
{
65+
return Enumerable.Empty<CurrencyDto>();
66+
}
67+
catch (Exception ex)
68+
{
69+
return Enumerable.Empty<CurrencyDto>();
70+
}
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)