pacnet_raven - Version 1.0.0

Version Notes

## [1.0.0] - 2016-03-27
### Initial Release
- Raven MarketDirect payments
- Merged Raven API payments

Download this release

Release Info

Developer Joerg Beekmann
Extension pacnet_raven
Version 1.0.0
Comparing to
See all releases


Code changes from version 0.1.0 to 1.0.0

Files changed (32) hide show
  1. app/code/community/PacNet/Raven/Block/MarketDirect/Form.php +50 -0
  2. app/code/community/PacNet/Raven/Block/MarketDirect/Info.php +57 -0
  3. app/code/community/PacNet/Raven/Exception.php +38 -0
  4. app/code/community/PacNet/Raven/Helper/Data.php +41 -0
  5. app/code/community/PacNet/Raven/Model/Api.php +222 -0
  6. app/code/community/PacNet/Raven/Model/Api/Service.php +322 -0
  7. app/code/community/PacNet/Raven/Model/Api/Service/Request/Abstract.php +493 -0
  8. app/code/community/PacNet/Raven/Model/Api/Service/Request/Exception.php +38 -0
  9. app/code/community/PacNet/Raven/Model/Api/Service/Request/Hello.php +57 -0
  10. app/code/community/PacNet/Raven/Model/Api/Service/Request/Response.php +57 -0
  11. app/code/community/PacNet/Raven/Model/Api/Service/Request/Submit.php +123 -0
  12. app/code/community/PacNet/Raven/Model/Api/Service/Response.php +464 -0
  13. app/code/community/PacNet/Raven/Model/Api/Service/Response/Codes/CVV2.php +52 -0
  14. app/code/community/PacNet/Raven/Model/Api/Service/Response/Codes/Status.php +139 -0
  15. app/code/community/PacNet/Raven/Model/Api/Service/Response/Exception.php +38 -0
  16. app/code/community/PacNet/Raven/Model/Api/Source/Paymentaction.php +49 -0
  17. app/code/community/PacNet/Raven/Model/MarketDirect.php +73 -0
  18. app/code/community/PacNet/Raven/Model/MarketDirect/Abstract.php +170 -0
  19. app/code/community/PacNet/Raven/Model/MarketDirect/Response.php +183 -0
  20. app/code/community/PacNet/Raven/Model/MarketDirect/Source/PaymentType.php +53 -0
  21. app/code/community/PacNet/Raven/Model/MarketDirect/Transaction.php +309 -0
  22. app/code/community/PacNet/Raven/controllers/MarketdirectController.php +177 -0
  23. app/code/community/PacNet/Raven/etc/config.xml +112 -0
  24. app/code/community/PacNet/Raven/etc/system.xml +307 -0
  25. app/design/adminhtml/default/default/template/pacnet/raven/marketdirect/info.phtml +48 -0
  26. app/design/adminhtml/default/default/template/pacnet/raven/marketdirect/pdf/info.phtml +43 -0
  27. app/design/frontend/base/default/layout/pacnet/raven/marketdirect.xml +45 -0
  28. app/design/frontend/base/default/template/pacnet/raven/marketdirect/form.phtml +47 -0
  29. app/design/frontend/base/default/template/pacnet/raven/marketdirect/redirect.phtml +56 -0
  30. app/etc/modules/PacNet_Raven.xml +43 -0
  31. package.xml +38 -35
  32. skin/frontend/base/default/pacnet/images/ajax-loader.gif +0 -0
