-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotify.ashx.cs
134 lines (108 loc) · 4.75 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using System;
using System.Web;
using NBrightCore.common;
using Nevoweb.DNN.NBrightBuy.Components;
using OS_sogecommerce;
namespace OS_sogecommerce
{
/// <summary>
/// Summary description for XMLconnector
/// </summary>
public class Notify : IHttpHandler
{
private String _lang = "";
/// <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 modCtrl = new NBrightBuyController();
var info = ProviderUtils.GetProviderSettings();
try
{
var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode");
var orderid = context.Request.Form.Get("vads_order_id");
string clientlang = context.Request.Form.Get("vads_order_info");
var rtnMsg = "SECURITY WARNING";
var sig1 = context.Request.Form.Get("signature");
var strMacCalc = ProviderUtils.GetSignatureReturnData(info.GetXmlProperty("genxml/textbox/certificate"), context.Request);
var sig2 = ProviderUtils.GetSignature(strMacCalc);
var debugMsg = "START CALL notify.ashx " + DateTime.Now.ToString("s") + " </br>";
if (debugMode)
{
foreach (var f in context.Request.Form.AllKeys)
{
debugMsg += f + ": " + context.Request.Form.Get(f) + "</br>";
}
debugMsg += "NBrightSystemPay DEBUG: " + DateTime.Now.ToString("s") + " </br>";
debugMsg += sig1 + " </br>";
debugMsg += sig2 + " </br>";
info.SetXmlProperty("genxml/debugmsg", debugMsg);
modCtrl.Update(info);
}
else
{
if (info.GetXmlProperty("genxml/debugmsg") != "")
{
info.SetXmlProperty("genxml/debugmsg", "");
modCtrl.Update(info);
}
}
if (sig1 == sig2)
{
// ------------------------------------------------------------------------
rtnMsg = "";
int nBrightSystemPayStoreOrderId = 0;
if (Utils.IsNumeric(orderid)) nBrightSystemPayStoreOrderId = Convert.ToInt32(orderid);
if (debugMode) debugMsg += "OrderId: " + nBrightSystemPayStoreOrderId + " vads_order_id: " + orderid + " </br>";
if (nBrightSystemPayStoreOrderId > 0)
{
var orderData = new OrderData(nBrightSystemPayStoreOrderId);
string nBrightSystemPayStatusCode = ProviderUtils.GetStatusCode(orderData, context.Request);
if (debugMode) debugMsg += "NBrightSystemPayStatusCode: " + nBrightSystemPayStatusCode + " </br>";
// Status return "00" is payment successful
if (nBrightSystemPayStatusCode == "00")
{
//set order status to Payed
orderData.PaymentOk();
}
else
{
orderData.PaymentFail();
}
orderData.Save();
}
if (debugMode)
{
debugMsg += "Return Message: " + rtnMsg;
info.SetXmlProperty("genxml/debugmsg", debugMsg);
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)
{
if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response.
{
info.SetXmlProperty("genxml/debugmsg", "NBrightSystemPay ERROR: " + ex.ToString());
modCtrl.Update(info);
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}