-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotify.ashx.cs
More file actions
124 lines (101 loc) · 4.18 KB
/
notify.ashx.cs
File metadata and controls
124 lines (101 loc) · 4.18 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
using System;
using System.Runtime.Remoting.Contexts;
using System.Web;
using NBrightCore.common;
using Nevoweb.DNN.NBrightBuy.Components;
namespace OS_Square.DNN.NBrightStore
{
/// <summary>
/// Summary description for XMLconnector
/// </summary>
public class OS_SquareNotify : 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 = modCtrl.GetPluginSinglePageData("OS_Squarepayment", "OS_SquarePAYMENT", Utils.GetCurrentCulture());
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";
// ------------------------------------------------------------------------
// In this case the payment provider passes back data via form POST.
// Get the data we need.
string returnmessage = "";
int OS_SquareStoreOrderID = 0;
string OS_SquareCartID = "";
string OS_SquareClientLang = "";
var orderid = Utils.RequestQueryStringParam(context, "ref");
debugMsg += "orderid: " + orderid + "</br>";
if (Utils.IsNumeric(orderid))
{
var authcode = Utils.RequestQueryStringParam(context, "auto");
var errcode = Utils.RequestQueryStringParam(context, "rtnerr");
OS_SquareStoreOrderID = Convert.ToInt32(orderid);
// ------------------------------------------------------------------------
debugMsg += "OrderId: " + orderid + " </br>";
debugMsg += "errcode: " + errcode + " </br>";
debugMsg += "authcode: " + authcode + " </br>";
var orderData = new OrderData(OS_SquareStoreOrderID);
if (authcode == "")
rtnMsg = "KO";
else
rtnMsg = "OK";
if (authcode == "")
{
orderData.PaymentFail();
}
else
{
if (errcode == "00000")
{
orderData.PaymentOk();
}
else if (errcode == "99999")
{
orderData.PaymentOk("050");
}
else
{
orderData.PaymentFail();
}
}
}
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", "OS_Square ERROR: " + ex.ToString());
modCtrl.Update(info);
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}