app/code/community/PacNet/Raven/Block/MarketDirect/Form.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven MarketDirect checkout payment form block
37
+ */
38
+ class PacNet_Raven_Block_MarketDirect_Form extends Mage_Payment_Block_Form
39
+ {
40
+ protected function _construct()
41
+ {
42
+ parent::_construct();
43
+ $this->setTemplate('pacnet/raven/marketdirect/form.phtml');
44
+ }
45
+
46
+ protected function _getConfig()
47
+ {
48
+ return Mage::getSingleton('pacnet_raven/config');
49
+ }
50
+ }
app/code/community/PacNet/Raven/Block/MarketDirect/Info.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven MarketDirect payment info block
37
+ */
38
+ class PacNet_Raven_Block_MarketDirect_Info extends Mage_Payment_Block_Info {
39
+
40
+ protected function _construct()
41
+ {
42
+ parent::_construct();
43
+ $this->setTemplate('pacnet/raven/marketdirect/info.phtml');
44
+ }
45
+
46
+ public function getMethodCode()
47
+ {
48
+ return $this->getInfo()->getMethodInstance()->getCode();
49
+ }
50
+
51
+ public function toPdf()
52
+ {
53
+ $this->setTemplate('pacnet/raven/marketdirect/pdf/info.phtml');
54
+ return $this->toHtml();
55
+ }
56
+
57
+ }
app/code/community/PacNet/Raven/Exception.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven default exception
37
+ */
38
+ class PacNet_Raven_Exception extends Mage_Core_Exception {}
app/code/community/PacNet/Raven/Helper/Data.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven default helper
37
+ */
38
+ class PacNet_Raven_Helper_Data extends Mage_Core_Helper_Abstract
39
+ {
40
+
41
+ }
app/code/community/PacNet/Raven/Model/Api.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API payment method
37
+ */
38
+ class PacNet_Raven_Model_Api extends Mage_Payment_Model_Method_Cc
39
+ {
40
+ protected $_code = 'pacnet_raven_api';
41
+ protected $_isGateway = true;
42
+ protected $_canAuthorize = true;
43
+ protected $_canCapture = true;
44
+ protected $_canCapturePartial = false;
45
+ protected $_canRefund = false;
46
+ protected $_canRefundInvoicePartial = false;
47
+ protected $_canVoid = true;
48
+ protected $_canUseInternal = true;
49
+ protected $_canUseCheckout = true;
50
+ protected $_canUseForMultishipping = true;
51
+ protected $_canSaveCc = false;
52
+
53
+ protected $_ravenConfig;
54
+ protected $_ravenService;
55
+ protected $_trackingNumber;
56
+
57
+ /**
58
+ * Assigns data to payment method
59
+ *
60
+ * Tracking number added for repeat payments
61
+ *
62
+ * @param mixed $data
63
+ *
64
+ * @return $this
65
+ */
66
+ public function assignData($data)
67
+ {
68
+ $this->setTrackingNumber($data->getPacnetTrackingNumber());
69
+ parent::assignData($data);
70
+ return $this;
71
+ }
72
+
73
+ /**
74
+ * Validates payment method
75
+ *
76
+ * @return $this
77
+ */
78
+ public function validate()
79
+ {
80
+ if (!$this->hasTrackingNumber()) {
81
+ parent::validate();
82
+ }
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Captures payment
88
+ *
89
+ * @param Varien_Object $payment
90
+ * @param float $amount
91
+ *
92
+ * @return $this
93
+ * @throws Mage_Core_Exception
94
+ */
95
+ public function capture(Varien_Object $payment, $amount)
96
+ {
97
+ $debug = $this->getConfigData('debug') ? $this->getConfigData('debug') : false;
98
+ $ravenService = new PacNet_Raven_Model_Api_Service($this->getRavenConfig(), $debug);
99
+
100
+ $ravenResponse = $this->hasTrackingNumber() ?
101
+ $ravenService->reccurring($this->getTrackingNumber(), $payment, $amount) :
102
+ $ravenService->debit($payment, $amount);
103
+
104
+ $errorMsg = null;
105
+
106
+ if (!$ravenResponse) {
107
+ $errorMsg = $this->_getHelper()->__('There was an error processing payment');
108
+ } else {
109
+
110
+ if ('500' == $ravenResponse->getHttpStatus()) {
111
+ //$errorMsg = $this->_getHelper()->__('There was an error processing payment at the payment gateway');
112
+ }
113
+
114
+ if ('Approved' == $ravenResponse->getStatus()) {
115
+ $payment->setTransactionId($ravenResponse->getRequestID())
116
+ ->setIsTransactionClosed(1)
117
+ ->setTransactionAdditionalInfo(
118
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
119
+ $ravenResponse->getTransactionAdditionalInfo()
120
+ );
121
+ } else {
122
+ $errorMsg = $this->_getHelper()->__('Payment was not approved');
123
+ }
124
+ }
125
+
126
+ if ($errorMsg) {
127
+ Mage::throwException($errorMsg);
128
+ }
129
+
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Voids payment
135
+ *
136
+ * @param Varien_Object $payment
137
+ *
138
+ * @return Mage_Payment_Model_Abstract
139
+ */
140
+ public function void(Varien_Object $payment)
141
+ {
142
+ return parent::void($payment);
143
+ }
144
+
145
+ /**
146
+ * Gets the Raven config
147
+ *
148
+ * @return array
149
+ */
150
+ public function getRavenConfig()
151
+ {
152
+ if (null === $this->_ravenConfig) {
153
+ $this->_ravenConfig = array(
154
+ 'UserName' => $this->getConfigData('username'),
155
+ 'Secret' => $this->getConfigData('shared_secret'),
156
+ 'PRN' => $this->getConfigData('prn'),
157
+ 'RequestID' => $this->_createRavenRequestID()
158
+ );
159
+ }
160
+
161
+ return $this->_ravenConfig;
162
+ }
163
+
164
+ /**
165
+ * Gets Raven service
166
+ *
167
+ * @return PacNet_Raven_Model_Api_Service
168
+ */
169
+ public function getRavenService()
170
+ {
171
+ if (null === $this->_ravenService) {
172
+ $this->_ravenService = new PacNet_Raven_Model_Api_Service($this->getRavenConfig());
173
+ }
174
+
175
+ return $this->_ravenService;
176
+ }
177
+
178
+
179
+ /**
180
+ * Creates a unique Raven reference no.
181
+ *
182
+ * @return string
183
+ */
184
+ protected function _createRavenRequestID()
185
+ {
186
+ return uniqid('RQ');
187
+ }
188
+
189
+ /**
190
+ * Gets tracking no.
191
+ *
192
+ * @return mixed
193
+ */
194
+ public function getTrackingNumber()
195
+ {
196
+ if (!$this->_trackingNumber) {
197
+ $this->_trackingNumber = $this->getInfoInstance()->getPacnetTrackingNumber();
198
+ }
199
+ return $this->_trackingNumber;
200
+ }
201
+
202
+ /**
203
+ * Sets tracking no.
204
+ *
205
+ * @param $trackingNumber
206
+ */
207
+ public function setTrackingNumber($trackingNumber)
208
+ {
209
+ $this->_trackingNumber = $trackingNumber;
210
+ }
211
+
212
+ /**
213
+ * Check if payment uses a tracking no.
214
+ *
215
+ * @return bool
216
+ */
217
+ public function hasTrackingNumber()
218
+ {
219
+ return $this->getTrackingNumber() ? true : false;
220
+ }
221
+ }
222
+ ?>
app/code/community/PacNet/Raven/Model/Api/Service.php ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API payment service
37
+ */
38
+ class PacNet_Raven_Model_Api_Service
39
+ {
40
+ /**
41
+ * Raven service config
42
+ *
43
+ * @var array|null
44
+ */
45
+ protected $_config;
46
+
47
+ /**
48
+ * Enable/disable config
49
+ *
50
+ * @var bool
51
+ */
52
+ protected $_debug;
53
+
54
+ /**
55
+ * Raven service config
56
+ *
57
+ * @var string
58
+ */
59
+ protected $_debugFile = 'raven_api.log';
60
+
61
+ /**
62
+ * Constructor.
63
+ *
64
+ * @param $config
65
+ * @param bool $debug
66
+ */
67
+ public function __construct($config, $debug=false)
68
+ {
69
+ $this->_setConfig($config);
70
+ $this->_debug = $debug;
71
+ }
72
+
73
+ /**
74
+ * Sets config
75
+ *
76
+ * @param $config
77
+ */
78
+ protected function _setConfig($config)
79
+ {
80
+ $this->_config = $config;
81
+ }
82
+
83
+ /**
84
+ * Gets config
85
+ *
86
+ * @return mixed
87
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
88
+ */
89
+ protected function _getConfig()
90
+ {
91
+ if (null === $this->_config) {
92
+ throw new PacNet_Raven_Model_Api_Service_Request_Exception('Config could not be found!');
93
+ }
94
+
95
+ return $this->_config;
96
+ }
97
+
98
+ /**
99
+ * Makes a debit payment
100
+ *
101
+ * @param Varien_Object $payment
102
+ * @param $amount
103
+ * @param null $description
104
+ *
105
+ * @return PacNet_Raven_Model_Api_Service_Response
106
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
107
+ */
108
+ public function debit(Varien_Object $payment, $amount, $description=null)
109
+ {
110
+ if($this->_debug) {
111
+ Mage::log('Initiating debit service', null, $this->_debugFile);
112
+ }
113
+
114
+
115
+ $amount = $amount * 100;
116
+ $ravenSubmitRequest = new PacNet_Raven_Model_Api_Service_Request_Submit($this->_getConfig());
117
+
118
+ $ravenSubmitRequest->setPaymentType(PacNet_Raven_Model_Api_Service_Request_Submit::CC_DEBIT)
119
+ ->setAmount($amount)
120
+ ->setDescription($description);
121
+ //->setComment();
122
+
123
+ if($payment->getCcNumber()) {
124
+ $CcExpYear = substr($payment->getCcExpYear(), 2, 2);
125
+
126
+ $ravenSubmitRequest->setCardNumber($payment->getCcNumber())
127
+ ->setCVV2($payment->getCcCid())
128
+ ->setExpiryDate(sprintf('%02d%02d', $payment->getCcExpMonth(), $CcExpYear))
129
+ ->setIssueNumber($payment->getCcSsIssue());
130
+ }
131
+
132
+ if ($order = $payment->getOrder()) {
133
+ $ravenSubmitRequest->setCurrency($order->getBaseCurrencyCode())
134
+ ->setReference($order->getIncrementId())
135
+ ->setContactEmail($order->getCustomerEmail());
136
+
137
+ if ($billing = $order->getBillingAddress()) {
138
+ $ravenSubmitRequest->setAccountName($billing->getFirstname() . ' ' . $billing->getLastname())
139
+ ->setBillingAddressLine1($billing->getStreet(1))
140
+ ->setBillingAddressLine2($billing->getStreet(2))
141
+ ->setBillingCity($billing->getCity())
142
+ ->setBillingRegion($billing->getRegion())
143
+ ->setBillingPostal($billing->getPostcode())
144
+ ->setBillingCountry($billing->getCountry())
145
+ ->setCustomerPhone($billing->getTelephone())
146
+ ->set('CustomerIP',Mage::helper('core/http')->getRemoteAddr($ipToLong = false));
147
+ // ->set('CustomerIP',$order->getRemoteAddr());
148
+ // Mage::log($ravenSubmitRequest);
149
+ }
150
+
151
+ if ($shipping = $order->getShippingAddress()) {
152
+ $ravenSubmitRequest->setShippingAddressLine1($shipping->getStreet(1))
153
+ ->setShippingAddressLine2($shipping->getStreet(2))
154
+ ->setShippingCity($shipping->getCity())
155
+ ->setShippingRegion($shipping->getRegion())
156
+ ->setShippingPostal($shipping->getPostcode())
157
+ ->setShippingCountry($shipping->getCountry());
158
+ }
159
+ }
160
+
161
+ if($this->_debug) {
162
+ Mage::log('Request Data: ' . print_r($ravenSubmitRequest->getData(false, true),true) , null, $this->_debugFile);
163
+ }
164
+
165
+ $ravenSubmitResponse = $ravenSubmitRequest->send();
166
+
167
+ if($this->_debug) {
168
+ Mage::log('Response String: ' . print_r($ravenSubmitResponse->getRavenResponseString(), true), null, $this->_debugFile);
169
+ Mage::log('Response Data: ' . print_r($ravenSubmitResponse->getRavenResponseData(), true), null, $this->_debugFile);
170
+ }
171
+
172
+ return $ravenSubmitResponse;
173
+ }
174
+
175
+ /**
176
+ * Makes a recurring payment
177
+ *
178
+ * @param $templateNo
179
+ * @param Varien_Object $payment
180
+ * @param $amount
181
+ * @param null $description
182
+ *
183
+ * @return PacNet_Raven_Model_Api_Service_Response
184
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
185
+ */
186
+ public function reccurring($templateNo, Varien_Object $payment, $amount, $description=null)
187
+ {
188
+ if($this->_debug) {
189
+ Mage::log('Initiating reccuring service', null, $this->_debugFile);
190
+ }
191
+
192
+ $amount = $amount * 100;
193
+ $ravenSubmitRequest = new PacNet_Raven_Model_Api_Service_Request_Submit($this->_getConfig());
194
+
195
+ $ravenSubmitRequest->setPaymentType(PacNet_Raven_Model_Api_Service_Request_Submit::CC_DEBIT)
196
+ ->setTemplateNumber($templateNo)
197
+ ->setAmount($amount)
198
+ ->setDescription($description);
199
+ //->setComment();
200
+
201
+ if ($order = $payment->getOrder()) {
202
+ $ravenSubmitRequest->setCurrency($order->getBaseCurrencyCode())
203
+ ->setReference($order->getIncrementId())
204
+ ->setContactEmail($order->getCustomerEmail());
205
+
206
+ if ($billing = $order->getBillingAddress()) {
207
+ $ravenSubmitRequest->setAccountName($billing->getFirstname() . ' ' . $billing->getLastname())
208
+ ->setBillingAddressLine1($billing->getStreet(1))
209
+ ->setBillingAddressLine2($billing->getStreet(2))
210
+ ->setBillingCity($billing->getCity())
211
+ ->setBillingRegion($billing->getRegion())
212
+ ->setBillingPostal($billing->getPostcode())
213
+ ->setBillingCountry($billing->getCountry())
214
+ ->setCustomerPhone($billing->getTelephone());
215
+ }
216
+
217
+ if ($shipping = $order->getShippingAddress()) {
218
+ $ravenSubmitRequest->setShippingAddressLine1($shipping->getStreet(1))
219
+ ->setShippingAddressLine2($shipping->getStreet(2))
220
+ ->setShippingCity($shipping->getCity())
221
+ ->setShippingRegion($shipping->getRegion())
222
+ ->setShippingPostal($shipping->getPostcode())
223
+ ->setShippingCountry($shipping->getCountry());
224
+ }
225
+ }
226
+
227
+ if($this->_debug) {
228
+ Mage::log('Request Data: ' . print_r($ravenSubmitRequest->getData(),true) , null, $this->_debugFile);
229
+ }
230
+
231
+ $ravenSubmitResponse = $ravenSubmitRequest->send();
232
+
233
+ if($this->_debug) {
234
+ Mage::log('Response String: ' . print_r($ravenSubmitResponse->getRavenResponseString(), true), null, $this->_debugFile);
235
+ Mage::log('Response Data: ' . print_r($ravenSubmitResponse->getRavenResponseData(), true), null, $this->_debugFile);
236
+ }
237
+
238
+ return $ravenSubmitResponse;
239
+ }
240
+
241
+ /**
242
+ * Makes a pre-authorised payment
243
+ * @todo To be implemented
244
+ */
245
+ public function preauth()
246
+ {
247
+
248
+ }
249
+
250
+ /**
251
+ * Settles a pre-authorised payment
252
+ * @todo To be implemented
253
+ */
254
+ public function settle()
255
+ {
256
+
257
+ }
258
+
259
+ /**
260
+ * Voids a payment
261
+ * @todo To be implemented
262
+ */
263
+ public function void()
264
+ {
265
+
266
+ }
267
+
268
+ /**
269
+ * Refund a payment
270
+ * @todo To be implemented
271
+ */
272
+ public function refund()
273
+ {
274
+
275
+ }
276
+
277
+ /**
278
+ * Makes a hello request
279
+ * @todo To be implemented
280
+ */
281
+ public function hello()
282
+ {
283
+
284
+ }
285
+
286
+ /**
287
+ * Gets a Raven response
288
+ *
289
+ * @param $requestID
290
+ *
291
+ * @return mixed
292
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
293
+ */
294
+ public function getResponse($requestID)
295
+ {
296
+ $ravenResponseRequest = new PacNet_Raven_Model_Api_Service_Response($this->_getConfig());
297
+ $ravenResponseRequest->setRequestID($requestID);
298
+
299
+ try {
300
+ $response = $ravenResponseRequest->send();
301
+ } catch (PacNet_Raven_Model_Api_Service_Request_Exception $e) {
302
+ //throw caught exception
303
+ }
304
+
305
+ return $response;
306
+
307
+ }
308
+
309
+ /**
310
+ * Format amount for Raven api
311
+ *
312
+ * @param $amount
313
+ * @param bool $asFloat
314
+ *
315
+ * @return float|string
316
+ */
317
+ protected function _formatAmount($amount, $asFloat = false)
318
+ {
319
+ $amount = Mage::app()->getStore()->roundPrice($amount);
320
+ return !$asFloat ? (string)$amount : $amount;
321
+ }
322
+ }
app/code/community/PacNet/Raven/Model/Api/Service/Request/Abstract.php ADDED
@@ -0,0 +1,493 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API service request abstract
37
+ */
38
+ abstract class PacNet_Raven_Model_Api_Service_Request_Abstract
39
+ {
40
+ /**
41
+ * Raven API version
42
+ */
43
+ const RAPI_VERSION = 2;
44
+
45
+ /**
46
+ * Rave API interface
47
+ */
48
+ const RAPI_INTERFACE = 'PHPVer2.3';
49
+
50
+ /**
51
+ * Raven API gateway
52
+ */
53
+ const RAPI_GATEWAY = 'https://raven.pacnetservices.com/realtime';
54
+
55
+ /**
56
+ * Raven API content type
57
+ */
58
+ const CONTENT_TYPE = 'application/x-www-form-urlencoded';
59
+
60
+ /**
61
+ * Raven mandatory request data
62
+ */
63
+ protected $_userName;
64
+ protected $_secret;
65
+ protected $_PRN;
66
+ protected $_requestID;
67
+ protected $_requestResult;
68
+ protected $_signature;
69
+ protected $_timestamp;
70
+ protected $_signatureParams;
71
+ protected $_serviceName;
72
+
73
+ /**
74
+ * Allowed request properties
75
+ *
76
+ * @var
77
+ */
78
+ protected $_dataKeys;
79
+
80
+ /**
81
+ * Request properties
82
+ *
83
+ * @var
84
+ */
85
+ protected $_data;
86
+
87
+ /**
88
+ * Constructor.
89
+ *
90
+ * @param $config
91
+ */
92
+ public function __construct($config)
93
+ {
94
+ $this->setConfig($config);
95
+ }
96
+
97
+ /**
98
+ * Sets config
99
+ *
100
+ * @param $config
101
+ *
102
+ * @return $this
103
+ */
104
+ public function setConfig($config)
105
+ {
106
+ if ($config['UserName']) $this->setUserName($config['UserName']);
107
+ if ($config['Secret']) $this->setSecret($config['Secret']);
108
+ if ($config['RequestID']) $this->setRequestID($config['RequestID']);
109
+ if ($config['PRN']) $this->setPRN($config['PRN']);
110
+
111
+ return $this;
112
+ }
113
+
114
+ /**
115
+ * Gets gateway url
116
+ *
117
+ * @return string
118
+ */
119
+ public function getUrl()
120
+ {
121
+ return self::RAPI_GATEWAY . '/' . $this->getServiceName();
122
+ }
123
+
124
+ /**
125
+ * Send a Raven request
126
+ *
127
+ * @return PacNet_Raven_Model_Api_Service_Response
128
+ */
129
+ public function send()
130
+ {
131
+ $responseConfig = array(
132
+ 'UserName' => $this->getUserName(),
133
+ 'Secret' => $this->getSecret()
134
+ );
135
+ list($httpResponseHeader, $responseData) = $this->_postRequest();
136
+ return new PacNet_Raven_Model_Api_Service_Response(
137
+ $responseConfig,
138
+ $httpResponseHeader,
139
+ $responseData,
140
+ $this->getServiceName());
141
+ }
142
+
143
+ /**
144
+ * Creates and posts the request
145
+ *
146
+ * @param null $optional_headers
147
+ *
148
+ * @return array
149
+ */
150
+ protected function _postRequest($optional_headers = null)
151
+ {
152
+ $url = $this->getUrl();
153
+ $data = $this->getData(true);
154
+
155
+ $params = array('http' => array(
156
+ 'method' => 'POST',
157
+ 'header' => 'Content-type: ' . self::CONTENT_TYPE,
158
+ 'content' => $data
159
+ ));
160
+
161
+ if ($optional_headers !== null) {
162
+ $params['http']['header'] = $optional_headers;
163
+ }
164
+
165
+ $context = stream_context_create($params);
166
+ $responseData = file_get_contents($url, false, $context);
167
+
168
+ $httpResponseHeader = null;
169
+
170
+ if (isset($http_response_header)) {
171
+ $httpResponseHeader = $http_response_header;
172
+ }
173
+
174
+ return array($httpResponseHeader, $responseData);
175
+ }
176
+
177
+ /**
178
+ * Creates a request signature
179
+ *
180
+ * @return string
181
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
182
+ */
183
+ protected function createSignature()
184
+ {
185
+ $data = '';
186
+ foreach($this->_signatureParams as $param) {
187
+ $data .= $this->get($param);
188
+ }
189
+ return hash_hmac("sha1", $data, $this->getSecret());
190
+ }
191
+
192
+ /**
193
+ * Creates a request reference no.
194
+ *
195
+ * @return string
196
+ */
197
+ protected function createRequestID()
198
+ {
199
+ return uniqid('RQ');
200
+ }
201
+
202
+ /**
203
+ * Gets object data
204
+ *
205
+ * @param bool $toString
206
+ * @param bool $secure
207
+ *
208
+ * @return array|string
209
+ */
210
+ public function getData($toString=false, $secure=false)
211
+ {
212
+ $configData = array();
213
+ $configData['RAPIVersion'] = self::RAPI_VERSION;
214
+ $configData['RAPIInterface'] = self::RAPI_INTERFACE;
215
+ $configData['UserName'] = $this->getUserName();
216
+ $configData['Timestamp'] = $this->getTimestamp();
217
+ $configData['RequestID'] = $this->getRequestID();
218
+ $configData['Signature'] = $this->getSignature();
219
+ $configData['PRN'] = $this->getPRN();
220
+ $data = array_merge($configData, $this->_data);
221
+
222
+ if ($secure) {
223
+ if (isset($data['CardNumber'])) $data['CardNumber'] = $this->maskCreditCard($data['CardNumber']);
224
+ if (isset($data['CVV2'])) $data['CVV2'] = str_repeat('X',strlen($data['CVV2']));
225
+ }
226
+
227
+ if ($toString) {
228
+ $data = '&' . http_build_query($data);
229
+ }
230
+
231
+ return $data;
232
+ }
233
+
234
+ /**
235
+ * Masks credit card no.
236
+ *
237
+ * Replaces all but the last for digits with x's in the given credit card number
238
+ *
239
+ * @param int|string $cc The credit card number to mask
240
+ * @return string The masked credit card number
241
+ */
242
+ public function maskCreditCard($cc){
243
+ $ccLength = strlen($cc);
244
+ for($i=0; $i<$ccLength-4; $i++){
245
+ if($cc[$i] == '-'){continue;}
246
+ $cc[$i] = 'X';
247
+ }
248
+ return $cc;
249
+ }
250
+
251
+ /**
252
+ * Gets the service name
253
+ *
254
+ * @return mixed
255
+ */
256
+ public function getServiceName()
257
+ {
258
+ return $this->_serviceName;
259
+ }
260
+
261
+ /**
262
+ * Sets the service name
263
+ *
264
+ * @param $serviceName
265
+ *
266
+ * @return $this
267
+ */
268
+ public function setServiceName($serviceName)
269
+ {
270
+ $this->_serviceName = $serviceName;
271
+
272
+ return $this;
273
+ }
274
+
275
+ /**
276
+ * Gets the API username
277
+ *
278
+ * @return mixed
279
+ */
280
+ public function getUserName()
281
+ {
282
+ return $this->_userName;
283
+ }
284
+
285
+ /**
286
+ * Sets the API username
287
+ *
288
+ * @param $userName
289
+ */
290
+ public function setUserName($userName)
291
+ {
292
+ $this->_userName = $userName;
293
+ }
294
+
295
+ /**
296
+ * Gets the API secret
297
+ *
298
+ * @return mixed
299
+ */
300
+ public function getSecret()
301
+ {
302
+ return $this->_secret;
303
+ }
304
+
305
+ /**
306
+ * Gets the API secret
307
+ *
308
+ * @param $secret
309
+ */
310
+ public function setSecret($secret)
311
+ {
312
+ $this->_secret = $secret;
313
+ }
314
+
315
+ /**
316
+ * Gets the API payment routing number
317
+ *
318
+ * @return mixed
319
+ */
320
+ public function getPRN()
321
+ {
322
+ return $this->_PRN;
323
+ }
324
+
325
+ /**
326
+ * Gets the API payment routing number
327
+ *
328
+ * @param $PRN
329
+ *
330
+ * @return $this
331
+ */
332
+ public function setPRN($PRN)
333
+ {
334
+ $this->_PRN = $PRN;
335
+ return $this;
336
+ }
337
+
338
+ /**
339
+ * Gets the request id/reference no.
340
+ *
341
+ * @return string
342
+ */
343
+ public function getRequestID()
344
+ {
345
+ if (null==$this->_requestID) {
346
+ $this->_requestID = $this->createRequestID();
347
+ }
348
+ return $this->_requestID;
349
+ }
350
+
351
+ /**
352
+ * Sets the request id/reference no.
353
+ *
354
+ * @param $requestID
355
+ */
356
+ public function setRequestID($requestID)
357
+ {
358
+ $this->_requestID = $requestID;
359
+ }
360
+
361
+ /**
362
+ * Gets the timestamp
363
+ *
364
+ * Returns current timestamp if none present
365
+ *
366
+ * @return string
367
+ */
368
+ public function getTimestamp()
369
+ {
370
+ if (null == $this->_timestamp) {
371
+ $this->_timestamp = gmdate('Y-m-d\TH:i:s.000\Z');
372
+ }
373
+
374
+ return $this->_timestamp;
375
+ }
376
+
377
+ /**
378
+ * Gets the request signature
379
+ *
380
+ * @return string
381
+ */
382
+ public function getSignature()
383
+ {
384
+ if (null === $this->_signature) {
385
+ $this->_signature = $this->createSignature();
386
+ }
387
+
388
+ return $this->_signature;
389
+ }
390
+
391
+ /**
392
+ * Get magic method
393
+ *
394
+ * @param $key
395
+ *
396
+ * @return mixed
397
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
398
+ */
399
+ public function __get($key)
400
+ {
401
+ return $this->get($key);
402
+ }
403
+
404
+ /**
405
+ * Set magic method
406
+ *
407
+ * @param $key
408
+ * @param $value
409
+ *
410
+ * @return PacNet_Raven_Model_Api_Service_Request_Abstract
411
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
412
+ */
413
+ public function __set($key, $value)
414
+ {
415
+ return $this->set($key, $value);
416
+ }
417
+
418
+ /**
419
+ * Global get
420
+ *
421
+ * @param $key
422
+ *
423
+ * @return mixed
424
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
425
+ */
426
+ public function get($key)
427
+ {
428
+ $method = 'get' . $key;
429
+
430
+ if (method_exists($this, $method)) {
431
+ return $this->$method();
432
+ }
433
+
434
+ if (!array_key_exists($key, $this->_data)) {
435
+ throw new PacNet_Raven_Model_Api_Service_Request_Exception("Trying to get value ($key) that doesn't exist");
436
+ }
437
+
438
+ return $this->_data[$key];
439
+ }
440
+
441
+ /**
442
+ * Global set
443
+ *
444
+ * @param $key
445
+ * @param $value
446
+ *
447
+ * @return $this
448
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
449
+ */
450
+ public function set($key, $value)
451
+ {
452
+ if (!$value) return $this;
453
+
454
+ $method = 'set' . $key;
455
+
456
+ if (method_exists($this, $method)) {
457
+ return $this->$method($value);
458
+ }
459
+ if (!in_array($key, $this->_dataKeys)) {
460
+ throw new PacNet_Raven_Model_Api_Service_Request_Exception("Trying to set value ($key) that doesn't exist");
461
+ }
462
+
463
+ $this->_data[$key] = $value;
464
+
465
+ return $this;
466
+ }
467
+
468
+ /**
469
+ * Call magic method
470
+ *
471
+ * @param $name
472
+ * @param $args
473
+ *
474
+ * @return PacNet_Raven_Model_Api_Service_Request_Abstract|mixed
475
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
476
+ */
477
+ public function __call($name, $args)
478
+ {
479
+ $key = substr($name, 3);
480
+ $type = substr($name, 0, 3);
481
+ switch ($type) {
482
+ case 'get':
483
+ return $this->get($key);
484
+ break;
485
+ case 'set':
486
+ return $this->set($key, $args[0]);
487
+ break;
488
+ default:
489
+ throw new PacNet_Raven_Model_Api_Service_Request_Exception("Method '$name' does not exist");
490
+ break;
491
+ }
492
+ }
493
+ }
app/code/community/PacNet/Raven/Model/Api/Service/Request/Exception.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API service request exception
37
+ */
38
+ class PacNet_Raven_Model_Api_Service_Request_Exception extends Exception {}
app/code/community/PacNet/Raven/Model/Api/Service/Request/Hello.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API hello service request
37
+ */
38
+ class PacNet_Raven_Model_Api_Service_Request_Hello extends PacNet_Raven_Model_Api_Service_Request_Abstract
39
+ {
40
+ /**
41
+ * Request properties
42
+ *
43
+ * @var array
44
+ */
45
+ protected $_data = array (
46
+ 'RequestResult'
47
+ );
48
+
49
+ /**
50
+ * Signature parameters
51
+ *
52
+ * @var array
53
+ */
54
+ protected $_signatureParams = array (
55
+ 'UserName'
56
+ );
57
+ }
app/code/community/PacNet/Raven/Model/Api/Service/Request/Response.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API payment request response
37
+ */
38
+ class PacNet_Raven_Model_Api_Service_Request_Response extends PacNet_Raven_Model_Api_Service_Request_Abstract
39
+ {
40
+ /**
41
+ * Request response properties
42
+ *
43
+ * @var array
44
+ */
45
+ protected $_data = array (
46
+ 'RequestResult'
47
+ );
48
+
49
+ /**
50
+ * Signature parameters
51
+ *
52
+ * @var array
53
+ */
54
+ protected $_signatureParams = array (
55
+ 'UserName'
56
+ );
57
+ }
app/code/community/PacNet/Raven/Model/Api/Service/Request/Submit.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API submit service request
37
+ */
38
+ class PacNet_Raven_Model_Api_Service_Request_Submit extends PacNet_Raven_Model_Api_Service_Request_Abstract
39
+ {
40
+ /**
41
+ * Raven API request types
42
+ */
43
+ const CC_DEBIT = 'cc_debit';
44
+ const CC_REFUND = 'cc_refund';
45
+ const CC_CREDIT = 'cc_credit';
46
+ const CC_OCT = 'cc_oct';
47
+ const CC_PREAUTH = 'cc_preauth';
48
+ const CC_SETTLE = 'cc_settle';
49
+ const CC_UPDATE = 'cc_update';
50
+ const CC_VERIFY = 'cc_verify';
51
+
52
+ /**
53
+ * Name of service
54
+ *
55
+ * @var string
56
+ */
57
+ protected $_serviceName = 'submit';
58
+
59
+ /**
60
+ * Signature parameters
61
+ *
62
+ * @var array
63
+ */
64
+ protected $_signatureParams = array (
65
+ 'UserName',
66
+ 'Timestamp',
67
+ 'RequestID',
68
+ 'PaymentType',
69
+ 'Amount',
70
+ 'Currency'
71
+ );
72
+
73
+ /**
74
+ * Allowed request properties
75
+ *
76
+ * @var array
77
+ */
78
+ protected $_dataKeys = array (
79
+ 'PRN',
80
+ 'Currency',
81
+ 'AccountName',
82
+ 'CardNumber',
83
+ 'CVV2',
84
+ 'IssueNumber',
85
+ 'PaymentType',
86
+ 'ExpiryDate',
87
+ 'Amount',
88
+ 'Reference',
89
+ 'Reference2',
90
+ 'Reference3',
91
+ 'Reference4',
92
+ 'Reference5',
93
+ 'Reference6',
94
+ 'Reference7',
95
+ 'Reference8',
96
+ 'Reference9',
97
+ 'Reference10',
98
+ 'PreauthNumber',
99
+ 'TemplateNumber',
100
+ 'Description',
101
+ 'Description2',
102
+ 'Comment',
103
+ 'BillingAddressLine1',
104
+ 'BillingAddressLine2',
105
+ 'BillingAddressLine3',
106
+ 'BillingAddressLine4',
107
+ 'BillingCity',
108
+ 'BillingRegion',
109
+ 'BillingPostal',
110
+ 'BillingCountry',
111
+ 'ShippingAddressLine1',
112
+ 'ShippingAddressLine2',
113
+ 'ShippingAddressLine3',
114
+ 'ShippingAddressLine4',
115
+ 'ShippingCity',
116
+ 'ShippingRegion',
117
+ 'ShippingPostal',
118
+ 'ShippingCountry',
119
+ 'ContactEmail',
120
+ 'CustomerIP',
121
+ 'CustomerPhone'
122
+ );
123
+ }
app/code/community/PacNet/Raven/Model/Api/Service/Response.php ADDED
@@ -0,0 +1,464 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API payment service response
37
+ */
38
+ class PacNet_Raven_Model_Api_Service_Response
39
+ {
40
+ /**
41
+ * @var string
42
+ */
43
+ protected $_userName;
44
+
45
+ /**
46
+ * @var string
47
+ */
48
+ protected $_secret;
49
+
50
+ /**
51
+ * @var string
52
+ */
53
+ protected $_httpResponseHeader;
54
+
55
+ /**
56
+ * @var string
57
+ */
58
+ protected $_ravenResponseString;
59
+
60
+ /**
61
+ * @var int
62
+ */
63
+ protected $_httpStatus;
64
+
65
+ /**
66
+ * @var string
67
+ */
68
+ protected $_serviceName;
69
+
70
+ /**
71
+ * @var array
72
+ */
73
+ protected $_data = array();
74
+
75
+
76
+ /**
77
+ * Constructor.
78
+ *
79
+ * @param $config
80
+ * @param $httpResponseHeader
81
+ * @param $ravenResponseString
82
+ * @param $serviceName
83
+ *
84
+ * @throws PacNet_Raven_Model_Api_Response_Exception
85
+ */
86
+ public function __construct($config, $httpResponseHeader, $ravenResponseString, $serviceName)
87
+ {
88
+ $this->setConfig($config);
89
+ $this->setRavenResponseString($ravenResponseString);
90
+ $this->setServiceName($serviceName);
91
+
92
+ $httpResponse = null;
93
+ if ($httpResponseHeader == null) {
94
+ throw new PacNet_Raven_Model_Api_Response_Exception('No response from server, please try again!');
95
+ }
96
+ $this->setHttpHeader($httpResponseHeader);
97
+
98
+ switch($this->getHttpStatus()) {
99
+ case 200:
100
+ $this->parseResponse($ravenResponseString);
101
+ break;
102
+ case 500:
103
+ throw new PacNet_Raven_Model_Api_Response_Exception('No response from server, please try again!');
104
+ break;
105
+ default:
106
+ break;
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Sets config
112
+ *
113
+ * @param $config
114
+ *
115
+ * @return $this
116
+ */
117
+ public function setConfig($config)
118
+ {
119
+ if ($config['UserName']) $this->setUserName($config['UserName']);
120
+ if ($config['Secret']) $this->setSecret($config['Secret']);
121
+ return $this;
122
+ }
123
+
124
+ /**
125
+ * Gets the Raven request result
126
+ *
127
+ * @return string
128
+ */
129
+ public function getRequestResult()
130
+ {
131
+ $status = $this->getHttpStatus();
132
+ if($status == 500) {
133
+ return 'serverError';
134
+ }
135
+ return $this->getRequestResult();
136
+ }
137
+
138
+ /**
139
+ * Gets the Raven response string
140
+ *
141
+ * @return mixed
142
+ */
143
+ public function getRavenResponseString()
144
+ {
145
+ return $this->_ravenResponseString;
146
+ }
147
+
148
+ /**
149
+ * Gets the Raven response data
150
+ *
151
+ * @return array
152
+ */
153
+ public function getRavenResponseData() {
154
+ return $this->_data;
155
+ }
156
+
157
+ /**
158
+ * Sets the Raven response string
159
+ *
160
+ * @param $ravenResponseString
161
+ *
162
+ * @return mixed
163
+ */
164
+ protected function setRavenResponseString($ravenResponseString)
165
+ {
166
+ return $this->_ravenResponseString = $ravenResponseString;
167
+ }
168
+
169
+ /**
170
+ * Parse the Raven response
171
+ *
172
+ * @param $ravenResponseString
173
+ *
174
+ * @throws PacNet_Raven_Model_Api_Response_Exception
175
+ */
176
+ protected function parseResponse($ravenResponseString)
177
+ {
178
+ $paramAndReportPairs = explode("\r", $ravenResponseString, 2);
179
+ $this->setResponseParameters($paramAndReportPairs[0]);
180
+ if (count($paramAndReportPairs) == 2) {
181
+ $this->setReportParameters($paramAndReportPairs[1]);
182
+ }
183
+
184
+ $this->authenticate();
185
+ }
186
+
187
+ /**
188
+ * Sets response parameters in object
189
+ *
190
+ * @param $responseParamData
191
+ */
192
+ protected function setResponseParameters($responseParamData)
193
+ {
194
+ $paramPairs = explode('&', $responseParamData);
195
+ foreach ($paramPairs as $paramPair) {
196
+ list($key, $value) = explode('=', $paramPair);
197
+ if ($key != '') {
198
+ $key = htmlspecialchars(urldecode($key));
199
+ $value = htmlspecialchars(urldecode($value));
200
+ $this->set($key, $value);
201
+ }
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Sets the response report parameters
207
+ *
208
+ * @param $reportData
209
+ */
210
+ protected function setReportParameters($reportData)
211
+ {
212
+ $this->setReport($reportData);
213
+ }
214
+
215
+ /**
216
+ * Authenticates the Raven response
217
+ *
218
+ * @throws PacNet_Raven_Model_Api_Response_Exception
219
+ */
220
+ protected function authenticate()
221
+ {
222
+ if ($this->verificationSignature() != $this->getSignature()) {
223
+ throw new PacNet_Raven_Model_Api_Response_Exception("Invalid Raven signature!");
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Verify the Raven signature
229
+ *
230
+ * @return string
231
+ */
232
+ protected function verificationSignature()
233
+ {
234
+ $data = $this->getUserName() . $this->getTimestamp() . $this->getRequestID();
235
+ return hash_hmac("sha1", $data, $this->getSecret());
236
+ }
237
+
238
+ /**
239
+ * Sets the Http header
240
+ *
241
+ * @param $httpResponseHeader
242
+ */
243
+ protected function setHttpHeader($httpResponseHeader)
244
+ {
245
+ $this->setHttpResponseHeader($httpResponseHeader);
246
+ $pattern = '/^HTTP\/1\.[01] ([0-9]{3})/';
247
+ preg_match($pattern, $httpResponseHeader[0], $matches);
248
+ $this->setHttpStatus($matches[1]);
249
+ }
250
+
251
+ /**
252
+ * Gets the Http response header
253
+ *
254
+ * @return mixed
255
+ */
256
+ public function getHttpResponseHeader()
257
+ {
258
+ return $this->_httpResponseHeader;
259
+ }
260
+
261
+ /**
262
+ * Sets the Http response header
263
+ *
264
+ * @param $httpResponseHeader
265
+ *
266
+ * @return $this
267
+ */
268
+ public function setHttpResponseHeader($httpResponseHeader)
269
+ {
270
+ $this->_httpResponseHeader = $httpResponseHeader;
271
+ return $this;
272
+ }
273
+
274
+ /**
275
+ * Gets the Http status
276
+ *
277
+ * @return mixed
278
+ */
279
+ public function getHttpStatus()
280
+ {
281
+ return $this->_httpStatus;
282
+ }
283
+
284
+ /**
285
+ * Sets the Http status
286
+ *
287
+ * @param $httpStatus
288
+ *
289
+ * @return $this
290
+ */
291
+ public function setHttpStatus($httpStatus)
292
+ {
293
+ $this->_httpStatus = $httpStatus;
294
+ return $this;
295
+ }
296
+
297
+ /**
298
+ * Gets the service name
299
+ *
300
+ * @return mixed
301
+ */
302
+ public function getServiceName()
303
+ {
304
+ return $this->_serviceName;
305
+ }
306
+
307
+ /**
308
+ * Sets the service name
309
+ *
310
+ * @param $serviceName
311
+ *
312
+ * @return $this
313
+ */
314
+ public function setServiceName($serviceName)
315
+ {
316
+ $this->_serviceName = $serviceName;
317
+ return $this;
318
+ }
319
+
320
+ /**
321
+ * Gets the API username
322
+ *
323
+ * @return mixed
324
+ */
325
+ public function getUserName()
326
+ {
327
+ return $this->_userName;
328
+ }
329
+
330
+ /**
331
+ * Sets the API username
332
+ *
333
+ * @param $userName
334
+ *
335
+ * @return $this
336
+ */
337
+ public function setUserName($userName)
338
+ {
339
+ $this->_userName = $userName;
340
+ return $this;
341
+ }
342
+
343
+ /**
344
+ * Gets the API secret
345
+ *
346
+ * @return mixed
347
+ */
348
+ public function getSecret()
349
+ {
350
+ return $this->_secret;
351
+ }
352
+
353
+ /**
354
+ * Sets the API secret
355
+ *
356
+ * @param $secret
357
+ *
358
+ * @return $this
359
+ */
360
+ public function setSecret($secret)
361
+ {
362
+ $this->_secret = $secret;
363
+ return $this;
364
+ }
365
+
366
+ /**
367
+ * Gets the transactional info
368
+ *
369
+ * Used for Magento transaction additional info
370
+ *
371
+ * @return array
372
+ */
373
+ public function getTransactionAdditionalInfo()
374
+ {
375
+ return array(
376
+ 'RequestID' => $this->getRequestID(),
377
+ 'ApprovalCode' => $this->getApprovalCode(),
378
+ 'Status' => $this->getStatus(),
379
+ 'TrackingNumber' => $this->getTrackingNumber()
380
+ );
381
+ }
382
+
383
+ /**
384
+ * Get magic method
385
+ *
386
+ * @param $key
387
+ *
388
+ * @return mixed|null
389
+ */
390
+ public function __get($key)
391
+ {
392
+ return $this->get($key);
393
+ }
394
+
395
+ /**
396
+ * Set magic method
397
+ *
398
+ * @param $key
399
+ * @param $value
400
+ *
401
+ * @return PacNet_Raven_Model_Api_Service_Response
402
+ */
403
+ public function __set($key, $value)
404
+ {
405
+ return $this->set($key, $value);
406
+ }
407
+
408
+ /**
409
+ * Global get
410
+ *
411
+ * @param $key
412
+ *
413
+ * @return mixed|null
414
+ */
415
+ public function get($key) {
416
+ if(array_key_exists($key, $this->_data)) {
417
+ return $this->_data[$key];
418
+ }
419
+
420
+ return null;
421
+ }
422
+
423
+ /**
424
+ * Global set
425
+ *
426
+ * @param $key
427
+ * @param $value
428
+ *
429
+ * @return $this
430
+ */
431
+ public function set($key, $value)
432
+ {
433
+ $this->_data[$key] = $value;
434
+ return $this;
435
+ }
436
+
437
+ /**
438
+ * Call magic method
439
+ *
440
+ * @param $name
441
+ * @param $args
442
+ *
443
+ * @return PacNet_Raven_Model_Api_Service_Response|mixed|null
444
+ * @throws PacNet_Raven_Model_Api_Service_Request_Exception
445
+ */
446
+ public function __call($name, $args)
447
+ {
448
+ $key = substr($name, 3);
449
+ $type = substr($name, 0, 3);
450
+ switch ($type) {
451
+ case 'get':
452
+ return $this->get($key);
453
+ break;
454
+ case 'set':
455
+ echo $key; exit;
456
+ return $this->set($key, $args[0]);
457
+ break;
458
+ default:
459
+ throw new PacNet_Raven_Model_Api_Service_Request_Exception("Method '$name' does not exist");
460
+ break;
461
+ }
462
+ }
463
+
464
+ }
app/code/community/PacNet/Raven/Model/Api/Service/Response/Codes/CVV2.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API payment CVV2 response codes
37
+ */
38
+ class PacNet_Raven_Model_Api_Service_Response_Codes_CVV2
39
+ {
40
+ /**
41
+ * CVV2 response codes
42
+ *
43
+ * @var array
44
+ */
45
+ protected $responseCodes = array(
46
+ 'cvv2_matched' => 'Any payment were the CVV2 was checked and matched the CVV2 supplied.',
47
+ 'cvv2_not_matched' => 'Any payment where the CVV2 was checked and did not match the CVV2 supplied.',
48
+ 'cvv2_not_checked' => 'Any payment where either the CVV2 data was not supplied or rarely, where the CVV2 was not checked by the gateway even though the service was available.',
49
+ 'cvv2_unavailable' => 'Any payment where the CVV2 could not be checked because the service was not available.',
50
+ 'cvv2__response_unknown' => 'If the CVV2 was provided but no information on the match is provided by the acquiring bank.',
51
+ );
52
+ }
app/code/community/PacNet/Raven/Model/Api/Service/Response/Codes/Status.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API payment status response codes
37
+ */
38
+ class PacNet_Raven_Model_Api_Service_Response_Codes_Status
39
+ {
40
+ /**
41
+ * Response status codes
42
+ *
43
+ * @var array
44
+ */
45
+ protected $statuses = array(
46
+ 'InProgress' => 'the payment has been received and will be processed.',
47
+ 'Pending3DS' => 'the payment has been received and response included information to complete 3DS authentication.',
48
+ 'Submitted' => 'the payment has been submitted to the clearing system.',
49
+ 'Approved' => 'the request has been approved and the payment can be settled.',
50
+ 'Declined' => 'the request was declined and the payment may not be settled.',
51
+ 'RepeatDeclined' => 'the request was declined four or more times and the payment may not be settled.',
52
+ 'PickupCard' => 'payment has been declined and the merchant should confiscate the card if possible.',
53
+ 'ReferToIssuer' => 'the payment could not be approved. Call the issuing bank for clarification.',
54
+ 'Voided' => 'the payment has been voided and will not be processed.',
55
+ 'Invalid:field' => 'a field in the request is invalid',
56
+ 'Rejected:reason' => 'the payment, while valid, has been rejected for another reason.',
57
+ 'ConfigError:error' => 'due to a RAVEN configuration error the payment could not be processed.',
58
+ 'Error:error' => 'an unusual error condition has occurred.',
59
+ 'UnexpectedResponse:value' => 'the bank has returned an unexpected error condition.',
60
+ 'AccountValid' => 'cc_verify only',
61
+ 'AccountInvalid' => 'cc_verify only',
62
+ 'InsufficientFunds' => 'insufficient funds',
63
+ 'InvalidMerchant' => 'invalid merchant',
64
+ 'InvalidAccount' => 'invalid account',
65
+ 'InvalidAmount:limit' => 'limit on card exceeded',
66
+ 'OverDailyLimit' => 'over daily limit',
67
+ 'RestrictedCard' => 'registered card',
68
+ 'Retry' => 'retry',
69
+ 'SuspectedFraud' => 'suspected fraud',
70
+ 'UnableToAuth' => 'unable to auth',
71
+ 'ExpiredCard' => 'expired card',
72
+ 'TooManyAuths' => 'too many auths',
73
+ 'ViolatesLaw' => 'violates law',
74
+ );
75
+
76
+ /**
77
+ * Parses a response status
78
+ *
79
+ * @return array
80
+ */
81
+ public function parseStatus() {
82
+ $status = array();
83
+ list($statusCode, $statusValue) = explode(':', $this->getStatus());
84
+ $status['code'] = $statusCode;
85
+ $status['reason'] = $statusValue;
86
+ $status['message'] = $this->getStatusMessage($statusCode);
87
+ return $status;
88
+ }
89
+
90
+ /**
91
+ * Gets a status value using code
92
+ *
93
+ * @param $statusCode
94
+ *
95
+ * @return bool
96
+ */
97
+ public function getStatusValue($statusCode) {
98
+ foreach ($this->statuses as $status){
99
+ list($statusCodeElement, $statusValueElement) = explode(':', $status);
100
+ if ($statusCodeElement == $statusCode) {
101
+ return $statusValueElement;
102
+ }
103
+ }
104
+
105
+ return false;
106
+ }
107
+
108
+ /**
109
+ * Gets a status message using code
110
+ *
111
+ * @param $statusCode
112
+ *
113
+ * @return mixed|null
114
+ */
115
+ public function getStatusMessage($statusCode) {
116
+ if (! $this->isStatus($statusCode)) {
117
+ return null;
118
+ }
119
+ return $this->statuses[$statusCode];
120
+ }
121
+
122
+ /**
123
+ * Checks response status
124
+ *
125
+ * @param $statusCode
126
+ *
127
+ * @return bool
128
+ */
129
+ public function isStatus($statusCode) {
130
+ foreach ($this->statuses as $status){
131
+ list($statusCodeElement, $statusValueElement) = explode(':', $status);
132
+ if ($statusCodeElement == $statusCode) {
133
+ return true;
134
+ }
135
+ }
136
+
137
+ return false;
138
+ }
139
+ }
app/code/community/PacNet/Raven/Model/Api/Service/Response/Exception.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API payment response exception
37
+ */
38
+ class PacNet_Raven_Model_Api_Response_Exception extends Exception {}
app/code/community/PacNet/Raven/Model/Api/Source/Paymentaction.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven API source payment action
37
+ */
38
+ class PacNet_Raven_Model_Api_Source_Paymentaction
39
+ {
40
+ public function toOptionArray()
41
+ {
42
+ return array(
43
+ array(
44
+ 'value' => PacNet_Raven_Model_Api::ACTION_AUTHORIZE_CAPTURE,
45
+ 'label' => 'Authorise and Capture'
46
+ ),
47
+ );
48
+ }
49
+ }
app/code/community/PacNet/Raven/Model/MarketDirect.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven MarketDirect payment method
37
+ */
38
+ class PacNet_Raven_Model_MarketDirect extends Mage_Payment_Model_Method_Abstract
39
+ {
40
+ protected $_code = 'pacnet_raven_marketdirect';
41
+
42
+ protected $_isGateway = false;
43
+ protected $_canAuthorize = true;
44
+ protected $_canCapture = true;
45
+ protected $_canVoid = false;
46
+ // protected $_isInitializeNeeded = true;
47
+ protected $_canUseInternal = false;
48
+ protected $_canUseForMultishipping = false;
49
+
50
+ protected $_formBlockType = 'pacnet_raven/MarketDirect_Form';
51
+ protected $_infoBlockType = 'pacnet_raven/MarketDirect_Info';
52
+
53
+ /**
54
+ * Return Order place redirect url
55
+ *
56
+ * @return string
57
+ */
58
+ public function getOrderPlaceRedirectUrl()
59
+ {
60
+ return Mage::getUrl('pacnet-raven/marketdirect/redirect', array('_secure' => true));
61
+ }
62
+
63
+ /**
64
+ * Instantiate state and set it to state object
65
+ *
66
+ * @param string $paymentAction
67
+ * @param Varien_Object $stateObject
68
+ */
69
+ public function initialize($paymentAction, $stateObject)
70
+ {
71
+ return parent::initialize($paymentAction, $stateObject);
72
+ }
73
+ }
app/code/community/PacNet/Raven/Model/MarketDirect/Abstract.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven MarketDirect payment abstract model
37
+ */
38
+ class PacNet_Raven_Model_MarketDirect_Abstract extends Varien_Object
39
+ {
40
+ /**
41
+ * Raven payment types
42
+ */
43
+ const RAVEN_PAYMENT_TYPE_DEBIT = 'debit';
44
+ const RAVEN_PAYMENT_TYPE_PREAUTH = 'preauth';
45
+
46
+ /**
47
+ * Sales order
48
+ *
49
+ * @var Mage_Sales_Model_Order
50
+ */
51
+ protected $_order;
52
+
53
+ /**
54
+ * Flag to use order currency instead of base currency
55
+ *
56
+ * @var bool
57
+ */
58
+ protected $_useOrderCurrency = false;
59
+
60
+ /**
61
+ * Name of log file
62
+ *
63
+ * @var string
64
+ */
65
+ protected $_logFile = 'raven_marketdirect.log';
66
+
67
+
68
+ /**
69
+ * Credit card types available
70
+ *
71
+ * @var array
72
+ */
73
+ static public $ccTypes = array (
74
+ 'DC' => 'Diners Club/Carte Blanche',
75
+ 'DV' => 'Discover',
76
+ 'ER' => 'EnRoute',
77
+ 'GE' => 'GE Capital',
78
+ 'JB' => 'JCB',
79
+ 'JC' => 'Laser',
80
+ 'MA' => 'Maestro',
81
+ 'MC' => 'MasterCard/Eurocard',
82
+ 'MD' => 'MasterCard/Eurocard Debit',
83
+ 'SO' => 'Solo',
84
+ 'SW' => 'Switch',
85
+ 'VD' => 'Visa Debit',
86
+ 'VE' => 'Visa Electron',
87
+ 'VI' => 'Visa',
88
+ 'VP' => 'Visa Purchase'
89
+ );
90
+
91
+ /**
92
+ * Accepted payment types
93
+ *
94
+ * @var array
95
+ */
96
+ protected $_acceptedPaymentTypes = array (
97
+ self::RAVEN_PAYMENT_TYPE_DEBIT, self::RAVEN_PAYMENT_TYPE_PREAUTH
98
+ );
99
+
100
+ /**
101
+ * Gets sales order
102
+ *
103
+ * @return Mage_Sales_Model_Order
104
+ */
105
+ public function getOrder()
106
+ {
107
+ return $this->_order;
108
+ }
109
+
110
+ /**
111
+ * Sets sales order
112
+ *
113
+ * @param mixed $order
114
+ *
115
+ * @return $this
116
+ */
117
+ public function setOrder($order)
118
+ {
119
+ $this->_order = $order;
120
+ return $this;
121
+ }
122
+
123
+ /**
124
+ * Checks if order currency can be used to make payment
125
+ *
126
+ * @return bool
127
+ */
128
+ public function canUseOrderCurrency()
129
+ {
130
+ return $this->_useOrderCurrency;
131
+ }
132
+
133
+ /**
134
+ * Gets payment config data
135
+ *
136
+ * @param $field
137
+ * @param null $storeId
138
+ *
139
+ * @return mixed
140
+ */
141
+ protected function _getPaymentConfigData($field, $storeId = null)
142
+ {
143
+ return $this->getOrder()->getPayment()->getMethodInstance()->getConfigData($field, $storeId);
144
+ }
145
+
146
+ /**
147
+ * Formats Raven MarketDirect amount ready for invoicing
148
+ *
149
+ * @param $amount
150
+ *
151
+ * @return float
152
+ */
153
+ protected function _formatInvoiceAmount($amount)
154
+ {
155
+ return $amount / 100;
156
+ }
157
+
158
+ /**
159
+ * Formats amount for Raven MarketDirect
160
+ *
161
+ * @param $amount
162
+ *
163
+ * @return float
164
+ */
165
+ protected function _formatAmount($amount, $asFloat=false)
166
+ {
167
+ $amount = Mage::app()->getStore()->roundPrice($amount) * 100;
168
+ return !$asFloat ? (string)$amount : $amount;
169
+ }
170
+ }
app/code/community/PacNet/Raven/Model/MarketDirect/Response.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven MarketDirect payment response model
37
+ */
38
+ class PacNet_Raven_Model_MarketDirect_Response extends PacNet_Raven_Model_MarketDirect_Abstract
39
+ {
40
+ /**
41
+ * Constructor
42
+ *
43
+ * @param $response
44
+ * @param $order
45
+ */
46
+ public function __construct($response)
47
+ {
48
+ $this->setData($response);
49
+
50
+ $orderIncrementId = $this->getOrderId();
51
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
52
+
53
+ $this->setOrder($order);
54
+
55
+ if ($this->_getPaymentConfigData('debug')) {
56
+ Mage::log('Raven MarketDirect response data: ' . print_r($response, true) , null, $this->_logFile);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Checks if response is valid
62
+ *
63
+ * @return bool
64
+ * @throws Mage_Core_Exception
65
+ */
66
+ public function isValid()
67
+ {
68
+ if (! $this->_isValidSignature()) {
69
+ throw Mage::exception('PacNet_Raven',
70
+ Mage::helper('pacnet_raven')->__('Invalid signature from Raven MarketDirect response'));
71
+ }
72
+
73
+ if (! $this->_checkAmountPaid()) {
74
+ throw Mage::exception('PacNet_Raven',
75
+ Mage::helper('pacnet_raven')->__('Invalid payment amount received from Raven MarketDirect response'));
76
+ }
77
+
78
+ if (! $this->_isValidPaymentType()) {
79
+ throw Mage::exception('PacNet_Raven',
80
+ Mage::helper('pacnet_raven')->__('Invalid payment type in Raven MarketDirect response'));
81
+ }
82
+
83
+ return true;
84
+ }
85
+
86
+ /**
87
+ * Is transaction approved
88
+ *
89
+ * @return bool
90
+ */
91
+ public function isApproved()
92
+ {
93
+ return 'Approved' == $this->getData('md_status') ? true : false;
94
+ }
95
+
96
+ /**
97
+ * Gets the order Id
98
+ *
99
+ * @return mixed
100
+ */
101
+ public function getOrderId()
102
+ {
103
+ return $this->getData('md_reference2');
104
+ }
105
+
106
+ /**
107
+ * Gets amount paid
108
+ *
109
+ * Formats to Magento invoice amount
110
+ *
111
+ * @return float
112
+ */
113
+ public function getAmountPaid()
114
+ {
115
+ return $this->_formatInvoiceAmount($this->getData('md_amount'));
116
+
117
+ }
118
+
119
+ /**
120
+ * Gets credit card type
121
+ *
122
+ * @return mixed
123
+ */
124
+ public function getCcType()
125
+ {
126
+ return self::$ccTypes[$this->getData('md_card_scheme')];
127
+ }
128
+
129
+ /**
130
+ * Gets the payment type
131
+ *
132
+ * @return mixed
133
+ */
134
+ public function getPaymentType()
135
+ {
136
+ return $this->getData('md_reference3');
137
+ }
138
+
139
+ /**
140
+ * Generates a Raven MarketDirect response signature
141
+ *
142
+ * @return bool
143
+ */
144
+ protected function _generateRavenSignature() {
145
+ $first = $this->getData('md_submitter') . ',' . $this->getData('md_timestamp') . ','
146
+ . $this->getData('md_amount') . ',' . $this->getData('md_currency') . ','
147
+ . $this->getData('md_reference');
148
+ $second = strtoupper(sha1($first));
149
+ $third = $second . ',' . $this->_getPaymentConfigData('shared_secret');
150
+ $final = strtoupper(sha1($third));
151
+ return $final == $this->getData('md_signature') ? true : false;
152
+ }
153
+
154
+ /**
155
+ * Check for a valid signature
156
+ *
157
+ * @return bool
158
+ */
159
+ protected function _isValidSignature()
160
+ {
161
+ return $this->_generateRavenSignature() == $this->getData('md_signature') ? true : false;
162
+ }
163
+
164
+ /**
165
+ * Checks for a valid payment type
166
+ *
167
+ * @return bool
168
+ */
169
+ protected function _isValidPaymentType()
170
+ {
171
+ return in_array($this->getPaymentType(), $this->_acceptedPaymentTypes);
172
+ }
173
+
174
+ /**
175
+ * Checks response amount is valid
176
+ *
177
+ * @return bool
178
+ */
179
+ protected function _checkAmountPaid()
180
+ {
181
+ return $this->getData('md_amount') == $this->_formatAmount($this->getOrder()->getGrandTotal()) ? true : false;
182
+ }
183
+ }
app/code/community/PacNet/Raven/Model/MarketDirect/Source/PaymentType.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven MarketDirect source payment type
37
+ */
38
+ class PacNet_Raven_Model_MarketDirect_Source_PaymentType
39
+ {
40
+ public function toOptionArray()
41
+ {
42
+ return array(
43
+ array(
44
+ 'value' => PacNet_Raven_Model_MarketDirect_Transaction::RAVEN_PAYMENT_TYPE_DEBIT,
45
+ 'label' => 'Debit'
46
+ ),
47
+ array(
48
+ 'value' => PacNet_Raven_Model_MarketDirect_Transaction::RAVEN_PAYMENT_TYPE_PREAUTH,
49
+ 'label' => 'Pre-Authorise'
50
+ ),
51
+ );
52
+ }
53
+ }
app/code/community/PacNet/Raven/Model/MarketDirect/Transaction.php ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven MarketDirect payment transaction model
37
+ */
38
+ class PacNet_Raven_Model_MarketDirect_Transaction extends PacNet_Raven_Model_MarketDirect_Abstract
39
+ {
40
+ /**
41
+ * Raven post URI for payments
42
+ */
43
+ const RAVEN_PAYMENT_URI = 'https://raven.pacnetservices.com/payment';
44
+
45
+ /**
46
+ * Constructor
47
+ *
48
+ * @param Mage_Sales_Model_Order $order
49
+ */
50
+ public function __construct(Mage_Sales_Model_Order $order)
51
+ {
52
+ $this->setOrder($order);
53
+ }
54
+
55
+ /**
56
+ * Sets an order
57
+ *
58
+ * @param Mage_Sales_Model_Order $order
59
+ *
60
+ * @return $this
61
+ */
62
+ public function setOrder(Mage_Sales_Model_Order $order)
63
+ {
64
+ parent::setOrder($order);
65
+ $this->_exchangeOrderData($this->_order);
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * Exchange data from order to Raven MarketDirect transaction
71
+ */
72
+ protected function _exchangeOrderData()
73
+ {
74
+ $order = $this->_order;
75
+
76
+ $this->_getPaymentConfigData('active');
77
+ $this->_getPaymentConfigData('debug');
78
+
79
+ $this->setPaymentTitle($this->_getPaymentConfigData('title'))
80
+ ->setSubmitter($this->_getPaymentConfigData('submitter'))
81
+ ->setSharedSecret($this->_getPaymentConfigData('shared_secret'))
82
+ ->setRouting($this->_getPaymentConfigData('prn'))
83
+ ->setPaymentType($this->_getPaymentConfigData('payment_type'))
84
+ ->setEmailReceipt($this->_getPaymentConfigData('email_receipt') ? 'yes' : 'no')
85
+ ->setTitle($this->_getPaymentConfigData('custom_title'))
86
+ ->setColor($this->_getPaymentConfigData('custom_colour'))
87
+ ->setLogoPath(Mage::getBaseDir('media') . '/pacnet/' . $this->_getPaymentConfigData('custom_logo'))
88
+ ->setGoogleAnalytics($this->_getPaymentConfigData('custom_google_analytics'));
89
+
90
+ if ($this->_getPaymentConfigData('enable_fulfillment_notification')
91
+ && $this->_getPaymentConfigData('fulfillment_url')) {
92
+ $this->setFulFillmentUrl($this->_getPaymentConfigData('fulfillment_url'))
93
+ ->setRetryFulfillmentNotification($this->_getPaymentConfigData('retry_fulfillment_notification'));
94
+ }
95
+
96
+ if ($order) {
97
+ if ($this->canUseOrderCurrency()) {
98
+ $this->setAmount($this->_formatAmount($order->getGrandTotal()))
99
+ ->setCurrency($order->getOrderCurrencyCode());
100
+ } else {
101
+ $this->setAmount($this->_formatAmount($order->getBaseGrandTotal()))
102
+ ->setCurrency($order->getBaseCurrencyCode());
103
+ }
104
+
105
+ $this->setReference2($order->getIncrementId())
106
+ ->setReference3($this->_getPaymentConfigData('payment_type'))
107
+ ->setContactEmail($order->getCustomerEmail())
108
+ ->setIpaddress($order->getRemoteIp());
109
+
110
+ if ($billing = $order->getBillingAddress()) {
111
+ $this->setBillingName($billing->getFirstname() . ' ' . $billing->getLastname())
112
+ ->setBillingAddress1($billing->getStreet(1))
113
+ ->setBillingAddress2($billing->getStreet(2))
114
+ ->setBillingCity($billing->getCity())
115
+ ->setBillingState($billing->getRegion() ? $billing->getRegion() : $billing->getCity())
116
+ ->setBillingPostal($billing->getPostcode())
117
+ ->setBillingCountry($billing->getCountry())
118
+ ->setBillingPhone($billing->getTelephone())
119
+ ->setBillingFax($billing->getFax());
120
+ }
121
+
122
+ if ($shipping = $order->getShippingAddress()) {
123
+ $this->setShippingName($shipping->getFirstname() . ' ' . $shipping->getLastname())
124
+ ->setShippingCompany($shipping->getCompany())
125
+ ->setShippingAddress1($shipping->getStreet(1))
126
+ ->setShippingAddress2($shipping->getStreet(2))
127
+ ->setShippingCity($shipping->getCity())
128
+ ->setShippingState($shipping->getRegion() ? $shipping->getRegion() : $shipping->getCity())
129
+ ->setShippingPostal($shipping->getPostcode())
130
+ ->setShippingCountry($shipping->getCountry());
131
+ }
132
+
133
+ $count = 0;
134
+ /** @var Mage_Sales_Model_Order_Item $item */
135
+ foreach ($order->getAllVisibleItems() as $item) {
136
+ $count++;
137
+ $this->setData('detail_item_' . $count, $item->getName())
138
+ ->setData('detail_cost_' . $count, $this->_formatAmount($item->getPriceInclTax()))
139
+ ->setData('detail_qty_'. $count, $item->getQtyOrdered());
140
+ }
141
+ }
142
+
143
+ // other settings
144
+ $this->addData(array(
145
+ 'collect_shipping' => 'Display',
146
+ 'collect_billing' => 'Display',
147
+ 'collect_email' => 'Display',
148
+ 'language' => $this->_getMageLanguage(),
149
+ 'result_url' => Mage::getUrl('pacnet-raven/marketdirect/response', array('_secure' => true))
150
+ ));
151
+ }
152
+
153
+ /**
154
+ * Gets langauge from Mage locale
155
+ *
156
+ * @return mixed
157
+ */
158
+ protected function _getMageLanguage() {
159
+ $locale = Mage::app()->getLocale()->getLocaleCode();
160
+ $localeParts = explode('_', $locale);
161
+ return $localeParts[0];
162
+ }
163
+
164
+ /**
165
+ * Convert object data to array
166
+ *
167
+ * @param array $arrAttributes
168
+ *
169
+ * @return array
170
+ */
171
+ public function toArray( array $arrAttributes = array() )
172
+ {
173
+ $data = parent::toArray( $arrAttributes );
174
+
175
+ $newData = array();
176
+
177
+ foreach ($data as $key => $value) {
178
+ if (!$value) continue;
179
+ if ('payment_title' == $value) continue;
180
+ $newKey = substr( $key, 0, 3 ) === 'md_' ? $key : 'md_' . $key;
181
+ $newData[$newKey] = $value;
182
+ }
183
+
184
+ return $newData;
185
+ }
186
+
187
+ /**
188
+ * Generate inputs for submission
189
+ *
190
+ * @param array|null $data
191
+ */
192
+ public function generateInputs(array $data=null)
193
+ {
194
+ if (!$data) {
195
+ $data = $this->toArray();
196
+ }
197
+
198
+ $container = array();
199
+ foreach ($data as $key => $value) {
200
+ $container[ltrim($key,"*")] = $value;
201
+ }
202
+ if (empty($container['md_timestamp'])) {
203
+ $container['md_timestamp'] = $this->_generateTimestamp();
204
+ }
205
+ if (empty($container['md_reference'])) {
206
+ $container['md_reference'] = $this->_generateReference();
207
+ }
208
+ if (empty($container['md_signature'])) {
209
+ $container['md_signature'] = $this->_generateSignature($container);
210
+ }
211
+
212
+ if (!empty($container['md_logo_path'])) {
213
+ $imgData = $this->_readImage( $container['md_logo_path']);
214
+ if ($imgData != null) {
215
+ $container['md_logo_image'] = $imgData;
216
+ }
217
+ unset($container['md_logo_path']);
218
+ }
219
+ unset($container['md_shared_secret']);
220
+
221
+ if ($this->_getPaymentConfigData('debug')) {
222
+ Mage::log('Raven MarketDirect request data: ' . print_r($container, true) , null, $this->_logFile);
223
+ }
224
+
225
+ $formFields = '';
226
+ while (list($key, $val) = each($container)) {
227
+ $formFields .= "<input type=\"hidden\" name=\"$key\" value=\"$val\"/>\r\n";
228
+ }
229
+ return $formFields;
230
+ }
231
+
232
+ /**
233
+ * Generates a payment timestamp
234
+ *
235
+ * @return string
236
+ */
237
+ private function _generateTimestamp ()
238
+ {
239
+ return gmdate('Y-m-d\TH:i:s\Z');
240
+ }
241
+
242
+ /**
243
+ * Generates a payment reference
244
+ *
245
+ * @return string
246
+ */
247
+ private function _generateReference()
248
+ {
249
+ return md5(uniqid(rand(),true));
250
+ }
251
+
252
+ /**
253
+ * Generates a payment signature
254
+ *
255
+ * @param $data
256
+ *
257
+ * @return string
258
+ */
259
+ private function _generateSignature($data)
260
+ {
261
+ $first = $data['md_submitter'] . ',' . $data['md_timestamp'] . ','
262
+ . $data['md_amount'] . ',' . $data['md_currency'] . ',' . $data['md_reference'];
263
+ $second = strtoupper(md5($first));
264
+ $third = $second . ',' . $data['md_shared_secret'];
265
+ $final = strtoupper(md5($third));
266
+ return $final;
267
+ }
268
+
269
+ /**
270
+ * Converts image file to Raven compatible image data
271
+ *
272
+ * Data is used to populate the md_logo_image field
273
+ *
274
+ * @param $file
275
+ *
276
+ * @return null|string
277
+ */
278
+ private function _readImage($file)
279
+ {
280
+ if(!file_exists($file)) return null;
281
+ $mime = $this->_getMIME( $file);
282
+ if($mime == null) return null;
283
+ $data = base64_encode(file_get_contents($file));
284
+ return $mime . "," . $data;
285
+ }
286
+
287
+ /**
288
+ * Gets the MIME type of an image
289
+ *
290
+ * @param $filename
291
+ *
292
+ * @return null|string
293
+ */
294
+ private function _getMIME($filename)
295
+ {
296
+ preg_match("|\.([a-z0-9]{2,4})$|i",$filename,$fileSuffix);
297
+ switch(strtolower($fileSuffix[1])) {
298
+ case "jpg" :
299
+ case "jpeg" :
300
+ case "jpe" :
301
+ return "image/jpg";
302
+ case "png" :
303
+ case "gif" :
304
+ return "image/".strtolower($fileSuffix[1]);
305
+ default :
306
+ return null;
307
+ }
308
+ }
309
+ }
app/code/community/PacNet/Raven/controllers/MarketdirectController.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Raven MarketDirect controller
37
+ */
38
+ class PacNet_Raven_MarketdirectController extends Mage_Core_Controller_Front_Action
39
+ {
40
+ /**
41
+ * Current Magento order
42
+ *
43
+ * @var Mage_Sales_Model_Order
44
+ */
45
+ protected $_currentOrder;
46
+
47
+ /**
48
+ * Payment gateway response action
49
+ *
50
+ * @return $this
51
+ */
52
+ public function redirectAction()
53
+ {
54
+ if (!$order = $this->_getCurrentOrder()) {
55
+ $this->_redirect('checkout/cart');
56
+ } else {
57
+ /** @var PacNet_Raven_Model_MarketDirect_Transaction $transaction */
58
+ $transaction = Mage::getModel('pacnet_raven/MarketDirect_Transaction', $order);
59
+
60
+ $this->loadLayout();
61
+ /** @var Mage_Core_Block_Template $block */
62
+ $block = $this->getLayout()->createBlock(
63
+ 'Mage_Core_Block_Template',
64
+ 'pacnet_raven_marketdirect_form',
65
+ array(
66
+ 'template' => 'pacnet/raven/marketdirect/redirect.phtml',
67
+ 'raven_transaction' => $transaction,
68
+ 'form_data' => $transaction->generateInputs()
69
+ )
70
+ )->setCacheLifetime(null);
71
+ $this->getLayout()->getBlock('content')->append($block);
72
+ $this->renderLayout();
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Payment gateway response action
78
+ *
79
+ * @throws Exception
80
+ */
81
+ public function responseAction()
82
+ {
83
+ $request = $this->getRequest();
84
+
85
+ if($request->isPost()) {
86
+ $paymentResponse = $request->getPost();
87
+ $marketDirectResponse = Mage::getModel('pacnet_raven/MarketDirect_Response', $paymentResponse);
88
+
89
+ try {
90
+ if ($marketDirectResponse->isValid()) {
91
+ if ($marketDirectResponse->isApproved()) {
92
+ $payment = $marketDirectResponse->getOrder()->getPayment();
93
+ $payment->setTransactionId($marketDirectResponse->getData('md_reference'))
94
+ ->setCurrencyCode($marketDirectResponse->getData('md_currency'))
95
+ ->setParentTransactionId($marketDirectResponse->getData('md_reference'))
96
+ ->setCcType($marketDirectResponse->getCcType());
97
+
98
+ switch ($marketDirectResponse->getPaymentType()) {
99
+ case 'debit':
100
+ $payment
101
+ //->setPreparedMessage('This message is prepended to the captured amount')
102
+ ->setShouldCloseParentTransaction(true)
103
+ ->setIsTransactionClosed(1)
104
+ ->registerCaptureNotification($marketDirectResponse->getAmountPaid());
105
+ break;
106
+
107
+ case 'preauth':
108
+ $payment
109
+ //->setPreparedMessage('This message is prepended to the captured amount')
110
+ ->setShouldCloseParentTransaction(true)
111
+ ->setIsTransactionClosed(0)
112
+ ->registerAuthorizationNotification($marketDirectResponse->getAmountPaid());
113
+ break;
114
+ }
115
+
116
+ $marketDirectResponse->getOrder()
117
+ ->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Raven MarketDirect has authorized the payment.')
118
+ ->sendNewOrderEmail()
119
+ ->setEmailSent(true)
120
+ ->save();
121
+
122
+ Mage::getSingleton( 'checkout/session' )->unsQuoteId();
123
+ Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure' => true));
124
+ } else {
125
+ $this->cancelAction();
126
+ Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true));
127
+ }
128
+ }
129
+ } catch (Exception $e) {
130
+ Mage::logException($e);
131
+ $this->_redirect('/');
132
+ }
133
+ }
134
+ else
135
+ $this->_redirect('/');
136
+ }
137
+
138
+ /**
139
+ * Payment cancelled action
140
+ *
141
+ * @throws Exception
142
+ */
143
+ public function cancelAction() {
144
+ if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
145
+ $order = $this->_getCurrentOrder();
146
+ if($order->getId()) {
147
+ $order->cancel()->setState(
148
+ Mage_Sales_Model_Order::STATE_CANCELED,
149
+ true,
150
+ 'Gateway has declined the payment.'
151
+ )->save();
152
+ }
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Gets current order
158
+ *
159
+ * @param $orderIncrementId
160
+ *
161
+ * @return Mage_Sales_Model_Order
162
+ */
163
+ protected function _getCurrentOrder($orderIncrementId=null)
164
+ {
165
+ if (null == $this->_currentOrder) {
166
+ $orderIncrementId = $orderIncrementId
167
+ ? $orderIncrementId
168
+ : Mage::getSingleton('checkout/session')->getLastRealOrderId();
169
+
170
+ $this->_currentOrder = $orderIncrementId
171
+ ? Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId)
172
+ : null;
173
+ }
174
+
175
+ return $this->_currentOrder;
176
+ }
177
+ }
app/code/community/PacNet/Raven/etc/config.xml ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PacNet's Raven Payment Gateway
5
+ *
6
+ * MIT License
7
+ *
8
+ * Copyright (c) 2016, PacNet Services Ltd
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ * of this software and associated documentation files (the "Software"), to deal
12
+ * in the Software without restriction, including without limitation the rights
13
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ * copies of the Software, and to permit persons to whom the Software is
15
+ * furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all
18
+ * copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ * SOFTWARE.
27
+ *
28
+ * @category PacNet
29
+ * @package PacNet_Raven
30
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
31
+ * @link https://pacnetservices.com/
32
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
33
+ * @license https://opensource.org/licenses/MIT MIT License
34
+ */
35
+ -->
36
+ <config>
37
+ <modules>
38
+ <PacNet_Raven>
39
+ <version>1.0.0</version>
40
+ </PacNet_Raven>
41
+ </modules>
42
+ <global>
43
+ <models>
44
+ <pacnet_raven>
45
+ <class>PacNet_Raven_Model</class>
46
+ </pacnet_raven>
47
+ </models>
48
+ <blocks>
49
+ <pacnet_raven>
50
+ <class>PacNet_Raven_Block</class>
51
+ </pacnet_raven>
52
+ </blocks>
53
+ <helpers>
54
+ <pacnet_raven>
55
+ <class>PacNet_Raven_Helper</class>
56
+ </pacnet_raven>
57
+ </helpers>
58
+ </global>
59
+ <default>
60
+ <payment>
61
+ <pacnet_raven_marketdirect>
62
+ <model>pacnet_raven/MarketDirect</model>
63
+ <active>0</active>
64
+ <debug>0</debug>
65
+ <title>Credit Card (Raven MarketDirect)</title>
66
+ <order_status>pending</order_status>
67
+ <payment_type>sale</payment_type>
68
+ <submitter></submitter>
69
+ <shared_secret></shared_secret>
70
+ <prn></prn>
71
+ <email_receipt>0</email_receipt>
72
+ <custom_title></custom_title>
73
+ <custom_colour>#206D82</custom_colour>
74
+ <custom_logo></custom_logo>
75
+ <custom_google_analytics></custom_google_analytics>
76
+ <enable_fulfillment_notification>0</enable_fulfillment_notification>
77
+ <fulfillment_url></fulfillment_url>
78
+ <retry_fulfillment_notification>0</retry_fulfillment_notification>
79
+ <allowspecific>0</allowspecific>
80
+ <sort_order>100</sort_order>
81
+ </pacnet_raven_marketdirect>
82
+ <pacnet_raven_api>
83
+ <model>pacnet_raven/Api</model>
84
+ <active>0</active>
85
+ <debug>0</debug>
86
+ <order_status>pending</order_status>
87
+ <title>Credit Card (Raven API)</title>
88
+ <cctypes>AE,VI,MC,DI</cctypes>
89
+ <payment_action>authorize_capture</payment_action>
90
+ <allowspecific>0</allowspecific>
91
+ </pacnet_raven_api>
92
+ </payment>
93
+ </default>
94
+ <frontend>
95
+ <routers>
96
+ <pacnet_raven>
97
+ <use>standard</use>
98
+ <args>
99
+ <module>PacNet_Raven</module>
100
+ <frontName>pacnet-raven</frontName>
101
+ </args>
102
+ </pacnet_raven>
103
+ </routers>
104
+ <layout>
105
+ <updates>
106
+ <pacnet_raven>
107
+ <file>pacnet/raven/marketdirect.xml</file>
108
+ </pacnet_raven>
109
+ </updates>
110
+ </layout>
111
+ </frontend>
112
+ </config>
app/code/community/PacNet/Raven/etc/system.xml ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PacNet's Raven Payment Gateway
5
+ *
6
+ * MIT License
7
+ *
8
+ * Copyright (c) 2016, PacNet Services Ltd
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ * of this software and associated documentation files (the "Software"), to deal
12
+ * in the Software without restriction, including without limitation the rights
13
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ * copies of the Software, and to permit persons to whom the Software is
15
+ * furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all
18
+ * copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ * SOFTWARE.
27
+ *
28
+ * @category PacNet
29
+ * @package PacNet_Raven
30
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
31
+ * @link https://pacnetservices.com/
32
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
33
+ * @license https://opensource.org/licenses/MIT MIT License
34
+ */
35
+ -->
36
+ <config>
37
+ <sections>
38
+ <payment>
39
+ <groups>
40
+ <pacnet_raven_marketdirect translate="label comment" module="pacnet_raven">
41
+ <label>Raven MarketDirect</label>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>100</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <fields>
48
+ <active translate="label">
49
+ <label>Enabled</label>
50
+ <frontend_type>select</frontend_type>
51
+ <source_model>adminhtml/system_config_source_yesno</source_model>
52
+ <sort_order>1</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ </active>
57
+ <debug translate="label">
58
+ <label>Debug</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>2</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>0</show_in_store>
65
+ </debug>
66
+ <title translate="label">
67
+ <label>Title</label>
68
+ <frontend_type>text</frontend_type>
69
+ <sort_order>3</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </title>
74
+ <order_status translate="label">
75
+ <label>New Order Status</label>
76
+ <frontend_type>select</frontend_type>
77
+ <source_model>adminhtml/system_config_source_order_status</source_model>
78
+ <sort_order>4</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ </order_status>
83
+ <payment_type>
84
+ <label>Payment Type</label>
85
+ <frontend_type>select</frontend_type>
86
+ <source_model>pacnet_raven/MarketDirect_Source_PaymentType</source_model>
87
+ <sort_order>5</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ </payment_type>
92
+ <submitter translate="label">
93
+ <label>Submitter ID</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>6</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>0</show_in_store>
99
+ </submitter>
100
+ <shared_secret translate="label">
101
+ <label>Shared Secret</label>
102
+ <frontend_type>text</frontend_type>
103
+ <sort_order>7</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>0</show_in_store>
107
+ </shared_secret>
108
+ <prn translate="label">
109
+ <label>Payment Routing Number (PRN)</label>
110
+ <frontend_type>text</frontend_type>
111
+ <sort_order>8</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>0</show_in_store>
115
+ </prn>
116
+ <email_receipt>
117
+ <label>Email Receipt</label>
118
+ <frontend_type>select</frontend_type>
119
+ <source_model>adminhtml/system_config_source_yesno</source_model>
120
+ <sort_order>9</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ <show_in_store>0</show_in_store>
124
+ </email_receipt>
125
+ <custom_title translate="label">
126
+ <label>HPP Title</label>
127
+ <frontend_type>text</frontend_type>
128
+ <sort_order>10</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>1</show_in_store>
132
+ </custom_title>
133
+ <custom_colour translate="label">
134
+ <label>HPP Colour</label>
135
+ <frontend_type>text</frontend_type>
136
+ <sort_order>11</sort_order>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>1</show_in_store>
140
+ </custom_colour>
141
+ <custom_logo translate="label">
142
+ <label>HPP Logo</label>
143
+ <frontend_type>image</frontend_type>
144
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
145
+ <upload_dir config="system/filesystem/media" scope_info="1">pacnet</upload_dir>
146
+ <base_url type="media" scope_info="1">pacnet</base_url>
147
+ <comment>Allowed types: jpg, jpeg, gif, png (150px x 100px)</comment>
148
+ <sort_order>12</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>1</show_in_store>
152
+ </custom_logo>
153
+ <custom_google_analytics>
154
+ <label>HPP Google Analytics A/C No</label>
155
+ <frontend_type>text</frontend_type>
156
+ <sort_order>13</sort_order>
157
+ <show_in_default>1</show_in_default>
158
+ <show_in_website>1</show_in_website>
159
+ <show_in_store>1</show_in_store>
160
+ </custom_google_analytics>
161
+ <enable_fulfillment_notification>
162
+ <label>Enable Fulfillment Notification</label>
163
+ <frontend_type>select</frontend_type>
164
+ <source_model>adminhtml/system_config_source_yesno</source_model>
165
+ <sort_order>14</sort_order>
166
+ <show_in_default>1</show_in_default>
167
+ <show_in_website>1</show_in_website>
168
+ <show_in_store>1</show_in_store>
169
+ </enable_fulfillment_notification>
170
+ <fulfillment_url>
171
+ <label>Fulfillment URL</label>
172
+ <frontend_type>text</frontend_type>
173
+ <sort_order>15</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ <depends><enable_fulfillment_notification>1</enable_fulfillment_notification></depends>
178
+ </fulfillment_url>
179
+ <retry_fulfillment_notification>
180
+ <label>Retry Filfillment Notification</label>
181
+ <frontend_type>select</frontend_type>
182
+ <source_model>adminhtml/system_config_source_yesno</source_model>
183
+ <sort_order>16</sort_order>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ <depends><enable_fulfillment_notification>1</enable_fulfillment_notification></depends>
188
+ </retry_fulfillment_notification>
189
+ <allowspecific translate="label">
190
+ <label>Payment Applicable From</label>
191
+ <frontend_type>select</frontend_type>
192
+ <sort_order>17</sort_order>
193
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
194
+ <show_in_default>1</show_in_default>
195
+ <show_in_website>1</show_in_website>
196
+ <show_in_store>0</show_in_store>
197
+ </allowspecific>
198
+ <specificcountry translate="label">
199
+ <label>Countries Payment Applicable From</label>
200
+ <frontend_type>multiselect</frontend_type>
201
+ <sort_order>18</sort_order>
202
+ <source_model>adminhtml/system_config_source_country</source_model>
203
+ <show_in_default>1</show_in_default>
204
+ <show_in_website>1</show_in_website>
205
+ <show_in_store>0</show_in_store>
206
+ <depends><allowspecific>1</allowspecific></depends>
207
+ </specificcountry>
208
+ <sort_order translate="label">
209
+ <label>Sort Order</label>
210
+ <frontend_type>text</frontend_type>
211
+ </sort_order>
212
+ <sort_order>100</sort_order>
213
+ <show_in_default>1</show_in_default>
214
+ <show_in_website>1</show_in_website>
215
+ <show_in_store>0</show_in_store>
216
+ </fields>
217
+ </pacnet_raven_marketdirect>
218
+ <pacnet_raven_api translate="label" module="pacnet_raven">
219
+ <label>Raven API</label>
220
+ <sort_order>101</sort_order>
221
+ <show_in_default>1</show_in_default>
222
+ <show_in_website>1</show_in_website>
223
+ <show_in_store>0</show_in_store>
224
+ <fields>
225
+ <active translate="label">
226
+ <label>Enabled</label>
227
+ <frontend_type>select</frontend_type>
228
+ <source_model>adminhtml/system_config_source_yesno</source_model>
229
+ <sort_order>1</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>0</show_in_store>
233
+ </active>
234
+ <debug translate="label">
235
+ <label>Debug</label>
236
+ <frontend_type>select</frontend_type>
237
+ <source_model>adminhtml/system_config_source_yesno</source_model>
238
+ <sort_order>2</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>1</show_in_website>
241
+ <show_in_store>0</show_in_store>
242
+ </debug>
243
+ <title translate="label">
244
+ <label>Title</label>
245
+ <frontend_type>text</frontend_type>
246
+ <sort_order>3</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>0</show_in_store>
250
+ </title>
251
+ <order_status translate="label">
252
+ <label>New order status</label>
253
+ <frontend_type>select</frontend_type>
254
+ <source_model>adminhtml/system_config_source_order_status</source_model>
255
+ <sort_order>5</sort_order>
256
+ <show_in_default>1</show_in_default>
257
+ <show_in_website>1</show_in_website>
258
+ <show_in_store>0</show_in_store>
259
+ </order_status>
260
+ <username translate="label">
261
+ <label>Username</label>
262
+ <frontend_type>text</frontend_type>
263
+ <sort_order>6</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <show_in_store>0</show_in_store>
267
+ </username>
268
+ <shared_secret translate="label">
269
+ <label>Shared Secret</label>
270
+ <frontend_type>text</frontend_type>
271
+ <sort_order>7</sort_order>
272
+ <show_in_default>1</show_in_default>
273
+ <show_in_website>1</show_in_website>
274
+ <show_in_store>0</show_in_store>
275
+ </shared_secret>
276
+ <prn translate="label">
277
+ <label>Payment Routing Number (PRN)</label>
278
+ <frontend_type>text</frontend_type>
279
+ <sort_order>8</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>1</show_in_website>
282
+ <show_in_store>0</show_in_store>
283
+ </prn>
284
+ <cctypes translate="label">
285
+ <label>Credit Card Types</label>
286
+ <frontend_type>multiselect</frontend_type>
287
+ <source_model>adminhtml/system_config_source_payment_cctype</source_model>
288
+ <sort_order>9</sort_order>
289
+ <show_in_default>1</show_in_default>
290
+ <show_in_website>1</show_in_website>
291
+ <show_in_store>0</show_in_store>
292
+ </cctypes>
293
+ <payment_action>
294
+ <label>Payment Action</label>
295
+ <frontend_type>select</frontend_type>
296
+ <source_model>pacnet_raven/Api_Source_Paymentaction</source_model>
297
+ <sort_order>10</sort_order>
298
+ <show_in_default>1</show_in_default>
299
+ <show_in_website>1</show_in_website>
300
+ <show_in_store>0</show_in_store>
301
+ </payment_action>
302
+ </fields>
303
+ </pacnet_raven_api>
304
+ </groups>
305
+ </payment>
306
+ </sections>
307
+ </config>
app/design/adminhtml/default/default/template/pacnet/raven/marketdirect/info.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Template for displaying payment information in the admin order
37
+ *
38
+ * @see PacNet_Raven_Block_MarketDirect_Info
39
+ */
40
+ ?>
41
+ <?php
42
+ echo $this->getMethod()->getTitle() . '<br/>';
43
+ if ($this->getInfo()->getLastTransId() == '') {
44
+ echo Mage::helper('pacnet_raven')->__('Payment has not been processed yet.') . '<br/>';
45
+ } else {
46
+ echo Mage::helper('pacnet_raven')->__('Credit Card Type: %s', $this->htmlEscape($this->getInfo()->getCcType())) . '<br/>';
47
+ echo Mage::helper('pacnet_raven')->__('Raven Transaction ID: %s', $this->htmlEscape($this->getInfo()->getLastTransId())) . '<br/>';
48
+ }
app/design/adminhtml/default/default/template/pacnet/raven/marketdirect/pdf/info.phtml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Template for displaying payment information on the invoice PDF
37
+ *
38
+ * @see PacNet_Raven_Block_MarketDirect_Info
39
+ */
40
+ ?>
41
+
42
+ <?php
43
+ echo $this->getMethod()->getTitle();
app/design/frontend/base/default/layout/pacnet/raven/marketdirect.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * PacNet's Raven Payment Gateway
5
+ *
6
+ * MIT License
7
+ *
8
+ * Copyright (c) 2016, PacNet Services Ltd
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ * of this software and associated documentation files (the "Software"), to deal
12
+ * in the Software without restriction, including without limitation the rights
13
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ * copies of the Software, and to permit persons to whom the Software is
15
+ * furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all
18
+ * copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ * SOFTWARE.
27
+ *
28
+ * @category PacNet
29
+ * @package PacNet_Raven
30
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
31
+ * @link https://pacnetservices.com/
32
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
33
+ * @license https://opensource.org/licenses/MIT MIT License
34
+ */
35
+ -->
36
+ <layout version="0.1.0">
37
+ <pacnet_raven_marketdirect_redirect translate="label">
38
+ <label>PacNet Raven MarketDirect Redirect Page</label>
39
+ <reference name="root">
40
+ <action method="setTemplate">
41
+ <template>page/1column.phtml</template>
42
+ </action>
43
+ </reference>
44
+ </pacnet_raven_marketdirect_redirect>
45
+ </layout>
app/design/frontend/base/default/template/pacnet/raven/marketdirect/form.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Template for displaying payment method form on store front checkout
37
+ * @see PacNet_Raven_Block_MarketDirect_Form
38
+ */
39
+ ?>
40
+ <fieldset class="form-list">
41
+ <?php $_code=$this->getMethodCode() ?>
42
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
43
+ <li>
44
+ <?php echo Mage::helper('pacnet_raven')->__('You will be redirected to Raven MarketDirect payments when you place an order.') ?>
45
+ </li>
46
+ </ul>
47
+ </fieldset>
app/design/frontend/base/default/template/pacnet/raven/marketdirect/redirect.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PacNet's Raven Payment Gateway
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2016, PacNet Services Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ *
27
+ * @category PacNet
28
+ * @package PacNet_Raven
29
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
30
+ * @link https://pacnetservices.com/
31
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
32
+ * @license https://opensource.org/licenses/MIT MIT License
33
+ */
34
+
35
+ /**
36
+ * Template displays the Raven MarkDirect form and redirect
37
+ * @see PacNet_Raven_MarketdirectController::redirectAction()
38
+ */
39
+ ?>
40
+ <div align="center">
41
+ <h1><?php echo Mage::helper('pacnet_raven')->__('Payment with') . ' ' . $this->raven_transaction->getPaymentTitle() ?></h1>
42
+ <p><img src='<?php echo $this->getSkinUrl('pacnet/images/ajax-loader.gif') ?>' /></p>
43
+ <p><?php echo Mage::helper('pacnet_raven')->__('Proceeding to payment...') ?></p>
44
+ <p><small><?php echo Mage::helper('pacnet_raven')->__('You are now entering a secure payment portal with Raven MarketDirect. If you are not automatically redirected within 5 seconds please...') ?></small></p>
45
+ <br />
46
+ <form action="<?php echo PacNet_Raven_Model_MarketDirect_Transaction::RAVEN_PAYMENT_URI ?>"
47
+ method="post" name="raven_marketdirect_form" id="raven_marketdirect_form">
48
+ <?php echo $this->form_data ?>
49
+ <p><input type="submit" name="submit" id="raven_marketdirect_form_submit" class="button" value="<?php echo Mage::helper('pacnet_raven')->__('Click here to Pay Now') ?>" /></p>
50
+ </form>
51
+ </div>
52
+ <script>
53
+ jQuery(function () {
54
+ jQuery('#raven_marketdirect_form_submit').click();
55
+ });
56
+ </script>
app/etc/modules/PacNet_Raven.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PacNet's Raven Payment Gateway
5
+ *
6
+ * MIT License
7
+ *
8
+ * Copyright (c) 2016, PacNet Services Ltd
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ * of this software and associated documentation files (the "Software"), to deal
12
+ * in the Software without restriction, including without limitation the rights
13
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ * copies of the Software, and to permit persons to whom the Software is
15
+ * furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all
18
+ * copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ * SOFTWARE.
27
+ *
28
+ * @category PacNet
29
+ * @package PacNet_Raven
30
+ * @author Joerg Beekmann <joerg@deepcovelabs.com>
31
+ * @link https://pacnetservices.com/
32
+ * @copyright Copyright (c) 2016, PacNet Services Ltd
33
+ * @license https://opensource.org/licenses/MIT MIT License
34
+ */
35
+ -->
36
+ <config>
37
+ <modules>
38
+ <PacNet_Raven>
39
+ <active>true</active>
40
+ <codePool>community</codePool>
41
+ </PacNet_Raven>
42
+ </modules>
43
+ </config>
package.xml CHANGED
@@ -1,43 +1,46 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>pacnet_raven</name>
4
- <version>0.1.0</version>
5
  <stability>stable</stability>
6
- <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License v. 3.0 (OSL-3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>If you have a PacNet merchant account, this Magento extension will allow you to securely accept card payments through your Magento e-commerce site. </summary>
10
- <description>Features:&#xD;
11
- &#xD;
12
- &#x2022; Accept any Visa or MasterCard branded or co-branded card payment. &#xD;
13
- &#x2022; Set prices in the local currency of your customers. Customers see your merchant descriptor and the exact amount that they agreed to pay with no currency conversion on their card statement. &#xD;
14
- &#x2022; No matter what currencies you accept from customers, you enjoy fast access to funds in a major currency of your choice.&#xD;
15
- &#x2022; Debit, Pre-authorize and Refund transactions supported. Further transaction types available in Raven Online. &#xD;
16
- &#x2022; Payment Reporting and Management available through Raven Online &#xD;
17
- &#x2022; Card Data Tokenization allows for secure processing of refunds or further customer transactions using Raven Online&#xD;
18
- &#x2022; Risk-flagging and management available through your PacNet account administration. Contact Client Services for implementation. &#xD;
19
- &#x2022; Level 1 PCI compliant &#xD;
20
- &#xD;
21
- Accepting cards using this extension requires a PacNet merchant account. Want to process debit and credit cards from around the world, but don&#x2019;t yet have an account with PacNet? &#xD;
22
- &#xD;
23
- Please visit us at www.pacnetservices.com for more details. &#xD;
24
- &#xD;
25
- Please have your PacNet UserName, Shared Secret, and Payment Routing Number ready to complete the setup. &#xD;
26
- &#xD;
27
- Your PacNet Client Service Representative will be happy confirm the above details if required. &#xD;
28
- &#xD;
29
- North America +1 604 689 0399 / clientsupport@pacnetservices.com&#xD;
30
- &#xD;
31
- Europe: +353 61 714 360 / shannon.clientsupport@pacnetservices.com&#xD;
32
- </description>
33
- <notes>Version number: 0.1.0&#xD;
34
- Stability: Stable&#xD;
35
- &#xD;
36
- </notes>
37
- <authors><author><name>Christine K </name><user>PacN3t</user><email>christinek@pacnetservices.com</email></author></authors>
38
- <date>2015-08-13</date>
39
- <time>19:27:14</time>
40
- <contents><target name="magecommunity"><dir name="."><dir name="app"><dir name="code"><file name="community" hash=""/></dir></dir></dir></target><target name="magedesign"><dir name="."><dir name="app"><file name="design" hash=""/></dir></dir></target><target name="magelib"><dir name="."><file name="lib" hash=""/></dir></target><target name="magemedia"><dir name="."><file name="media" hash=""/></dir></target><target name="mageweb"><dir name="."><file name="." hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></target><target name="mage"><dir name="."><file name="." hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></target></contents>
 
 
 
41
  <compatible/>
42
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>pacnet_raven</name><channel>community</channel><min>1.5.0</min><max>1.9.0</max></package></required></dependencies>
43
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>pacnet_raven</name>
4
+ <version>1.0.0</version>
5
  <stability>stable</stability>
6
+ <license uri="https://opensource.org/licenses/MIT">MIT License (MIT)</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>PacNet's Raven Payment Gateway extension integrates Raven API and/or&#xD;
10
+ MarketDirect payments to your Magento store.</summary>
11
+ <description>PCI DSS compliance is NOT required when using Raven MarketDirect as the&#xD;
12
+ payment will be captured and processed on the PacNet secure payment portal.&#xD;
13
+ If you are using Raven API, PCI DSS compliance is mandatory to ensure the&#xD;
14
+ security and privacy of your customer's transactions.&#xD;
15
+ &#xD;
16
+ == API features ==&#xD;
17
+ - Debit (preauthorise and capture) payment type only&#xD;
18
+ - Debug mode&#xD;
19
+ &#xD;
20
+ == MarketDirect features ==&#xD;
21
+ - Debit and preauthorise payment types&#xD;
22
+ - Email a Raven payment receipt to the customer&#xD;
23
+ - Hosted payment page customisation&#xD;
24
+ - Google Analytics compatibility&#xD;
25
+ - Fulfillment notifications&#xD;
26
+ - Debug mode&#xD;
27
+ &#xD;
28
+ == Getting Started ==&#xD;
29
+ Before you start you will require the following Raven credentials:&#xD;
30
+ - Username/Submitted ID&#xD;
31
+ - Shared Secret&#xD;
32
+ - Payment routing Number (PRN)&#xD;
33
+ &#xD;
34
+ == Reference ==&#xD;
35
+ Raven Documentation: https://pacnetservices.com/documentation</description>
36
+ <notes>## [1.0.0] - 2016-03-27&#xD;
37
+ ### Initial Release&#xD;
38
+ - Raven MarketDirect payments&#xD;
39
+ - Merged Raven API payments</notes>
40
+ <authors><author><name>Joerg Beekmann</name><user>PacN3t</user><email>christinek@pacnetservices.com</email></author></authors>
41
+ <date>2016-04-29</date>
42
+ <time>17:37:14</time>
43
+ <contents><target name="magecommunity"><dir name="PacNet"><dir name="Raven"><dir name="Block"><dir name="MarketDirect"><file name="Form.php" hash="81c8fb9acda4e63bd5a2be1446f4faef"/><file name="Info.php" hash="85546f1f005e91bcd82312ee8e19fc1d"/></dir></dir><file name="Exception.php" hash="1f2b1c9a471ca584ef53616d7effa2fd"/><dir name="Helper"><file name="Data.php" hash="744aaafe84165b840e7672bccb2a5869"/></dir><dir name="Model"><dir name="Api"><dir name="Service"><dir name="Request"><file name="Abstract.php" hash="0fbd81ae4098922e2a322ea34e654be9"/><file name="Exception.php" hash="53888eafadceafe4fd78dc4d8feed5cf"/><file name="Hello.php" hash="8d3510efc32a10fabefae86c4688b62e"/><file name="Response.php" hash="e4c1c71c3cbcb399d5cb7f4866778e9d"/><file name="Submit.php" hash="d531f90a7b2d4d96968f8c2257d3713e"/></dir><dir name="Response"><dir name="Codes"><file name="CVV2.php" hash="fdd42b390e7f9be7bd00575f555b2eae"/><file name="Status.php" hash="a3dde758331bd59ab2c2bb3f7e55f5c6"/></dir><file name="Exception.php" hash="0dd0b17cf0f792a376eb67b219eba28d"/></dir><file name="Response.php" hash="0e81ca74231e438bc6eeb3f177a2a637"/></dir><file name="Service.php" hash="42865ecc90b97193238721537aa52f0c"/><dir name="Source"><file name="Paymentaction.php" hash="d287e9045482c542f36e19c1013eeb72"/></dir></dir><file name="Api.php" hash="3c4b9c4e92ba91c70d1868ff1d92883a"/><dir name="MarketDirect"><file name="Abstract.php" hash="ce4549825dcade10cc7a2589bb59f5c0"/><file name="Response.php" hash="f270410937acb6fd54ba17a4cec15ff4"/><dir name="Source"><file name="PaymentType.php" hash="0f945b717446c5d5b099a2dbc2df53be"/></dir><file name="Transaction.php" hash="07b78e678e753a3a0fbf4ebda05adf9c"/></dir><file name="MarketDirect.php" hash="470da58172d76c550c973cca7727178f"/></dir><dir name="controllers"><file name="MarketdirectController.php" hash="ddf05372520d4a8c349d4d7ddf08cf63"/></dir><dir name="etc"><file name="config.xml" hash="eb35a9b158b39d417b3680462cc530bf"/><file name="system.xml" hash="97b94c67e58d6ddfc1111393ec597d72"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="pacnet"><dir name="raven"><dir name="marketdirect"><file name="info.phtml" hash="dc5ad9843268f2af5370ef9dceb985f4"/><dir name="pdf"><file name="info.phtml" hash="27d2865889a3be0074d80d310e29799a"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="pacnet"><dir name="raven"><file name="marketdirect.xml" hash="527057af370e49fa25a7c1cde04be74e"/></dir></dir></dir><dir name="template"><dir name="pacnet"><dir name="raven"><dir name="marketdirect"><file name="form.phtml" hash="27a19d4b2b3bf12e560750768d1895fd"/><file name="redirect.phtml" hash="21da7f23c7b6e7e63f102335db2c2e10"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PacNet_Raven.xml" hash="e3909b1c66130c3db85996d17744b5da"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="pacnet"><dir name="images"><file name="ajax-loader.gif" hash="f48ee069890b16455c3ddcacee9b5f75"/></dir></dir></dir></dir></dir></target></contents>
44
  <compatible/>
45
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
46
  </package>
skin/frontend/base/default/pacnet/images/ajax-loader.gif ADDED
Binary file