forked from paypal/tech-talks
/
Application.cfc
136 lines (89 loc) · 3.89 KB
/
Application.cfc
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
135
136
<cfscript>
/**
@dateCreated "July 18, 2011"
@hint "You implement methods in Application.cfc to handle ColdFusion application events and set variables in the CFC to configure application characteristics."
*/
component output="false" {
/* **************************** APPLICATION VARIABLES **************************** */
THIS.name = "NCDevConCheckout01";
THIS.applicationTimeout = createTimeSpan(0, 2, 0, 0);
customtagpaths = "#getDirectoryFromPath(ExpandPath('../lib/'))#";
THIS.customTagPaths = customtagpaths;
THIS.serverSideFormValidation = true;
THIS.sessionManagement = true;
THIS.sessionTimeout = createTimeSpan(0, 0, 30, 0);
THIS.setClientCookies = true;
THIS.setDomainCookies = false;
THIS.scriptProtect = true;
THIS.secureJSON = false;
THIS.secureJSONPrefix = "";
THIS.enablerobustexception = true;
/* **************************** APPLICATION METHODS **************************** */
public void function onApplicationEnd(struct ApplicationScope=structNew()) {
return;
}
public boolean function onApplicationStart() {
return true;
}
public void function onRequestEnd() {
return;
}
public boolean function onRequestStart(required string TargetPage) {
request.serverURL = "https://api-3t.sandbox.paypal.com/nvp";
/* SUBJECT to be uncommented for UNIPAY all the other credentials like API username,
password,signature can be commented for UNIPAY
To enable Payments for Third Party Email whcih will be passed along with Partner's 3token credentials
uncomment both subject and 3 token credentials.
*/
//request.SUBJECT="sidney@x.com";
APIuserName = "sidney_1311957058_biz_api1.x.com";
APIPassword = "1311957099";
APISignature = "AsWOI0XsYOW6SY4-RFW6nmQX9L2GAx2Dvzlusmnc2lLkNlYS6cilwiEc";
//condition to check if it is UNIPAY
if (isdefined("SUBJECT") && (isdefined("APIuserName") eq "false" && isdefined("APIPassword") eq "false" && isdefined("APISignature") eq "false") )
{
request.UNIPAYSUBJECT="#SUBJECT#";
request.USER = "";
request.PWD = "";
request.SIGNATURE = "";
}
//condition to check if it is Payments for Third Party Email
if (isdefined("SUBJECT") && isdefined("APIuserName") && isdefined("APIPassword") && isdefined("APISignature"))
{
request.UNIPAYSUBJECT="#SUBJECT#";
request.USER = "#APIuserName#";
request.PWD = "#APIPassword#";
request.SIGNATURE = "#APISignature#";
}
//condition to check if it is 3 token credentials
if (isdefined("SUBJECT") eq "false" && isdefined("APIuserName") && isdefined("APIPassword") && isdefined("APISignature") )
{
request.UNIPAYSUBJECT="";
request.USER = "#APIuserName#";
request.PWD = "#APIPassword#";
request.SIGNATURE = "#APISignature#";
}
request.PayPalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
request.version = "78";
/*
By default the API requests doesn't go through proxy. To route the requests through a proxy server
set "useProxy" value as "true" and set values for proxyName and proxyPort. Set proxyName with
the Host Name or the IP address of the proxy server. proxyPort should be a valid port number.
eg:
useProxy = "true";
proxyName = "127.0.0.1";
proxyPort = "8081";
*/
request.useProxy = "false";
request.proxyName = "";
request.proxyPort = "";
return true;
}
public void function onSessionEnd(required struct SessionScope, struct ApplicationScope=structNew()) {
return;
}
public void function onSessionStart() {
return;
}
}
</cfscript>