-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginPsigate.php
More file actions
254 lines (224 loc) · 12.6 KB
/
PluginPsigate.php
File metadata and controls
254 lines (224 loc) · 12.6 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
/*****************************************************************/
// function plugin_psigate_variables($params) - required function
/*****************************************************************/
require_once 'modules/admin/models/GatewayPlugin.php';
/**
* @package Plugins
*/
class PluginPsigate extends GatewayPlugin
{
function getVariables()
{
/* Specification
itemkey - used to identify variable in your other functions
type - text,textarea,yesno,password
description - description of the variable, displayed in ClientExec
*/
$variables = array (
lang("Plugin Name") => array (
"type" =>"hidden",
"description" =>lang("How CE sees this plugin (not to be confused with the Signup Name)"),
"value" =>lang("PSiGate")
),
lang("Store Name") => array (
"type" =>"text",
"description" =>lang("ID used to identify you to PSiGate.<br>NOTE: This ID is required if you have selected PSiGate as a payment gateway for any of your clients."),
"value" =>""
),
lang("Passphrase") => array (
"type" =>"password",
"description" =>lang("Your PSiGate passphrase used to authenticate a valid transaction."),
"value" =>""
),
lang("Demo Mode") => array (
"type" =>"yesno",
"description" =>lang("Select YES if you want to set this plugin in Demo mode for testing purposes."),
"value" =>"1"
),
lang("Visa") => array (
"type" =>"yesno",
"description" =>lang("Select YES to allow Visa card acceptance with this plugin. No will prevent this card type."),
"value" =>"1"
),
lang("MasterCard") => array (
"type" =>"yesno",
"description" =>lang("Select YES to allow MasterCard acceptance with this plugin. No will prevent this card type."),
"value" =>"1"
),
lang("AmericanExpress") => array (
"type" =>"yesno",
"description" =>lang("Select YES to allow American Express card acceptance with this plugin. No will prevent this card type."),
"value" =>"0"
),
lang("Discover") => array (
"type" =>"yesno",
"description" =>lang("Select YES to allow Discover card acceptance with this plugin. No will prevent this card type."),
"value" =>"0"
),
lang("Invoice After Signup") => array (
"type" =>"yesno",
"description" =>lang("Select YES if you want an invoice sent to the client after signup is complete."),
"value" =>"1"
),
lang("Signup Name") => array (
"type" =>"text",
"description" =>lang("Select the name to display in the signup process for this payment type. Example: eCheck or Credit Card."),
"value" =>"Credit Card"
),
lang("Accept CC Number") => array (
"type" =>"yesno",
"description" =>lang("Selecting YES allows the entering of CC numbers when using this plugin type. No will prevent entering of cc information"),
"value" =>"1"
),
lang("Dummy Plugin") => array (
"type" =>"hidden",
"description" =>lang("1 = Only used to specify a billing type for a client. 0 = full fledged plugin requiring complete functions"),
"value" =>"0"
),
lang("Auto Payment") => array (
"type" =>"hidden",
"description" =>lang("No description"),
"value" =>"1"
),
lang("Check CVV2") => array (
"type" =>"hidden",
"description" =>lang("Select YES if you want to accept CVV2 for this plugin."),
"value" =>"1"
)
);
return $variables;
}
/*****************************************************************/
// function plugin_psigate_singlepayment($params) - required function
/*****************************************************************/
function singlepayment($params)
{
//Function needs to build the url to the payment processor
//Plugin variables can be accesses via $params["plugin_[pluginname]_[variable]"] (ex. $params["plugin_paypal_UserID"])
return $this->autopayment($params);
}
/**********************************************************************************/
// function plugin_psigate_autopayment($params) - plugin function, used internally
/**********************************************************************************/
function autopayment($params)
{
require_once 'class.psigate_xml.php';
require_once 'library/CE/NE_Network.php';
$psi = new PsiGatePayment();
// used for callback
$transType = 'charge';
$ip = CE_Lib::getRemoteAddr();
$host = @gethostbyaddr($ip);
if ($params["plugin_psigate_Demo Mode"] == 0) {
$psi->setGatewayURL('https://realtime.psigate.com/xml');
} else {
$psi->setGatewayURL('https://realtimestaging.psigate.com/xml');
}
$psi->setStoreID($params["plugin_psigate_Store Name"]);
$psi->setPassPhrase($params["plugin_psigate_Passphrase"]); // Assures authenticity
$psi->setOrderID(""); // Order ID. Leave blank to have PSiGate assign
$psi->setPaymentType('CC');
$psi->setCardAction('0'); // 1 for Authorize, 0 for Immediate Charge
$psi->setSubTotal(sprintf("%01.2f", round($params["invoiceTotal"], 2))); // Amount
$psi->setCardNumber($params["userCCNumber"]); // Card Number
$psi->setCardExpMonth(mb_substr($params["userCCExp"], 0, 2)); // Month in 2-digit format
$psi->setCardExpYear(mb_substr($params["userCCExp"], strpos($params["userCCExp"], "/")+3));
$psi->setCardIDNumber($params["userCCCVV2"]);
$psi->setUserID($params['userID']); // Unique customer identifier set by merchant.
$psi->setBname($params['userFirstName']." ".$params['userLastName']); // Billing Name
$psi->setBcompany($params["userOrganization"]); // Company Name
$psi->setBaddress1($params["userAddress"]); // Billing Address 1
$psi->setBcity($params["userCity"]); // Billing City
$psi->setBprovince($params["userState"]); // Billing state or province
$psi->setBpostalCode($params["userZipcode"]); // Billing Zip
$psi->setBcountry($params["userCountry"]);
$psi->setPhone($params["userPhone"]); // Customer Phone
$psi->setEmail($params["userEmail"]); // Customer Email
$psi->setCustomerIP($ip); // Customer IP address, for fraud
$psi->setComments($params["invoiceDescription"]);
// doPayment is not safe for used with E_NOTICE
$errorReporting = error_reporting();
error_reporting(0);
// Send transaction data to the gateway
$psi->doPayment();
error_reporting($errorReporting);
if ($params['isSignup']==1) {
$bolInSignup = true;
} else {
$bolInSignup = false;
}
include 'plugins/gateways/psigate/callback.php';
//Return error code
$tReturnValue = "";
if ($psi->getTrxnApproved() == 'APPROVED') {
$tReturnValue = "";
} else {
$tReturnValue = $psi->getTrxnApproved()." Error: ".$psi->getErrorMessage();
}
return $tReturnValue;
}
function credit($params)
{
require_once 'class.psigate_xml.php';
require_once 'library/CE/NE_Network.php';
$psi = new PsiGatePayment();
// used for callback
$transType = 'void';
$ip = CE_Lib::getRemoteAddr();
$host = @gethostbyaddr($ip);
if ($params["plugin_psigate_Demo Mode"] == 0) {
$psi->setGatewayURL('https://realtime.psigate.com/xml');
} else {
$psi->setGatewayURL('https://realtimestaging.psigate.com/xml');
}
$psi->setStoreID($params["plugin_psigate_Store Name"]);
$psi->setPassPhrase($params["plugin_psigate_Passphrase"]); // Assures authenticity
//$psi->setOrderID($params["invoiceRefundTransactionId"]); // Order ID. Leave blank to have PSiGate assign
$OrderArray = explode(" | ", $params["invoiceRefundTransactionId"]);
$psi->setTrxnTransRefNumber($OrderArray[0]);
$psi->setOrderID((isset($OrderArray[1]))? $OrderArray[1] : ""); // Order ID. Leave blank to have PSiGate assign
$psi->setPaymentType('CC');
$psi->setCardAction('9'); // 1 for Authorize, 0 for Immediate Charge, 9 for void, 3 for credit
$psi->setSubTotal(sprintf("%01.2f", round($params["invoiceTotal"], 2))); // Amount
$psi->setCardNumber($params["userCCNumber"]); // Card Number
$psi->setCardExpMonth(mb_substr($params["userCCExp"], 0, 2)); // Month in 2-digit format
$psi->setCardExpYear(mb_substr($params["userCCExp"], strpos($params["userCCExp"], "/")+3));
$psi->setUserID($params['userID']); // Unique customer identifier set by merchant.
$psi->setBname($params['userFirstName']." ".$params['userLastName']); // Billing Name
$psi->setBcompany($params["userOrganization"]); // Company Name
$psi->setBaddress1($params["userAddress"]); // Billing Address 1
$psi->setBcity($params["userCity"]); // Billing City
$psi->setBprovince($params["userState"]); // Billing state or province
$psi->setBpostalCode($params["userZipcode"]); // Billing Zip
$psi->setBcountry($params["userCountry"]);
$psi->setPhone($params["userPhone"]); // Customer Phone
$psi->setEmail($params["userEmail"]); // Customer Email
$psi->setCustomerIP($ip); // Customer IP address, for fraud
$psi->setComments($params["invoiceDescription"]);
// doPayment is not safe for used with E_NOTICE
$errorReporting = error_reporting();
error_reporting(0);
// Send transaction data to the gateway
$psi->doPayment();
// if void failed, try refunding it
if ($psi->getTrxnApproved() != 'APPROVED') {
$psi->setCardAction(3); // credit
$psi->doPayment();
$transType = 'refund';
}
error_reporting($errorReporting);
if ($params['isSignup']==1) {
$bolInSignup = true;
} else {
$bolInSignup = false;
}
include 'plugins/gateways/psigate/callback.php';
//Return error code
if ($psi->getTrxnApproved() == 'APPROVED') {
return array('AMOUNT' => $psi->getTrxnSubTotal());
} else {
return $psi->getTrxnApproved()." Error: ".$psi->getErrorMessage();
}
}
}