-
Notifications
You must be signed in to change notification settings - Fork 1
/
notify.ashx.cs
119 lines (102 loc) · 4.41 KB
/
notify.ashx.cs
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
using System;
using System.Runtime.Remoting.Contexts;
using System.Threading.Tasks;
using System.Web;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Services.Log.EventLog;
using Mollie.Api.Client;
using Mollie.Api.Client.Abstract;
using Mollie.Api.Models.Payment.Response;
using NBrightCore.common;
using Nevoweb.DNN.NBrightBuy.Components;
namespace OS_Mollie.DNN.NBrightStore
{
/// <summary>
/// Summary description for XMLconnector
/// </summary>
public class OS_MollieNotify : IHttpHandler
{
/// <summary>
/// This function needs to process and returned message from the bank.
/// This processing may vary widely between banks.
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
var info = ProviderUtils.GetProviderSettings();
var objEventLog = new EventLogController();
PortalSettings portalsettings = new PortalSettings();
try
{
var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode");
var debugMsg = "START CALL" + DateTime.Now.ToString("s") + " </br>";
var rtnMsg = "version=2" + Environment.NewLine + "cdr=1";
var orderid = Utils.RequestQueryStringParam(context, "orderid");
debugMsg += "orderid: " + orderid + "</br>";
if (Utils.IsNumeric(orderid))
{
var orderData = new OrderData(Convert.ToInt32(orderid));
PaymentResponse paymentClientResult = ProviderUtils.GetOrderPaymentResponse(orderData, "OS_MollieNotify.ProcessRequest");
objEventLog.AddLog("Mollie Webhook call for orderid: " + orderid , "Status: " + paymentClientResult.Status, portalsettings, -1, EventLogController.EventLogType.ADMIN_ALERT);
//Waiting for Payment 060
//Payment OK 040
//Incomplete 010
//Cancelled 030
switch (paymentClientResult.Status.ToString().ToLower())
{
case "paid":
orderData.PaymentOk("040", true);
rtnMsg = "OK";
break;
case "failed":
orderData.PaymentFail("010");
rtnMsg = "OK";
break;
case "canceled":
orderData.PaymentFail("030");
rtnMsg = "OK";
break;
case "expired":
orderData.PaymentFail("010");
rtnMsg = "OK";
break;
default:
orderData.PaymentFail("010");
rtnMsg = "OK";
break;
}
}
if (debugMode)
{
debugMsg += "Return Message: " + rtnMsg;
info.SetXmlProperty("genxml/debugmsg", debugMsg);
var modCtrl = new NBrightBuyController();
modCtrl.Update(info);
}
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(rtnMsg);
HttpContext.Current.Response.ContentType = "text/plain";
HttpContext.Current.Response.CacheControl = "no-cache";
HttpContext.Current.Response.Expires = -1;
HttpContext.Current.Response.End();
}
catch (Exception ex)
{
objEventLog.AddLog("Mollie Webhook call failed" , ex.Message + " " + ex.InnerException , portalsettings, -1, EventLogController.EventLogType.ADMIN_ALERT);
if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response.
{
info.SetXmlProperty("genxml/debugmsg", "OS_Mollie ERROR: " + ex.ToString());
var modCtrl = new NBrightBuyController();
modCtrl.Update(info);
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}