-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProviderUtils.cs
More file actions
133 lines (108 loc) · 5.29 KB
/
ProviderUtils.cs
File metadata and controls
133 lines (108 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using DotNetNuke.Entities.Portals;
using NBrightCore.common;
using NBrightDNN;
using Nevoweb.DNN.NBrightBuy.Components;
using DnnC.Mollie.Api;
namespace DnnC.Mollie
{
public class ProviderUtils
{
public static String GetTemplateMollieData(String templatename, NBrightInfo pluginInfo)
{
var templ = GetTemplateData(templatename, pluginInfo);
#region "Get Mollie options from API"
var info = ProviderUtils.GetProviderSettings("DnnCMolliepayment");
var testMode = info.GetXmlPropertyBool("genxml/checkbox/testmode");
var testApiKey = info.GetXmlProperty("genxml/textbox/testapikey");
var liveApiKey = info.GetXmlProperty("genxml/textbox/liveapikey");
// Check to see if the test api keys is filled in,
// stops the error with the settings in the backoffice
if (testApiKey != "")
{
var apiKey = testApiKey;
if (!testMode)
{
apiKey = liveApiKey;
}
MollieClient mollieClient = new MollieClient();
mollieClient.setApiKey(apiKey);
var strPayOptions = "";
PaymentMethods methods = mollieClient.GetPaymentMethods();
Issuers issuers = mollieClient.GetIssuers();
foreach (PaymentMethod method in methods.data)
{
strPayOptions += "<tr>";
strPayOptions += "<td><input type='radio' id='" + method.id + "' value='" + method.id + "' name='group1' class='rdoBanks' /></td>";
strPayOptions += "<td><img src='" + method.image.normal + "' /></td>";
strPayOptions += "<td><strong>" + method.description + "</strong></td>";
strPayOptions += "</tr>";
if (method.id == "ideal")
{
strPayOptions += "<tr><td colspan='3'><div id='bank-holder' class='hidden'>";
strPayOptions += "<select id='mollieidealgatewaybankselectordropdown' name='mollieidealgatewaybankselectordropdown' class='bankSelector'>";
strPayOptions += "<option>" + info.GetXmlProperty("genxml/textbox/bankdropdowntext") + "</option>";
foreach (Issuer issuer in issuers.data)
{
strPayOptions += string.Format("<option value=\"{0}\">{1}</option>", issuer.id, issuer.name);
}
strPayOptions += "</select>";
strPayOptions += "</div></td></tr>";
}
strPayOptions += "<tr><td colspan='3'><hr/></td></tr>";
}
templ = templ.Replace("[PAYMENTMETHODS]", strPayOptions);
}
#endregion
return templ;
}
public static String GetTemplateData(String templatename, NBrightInfo pluginInfo)
{
var controlMapPath = HttpContext.Current.Server.MapPath("/DesktopModules/NBright/DnnCMollie");
var templCtrl = new NBrightCore.TemplateEngine.TemplateGetter(PortalSettings.Current.HomeDirectoryMapPath, controlMapPath, "Themes\\config", "");
var templ = templCtrl.GetTemplateData(templatename, Utils.GetCurrentCulture());
templ = Utils.ReplaceSettingTokens(templ, pluginInfo.ToDictionary());
templ = Utils.ReplaceUrlTokens(templ);
return templ;
}
public static NBrightInfo GetProviderSettings(String ctrlkey)
{
var info = (NBrightInfo)Utils.GetCache("DnnCMolliePaymentProvider" + PortalSettings.Current.PortalId.ToString(""));
if (info == null)
{
var modCtrl = new NBrightBuyController();
info = modCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "DnnCMolliePAYMENT", ctrlkey);
if (info == null)
{
info = new NBrightInfo(true);
info.GUIDKey = ctrlkey;
info.TypeCode = "DnnCMolliePAYMENT";
info.ModuleId = -1;
info.PortalId = PortalSettings.Current.PortalId;
}
Utils.SetCache("DnnCMolliePaymentProvider" + PortalSettings.Current.PortalId.ToString(""), info);
}
return info;
}
public static String GetBankRemotePost(OrderData orderData)
{
var rPost = new RemotePost();
var settings = ProviderUtils.GetProviderSettings("DnnCMolliepayment");
var payData = new PayData(orderData);
rPost.Url = orderData.PurchaseInfo.GetXmlProperty("genxml/posturl");
//Build the re-direct html
var rtnStr = rPost.GetPostHtml("/DesktopModules/NBright/DnnCMollie/Themes/config/img/loading.gif");
if (settings.GetXmlPropertyBool("genxml/checkbox/debugmode"))
{
File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_DnnCMolliepost.html", rtnStr);
}
return rtnStr;
}
}
}