WebPaymentSoftware_Pay - Version 0.1.0

Version Notes

First release

Download this release

Release Info

Developer wps
Extension WebPaymentSoftware_Pay
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/WebPaymentSoftware/Pay/Block/Form/Pay.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Payment
16
+ * @package WebPaymentSoftware_Pay
17
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class WebPaymentSoftware_Pay_Block_Form_Pay extends Mage_Payment_Block_Form_Ccsave
22
+ {
23
+ }
app/code/community/WebPaymentSoftware/Pay/Block/Info/Pay.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Payment
16
+ * @package WebPaymentSoftware_Pay
17
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class WebPaymentSoftware_Pay_Block_Info_Pay extends Mage_Payment_Block_Info
22
+ {
23
+ protected function _prepareSpecificInformation($transport = null)
24
+ {
25
+ if (null !== $this->_paymentSpecificInformation) {
26
+ return $this->_paymentSpecificInformation;
27
+ }
28
+ $info = $this->getInfo();
29
+ $transport = new Varien_Object();
30
+ $transport = parent::_prepareSpecificInformation($transport);
31
+ $transport->addData(array(
32
+ Mage::helper('payment')->__('Credit Card No Last 4') => $info->getCcLast4(),
33
+ Mage::helper('payment')->__('Card Type') => $info->getCcType(),
34
+ Mage::helper('payment')->__('Exp Date') => $info->getCcExpMonth() . ' / '.$info->getCcExpYear(),
35
+ Mage::helper('payment')->__('Card Owner') => $info->getCcOwner(),
36
+ ));
37
+ return $transport;
38
+ }
39
+ }
app/code/community/WebPaymentSoftware/Pay/Helper/Data.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Payment
16
+ * @package WebPaymentSoftware_Pay
17
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class WebPaymentSoftware_Pay_Helper_Data extends Mage_Core_Helper_Abstract
22
+ {
23
+ }
app/code/community/WebPaymentSoftware/Pay/Model/Api.php ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Payment
16
+ * @package WebPaymentSoftware_Pay
17
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class WebPaymentSoftware_Pay_Model_Api {
22
+
23
+ // Config
24
+ //var $host = "secure.web-payment-software.com";
25
+ var $port = 443;
26
+ var $path = "/gateway/";
27
+ var $payment_method = 'card';
28
+
29
+ // Request fields
30
+ var $merchant_id;
31
+ var $merchant_key;
32
+ var $trans_type;
33
+ var $order_id;
34
+ var $amount;
35
+ var $tax;
36
+ var $shipping;
37
+
38
+ var $cc_number;
39
+ var $cc_exp;
40
+ var $cc_cvv;
41
+
42
+ var $check_routing_num;
43
+ var $check_account_num;
44
+ var $check_account_type = 'C';
45
+ var $check_num;
46
+ var $check_ssn;
47
+ var $check_dl_num;
48
+ var $check_dl_state;
49
+
50
+ var $company;
51
+ var $name;
52
+ var $address;
53
+ var $city;
54
+ var $state;
55
+ var $zip;
56
+ var $country;
57
+ var $phone;
58
+ var $email;
59
+
60
+ var $ip_address;
61
+ var $invoice_num;
62
+ var $memo;
63
+ var $test_mode = 0;
64
+
65
+ // Response fields
66
+ var $response;
67
+ var $response_code;
68
+ var $approval_code;
69
+ var $auth_response_text;
70
+ var $avs_result_code;
71
+ var $cvv_result_code;
72
+ var $response_text;
73
+
74
+ // Check-only responses
75
+ var $trace_num;
76
+ var $preauth_result;
77
+ var $preauth_text;
78
+
79
+ // Socket error responses
80
+ var $error_num;
81
+ var $error_string;
82
+
83
+
84
+ //////////
85
+ //// INTERFACE METHOD TO THE PAYGATE GATEWAY
86
+ //// Do some basic error handling and post to PayGate
87
+ function transact() {
88
+
89
+ $required = array( 'merchant_id',
90
+ 'merchant_key',
91
+ 'trans_type',
92
+ 'ip_address'
93
+ );
94
+
95
+
96
+ if (!isset($this->ip_address)) $this->ip_address = $_SERVER['REMOTE_ADDR'];
97
+ //if (!isset($this->referer)) $this->referer = $_SERVER[''];
98
+
99
+ if ($this->payment_method != 'card' && $this->payment_method != 'check') die ("\$payment_method must be 'card' or 'check'!");
100
+
101
+ $this->trans_type = strtolower($this->trans_type);
102
+ if ($this->trans_type == 'unmark') $this->trans_type == 'void';
103
+ if ($this->trans_type == 'mark') $this->trans_type == 'postauth';
104
+
105
+ // Set required fields array
106
+ if (($this->trans_type == 'authonly') || ($this->trans_type == 'authcapture')) {
107
+ array_push( $required,
108
+ 'amount',
109
+ 'name',
110
+ 'address',
111
+ 'city',
112
+ 'state',
113
+ 'zip',
114
+ 'country'
115
+ );
116
+
117
+ if ($this->payment_method == 'card') {
118
+ array_push($required,'cc_number','cc_exp');
119
+ } elseif ($this->payment_method == 'check') {
120
+ array_push($required,'check_routing_num','check_account_num');
121
+ }
122
+
123
+ } elseif (($this->trans_type == 'void') || ($this->trans_type == 'postauth')) {
124
+ array_push( $required,'order_id');
125
+
126
+ } elseif (($this->trans_type == 'credit') || ($this->trans_type == 'force')) {
127
+ array_push( $required,
128
+ 'amount',
129
+ 'name'
130
+ );
131
+ if ($this->payment_method == 'card') {
132
+ array_push($required,'cc_number','cc_exp');
133
+
134
+ if ($this->trans_type == 'force') {
135
+ array_push($required,'approval_code');
136
+ }
137
+
138
+ } elseif ($this->payment_method == 'check') {
139
+ array_push($required,'check_routing_num','check_account_num');
140
+
141
+ }
142
+
143
+ }
144
+
145
+ // first do a quick check to make sure required fields
146
+ // are set
147
+ foreach ($required as $field) {
148
+ if (!isset($this->$field)) die ("$field must be set!");
149
+ }
150
+
151
+ return $this->_post2PayGate();
152
+
153
+ }
154
+
155
+
156
+ // PRIVATE METHOD FOR POSTING TO PAYGATE
157
+ function _post2PayGate() {
158
+
159
+ // Array of fields that may be posted
160
+ $fields = array(
161
+ 'merchant_id',
162
+ 'merchant_key',
163
+ 'trans_type',
164
+ 'order_id',
165
+ 'amount',
166
+ 'tax',
167
+ 'shipping',
168
+
169
+ 'cc_number',
170
+ 'cc_exp',
171
+ 'cc_cvv',
172
+
173
+ 'check_routing_num',
174
+ 'check_account_num',
175
+ 'check_account_type',
176
+ 'check_num',
177
+ 'check_ssn',
178
+ 'check_dl_num',
179
+ 'check_dl_state',
180
+
181
+ 'company',
182
+ 'name',
183
+ 'address',
184
+ 'city',
185
+ 'state',
186
+ 'zip',
187
+ 'country',
188
+ 'phone',
189
+ 'email',
190
+
191
+ 'ip_address',
192
+ 'invoice_num',
193
+ 'memo',
194
+ 'test_mode',
195
+ );
196
+
197
+ // Fields whose names must be changed to cc_... or check_...
198
+ $prepend_fields = array('company','name','address','city','state','zip','country','phone','email');
199
+
200
+
201
+ // build request
202
+ $post = '';
203
+ foreach($fields as $field) {
204
+ if (isset($this->$field)) {
205
+ if ($post!='') $post.="&";
206
+
207
+ if (in_array($field,$prepend_fields)) {
208
+ $field_name = ($this->payment_method=='card'?'cc_':'check_').$field;
209
+ } else {
210
+ $field_name = $field;
211
+ }
212
+
213
+ $post .= urlencode($field_name)."=".urlencode($this->$field);
214
+ //$post.="&";
215
+ }
216
+ }
217
+
218
+ // Build header and body string
219
+ $req = "POST ".$this->path.$this->payment_method." HTTP/1.0\r\n" .
220
+ "Host: ".$this->host."\r\n" .
221
+ "Content-Type: application/x-www-form-urlencoded\r\n" .
222
+ "Content-Length: ".strlen($post)."\r\n" .
223
+ "User-Agent: PayGate-Zilla/1.0\r\n" .
224
+ "Connection: Close\r\n" .
225
+ "\r\n" .
226
+ $post .
227
+ "\r\n\r\n";
228
+
229
+ // if ($this->debug) echo "<pre>\n";
230
+ // if ($this->debug) echo $req;
231
+
232
+
233
+ $timeout = 5;
234
+ $attempt_count = 5;
235
+ $sleep_between = 2;
236
+
237
+ for ($i=0;$i<$attempt_count;$i++) {
238
+ $socket = fsockopen("ssl://".$this->host, $this->port, $errno, $errstr, $timeout);
239
+ if ($socket) break;
240
+
241
+ // If we haven't exhausted connexion attempts, sleep then try again.
242
+ if ($i < $attempt_count-1) {
243
+ sleep($sleep_between);
244
+ continue;
245
+ } else {
246
+ $this->error_string = $errstr;
247
+ $this->error_num = $errno;
248
+ $this->response_code = 501;
249
+ $this->response_text = 'Error connecting to financial network.';
250
+ return;
251
+ }
252
+
253
+ }
254
+
255
+ // Send the server request
256
+ $header = ''; //marcel
257
+ fwrite($socket, $req, strlen($req));
258
+ do $header.=fgets($socket); while (!preg_match('/\\r\\n\\r\\n$/',$header));
259
+
260
+ // create regex for parsing xml response
261
+ $match = "/^<([a-z_]+)>([ \(\)&\+,A-Za-z0-9\.-]+)<\/[a-z_]+>/";
262
+
263
+ // Parse response
264
+ while (!feof($socket)) {
265
+ $buffer = @fgets($socket);
266
+ $this->response .= $buffer;
267
+
268
+ // parse xml
269
+ if(preg_match($match,$buffer,$matches))
270
+ $this->$matches[1] = $matches[2];
271
+ }
272
+
273
+ // Close socket
274
+ fclose ($socket);
275
+
276
+ if ($this->debug) {
277
+ $responses = array( 'response_code','approval_code','auth_response_text',
278
+ 'avs_result_code','cvv_result_code','response_text',
279
+ 'trace_num','preauth_result','preauth_text','order_id');
280
+ $result = array();
281
+ foreach($responses as $row) {
282
+ if (!isset($this->$row)) continue;
283
+ $result[$row] = $this->$row;
284
+ }
285
+ Mage::log($result, null, 'paygate.log');
286
+ }
287
+ return true;
288
+ }
289
+
290
+ }
app/code/community/WebPaymentSoftware/Pay/Model/Pay.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Payment
16
+ * @package WebPaymentSoftware_Pay
17
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class WebPaymentSoftware_Pay_Model_Pay extends Mage_Payment_Model_Method_Cc
22
+ {
23
+ protected $_code = 'pay';
24
+ protected $_formBlockType = 'pay/form_pay';
25
+ protected $_infoBlockType = 'pay/info_pay';
26
+
27
+ //protected $_isGateway = true;
28
+ protected $_canAuthorize = true;
29
+ protected $_canCapture = true;
30
+ protected $_canRefund = true;
31
+ //protected $_canCapturePartial = true;
32
+
33
+
34
+ protected $_canSaveCc = false; //if made try, the actual credit card number and cvv code are stored in database.
35
+
36
+ //protected $_canRefundInvoicePartial = true;
37
+ //protected $_canVoid = true;
38
+ //protected $_canUseInternal = true;
39
+ //protected $_canUseCheckout = true;
40
+ //protected $_canUseForMultishipping = true;
41
+ //protected $_canFetchTransactionInfo = true;
42
+ //protected $_canReviewPayment = true;
43
+
44
+
45
+ public function process($data){
46
+
47
+ if($data['cancel'] == 1){
48
+ $order->getPayment()
49
+ ->setTransactionId(null)
50
+ ->setParentTransactionId(time())
51
+ ->void();
52
+ $message = 'Unable to process Payment';
53
+ $order->registerCancellation($message)->save();
54
+ }
55
+ }
56
+
57
+ /** For capture **/
58
+ public function capture(Varien_Object $payment, $amount)
59
+ {
60
+ $order = $payment->getOrder();
61
+ $result = $this->callApi($payment, $amount, 'AuthCapture');
62
+ if($result == false) {
63
+ $errorCode = 'Invalid Data';
64
+ $errorMsg = $this->_getHelper()->__('Error Processing the request');
65
+ } else {
66
+ if($result['status'] == '00'){
67
+ $payment->setTransactionId($result['transaction_id']);
68
+ $payment->setIsTransactionClosed(1);
69
+ $order->save();
70
+ }else{
71
+ $errorMsg = $this->_getHelper()->__($result['response_text']);
72
+ Mage::throwException($errorMsg);
73
+ }
74
+ }
75
+ if(isset($errorMsg)){
76
+ Mage::throwException($errorMsg);
77
+ }
78
+
79
+ return $this;
80
+ }
81
+
82
+
83
+ /** For authorization **/
84
+ public function authorize(Varien_Object $payment, $amount)
85
+ {
86
+ $order = $payment->getOrder();
87
+ $result = $this->callApi($payment, $amount, 'AuthOnly');
88
+
89
+ if($result == false) {
90
+ $errorCode = 'Invalid Data';
91
+ $errorMsg = $this->_getHelper()->__('Error Processing the request');
92
+ } else {
93
+ if($result['status'] == '00'){
94
+ $payment->setTransactionId($result['transaction_id']);
95
+ $payment->setIsTransactionClosed(1);
96
+ $order->save();
97
+ }else{
98
+ $errorMsg = $this->_getHelper()->__($result['response_text']);
99
+ Mage::throwException($errorMsg);
100
+ }
101
+ }
102
+ if(isset($errorMsg)){
103
+ Mage::throwException($errorMsg);
104
+ }
105
+
106
+ return $this;
107
+ }
108
+
109
+ public function processBeforeRefund($invoice, $payment){
110
+ return parent::processBeforeRefund($invoice, $payment);
111
+ }
112
+
113
+ public function refund(Varien_Object $payment, $amount){
114
+ $order = $payment->getOrder();
115
+ $result = $this->callApi($payment,$amount,'Reversal');
116
+ if($result == false) {
117
+ $errorCode = 'Invalid Data';
118
+ $errorMsg = $this->_getHelper()->__('Error Processing the request');
119
+ Mage::throwException($errorMsg);
120
+ }
121
+ return $this;
122
+ }
123
+
124
+ public function processCreditmemo($creditmemo, $payment){
125
+ return parent::processCreditmemo($creditmemo, $payment);
126
+ }
127
+
128
+ private function callApi(Varien_Object $payment, $amount, $type){
129
+
130
+ $order = $payment->getOrder();
131
+ $billingaddress = $order->getBillingAddress();
132
+ $totals = number_format($amount, 2, '.', '');
133
+ $orderId = $order->getIncrementId();
134
+ $currencyDesc = $order->getBaseCurrencyCode();
135
+
136
+ $trans = Mage::getModel('pay/api');
137
+ $trans->host = $this->getConfigData('gateway_url');
138
+ $trans->merchant_id = $this->getConfigData('merchant_id');
139
+ $trans->merchant_key = $this->getConfigData('merchant_key');
140
+ $trans->trans_type = $type;
141
+ $trans->amount = $totals;
142
+ $trans->cc_number = $payment->getCcNumber();
143
+ $trans->cc_exp = $this->getExp($payment->getCcExpMonth(), $payment->getCcExpYear());
144
+ $trans->cc_cvv = $payment->getCcCid();
145
+ $trans->name = $billingaddress->getData('firstname') . ' ' . $billingaddress->getData('lastname');
146
+ $trans->address = $billingaddress->getData('street');
147
+ $trans->city = $billingaddress->getData('city');
148
+ $trans->state = $this->getState($billingaddress->getData('region_id'));
149
+ $trans->zip = $billingaddress->getData('postcode');
150
+ $trans->country = $billingaddress->getData('country_id');
151
+ $trans->test_mode = $this->getConfigData('test');
152
+ $trans->debug = $this->getConfigData('debug');
153
+
154
+ $trans->transact();
155
+
156
+ return array('status' => $trans->response_code, 'transaction_id' => $trans->approval_code, 'response_text' => $trans->response_text);
157
+
158
+ //return array('status'=>1,'transaction_id' => time() , 'fraud' => rand(0,1));
159
+ //return array('status'=>rand(0, 1),'transaction_id' => time() , 'fraud' => rand(0,1));
160
+ }
161
+
162
+ function getState($region_id, $region){
163
+ if($region_id){
164
+ $region = Mage::getModel('directory/region')->load($region_id);
165
+ $state = $region->getName();
166
+
167
+ $explode = explode(' ', $state);
168
+ if (count($explode) >= 2) {
169
+ $state = substr($explode[0], 0, 1) . substr($explode[1], 0, 1);
170
+ } else {
171
+ $state = substr($state, 0, 2);
172
+ }
173
+
174
+ return $state;
175
+ }elseif ($region) {
176
+ $state = $region;
177
+ $explode = explode(' ', $state);
178
+ if (count($explode) >= 2) {
179
+ $state = substr($explode[0], 0, 1) . substr($explode[1], 0, 1);
180
+ } else {
181
+ $state = substr($state, 0, 2);
182
+ }
183
+
184
+ return $state;
185
+ }
186
+ }
187
+
188
+ function getExp($month, $year){
189
+ if(strlen($month) == 1) {
190
+ $month = '0'.$month;
191
+ }
192
+ $year = substr($year, -2);
193
+
194
+ return "$month$year";
195
+ }
196
+ }
app/code/community/WebPaymentSoftware/Pay/Model/Source/Action.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Payment
16
+ * @package WebPaymentSoftware_Pay
17
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class WebPaymentSoftware_Pay_Model_Source_Action
22
+ {
23
+ public function toOptionArray()
24
+ {
25
+ return array(
26
+ array(
27
+ 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE,
28
+ 'label' => Mage::helper('core')->__('Authorize & Capture')
29
+ ),
30
+ array(
31
+ 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE,
32
+ 'label' => Mage::helper('core')->__('Authorize')
33
+ ),
34
+
35
+ );
36
+ }
37
+ }
app/code/community/WebPaymentSoftware/Pay/Model/Source/Cctype.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Payment
16
+ * @package WebPaymentSoftware_Pay
17
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class WebPaymentSoftware_Pay_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype
22
+ {
23
+ public function getAllowedTypes()
24
+ {
25
+ return array('VI', 'MC', 'AE', 'DI', 'OT');
26
+ }
27
+ }
app/code/community/WebPaymentSoftware/Pay/etc/config.xml ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Payment
17
+ * @package WebPaymentSoftware_Pay
18
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+
23
+ <config>
24
+ <modules>
25
+ <WebPaymentSoftware_Pay>
26
+ <version>0.1.0</version>
27
+ </WebPaymentSoftware_Pay>
28
+ </modules>
29
+ <frontend>
30
+ <!-- <routers>
31
+ <pay>
32
+ <use>standard</use>
33
+ <args>
34
+ <module>WebPaymentSoftware_Pay</module>
35
+ <frontName>pay</frontName>
36
+ </args>
37
+ </pay>
38
+ </routers>
39
+ <layout>
40
+ <updates>
41
+ <pay>
42
+ <file>pay.xml</file>
43
+ </pay>
44
+ </updates>
45
+ </layout>-->
46
+ </frontend>
47
+ <global>
48
+ <fieldsets>
49
+ <sales_convert_quote_payment>
50
+ <check_no>
51
+ <to_order_payment>*</to_order_payment>
52
+ </check_no>
53
+ <check_date>
54
+ <to_order_payment>*</to_order_payment>
55
+ </check_date>
56
+ </sales_convert_quote_payment>
57
+ </fieldsets>
58
+ <models>
59
+ <pay>
60
+ <class>WebPaymentSoftware_Pay_Model</class>
61
+ <resourceModel>pay_mysql4</resourceModel>
62
+ </pay>
63
+ <pay_mysql4>
64
+ <class>WebPaymentSoftware_Pay_Model_Mysql4</class>
65
+ <entities>
66
+ <pay>
67
+ <table>pay</table>
68
+ </pay>
69
+ </entities>
70
+ </pay_mysql4>
71
+ </models>
72
+ <resources>
73
+ <pay_setup>
74
+ <setup>
75
+ <module>WebPaymentSoftware_Pay</module>
76
+ </setup>
77
+ <connection>
78
+ <use>core_setup</use>
79
+ </connection>
80
+ </pay_setup>
81
+ <pay_write>
82
+ <connection>
83
+ <use>core_write</use>
84
+ </connection>
85
+ </pay_write>
86
+ <pay_read>
87
+ <connection>
88
+ <use>core_read</use>
89
+ </connection>
90
+ </pay_read>
91
+ </resources>
92
+ <blocks>
93
+ <pay>
94
+ <class>WebPaymentSoftware_Pay_Block</class>
95
+ </pay>
96
+ </blocks>
97
+ <helpers>
98
+ <pay>
99
+ <class>WebPaymentSoftware_Pay_Helper</class>
100
+ </pay>
101
+ </helpers>
102
+ </global>
103
+ <default>
104
+ <payment>
105
+ <pay>
106
+ <active>0</active>
107
+ <model>pay/pay</model>
108
+ <order_status>processing</order_status>
109
+ <title>Web Payment Software</title>
110
+ <gateway_url>secure.web-payment-software.com</gateway_url>
111
+ <cctypes>AE,VI,MC,DI</cctypes>
112
+ <test>1</test>
113
+ <debug>1</debug>
114
+ <payment_action>authorize</payment_action>
115
+ <order_status>processing</order_status>
116
+ <allowspecific>0</allowspecific>
117
+ </pay>
118
+ </payment>
119
+ </default>
120
+ </config>
app/code/community/WebPaymentSoftware/Pay/etc/system.xml ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Payment
17
+ * @package WebPaymentSoftware_Pay
18
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+
23
+ <config>
24
+ <sections>
25
+ <payment>
26
+ <groups>
27
+ <pay translate="label" module="pay">
28
+ <label>Web Payment Software</label>
29
+ <sort_order>1</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>0</show_in_store>
33
+ <fields>
34
+ <active translate="label">
35
+ <label>Enabled</label>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ <sort_order>10</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>0</show_in_store>
42
+ </active>
43
+ <title translate="label">
44
+ <label>Title</label>
45
+ <frontend_type>text</frontend_type>
46
+ <sort_order>11</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>0</show_in_store>
50
+ </title>
51
+ <merchant_id translate="label">
52
+ <label>Merchant ID</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>20</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>0</show_in_store>
58
+ </merchant_id>
59
+ <merchant_key translate="label">
60
+ <label>Merchant KEY</label>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>30</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ </merchant_key>
67
+ <gateway_url translate="label">
68
+ <label>Gateway</label>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>40</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </gateway_url>
75
+ <cctypes translate="label">
76
+ <label>Credit Card Types</label>
77
+ <frontend_type>multiselect</frontend_type>
78
+ <source_model>pay/source_cctype</source_model>
79
+ <sort_order>50</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ <can_be_empty>1</can_be_empty>
84
+ </cctypes>
85
+ <test translate="label">
86
+ <label>Test Mode</label>
87
+ <frontend_type>select</frontend_type>
88
+ <source_model>adminhtml/system_config_source_yesno</source_model>
89
+ <sort_order>51</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>0</show_in_store>
93
+ </test>
94
+ <debug translate="label">
95
+ <label>Debug</label>
96
+ <frontend_type>select</frontend_type>
97
+ <source_model>adminhtml/system_config_source_yesno</source_model>
98
+ <sort_order>52</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </debug>
103
+ <payment_action translate="label">
104
+ <label>Payment Action</label>
105
+ <frontend_type>select</frontend_type>
106
+ <source_model>pay/source_action</source_model>
107
+ <sort_order>70</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ </payment_action>
111
+ <order_status translate="label">
112
+ <label>New order status</label>
113
+ <frontend_type>select</frontend_type>
114
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
115
+ <sort_order>80</sort_order>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <show_in_store>0</show_in_store>
119
+ </order_status>
120
+ <allowspecific translate="label">
121
+ <label>Payment from Applicable Countries</label>
122
+ <frontend_type>allowspecific</frontend_type>
123
+ <sort_order>81</sort_order>
124
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>0</show_in_store>
128
+ </allowspecific>
129
+ <specificcountry translate="label">
130
+ <label>Payment from Specific Countries</label>
131
+ <frontend_type>multiselect</frontend_type>
132
+ <sort_order>82</sort_order>
133
+ <source_model>adminhtml/system_config_source_country</source_model>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>1</show_in_website>
136
+ <show_in_store>0</show_in_store>
137
+ </specificcountry>
138
+ </fields>
139
+ </pay>
140
+ </groups>
141
+ </payment>
142
+ </sections>
143
+ </config>
app/code/community/WebPaymentSoftware/Pay/sql/pay_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Payment
16
+ * @package WebPaymentSoftware_Pay
17
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ $installer = $this;
22
+ /* @var $installer Mage_Customer_Model_Entity_Setup */
23
+
24
+ $installer->startSetup();
25
+
26
+ $installer->run("
27
+
28
+ ALTER TABLE `{$installer->getTable('sales/quote_payment')}` ADD `pay_cc_expmo` VARCHAR( 255 ) NOT NULL ;
29
+ ALTER TABLE `{$installer->getTable('sales/quote_payment')}` ADD `pay_cc_expyr` VARCHAR( 255 ) NOT NULL ;
30
+ ALTER TABLE `{$installer->getTable('sales/quote_payment')}` ADD `pay_cc_number` VARCHAR( 255 ) NOT NULL ;
31
+ ALTER TABLE `{$installer->getTable('sales/quote_payment')}` ADD `pay_cc_type` VARCHAR( 255 ) NOT NULL ;
32
+ ALTER TABLE `{$installer->getTable('sales/quote_payment')}` ADD `pay_cc_cvc` VARCHAR( 255 ) NOT NULL ;
33
+
34
+
35
+
36
+ ALTER TABLE `{$installer->getTable('sales/order_payment')}` ADD `pay_cc_expmo` VARCHAR( 255 ) NOT NULL ;
37
+ ALTER TABLE `{$installer->getTable('sales/order_payment')}` ADD `pay_cc_expyr` VARCHAR( 255 ) NOT NULL ;
38
+ ALTER TABLE `{$installer->getTable('sales/order_payment')}` ADD `pay_cc_number` VARCHAR( 255 ) NOT NULL ;
39
+ ALTER TABLE `{$installer->getTable('sales/order_payment')}` ADD `pay_cc_type` VARCHAR( 255 ) NOT NULL ;
40
+ ALTER TABLE `{$installer->getTable('sales/order_payment')}` ADD `pay_cc_cvc` VARCHAR( 255 ) NOT NULL ;
41
+
42
+ ");
43
+
44
+ $installer->endSetup();
app/etc/modules/WebPaymentSoftware_Pay.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Payment
17
+ * @package WebPaymentSoftware_Pay
18
+ * @copyright Copyright (c) 2013 Web Payment Software (http://www.web-payment-software.com/)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+
23
+ <config>
24
+ <modules>
25
+ <WebPaymentSoftware_Pay>
26
+ <active>true</active>
27
+ <codePool>community</codePool>
28
+ <depends>
29
+ <Mage_Payment />
30
+ </depends>
31
+ </WebPaymentSoftware_Pay>
32
+ </modules>
33
+ </config>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>WebPaymentSoftware_Pay</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>WPS, a PCI Level 1 service provider, offering you the most safe and secure online payment solutions available.</summary>
10
+ <description>Web Payment Software&#x2122; is a product and service of Mountain Media. Mountain Media has been serving the eCommerce development marketplace since 1998.&#xD;
11
+ &#xD;
12
+ As a compliment to Mountain Commerce, the company&#x2019;s full-featured eCommerce platform, Mountain Media has developed a payment gateway for use with eCommerce Web sites with an added twist. Not only does Web Payment Software&#x2122; function as a traditional ecommerce gateway and virtual terminal, it also offers a hosted solution for constructing and managing &#x201C;payment pages.&#x201D; This flexible new system is great for accepting online invoice payments, donations or event registrations or as an alternative to PayPal.&#xD;
13
+ &#xD;
14
+ Mountain Media is a PCI DSS compliant hosting provider which ensures that your transactions will be protected by the toughest data security standards and technology available.&#xD;
15
+ &#xD;
16
+ Contact a payment consultant today at (877) 583-0300 for a free consultation.</description>
17
+ <notes>First release</notes>
18
+ <authors><author><name>wps</name><user>wps_magento</user><email>dev@web-payment-software.com</email></author></authors>
19
+ <date>2013-11-08</date>
20
+ <time>18:05:47</time>
21
+ <contents><target name="magecommunity"><dir name="WebPaymentSoftware"><dir name="Pay"><dir name="Block"><dir name="Form"><file name="Pay.php" hash="e135ba0b5c3d15fee6598e141ac75ff2"/></dir><dir name="Info"><file name="Pay.php" hash="f70b683675249e1d2a37c48dc65fd06c"/></dir></dir><dir name="Helper"><file name="Data.php" hash="7374e037a98af0661be9c67d3e66aaaf"/></dir><dir name="Model"><file name="Api.php" hash="785ace2ecac6f78af74e350b8ff78364"/><file name="Pay.php" hash="07ace6a00da2c2f727da201d6fe64822"/><dir name="Source"><file name="Action.php" hash="5e9830f2921b3bd0b3e246f9832d7f18"/><file name="Cctype.php" hash="45e6997f63628c826b554cf8dc85f35a"/></dir></dir><dir name="etc"><file name="config.xml" hash="11afb437534b15877c14758695af51cd"/><file name="system.xml" hash="87fb20507d5455fdbd36d447b6dab24e"/></dir><dir name="sql"><dir name="pay_setup"><file name="mysql4-install-0.1.0.php" hash="80f739cd45919dab5648ff12faf083ee"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="WebPaymentSoftware_Pay.xml" hash="1286d3ba81e449140c2366c77582c7e2"/></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
24
+ </package>