Version Notes
Fixes and updates:
- Require eWAY customer account pages to use HTTPS if available
- Fix for PHP 5.3 compatibility issues
- Fix for issues with using alternate payment methods
- Fix the card selection dropdown appearing even if saved cards was disabled
Download this release
Release Info
Developer | eWAY Payments |
Extension | eWAY_Payment_Rapid31 |
Version | 1.4.1 |
Comparing to | |
See all releases |
Code changes from version 1.4.0 to 1.4.1
- app/code/community/Eway/Rapid31/Block/Adminhtml/Customer/Edit/Tab/Cards.php +57 -54
- app/code/community/Eway/Rapid31/Block/Adminhtml/Customer/Edit/Tab/Form.php +106 -105
- app/code/community/Eway/Rapid31/Block/Adminhtml/Customer/Method.php +33 -33
- app/code/community/Eway/Rapid31/Block/Adminhtml/Sales/Order/Grid.php +205 -187
- app/code/community/Eway/Rapid31/Block/Adminhtml/Sales/Order/Renderer/Items.php +18 -18
- app/code/community/Eway/Rapid31/Block/Customer/Edit.php +116 -117
- app/code/community/Eway/Rapid31/Block/Form/Direct/Ewayone.php +61 -57
- app/code/community/Eway/Rapid31/Block/Form/Direct/Saved.php +40 -40
- app/code/community/Eway/Rapid31/Block/Form/Sharedpage/Ewayone.php +57 -53
- app/code/community/Eway/Rapid31/Block/Form/Sharedpage/Notsaved.php +12 -12
- app/code/community/Eway/Rapid31/Block/Form/Sharedpage/Saved.php +34 -34
- app/code/community/Eway/Rapid31/Block/Form/Transparent/Ewayone.php +8 -4
- app/code/community/Eway/Rapid31/Block/Html/Head.php +2 -1
- app/code/community/Eway/Rapid31/Block/Info/Direct/Ewayone.php +44 -44
- app/code/community/Eway/Rapid31/Block/Info/Direct/Saved.php +44 -44
- app/code/community/Eway/Rapid31/Block/Info/Sharedpage/Ewayone.php +44 -44
- app/code/community/Eway/Rapid31/Block/Info/Sharedpage/Saved.php +44 -44
- app/code/community/Eway/Rapid31/Block/Redirect/PaypalReview.php +4 -2
- app/code/community/Eway/Rapid31/Block/Redirect/Transparent.php +83 -83
- app/code/community/Eway/Rapid31/Block/Redirect/TransparentCheckout.php +54 -54
- app/code/community/Eway/Rapid31/Block/Sales/Order/Grid.php +2 -1
- app/code/community/Eway/Rapid31/Helper/Customer.php +242 -242
- app/code/community/Eway/Rapid31/Helper/Data.php +232 -231
- app/code/community/Eway/Rapid31/Model/Backend/Savedtokens.php +37 -37
- app/code/community/Eway/Rapid31/Model/Config.php +187 -184
- app/code/community/Eway/Rapid31/Model/Customer/Savedtokens.php +92 -90
- app/code/community/Eway/Rapid31/Model/EwayCron.php +138 -131
- app/code/community/Eway/Rapid31/Model/Field/CardDetails.php +89 -89
- app/code/community/Eway/Rapid31/Model/JsonSerializableAbstract.php +44 -44
- app/code/community/Eway/Rapid31/Model/Method/Ewayone.php +431 -432
- app/code/community/Eway/Rapid31/Model/Method/Notsaved.php +524 -542
- app/code/community/Eway/Rapid31/Model/Method/Saved.php +284 -286
- app/code/community/Eway/Rapid31/Model/Observer.php +297 -292
- app/code/community/Eway/Rapid31/Model/RecurringProfile.php +531 -530
- app/code/community/Eway/Rapid31/Model/Request/Abstract.php +181 -179
- app/code/community/Eway/Rapid31/Model/Request/Direct.php +364 -339
- app/code/community/Eway/Rapid31/Model/Request/Sharedpage.php +647 -638
- app/code/community/Eway/Rapid31/Model/Request/Token.php +556 -543
- app/code/community/Eway/Rapid31/Model/Request/Transparent.php +779 -751
- app/code/community/Eway/Rapid31/Model/Resource/Setup.php +5 -4
- app/code/community/Eway/Rapid31/Model/Response.php +425 -426
- app/code/community/Eway/Rapid31/Model/System/Config/Backend/Orderstatus.php +21 -21
- app/code/community/Eway/Rapid31/Model/System/Config/Backend/Validation.php +51 -47
- app/code/community/Eway/Rapid31/Model/System/Config/Source/Orderstatus.php +32 -32
- app/code/community/Eway/Rapid31/Test/Model/Abstract.php +178 -178
- app/code/community/Eway/Rapid31/Test/Model/Config.php +12 -6
- app/code/community/Eway/Rapid31/Test/Model/CustomerToken.php +3 -6
- app/code/community/Eway/Rapid31/Test/Model/JsonSerializable.php +33 -17
- app/code/community/Eway/Rapid31/Test/Model/Response.php +4 -2
- app/code/community/Eway/Rapid31/controllers/Adminhtml/EwayadminController.php +237 -189
- app/code/community/Eway/Rapid31/controllers/Adminhtml/Ewayrapid/SavedcardController.php +306 -300
- app/code/community/Eway/Rapid31/controllers/Adminhtml/Sales/Order/CreateController.php +321 -302
- app/code/community/Eway/Rapid31/controllers/MycardsController.php +407 -401
- app/code/community/Eway/Rapid31/controllers/SharedpageController.php +475 -459
- app/code/community/Eway/Rapid31/controllers/TestController.php +127 -127
- app/code/community/Eway/Rapid31/controllers/TransparentController.php +556 -556
- app/code/community/Eway/Rapid31/etc/config.xml +369 -381
- app/code/community/Eway/Rapid31/sql/ewayrapid_setup/install-0.1.0.php +4 -2
- app/code/community/Eway/Rapid31/sql/ewayrapid_setup/upgrade-1.0.0-1.0.1.php +14 -10
- app/code/community/Eway/Rapid31/sql/ewayrapid_setup/upgrade-1.0.1-1.0.3.php +4 -2
- app/code/community/Eway/Rapid31/sql/ewayrapid_setup/upgrade-1.3.2-1.4.0.php +20 -10
- app/design/adminhtml/default/default/layout/ewayrapid/layout.xml +78 -78
- app/design/adminhtml/default/default/template/ewayrapid/customer/edit/tab/cards.phtml +36 -36
- app/design/adminhtml/default/default/template/ewayrapid/customer/edit/tab/form.phtml +218 -218
- app/design/adminhtml/default/default/template/ewayrapid/customer/method.phtml +175 -175
- app/design/adminhtml/default/default/template/ewayrapid/form/direct_ewayone.phtml +181 -180
- app/design/adminhtml/default/default/template/ewayrapid/form/direct_notsaved.phtml +73 -72
- app/design/adminhtml/default/default/template/ewayrapid/form/direct_saved.phtml +110 -109
- app/design/adminhtml/default/default/template/ewayrapid/form/sharedpage_ewayone.phtml +7 -6
- app/design/adminhtml/default/default/template/ewayrapid/form/sharedpage_notsaved.phtml +28 -27
- app/design/adminhtml/default/default/template/ewayrapid/info/direct_ewayone.phtml +90 -90
- app/design/adminhtml/default/default/template/ewayrapid/info/direct_notsaved.phtml +104 -104
- app/design/adminhtml/default/default/template/ewayrapid/info/direct_saved.phtml +89 -89
- app/design/adminhtml/default/default/template/ewayrapid/info/sharedpage_notsaved.phtml +103 -103
- app/design/adminhtml/default/default/template/ewayrapid/info/sharedpage_saved.phtml +103 -103
- app/design/adminhtml/default/default/template/ewayrapid/pdf/direct_notsaved.phtml +54 -53
- app/design/frontend/base/default/layout/ewayrapid/layout.xml +215 -215
- app/design/frontend/base/default/template/ewayrapid/customer/edit.phtml +0 -627
app/code/community/Eway/Rapid31/Block/Adminhtml/Customer/Edit/Tab/Cards.php
CHANGED
@@ -1,54 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Adminhtml_Customer_Edit_Tab_Cards extends Mage_Adminhtml_Block_Template
|
3 |
-
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
}
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Adminhtml_Customer_Edit_Tab_Cards extends Mage_Adminhtml_Block_Template
|
3 |
+
{
|
4 |
+
protected $_code = 'ewayrapid';
|
5 |
+
protected $_addressModel = null;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Get stored cards for the currently-active method.
|
9 |
+
*/
|
10 |
+
public function getCards()
|
11 |
+
{
|
12 |
+
$customer = Mage::registry('current_customer');
|
13 |
+
if ($customer && $customer->getSavedTokens()) {
|
14 |
+
return $customer->getSavedTokens()->getTokens();
|
15 |
+
} else {
|
16 |
+
return array();
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _getAddressModel()
|
21 |
+
{
|
22 |
+
if (!$this->_addressModel) {
|
23 |
+
$this->_addressModel = Mage::getModel('customer/address');
|
24 |
+
}
|
25 |
+
|
26 |
+
return $this->_addressModel;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Get the current method code.
|
31 |
+
*/
|
32 |
+
public function getCode()
|
33 |
+
{
|
34 |
+
if ( parent::hasCode() ) {
|
35 |
+
return parent::getCode();
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->_code;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function formatAddress($address)
|
42 |
+
{
|
43 |
+
$this->_getAddressModel()->unsetData();
|
44 |
+
$this->_getAddressModel()->addData($address->getData());
|
45 |
+
return $this->_getAddressModel()->format('html');
|
46 |
+
}
|
47 |
+
|
48 |
+
public function checkCards()
|
49 |
+
{
|
50 |
+
foreach ($this->getCards() as $card) {
|
51 |
+
if ($card->getActive()) {
|
52 |
+
return true;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
}
|
app/code/community/Eway/Rapid31/Block/Adminhtml/Customer/Edit/Tab/Form.php
CHANGED
@@ -1,105 +1,106 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Eway_Rapid31_Block_Adminhtml_Customer_Edit_Tab_Form extends Mage_Adminhtml_Block_Template
|
4 |
-
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
// 'Type' => 'a',
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
}
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Eway_Rapid31_Block_Adminhtml_Customer_Edit_Tab_Form extends Mage_Adminhtml_Block_Template
|
4 |
+
{
|
5 |
+
protected $_code = 'ewayrapid';
|
6 |
+
protected $_card = null;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Get the address block for dynamic state/country selection on forms.
|
10 |
+
*/
|
11 |
+
public function getAddressBlock()
|
12 |
+
{
|
13 |
+
return Mage::helper('ewayrapid')->getAddressBlock();
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Return active card (if any).
|
18 |
+
*/
|
19 |
+
public function getCard()
|
20 |
+
{
|
21 |
+
if (!$this->_card) {
|
22 |
+
$tokenId = $this->getTokenId();
|
23 |
+
if ($tokenId && $tokenId > 0) {
|
24 |
+
$tokens = Mage::registry('current_customer')->getSavedTokens();
|
25 |
+
$this->_card = $tokens->getTokenById($tokenId);
|
26 |
+
} else {
|
27 |
+
$token = new Varien_Object();
|
28 |
+
$address = new Varien_Object();
|
29 |
+
$addressInfo = array(
|
30 |
+
'token_customer_id' => '',
|
31 |
+
'reference' => '',
|
32 |
+
'title' => '',
|
33 |
+
'first_name' => '',
|
34 |
+
'last_name' => '',
|
35 |
+
'company_name' => '',
|
36 |
+
'job_description' => '',
|
37 |
+
'street_1' => '',
|
38 |
+
'street_2' => '',
|
39 |
+
'city' => '',
|
40 |
+
'state' => '',
|
41 |
+
'postal_code' => '',
|
42 |
+
'country' => 'us',
|
43 |
+
'email' => '',
|
44 |
+
'phone' => '',
|
45 |
+
'mobile' => '',
|
46 |
+
'comments' => '',
|
47 |
+
'fax' => '',
|
48 |
+
'url' => '',
|
49 |
+
'region_id' => ''
|
50 |
+
);
|
51 |
+
$address->addData($addressInfo);
|
52 |
+
|
53 |
+
$tokenInfo = array(
|
54 |
+
'token' => '',
|
55 |
+
'card' => '',
|
56 |
+
'owner' => '',
|
57 |
+
'exp_month' => '',
|
58 |
+
'exp_year' => '',
|
59 |
+
// 'Type' => 'a',
|
60 |
+
'address' => $address,
|
61 |
+
'active' => 0
|
62 |
+
);
|
63 |
+
$token->addData($tokenInfo);
|
64 |
+
$this->_card = $token;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
return $this->_card;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function getRegionId()
|
72 |
+
{
|
73 |
+
$region = Mage::getModel('directory/region')->loadByName($this->getCard()->getAddress()->getState(), $this->getCard()->getAddress()->getData('Country'));
|
74 |
+
return $region->getId();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Get the current method code.
|
79 |
+
*/
|
80 |
+
public function getCode()
|
81 |
+
{
|
82 |
+
if ( parent::hasCode() ) {
|
83 |
+
return parent::getCode();
|
84 |
+
}
|
85 |
+
|
86 |
+
return $this->_code;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Return whether or not this is a card edit.
|
91 |
+
*/
|
92 |
+
public function isEdit()
|
93 |
+
{
|
94 |
+
return ($this->getCard() && $this->getCard()->getToken());
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Retrieve array of prefix that accepted by eWAY
|
99 |
+
*
|
100 |
+
* @return array
|
101 |
+
*/
|
102 |
+
public function getPrefixOptions()
|
103 |
+
{
|
104 |
+
return array('', 'Mr.', 'Ms.', 'Mrs.', 'Miss', 'Dr.', 'Sir.', 'Prof.');
|
105 |
+
}
|
106 |
+
}
|
app/code/community/Eway/Rapid31/Block/Adminhtml/Customer/Method.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Adminhtml_Customer_Method extends Mage_Adminhtml_Block_Template
|
3 |
-
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Adminhtml_Customer_Method extends Mage_Adminhtml_Block_Template
|
3 |
+
{
|
4 |
+
protected $_code = 'ewayrapid';
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Get the current method code.
|
8 |
+
*/
|
9 |
+
public function getCode()
|
10 |
+
{
|
11 |
+
if ( parent::hasCode() ) {
|
12 |
+
return parent::getCode();
|
13 |
+
}
|
14 |
+
|
15 |
+
return $this->_code;
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Return whether or not this is an AJAX request.
|
20 |
+
*/
|
21 |
+
public function isAjax()
|
22 |
+
{
|
23 |
+
return ( $this->getRequest()->getParam('isAjax') == 1 ) ? true : false;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Return the current customer record.
|
28 |
+
*/
|
29 |
+
public function getCustomer()
|
30 |
+
{
|
31 |
+
return Mage::registry('current_customer');
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Eway/Rapid31/Block/Adminhtml/Sales/Order/Grid.php
CHANGED
@@ -1,188 +1,206 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
-
{
|
4 |
-
const CAPTURED = 1;
|
5 |
-
const NOT_CAPTURED = 0;
|
6 |
-
|
7 |
-
public function __construct()
|
8 |
-
{
|
9 |
-
parent::__construct();
|
10 |
-
$this->setId('eway_order_grid');
|
11 |
-
$this->setUseAjax(true);
|
12 |
-
$this->setDefaultSort('created_at');
|
13 |
-
$this->setDefaultDir('DESC');
|
14 |
-
$this->setSaveParametersInSession(true);
|
15 |
-
}
|
16 |
-
|
17 |
-
protected function _getCollectionClass()
|
18 |
-
{
|
19 |
-
return 'sales/order_grid_collection';
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Set the orders to display
|
24 |
-
*
|
25 |
-
* @return $this
|
26 |
-
*/
|
27 |
-
protected function _prepareCollection()
|
28 |
-
{
|
29 |
-
// Test that the eWAY columns are present
|
30 |
-
$resource = Mage::getSingleton('core/resource');
|
31 |
-
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
32 |
-
$table = $resource->getTableName('sales/order_payment');
|
33 |
-
$rows = $connection->fetchAll("SHOW COLUMNS FROM `{$table}` LIKE 'fraud_action'");
|
34 |
-
|
35 |
-
if (empty($rows)) {
|
36 |
-
echo '<div id="messages"><ul class="messages"><li class="error-msg"><ul><li><span>Error fetching eWAY orders, please check the eWAY extension is properly installed.</span></li></ul></li></ul></div>';
|
37 |
-
return parent::_prepareCollection();
|
38 |
-
}
|
39 |
-
|
40 |
-
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
41 |
-
|
42 |
-
$ewayMethodCodes = array(
|
43 |
-
Mage::getModel('ewayrapid/method_notsaved')->getCode(),
|
44 |
-
Mage::getModel('ewayrapid/method_saved')->getCode(),
|
45 |
-
Mage::getModel('ewayrapid/method_ewayone')->getCode()
|
46 |
-
);
|
47 |
-
|
48 |
-
// Add payment method to filter
|
49 |
-
$collection->getSelect()->join(
|
50 |
-
array('payment' => $resource->getTableName('sales/order_payment')),
|
51 |
-
'main_table.entity_id=payment.parent_id',
|
52 |
-
array(
|
53 |
-
'payment_method' => 'payment.method',
|
54 |
-
'fraud_action' => 'payment.fraud_action',
|
55 |
-
'fraud_codes' => 'payment.fraud_codes',
|
56 |
-
'transaction_captured' => 'payment.transaction_captured',
|
57 |
-
'beagle_score' => 'payment.beagle_score'
|
58 |
-
)
|
59 |
-
);
|
60 |
-
|
61 |
-
$collection->addFieldToFilter('payment.method',array('in' => $ewayMethodCodes));
|
62 |
-
|
63 |
-
$this->setCollection($collection);
|
64 |
-
return parent::_prepareCollection();
|
65 |
-
}
|
66 |
-
|
67 |
-
protected function _prepareColumns()
|
68 |
-
{
|
69 |
-
|
70 |
-
$this->addColumn(
|
71 |
-
'
|
72 |
-
'
|
73 |
-
'
|
74 |
-
'
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
'
|
81 |
-
'
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
'
|
93 |
-
'
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
'
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
'
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
),
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
'
|
123 |
-
'
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
'
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
$
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
const CAPTURED = 1;
|
5 |
+
const NOT_CAPTURED = 0;
|
6 |
+
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
parent::__construct();
|
10 |
+
$this->setId('eway_order_grid');
|
11 |
+
$this->setUseAjax(true);
|
12 |
+
$this->setDefaultSort('created_at');
|
13 |
+
$this->setDefaultDir('DESC');
|
14 |
+
$this->setSaveParametersInSession(true);
|
15 |
+
}
|
16 |
+
|
17 |
+
protected function _getCollectionClass()
|
18 |
+
{
|
19 |
+
return 'sales/order_grid_collection';
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set the orders to display
|
24 |
+
*
|
25 |
+
* @return $this
|
26 |
+
*/
|
27 |
+
protected function _prepareCollection()
|
28 |
+
{
|
29 |
+
// Test that the eWAY columns are present
|
30 |
+
$resource = Mage::getSingleton('core/resource');
|
31 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
32 |
+
$table = $resource->getTableName('sales/order_payment');
|
33 |
+
$rows = $connection->fetchAll("SHOW COLUMNS FROM `{$table}` LIKE 'fraud_action'");
|
34 |
+
|
35 |
+
if (empty($rows)) {
|
36 |
+
echo '<div id="messages"><ul class="messages"><li class="error-msg"><ul><li><span>Error fetching eWAY orders, please check the eWAY extension is properly installed.</span></li></ul></li></ul></div>';
|
37 |
+
return parent::_prepareCollection();
|
38 |
+
}
|
39 |
+
|
40 |
+
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
41 |
+
|
42 |
+
$ewayMethodCodes = array(
|
43 |
+
Mage::getModel('ewayrapid/method_notsaved')->getCode(),
|
44 |
+
Mage::getModel('ewayrapid/method_saved')->getCode(),
|
45 |
+
Mage::getModel('ewayrapid/method_ewayone')->getCode()
|
46 |
+
);
|
47 |
+
|
48 |
+
// Add payment method to filter
|
49 |
+
$collection->getSelect()->join(
|
50 |
+
array('payment' => $resource->getTableName('sales/order_payment')),
|
51 |
+
'main_table.entity_id=payment.parent_id',
|
52 |
+
array(
|
53 |
+
'payment_method' => 'payment.method',
|
54 |
+
'fraud_action' => 'payment.fraud_action',
|
55 |
+
'fraud_codes' => 'payment.fraud_codes',
|
56 |
+
'transaction_captured' => 'payment.transaction_captured',
|
57 |
+
'beagle_score' => 'payment.beagle_score'
|
58 |
+
)
|
59 |
+
);
|
60 |
+
|
61 |
+
$collection->addFieldToFilter('payment.method', array('in' => $ewayMethodCodes));
|
62 |
+
|
63 |
+
$this->setCollection($collection);
|
64 |
+
return parent::_prepareCollection();
|
65 |
+
}
|
66 |
+
|
67 |
+
protected function _prepareColumns()
|
68 |
+
{
|
69 |
+
|
70 |
+
$this->addColumn(
|
71 |
+
'real_order_id', array(
|
72 |
+
'header'=> Mage::helper('ewayrapid')->__('Magento Order ID'),
|
73 |
+
'width' => '80px',
|
74 |
+
'type' => 'text',
|
75 |
+
'index' => 'increment_id',
|
76 |
+
)
|
77 |
+
);
|
78 |
+
|
79 |
+
$this->addColumn(
|
80 |
+
'items_ordered', array(
|
81 |
+
'header' => Mage::helper('ewayrapid')->__('Item(s) Ordered'),
|
82 |
+
'index' => 'entity_id',
|
83 |
+
'renderer' => 'Eway_Rapid31_Block_Adminhtml_Sales_Order_Renderer_Items',
|
84 |
+
'filter_condition_callback' => array($this, '_itemsFilter'),
|
85 |
+
)
|
86 |
+
);
|
87 |
+
|
88 |
+
$this->addColumn(
|
89 |
+
'created_at', array(
|
90 |
+
'header' => Mage::helper('ewayrapid')->__('Purchased On'),
|
91 |
+
'index' => 'created_at',
|
92 |
+
'type' => 'datetime',
|
93 |
+
'width' => '100px',
|
94 |
+
)
|
95 |
+
);
|
96 |
+
|
97 |
+
$this->addColumn(
|
98 |
+
'billing_name', array(
|
99 |
+
'header' => Mage::helper('ewayrapid')->__('Bill to Name'),
|
100 |
+
'index' => 'billing_name',
|
101 |
+
)
|
102 |
+
);
|
103 |
+
|
104 |
+
$this->addColumn(
|
105 |
+
'beagle_score', array(
|
106 |
+
'header' => Mage::helper('ewayrapid')->__('Beagle Score'),
|
107 |
+
'index' => 'beagle_score',
|
108 |
+
)
|
109 |
+
);
|
110 |
+
|
111 |
+
$this->addColumn(
|
112 |
+
'fraud_action', array(
|
113 |
+
'header' => Mage::helper('ewayrapid')->__('Fraud Action'),
|
114 |
+
'index' => 'fraud_action',
|
115 |
+
)
|
116 |
+
);
|
117 |
+
|
118 |
+
$this->addColumn(
|
119 |
+
'transaction_captured', array(
|
120 |
+
'header' => Mage::helper('ewayrapid')->__('Captured'),
|
121 |
+
'index' => 'transaction_captured',
|
122 |
+
'type' => 'options',
|
123 |
+
'options' => array(
|
124 |
+
self::CAPTURED => Mage::helper('ewayrapid')->__('Yes'),
|
125 |
+
self::NOT_CAPTURED => Mage::helper('ewayrapid')->__('No')
|
126 |
+
),
|
127 |
+
)
|
128 |
+
);
|
129 |
+
|
130 |
+
$this->addColumn(
|
131 |
+
'fraud_codes', array(
|
132 |
+
'header' => Mage::helper('ewayrapid')->__('Fraud Codes'),
|
133 |
+
'index' => 'fraud_codes',
|
134 |
+
)
|
135 |
+
);
|
136 |
+
|
137 |
+
$this->addColumn(
|
138 |
+
'status', array(
|
139 |
+
'header' => Mage::helper('ewayrapid')->__('Order Status'),
|
140 |
+
'index' => 'status',
|
141 |
+
'type' => 'options',
|
142 |
+
'width' => '70px',
|
143 |
+
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
|
144 |
+
)
|
145 |
+
);
|
146 |
+
|
147 |
+
return parent::_prepareColumns();
|
148 |
+
}
|
149 |
+
|
150 |
+
protected function _prepareMassaction()
|
151 |
+
{
|
152 |
+
$this->setMassactionIdField('entity_id');
|
153 |
+
$this->getMassactionBlock()->setFormFieldName('order_ids');
|
154 |
+
$this->getMassactionBlock()->setUseSelectAll(false);
|
155 |
+
|
156 |
+
// Append new mass action option
|
157 |
+
$this->getMassactionBlock()->addItem(
|
158 |
+
'pending',
|
159 |
+
array(
|
160 |
+
'label' => $this->__('Verify eWAY Order'),
|
161 |
+
'url' => Mage::helper("adminhtml")->getUrl("adminhtml/ewayadmin/massVerifyEwayOrder"), //this should be the url where there will be mass operation
|
162 |
+
'confirm'=> $this->__('Are you sure?')
|
163 |
+
)
|
164 |
+
);
|
165 |
+
}
|
166 |
+
|
167 |
+
public function getGridUrl()
|
168 |
+
{
|
169 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
170 |
+
}
|
171 |
+
|
172 |
+
protected function _itemsFilter($collection, $column)
|
173 |
+
{
|
174 |
+
if (!$value = $column->getFilter()->getValue()) {
|
175 |
+
return $this;
|
176 |
+
}
|
177 |
+
$filteredCollection = Mage::getResourceModel($this->_getCollectionClass());
|
178 |
+
|
179 |
+
$resource = Mage::getSingleton('core/resource');
|
180 |
+
|
181 |
+
$filteredCollection->getSelect()->join(
|
182 |
+
array('items' => $resource->getTableName('sales/order_item')),
|
183 |
+
'main_table.entity_id=items.order_id and items.parent_item_id is null',
|
184 |
+
array('items_ordered' => 'GROUP_CONCAT(items.name)')
|
185 |
+
)->group('main_table.entity_id')->having('items_ordered like "%'. $value .'%"');
|
186 |
+
|
187 |
+
$filteredOrderIds = array();
|
188 |
+
|
189 |
+
foreach ($filteredCollection as $filteredOrder) {
|
190 |
+
$filteredOrderIds[] = $filteredOrder->getId();
|
191 |
+
}
|
192 |
+
|
193 |
+
$collection->addFieldToFilter('entity_id', array('in' => $filteredOrderIds));
|
194 |
+
|
195 |
+
return $this;
|
196 |
+
}
|
197 |
+
|
198 |
+
public function getRowUrl($row)
|
199 |
+
{
|
200 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
201 |
+
return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
|
202 |
+
}
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
|
206 |
}
|
app/code/community/Eway/Rapid31/Block/Adminhtml/Sales/Order/Renderer/Items.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Adminhtml_Sales_Order_Renderer_Items extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
3 |
-
{
|
4 |
-
public function render(Varien_Object $row)
|
5 |
-
{
|
6 |
-
$value = $row->getData('entity_id');
|
7 |
-
|
8 |
-
$order = Mage::getModel('sales/order')->load($value);
|
9 |
-
|
10 |
-
$html = '';
|
11 |
-
if($order->getId()){
|
12 |
-
foreach($order->getAllVisibleItems() as $item){
|
13 |
-
$html .= $item->getName() . ', ';
|
14 |
-
}
|
15 |
-
}
|
16 |
-
|
17 |
-
return trim($html, ', ');
|
18 |
-
}
|
19 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Adminhtml_Sales_Order_Renderer_Items extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
3 |
+
{
|
4 |
+
public function render(Varien_Object $row)
|
5 |
+
{
|
6 |
+
$value = $row->getData('entity_id');
|
7 |
+
|
8 |
+
$order = Mage::getModel('sales/order')->load($value);
|
9 |
+
|
10 |
+
$html = '';
|
11 |
+
if ($order->getId()) {
|
12 |
+
foreach ($order->getAllVisibleItems() as $item) {
|
13 |
+
$html .= $item->getName() . ', ';
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
return trim($html, ', ');
|
18 |
+
}
|
19 |
}
|
app/code/community/Eway/Rapid31/Block/Customer/Edit.php
CHANGED
@@ -1,118 +1,117 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Customer_Edit extends Mage_Directory_Block_Data
|
3 |
-
{
|
4 |
-
|
5 |
-
private $_currentToken = null;
|
6 |
-
|
7 |
-
public function getTitle()
|
8 |
-
{
|
9 |
-
if ($title = $this->getData('title')) {
|
10 |
-
return $title;
|
11 |
-
}
|
12 |
-
if ($this->isEdit()) {
|
13 |
-
$title = Mage::helper('customer')->__('Edit Credit Card');
|
14 |
-
}
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
*
|
58 |
-
*
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
*
|
69 |
-
*
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
*
|
79 |
-
*
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
$months
|
85 |
-
|
86 |
-
$months
|
87 |
-
$
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
*
|
95 |
-
*
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
$years
|
101 |
-
|
102 |
-
$years =
|
103 |
-
$
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
*
|
111 |
-
*
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
}
|
118 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Customer_Edit extends Mage_Directory_Block_Data
|
3 |
+
{
|
4 |
+
|
5 |
+
private $_currentToken = null;
|
6 |
+
|
7 |
+
public function getTitle()
|
8 |
+
{
|
9 |
+
if ($title = $this->getData('title')) {
|
10 |
+
return $title;
|
11 |
+
}
|
12 |
+
if ($this->isEdit()) {
|
13 |
+
$title = Mage::helper('customer')->__('Edit Credit Card');
|
14 |
+
} else {
|
15 |
+
$title = Mage::helper('customer')->__('Add New Credit Card');
|
16 |
+
}
|
17 |
+
return $title;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return Eway_Rapid31_Model_Customer_Token|mixed
|
22 |
+
*/
|
23 |
+
public function getCurrentToken()
|
24 |
+
{
|
25 |
+
if (Mage::getSingleton('customer/session')->getTokenInfo()) {
|
26 |
+
$this->_currentToken = Mage::getSingleton('customer/session')->getTokenInfo();
|
27 |
+
Mage::getSingleton('customer/session')->setTokenInfo(null);
|
28 |
+
}
|
29 |
+
|
30 |
+
if (is_null($this->_currentToken)) {
|
31 |
+
$this->_currentToken = Mage::registry('current_token') ? Mage::registry('current_token') : Mage::getModel('ewayrapid/customer_token');
|
32 |
+
}
|
33 |
+
|
34 |
+
return $this->_currentToken;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return Eway_Rapid31_Model_Field_Customer
|
39 |
+
*/
|
40 |
+
public function getCustomerAddress()
|
41 |
+
{
|
42 |
+
return $this->getCurrentToken()->getAddress() ? $this->getCurrentToken()->getAddress() : Mage::getModel('ewayrapid/field_customer');
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getSaveUrl()
|
46 |
+
{
|
47 |
+
return $this::getUrl('*/*/save');
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getBackUrl()
|
51 |
+
{
|
52 |
+
return $this::getUrl('*/*/');
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Check if CVN is required or not
|
57 |
+
*
|
58 |
+
* @return bool
|
59 |
+
*/
|
60 |
+
public function hasVerification()
|
61 |
+
{
|
62 |
+
// No need for CVN in creating/updating token
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Check if current action is Edit or New
|
68 |
+
*
|
69 |
+
* @return int
|
70 |
+
*/
|
71 |
+
public function isEdit()
|
72 |
+
{
|
73 |
+
return $this->getCurrentToken()->getToken();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Retrieve credit card expire months
|
78 |
+
*
|
79 |
+
* @return array
|
80 |
+
*/
|
81 |
+
public function getCcMonths()
|
82 |
+
{
|
83 |
+
$months = $this->getData('cc_months');
|
84 |
+
if (is_null($months)) {
|
85 |
+
$months[0] = $this->__('Month');
|
86 |
+
$months = array_merge($months, Mage::getSingleton('payment/config')->getMonths());
|
87 |
+
$this->setData('cc_months', $months);
|
88 |
+
}
|
89 |
+
return $months;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Retrieve credit card expire years
|
94 |
+
*
|
95 |
+
* @return array
|
96 |
+
*/
|
97 |
+
public function getCcYears()
|
98 |
+
{
|
99 |
+
$years = $this->getData('cc_years');
|
100 |
+
if (is_null($years)) {
|
101 |
+
$years = Mage::getSingleton('payment/config')->getYears();
|
102 |
+
$years = array(0=>$this->__('Year'))+$years;
|
103 |
+
$this->setData('cc_years', $years);
|
104 |
+
}
|
105 |
+
return $years;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Retrieve array of prefix that accepted by eWAY
|
110 |
+
*
|
111 |
+
* @return array
|
112 |
+
*/
|
113 |
+
public function getPrefixOptions()
|
114 |
+
{
|
115 |
+
return array('', 'Mr.', 'Ms.', 'Mrs.', 'Miss', 'Dr.', 'Sir.', 'Prof.');
|
116 |
+
}
|
|
|
117 |
}
|
app/code/community/Eway/Rapid31/Block/Form/Direct/Ewayone.php
CHANGED
@@ -1,58 +1,62 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Form_Direct_Ewayone extends Mage_Payment_Block_Form_Cc
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->setIsRecurring(Mage::helper('ewayrapid')->isRecurring());
|
8 |
-
$this->setTemplate('ewayrapid/form/direct_ewayone.phtml');
|
9 |
-
}
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Get list of active tokens of current customer
|
13 |
-
*
|
14 |
-
* @return array
|
15 |
-
*/
|
16 |
-
public function getTokenList()
|
17 |
-
{
|
18 |
-
$tokenList = array();
|
19 |
-
$tokenList['tokens'] = Mage::helper('ewayrapid/customer')->getActiveTokenList();
|
20 |
-
$tokenList['tokens'][Eway_Rapid31_Model_Config::TOKEN_NEW] =
|
21 |
-
Mage::getModel('ewayrapid/customer_token')->setCard($this->__('Use a new card'))->setOwner('')
|
22 |
-
->setExpMonth('')->setExpYear('');
|
23 |
-
$tokenList['default_token'] = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
24 |
-
|
25 |
-
$tokenListJson = array();
|
26 |
-
foreach($tokenList['tokens'] as $id => $token) {
|
27 |
-
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
28 |
-
$tokenListJson[] = "\"{$id}\":{$token->jsonSerialize()}";
|
29 |
-
}
|
30 |
-
$tokenList['tokens_json'] = '{' . implode(',', $tokenListJson) . '}';
|
31 |
-
|
32 |
-
return $tokenList;
|
33 |
-
}
|
34 |
-
|
35 |
-
public function checkCardName($card)
|
36 |
-
{
|
37 |
-
/* @var Eway_Rapid31_Model_Request_Token $model */
|
38 |
-
$model = Mage::getModel('ewayrapid/request_token');
|
39 |
-
return $model->checkCardName($card);
|
40 |
-
}
|
41 |
-
|
42 |
-
public function getSaveCard()
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Form_Direct_Ewayone extends Mage_Payment_Block_Form_Cc
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setIsRecurring(Mage::helper('ewayrapid')->isRecurring());
|
8 |
+
$this->setTemplate('ewayrapid/form/direct_ewayone.phtml');
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Get list of active tokens of current customer
|
13 |
+
*
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function getTokenList()
|
17 |
+
{
|
18 |
+
$tokenList = array();
|
19 |
+
$tokenList['tokens'] = Mage::helper('ewayrapid/customer')->getActiveTokenList();
|
20 |
+
$tokenList['tokens'][Eway_Rapid31_Model_Config::TOKEN_NEW] =
|
21 |
+
Mage::getModel('ewayrapid/customer_token')->setCard($this->__('Use a new card'))->setOwner('')
|
22 |
+
->setExpMonth('')->setExpYear('');
|
23 |
+
$tokenList['default_token'] = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
24 |
+
|
25 |
+
$tokenListJson = array();
|
26 |
+
foreach ($tokenList['tokens'] as $id => $token) {
|
27 |
+
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
28 |
+
$tokenListJson[] = "\"{$id}\":{$token->jsonSerialize()}";
|
29 |
+
}
|
30 |
+
$tokenList['tokens_json'] = '{' . implode(',', $tokenListJson) . '}';
|
31 |
+
|
32 |
+
return $tokenList;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function checkCardName($card)
|
36 |
+
{
|
37 |
+
/* @var Eway_Rapid31_Model_Request_Token $model */
|
38 |
+
$model = Mage::getModel('ewayrapid/request_token');
|
39 |
+
return $model->checkCardName($card);
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getSaveCard()
|
43 |
+
{
|
44 |
+
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_card');
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getSaveText()
|
48 |
+
{
|
49 |
+
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_text');
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getSaveDefaultCheck()
|
53 |
+
{
|
54 |
+
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_card_checked');
|
55 |
+
}
|
56 |
+
|
57 |
+
public function checkSaveCardAvailable()
|
58 |
+
{
|
59 |
+
return Mage::helper('ewayrapid/customer')->getCurrentCustomer()
|
60 |
+
|| Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
|
61 |
+
}
|
62 |
}
|
app/code/community/Eway/Rapid31/Block/Form/Direct/Saved.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Form_Direct_Saved extends Mage_Payment_Block_Form_Cc
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->setIsRecurring(Mage::helper('ewayrapid')->isRecurring());
|
8 |
-
$this->setTemplate('ewayrapid/form/direct_saved.phtml');
|
9 |
-
}
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Get list of active tokens of current customer
|
13 |
-
*
|
14 |
-
* @return array
|
15 |
-
*/
|
16 |
-
public function getTokenList()
|
17 |
-
{
|
18 |
-
$tokenList = array();
|
19 |
-
$tokenList['tokens'] = Mage::helper('ewayrapid/customer')->getActiveTokenList();
|
20 |
-
$tokenList['tokens'][Eway_Rapid31_Model_Config::TOKEN_NEW] =
|
21 |
-
Mage::getModel('ewayrapid/customer_token')->setCard($this->__('Add new card'))->setOwner('')
|
22 |
-
->setExpMonth('')->setExpYear('');
|
23 |
-
$tokenList['default_token'] = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
24 |
-
|
25 |
-
$tokenListJson = array();
|
26 |
-
foreach($tokenList['tokens'] as $id => $token) {
|
27 |
-
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
28 |
-
$tokenListJson[] = "\"{$id}\":{$token->jsonSerialize()}";
|
29 |
-
}
|
30 |
-
$tokenList['tokens_json'] = '{' . implode(',', $tokenListJson) . '}';
|
31 |
-
|
32 |
-
return $tokenList;
|
33 |
-
}
|
34 |
-
|
35 |
-
public function checkCardName($card)
|
36 |
-
{
|
37 |
-
/* @var Eway_Rapid31_Model_Request_Token $model */
|
38 |
-
$model = Mage::getModel('ewayrapid/request_token');
|
39 |
-
return $model->checkCardName($card);
|
40 |
-
}
|
41 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Form_Direct_Saved extends Mage_Payment_Block_Form_Cc
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setIsRecurring(Mage::helper('ewayrapid')->isRecurring());
|
8 |
+
$this->setTemplate('ewayrapid/form/direct_saved.phtml');
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Get list of active tokens of current customer
|
13 |
+
*
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function getTokenList()
|
17 |
+
{
|
18 |
+
$tokenList = array();
|
19 |
+
$tokenList['tokens'] = Mage::helper('ewayrapid/customer')->getActiveTokenList();
|
20 |
+
$tokenList['tokens'][Eway_Rapid31_Model_Config::TOKEN_NEW] =
|
21 |
+
Mage::getModel('ewayrapid/customer_token')->setCard($this->__('Add new card'))->setOwner('')
|
22 |
+
->setExpMonth('')->setExpYear('');
|
23 |
+
$tokenList['default_token'] = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
24 |
+
|
25 |
+
$tokenListJson = array();
|
26 |
+
foreach ($tokenList['tokens'] as $id => $token) {
|
27 |
+
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
28 |
+
$tokenListJson[] = "\"{$id}\":{$token->jsonSerialize()}";
|
29 |
+
}
|
30 |
+
$tokenList['tokens_json'] = '{' . implode(',', $tokenListJson) . '}';
|
31 |
+
|
32 |
+
return $tokenList;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function checkCardName($card)
|
36 |
+
{
|
37 |
+
/* @var Eway_Rapid31_Model_Request_Token $model */
|
38 |
+
$model = Mage::getModel('ewayrapid/request_token');
|
39 |
+
return $model->checkCardName($card);
|
40 |
+
}
|
41 |
}
|
app/code/community/Eway/Rapid31/Block/Form/Sharedpage/Ewayone.php
CHANGED
@@ -1,54 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Form_Sharedpage_Ewayone extends Mage_Payment_Block_Form_Cc
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->setTemplate('ewayrapid/form/sharedpage_ewayone.phtml');
|
8 |
-
// unset all session's sharedpage
|
9 |
-
if(!Mage::app()->getRequest()->isPost()){
|
10 |
-
Mage::helper('ewayrapid')->clearSessionSharedpage();
|
11 |
-
}
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Get list of active tokens of current customer
|
16 |
-
*
|
17 |
-
* @return array
|
18 |
-
*/
|
19 |
-
public function getTokenList()
|
20 |
-
{
|
21 |
-
$tokenList = array();
|
22 |
-
$tokenList['tokens'] = Mage::helper('ewayrapid/customer')->getActiveTokenList();
|
23 |
-
$tokenList['tokens'][Eway_Rapid31_Model_Config::TOKEN_NEW] =
|
24 |
-
Mage::getModel('ewayrapid/customer_token')->setCard($this->__('Use a new card'))->setOwner('')
|
25 |
-
->setExpMonth('')->setExpYear('');
|
26 |
-
$tokenList['default_token'] = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
27 |
-
|
28 |
-
$tokenListJson = array();
|
29 |
-
foreach($tokenList['tokens'] as $id => $token) {
|
30 |
-
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
31 |
-
$tokenListJson[] = "\"{$id}\":{$token->jsonSerialize()}";
|
32 |
-
}
|
33 |
-
$tokenList['tokens_json'] = '{' . implode(',', $tokenListJson) . '}';
|
34 |
-
|
35 |
-
return $tokenList;
|
36 |
-
}
|
37 |
-
|
38 |
-
public function getSaveCard()
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
54 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Form_Sharedpage_Ewayone extends Mage_Payment_Block_Form_Cc
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('ewayrapid/form/sharedpage_ewayone.phtml');
|
8 |
+
// unset all session's sharedpage
|
9 |
+
if (!Mage::app()->getRequest()->isPost()) {
|
10 |
+
Mage::helper('ewayrapid')->clearSessionSharedpage();
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Get list of active tokens of current customer
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function getTokenList()
|
20 |
+
{
|
21 |
+
$tokenList = array();
|
22 |
+
$tokenList['tokens'] = Mage::helper('ewayrapid/customer')->getActiveTokenList();
|
23 |
+
$tokenList['tokens'][Eway_Rapid31_Model_Config::TOKEN_NEW] =
|
24 |
+
Mage::getModel('ewayrapid/customer_token')->setCard($this->__('Use a new card'))->setOwner('')
|
25 |
+
->setExpMonth('')->setExpYear('');
|
26 |
+
$tokenList['default_token'] = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
27 |
+
|
28 |
+
$tokenListJson = array();
|
29 |
+
foreach ($tokenList['tokens'] as $id => $token) {
|
30 |
+
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
31 |
+
$tokenListJson[] = "\"{$id}\":{$token->jsonSerialize()}";
|
32 |
+
}
|
33 |
+
$tokenList['tokens_json'] = '{' . implode(',', $tokenListJson) . '}';
|
34 |
+
|
35 |
+
return $tokenList;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getSaveCard()
|
39 |
+
{
|
40 |
+
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_card');
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getSaveText()
|
44 |
+
{
|
45 |
+
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_text');
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getSaveDefaultCheck()
|
49 |
+
{
|
50 |
+
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_card_checked');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function checkSaveCardAvailable()
|
54 |
+
{
|
55 |
+
return Mage::helper('ewayrapid/customer')->getCurrentCustomer()
|
56 |
+
|| Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
|
57 |
+
}
|
58 |
}
|
app/code/community/Eway/Rapid31/Block/Form/Sharedpage/Notsaved.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Form_Sharedpage_Notsaved extends Mage_Payment_Block_Form_Cc
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->setTemplate('ewayrapid/form/sharedpage_notsaved.phtml');
|
8 |
-
// unset all session's sharedpage
|
9 |
-
if(!Mage::app()->getRequest()->isPost()){
|
10 |
-
Mage::helper('ewayrapid')->clearSessionSharedpage();
|
11 |
-
}
|
12 |
-
}
|
13 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Form_Sharedpage_Notsaved extends Mage_Payment_Block_Form_Cc
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('ewayrapid/form/sharedpage_notsaved.phtml');
|
8 |
+
// unset all session's sharedpage
|
9 |
+
if (!Mage::app()->getRequest()->isPost()) {
|
10 |
+
Mage::helper('ewayrapid')->clearSessionSharedpage();
|
11 |
+
}
|
12 |
+
}
|
13 |
}
|
app/code/community/Eway/Rapid31/Block/Form/Sharedpage/Saved.php
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Form_Sharedpage_Saved extends Mage_Payment_Block_Form_Cc
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->setTemplate('ewayrapid/form/sharedpage_saved.phtml');
|
8 |
-
// unset all session's sharedpage
|
9 |
-
Mage::helper('ewayrapid')->clearSessionSharedpage();
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Get list of active tokens of current customer
|
14 |
-
*
|
15 |
-
* @return array
|
16 |
-
*/
|
17 |
-
public function getTokenList()
|
18 |
-
{
|
19 |
-
$tokenList = array();
|
20 |
-
$tokenList['tokens'] = Mage::helper('ewayrapid/customer')->getActiveTokenList();
|
21 |
-
$tokenList['tokens'][Eway_Rapid31_Model_Config::TOKEN_NEW] =
|
22 |
-
Mage::getModel('ewayrapid/customer_token')->setCard($this->__('Add new card'))->setOwner('')
|
23 |
-
->setExpMonth('')->setExpYear('');
|
24 |
-
$tokenList['default_token'] = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
25 |
-
|
26 |
-
$tokenListJson = array();
|
27 |
-
foreach($tokenList['tokens'] as $id => $token) {
|
28 |
-
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
29 |
-
$tokenListJson[] = "\"{$id}\":{$token->jsonSerialize()}";
|
30 |
-
}
|
31 |
-
$tokenList['tokens_json'] = '{' . implode(',', $tokenListJson) . '}';
|
32 |
-
|
33 |
-
return $tokenList;
|
34 |
-
}
|
35 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Form_Sharedpage_Saved extends Mage_Payment_Block_Form_Cc
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('ewayrapid/form/sharedpage_saved.phtml');
|
8 |
+
// unset all session's sharedpage
|
9 |
+
Mage::helper('ewayrapid')->clearSessionSharedpage();
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Get list of active tokens of current customer
|
14 |
+
*
|
15 |
+
* @return array
|
16 |
+
*/
|
17 |
+
public function getTokenList()
|
18 |
+
{
|
19 |
+
$tokenList = array();
|
20 |
+
$tokenList['tokens'] = Mage::helper('ewayrapid/customer')->getActiveTokenList();
|
21 |
+
$tokenList['tokens'][Eway_Rapid31_Model_Config::TOKEN_NEW] =
|
22 |
+
Mage::getModel('ewayrapid/customer_token')->setCard($this->__('Add new card'))->setOwner('')
|
23 |
+
->setExpMonth('')->setExpYear('');
|
24 |
+
$tokenList['default_token'] = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
25 |
+
|
26 |
+
$tokenListJson = array();
|
27 |
+
foreach ($tokenList['tokens'] as $id => $token) {
|
28 |
+
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
29 |
+
$tokenListJson[] = "\"{$id}\":{$token->jsonSerialize()}";
|
30 |
+
}
|
31 |
+
$tokenList['tokens_json'] = '{' . implode(',', $tokenListJson) . '}';
|
32 |
+
|
33 |
+
return $tokenList;
|
34 |
+
}
|
35 |
}
|
app/code/community/Eway/Rapid31/Block/Form/Transparent/Ewayone.php
CHANGED
@@ -72,19 +72,23 @@ class Eway_Rapid31_Block_Form_Transparent_Ewayone extends Mage_Payment_Block_For
|
|
72 |
return $model->checkCardName($card);
|
73 |
}
|
74 |
|
75 |
-
public function getSaveCard()
|
|
|
76 |
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_card');
|
77 |
}
|
78 |
|
79 |
-
public function getSaveText()
|
|
|
80 |
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_text');
|
81 |
}
|
82 |
|
83 |
-
public function getSaveDefaultCheck()
|
|
|
84 |
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_card_checked');
|
85 |
}
|
86 |
|
87 |
-
public function checkSaveCardAvailable()
|
|
|
88 |
return Mage::helper('ewayrapid/customer')->getCurrentCustomer()
|
89 |
|| Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
|
90 |
}
|
72 |
return $model->checkCardName($card);
|
73 |
}
|
74 |
|
75 |
+
public function getSaveCard()
|
76 |
+
{
|
77 |
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_card');
|
78 |
}
|
79 |
|
80 |
+
public function getSaveText()
|
81 |
+
{
|
82 |
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_text');
|
83 |
}
|
84 |
|
85 |
+
public function getSaveDefaultCheck()
|
86 |
+
{
|
87 |
return Mage::getStoreConfig('payment/ewayrapid_ewayone/save_card_checked');
|
88 |
}
|
89 |
|
90 |
+
public function checkSaveCardAvailable()
|
91 |
+
{
|
92 |
return Mage::helper('ewayrapid/customer')->getCurrentCustomer()
|
93 |
|| Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
|
94 |
}
|
app/code/community/Eway/Rapid31/Block/Html/Head.php
CHANGED
@@ -62,7 +62,8 @@ class Eway_Rapid31_Block_Html_Head extends Mage_Adminhtml_Block_Page_Head
|
|
62 |
$href = $itemName;
|
63 |
switch ($itemType) {
|
64 |
case 'rss':
|
65 |
-
$lines[$itemIf]['other'][] = sprintf(
|
|
|
66 |
$href, $params
|
67 |
);
|
68 |
break;
|
62 |
$href = $itemName;
|
63 |
switch ($itemType) {
|
64 |
case 'rss':
|
65 |
+
$lines[$itemIf]['other'][] = sprintf(
|
66 |
+
'<link href="%s"%s rel="alternate" type="application/rss+xml" />',
|
67 |
$href, $params
|
68 |
);
|
69 |
break;
|
app/code/community/Eway/Rapid31/Block/Info/Direct/Ewayone.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Info_Direct_Ewayone extends Mage_Payment_Block_Info
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->setTemplate('ewayrapid/info/direct_ewayone.phtml');
|
8 |
-
}
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Render as PDF
|
12 |
-
*
|
13 |
-
* @return string
|
14 |
-
*/
|
15 |
-
public function toPdf()
|
16 |
-
{
|
17 |
-
$this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
|
18 |
-
return $this->toHtml();
|
19 |
-
}
|
20 |
-
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Get eWAY Customer Token Id of this transaction
|
24 |
-
*
|
25 |
-
* @return string
|
26 |
-
*/
|
27 |
-
public function getTokenId()
|
28 |
-
{
|
29 |
-
$info = $this->getInfo();
|
30 |
-
/* @var Mage_Sales_Model_Order_Payment $info */
|
31 |
-
$order = $info->getOrder();
|
32 |
-
if($order->getCustomerIsGuest()) {
|
33 |
-
return '';
|
34 |
-
}
|
35 |
-
|
36 |
-
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
37 |
-
if(!$info->getSavedToken()) {
|
38 |
-
return '';
|
39 |
-
}
|
40 |
-
|
41 |
-
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
42 |
-
$helper = Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
43 |
-
return $helper->getCustomerTokenId($info->getSavedToken());
|
44 |
-
}
|
45 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Info_Direct_Ewayone extends Mage_Payment_Block_Info
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('ewayrapid/info/direct_ewayone.phtml');
|
8 |
+
}
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Render as PDF
|
12 |
+
*
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function toPdf()
|
16 |
+
{
|
17 |
+
$this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
|
18 |
+
return $this->toHtml();
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get eWAY Customer Token Id of this transaction
|
24 |
+
*
|
25 |
+
* @return string
|
26 |
+
*/
|
27 |
+
public function getTokenId()
|
28 |
+
{
|
29 |
+
$info = $this->getInfo();
|
30 |
+
/* @var Mage_Sales_Model_Order_Payment $info */
|
31 |
+
$order = $info->getOrder();
|
32 |
+
if ($order->getCustomerIsGuest()) {
|
33 |
+
return '';
|
34 |
+
}
|
35 |
+
|
36 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
37 |
+
if (!$info->getSavedToken()) {
|
38 |
+
return '';
|
39 |
+
}
|
40 |
+
|
41 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
42 |
+
$helper = Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
43 |
+
return $helper->getCustomerTokenId($info->getSavedToken());
|
44 |
+
}
|
45 |
}
|
app/code/community/Eway/Rapid31/Block/Info/Direct/Saved.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Info_Direct_Saved extends Mage_Payment_Block_Info
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->setTemplate('ewayrapid/info/direct_saved.phtml');
|
8 |
-
}
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Render as PDF
|
12 |
-
*
|
13 |
-
* @return string
|
14 |
-
*/
|
15 |
-
public function toPdf()
|
16 |
-
{
|
17 |
-
$this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
|
18 |
-
return $this->toHtml();
|
19 |
-
}
|
20 |
-
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Get eWAY Customer Token Id of this transaction
|
24 |
-
*
|
25 |
-
* @return string
|
26 |
-
*/
|
27 |
-
public function getTokenId()
|
28 |
-
{
|
29 |
-
$info = $this->getInfo();
|
30 |
-
/* @var Mage_Sales_Model_Order_Payment $info */
|
31 |
-
$order = $info->getOrder();
|
32 |
-
if($order->getCustomerIsGuest()) {
|
33 |
-
return '';
|
34 |
-
}
|
35 |
-
|
36 |
-
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
37 |
-
if(!$info->getSavedToken()) {
|
38 |
-
return '';
|
39 |
-
}
|
40 |
-
|
41 |
-
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
42 |
-
$helper = Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
43 |
-
return $helper->getCustomerTokenId($info->getSavedToken());
|
44 |
-
}
|
45 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Info_Direct_Saved extends Mage_Payment_Block_Info
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('ewayrapid/info/direct_saved.phtml');
|
8 |
+
}
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Render as PDF
|
12 |
+
*
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function toPdf()
|
16 |
+
{
|
17 |
+
$this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
|
18 |
+
return $this->toHtml();
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get eWAY Customer Token Id of this transaction
|
24 |
+
*
|
25 |
+
* @return string
|
26 |
+
*/
|
27 |
+
public function getTokenId()
|
28 |
+
{
|
29 |
+
$info = $this->getInfo();
|
30 |
+
/* @var Mage_Sales_Model_Order_Payment $info */
|
31 |
+
$order = $info->getOrder();
|
32 |
+
if ($order->getCustomerIsGuest()) {
|
33 |
+
return '';
|
34 |
+
}
|
35 |
+
|
36 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
37 |
+
if (!$info->getSavedToken()) {
|
38 |
+
return '';
|
39 |
+
}
|
40 |
+
|
41 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
42 |
+
$helper = Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
43 |
+
return $helper->getCustomerTokenId($info->getSavedToken());
|
44 |
+
}
|
45 |
}
|
app/code/community/Eway/Rapid31/Block/Info/Sharedpage/Ewayone.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Info_Sharedpage_Ewayone extends Mage_Payment_Block_Info
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->setTemplate('ewayrapid/info/sharedpage_saved.phtml');
|
8 |
-
}
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Render as PDF
|
12 |
-
*
|
13 |
-
* @return string
|
14 |
-
*/
|
15 |
-
public function toPdf()
|
16 |
-
{
|
17 |
-
$this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
|
18 |
-
return $this->toHtml();
|
19 |
-
}
|
20 |
-
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Get eWAY Customer Token Id of this transaction
|
24 |
-
*
|
25 |
-
* @return string
|
26 |
-
*/
|
27 |
-
public function getTokenId()
|
28 |
-
{
|
29 |
-
$info = $this->getInfo();
|
30 |
-
/* @var Mage_Sales_Model_Order_Payment $info */
|
31 |
-
$order = $info->getOrder();
|
32 |
-
if($order->getCustomerIsGuest()) {
|
33 |
-
return '';
|
34 |
-
}
|
35 |
-
|
36 |
-
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
37 |
-
if(!$info->getSavedToken()) {
|
38 |
-
return '';
|
39 |
-
}
|
40 |
-
|
41 |
-
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
42 |
-
$helper = Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
43 |
-
return $helper->getCustomerTokenId($info->getSavedToken());
|
44 |
-
}
|
45 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Info_Sharedpage_Ewayone extends Mage_Payment_Block_Info
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('ewayrapid/info/sharedpage_saved.phtml');
|
8 |
+
}
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Render as PDF
|
12 |
+
*
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function toPdf()
|
16 |
+
{
|
17 |
+
$this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
|
18 |
+
return $this->toHtml();
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get eWAY Customer Token Id of this transaction
|
24 |
+
*
|
25 |
+
* @return string
|
26 |
+
*/
|
27 |
+
public function getTokenId()
|
28 |
+
{
|
29 |
+
$info = $this->getInfo();
|
30 |
+
/* @var Mage_Sales_Model_Order_Payment $info */
|
31 |
+
$order = $info->getOrder();
|
32 |
+
if ($order->getCustomerIsGuest()) {
|
33 |
+
return '';
|
34 |
+
}
|
35 |
+
|
36 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
37 |
+
if (!$info->getSavedToken()) {
|
38 |
+
return '';
|
39 |
+
}
|
40 |
+
|
41 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
42 |
+
$helper = Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
43 |
+
return $helper->getCustomerTokenId($info->getSavedToken());
|
44 |
+
}
|
45 |
}
|
app/code/community/Eway/Rapid31/Block/Info/Sharedpage/Saved.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Block_Info_Sharedpage_Saved extends Mage_Payment_Block_Info
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->setTemplate('ewayrapid/info/sharedpage_saved.phtml');
|
8 |
-
}
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Render as PDF
|
12 |
-
*
|
13 |
-
* @return string
|
14 |
-
*/
|
15 |
-
public function toPdf()
|
16 |
-
{
|
17 |
-
$this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
|
18 |
-
return $this->toHtml();
|
19 |
-
}
|
20 |
-
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Get eWAY Customer Token Id of this transaction
|
24 |
-
*
|
25 |
-
* @return string
|
26 |
-
*/
|
27 |
-
public function getTokenId()
|
28 |
-
{
|
29 |
-
$info = $this->getInfo();
|
30 |
-
/* @var Mage_Sales_Model_Order_Payment $info */
|
31 |
-
$order = $info->getOrder();
|
32 |
-
if($order->getCustomerIsGuest()) {
|
33 |
-
return '';
|
34 |
-
}
|
35 |
-
|
36 |
-
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
37 |
-
if(!$info->getSavedToken()) {
|
38 |
-
return '';
|
39 |
-
}
|
40 |
-
|
41 |
-
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
42 |
-
$helper = Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
43 |
-
return $helper->getCustomerTokenId($info->getSavedToken());
|
44 |
-
}
|
45 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Block_Info_Sharedpage_Saved extends Mage_Payment_Block_Info
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('ewayrapid/info/sharedpage_saved.phtml');
|
8 |
+
}
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Render as PDF
|
12 |
+
*
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function toPdf()
|
16 |
+
{
|
17 |
+
$this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
|
18 |
+
return $this->toHtml();
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get eWAY Customer Token Id of this transaction
|
24 |
+
*
|
25 |
+
* @return string
|
26 |
+
*/
|
27 |
+
public function getTokenId()
|
28 |
+
{
|
29 |
+
$info = $this->getInfo();
|
30 |
+
/* @var Mage_Sales_Model_Order_Payment $info */
|
31 |
+
$order = $info->getOrder();
|
32 |
+
if ($order->getCustomerIsGuest()) {
|
33 |
+
return '';
|
34 |
+
}
|
35 |
+
|
36 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
37 |
+
if (!$info->getSavedToken()) {
|
38 |
+
return '';
|
39 |
+
}
|
40 |
+
|
41 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
42 |
+
$helper = Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
43 |
+
return $helper->getCustomerTokenId($info->getSavedToken());
|
44 |
+
}
|
45 |
}
|
app/code/community/Eway/Rapid31/Block/Redirect/PaypalReview.php
CHANGED
@@ -49,9 +49,11 @@ class Eway_Rapid31_Block_Redirect_PaypalReview extends Mage_Core_Block_Template
|
|
49 |
$postCode = $this->_quote->getShippingAddress()
|
50 |
->getPostcode();
|
51 |
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
52 |
-
$sharedpageModel = Mage::getModel(
|
|
|
53 |
'quote' => $this->_quote
|
54 |
-
|
|
|
55 |
return $sharedpageModel->getShippingByCode($postCode);
|
56 |
} elseif (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
57 |
$transModel = Mage::getModel('ewayrapid/request_transparent');
|
49 |
$postCode = $this->_quote->getShippingAddress()
|
50 |
->getPostcode();
|
51 |
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
52 |
+
$sharedpageModel = Mage::getModel(
|
53 |
+
'ewayrapid/request_sharedpage', array(
|
54 |
'quote' => $this->_quote
|
55 |
+
)
|
56 |
+
);
|
57 |
return $sharedpageModel->getShippingByCode($postCode);
|
58 |
} elseif (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
59 |
$transModel = Mage::getModel('ewayrapid/request_transparent');
|
app/code/community/Eway/Rapid31/Block/Redirect/Transparent.php
CHANGED
@@ -1,84 +1,84 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Eway_Rapid31_Block_Redirect_Transparent extends Mage_Core_Block_Template
|
4 |
-
{
|
5 |
-
protected $
|
6 |
-
protected $
|
7 |
-
protected $
|
8 |
-
protected $
|
9 |
-
|
10 |
-
public function _construct()
|
11 |
-
{
|
12 |
-
$this->
|
13 |
-
$this->
|
14 |
-
if (!$this->
|
15 |
-
$this->
|
16 |
-
}
|
17 |
-
|
18 |
-
if ($this->
|
19 |
-
if ($this->
|
20 |
-
$this->
|
21 |
-
} else {
|
22 |
-
$this->
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
-
$this->setTemplate('ewayrapid/redirect/transparent.phtml')->toHtml();
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Retrieve credit card expire months
|
31 |
-
*
|
32 |
-
* @return array
|
33 |
-
*/
|
34 |
-
public function getCcMonths()
|
35 |
-
{
|
36 |
-
$months = $this->getData('cc_months');
|
37 |
-
if (is_null($months)) {
|
38 |
-
$months[0] = $this->__('Month');
|
39 |
-
$months = array_merge($months, Mage::getSingleton('payment/config')->getMonths());
|
40 |
-
$this->setData('cc_months', $months);
|
41 |
-
}
|
42 |
-
return $months;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Retrieve credit card expire years
|
47 |
-
*
|
48 |
-
* @return array
|
49 |
-
*/
|
50 |
-
public function getCcYears()
|
51 |
-
{
|
52 |
-
$years = $this->getData('cc_years');
|
53 |
-
if (is_null($years)) {
|
54 |
-
$years = Mage::getSingleton('payment/config')->getYears();
|
55 |
-
$years = array(0 => $this->__('Year')) + $years;
|
56 |
-
$this->setData('cc_years', $years);
|
57 |
-
}
|
58 |
-
return $years;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Get New Shipping from items
|
63 |
-
* @return int
|
64 |
-
*/
|
65 |
-
public function getNewShippingTotal()
|
66 |
-
{
|
67 |
-
$totalItem = 0;
|
68 |
-
foreach ($this->_getQuote()->getAllVisibleItems() as $item) {
|
69 |
-
$totalItem += $item->getQty();
|
70 |
-
}
|
71 |
-
return $totalItem;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Check if CVN is required or not
|
76 |
-
*
|
77 |
-
* @return bool
|
78 |
-
*/
|
79 |
-
public function hasVerification()
|
80 |
-
{
|
81 |
-
// No need for CVN in creating/updating token
|
82 |
-
return Mage::getModel('ewayrapid/method_notsaved')->hasVerification();
|
83 |
-
}
|
84 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Eway_Rapid31_Block_Redirect_Transparent extends Mage_Core_Block_Template
|
4 |
+
{
|
5 |
+
protected $_methodPayment;
|
6 |
+
protected $_transMethod;
|
7 |
+
protected $_paypalSavedToken;
|
8 |
+
protected $_savedToken;
|
9 |
+
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$this->_methodPayment = Mage::getSingleton('core/session')->getMethod();
|
13 |
+
$this->_transMethod = Mage::getSingleton('core/session')->getTransparentNotsaved();
|
14 |
+
if (!$this->_transMethod) {
|
15 |
+
$this->_transMethod = Mage::getSingleton('core/session')->getTransparentSaved();
|
16 |
+
}
|
17 |
+
|
18 |
+
if ($this->_methodPayment == 'ewayrapid_saved' || $this->_methodPayment == 'ewayrapid_ewayone') {
|
19 |
+
if ($this->_transMethod == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
20 |
+
$this->_paypalSavedToken = Mage::getSingleton('core/session')->getPaypalSavedToken();
|
21 |
+
} else {
|
22 |
+
$this->_savedToken = Mage::getSingleton('core/session')->getSavedToken();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
$this->setTemplate('ewayrapid/redirect/transparent.phtml')->toHtml();
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Retrieve credit card expire months
|
31 |
+
*
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
public function getCcMonths()
|
35 |
+
{
|
36 |
+
$months = $this->getData('cc_months');
|
37 |
+
if (is_null($months)) {
|
38 |
+
$months[0] = $this->__('Month');
|
39 |
+
$months = array_merge($months, Mage::getSingleton('payment/config')->getMonths());
|
40 |
+
$this->setData('cc_months', $months);
|
41 |
+
}
|
42 |
+
return $months;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Retrieve credit card expire years
|
47 |
+
*
|
48 |
+
* @return array
|
49 |
+
*/
|
50 |
+
public function getCcYears()
|
51 |
+
{
|
52 |
+
$years = $this->getData('cc_years');
|
53 |
+
if (is_null($years)) {
|
54 |
+
$years = Mage::getSingleton('payment/config')->getYears();
|
55 |
+
$years = array(0 => $this->__('Year')) + $years;
|
56 |
+
$this->setData('cc_years', $years);
|
57 |
+
}
|
58 |
+
return $years;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get New Shipping from items
|
63 |
+
* @return int
|
64 |
+
*/
|
65 |
+
public function getNewShippingTotal()
|
66 |
+
{
|
67 |
+
$totalItem = 0;
|
68 |
+
foreach ($this->_getQuote()->getAllVisibleItems() as $item) {
|
69 |
+
$totalItem += $item->getQty();
|
70 |
+
}
|
71 |
+
return $totalItem;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Check if CVN is required or not
|
76 |
+
*
|
77 |
+
* @return bool
|
78 |
+
*/
|
79 |
+
public function hasVerification()
|
80 |
+
{
|
81 |
+
// No need for CVN in creating/updating token
|
82 |
+
return Mage::getModel('ewayrapid/method_notsaved')->hasVerification();
|
83 |
+
}
|
84 |
}
|
app/code/community/Eway/Rapid31/Block/Redirect/TransparentCheckout.php
CHANGED
@@ -1,55 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Eway_Rapid31_Block_Redirect_TransparentCheckout extends Mage_Core_Block_Template
|
4 |
-
{
|
5 |
-
protected $
|
6 |
-
protected $
|
7 |
-
|
8 |
-
public function _construct()
|
9 |
-
{
|
10 |
-
$this->
|
11 |
-
$this->
|
12 |
-
if(!$this->
|
13 |
-
$this->
|
14 |
-
}
|
15 |
-
$this->setTemplate('ewayrapid/redirect/transparent_checkout.phtml')->toHtml();
|
16 |
-
}
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Retrieve credit card expire months
|
20 |
-
*
|
21 |
-
* @return array
|
22 |
-
*/
|
23 |
-
public function getCcMonths()
|
24 |
-
{
|
25 |
-
$months = $this->getData('cc_months');
|
26 |
-
if (is_null($months)) {
|
27 |
-
$months[0] = $this->__('Month');
|
28 |
-
$months = array_merge($months, Mage::getSingleton('payment/config')->getMonths());
|
29 |
-
$this->setData('cc_months', $months);
|
30 |
-
}
|
31 |
-
return $months;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Retrieve credit card expire years
|
36 |
-
*
|
37 |
-
* @return array
|
38 |
-
*/
|
39 |
-
public function getCcYears()
|
40 |
-
{
|
41 |
-
$years = $this->getData('cc_years');
|
42 |
-
if (is_null($years)) {
|
43 |
-
$years = Mage::getSingleton('payment/config')->getYears();
|
44 |
-
$years = array(0 => $this->__('Year')) + $years;
|
45 |
-
$this->setData('cc_years', $years);
|
46 |
-
}
|
47 |
-
return $years;
|
48 |
-
}
|
49 |
-
|
50 |
-
public function getEnableVisaCheckout()
|
51 |
-
{
|
52 |
-
$_config = Mage::getSingleton('ewayrapid/config');
|
53 |
-
return $_config->getVisaCheckoutEnable();
|
54 |
-
}
|
55 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Eway_Rapid31_Block_Redirect_TransparentCheckout extends Mage_Core_Block_Template
|
4 |
+
{
|
5 |
+
protected $_methodPayment;
|
6 |
+
protected $_transMethod;
|
7 |
+
|
8 |
+
public function _construct()
|
9 |
+
{
|
10 |
+
$this->_methodPayment = Mage::getSingleton('core/session')->getMethod();
|
11 |
+
$this->_transMethod = Mage::getSingleton('core/session')->getTransparentNotsaved();
|
12 |
+
if (!$this->_transMethod) {
|
13 |
+
$this->_transMethod = Mage::getSingleton('core/session')->getTransparentSaved();
|
14 |
+
}
|
15 |
+
$this->setTemplate('ewayrapid/redirect/transparent_checkout.phtml')->toHtml();
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Retrieve credit card expire months
|
20 |
+
*
|
21 |
+
* @return array
|
22 |
+
*/
|
23 |
+
public function getCcMonths()
|
24 |
+
{
|
25 |
+
$months = $this->getData('cc_months');
|
26 |
+
if (is_null($months)) {
|
27 |
+
$months[0] = $this->__('Month');
|
28 |
+
$months = array_merge($months, Mage::getSingleton('payment/config')->getMonths());
|
29 |
+
$this->setData('cc_months', $months);
|
30 |
+
}
|
31 |
+
return $months;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Retrieve credit card expire years
|
36 |
+
*
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
public function getCcYears()
|
40 |
+
{
|
41 |
+
$years = $this->getData('cc_years');
|
42 |
+
if (is_null($years)) {
|
43 |
+
$years = Mage::getSingleton('payment/config')->getYears();
|
44 |
+
$years = array(0 => $this->__('Year')) + $years;
|
45 |
+
$this->setData('cc_years', $years);
|
46 |
+
}
|
47 |
+
return $years;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getEnableVisaCheckout()
|
51 |
+
{
|
52 |
+
$_config = Mage::getSingleton('ewayrapid/config');
|
53 |
+
return $_config->getVisaCheckoutEnable();
|
54 |
+
}
|
55 |
}
|
app/code/community/Eway/Rapid31/Block/Sales/Order/Grid.php
CHANGED
@@ -2,7 +2,8 @@
|
|
2 |
/**
|
3 |
*
|
4 |
*/
|
5 |
-
class Eway_Rapid31_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
|
|
|
6 |
|
7 |
protected function _prepareMassaction()
|
8 |
{
|
2 |
/**
|
3 |
*
|
4 |
*/
|
5 |
+
class Eway_Rapid31_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
|
6 |
+
{
|
7 |
|
8 |
protected function _prepareMassaction()
|
9 |
{
|
app/code/community/Eway/Rapid31/Helper/Customer.php
CHANGED
@@ -1,243 +1,243 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Helper_Customer extends Mage_Core_Helper_Abstract
|
3 |
-
{
|
4 |
-
private $_currentCustomer = false;
|
5 |
-
|
6 |
-
public function __construct()
|
7 |
-
{
|
8 |
-
$this->setCurrentCustomer($this->_getCurrentCustomer());
|
9 |
-
}
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @return Mage_Customer_Model_Customer
|
13 |
-
*/
|
14 |
-
public function getCurrentCustomer()
|
15 |
-
{
|
16 |
-
if(!$this->_currentCustomer) {
|
17 |
-
$this->_currentCustomer = $this->_getCurrentCustomer();
|
18 |
-
}
|
19 |
-
|
20 |
-
return $this->_currentCustomer;
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @param Mage_Customer_Model_Customer $value
|
25 |
-
* @return $this
|
26 |
-
*/
|
27 |
-
public function setCurrentCustomer($value)
|
28 |
-
{
|
29 |
-
$this->_currentCustomer = $value;
|
30 |
-
return $this;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Get current logged in customer (frontend) or chosen customer to create order (backend)
|
35 |
-
*
|
36 |
-
* @return bool|Mage_Customer_Model_Customer
|
37 |
-
*/
|
38 |
-
protected function _getCurrentCustomer()
|
39 |
-
{
|
40 |
-
if(Mage::helper('ewayrapid')->isBackendOrder()){
|
41 |
-
if(Mage::registry('current_customer')){
|
42 |
-
return Mage::registry('current_customer');
|
43 |
-
}elseif($this->_getRequest()->getParam('customer_id')){
|
44 |
-
return Mage::getModel('customer/customer')->load($this->_getRequest()->getParam('customer_id'));
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
if(Mage::helper('ewayrapid')->isBackendOrder() && Mage::getSingleton('adminhtml/session_quote')->getCustomer()) {
|
49 |
-
return Mage::getSingleton('adminhtml/session_quote')->getCustomer();
|
50 |
-
}
|
51 |
-
|
52 |
-
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
53 |
-
return Mage::getSingleton('customer/session')->getCustomer();
|
54 |
-
}
|
55 |
-
|
56 |
-
if(($quote = Mage::getSingleton('checkout/session')->getQuote()) && ($customer = $quote->getCustomer()) && $customer->getId()) {
|
57 |
-
return $customer;
|
58 |
-
}
|
59 |
-
|
60 |
-
return false;
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Get eWAY Customer Token Id
|
65 |
-
*
|
66 |
-
* @param $id
|
67 |
-
* @return mixed
|
68 |
-
*/
|
69 |
-
public function getCustomerTokenId($id)
|
70 |
-
{
|
71 |
-
return $this->getTokenById($id)->getToken() ? $this->getTokenById($id)->getToken() : $this->getTokenById($id)->getTokenCustomerID();
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Get token object by id (id used in Magento, not Customer Token Id)
|
76 |
-
*
|
77 |
-
* @param $id
|
78 |
-
* @return Eway_Rapid31_Model_Customer_Token
|
79 |
-
*/
|
80 |
-
public function getTokenById($id)
|
81 |
-
{
|
82 |
-
$customer = $this->getCurrentCustomer();
|
83 |
-
if($customer && $customer->getSavedTokens()) {
|
84 |
-
return $customer->getSavedTokens()->getTokenById($id);
|
85 |
-
} else {
|
86 |
-
Mage::throwException($this->__('Customer does not have any saved token.'));
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Get last token id of this customer
|
92 |
-
*
|
93 |
-
* @return bool | int
|
94 |
-
*/
|
95 |
-
public function getLastTokenId()
|
96 |
-
{
|
97 |
-
$customer = $this->getCurrentCustomer();
|
98 |
-
if($customer && $customer->getSavedTokens()) {
|
99 |
-
return $customer->getSavedTokens()->getLastId();
|
100 |
-
}
|
101 |
-
|
102 |
-
return false;
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Add new token to customer's token list
|
107 |
-
*
|
108 |
-
* @param $info array
|
109 |
-
*/
|
110 |
-
public function addToken($info)
|
111 |
-
{
|
112 |
-
$customer = $this->getCurrentCustomer();
|
113 |
-
if($customer) {
|
114 |
-
$savedTokens = $customer->getSavedTokens();
|
115 |
-
if(!$savedTokens) {
|
116 |
-
$savedTokens = Mage::getModel('ewayrapid/customer_savedtokens');
|
117 |
-
}
|
118 |
-
|
119 |
-
$savedTokens->addToken($info);
|
120 |
-
$customer->setSavedTokens($savedTokens);
|
121 |
-
|
122 |
-
// Only save existed customer, new customer will be saved by Magento.
|
123 |
-
if($customer->getId()) {
|
124 |
-
$customer->save();
|
125 |
-
}
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Update token identified by id (id used in Magento, not Customer Token Id)
|
131 |
-
*
|
132 |
-
* @param int $id
|
133 |
-
* @param $info
|
134 |
-
*/
|
135 |
-
public function updateToken($id, $info)
|
136 |
-
{
|
137 |
-
$this->getTokenById($id)->addData($info);
|
138 |
-
$this->getCurrentCustomer()->setDataChanges(true)->save();
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Delete token identified by id (id used in Magento, not Customer Token Id)
|
143 |
-
*
|
144 |
-
* @param int $id
|
145 |
-
*/
|
146 |
-
public function deleteToken($id)
|
147 |
-
{
|
148 |
-
$this->updateToken($id, array('Active' => 0));
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Set token identified by id as default token (id used in Magento, not Customer Token Id)
|
153 |
-
*
|
154 |
-
* @param int $id
|
155 |
-
*/
|
156 |
-
public function setDefaultToken($id)
|
157 |
-
{
|
158 |
-
// Check if token is existed.
|
159 |
-
$this->getTokenById($id);
|
160 |
-
$this->getCurrentCustomer()->getSavedTokens()->setDefaultToken($id);
|
161 |
-
$this->getCurrentCustomer()->setDataChanges(true)->save();
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Get default token id
|
166 |
-
*
|
167 |
-
* @return bool | int
|
168 |
-
*/
|
169 |
-
public function getDefaultToken()
|
170 |
-
{
|
171 |
-
$customer = $this->getCurrentCustomer();
|
172 |
-
if($customer && $customer->getSavedTokens()) {
|
173 |
-
return $customer->getSavedTokens()->getDefaultToken();
|
174 |
-
}
|
175 |
-
|
176 |
-
return false;
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Get active token list of current customer
|
181 |
-
*
|
182 |
-
* @return array
|
183 |
-
*/
|
184 |
-
public function getActiveTokenList()
|
185 |
-
{
|
186 |
-
$customer = $this->getCurrentCustomer();
|
187 |
-
if($customer && $customer->getSavedTokens()) {
|
188 |
-
$tokens = $customer->getSavedTokens()->getTokens();
|
189 |
-
if(is_array($tokens)) {
|
190 |
-
foreach($tokens as $key => $token) {
|
191 |
-
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
192 |
-
if(!$token->getActive()) {
|
193 |
-
unset($tokens[$key]);
|
194 |
-
} else {
|
195 |
-
$token->unsetData('Token');
|
196 |
-
}
|
197 |
-
}
|
198 |
-
return $tokens;
|
199 |
-
}
|
200 |
-
}
|
201 |
-
|
202 |
-
return array();
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Get active token list of current customer
|
207 |
-
*
|
208 |
-
* @return array
|
209 |
-
*/
|
210 |
-
public function checkTokenListByType($type = Eway_Rapid31_Model_Config::CREDITCARD_METHOD)
|
211 |
-
{
|
212 |
-
$customer = $this->getCurrentCustomer();
|
213 |
-
if($customer && $customer->getSavedTokens()) {
|
214 |
-
$tokens = $customer->getSavedTokens()->getTokens();
|
215 |
-
if(is_array($tokens)) {
|
216 |
-
foreach($tokens as $key => $token) {
|
217 |
-
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
218 |
-
if(!$token->getActive()) {
|
219 |
-
unset($tokens[$key]);
|
220 |
-
} else {
|
221 |
-
$token->unsetData('Token');
|
222 |
-
}
|
223 |
-
|
224 |
-
if($token->getCard() && $type == Eway_Rapid31_Model_Config::CREDITCARD_METHOD) {
|
225 |
-
if (preg_match('/^'.Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD.'/', strtolower($token->getCard()))) {
|
226 |
-
unset($tokens[$key]);
|
227 |
-
}
|
228 |
-
if (preg_match('/^mc/', strtolower($token->getCard()))) {
|
229 |
-
unset($tokens[$key]);
|
230 |
-
}
|
231 |
-
} elseif($token->getCard()) {
|
232 |
-
if (!preg_match('/^'.$type.'/', strtolower($token->getCard()))) {
|
233 |
-
unset($tokens[$key]);
|
234 |
-
}
|
235 |
-
}
|
236 |
-
}
|
237 |
-
return $tokens;
|
238 |
-
}
|
239 |
-
}
|
240 |
-
|
241 |
-
return array();
|
242 |
-
}
|
243 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Helper_Customer extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
private $_currentCustomer = false;
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->setCurrentCustomer($this->_getCurrentCustomer());
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @return Mage_Customer_Model_Customer
|
13 |
+
*/
|
14 |
+
public function getCurrentCustomer()
|
15 |
+
{
|
16 |
+
if (!$this->_currentCustomer) {
|
17 |
+
$this->_currentCustomer = $this->_getCurrentCustomer();
|
18 |
+
}
|
19 |
+
|
20 |
+
return $this->_currentCustomer;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param Mage_Customer_Model_Customer $value
|
25 |
+
* @return $this
|
26 |
+
*/
|
27 |
+
public function setCurrentCustomer($value)
|
28 |
+
{
|
29 |
+
$this->_currentCustomer = $value;
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Get current logged in customer (frontend) or chosen customer to create order (backend)
|
35 |
+
*
|
36 |
+
* @return bool|Mage_Customer_Model_Customer
|
37 |
+
*/
|
38 |
+
protected function _getCurrentCustomer()
|
39 |
+
{
|
40 |
+
if (Mage::helper('ewayrapid')->isBackendOrder()) {
|
41 |
+
if (Mage::registry('current_customer')) {
|
42 |
+
return Mage::registry('current_customer');
|
43 |
+
} elseif ($this->_getRequest()->getParam('customer_id')) {
|
44 |
+
return Mage::getModel('customer/customer')->load($this->_getRequest()->getParam('customer_id'));
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
if (Mage::helper('ewayrapid')->isBackendOrder() && Mage::getSingleton('adminhtml/session_quote')->getCustomer()) {
|
49 |
+
return Mage::getSingleton('adminhtml/session_quote')->getCustomer();
|
50 |
+
}
|
51 |
+
|
52 |
+
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
|
53 |
+
return Mage::getSingleton('customer/session')->getCustomer();
|
54 |
+
}
|
55 |
+
|
56 |
+
if (($quote = Mage::getSingleton('checkout/session')->getQuote()) && ($customer = $quote->getCustomer()) && $customer->getId()) {
|
57 |
+
return $customer;
|
58 |
+
}
|
59 |
+
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Get eWAY Customer Token Id
|
65 |
+
*
|
66 |
+
* @param $id
|
67 |
+
* @return mixed
|
68 |
+
*/
|
69 |
+
public function getCustomerTokenId($id)
|
70 |
+
{
|
71 |
+
return $this->getTokenById($id)->getToken() ? $this->getTokenById($id)->getToken() : $this->getTokenById($id)->getTokenCustomerID();
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Get token object by id (id used in Magento, not Customer Token Id)
|
76 |
+
*
|
77 |
+
* @param $id
|
78 |
+
* @return Eway_Rapid31_Model_Customer_Token
|
79 |
+
*/
|
80 |
+
public function getTokenById($id)
|
81 |
+
{
|
82 |
+
$customer = $this->getCurrentCustomer();
|
83 |
+
if ($customer && $customer->getSavedTokens()) {
|
84 |
+
return $customer->getSavedTokens()->getTokenById($id);
|
85 |
+
} else {
|
86 |
+
Mage::throwException($this->__('Customer does not have any saved token.'));
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Get last token id of this customer
|
92 |
+
*
|
93 |
+
* @return bool | int
|
94 |
+
*/
|
95 |
+
public function getLastTokenId()
|
96 |
+
{
|
97 |
+
$customer = $this->getCurrentCustomer();
|
98 |
+
if ($customer && $customer->getSavedTokens()) {
|
99 |
+
return $customer->getSavedTokens()->getLastId();
|
100 |
+
}
|
101 |
+
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Add new token to customer's token list
|
107 |
+
*
|
108 |
+
* @param $info array
|
109 |
+
*/
|
110 |
+
public function addToken($info)
|
111 |
+
{
|
112 |
+
$customer = $this->getCurrentCustomer();
|
113 |
+
if ($customer) {
|
114 |
+
$savedTokens = $customer->getSavedTokens();
|
115 |
+
if (!$savedTokens) {
|
116 |
+
$savedTokens = Mage::getModel('ewayrapid/customer_savedtokens');
|
117 |
+
}
|
118 |
+
|
119 |
+
$savedTokens->addToken($info);
|
120 |
+
$customer->setSavedTokens($savedTokens);
|
121 |
+
|
122 |
+
// Only save existed customer, new customer will be saved by Magento.
|
123 |
+
if ($customer->getId()) {
|
124 |
+
$customer->save();
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Update token identified by id (id used in Magento, not Customer Token Id)
|
131 |
+
*
|
132 |
+
* @param int $id
|
133 |
+
* @param $info
|
134 |
+
*/
|
135 |
+
public function updateToken($id, $info)
|
136 |
+
{
|
137 |
+
$this->getTokenById($id)->addData($info);
|
138 |
+
$this->getCurrentCustomer()->setDataChanges(true)->save();
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Delete token identified by id (id used in Magento, not Customer Token Id)
|
143 |
+
*
|
144 |
+
* @param int $id
|
145 |
+
*/
|
146 |
+
public function deleteToken($id)
|
147 |
+
{
|
148 |
+
$this->updateToken($id, array('Active' => 0));
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Set token identified by id as default token (id used in Magento, not Customer Token Id)
|
153 |
+
*
|
154 |
+
* @param int $id
|
155 |
+
*/
|
156 |
+
public function setDefaultToken($id)
|
157 |
+
{
|
158 |
+
// Check if token is existed.
|
159 |
+
$this->getTokenById($id);
|
160 |
+
$this->getCurrentCustomer()->getSavedTokens()->setDefaultToken($id);
|
161 |
+
$this->getCurrentCustomer()->setDataChanges(true)->save();
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Get default token id
|
166 |
+
*
|
167 |
+
* @return bool | int
|
168 |
+
*/
|
169 |
+
public function getDefaultToken()
|
170 |
+
{
|
171 |
+
$customer = $this->getCurrentCustomer();
|
172 |
+
if ($customer && $customer->getSavedTokens()) {
|
173 |
+
return $customer->getSavedTokens()->getDefaultToken();
|
174 |
+
}
|
175 |
+
|
176 |
+
return false;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Get active token list of current customer
|
181 |
+
*
|
182 |
+
* @return array
|
183 |
+
*/
|
184 |
+
public function getActiveTokenList()
|
185 |
+
{
|
186 |
+
$customer = $this->getCurrentCustomer();
|
187 |
+
if ($customer && $customer->getSavedTokens()) {
|
188 |
+
$tokens = $customer->getSavedTokens()->getTokens();
|
189 |
+
if (is_array($tokens)) {
|
190 |
+
foreach ($tokens as $key => $token) {
|
191 |
+
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
192 |
+
if (!$token->getActive()) {
|
193 |
+
unset($tokens[$key]);
|
194 |
+
} else {
|
195 |
+
$token->unsetData('Token');
|
196 |
+
}
|
197 |
+
}
|
198 |
+
return $tokens;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
return array();
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Get active token list of current customer
|
207 |
+
*
|
208 |
+
* @return array
|
209 |
+
*/
|
210 |
+
public function checkTokenListByType($type = Eway_Rapid31_Model_Config::CREDITCARD_METHOD)
|
211 |
+
{
|
212 |
+
$customer = $this->getCurrentCustomer();
|
213 |
+
if ($customer && $customer->getSavedTokens()) {
|
214 |
+
$tokens = $customer->getSavedTokens()->getTokens();
|
215 |
+
if (is_array($tokens)) {
|
216 |
+
foreach ($tokens as $key => $token) {
|
217 |
+
/* @var Eway_Rapid31_Model_Customer_Token $token */
|
218 |
+
if (!$token->getActive()) {
|
219 |
+
unset($tokens[$key]);
|
220 |
+
} else {
|
221 |
+
$token->unsetData('Token');
|
222 |
+
}
|
223 |
+
|
224 |
+
if ($token->getCard() && $type == Eway_Rapid31_Model_Config::CREDITCARD_METHOD) {
|
225 |
+
if (preg_match('/^'.Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD.'/', strtolower($token->getCard()))) {
|
226 |
+
unset($tokens[$key]);
|
227 |
+
}
|
228 |
+
if (preg_match('/^mc/', strtolower($token->getCard()))) {
|
229 |
+
unset($tokens[$key]);
|
230 |
+
}
|
231 |
+
} elseif ($token->getCard()) {
|
232 |
+
if (!preg_match('/^'.$type.'/', strtolower($token->getCard()))) {
|
233 |
+
unset($tokens[$key]);
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
237 |
+
return $tokens;
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
return array();
|
242 |
+
}
|
243 |
}
|
app/code/community/Eway/Rapid31/Helper/Data.php
CHANGED
@@ -1,232 +1,233 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*/
|
5 |
-
class Eway_Rapid31_Helper_Data extends Mage_Core_Helper_Abstract
|
6 |
-
{
|
7 |
-
protected $_address
|
8 |
-
private $_ccTypeNames = null;
|
9 |
-
private $_isSaveMethodEnabled = null;
|
10 |
-
private $_beagleVerificationCodes = array(
|
11 |
-
0 => 'Not Verified',
|
12 |
-
1 => 'Attempted',
|
13 |
-
2 => 'Verified',
|
14 |
-
3 => 'Failed'
|
15 |
-
);
|
16 |
-
|
17 |
-
public function isBackendOrder()
|
18 |
-
{
|
19 |
-
return Mage::app()->getStore()->isAdmin();
|
20 |
-
}
|
21 |
-
|
22 |
-
public function getExtensionVersion()
|
23 |
-
{
|
24 |
-
return (string) Mage::getConfig()->getModuleConfig("Eway_Rapid31")->version;
|
25 |
-
}
|
26 |
-
|
27 |
-
public function serializeInfoInstance(&$info)
|
28 |
-
{
|
29 |
-
$fieldsToSerialize = array('is_new_token', 'is_update_token', 'saved_token');
|
30 |
-
$data = array();
|
31 |
-
foreach($fieldsToSerialize as $field) {
|
32 |
-
$data[$field] = $info->getData($field);
|
33 |
-
}
|
34 |
-
|
35 |
-
$info->setAdditionalData(json_encode($data));
|
36 |
-
}
|
37 |
-
|
38 |
-
public function unserializeInfoInstace(&$info)
|
39 |
-
{
|
40 |
-
$data = json_decode($info->getAdditionalData(), true);
|
41 |
-
$info->addData($data);
|
42 |
-
}
|
43 |
-
|
44 |
-
public function getCcTypeName($type)
|
45 |
-
{
|
46 |
-
if (preg_match('/^paypal/', strtolower($type))) {
|
47 |
-
return 'PayPal';
|
48 |
-
}
|
49 |
-
|
50 |
-
if(is_null($this->_ccTypeNames)) {
|
51 |
-
$this->_ccTypeNames = Mage::getSingleton('payment/config')->getCcTypes();
|
52 |
-
}
|
53 |
-
return (isset($this->_ccTypeNames[$type]) ? $this->_ccTypeNames[$type] : 'Unknown');
|
54 |
-
}
|
55 |
-
|
56 |
-
public function isSavedMethodEnabled()
|
57 |
-
{
|
58 |
-
if(is_null($this->_isSaveMethodEnabled)) {
|
59 |
-
$savedEnable = Mage::getSingleton('ewayrapid/method_saved')->getConfigData('active');
|
60 |
-
$ewayOneEnable = Mage::getSingleton('ewayrapid/method_ewayone')->getConfigData('active');
|
61 |
-
$this->_isSaveMethodEnabled = $ewayOneEnable ? $ewayOneEnable : $savedEnable;
|
62 |
-
}
|
63 |
-
return $this->_isSaveMethodEnabled;
|
64 |
-
}
|
65 |
-
|
66 |
-
public function isRecurring()
|
67 |
-
{
|
68 |
-
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
69 |
-
$items = $quote->getAllItems();
|
70 |
-
foreach ($items as $item) {
|
71 |
-
if ($item->getIsRecurring()) {
|
72 |
-
return true;
|
73 |
-
}
|
74 |
-
}
|
75 |
-
return false;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @param $data
|
80 |
-
* @param $key
|
81 |
-
* @return string
|
82 |
-
*/
|
83 |
-
public function encryptSha256($data, $key)
|
84 |
-
{
|
85 |
-
//To Encrypt:
|
86 |
-
return trim(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB));
|
87 |
-
}
|
88 |
-
|
89 |
-
public function decryptSha256($data, $key)
|
90 |
-
{
|
91 |
-
//To Decrypt:
|
92 |
-
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB));
|
93 |
-
}
|
94 |
-
|
95 |
-
public function getPaymentAction()
|
96 |
-
{
|
97 |
-
return Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
|
98 |
-
}
|
99 |
-
|
100 |
-
public function getTransferCartLineItems()
|
101 |
-
{
|
102 |
-
return Mage::getStoreConfig('payment/ewayrapid_general/transfer_cart_items');
|
103 |
-
}
|
104 |
-
|
105 |
-
public function getLineItems()
|
106 |
-
{
|
107 |
-
$lineItems = array();
|
108 |
-
/** @var Mage_Sales_Model_Quote $quote */
|
109 |
-
if(!$this->isBackendOrder()){
|
110 |
-
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
111 |
-
}else{
|
112 |
-
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
113 |
-
}
|
114 |
-
if ($quote) {
|
115 |
-
// add Shipping item
|
116 |
-
if ($quote->getShippingAddress()->getBaseShippingInclTax()) {
|
117 |
-
$shippingItem = Mage::getModel('ewayrapid/field_lineItem');
|
118 |
-
$shippingItem->setSKU('');
|
119 |
-
$shippingItem->setDescription('Shipping');
|
120 |
-
$shippingItem->setQuantity(1);
|
121 |
-
$shippingItem->setUnitCost(round($quote->getShippingAddress()->getBaseShippingAmount() * 100));
|
122 |
-
$shippingItem->setTax(round($quote->getShippingAddress()->getBaseShippingTaxAmount() * 100));
|
123 |
-
$shippingItem->setTotal(round($quote->getShippingAddress()->getBaseShippingInclTax() * 100));
|
124 |
-
$lineItems[] = $shippingItem;
|
125 |
-
}
|
126 |
-
|
127 |
-
// add Line items
|
128 |
-
$items = $quote->getAllVisibleItems();
|
129 |
-
foreach ($items as $item) {
|
130 |
-
/* @var Mage_Sales_Model_Order_Item $item */
|
131 |
-
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
|
132 |
-
$lineItem->setSKU($item->getSku());
|
133 |
-
$lineItem->setDescription(substr($item->getName(), 0, 26));
|
134 |
-
$lineItem->setQuantity($item->getQty());
|
135 |
-
$lineItem->setUnitCost(round($item->getBasePrice() * 100));
|
136 |
-
$lineItem->setTax(round($item->getBaseTaxAmount() * 100));
|
137 |
-
$lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
|
138 |
-
$lineItems[] = $lineItem;
|
139 |
-
}
|
140 |
-
|
141 |
-
// add Discount item
|
142 |
-
if ((int)$quote->getShippingAddress()->getBaseDiscountAmount() !== 0) {
|
143 |
-
$shippingItem = Mage::getModel('ewayrapid/field_lineItem');
|
144 |
-
$shippingItem->setSKU('');
|
145 |
-
$shippingItem->setDescription('Discount');
|
146 |
-
$shippingItem->setQuantity(1);
|
147 |
-
$shippingItem->setUnitCost(round($quote->getShippingAddress()->getBaseDiscountAmount() * 100));
|
148 |
-
$shippingItem->setTax(0);
|
149 |
-
$shippingItem->setTotal(round($quote->getShippingAddress()->getBaseDiscountAmount() * 100));
|
150 |
-
$lineItems[] = $shippingItem;
|
151 |
-
}
|
152 |
-
}
|
153 |
-
return $lineItems;
|
154 |
-
}
|
155 |
-
|
156 |
-
public function checkCardName($card)
|
157 |
-
{
|
158 |
-
/* @var Eway_Rapid31_Model_Request_Token $model */
|
159 |
-
$model = Mage::getModel('ewayrapid/request_token');
|
160 |
-
return $model->checkCardName($card);
|
161 |
-
}
|
162 |
-
|
163 |
-
public function clearSessionSharedpage()
|
164 |
-
{
|
165 |
-
Mage::getSingleton('core/session')->unsetData('editToken');
|
166 |
-
Mage::getSingleton('core/session')->unsetData('newToken');
|
167 |
-
Mage::getSingleton('core/session')->unsetData('sharedpagePaypal');
|
168 |
-
}
|
169 |
-
|
170 |
-
public function limitInvoiceDescriptionLength($description)
|
171 |
-
{
|
172 |
-
if(strlen($description) > 64){
|
173 |
-
$description = substr($description,0,61);
|
174 |
-
$description .= '...';
|
175 |
-
}
|
176 |
-
|
177 |
-
return $description;
|
178 |
-
}
|
179 |
-
|
180 |
-
public function getBeagleVerificationTitle($code)
|
181 |
-
{
|
182 |
-
return $this->_beagleVerificationCodes[$code];
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Get Fraud Codes from ResponseMessage
|
187 |
-
*
|
188 |
-
* @return string
|
189 |
-
*/
|
190 |
-
public function getFraudCodes($codes)
|
191 |
-
{
|
192 |
-
$codes = explode(',', $codes);
|
193 |
-
|
194 |
-
$fraudCodes = array();
|
195 |
-
|
196 |
-
foreach($codes as $code){
|
197 |
-
$code = trim($code);
|
198 |
-
if(substr($code,0,1) == "F"){
|
199 |
-
$fraudCodes[] = $code;
|
200 |
-
}
|
201 |
-
}
|
202 |
-
|
203 |
-
return implode(',', $fraudCodes);
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Get the address block for dynamic state/country selection on forms.
|
208 |
-
*/
|
209 |
-
public function getAddressBlock()
|
210 |
-
{
|
211 |
-
if( is_null(
|
212 |
-
$this->_address = Mage::app()->getLayout()->createBlock('directory/data');
|
213 |
-
}
|
214 |
-
|
215 |
-
return $this->_address;
|
216 |
-
}
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Get customer country dropdown
|
220 |
-
*/
|
221 |
-
public function getCountryHtmlSelect( $name, $default='US', $id=null )
|
222 |
-
{
|
223 |
-
return $this->getAddressBlock()->getCountryHtmlSelect(
|
224 |
-
}
|
225 |
-
|
226 |
-
public function useIframeInBackend()
|
227 |
-
|
228 |
-
$
|
229 |
-
|
230 |
-
|
231 |
-
|
|
|
232 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
class Eway_Rapid31_Helper_Data extends Mage_Core_Helper_Abstract
|
6 |
+
{
|
7 |
+
protected $_address = null;
|
8 |
+
private $_ccTypeNames = null;
|
9 |
+
private $_isSaveMethodEnabled = null;
|
10 |
+
private $_beagleVerificationCodes = array(
|
11 |
+
0 => 'Not Verified',
|
12 |
+
1 => 'Attempted',
|
13 |
+
2 => 'Verified',
|
14 |
+
3 => 'Failed'
|
15 |
+
);
|
16 |
+
|
17 |
+
public function isBackendOrder()
|
18 |
+
{
|
19 |
+
return Mage::app()->getStore()->isAdmin();
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getExtensionVersion()
|
23 |
+
{
|
24 |
+
return (string) Mage::getConfig()->getModuleConfig("Eway_Rapid31")->version;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function serializeInfoInstance(&$info)
|
28 |
+
{
|
29 |
+
$fieldsToSerialize = array('is_new_token', 'is_update_token', 'saved_token');
|
30 |
+
$data = array();
|
31 |
+
foreach ($fieldsToSerialize as $field) {
|
32 |
+
$data[$field] = $info->getData($field);
|
33 |
+
}
|
34 |
+
|
35 |
+
$info->setAdditionalData(json_encode($data));
|
36 |
+
}
|
37 |
+
|
38 |
+
public function unserializeInfoInstace(&$info)
|
39 |
+
{
|
40 |
+
$data = json_decode($info->getAdditionalData(), true);
|
41 |
+
$info->addData($data);
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getCcTypeName($type)
|
45 |
+
{
|
46 |
+
if (preg_match('/^paypal/', strtolower($type))) {
|
47 |
+
return 'PayPal';
|
48 |
+
}
|
49 |
+
|
50 |
+
if (is_null($this->_ccTypeNames)) {
|
51 |
+
$this->_ccTypeNames = Mage::getSingleton('payment/config')->getCcTypes();
|
52 |
+
}
|
53 |
+
return (isset($this->_ccTypeNames[$type]) ? $this->_ccTypeNames[$type] : 'Unknown');
|
54 |
+
}
|
55 |
+
|
56 |
+
public function isSavedMethodEnabled()
|
57 |
+
{
|
58 |
+
if (is_null($this->_isSaveMethodEnabled)) {
|
59 |
+
$savedEnable = Mage::getSingleton('ewayrapid/method_saved')->getConfigData('active');
|
60 |
+
$ewayOneEnable = Mage::getSingleton('ewayrapid/method_ewayone')->getConfigData('active');
|
61 |
+
$this->_isSaveMethodEnabled = $ewayOneEnable ? $ewayOneEnable : $savedEnable;
|
62 |
+
}
|
63 |
+
return $this->_isSaveMethodEnabled;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function isRecurring()
|
67 |
+
{
|
68 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
69 |
+
$items = $quote->getAllItems();
|
70 |
+
foreach ($items as $item) {
|
71 |
+
if ($item->getIsRecurring()) {
|
72 |
+
return true;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @param $data
|
80 |
+
* @param $key
|
81 |
+
* @return string
|
82 |
+
*/
|
83 |
+
public function encryptSha256($data, $key)
|
84 |
+
{
|
85 |
+
//To Encrypt:
|
86 |
+
return trim(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB));
|
87 |
+
}
|
88 |
+
|
89 |
+
public function decryptSha256($data, $key)
|
90 |
+
{
|
91 |
+
//To Decrypt:
|
92 |
+
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB));
|
93 |
+
}
|
94 |
+
|
95 |
+
public function getPaymentAction()
|
96 |
+
{
|
97 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
|
98 |
+
}
|
99 |
+
|
100 |
+
public function getTransferCartLineItems()
|
101 |
+
{
|
102 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/transfer_cart_items');
|
103 |
+
}
|
104 |
+
|
105 |
+
public function getLineItems()
|
106 |
+
{
|
107 |
+
$lineItems = array();
|
108 |
+
/** @var Mage_Sales_Model_Quote $quote */
|
109 |
+
if (!$this->isBackendOrder()) {
|
110 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
111 |
+
} else {
|
112 |
+
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
113 |
+
}
|
114 |
+
if ($quote) {
|
115 |
+
// add Shipping item
|
116 |
+
if ($quote->getShippingAddress()->getBaseShippingInclTax()) {
|
117 |
+
$shippingItem = Mage::getModel('ewayrapid/field_lineItem');
|
118 |
+
$shippingItem->setSKU('');
|
119 |
+
$shippingItem->setDescription('Shipping');
|
120 |
+
$shippingItem->setQuantity(1);
|
121 |
+
$shippingItem->setUnitCost(round($quote->getShippingAddress()->getBaseShippingAmount() * 100));
|
122 |
+
$shippingItem->setTax(round($quote->getShippingAddress()->getBaseShippingTaxAmount() * 100));
|
123 |
+
$shippingItem->setTotal(round($quote->getShippingAddress()->getBaseShippingInclTax() * 100));
|
124 |
+
$lineItems[] = $shippingItem;
|
125 |
+
}
|
126 |
+
|
127 |
+
// add Line items
|
128 |
+
$items = $quote->getAllVisibleItems();
|
129 |
+
foreach ($items as $item) {
|
130 |
+
/* @var Mage_Sales_Model_Order_Item $item */
|
131 |
+
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
|
132 |
+
$lineItem->setSKU($item->getSku());
|
133 |
+
$lineItem->setDescription(substr($item->getName(), 0, 26));
|
134 |
+
$lineItem->setQuantity($item->getQty());
|
135 |
+
$lineItem->setUnitCost(round($item->getBasePrice() * 100));
|
136 |
+
$lineItem->setTax(round($item->getBaseTaxAmount() * 100));
|
137 |
+
$lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
|
138 |
+
$lineItems[] = $lineItem;
|
139 |
+
}
|
140 |
+
|
141 |
+
// add Discount item
|
142 |
+
if ((int)$quote->getShippingAddress()->getBaseDiscountAmount() !== 0) {
|
143 |
+
$shippingItem = Mage::getModel('ewayrapid/field_lineItem');
|
144 |
+
$shippingItem->setSKU('');
|
145 |
+
$shippingItem->setDescription('Discount');
|
146 |
+
$shippingItem->setQuantity(1);
|
147 |
+
$shippingItem->setUnitCost(round($quote->getShippingAddress()->getBaseDiscountAmount() * 100));
|
148 |
+
$shippingItem->setTax(0);
|
149 |
+
$shippingItem->setTotal(round($quote->getShippingAddress()->getBaseDiscountAmount() * 100));
|
150 |
+
$lineItems[] = $shippingItem;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
return $lineItems;
|
154 |
+
}
|
155 |
+
|
156 |
+
public function checkCardName($card)
|
157 |
+
{
|
158 |
+
/* @var Eway_Rapid31_Model_Request_Token $model */
|
159 |
+
$model = Mage::getModel('ewayrapid/request_token');
|
160 |
+
return $model->checkCardName($card);
|
161 |
+
}
|
162 |
+
|
163 |
+
public function clearSessionSharedpage()
|
164 |
+
{
|
165 |
+
Mage::getSingleton('core/session')->unsetData('editToken');
|
166 |
+
Mage::getSingleton('core/session')->unsetData('newToken');
|
167 |
+
Mage::getSingleton('core/session')->unsetData('sharedpagePaypal');
|
168 |
+
}
|
169 |
+
|
170 |
+
public function limitInvoiceDescriptionLength($description)
|
171 |
+
{
|
172 |
+
if (strlen($description) > 64) {
|
173 |
+
$description = substr($description, 0, 61);
|
174 |
+
$description .= '...';
|
175 |
+
}
|
176 |
+
|
177 |
+
return $description;
|
178 |
+
}
|
179 |
+
|
180 |
+
public function getBeagleVerificationTitle($code)
|
181 |
+
{
|
182 |
+
return $this->_beagleVerificationCodes[$code];
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Get Fraud Codes from ResponseMessage
|
187 |
+
*
|
188 |
+
* @return string
|
189 |
+
*/
|
190 |
+
public function getFraudCodes($codes)
|
191 |
+
{
|
192 |
+
$codes = explode(',', $codes);
|
193 |
+
|
194 |
+
$fraudCodes = array();
|
195 |
+
|
196 |
+
foreach ($codes as $code) {
|
197 |
+
$code = trim($code);
|
198 |
+
if (substr($code, 0, 1) == "F") {
|
199 |
+
$fraudCodes[] = $code;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
return implode(',', $fraudCodes);
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Get the address block for dynamic state/country selection on forms.
|
208 |
+
*/
|
209 |
+
public function getAddressBlock()
|
210 |
+
{
|
211 |
+
if ( is_null($this->_address) ) {
|
212 |
+
$this->_address = Mage::app()->getLayout()->createBlock('directory/data');
|
213 |
+
}
|
214 |
+
|
215 |
+
return $this->_address;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Get customer country dropdown
|
220 |
+
*/
|
221 |
+
public function getCountryHtmlSelect( $name, $default='US', $id=null )
|
222 |
+
{
|
223 |
+
return $this->getAddressBlock()->getCountryHtmlSelect($default, $name, $id);
|
224 |
+
}
|
225 |
+
|
226 |
+
public function useIframeInBackend()
|
227 |
+
{
|
228 |
+
$_config = Mage::getSingleton('ewayrapid/config');
|
229 |
+
$isBackend = $this->isBackendOrder();
|
230 |
+
|
231 |
+
return $isBackend && ($_config->isSharedPageConnection() || $_config->isRapidIframeConnection());
|
232 |
+
}
|
233 |
}
|
app/code/community/Eway/Rapid31/Model/Backend/Savedtokens.php
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_Backend_Savedtokens extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Serialize array in saved_tokens field, then encrypt it and save it into saved_tokens_json attribute
|
6 |
-
*
|
7 |
-
* @param Varien_Object $object
|
8 |
-
* @return $this|Mage_Eav_Model_Entity_Attribute_Backend_Abstract
|
9 |
-
*/
|
10 |
-
public function beforeSave($object)
|
11 |
-
{
|
12 |
-
$attrCode = $this->getAttribute()->getAttributeCode();
|
13 |
-
if($object->hasData('saved_tokens') && ($savedTokens = $object->getData('saved_tokens'))) {
|
14 |
-
/* @var Eway_Rapid31_Model_Customer_Savedtokens $savedTokens */
|
15 |
-
if($savedTokens && $savedTokens instanceof Eway_Rapid31_Model_Customer_Savedtokens) {
|
16 |
-
$object->setData($attrCode, Mage::helper('core')->encrypt($savedTokens->jsonSerialize()));
|
17 |
-
}
|
18 |
-
}
|
19 |
-
|
20 |
-
return $this;
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Decrypt data in saved_tokens_json, decode it into array and set into saved_tokens field.
|
25 |
-
*
|
26 |
-
* @param Varien_Object $object
|
27 |
-
* @return $this|Mage_Eav_Model_Entity_Attribute_Backend_Abstract
|
28 |
-
*/
|
29 |
-
public function afterLoad($object)
|
30 |
-
{
|
31 |
-
$attrCode = $this->getAttribute()->getAttributeCode();
|
32 |
-
if($encryptedJson = $object->getData($attrCode)) {
|
33 |
-
$object->setData('saved_tokens', Mage::getModel('ewayrapid/customer_savedtokens')->decodeJSON(Mage::helper('core')->decrypt($encryptedJson)));
|
34 |
-
}
|
35 |
-
|
36 |
-
return $this;
|
37 |
-
}
|
38 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_Backend_Savedtokens extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Serialize array in saved_tokens field, then encrypt it and save it into saved_tokens_json attribute
|
6 |
+
*
|
7 |
+
* @param Varien_Object $object
|
8 |
+
* @return $this|Mage_Eav_Model_Entity_Attribute_Backend_Abstract
|
9 |
+
*/
|
10 |
+
public function beforeSave($object)
|
11 |
+
{
|
12 |
+
$attrCode = $this->getAttribute()->getAttributeCode();
|
13 |
+
if ($object->hasData('saved_tokens') && ($savedTokens = $object->getData('saved_tokens'))) {
|
14 |
+
/* @var Eway_Rapid31_Model_Customer_Savedtokens $savedTokens */
|
15 |
+
if ($savedTokens && $savedTokens instanceof Eway_Rapid31_Model_Customer_Savedtokens) {
|
16 |
+
$object->setData($attrCode, Mage::helper('core')->encrypt($savedTokens->jsonSerialize()));
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Decrypt data in saved_tokens_json, decode it into array and set into saved_tokens field.
|
25 |
+
*
|
26 |
+
* @param Varien_Object $object
|
27 |
+
* @return $this|Mage_Eav_Model_Entity_Attribute_Backend_Abstract
|
28 |
+
*/
|
29 |
+
public function afterLoad($object)
|
30 |
+
{
|
31 |
+
$attrCode = $this->getAttribute()->getAttributeCode();
|
32 |
+
if ($encryptedJson = $object->getData($attrCode)) {
|
33 |
+
$object->setData('saved_tokens', Mage::getModel('ewayrapid/customer_savedtokens')->decodeJSON(Mage::helper('core')->decrypt($encryptedJson)));
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
}
|
app/code/community/Eway/Rapid31/Model/Config.php
CHANGED
@@ -1,185 +1,188 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_Config
|
3 |
-
{
|
4 |
-
const MODE_SANDBOX = 'sandbox';
|
5 |
-
const MODE_LIVE = 'live';
|
6 |
-
const PAYMENT_NOT_SAVED_METHOD = 'ewayrapid_notsaved';
|
7 |
-
const PAYMENT_SAVED_METHOD = 'ewayrapid_saved';
|
8 |
-
const PAYMENT_EWAYONE_METHOD = 'ewayrapid_ewayone';
|
9 |
-
|
10 |
-
const METHOD_PROCESS_PAYMENT = 'ProcessPayment';
|
11 |
-
const METHOD_CREATE_TOKEN = 'CreateTokenCustomer';
|
12 |
-
const METHOD_UPDATE_TOKEN = 'UpdateTokenCustomer';
|
13 |
-
const METHOD_TOKEN_PAYMENT = 'TokenPayment';
|
14 |
-
const METHOD_AUTHORISE = 'Authorise';
|
15 |
-
|
16 |
-
const TRANSACTION_PURCHASE = 'Purchase';
|
17 |
-
const TRANSACTION_MOTO = 'MOTO';
|
18 |
-
const TRANSACTION_RECURRING = 'Recurring';
|
19 |
-
|
20 |
-
const CONNECTION_DIRECT = 'direct';
|
21 |
-
const CONNECTION_TRANSPARENT = 'transparent';
|
22 |
-
const CONNECTION_SHARED_PAGE = 'sharedpage';
|
23 |
-
const CONNECTION_RAPID_IFRAME = 'rapidiframe';
|
24 |
-
|
25 |
-
const CREDITCARD_METHOD = 'creditcard';
|
26 |
-
const PAYPAL_STANDARD_METHOD = 'paypal';
|
27 |
-
const PAYPAL_EXPRESS_METHOD = 'paypal_express';
|
28 |
-
const MASTERPASS_METHOD = 'masterpass';
|
29 |
-
const VISA_CHECKOUT_METHOD = 'visa';
|
30 |
-
|
31 |
-
const MESSAGE_ERROR_ORDER = 'Billing Frequency is wrong. It must be numeric and greater than 0. Status of recurring profile is changed to cancelled';
|
32 |
-
|
33 |
-
const TRANSPARENT_ACCESSCODE = 'AccessCodes';
|
34 |
-
const TRANSPARENT_ACCESSCODE_RESULT = 'AccessCode';
|
35 |
-
|
36 |
-
const ENCRYPTION_PREFIX = 'eCrypted';
|
37 |
-
const TOKEN_NEW = 'new';
|
38 |
-
|
39 |
-
const ORDER_STATUS_AUTHORISED = 'eway_authorised';
|
40 |
-
const ORDER_STATUS_CAPTURED = 'eway_captured';
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
public function __construct()
|
53 |
-
{
|
54 |
-
$this->_isSandbox = (Mage::getStoreConfig('payment/ewayrapid_general/mode') == self::MODE_SANDBOX);
|
55 |
-
$this->_isDebug = (bool) Mage::getStoreConfig('payment/ewayrapid_general/debug');
|
56 |
-
$this->_sandboxUrl = Mage::getStoreConfig('payment/ewayrapid_general/sandbox_endpoint');
|
57 |
-
$this->_liveUrl = Mage::getStoreConfig('payment/ewayrapid_general/live_endpoint');
|
58 |
-
$this->_liveApiKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/ewayrapid_general/live_api_key'));
|
59 |
-
$this->_livePassword = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/ewayrapid_general/live_api_password'));
|
60 |
-
$this->_sandboxApiKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/ewayrapid_general/sandbox_api_key'));
|
61 |
-
$this->_sandboxPassword = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/ewayrapid_general/sandbox_api_password'));
|
62 |
-
$this->_isEnableSSLVerification = Mage::getStoreConfig('payment/ewayrapid_general/ssl_verification');
|
63 |
-
}
|
64 |
-
|
65 |
-
public function isSandbox($sandbox = null)
|
66 |
-
{
|
67 |
-
if($sandbox !== null) {
|
68 |
-
$this->_isSandbox = (bool) $sandbox;
|
69 |
-
}
|
70 |
-
|
71 |
-
return $this->_isSandbox;
|
72 |
-
}
|
73 |
-
|
74 |
-
public function isDebug($debug = null)
|
75 |
-
{
|
76 |
-
if($debug !== null) {
|
77 |
-
$this->_isDebug = (bool) $debug;
|
78 |
-
}
|
79 |
-
|
80 |
-
return $this->_isDebug;
|
81 |
-
}
|
82 |
-
|
83 |
-
public function getRapidAPIUrl($action = false)
|
84 |
-
{
|
85 |
-
$url = $this->isSandbox() ? $this->_sandboxUrl : $this->_liveUrl;
|
86 |
-
$url = rtrim($url, '/') . '/';
|
87 |
-
if($action) {
|
88 |
-
$url .= $action;
|
89 |
-
}
|
90 |
-
|
91 |
-
return $url;
|
92 |
-
}
|
93 |
-
|
94 |
-
public function getBasicAuthenticationHeader()
|
95 |
-
{
|
96 |
-
return $this->isSandbox() ? $this->_sandboxApiKey . ':' . $this->_sandboxPassword
|
97 |
-
: $this->_liveApiKey . ':' . $this->_livePassword;
|
98 |
-
}
|
99 |
-
|
100 |
-
public function isEnableSSLVerification()
|
101 |
-
{
|
102 |
-
// Always return true in Live mode regardless Magento config.
|
103 |
-
return !$this->isSandbox() || $this->_isEnableSSLVerification;
|
104 |
-
}
|
105 |
-
|
106 |
-
public function getEncryptionKey()
|
107 |
-
{
|
108 |
-
return $this->isSandbox() ? Mage::getStoreConfig('payment/ewayrapid_general/sandbox_encryption_key')
|
109 |
-
: Mage::getStoreConfig('payment/ewayrapid_general/live_encryption_key');
|
110 |
-
}
|
111 |
-
|
112 |
-
public function isDirectConnection()
|
113 |
-
{
|
114 |
-
return Mage::getStoreConfig('payment/ewayrapid_general/connection_type') == self::CONNECTION_DIRECT;
|
115 |
-
}
|
116 |
-
|
117 |
-
public function isTransparentConnection()
|
118 |
-
{
|
119 |
-
return Mage::getStoreConfig('payment/ewayrapid_general/connection_type') == self::CONNECTION_TRANSPARENT;
|
120 |
-
}
|
121 |
-
|
122 |
-
public function isSharedPageConnection()
|
123 |
-
{
|
124 |
-
return Mage::getStoreConfig('payment/ewayrapid_general/connection_type') == self::CONNECTION_SHARED_PAGE;
|
125 |
-
}
|
126 |
-
|
127 |
-
public function isRapidIframeConnection()
|
128 |
-
{
|
129 |
-
return Mage::getStoreConfig('payment/ewayrapid_general/connection_type') == self::CONNECTION_RAPID_IFRAME;
|
130 |
-
}
|
131 |
-
|
132 |
-
public function canEditToken()
|
133 |
-
{
|
134 |
-
return (bool) Mage::getStoreConfig('payment/ewayrapid_general/can_edit_token');
|
135 |
-
}
|
136 |
-
|
137 |
-
public function getSupportedCardTypes()
|
138 |
-
{
|
139 |
-
return explode(',', Mage::getStoreConfig('payment/ewayrapid_general/cctypes'));
|
140 |
-
}
|
141 |
-
|
142 |
-
public function getVerifyEmail()
|
143 |
-
{
|
144 |
-
return (bool) Mage::getStoreConfig('payment/ewayrapid_general/beagle_verify_email');
|
145 |
-
}
|
146 |
-
|
147 |
-
public function getVerifyPhone()
|
148 |
-
{
|
149 |
-
return (bool) Mage::getStoreConfig('payment/ewayrapid_general/beagle_verify_phone');
|
150 |
-
}
|
151 |
-
|
152 |
-
public function getCustomView()
|
153 |
-
{
|
154 |
-
return Mage::getStoreConfig('payment/ewayrapid_general/custom_view');
|
155 |
-
}
|
156 |
-
|
157 |
-
public function shouldPassingInvoiceDescription()
|
158 |
-
{
|
159 |
-
return Mage::getStoreConfig('payment/ewayrapid_general/invoice_description');
|
160 |
-
}
|
161 |
-
|
162 |
-
public function shouldPassingGuessOrder()
|
163 |
-
{
|
164 |
-
return Mage::getStoreConfig('payment/ewayrapid_general/guess_order');
|
165 |
-
}
|
166 |
-
|
167 |
-
public function getVisaCheckoutApiKey()
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
|
|
|
|
|
|
185 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_Config
|
3 |
+
{
|
4 |
+
const MODE_SANDBOX = 'sandbox';
|
5 |
+
const MODE_LIVE = 'live';
|
6 |
+
const PAYMENT_NOT_SAVED_METHOD = 'ewayrapid_notsaved';
|
7 |
+
const PAYMENT_SAVED_METHOD = 'ewayrapid_saved';
|
8 |
+
const PAYMENT_EWAYONE_METHOD = 'ewayrapid_ewayone';
|
9 |
+
|
10 |
+
const METHOD_PROCESS_PAYMENT = 'ProcessPayment';
|
11 |
+
const METHOD_CREATE_TOKEN = 'CreateTokenCustomer';
|
12 |
+
const METHOD_UPDATE_TOKEN = 'UpdateTokenCustomer';
|
13 |
+
const METHOD_TOKEN_PAYMENT = 'TokenPayment';
|
14 |
+
const METHOD_AUTHORISE = 'Authorise';
|
15 |
+
|
16 |
+
const TRANSACTION_PURCHASE = 'Purchase';
|
17 |
+
const TRANSACTION_MOTO = 'MOTO';
|
18 |
+
const TRANSACTION_RECURRING = 'Recurring';
|
19 |
+
|
20 |
+
const CONNECTION_DIRECT = 'direct';
|
21 |
+
const CONNECTION_TRANSPARENT = 'transparent';
|
22 |
+
const CONNECTION_SHARED_PAGE = 'sharedpage';
|
23 |
+
const CONNECTION_RAPID_IFRAME = 'rapidiframe';
|
24 |
+
|
25 |
+
const CREDITCARD_METHOD = 'creditcard';
|
26 |
+
const PAYPAL_STANDARD_METHOD = 'paypal';
|
27 |
+
const PAYPAL_EXPRESS_METHOD = 'paypal_express';
|
28 |
+
const MASTERPASS_METHOD = 'masterpass';
|
29 |
+
const VISA_CHECKOUT_METHOD = 'visa';
|
30 |
+
|
31 |
+
const MESSAGE_ERROR_ORDER = 'Billing Frequency is wrong. It must be numeric and greater than 0. Status of recurring profile is changed to cancelled';
|
32 |
+
|
33 |
+
const TRANSPARENT_ACCESSCODE = 'AccessCodes';
|
34 |
+
const TRANSPARENT_ACCESSCODE_RESULT = 'AccessCode';
|
35 |
+
|
36 |
+
const ENCRYPTION_PREFIX = 'eCrypted';
|
37 |
+
const TOKEN_NEW = 'new';
|
38 |
+
|
39 |
+
const ORDER_STATUS_AUTHORISED = 'eway_authorised';
|
40 |
+
const ORDER_STATUS_CAPTURED = 'eway_captured';
|
41 |
+
|
42 |
+
protected $_isSandbox = true;
|
43 |
+
protected $_isDebug = false;
|
44 |
+
protected $_liveUrl = '';
|
45 |
+
protected $_liveApiKey = '';
|
46 |
+
protected $_livePassword = '';
|
47 |
+
protected $_sandboxUrl = '';
|
48 |
+
protected $_sandboxApiKey = '';
|
49 |
+
protected $_sandboxPassword = '';
|
50 |
+
protected $_isEnableSSLVerification = false;
|
51 |
+
|
52 |
+
public function __construct()
|
53 |
+
{
|
54 |
+
$this->_isSandbox = (Mage::getStoreConfig('payment/ewayrapid_general/mode') == self::MODE_SANDBOX);
|
55 |
+
$this->_isDebug = (bool) Mage::getStoreConfig('payment/ewayrapid_general/debug');
|
56 |
+
$this->_sandboxUrl = Mage::getStoreConfig('payment/ewayrapid_general/sandbox_endpoint');
|
57 |
+
$this->_liveUrl = Mage::getStoreConfig('payment/ewayrapid_general/live_endpoint');
|
58 |
+
$this->_liveApiKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/ewayrapid_general/live_api_key'));
|
59 |
+
$this->_livePassword = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/ewayrapid_general/live_api_password'));
|
60 |
+
$this->_sandboxApiKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/ewayrapid_general/sandbox_api_key'));
|
61 |
+
$this->_sandboxPassword = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/ewayrapid_general/sandbox_api_password'));
|
62 |
+
$this->_isEnableSSLVerification = Mage::getStoreConfig('payment/ewayrapid_general/ssl_verification');
|
63 |
+
}
|
64 |
+
|
65 |
+
public function isSandbox($sandbox = null)
|
66 |
+
{
|
67 |
+
if ($sandbox !== null) {
|
68 |
+
$this->_isSandbox = (bool) $sandbox;
|
69 |
+
}
|
70 |
+
|
71 |
+
return $this->_isSandbox;
|
72 |
+
}
|
73 |
+
|
74 |
+
public function isDebug($debug = null)
|
75 |
+
{
|
76 |
+
if ($debug !== null) {
|
77 |
+
$this->_isDebug = (bool) $debug;
|
78 |
+
}
|
79 |
+
|
80 |
+
return $this->_isDebug;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getRapidAPIUrl($action = false)
|
84 |
+
{
|
85 |
+
$url = $this->isSandbox() ? $this->_sandboxUrl : $this->_liveUrl;
|
86 |
+
$url = rtrim($url, '/') . '/';
|
87 |
+
if ($action) {
|
88 |
+
$url .= $action;
|
89 |
+
}
|
90 |
+
|
91 |
+
return $url;
|
92 |
+
}
|
93 |
+
|
94 |
+
public function getBasicAuthenticationHeader()
|
95 |
+
{
|
96 |
+
return $this->isSandbox() ? $this->_sandboxApiKey . ':' . $this->_sandboxPassword
|
97 |
+
: $this->_liveApiKey . ':' . $this->_livePassword;
|
98 |
+
}
|
99 |
+
|
100 |
+
public function isEnableSSLVerification()
|
101 |
+
{
|
102 |
+
// Always return true in Live mode regardless Magento config.
|
103 |
+
return !$this->isSandbox() || $this->_isEnableSSLVerification;
|
104 |
+
}
|
105 |
+
|
106 |
+
public function getEncryptionKey()
|
107 |
+
{
|
108 |
+
return $this->isSandbox() ? Mage::getStoreConfig('payment/ewayrapid_general/sandbox_encryption_key')
|
109 |
+
: Mage::getStoreConfig('payment/ewayrapid_general/live_encryption_key');
|
110 |
+
}
|
111 |
+
|
112 |
+
public function isDirectConnection()
|
113 |
+
{
|
114 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/connection_type') == self::CONNECTION_DIRECT;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function isTransparentConnection()
|
118 |
+
{
|
119 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/connection_type') == self::CONNECTION_TRANSPARENT;
|
120 |
+
}
|
121 |
+
|
122 |
+
public function isSharedPageConnection()
|
123 |
+
{
|
124 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/connection_type') == self::CONNECTION_SHARED_PAGE;
|
125 |
+
}
|
126 |
+
|
127 |
+
public function isRapidIframeConnection()
|
128 |
+
{
|
129 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/connection_type') == self::CONNECTION_RAPID_IFRAME;
|
130 |
+
}
|
131 |
+
|
132 |
+
public function canEditToken()
|
133 |
+
{
|
134 |
+
return (bool) Mage::getStoreConfig('payment/ewayrapid_general/can_edit_token');
|
135 |
+
}
|
136 |
+
|
137 |
+
public function getSupportedCardTypes()
|
138 |
+
{
|
139 |
+
return explode(',', Mage::getStoreConfig('payment/ewayrapid_general/cctypes'));
|
140 |
+
}
|
141 |
+
|
142 |
+
public function getVerifyEmail()
|
143 |
+
{
|
144 |
+
return (bool) Mage::getStoreConfig('payment/ewayrapid_general/beagle_verify_email');
|
145 |
+
}
|
146 |
+
|
147 |
+
public function getVerifyPhone()
|
148 |
+
{
|
149 |
+
return (bool) Mage::getStoreConfig('payment/ewayrapid_general/beagle_verify_phone');
|
150 |
+
}
|
151 |
+
|
152 |
+
public function getCustomView()
|
153 |
+
{
|
154 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/custom_view');
|
155 |
+
}
|
156 |
+
|
157 |
+
public function shouldPassingInvoiceDescription()
|
158 |
+
{
|
159 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/invoice_description');
|
160 |
+
}
|
161 |
+
|
162 |
+
public function shouldPassingGuessOrder()
|
163 |
+
{
|
164 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/guess_order');
|
165 |
+
}
|
166 |
+
|
167 |
+
public function getVisaCheckoutApiKey()
|
168 |
+
{
|
169 |
+
return Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/ewayrapid_general/visa_checkout_api_key'));
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getVisaCheckoutEnable()
|
173 |
+
{
|
174 |
+
return Mage::getStoreConfig('payment/ewayrapid_general/enable_visa_checkout')
|
175 |
+
&& Mage::getStoreConfig('payment/ewayrapid_general/visa_checkout_api_key') != '';
|
176 |
+
}
|
177 |
+
|
178 |
+
public function getVisaCheckoutSDK()
|
179 |
+
{
|
180 |
+
if (!$this->getVisaCheckoutEnable()) {
|
181 |
+
return false;
|
182 |
+
} else {
|
183 |
+
return $this->_isSandbox
|
184 |
+
? 'https://sandbox-assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js'
|
185 |
+
: 'https://assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js';
|
186 |
+
}
|
187 |
+
}
|
188 |
}
|
app/code/community/Eway/Rapid31/Model/Customer/Savedtokens.php
CHANGED
@@ -1,91 +1,93 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Eway_Rapid31_Model_Customer_Savedtokens
|
5 |
-
*
|
6 |
-
*
|
7 |
-
* @method int getLastId()
|
8 |
-
* @method Eway_Rapid31_Model_Customer_Savedtokens setLastId(int $value)
|
9 |
-
* @method int getDefaultToken()
|
10 |
-
* @method Eway_Rapid31_Model_Customer_Savedtokens setDefaultToken(int $value)
|
11 |
-
* @method array getTokens()
|
12 |
-
* @method Eway_Rapid31_Model_Customer_Savedtokens setTokens(array $value)
|
13 |
-
*/
|
14 |
-
class Eway_Rapid31_Model_Customer_Savedtokens extends Eway_Rapid31_Model_JsonSerializableAbstract
|
15 |
-
{
|
16 |
-
protected function _construct()
|
17 |
-
{
|
18 |
-
$this->setLastId(0);
|
19 |
-
$this->setTokens(array());
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @param $json string|array
|
24 |
-
* @return $this
|
25 |
-
*/
|
26 |
-
public function decodeJSON($json)
|
27 |
-
{
|
28 |
-
if(is_string($json)) {
|
29 |
-
$json = json_decode($json, true);
|
30 |
-
}
|
31 |
-
/*
|
32 |
-
$json = array(
|
33 |
-
'LastId' => <last token id>
|
34 |
-
'DefaultToken' => <default token id>
|
35 |
-
'Tokens' => array(
|
36 |
-
<token id> => array(
|
37 |
-
'Token' => <eWAY customer token>,
|
38 |
-
'Card' => <masked card number>,
|
39 |
-
'Type' => <credit card type, e.g: VI, MA>
|
40 |
-
'Owner' => <owner>,
|
41 |
-
'ExpMonth' => <expired month>,
|
42 |
-
'ExpYear' => <expired year>,
|
43 |
-
'Active' => 0 | 1,
|
44 |
-
'Address' => array(
|
45 |
-
'FirstName' => <first name>
|
46 |
-
...
|
47 |
-
)
|
48 |
-
),
|
49 |
-
)
|
50 |
-
)
|
51 |
-
*/
|
52 |
-
|
53 |
-
$this->addData($json);
|
54 |
-
$tokens = $this->getTokens();
|
55 |
-
if(is_array($tokens)) {
|
56 |
-
foreach($tokens as $id => $token) {
|
57 |
-
$tokenModel = Mage::getModel('ewayrapid/customer_token')->addData($token);
|
58 |
-
/* @var Eway_Rapid31_Model_Customer_Token $tokenModel */
|
59 |
-
if($address = $tokenModel->getAddress()) {
|
60 |
-
$tokenModel->setAddress(Mage::getModel('ewayrapid/field_customer')->addData($address));
|
61 |
-
}
|
62 |
-
$tokens[$id] = $tokenModel;
|
63 |
-
}
|
64 |
-
|
65 |
-
$this->setTokens($tokens);
|
66 |
-
}
|
67 |
-
|
68 |
-
return $this;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* @param $id
|
73 |
-
* @return Eway_Rapid31_Model_Customer_Token
|
74 |
-
*/
|
75 |
-
public function getTokenById($id)
|
76 |
-
{
|
77 |
-
if(($tokens = $this->getTokens())
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
}
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
$
|
89 |
-
$this->
|
90 |
-
|
|
|
|
|
91 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Eway_Rapid31_Model_Customer_Savedtokens
|
5 |
+
*
|
6 |
+
*
|
7 |
+
* @method int getLastId()
|
8 |
+
* @method Eway_Rapid31_Model_Customer_Savedtokens setLastId(int $value)
|
9 |
+
* @method int getDefaultToken()
|
10 |
+
* @method Eway_Rapid31_Model_Customer_Savedtokens setDefaultToken(int $value)
|
11 |
+
* @method array getTokens()
|
12 |
+
* @method Eway_Rapid31_Model_Customer_Savedtokens setTokens(array $value)
|
13 |
+
*/
|
14 |
+
class Eway_Rapid31_Model_Customer_Savedtokens extends Eway_Rapid31_Model_JsonSerializableAbstract
|
15 |
+
{
|
16 |
+
protected function _construct()
|
17 |
+
{
|
18 |
+
$this->setLastId(0);
|
19 |
+
$this->setTokens(array());
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param $json string|array
|
24 |
+
* @return $this
|
25 |
+
*/
|
26 |
+
public function decodeJSON($json)
|
27 |
+
{
|
28 |
+
if (is_string($json)) {
|
29 |
+
$json = json_decode($json, true);
|
30 |
+
}
|
31 |
+
/*
|
32 |
+
$json = array(
|
33 |
+
'LastId' => <last token id>
|
34 |
+
'DefaultToken' => <default token id>
|
35 |
+
'Tokens' => array(
|
36 |
+
<token id> => array(
|
37 |
+
'Token' => <eWAY customer token>,
|
38 |
+
'Card' => <masked card number>,
|
39 |
+
'Type' => <credit card type, e.g: VI, MA>
|
40 |
+
'Owner' => <owner>,
|
41 |
+
'ExpMonth' => <expired month>,
|
42 |
+
'ExpYear' => <expired year>,
|
43 |
+
'Active' => 0 | 1,
|
44 |
+
'Address' => array(
|
45 |
+
'FirstName' => <first name>
|
46 |
+
...
|
47 |
+
)
|
48 |
+
),
|
49 |
+
)
|
50 |
+
)
|
51 |
+
*/
|
52 |
+
|
53 |
+
$this->addData($json);
|
54 |
+
$tokens = $this->getTokens();
|
55 |
+
if (is_array($tokens)) {
|
56 |
+
foreach ($tokens as $id => $token) {
|
57 |
+
$tokenModel = Mage::getModel('ewayrapid/customer_token')->addData($token);
|
58 |
+
/* @var Eway_Rapid31_Model_Customer_Token $tokenModel */
|
59 |
+
if ($address = $tokenModel->getAddress()) {
|
60 |
+
$tokenModel->setAddress(Mage::getModel('ewayrapid/field_customer')->addData($address));
|
61 |
+
}
|
62 |
+
$tokens[$id] = $tokenModel;
|
63 |
+
}
|
64 |
+
|
65 |
+
$this->setTokens($tokens);
|
66 |
+
}
|
67 |
+
|
68 |
+
return $this;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @param $id
|
73 |
+
* @return Eway_Rapid31_Model_Customer_Token
|
74 |
+
*/
|
75 |
+
public function getTokenById($id)
|
76 |
+
{
|
77 |
+
if (($tokens = $this->getTokens())
|
78 |
+
&& isset($tokens[$id])
|
79 |
+
&& $tokens[$id] instanceof Eway_Rapid31_Model_Customer_Token) {
|
80 |
+
return $tokens[$id];
|
81 |
+
} else {
|
82 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('Customer token does not exist.'));
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
public function addToken($info)
|
87 |
+
{
|
88 |
+
$this->setLastId($this->getLastId() + 1);
|
89 |
+
$tokens = $this->getTokens();
|
90 |
+
$tokens[$this->getLastId()] = Mage::getModel('ewayrapid/customer_token')->addData($info)->setActive(1);
|
91 |
+
$this->setTokens($tokens);
|
92 |
+
}
|
93 |
}
|
app/code/community/Eway/Rapid31/Model/EwayCron.php
CHANGED
@@ -1,132 +1,139 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*/
|
5 |
-
class Eway_Rapid31_Model_EwayCron
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
->addFieldToFilter('
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
//
|
41 |
-
$this->
|
42 |
-
//
|
43 |
-
$this->
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
curl_setopt($ch,
|
60 |
-
curl_setopt($ch,
|
61 |
-
|
62 |
-
|
63 |
-
$
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
$trans
|
88 |
-
|
89 |
-
$
|
90 |
-
|
91 |
-
$trans->
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
$trans->
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
$
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
class Eway_Rapid31_Model_EwayCron
|
6 |
+
{
|
7 |
+
|
8 |
+
public function querySuspectFraud()
|
9 |
+
{
|
10 |
+
|
11 |
+
// Load orders with fraud in 7 days before from now
|
12 |
+
$orders = Mage::getModel('sales/order')->getCollection()
|
13 |
+
->addFieldToFilter('status', array('eq' => 'fraud')) // State fraud
|
14 |
+
->addFieldToFilter('eway_transaction_id', array('notnull' => ''))
|
15 |
+
->addFieldToFilter('created_at', array('to' => date('Y-m-d 23:59:59'), 'from' => date('Y-m-d 00:00:01', strtotime('-7 days'))));
|
16 |
+
|
17 |
+
foreach ($orders as $o) {
|
18 |
+
$transactionId = $o->getEwayTransactionId();
|
19 |
+
|
20 |
+
// continue when order does not contain eway transaction
|
21 |
+
if (!$transactionId) {
|
22 |
+
continue;
|
23 |
+
}
|
24 |
+
$result = $this->__getTransaction($transactionId);
|
25 |
+
$resultDecode = json_decode($result);
|
26 |
+
// continue when property transaction is not exist
|
27 |
+
if (!property_exists($resultDecode, 'Transactions') || empty($resultDecode->Transactions)) {
|
28 |
+
continue;
|
29 |
+
}
|
30 |
+
$trans = $resultDecode->Transactions;
|
31 |
+
|
32 |
+
// continue when transaction is not exits
|
33 |
+
if (!isset($trans[0])) {
|
34 |
+
continue;
|
35 |
+
}
|
36 |
+
$tranId = $trans[0]->TransactionID;
|
37 |
+
|
38 |
+
// Success - Fraud order has been approved
|
39 |
+
if ($trans[0]->ResponseMessage == 'A2000') {
|
40 |
+
// Create new transaction
|
41 |
+
$this->__createNewTransaction($o, $tranId);
|
42 |
+
// Update order status
|
43 |
+
$this->__updateStatusOrder($o);
|
44 |
+
// Un-mark fraud customer
|
45 |
+
$this->__unMarkFraudUser($o);
|
46 |
+
}
|
47 |
+
}
|
48 |
+
// Response data to client
|
49 |
+
/*$this->getResponse()->setHeader('Content-type', 'application/json');
|
50 |
+
$this->getResponse()->setBody($result);*/
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function __getTransaction($transId)
|
54 |
+
{
|
55 |
+
$ewayConfig = Mage::getSingleton('ewayrapid/config');
|
56 |
+
$url = $ewayConfig->getRapidAPIUrl('Transaction') . '/' . $transId;
|
57 |
+
$ch = curl_init($url);
|
58 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));
|
59 |
+
curl_setopt($ch, CURLOPT_USERPWD, $ewayConfig->getBasicAuthenticationHeader());
|
60 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
|
61 |
+
|
62 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
63 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
64 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $ewayConfig->isEnableSSLVerification());
|
65 |
+
|
66 |
+
$result = curl_exec($ch);
|
67 |
+
return $result;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Re-create order with new transaction returned by Eway
|
72 |
+
* @param $data
|
73 |
+
*/
|
74 |
+
protected function __createNewTransaction(Mage_Sales_Model_Order $order, $transId)
|
75 |
+
{
|
76 |
+
|
77 |
+
// Load transaction
|
78 |
+
$currentTrans = Mage::getModel('sales/order_payment_transaction')
|
79 |
+
->getCollection()
|
80 |
+
->addFieldToFilter('order_id', array('eq' => $order->getEntityId()));
|
81 |
+
foreach ($currentTrans as $t) {
|
82 |
+
}
|
83 |
+
if ($t == null) {
|
84 |
+
$t = new Mage_Sales_Model_Order_Payment_Transaction();
|
85 |
+
}
|
86 |
+
|
87 |
+
$trans = new Mage_Sales_Model_Order_Payment_Transaction();
|
88 |
+
// Load payment object
|
89 |
+
$payment = Mage::getModel('sales/order_payment')->load($t->getPaymentId());
|
90 |
+
|
91 |
+
$trans->setOrderPaymentObject($payment);
|
92 |
+
$trans->setOrder($order);
|
93 |
+
|
94 |
+
$trans->setParentId($t->getTransactionId());
|
95 |
+
$trans->setOrderId($order->getEntityId());
|
96 |
+
$trans->setPaymentId($t->getPaymentId());
|
97 |
+
// Get new TxnId
|
98 |
+
$break = true;
|
99 |
+
for ($i = 0; $i < 100; $i++) {
|
100 |
+
$transId ++;
|
101 |
+
$newTrans = Mage::getModel('sales/order_payment_transaction')
|
102 |
+
->getCollection()
|
103 |
+
->addFieldToFilter('txn_id', array('eq' => $transId));
|
104 |
+
if (count($newTrans) == 0) {
|
105 |
+
$break = false;
|
106 |
+
break;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
if ($break) {
|
110 |
+
return false;
|
111 |
+
}
|
112 |
+
$trans->setTxnId($transId);
|
113 |
+
$trans->setParentTxnId($t->getTxnId());
|
114 |
+
$trans->setTxnType($t->getTxnType());
|
115 |
+
$trans->setIsClosed($t->getIsClosed());
|
116 |
+
$trans->setCreatedAt(date('Y-m-d H:i:s'));
|
117 |
+
$trans->save();
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
protected function __updateStatusOrder(Mage_Sales_Model_Order $order)
|
122 |
+
{
|
123 |
+
$stateConfig = Mage::getStoreConfig('payment/ewayrapid_general/verify_eway_order');
|
124 |
+
|
125 |
+
$order->setState($stateConfig);
|
126 |
+
$order->setStatus($stateConfig);
|
127 |
+
$order->save();
|
128 |
+
}
|
129 |
+
|
130 |
+
protected function __unMarkFraudUser(Mage_Sales_Model_Order $order)
|
131 |
+
{
|
132 |
+
$uid = $order->getCustomerId();
|
133 |
+
if ($uid) {
|
134 |
+
$customer = Mage::getModel('customer/customer')->load($uid);
|
135 |
+
$customer->setMarkFraud(0);
|
136 |
+
$customer->save();
|
137 |
+
}
|
138 |
+
}
|
139 |
}
|
app/code/community/Eway/Rapid31/Model/Field/CardDetails.php
CHANGED
@@ -1,90 +1,90 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Eway_Rapid31_Model_Field_CardDetails
|
5 |
-
*
|
6 |
-
* @method string getName()
|
7 |
-
* @method Eway_Rapid31_Model_Field_CardDetails setName(string $value)
|
8 |
-
* @method Eway_Rapid31_Model_Field_CardDetails setNumber(string $value)
|
9 |
-
* @method string getStartMonth()
|
10 |
-
* @method Eway_Rapid31_Model_Field_CardDetails setStartMonth(string $value)
|
11 |
-
* @method string getStartYear()
|
12 |
-
* @method string getExpiryMonth()
|
13 |
-
* @method string getExpiryYear()
|
14 |
-
* @method Eway_Rapid31_Model_Field_CardDetails setStartYear(string $value)
|
15 |
-
* @method string getIssueNumber()
|
16 |
-
* @method Eway_Rapid31_Model_Field_CardDetails setIssueNumber(string $value)
|
17 |
-
* @method Eway_Rapid31_Model_Field_CardDetails setCVN(string $value)
|
18 |
-
*/
|
19 |
-
class Eway_Rapid31_Model_Field_CardDetails extends Eway_Rapid31_Model_JsonSerializableAbstract
|
20 |
-
{
|
21 |
-
protected $_shouldMasked = false;
|
22 |
-
|
23 |
-
public function shouldBeMasked($value = true)
|
24 |
-
{
|
25 |
-
$this->_shouldMasked = $value;
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getJsonData(array $rawData = null)
|
29 |
-
{
|
30 |
-
$jsonData = parent::getJsonData($rawData);
|
31 |
-
// Mask sensitive data in necessary
|
32 |
-
if($this->_shouldMasked) {
|
33 |
-
if(!empty($jsonData['Number'])) {
|
34 |
-
if(strlen($jsonData['Number']) > 19) {
|
35 |
-
$jsonData['Number'] = '*** Encrypted ***';
|
36 |
-
} else {
|
37 |
-
$jsonData['Number'] = substr_replace($this->_data['Number'], '******', 6, 6);
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
if(!empty($this->_data['CVN'])) {
|
42 |
-
$jsonData['CVN'] = '***';
|
43 |
-
}
|
44 |
-
if(!empty($this->_data['ExpiryMonth'])) {
|
45 |
-
$jsonData['ExpiryMonth'] = '**';
|
46 |
-
}
|
47 |
-
if(!empty($this->_data['ExpiryYear'])) {
|
48 |
-
$jsonData['ExpiryYear'] = '**';
|
49 |
-
}
|
50 |
-
|
51 |
-
if(!empty($this->_data['StartMonth'])) {
|
52 |
-
$jsonData['StartMonth'] = '**';
|
53 |
-
}
|
54 |
-
if(!empty($this->_data['StartYear'])) {
|
55 |
-
$jsonData['StartYear'] = '**';
|
56 |
-
}
|
57 |
-
if(!empty($this->_data['IssueNumber'])) {
|
58 |
-
$jsonData['IssueNumber'] = '***';
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
return $jsonData;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Normalize data to compatible with eWAY API
|
67 |
-
*
|
68 |
-
* @param $value
|
69 |
-
* @return $this
|
70 |
-
*/
|
71 |
-
public function setExpiryMonth($value)
|
72 |
-
{
|
73 |
-
$value = (string) ($value < 10 ? '0' . $value : $value);
|
74 |
-
$this->setData('ExpiryMonth', $value);
|
75 |
-
return $this;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Normalize data to compatible with eWAY API
|
80 |
-
*
|
81 |
-
* @param $value
|
82 |
-
* @return $this
|
83 |
-
*/
|
84 |
-
public function setExpiryYear($value)
|
85 |
-
{
|
86 |
-
$value = substr((string)$value, -2);
|
87 |
-
$this->setData('ExpiryYear', $value);
|
88 |
-
return $this;
|
89 |
-
}
|
90 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Eway_Rapid31_Model_Field_CardDetails
|
5 |
+
*
|
6 |
+
* @method string getName()
|
7 |
+
* @method Eway_Rapid31_Model_Field_CardDetails setName(string $value)
|
8 |
+
* @method Eway_Rapid31_Model_Field_CardDetails setNumber(string $value)
|
9 |
+
* @method string getStartMonth()
|
10 |
+
* @method Eway_Rapid31_Model_Field_CardDetails setStartMonth(string $value)
|
11 |
+
* @method string getStartYear()
|
12 |
+
* @method string getExpiryMonth()
|
13 |
+
* @method string getExpiryYear()
|
14 |
+
* @method Eway_Rapid31_Model_Field_CardDetails setStartYear(string $value)
|
15 |
+
* @method string getIssueNumber()
|
16 |
+
* @method Eway_Rapid31_Model_Field_CardDetails setIssueNumber(string $value)
|
17 |
+
* @method Eway_Rapid31_Model_Field_CardDetails setCVN(string $value)
|
18 |
+
*/
|
19 |
+
class Eway_Rapid31_Model_Field_CardDetails extends Eway_Rapid31_Model_JsonSerializableAbstract
|
20 |
+
{
|
21 |
+
protected $_shouldMasked = false;
|
22 |
+
|
23 |
+
public function shouldBeMasked($value = true)
|
24 |
+
{
|
25 |
+
$this->_shouldMasked = $value;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getJsonData(array $rawData = null)
|
29 |
+
{
|
30 |
+
$jsonData = parent::getJsonData($rawData);
|
31 |
+
// Mask sensitive data in necessary
|
32 |
+
if ($this->_shouldMasked) {
|
33 |
+
if (!empty($jsonData['Number'])) {
|
34 |
+
if (strlen($jsonData['Number']) > 19) {
|
35 |
+
$jsonData['Number'] = '*** Encrypted ***';
|
36 |
+
} else {
|
37 |
+
$jsonData['Number'] = substr_replace($this->_data['Number'], '******', 6, 6);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
if (!empty($this->_data['CVN'])) {
|
42 |
+
$jsonData['CVN'] = '***';
|
43 |
+
}
|
44 |
+
if (!empty($this->_data['ExpiryMonth'])) {
|
45 |
+
$jsonData['ExpiryMonth'] = '**';
|
46 |
+
}
|
47 |
+
if (!empty($this->_data['ExpiryYear'])) {
|
48 |
+
$jsonData['ExpiryYear'] = '**';
|
49 |
+
}
|
50 |
+
|
51 |
+
if (!empty($this->_data['StartMonth'])) {
|
52 |
+
$jsonData['StartMonth'] = '**';
|
53 |
+
}
|
54 |
+
if (!empty($this->_data['StartYear'])) {
|
55 |
+
$jsonData['StartYear'] = '**';
|
56 |
+
}
|
57 |
+
if (!empty($this->_data['IssueNumber'])) {
|
58 |
+
$jsonData['IssueNumber'] = '***';
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
return $jsonData;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Normalize data to compatible with eWAY API
|
67 |
+
*
|
68 |
+
* @param $value
|
69 |
+
* @return $this
|
70 |
+
*/
|
71 |
+
public function setExpiryMonth($value)
|
72 |
+
{
|
73 |
+
$value = (string) ($value < 10 ? '0' . $value : $value);
|
74 |
+
$this->setData('ExpiryMonth', $value);
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Normalize data to compatible with eWAY API
|
80 |
+
*
|
81 |
+
* @param $value
|
82 |
+
* @return $this
|
83 |
+
*/
|
84 |
+
public function setExpiryYear($value)
|
85 |
+
{
|
86 |
+
$value = substr((string)$value, -2);
|
87 |
+
$this->setData('ExpiryYear', $value);
|
88 |
+
return $this;
|
89 |
+
}
|
90 |
}
|
app/code/community/Eway/Rapid31/Model/JsonSerializableAbstract.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
abstract class Eway_Rapid31_Model_JsonSerializableAbstract extends Varien_Object implements Eway_Rapid31_Model_JsonSerializable
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Recursively serialize json for all value in _data array in Varien_Object
|
6 |
-
*
|
7 |
-
* @param array $rawData
|
8 |
-
* @return array
|
9 |
-
*/
|
10 |
-
public function getJsonData(array $rawData = null)
|
11 |
-
{
|
12 |
-
if($rawData === null) {
|
13 |
-
$rawData = $this->_data;
|
14 |
-
}
|
15 |
-
|
16 |
-
$jsonData = array();
|
17 |
-
foreach ($rawData as $key => $value) {
|
18 |
-
if (is_scalar($value)) {
|
19 |
-
$jsonData[$key] = $value;
|
20 |
-
} elseif (is_array($value)) {
|
21 |
-
$jsonData[$key] = $this->getJsonData($value);
|
22 |
-
} elseif (is_object($value) && $value instanceof Eway_Rapid31_Model_JsonSerializable) {
|
23 |
-
$jsonData[$key] = $value->getJsonData();
|
24 |
-
}
|
25 |
-
}
|
26 |
-
|
27 |
-
return $jsonData;
|
28 |
-
}
|
29 |
-
|
30 |
-
public function jsonSerialize()
|
31 |
-
{
|
32 |
-
return json_encode($this->getJsonData());
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Override Varien_Object::_underscore() to prevent transform of field name.
|
37 |
-
*
|
38 |
-
* @param string $name
|
39 |
-
* @return string
|
40 |
-
*/
|
41 |
-
protected function _underscore($name)
|
42 |
-
{
|
43 |
-
return $name;
|
44 |
-
}
|
45 |
}
|
1 |
+
<?php
|
2 |
+
abstract class Eway_Rapid31_Model_JsonSerializableAbstract extends Varien_Object implements Eway_Rapid31_Model_JsonSerializable
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Recursively serialize json for all value in _data array in Varien_Object
|
6 |
+
*
|
7 |
+
* @param array $rawData
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function getJsonData(array $rawData = null)
|
11 |
+
{
|
12 |
+
if ($rawData === null) {
|
13 |
+
$rawData = $this->_data;
|
14 |
+
}
|
15 |
+
|
16 |
+
$jsonData = array();
|
17 |
+
foreach ($rawData as $key => $value) {
|
18 |
+
if (is_scalar($value)) {
|
19 |
+
$jsonData[$key] = $value;
|
20 |
+
} elseif (is_array($value)) {
|
21 |
+
$jsonData[$key] = $this->getJsonData($value);
|
22 |
+
} elseif (is_object($value) && $value instanceof Eway_Rapid31_Model_JsonSerializable) {
|
23 |
+
$jsonData[$key] = $value->getJsonData();
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
return $jsonData;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function jsonSerialize()
|
31 |
+
{
|
32 |
+
return json_encode($this->getJsonData());
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Override Varien_Object::_underscore() to prevent transform of field name.
|
37 |
+
*
|
38 |
+
* @param string $name
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
protected function _underscore($name)
|
42 |
+
{
|
43 |
+
return $name;
|
44 |
+
}
|
45 |
}
|
app/code/community/Eway/Rapid31/Model/Method/Ewayone.php
CHANGED
@@ -1,433 +1,432 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_Method_Ewayone extends Eway_Rapid31_Model_Method_Notsaved implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
3 |
-
{
|
4 |
-
protected $_code = 'ewayrapid_ewayone';
|
5 |
-
|
6 |
-
protected $_formBlockType = 'ewayrapid/form_direct_ewayone';
|
7 |
-
protected $_infoBlockType = 'ewayrapid/info_direct_ewayone';
|
8 |
-
protected $_canCapturePartial = true;
|
9 |
-
protected $_billing = null;
|
10 |
-
|
11 |
-
public function __construct()
|
12 |
-
{
|
13 |
-
parent::__construct();
|
14 |
-
if (!$this->_isBackendOrder) {
|
15 |
-
if (!Mage::helper('ewayrapid')->isBackendOrder()) {
|
16 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
17 |
-
$this->_infoBlockType = 'ewayrapid/info_transparent_ewayone';
|
18 |
-
$this->_formBlockType = 'ewayrapid/form_transparent_ewayone';
|
19 |
-
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
20 |
-
$this->_infoBlockType = 'ewayrapid/info_sharedpage_ewayone';
|
21 |
-
$this->_formBlockType = 'ewayrapid/form_sharedpage_ewayone';
|
22 |
-
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME) {
|
23 |
-
$this->_infoBlockType = 'ewayrapid/info_sharedpage_ewayone';
|
24 |
-
$this->_formBlockType = 'ewayrapid/form_sharedpage_ewayone';
|
25 |
-
}
|
26 |
-
}
|
27 |
-
}
|
28 |
-
|
29 |
-
if ($this->_isBackendOrder) {
|
30 |
-
if (Mage::helper('ewayrapid')->isBackendOrder()) {
|
31 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
*
|
44 |
-
*
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
*
|
54 |
-
*
|
55 |
-
* @
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
Mage::
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
$info->
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
&& $data->
|
140 |
-
&&
|
141 |
-
&&
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
$
|
165 |
-
|
166 |
-
|
167 |
-
unset($
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
->
|
176 |
-
->
|
177 |
-
->
|
178 |
-
->
|
179 |
-
->
|
180 |
-
->
|
181 |
-
|
182 |
-
)
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
->
|
188 |
-
->
|
189 |
-
->
|
190 |
-
->
|
191 |
-
->
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
*
|
202 |
-
*
|
203 |
-
* @
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
return $this;
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Authorize & Capture a payment
|
219 |
-
*
|
220 |
-
* @param Varien_Object $payment
|
221 |
-
* @param float $amount
|
222 |
-
*
|
223 |
-
* @return Mage_Payment_Model_Abstract
|
224 |
-
*/
|
225 |
-
public function capture(Varien_Object $payment, $amount)
|
226 |
-
{
|
227 |
-
if (!$this->_isPreauthCapture($payment) && (
|
228 |
-
$this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
229 |
-
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME)) {
|
230 |
-
$transID = Mage::getSingleton('core/session')->getData('ewayTransactionID');
|
231 |
-
$payment->setTransactionId($transID);
|
232 |
-
$payment->setIsTransactionClosed(0);
|
233 |
-
Mage::getSingleton('core/session')->unsetData('ewayTransactionID');
|
234 |
-
return $this;
|
235 |
-
} elseif (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT ) {
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
$info
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
$previousCapture
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
$
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
*
|
289 |
-
*
|
290 |
-
* @param
|
291 |
-
*
|
292 |
-
*
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
$
|
299 |
-
$payment->
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
$request = Mage::getModel('ewayrapid/
|
321 |
-
}
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
$
|
349 |
-
|
350 |
-
$info
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
}
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
*
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
*
|
384 |
-
*
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
$profile->
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
*
|
397 |
-
*
|
398 |
-
* @param
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
*
|
416 |
-
*
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
*
|
426 |
-
*
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
}
|
433 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_Method_Ewayone extends Eway_Rapid31_Model_Method_Notsaved implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
3 |
+
{
|
4 |
+
protected $_code = 'ewayrapid_ewayone';
|
5 |
+
|
6 |
+
protected $_formBlockType = 'ewayrapid/form_direct_ewayone';
|
7 |
+
protected $_infoBlockType = 'ewayrapid/info_direct_ewayone';
|
8 |
+
protected $_canCapturePartial = true;
|
9 |
+
protected $_billing = null;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
if (!$this->_isBackendOrder) {
|
15 |
+
if (!Mage::helper('ewayrapid')->isBackendOrder()) {
|
16 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
17 |
+
$this->_infoBlockType = 'ewayrapid/info_transparent_ewayone';
|
18 |
+
$this->_formBlockType = 'ewayrapid/form_transparent_ewayone';
|
19 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
20 |
+
$this->_infoBlockType = 'ewayrapid/info_sharedpage_ewayone';
|
21 |
+
$this->_formBlockType = 'ewayrapid/form_sharedpage_ewayone';
|
22 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME) {
|
23 |
+
$this->_infoBlockType = 'ewayrapid/info_sharedpage_ewayone';
|
24 |
+
$this->_formBlockType = 'ewayrapid/form_sharedpage_ewayone';
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
if ($this->_isBackendOrder) {
|
30 |
+
if (Mage::helper('ewayrapid')->isBackendOrder()) {
|
31 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
32 |
+
$this->_formBlockType = 'ewayrapid/form_sharedpage_ewayone';
|
33 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME) {
|
34 |
+
$this->_formBlockType = 'ewayrapid/form_sharedpage_ewayone';
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Use the grandparent isAvailable
|
42 |
+
*
|
43 |
+
* @param Mage_Sales_Model_Quote|null $quote
|
44 |
+
* @return boolean
|
45 |
+
*/
|
46 |
+
public function isAvailable($quote = null)
|
47 |
+
{
|
48 |
+
return Mage_Payment_Model_Method_Abstract::isAvailable($quote);
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Assign data to info model instance
|
53 |
+
*
|
54 |
+
* @param mixed $data
|
55 |
+
* @return Mage_Payment_Model_Info
|
56 |
+
*/
|
57 |
+
public function assignData($data)
|
58 |
+
{
|
59 |
+
if (!($data instanceof Varien_Object)) {
|
60 |
+
$data = new Varien_Object($data);
|
61 |
+
}
|
62 |
+
$info = $this->getInfoInstance();
|
63 |
+
if ($data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW) {
|
64 |
+
Mage::helper('ewayrapid')->clearSessionSharedpage();
|
65 |
+
Mage::getSingleton('core/session')->unsetData('visa_checkout_call_id');
|
66 |
+
if (($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
67 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME)
|
68 |
+
&& !$this->_isBackendOrder && $data->getSaveCard()
|
69 |
+
) {
|
70 |
+
Mage::getSingleton('core/session')->setData('newToken', 1);
|
71 |
+
}
|
72 |
+
if ($data->getSaveCard()) {
|
73 |
+
$info->setIsNewToken(true);
|
74 |
+
}
|
75 |
+
|
76 |
+
if ($this->_isBackendOrder
|
77 |
+
&& ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
78 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME)
|
79 |
+
&& $data->getSaveCard()
|
80 |
+
) {
|
81 |
+
Mage::getSingleton('core/session')->setData('newToken', 1);
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
} else {
|
86 |
+
if ( ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE || $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME)
|
87 |
+
&& !$this->_isBackendOrder
|
88 |
+
) {
|
89 |
+
Mage::getSingleton('core/session')->setData('editToken', $data->getSavedToken());
|
90 |
+
}
|
91 |
+
|
92 |
+
if ($this->_isBackendOrder
|
93 |
+
&& ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
94 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME)
|
95 |
+
) {
|
96 |
+
Mage::getSingleton('core/session')->setData('editToken', $data->getSavedToken());
|
97 |
+
}
|
98 |
+
|
99 |
+
$info->setSavedToken($data->getSavedToken());
|
100 |
+
// Update token
|
101 |
+
if ($data->getCcOwner() && $data->getSaveCard()) {
|
102 |
+
$info->setIsUpdateToken(true);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
if ($this->_isBackendOrder &&
|
107 |
+
($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
108 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME)
|
109 |
+
) {
|
110 |
+
if ($data->getMethod()) {
|
111 |
+
Mage::getSingleton('core/session')->setData('ewayMethod', $data->getMethod());
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
if (!$this->_isBackendOrder &&
|
116 |
+
($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
117 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME)
|
118 |
+
) {
|
119 |
+
if ($data->getMethod()) {
|
120 |
+
Mage::getSingleton('core/session')->setData('ewayMethod', $data->getMethod());
|
121 |
+
}
|
122 |
+
} elseif (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
123 |
+
if ($data->getVisaCheckoutCallId()) {
|
124 |
+
Mage::getSingleton('core/session')->setData('visa_checkout_call_id', $data->getVisaCheckoutCallId());
|
125 |
+
}
|
126 |
+
$info->setTransparentNotsaved($data->getTransparentNotsaved());
|
127 |
+
$info->setTransparentSaved($data->getTransparentSaved());
|
128 |
+
|
129 |
+
//Option choice
|
130 |
+
if ($data->getMethod() == 'ewayrapid_ewayone' && !$data->getTransparentSaved()) {
|
131 |
+
Mage::throwException(Mage::helper('payment')->__('Please select an option payment for eWay saved'));
|
132 |
+
} elseif ($data->getMethod() == 'ewayrapid_notsaved' && !$data->getTransparentNotsaved()) {
|
133 |
+
Mage::throwException(Mage::helper('payment')->__('Please select an option payment for eWay not saved'));
|
134 |
+
}
|
135 |
+
|
136 |
+
//New Token
|
137 |
+
if ($data->getMethod() == 'ewayrapid_ewayone'
|
138 |
+
&& $data->getTransparentSaved() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD
|
139 |
+
&& $data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW
|
140 |
+
&& Mage::helper('ewayrapid/customer')->checkTokenListByType(Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD)
|
141 |
+
&& $data->getSaveCard()
|
142 |
+
) {
|
143 |
+
Mage::throwException(Mage::helper('payment')->__('You could only save one PayPal account, please select PayPal account existed to payent.'));
|
144 |
+
}
|
145 |
+
|
146 |
+
if ($data->getTransparentNotsaved())
|
147 |
+
Mage::getSingleton('core/session')->setTransparentNotsaved($data->getTransparentNotsaved());
|
148 |
+
|
149 |
+
if ($data->getTransparentSaved())
|
150 |
+
Mage::getSingleton('core/session')->setTransparentSaved($data->getTransparentSaved());
|
151 |
+
|
152 |
+
if ($data->getMethod())
|
153 |
+
Mage::getSingleton('core/session')->setMethod($data->getMethod());
|
154 |
+
|
155 |
+
// Add Save Card to session
|
156 |
+
Mage::getSingleton('core/session')->setSaveCard($data->getSaveCard());
|
157 |
+
|
158 |
+
if ($data->getSavedToken()) {
|
159 |
+
Mage::getSingleton('core/session')->setSavedToken($data->getSavedToken());
|
160 |
+
if (is_numeric($data->getSavedToken())) {
|
161 |
+
$token = Mage::helper('ewayrapid/customer')->getTokenById($data->getSavedToken());
|
162 |
+
/* @var Eway_Rapid31_Model_Request_Token $model */
|
163 |
+
$model = Mage::getModel('ewayrapid/request_token');
|
164 |
+
$type = $model->checkCardName($token);
|
165 |
+
Mage::getSingleton('core/session')->setTransparentSaved($type);
|
166 |
+
unset($model);
|
167 |
+
unset($token);
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
$infoCard = new Varien_Object();
|
172 |
+
Mage::getSingleton('core/session')->setInfoCard(
|
173 |
+
$infoCard->setCcType($data->getCcType())
|
174 |
+
->setOwner($data->getCcOwner())
|
175 |
+
->setLast4($this->_isClientSideEncrypted($data->getCcNumber()) ? 'encrypted' : substr($data->getCcNumber(), -4))
|
176 |
+
->setCard($data->getCcNumber())
|
177 |
+
->setNumber($data->getCcNumber())
|
178 |
+
->setCid($data->getCcCid())
|
179 |
+
->setExpMonth($data->getCcExpMonth())
|
180 |
+
->setExpYear(
|
181 |
+
$data->getCcExpYear()
|
182 |
+
)
|
183 |
+
);
|
184 |
+
|
185 |
+
} else {
|
186 |
+
$info->setCcType($data->getCcType())
|
187 |
+
->setCcOwner($data->getCcOwner())
|
188 |
+
->setCcLast4($this->_isClientSideEncrypted($data->getCcNumber()) ? 'encrypted' : substr($data->getCcNumber(), -4))
|
189 |
+
->setCcNumber($data->getCcNumber())
|
190 |
+
->setCcCid($data->getCcCid())
|
191 |
+
->setCcExpMonth($data->getCcExpMonth())
|
192 |
+
->setCcExpYear($data->getCcExpYear());
|
193 |
+
}
|
194 |
+
|
195 |
+
Mage::helper('ewayrapid')->serializeInfoInstance($info);
|
196 |
+
|
197 |
+
return $this;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Validate payment method information object
|
202 |
+
*
|
203 |
+
* @param Mage_Payment_Model_Info $info
|
204 |
+
* @return Mage_Payment_Model_Abstract
|
205 |
+
*/
|
206 |
+
public function validate()
|
207 |
+
{
|
208 |
+
$info = $this->getInfoInstance();
|
209 |
+
if ($info->getIsNewToken()) {
|
210 |
+
parent::validate();
|
211 |
+
}
|
212 |
+
// TODO: Check if this token is still Active using GET /Customer endpoint.
|
213 |
+
|
214 |
+
return $this;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Authorize & Capture a payment
|
219 |
+
*
|
220 |
+
* @param Varien_Object $payment
|
221 |
+
* @param float $amount
|
222 |
+
*
|
223 |
+
* @return Mage_Payment_Model_Abstract
|
224 |
+
*/
|
225 |
+
public function capture(Varien_Object $payment, $amount)
|
226 |
+
{
|
227 |
+
if (!$this->_isPreauthCapture($payment) && (
|
228 |
+
$this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
229 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME)) {
|
230 |
+
$transID = Mage::getSingleton('core/session')->getData('ewayTransactionID');
|
231 |
+
$payment->setTransactionId($transID);
|
232 |
+
$payment->setIsTransactionClosed(0);
|
233 |
+
Mage::getSingleton('core/session')->unsetData('ewayTransactionID');
|
234 |
+
return $this;
|
235 |
+
} elseif (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT ) {
|
236 |
+
Mage::getModel('ewayrapid/request_transparent')->setTransaction($payment);
|
237 |
+
return $this;
|
238 |
+
}
|
239 |
+
|
240 |
+
/* @var Mage_Sales_Model_Order_Payment $payment */
|
241 |
+
if ($amount <= 0) {
|
242 |
+
Mage::throwException(Mage::helper('payment')->__('Invalid amount for capture.'));
|
243 |
+
}
|
244 |
+
$info = $this->getInfoInstance();
|
245 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
246 |
+
|
247 |
+
if (!$info->getIsNewToken() && !$info->getIsUpdateToken()) {
|
248 |
+
// Not new/update token
|
249 |
+
if ($info->getSavedToken() && is_numeric($info->getSavedToken())) {
|
250 |
+
// Saved token is numeric
|
251 |
+
$request = Mage::getModel('ewayrapid/request_token');
|
252 |
+
} else {
|
253 |
+
$request = Mage::getModel('ewayrapid/request_direct');
|
254 |
+
}
|
255 |
+
} else {
|
256 |
+
// New/update token
|
257 |
+
$request = Mage::getModel('ewayrapid/request_token');
|
258 |
+
}
|
259 |
+
|
260 |
+
$amount = round($amount * 100);
|
261 |
+
if ($this->_isPreauthCapture($payment)) {
|
262 |
+
$previousCapture = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
263 |
+
if ($previousCapture) {
|
264 |
+
$customer = Mage::getModel('customer/customer')->load($payment->getOrder()->getCustomerId());
|
265 |
+
Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
266 |
+
|
267 |
+
/* @var Mage_Sales_Model_Order_Payment_Transaction $previousCapture */
|
268 |
+
$request->doTransaction($payment, $amount);
|
269 |
+
$payment->setParentTransactionId($previousCapture->getParentTxnId());
|
270 |
+
} else {
|
271 |
+
$request->doCapturePayment($payment, $amount);
|
272 |
+
}
|
273 |
+
} else {
|
274 |
+
if (!$payment->getIsRecurring()) {
|
275 |
+
if ($request instanceof Eway_Rapid31_Model_Request_Token) {
|
276 |
+
$this->_shouldCreateOrUpdateToken($payment, $request);
|
277 |
+
}
|
278 |
+
|
279 |
+
}
|
280 |
+
$request->doTransaction($payment, $amount);
|
281 |
+
}
|
282 |
+
|
283 |
+
return $this;
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Authorize a payment
|
288 |
+
*
|
289 |
+
* @param Varien_Object $payment
|
290 |
+
* @param float $amount
|
291 |
+
*
|
292 |
+
* @return Mage_Payment_Model_Abstract
|
293 |
+
*/
|
294 |
+
public function authorize(Varien_Object $payment, $amount)
|
295 |
+
{
|
296 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE || $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME) {
|
297 |
+
$transID = Mage::getSingleton('core/session')->getData('ewayTransactionID');
|
298 |
+
$payment->setTransactionId($transID);
|
299 |
+
$payment->setIsTransactionClosed(0);
|
300 |
+
Mage::getSingleton('core/session')->unsetData('ewayTransactionID');
|
301 |
+
return $this;
|
302 |
+
} elseif (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
303 |
+
Mage::getModel('ewayrapid/request_transparent')->setTransaction($payment);
|
304 |
+
return $this;
|
305 |
+
}
|
306 |
+
|
307 |
+
/* @var Mage_Sales_Model_Order_Payment $payment */
|
308 |
+
if ($amount <= 0) {
|
309 |
+
Mage::throwException(Mage::helper('payment')->__('Invalid amount for authorize.'));
|
310 |
+
}
|
311 |
+
$info = $this->getInfoInstance();
|
312 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
313 |
+
|
314 |
+
if (!$info->getIsNewToken() && !$info->getIsUpdateToken()) {
|
315 |
+
// Not new/update token
|
316 |
+
if ($info->getSavedToken() && is_numeric($info->getSavedToken())) {
|
317 |
+
// Saved token is numeric
|
318 |
+
$request = Mage::getModel('ewayrapid/request_token');
|
319 |
+
} else {
|
320 |
+
$request = Mage::getModel('ewayrapid/request_direct');
|
321 |
+
}
|
322 |
+
} else {
|
323 |
+
// New/update token
|
324 |
+
$request = Mage::getModel('ewayrapid/request_token');
|
325 |
+
}
|
326 |
+
|
327 |
+
/** @todo there's an error in case recurring profile */
|
328 |
+
if (!$payment->getIsRecurring()) {
|
329 |
+
if ($request instanceof Eway_Rapid31_Model_Request_Token) {
|
330 |
+
$this->_shouldCreateOrUpdateToken($payment, $request);
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
$amount = round($amount * 100);
|
335 |
+
$request->doAuthorisation($payment, $amount);
|
336 |
+
|
337 |
+
return $this;
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
342 |
+
* @param Eway_Rapid31_Model_Request_Token $request
|
343 |
+
*/
|
344 |
+
public function _shouldCreateOrUpdateToken(Mage_Sales_Model_Order_Payment $payment, Eway_Rapid31_Model_Request_Token $request)
|
345 |
+
{
|
346 |
+
$order = $payment->getOrder();
|
347 |
+
$billing = ($this->_getBilling() == null) ? $order->getBillingAddress() : $this->_getBilling();
|
348 |
+
$info = $this->getInfoInstance();
|
349 |
+
|
350 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
351 |
+
if ($info->getIsNewToken()) {
|
352 |
+
$request->createNewToken($billing, $info);
|
353 |
+
$info->setSavedToken(Mage::helper('ewayrapid/customer')->getLastTokenId());
|
354 |
+
Mage::helper('ewayrapid')->serializeInfoInstance($info);
|
355 |
+
} elseif ($info->getIsUpdateToken()) {
|
356 |
+
$request->updateToken($billing, $info);
|
357 |
+
}
|
358 |
+
}
|
359 |
+
|
360 |
+
public function _setBilling(Mage_Sales_Model_Quote_Address $billing)
|
361 |
+
{
|
362 |
+
$this->_billing = $billing;
|
363 |
+
}
|
364 |
+
|
365 |
+
public function _getBilling()
|
366 |
+
{
|
367 |
+
return $this->_billing;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Validate RP data
|
372 |
+
*
|
373 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
374 |
+
*/
|
375 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
376 |
+
{
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Submit RP to the gateway
|
382 |
+
*
|
383 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
384 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
385 |
+
*/
|
386 |
+
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
|
387 |
+
Mage_Payment_Model_Info $paymentInfo
|
388 |
+
)
|
389 |
+
{
|
390 |
+
$profile->setReferenceId(strtoupper(uniqid()));
|
391 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Fetch RP details
|
396 |
+
*
|
397 |
+
* @param string $referenceId
|
398 |
+
* @param Varien_Object $result
|
399 |
+
*/
|
400 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
401 |
+
{
|
402 |
+
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Whether can get recurring profile details
|
407 |
+
*/
|
408 |
+
public function canGetRecurringProfileDetails()
|
409 |
+
{
|
410 |
+
return true;
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Update RP data
|
415 |
+
*
|
416 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
417 |
+
*/
|
418 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
419 |
+
{
|
420 |
+
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Manage status
|
425 |
+
*
|
426 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
427 |
+
*/
|
428 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
429 |
+
{
|
430 |
+
|
431 |
+
}
|
|
|
432 |
}
|
app/code/community/Eway/Rapid31/Model/Method/Notsaved.php
CHANGED
@@ -1,543 +1,525 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_Method_Notsaved extends Mage_Payment_Model_Method_Abstract
|
3 |
-
{
|
4 |
-
protected $_code = 'ewayrapid_notsaved';
|
5 |
-
|
6 |
-
protected $_formBlockType = 'ewayrapid/form_direct_notsaved';
|
7 |
-
protected $_infoBlockType = 'ewayrapid/info_direct_notsaved';
|
8 |
-
protected $_canSaveCc = false;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Payment Method features
|
12 |
-
* @var bool
|
13 |
-
*/
|
14 |
-
protected $_isGateway = true;
|
15 |
-
protected $_canAuthorize = true;
|
16 |
-
protected $_canCapture = true;
|
17 |
-
protected $_canCapturePartial = false;
|
18 |
-
protected $_canRefund = true;
|
19 |
-
protected $_canRefundInvoicePartial = true;
|
20 |
-
protected $_canVoid = true;
|
21 |
-
protected $_canUseInternal = true;
|
22 |
-
protected $_canUseCheckout = true;
|
23 |
-
protected $_canUseForMultishipping = true;
|
24 |
-
protected $_isInitializeNeeded = false;
|
25 |
-
protected $_canFetchTransactionInfo = true;
|
26 |
-
protected $_canReviewPayment = false;
|
27 |
-
protected $_canCreateBillingAgreement = false;
|
28 |
-
protected $_canManageRecurringProfiles = true;
|
29 |
-
protected $_connectionType;
|
30 |
-
protected $_isBackendOrder;
|
31 |
-
|
32 |
-
public static $
|
33 |
-
public function __construct()
|
34 |
-
{
|
35 |
-
parent::__construct();
|
36 |
-
$this->_isBackendOrder = Mage::helper('ewayrapid')->isBackendOrder();
|
37 |
-
$this->_connectionType = Mage::getStoreConfig('payment/ewayrapid_general/connection_type');
|
38 |
-
if (!$this->_isBackendOrder) {
|
39 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
40 |
-
$this->_infoBlockType = 'ewayrapid/info_transparent_notsaved';
|
41 |
-
$this->_formBlockType = 'ewayrapid/form_transparent_notsaved';
|
42 |
-
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
43 |
-
$this->_infoBlockType = 'ewayrapid/info_sharedpage_notsaved';
|
44 |
-
$this->_formBlockType = 'ewayrapid/form_sharedpage_notsaved';
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
if($this->_isBackendOrder){
|
49 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
50 |
-
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
51 |
-
) {
|
52 |
-
$this->_infoBlockType = 'ewayrapid/info_sharedpage_notsaved';
|
53 |
-
$this->_formBlockType = 'ewayrapid/form_sharedpage_notsaved';
|
54 |
-
}
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* As of version 1.4.0 this payment method isn't used.
|
60 |
-
*
|
61 |
-
* @param Mage_Sales_Model_Quote|null $quote
|
62 |
-
* @return boolean
|
63 |
-
*/
|
64 |
-
public function isAvailable($quote = null)
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
*
|
100 |
-
*
|
101 |
-
* @
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
Mage::throwException(Mage::helper('payment')->__('Please select an option payment for saved'));
|
123 |
-
}
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
&&
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
$
|
149 |
-
|
150 |
-
|
151 |
-
$
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
->
|
162 |
-
->
|
163 |
-
->
|
164 |
-
->
|
165 |
-
->
|
166 |
-
|
167 |
-
|
168 |
-
)
|
169 |
-
|
170 |
-
} else {
|
171 |
-
$info->setCcType($data->getCcType())
|
172 |
-
->setCcOwner($data->getCcOwner())
|
173 |
-
->setCcLast4($this->_isClientSideEncrypted($data->getCcNumber()) ? 'encrypted' : substr($data->getCcNumber(), -4))
|
174 |
-
->setCcNumber($data->getCcNumber())
|
175 |
-
->setCcCid($data->getCcCid())
|
176 |
-
->setCcExpMonth($data->getCcExpMonth())
|
177 |
-
->setCcExpYear($data->getCcExpYear());
|
178 |
-
}
|
179 |
-
|
180 |
-
return $this;
|
181 |
-
}
|
182 |
-
|
183 |
-
protected function _isClientSideEncrypted($ccNumber)
|
184 |
-
{
|
185 |
-
return (strlen($ccNumber) > 19 && strpos($ccNumber, Eway_Rapid31_Model_Config::ENCRYPTION_PREFIX) !== false);
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Validate payment method information object
|
190 |
-
*
|
191 |
-
* @param Mage_Payment_Model_Info $info
|
192 |
-
* @return Mage_Payment_Model_Abstract
|
193 |
-
*/
|
194 |
-
public function validate()
|
195 |
-
{
|
196 |
-
/*
|
197 |
-
* calling parent validate function
|
198 |
-
*/
|
199 |
-
parent::validate();
|
200 |
-
if (!$this->_isBackendOrder) {
|
201 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE || $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME) {
|
202 |
-
return $this;
|
203 |
-
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT ) {
|
204 |
-
return $this;
|
205 |
-
}
|
206 |
-
}
|
207 |
-
|
208 |
-
if($this->_isBackendOrder
|
209 |
-
&& $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
210 |
-
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
211 |
-
){
|
212 |
-
return $this;
|
213 |
-
}
|
214 |
-
|
215 |
-
$info = $this->getInfoInstance();
|
216 |
-
$errorMsg = false;
|
217 |
-
$availableTypes = explode(','
|
218 |
-
|
219 |
-
$ccNumber = $info->getCcNumber();
|
220 |
-
|
221 |
-
// Cannot do normal validation in case client side encrypted
|
222 |
-
if($this->_isClientSideEncrypted($ccNumber)) {
|
223 |
-
return true;
|
224 |
-
}
|
225 |
-
|
226 |
-
// remove credit card number delimiters such as "-" and space
|
227 |
-
$ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
|
228 |
-
$info->setCcNumber($ccNumber);
|
229 |
-
|
230 |
-
$ccType = '';
|
231 |
-
|
232 |
-
if (in_array($info->getCcType(), $availableTypes)){
|
233 |
-
if ($this->validateCcNum($ccNumber)) {
|
234 |
-
$ccTypeRegExpList = array(
|
235 |
-
// Visa Electron
|
236 |
-
'VE' => '/^(4026|4405|4508|4844|4913|4917)[0-9]{12}|417500[0-9]{10}$/',
|
237 |
-
// Maestro
|
238 |
-
'ME' => '/(^(5[0678])[0-9]{11,18}$)|(^(6[^05])[0-9]{11,18}$)|(^(601)[^1][0-9]{9,16}$)|(^(6011)[0-9]{9,11}$)|(^(6011)[0-9]{13,16}$)|(^(65)[0-9]{11,13}$)|(^(65)[0-9]{15,18}$)|(^(49030)[2-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49033)[5-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49110)[1-2]([0-9]{10}$|[0-9]{12,13}$))|(^(49117)[4-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49118)[0-2]([0-9]{10}$|[0-9]{12,13}$))|(^(4936)([0-9]{12}$|[0-9]{14,15}$))/',
|
239 |
-
// Visa
|
240 |
-
'VI' => '/^4[0-9]{12}([0-9]{3})?$/',
|
241 |
-
// Master Card
|
242 |
-
'MC' => '/^5[1-5][0-9]{14}$/',
|
243 |
-
// Master Card 2017 - new MasterCard Range 2221-2720
|
244 |
-
//'MC' => '/(^5[1-5][0-9]{14}$)|(^2221[0-9]{12}$)|(^222[2-9][0-9]{12}$)|(^22[3-9][0-9]{13}$)|(^2[3-6][0-9]{14}$)|(^2720[0-9]{12}$)|(^27[0-1][0-9]{13}$)/',
|
245 |
-
// American Express
|
246 |
-
'AE' => '/^3[47][0-9]{13}$/',
|
247 |
-
// JCB
|
248 |
-
'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/',
|
249 |
-
// Diners Club
|
250 |
-
'DC' => '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/',
|
251 |
-
);
|
252 |
-
|
253 |
-
foreach ($ccTypeRegExpList as $ccTypeMatch=>$ccTypeRegExp) {
|
254 |
-
if (preg_match($ccTypeRegExp, $ccNumber)) {
|
255 |
-
$ccType = $ccTypeMatch;
|
256 |
-
break;
|
257 |
-
}
|
258 |
-
}
|
259 |
-
|
260 |
-
if ($ccType!=$info->getCcType()) {
|
261 |
-
$errorMsg = Mage::helper('payment')->__('Please enter a valid credit card number.');
|
262 |
-
}
|
263 |
-
} else {
|
264 |
-
$errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number');
|
265 |
-
}
|
266 |
-
|
267 |
-
} else {
|
268 |
-
$errorMsg = Mage::helper('payment')->__('Credit card type is not allowed for this payment method.');
|
269 |
-
}
|
270 |
-
|
271 |
-
//validate credit card verification number
|
272 |
-
if ($errorMsg === false && $this->hasVerification()) {
|
273 |
-
$verifcationRegEx = $this->getVerificationRegEx();
|
274 |
-
$regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
|
275 |
-
if (!$info->getCcCid() || !$regExp || !preg_match($regExp
|
276 |
-
$errorMsg = Mage::helper('payment')->__('Please enter a valid credit card verification number.');
|
277 |
-
}
|
278 |
-
}
|
279 |
-
|
280 |
-
if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
|
281 |
-
$errorMsg = Mage::helper('payment')->__('Incorrect credit card expiration date.');
|
282 |
-
}
|
283 |
-
|
284 |
-
if($errorMsg){
|
285 |
-
Mage::throwException($errorMsg);
|
286 |
-
}
|
287 |
-
|
288 |
-
return $this;
|
289 |
-
}
|
290 |
-
|
291 |
-
public function hasVerification()
|
292 |
-
{
|
293 |
-
if(Mage::helper('ewayrapid')->isBackendOrder()) {
|
294 |
-
return false;
|
295 |
-
}
|
296 |
-
|
297 |
-
$configData = $this->getConfigData('useccv');
|
298 |
-
if(
|
299 |
-
return true;
|
300 |
-
}
|
301 |
-
return (bool) $configData;
|
302 |
-
}
|
303 |
-
|
304 |
-
public function getVerificationRegEx()
|
305 |
-
{
|
306 |
-
$verificationExpList = array(
|
307 |
-
'VI' => '/^[0-9]{3}$/', // Visa
|
308 |
-
'VE' => '/^[0-9]{3}$/', // Visa Electron
|
309 |
-
'MC' => '/^[0-9]{3}$/', // Master Card
|
310 |
-
'ME' => '/^[0-9]{3,4}$/', // Maestro
|
311 |
-
'AE' => '/^[0-9]{4}$/', // American Express
|
312 |
-
'DC' => '/^[0-9]{3}$/', // Diners Club
|
313 |
-
'JCB' => '/^[0-9]{3,4}$/' //JCB
|
314 |
-
);
|
315 |
-
return $verificationExpList;
|
316 |
-
}
|
317 |
-
|
318 |
-
protected function _validateExpDate($expYear, $expMonth)
|
319 |
-
{
|
320 |
-
$date = Mage::app()->getLocale()->date();
|
321 |
-
if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1)
|
322 |
-
|| ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1))
|
323 |
-
) {
|
324 |
-
return false;
|
325 |
-
}
|
326 |
-
return true;
|
327 |
-
}
|
328 |
-
|
329 |
-
/**
|
330 |
-
* Validate credit card number
|
331 |
-
*
|
332 |
-
* @param string $cc_number
|
333 |
-
* @return bool
|
334 |
-
*/
|
335 |
-
public function validateCcNum($ccNumber)
|
336 |
-
{
|
337 |
-
$cardNumber = strrev($ccNumber);
|
338 |
-
$numSum = 0;
|
339 |
-
|
340 |
-
for ($i=0; $i<strlen($cardNumber); $i++) {
|
341 |
-
$currentNum = substr($cardNumber, $i, 1);
|
342 |
-
|
343 |
-
/**
|
344 |
-
* Double every second digit
|
345 |
-
*/
|
346 |
-
if ($i % 2 == 1) {
|
347 |
-
$currentNum *= 2;
|
348 |
-
}
|
349 |
-
|
350 |
-
/**
|
351 |
-
* Add digits of 2-digit numbers together
|
352 |
-
*/
|
353 |
-
if ($currentNum > 9) {
|
354 |
-
$firstNum = $currentNum % 10;
|
355 |
-
$secondNum = ($currentNum - $firstNum) / 10;
|
356 |
-
$currentNum = $firstNum + $secondNum;
|
357 |
-
}
|
358 |
-
|
359 |
-
$numSum += $currentNum;
|
360 |
-
}
|
361 |
-
|
362 |
-
/**
|
363 |
-
* If the total has no remainder it's OK
|
364 |
-
*/
|
365 |
-
return ($numSum % 10 == 0);
|
366 |
-
}
|
367 |
-
|
368 |
-
/**
|
369 |
-
* Authorize & Capture a payment
|
370 |
-
*
|
371 |
-
* @param Varien_Object $payment
|
372 |
-
* @param float $amount
|
373 |
-
*
|
374 |
-
* @return Mage_Payment_Model_Abstract
|
375 |
-
*/
|
376 |
-
public function capture(Varien_Object $payment, $amount)
|
377 |
-
{
|
378 |
-
if (!$this->_isBackendOrder) {
|
379 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
380 |
-
$transID = Mage::getSingleton('core/session')->getData('ewayTransactionID');
|
381 |
-
$payment->setTransactionId($transID);
|
382 |
-
$payment->setIsTransactionClosed(0);
|
383 |
-
Mage::getSingleton('core/session')->unsetData('ewayTransactionID');
|
384 |
-
return $this;
|
385 |
-
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT ) {
|
386 |
-
$payment = Mage::getModel('ewayrapid/request_transparent')->setTransaction($payment);
|
387 |
-
return $this;
|
388 |
-
}
|
389 |
-
}
|
390 |
-
|
391 |
-
if ($this->_isBackendOrder) {
|
392 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
393 |
-
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
394 |
-
) {
|
395 |
-
return $this;
|
396 |
-
}
|
397 |
-
}
|
398 |
-
|
399 |
-
/* @var Mage_Sales_Model_Order_Payment $payment */
|
400 |
-
if ($amount <= 0) {
|
401 |
-
Mage::throwException(Mage::helper('payment')->__('Invalid amount for capture.'));
|
402 |
-
}
|
403 |
-
|
404 |
-
$amount = round($amount * 100);
|
405 |
-
$request = Mage::getModel('ewayrapid/request_direct');
|
406 |
-
if($this->_isPreauthCapture($payment)) {
|
407 |
-
$request->doCapturePayment($payment, $amount);
|
408 |
-
} else {
|
409 |
-
$request->doTransaction($payment, $amount);
|
410 |
-
}
|
411 |
-
|
412 |
-
return $this;
|
413 |
-
}
|
414 |
-
|
415 |
-
/**
|
416 |
-
* Authorize a payment
|
417 |
-
*
|
418 |
-
* @param Varien_Object $payment
|
419 |
-
* @param float $amount
|
420 |
-
*
|
421 |
-
* @return Mage_Payment_Model_Abstract
|
422 |
-
*/
|
423 |
-
public function authorize(Varien_Object $payment, $amount)
|
424 |
-
{
|
425 |
-
if (!$this->_isBackendOrder) {
|
426 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
427 |
-
$transID = Mage::getSingleton('core/session')->getData('ewayTransactionID');
|
428 |
-
$payment->setTransactionId($transID);
|
429 |
-
$payment->setIsTransactionClosed(0);
|
430 |
-
Mage::getSingleton('core/session')->unsetData('ewayTransactionID');
|
431 |
-
return $this;
|
432 |
-
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT ) {
|
433 |
-
$payment = Mage::getModel('ewayrapid/request_transparent')->setTransaction($payment);
|
434 |
-
return $this;
|
435 |
-
}
|
436 |
-
}
|
437 |
-
|
438 |
-
if ($this->_isBackendOrder) {
|
439 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
440 |
-
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
441 |
-
) {
|
442 |
-
return $this;
|
443 |
-
}
|
444 |
-
}
|
445 |
-
|
446 |
-
/* @var Mage_Sales_Model_Order_Payment $payment */
|
447 |
-
if ($amount <= 0) {
|
448 |
-
Mage::throwException(Mage::helper('payment')->__('Invalid amount for authorize.'));
|
449 |
-
}
|
450 |
-
|
451 |
-
|
452 |
-
)
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
elseif (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
526 |
-
=== Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
|
527 |
-
&& Mage::getSingleton('core/session')->getCheckoutExtension()
|
528 |
-
) {
|
529 |
-
return Mage::getUrl('ewayrapid/transparent/build', array('_secure'=>true));
|
530 |
-
}
|
531 |
-
/*elseif (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
532 |
-
=== Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
|
533 |
-
&& (Mage::getStoreConfig('onestepcheckout/general/active')
|
534 |
-
|| Mage::getStoreConfig('opc/global/status')
|
535 |
-
|| Mage::getStoreConfig('firecheckout/general/enabled')
|
536 |
-
|| Mage::getStoreConfig('gomage_checkout/general/enabled')
|
537 |
-
|| Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links'))
|
538 |
-
) {
|
539 |
-
return Mage::getUrl('ewayrapid/transparent/build', array('_secure'=>true));
|
540 |
-
}*/
|
541 |
-
return null;
|
542 |
-
}
|
543 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_Method_Notsaved extends Mage_Payment_Model_Method_Abstract
|
3 |
+
{
|
4 |
+
protected $_code = 'ewayrapid_notsaved';
|
5 |
+
|
6 |
+
protected $_formBlockType = 'ewayrapid/form_direct_notsaved';
|
7 |
+
protected $_infoBlockType = 'ewayrapid/info_direct_notsaved';
|
8 |
+
protected $_canSaveCc = false;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Payment Method features
|
12 |
+
* @var bool
|
13 |
+
*/
|
14 |
+
protected $_isGateway = true;
|
15 |
+
protected $_canAuthorize = true;
|
16 |
+
protected $_canCapture = true;
|
17 |
+
protected $_canCapturePartial = false;
|
18 |
+
protected $_canRefund = true;
|
19 |
+
protected $_canRefundInvoicePartial = true;
|
20 |
+
protected $_canVoid = true;
|
21 |
+
protected $_canUseInternal = true;
|
22 |
+
protected $_canUseCheckout = true;
|
23 |
+
protected $_canUseForMultishipping = true;
|
24 |
+
protected $_isInitializeNeeded = false;
|
25 |
+
protected $_canFetchTransactionInfo = true;
|
26 |
+
protected $_canReviewPayment = false;
|
27 |
+
protected $_canCreateBillingAgreement = false;
|
28 |
+
protected $_canManageRecurringProfiles = true;
|
29 |
+
protected $_connectionType;
|
30 |
+
protected $_isBackendOrder;
|
31 |
+
|
32 |
+
public static $extension = false;
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
parent::__construct();
|
36 |
+
$this->_isBackendOrder = Mage::helper('ewayrapid')->isBackendOrder();
|
37 |
+
$this->_connectionType = Mage::getStoreConfig('payment/ewayrapid_general/connection_type');
|
38 |
+
if (!$this->_isBackendOrder) {
|
39 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
40 |
+
$this->_infoBlockType = 'ewayrapid/info_transparent_notsaved';
|
41 |
+
$this->_formBlockType = 'ewayrapid/form_transparent_notsaved';
|
42 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
43 |
+
$this->_infoBlockType = 'ewayrapid/info_sharedpage_notsaved';
|
44 |
+
$this->_formBlockType = 'ewayrapid/form_sharedpage_notsaved';
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($this->_isBackendOrder) {
|
49 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
50 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
51 |
+
) {
|
52 |
+
$this->_infoBlockType = 'ewayrapid/info_sharedpage_notsaved';
|
53 |
+
$this->_formBlockType = 'ewayrapid/form_sharedpage_notsaved';
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* As of version 1.4.0 this payment method isn't used.
|
60 |
+
*
|
61 |
+
* @param Mage_Sales_Model_Quote|null $quote
|
62 |
+
* @return boolean
|
63 |
+
*/
|
64 |
+
public function isAvailable($quote = null)
|
65 |
+
{
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getConfigData($field, $storeId = null)
|
70 |
+
{
|
71 |
+
$data = parent::getConfigData($field, $storeId);
|
72 |
+
if ($data === null) {
|
73 |
+
return $this->_getGeneralConfig($field, $storeId);
|
74 |
+
} else {
|
75 |
+
switch($field) {
|
76 |
+
case 'active':
|
77 |
+
return $data && $this->_isActive($storeId);
|
78 |
+
default:
|
79 |
+
return $data;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
protected function _getGeneralConfig($field, $storeId = null)
|
85 |
+
{
|
86 |
+
if (null === $storeId) {
|
87 |
+
$storeId = $this->getStore();
|
88 |
+
}
|
89 |
+
$path = 'payment/ewayrapid_general/'.$field;
|
90 |
+
return Mage::getStoreConfig($path, $storeId);
|
91 |
+
}
|
92 |
+
|
93 |
+
protected function _isActive($storeId)
|
94 |
+
{
|
95 |
+
return $this->_getGeneralConfig('active', $storeId);
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Assign data to info model instance
|
100 |
+
*
|
101 |
+
* @param mixed $data
|
102 |
+
* @return Mage_Payment_Model_Info
|
103 |
+
*/
|
104 |
+
public function assignData($data)
|
105 |
+
{
|
106 |
+
if (!($data instanceof Varien_Object)) {
|
107 |
+
$data = new Varien_Object($data);
|
108 |
+
}
|
109 |
+
$info = $this->getInfoInstance();
|
110 |
+
|
111 |
+
if (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
112 |
+
if ($data->getMethod()) {
|
113 |
+
Mage::getSingleton('core/session')->setData('ewayMethod', $data->getMethod());
|
114 |
+
}
|
115 |
+
} elseif (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
116 |
+
$info->setTransparentNotsaved($data->getTransparentNotsaved());
|
117 |
+
|
118 |
+
//Option choice
|
119 |
+
if ($data->getMethod() == 'ewayrapid_saved' && !$data->getTransparentSaved()) {
|
120 |
+
Mage::throwException(Mage::helper('payment')->__('Please select an option payment for saved'));
|
121 |
+
} elseif ($data->getMethod() == 'ewayrapid_notsaved' && !$data->getTransparentNotsaved()) {
|
122 |
+
Mage::throwException(Mage::helper('payment')->__('Please select an option payment for not saved'));
|
123 |
+
}
|
124 |
+
|
125 |
+
//New Token
|
126 |
+
if ($data->getMethod() == 'ewayrapid_saved'
|
127 |
+
&& $data->getTransparentSaved() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD
|
128 |
+
&& $data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW
|
129 |
+
&& Mage::helper('ewayrapid/customer')->checkTokenListByType(Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD)
|
130 |
+
) {
|
131 |
+
Mage::throwException(Mage::helper('payment')->__('You can only save one PayPal account, please select existing PayPal account.'));
|
132 |
+
}
|
133 |
+
|
134 |
+
if ($data->getTransparentNotsaved())
|
135 |
+
Mage::getSingleton('core/session')->setTransparentNotsaved($data->getTransparentNotsaved());
|
136 |
+
|
137 |
+
if ($data->getTransparentSaved())
|
138 |
+
Mage::getSingleton('core/session')->setTransparentSaved($data->getTransparentSaved());
|
139 |
+
|
140 |
+
if ($data->getMethod())
|
141 |
+
Mage::getSingleton('core/session')->setMethod($data->getMethod());
|
142 |
+
|
143 |
+
if ($data->getSavedToken()) {
|
144 |
+
Mage::getSingleton('core/session')->setSavedToken($data->getSavedToken());
|
145 |
+
if (is_numeric($data->getSavedToken())) {
|
146 |
+
$token = Mage::helper('ewayrapid/customer')->getTokenById($data->getSavedToken());
|
147 |
+
/* @var Eway_Rapid31_Model_Request_Token $model */
|
148 |
+
$model = Mage::getModel('ewayrapid/request_token');
|
149 |
+
$type = $model->checkCardName($token);
|
150 |
+
Mage::getSingleton('core/session')->setTransparentSaved($type);
|
151 |
+
unset($model);
|
152 |
+
unset($token);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
$infoCard = new Varien_Object();
|
157 |
+
Mage::getSingleton('core/session')->setInfoCard(
|
158 |
+
$infoCard->setCcType($data->getCcType())
|
159 |
+
->setOwner($data->getCcOwner())
|
160 |
+
->setLast4($this->_isClientSideEncrypted($data->getCcNumber()) ? 'encrypted' : substr($data->getCcNumber(), -4))
|
161 |
+
->setCard($data->getCcNumber())
|
162 |
+
->setNumber($data->getCcNumber())
|
163 |
+
->setCid($data->getCcCid())
|
164 |
+
->setExpMonth($data->getCcExpMonth())
|
165 |
+
->setExpYear(
|
166 |
+
$data->getCcExpYear()
|
167 |
+
)
|
168 |
+
);
|
169 |
+
|
170 |
+
} else {
|
171 |
+
$info->setCcType($data->getCcType())
|
172 |
+
->setCcOwner($data->getCcOwner())
|
173 |
+
->setCcLast4($this->_isClientSideEncrypted($data->getCcNumber()) ? 'encrypted' : substr($data->getCcNumber(), -4))
|
174 |
+
->setCcNumber($data->getCcNumber())
|
175 |
+
->setCcCid($data->getCcCid())
|
176 |
+
->setCcExpMonth($data->getCcExpMonth())
|
177 |
+
->setCcExpYear($data->getCcExpYear());
|
178 |
+
}
|
179 |
+
|
180 |
+
return $this;
|
181 |
+
}
|
182 |
+
|
183 |
+
protected function _isClientSideEncrypted($ccNumber)
|
184 |
+
{
|
185 |
+
return (strlen($ccNumber) > 19 && strpos($ccNumber, Eway_Rapid31_Model_Config::ENCRYPTION_PREFIX) !== false);
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Validate payment method information object
|
190 |
+
*
|
191 |
+
* @param Mage_Payment_Model_Info $info
|
192 |
+
* @return Mage_Payment_Model_Abstract
|
193 |
+
*/
|
194 |
+
public function validate()
|
195 |
+
{
|
196 |
+
/*
|
197 |
+
* calling parent validate function
|
198 |
+
*/
|
199 |
+
parent::validate();
|
200 |
+
if (!$this->_isBackendOrder) {
|
201 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE || $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME) {
|
202 |
+
return $this;
|
203 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT ) {
|
204 |
+
return $this;
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
if ($this->_isBackendOrder
|
209 |
+
&& $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
210 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
211 |
+
) {
|
212 |
+
return $this;
|
213 |
+
}
|
214 |
+
|
215 |
+
$info = $this->getInfoInstance();
|
216 |
+
$errorMsg = false;
|
217 |
+
$availableTypes = explode(',', $this->getConfigData('cctypes'));
|
218 |
+
|
219 |
+
$ccNumber = $info->getCcNumber();
|
220 |
+
|
221 |
+
// Cannot do normal validation in case client side encrypted
|
222 |
+
if ($this->_isClientSideEncrypted($ccNumber)) {
|
223 |
+
return true;
|
224 |
+
}
|
225 |
+
|
226 |
+
// remove credit card number delimiters such as "-" and space
|
227 |
+
$ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
|
228 |
+
$info->setCcNumber($ccNumber);
|
229 |
+
|
230 |
+
$ccType = '';
|
231 |
+
|
232 |
+
if (in_array($info->getCcType(), $availableTypes)) {
|
233 |
+
if ($this->validateCcNum($ccNumber)) {
|
234 |
+
$ccTypeRegExpList = array(
|
235 |
+
// Visa Electron
|
236 |
+
'VE' => '/^(4026|4405|4508|4844|4913|4917)[0-9]{12}|417500[0-9]{10}$/',
|
237 |
+
// Maestro
|
238 |
+
'ME' => '/(^(5[0678])[0-9]{11,18}$)|(^(6[^05])[0-9]{11,18}$)|(^(601)[^1][0-9]{9,16}$)|(^(6011)[0-9]{9,11}$)|(^(6011)[0-9]{13,16}$)|(^(65)[0-9]{11,13}$)|(^(65)[0-9]{15,18}$)|(^(49030)[2-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49033)[5-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49110)[1-2]([0-9]{10}$|[0-9]{12,13}$))|(^(49117)[4-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49118)[0-2]([0-9]{10}$|[0-9]{12,13}$))|(^(4936)([0-9]{12}$|[0-9]{14,15}$))/',
|
239 |
+
// Visa
|
240 |
+
'VI' => '/^4[0-9]{12}([0-9]{3})?$/',
|
241 |
+
// Master Card
|
242 |
+
'MC' => '/^5[1-5][0-9]{14}$/',
|
243 |
+
// Master Card 2017 - new MasterCard Range 2221-2720
|
244 |
+
//'MC' => '/(^5[1-5][0-9]{14}$)|(^2221[0-9]{12}$)|(^222[2-9][0-9]{12}$)|(^22[3-9][0-9]{13}$)|(^2[3-6][0-9]{14}$)|(^2720[0-9]{12}$)|(^27[0-1][0-9]{13}$)/',
|
245 |
+
// American Express
|
246 |
+
'AE' => '/^3[47][0-9]{13}$/',
|
247 |
+
// JCB
|
248 |
+
'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/',
|
249 |
+
// Diners Club
|
250 |
+
'DC' => '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/',
|
251 |
+
);
|
252 |
+
|
253 |
+
foreach ($ccTypeRegExpList as $ccTypeMatch=>$ccTypeRegExp) {
|
254 |
+
if (preg_match($ccTypeRegExp, $ccNumber)) {
|
255 |
+
$ccType = $ccTypeMatch;
|
256 |
+
break;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
if ($ccType!=$info->getCcType()) {
|
261 |
+
$errorMsg = Mage::helper('payment')->__('Please enter a valid credit card number.');
|
262 |
+
}
|
263 |
+
} else {
|
264 |
+
$errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number');
|
265 |
+
}
|
266 |
+
|
267 |
+
} else {
|
268 |
+
$errorMsg = Mage::helper('payment')->__('Credit card type is not allowed for this payment method.');
|
269 |
+
}
|
270 |
+
|
271 |
+
//validate credit card verification number
|
272 |
+
if ($errorMsg === false && $this->hasVerification()) {
|
273 |
+
$verifcationRegEx = $this->getVerificationRegEx();
|
274 |
+
$regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
|
275 |
+
if (!$info->getCcCid() || !$regExp || !preg_match($regExp, $info->getCcCid())) {
|
276 |
+
$errorMsg = Mage::helper('payment')->__('Please enter a valid credit card verification number.');
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
|
281 |
+
$errorMsg = Mage::helper('payment')->__('Incorrect credit card expiration date.');
|
282 |
+
}
|
283 |
+
|
284 |
+
if ($errorMsg) {
|
285 |
+
Mage::throwException($errorMsg);
|
286 |
+
}
|
287 |
+
|
288 |
+
return $this;
|
289 |
+
}
|
290 |
+
|
291 |
+
public function hasVerification()
|
292 |
+
{
|
293 |
+
if (Mage::helper('ewayrapid')->isBackendOrder()) {
|
294 |
+
return false;
|
295 |
+
}
|
296 |
+
|
297 |
+
$configData = $this->getConfigData('useccv');
|
298 |
+
if ($configData === null) {
|
299 |
+
return true;
|
300 |
+
}
|
301 |
+
return (bool) $configData;
|
302 |
+
}
|
303 |
+
|
304 |
+
public function getVerificationRegEx()
|
305 |
+
{
|
306 |
+
$verificationExpList = array(
|
307 |
+
'VI' => '/^[0-9]{3}$/', // Visa
|
308 |
+
'VE' => '/^[0-9]{3}$/', // Visa Electron
|
309 |
+
'MC' => '/^[0-9]{3}$/', // Master Card
|
310 |
+
'ME' => '/^[0-9]{3,4}$/', // Maestro
|
311 |
+
'AE' => '/^[0-9]{4}$/', // American Express
|
312 |
+
'DC' => '/^[0-9]{3}$/', // Diners Club
|
313 |
+
'JCB' => '/^[0-9]{3,4}$/' //JCB
|
314 |
+
);
|
315 |
+
return $verificationExpList;
|
316 |
+
}
|
317 |
+
|
318 |
+
protected function _validateExpDate($expYear, $expMonth)
|
319 |
+
{
|
320 |
+
$date = Mage::app()->getLocale()->date();
|
321 |
+
if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1)
|
322 |
+
|| ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1))
|
323 |
+
) {
|
324 |
+
return false;
|
325 |
+
}
|
326 |
+
return true;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Validate credit card number
|
331 |
+
*
|
332 |
+
* @param string $cc_number
|
333 |
+
* @return bool
|
334 |
+
*/
|
335 |
+
public function validateCcNum($ccNumber)
|
336 |
+
{
|
337 |
+
$cardNumber = strrev($ccNumber);
|
338 |
+
$numSum = 0;
|
339 |
+
|
340 |
+
for ($i=0; $i<strlen($cardNumber); $i++) {
|
341 |
+
$currentNum = substr($cardNumber, $i, 1);
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Double every second digit
|
345 |
+
*/
|
346 |
+
if ($i % 2 == 1) {
|
347 |
+
$currentNum *= 2;
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Add digits of 2-digit numbers together
|
352 |
+
*/
|
353 |
+
if ($currentNum > 9) {
|
354 |
+
$firstNum = $currentNum % 10;
|
355 |
+
$secondNum = ($currentNum - $firstNum) / 10;
|
356 |
+
$currentNum = $firstNum + $secondNum;
|
357 |
+
}
|
358 |
+
|
359 |
+
$numSum += $currentNum;
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* If the total has no remainder it's OK
|
364 |
+
*/
|
365 |
+
return ($numSum % 10 == 0);
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Authorize & Capture a payment
|
370 |
+
*
|
371 |
+
* @param Varien_Object $payment
|
372 |
+
* @param float $amount
|
373 |
+
*
|
374 |
+
* @return Mage_Payment_Model_Abstract
|
375 |
+
*/
|
376 |
+
public function capture(Varien_Object $payment, $amount)
|
377 |
+
{
|
378 |
+
if (!$this->_isBackendOrder) {
|
379 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
380 |
+
$transID = Mage::getSingleton('core/session')->getData('ewayTransactionID');
|
381 |
+
$payment->setTransactionId($transID);
|
382 |
+
$payment->setIsTransactionClosed(0);
|
383 |
+
Mage::getSingleton('core/session')->unsetData('ewayTransactionID');
|
384 |
+
return $this;
|
385 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT ) {
|
386 |
+
$payment = Mage::getModel('ewayrapid/request_transparent')->setTransaction($payment);
|
387 |
+
return $this;
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
if ($this->_isBackendOrder) {
|
392 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
393 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
394 |
+
) {
|
395 |
+
return $this;
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
/* @var Mage_Sales_Model_Order_Payment $payment */
|
400 |
+
if ($amount <= 0) {
|
401 |
+
Mage::throwException(Mage::helper('payment')->__('Invalid amount for capture.'));
|
402 |
+
}
|
403 |
+
|
404 |
+
$amount = round($amount * 100);
|
405 |
+
$request = Mage::getModel('ewayrapid/request_direct');
|
406 |
+
if ($this->_isPreauthCapture($payment)) {
|
407 |
+
$request->doCapturePayment($payment, $amount);
|
408 |
+
} else {
|
409 |
+
$request->doTransaction($payment, $amount);
|
410 |
+
}
|
411 |
+
|
412 |
+
return $this;
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Authorize a payment
|
417 |
+
*
|
418 |
+
* @param Varien_Object $payment
|
419 |
+
* @param float $amount
|
420 |
+
*
|
421 |
+
* @return Mage_Payment_Model_Abstract
|
422 |
+
*/
|
423 |
+
public function authorize(Varien_Object $payment, $amount)
|
424 |
+
{
|
425 |
+
if (!$this->_isBackendOrder) {
|
426 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
427 |
+
$transID = Mage::getSingleton('core/session')->getData('ewayTransactionID');
|
428 |
+
$payment->setTransactionId($transID);
|
429 |
+
$payment->setIsTransactionClosed(0);
|
430 |
+
Mage::getSingleton('core/session')->unsetData('ewayTransactionID');
|
431 |
+
return $this;
|
432 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT ) {
|
433 |
+
$payment = Mage::getModel('ewayrapid/request_transparent')->setTransaction($payment);
|
434 |
+
return $this;
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
if ($this->_isBackendOrder) {
|
439 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
440 |
+
|| $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
441 |
+
) {
|
442 |
+
return $this;
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
/* @var Mage_Sales_Model_Order_Payment $payment */
|
447 |
+
if ($amount <= 0) {
|
448 |
+
Mage::throwException(Mage::helper('payment')->__('Invalid amount for authorize.'));
|
449 |
+
}
|
450 |
+
|
451 |
+
$amount = round($amount * 100);
|
452 |
+
$request = Mage::getModel('ewayrapid/request_direct');
|
453 |
+
$request->doAuthorisation($payment, $amount);
|
454 |
+
|
455 |
+
return $this;
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Refund a payment
|
460 |
+
*
|
461 |
+
* @param Varien_Object $payment
|
462 |
+
* @param float $amount
|
463 |
+
*
|
464 |
+
* @return Mage_Payment_Model_Abstract
|
465 |
+
*/
|
466 |
+
public function refund(Varien_Object $payment, $amount)
|
467 |
+
{
|
468 |
+
/* @var Mage_Sales_Model_Order_Payment $payment */
|
469 |
+
if ($amount <= 0) {
|
470 |
+
Mage::throwException(Mage::helper('payment')->__('Invalid amount for refund.'));
|
471 |
+
}
|
472 |
+
|
473 |
+
$amount = round($amount * 100);
|
474 |
+
$request = Mage::getModel('ewayrapid/request_direct');
|
475 |
+
$request->doRefund($payment, $amount);
|
476 |
+
|
477 |
+
return $this;
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* Cancel a payment
|
482 |
+
*
|
483 |
+
* @param Varien_Object $payment
|
484 |
+
*
|
485 |
+
* @return Mage_Payment_Model_Abstract
|
486 |
+
*/
|
487 |
+
public function cancel(Varien_Object $payment)
|
488 |
+
{
|
489 |
+
/* @var Mage_Sales_Model_Order_Payment $payment */
|
490 |
+
$request = Mage::getModel('ewayrapid/request_direct');
|
491 |
+
$request->doCancel($payment);
|
492 |
+
|
493 |
+
return $this;
|
494 |
+
}
|
495 |
+
|
496 |
+
protected function _isPreauthCapture(Mage_Sales_Model_Order_Payment $payment)
|
497 |
+
{
|
498 |
+
return (bool) $payment->getLastTransId();
|
499 |
+
}
|
500 |
+
|
501 |
+
public function canVoid(Varien_Object $payment)
|
502 |
+
{
|
503 |
+
return $this->_canVoid && (Mage::app()->getRequest()->getActionName() == 'cancel');
|
504 |
+
}
|
505 |
+
|
506 |
+
public function getCheckoutRedirectUrl()
|
507 |
+
{
|
508 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
509 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
510 |
+
) {
|
511 |
+
return Mage::getUrl('ewayrapid/sharedpage/start', array('_secure'=>true));
|
512 |
+
} elseif (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
513 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
514 |
+
&& Mage::getSingleton('core/session')->getCheckoutExtension()
|
515 |
+
) {
|
516 |
+
return Mage::getUrl('ewayrapid/sharedpage/iframe', array('_secure'=>true));
|
517 |
+
} elseif (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
518 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
|
519 |
+
&& Mage::getSingleton('core/session')->getCheckoutExtension()
|
520 |
+
) {
|
521 |
+
return Mage::getUrl('ewayrapid/transparent/build', array('_secure'=>true));
|
522 |
+
}
|
523 |
+
return null;
|
524 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
}
|
app/code/community/Eway/Rapid31/Model/Method/Saved.php
CHANGED
@@ -1,287 +1,285 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_Method_Saved extends Eway_Rapid31_Model_Method_Notsaved implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
3 |
-
{
|
4 |
-
protected $_code = 'ewayrapid_saved';
|
5 |
-
|
6 |
-
protected $_formBlockType = 'ewayrapid/form_direct_saved';
|
7 |
-
protected $_infoBlockType = 'ewayrapid/info_direct_saved';
|
8 |
-
|
9 |
-
protected $_canCapturePartial = true;
|
10 |
-
|
11 |
-
protected $_billing = null;
|
12 |
-
|
13 |
-
public function __construct()
|
14 |
-
{
|
15 |
-
parent::__construct();
|
16 |
-
if (!$this->_isBackendOrder) {
|
17 |
-
if (!Mage::helper('ewayrapid')->isBackendOrder()) {
|
18 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
19 |
-
$this->_infoBlockType = 'ewayrapid/info_transparent_saved';
|
20 |
-
$this->_formBlockType = 'ewayrapid/form_transparent_saved';
|
21 |
-
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
22 |
-
$this->_infoBlockType = 'ewayrapid/info_sharedpage_saved';
|
23 |
-
$this->_formBlockType = 'ewayrapid/form_sharedpage_saved';
|
24 |
-
}
|
25 |
-
}
|
26 |
-
}
|
27 |
-
}
|
28 |
-
|
29 |
-
protected function _isActive($storeId)
|
30 |
-
{
|
31 |
-
return parent::_isActive($storeId) &&
|
32 |
-
(Mage::helper('ewayrapid/customer')->getCurrentCustomer()
|
33 |
-
|| Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER);
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Assign data to info model instance
|
38 |
-
*
|
39 |
-
* @param mixed $data
|
40 |
-
* @return Mage_Payment_Model_Info
|
41 |
-
*/
|
42 |
-
public function assignData($data)
|
43 |
-
{
|
44 |
-
if (!($data instanceof Varien_Object)) {
|
45 |
-
$data = new Varien_Object($data);
|
46 |
-
}
|
47 |
-
$info = $this->getInfoInstance();
|
48 |
-
|
49 |
-
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
|
50 |
-
&& !$this->_isBackendOrder
|
51 |
-
) {
|
52 |
-
$info->setTransparentSaved($data->getTransparentSaved());
|
53 |
-
}
|
54 |
-
|
55 |
-
if($data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW) {
|
56 |
-
Mage::helper('ewayrapid')->clearSessionSharedpage();
|
57 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
58 |
-
&& !$this->_isBackendOrder
|
59 |
-
) {
|
60 |
-
Mage::getSingleton('core/session')->setData('newToken', 1);
|
61 |
-
}
|
62 |
-
$info->setIsNewToken(true);
|
63 |
-
} else {
|
64 |
-
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
65 |
-
&& !$this->_isBackendOrder
|
66 |
-
) {
|
67 |
-
Mage::getSingleton('core/session')->setData('editToken', $data->getSavedToken());
|
68 |
-
}
|
69 |
-
|
70 |
-
$info->setSavedToken($data->getSavedToken());
|
71 |
-
// Update token
|
72 |
-
if($data->getCcOwner()) {
|
73 |
-
$info->setIsUpdateToken(true);
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
parent::assignData($data);
|
78 |
-
|
79 |
-
Mage::helper('ewayrapid')->serializeInfoInstance($info);
|
80 |
-
|
81 |
-
return $this;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Validate payment method information object
|
86 |
-
*
|
87 |
-
* @param Mage_Payment_Model_Info $info
|
88 |
-
* @return Mage_Payment_Model_Abstract
|
89 |
-
*/
|
90 |
-
public function validate()
|
91 |
-
{
|
92 |
-
$info = $this->getInfoInstance();
|
93 |
-
if($info->getIsNewToken()) {
|
94 |
-
parent::validate();
|
95 |
-
}
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
*
|
104 |
-
*
|
105 |
-
* @param
|
106 |
-
*
|
107 |
-
*
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
$
|
115 |
-
$payment->
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
$
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
$
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
*
|
157 |
-
*
|
158 |
-
*
|
159 |
-
* @
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
$
|
168 |
-
|
169 |
-
$
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
$info
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
$
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
*
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
*
|
251 |
-
*
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
*
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
*
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
}
|
287 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_Method_Saved extends Eway_Rapid31_Model_Method_Notsaved implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
3 |
+
{
|
4 |
+
protected $_code = 'ewayrapid_saved';
|
5 |
+
|
6 |
+
protected $_formBlockType = 'ewayrapid/form_direct_saved';
|
7 |
+
protected $_infoBlockType = 'ewayrapid/info_direct_saved';
|
8 |
+
|
9 |
+
protected $_canCapturePartial = true;
|
10 |
+
|
11 |
+
protected $_billing = null;
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
if (!$this->_isBackendOrder) {
|
17 |
+
if (!Mage::helper('ewayrapid')->isBackendOrder()) {
|
18 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
19 |
+
$this->_infoBlockType = 'ewayrapid/info_transparent_saved';
|
20 |
+
$this->_formBlockType = 'ewayrapid/form_transparent_saved';
|
21 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
22 |
+
$this->_infoBlockType = 'ewayrapid/info_sharedpage_saved';
|
23 |
+
$this->_formBlockType = 'ewayrapid/form_sharedpage_saved';
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _isActive($storeId)
|
30 |
+
{
|
31 |
+
return parent::_isActive($storeId) &&
|
32 |
+
(Mage::helper('ewayrapid/customer')->getCurrentCustomer()
|
33 |
+
|| Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER);
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Assign data to info model instance
|
38 |
+
*
|
39 |
+
* @param mixed $data
|
40 |
+
* @return Mage_Payment_Model_Info
|
41 |
+
*/
|
42 |
+
public function assignData($data)
|
43 |
+
{
|
44 |
+
if (!($data instanceof Varien_Object)) {
|
45 |
+
$data = new Varien_Object($data);
|
46 |
+
}
|
47 |
+
$info = $this->getInfoInstance();
|
48 |
+
|
49 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
|
50 |
+
&& !$this->_isBackendOrder
|
51 |
+
) {
|
52 |
+
$info->setTransparentSaved($data->getTransparentSaved());
|
53 |
+
}
|
54 |
+
|
55 |
+
if ($data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW) {
|
56 |
+
Mage::helper('ewayrapid')->clearSessionSharedpage();
|
57 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
58 |
+
&& !$this->_isBackendOrder
|
59 |
+
) {
|
60 |
+
Mage::getSingleton('core/session')->setData('newToken', 1);
|
61 |
+
}
|
62 |
+
$info->setIsNewToken(true);
|
63 |
+
} else {
|
64 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
65 |
+
&& !$this->_isBackendOrder
|
66 |
+
) {
|
67 |
+
Mage::getSingleton('core/session')->setData('editToken', $data->getSavedToken());
|
68 |
+
}
|
69 |
+
|
70 |
+
$info->setSavedToken($data->getSavedToken());
|
71 |
+
// Update token
|
72 |
+
if ($data->getCcOwner()) {
|
73 |
+
$info->setIsUpdateToken(true);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
parent::assignData($data);
|
78 |
+
|
79 |
+
Mage::helper('ewayrapid')->serializeInfoInstance($info);
|
80 |
+
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Validate payment method information object
|
86 |
+
*
|
87 |
+
* @param Mage_Payment_Model_Info $info
|
88 |
+
* @return Mage_Payment_Model_Abstract
|
89 |
+
*/
|
90 |
+
public function validate()
|
91 |
+
{
|
92 |
+
$info = $this->getInfoInstance();
|
93 |
+
if ($info->getIsNewToken()) {
|
94 |
+
parent::validate();
|
95 |
+
}
|
96 |
+
// TODO: Check if this token is still Active using GET /Customer endpoint.
|
97 |
+
|
98 |
+
return $this;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Authorize & Capture a payment
|
103 |
+
*
|
104 |
+
* @param Varien_Object $payment
|
105 |
+
* @param float $amount
|
106 |
+
*
|
107 |
+
* @return Mage_Payment_Model_Abstract
|
108 |
+
*/
|
109 |
+
public function capture(Varien_Object $payment, $amount)
|
110 |
+
{
|
111 |
+
if (!$this->_isBackendOrder) {
|
112 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
113 |
+
$transID = Mage::getSingleton('core/session')->getData('ewayTransactionID');
|
114 |
+
$payment->setTransactionId($transID);
|
115 |
+
$payment->setIsTransactionClosed(0);
|
116 |
+
Mage::getSingleton('core/session')->unsetData('ewayTransactionID');
|
117 |
+
return $this;
|
118 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT ) {
|
119 |
+
Mage::getModel('ewayrapid/request_transparent')->setTransaction($payment);
|
120 |
+
return $this;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/* @var Mage_Sales_Model_Order_Payment $payment */
|
125 |
+
if ($amount <= 0) {
|
126 |
+
Mage::throwException(Mage::helper('payment')->__('Invalid amount for capture.'));
|
127 |
+
}
|
128 |
+
$request = Mage::getModel('ewayrapid/request_token');
|
129 |
+
|
130 |
+
$amount = round($amount * 100);
|
131 |
+
if ($this->_isPreauthCapture($payment)) {
|
132 |
+
$previousCapture = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
133 |
+
if ($previousCapture) {
|
134 |
+
$customer = Mage::getModel('customer/customer')->load($payment->getOrder()->getCustomerId());
|
135 |
+
Mage::helper('ewayrapid/customer')->setCurrentCustomer($customer);
|
136 |
+
|
137 |
+
/* @var Mage_Sales_Model_Order_Payment_Transaction $previousCapture */
|
138 |
+
$request->doTransaction($payment, $amount);
|
139 |
+
$payment->setParentTransactionId($previousCapture->getParentTxnId());
|
140 |
+
} else {
|
141 |
+
$request->doCapturePayment($payment, $amount);
|
142 |
+
}
|
143 |
+
} else {
|
144 |
+
if (!$payment->getIsRecurring()) {
|
145 |
+
$this->_shouldCreateOrUpdateToken($payment, $request);
|
146 |
+
}
|
147 |
+
$request->doTransaction($payment, $amount);
|
148 |
+
}
|
149 |
+
|
150 |
+
return $this;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Authorize a payment
|
155 |
+
*
|
156 |
+
* @param Varien_Object $payment
|
157 |
+
* @param float $amount
|
158 |
+
*
|
159 |
+
* @return Mage_Payment_Model_Abstract
|
160 |
+
*/
|
161 |
+
public function authorize(Varien_Object $payment, $amount)
|
162 |
+
{
|
163 |
+
if (!$this->_isBackendOrder) {
|
164 |
+
if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
|
165 |
+
$transID = Mage::getSingleton('core/session')->getData('ewayTransactionID');
|
166 |
+
$payment->setTransactionId($transID);
|
167 |
+
$payment->setIsTransactionClosed(0);
|
168 |
+
Mage::getSingleton('core/session')->unsetData('ewayTransactionID');
|
169 |
+
return $this;
|
170 |
+
} elseif ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
|
171 |
+
Mage::getModel('ewayrapid/request_transparent')->setTransaction($payment);
|
172 |
+
return $this;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
/* @var Mage_Sales_Model_Order_Payment $payment */
|
177 |
+
if ($amount <= 0) {
|
178 |
+
Mage::throwException(Mage::helper('payment')->__('Invalid amount for authorize.'));
|
179 |
+
}
|
180 |
+
$request = Mage::getModel('ewayrapid/request_token');
|
181 |
+
|
182 |
+
/** @todo there's an error in case recurring profile */
|
183 |
+
if (!$payment->getIsRecurring()) {
|
184 |
+
$this->_shouldCreateOrUpdateToken($payment, $request);
|
185 |
+
}
|
186 |
+
|
187 |
+
$amount = round($amount * 100);
|
188 |
+
$request->doAuthorisation($payment, $amount);
|
189 |
+
|
190 |
+
return $this;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
195 |
+
* @param Eway_Rapid31_Model_Request_Token $request
|
196 |
+
*/
|
197 |
+
public function _shouldCreateOrUpdateToken(Mage_Sales_Model_Order_Payment $payment, Eway_Rapid31_Model_Request_Token $request)
|
198 |
+
{
|
199 |
+
$order = $payment->getOrder();
|
200 |
+
$billing = ($this->_getBilling() == null) ? $order->getBillingAddress() : $this->_getBilling();
|
201 |
+
$info = $this->getInfoInstance();
|
202 |
+
|
203 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
204 |
+
if ($info->getIsNewToken()) {
|
205 |
+
$request->createNewToken($billing, $info);
|
206 |
+
$info->setSavedToken(Mage::helper('ewayrapid/customer')->getLastTokenId());
|
207 |
+
Mage::helper('ewayrapid')->serializeInfoInstance($info);
|
208 |
+
} elseif ($info->getIsUpdateToken()) {
|
209 |
+
$request->updateToken($billing, $info);
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
public function _setBilling(Mage_Sales_Model_Quote_Address $billing)
|
214 |
+
{
|
215 |
+
$this->_billing = $billing;
|
216 |
+
}
|
217 |
+
|
218 |
+
public function _getBilling()
|
219 |
+
{
|
220 |
+
return $this->_billing;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Validate RP data
|
225 |
+
*
|
226 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
227 |
+
*/
|
228 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
229 |
+
{
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Submit RP to the gateway
|
235 |
+
*
|
236 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
237 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
238 |
+
*/
|
239 |
+
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
|
240 |
+
Mage_Payment_Model_Info $paymentInfo
|
241 |
+
)
|
242 |
+
{
|
243 |
+
$profile->setReferenceId(strtoupper(uniqid()));
|
244 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Fetch RP details
|
249 |
+
*
|
250 |
+
* @param string $referenceId
|
251 |
+
* @param Varien_Object $result
|
252 |
+
*/
|
253 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
254 |
+
{
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Whether can get recurring profile details
|
260 |
+
*/
|
261 |
+
public function canGetRecurringProfileDetails()
|
262 |
+
{
|
263 |
+
return true;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Update RP data
|
268 |
+
*
|
269 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
270 |
+
*/
|
271 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
272 |
+
{
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Manage status
|
278 |
+
*
|
279 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
280 |
+
*/
|
281 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
282 |
+
{
|
283 |
+
|
284 |
+
}
|
|
|
|
|
285 |
}
|
app/code/community/Eway/Rapid31/Model/Observer.php
CHANGED
@@ -1,293 +1,298 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*/
|
5 |
-
class Eway_Rapid31_Model_Observer
|
6 |
-
|
7 |
-
|
8 |
-
var
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
)
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
$
|
133 |
-
$
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
$
|
143 |
-
|
144 |
-
|
145 |
-
$
|
146 |
-
|
147 |
-
$
|
148 |
-
|
149 |
-
|
150 |
-
$
|
151 |
-
|
152 |
-
$additional
|
153 |
-
$
|
154 |
-
$
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
//
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
)
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
$item
|
242 |
-
$item->
|
243 |
-
$item->
|
244 |
-
$item->
|
245 |
-
$item->
|
246 |
-
$
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
}
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
293 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
class Eway_Rapid31_Model_Observer
|
6 |
+
{
|
7 |
+
|
8 |
+
/* @var Magento_Sales_Model_Order_Invoice*/
|
9 |
+
public $invoice;
|
10 |
+
|
11 |
+
public function myCards()
|
12 |
+
{
|
13 |
+
|
14 |
+
}
|
15 |
+
|
16 |
+
public function checkCustomerMark()
|
17 |
+
{
|
18 |
+
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
|
19 |
+
$fraudEnabled = Mage::getStoreConfig('payment/ewayrapid_general/block_fraud_customers');
|
20 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
21 |
+
$markFraud = $customer->getMarkFraud();
|
22 |
+
$unblock = $customer->getBlockFraudCustomer();
|
23 |
+
if ((int)$markFraud === 1
|
24 |
+
&& $fraudEnabled
|
25 |
+
&& (int)$unblock === 0
|
26 |
+
) {
|
27 |
+
Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
|
28 |
+
Mage::app()->getResponse()->sendResponse();
|
29 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Your latest payment is being reviewed and you cannot place a new order temporarily. Please try again later.'));
|
30 |
+
exit;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public function sales_order_save_before($observer) {
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
public function sales_order_save_after($observer) {
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
public function sales_order_place_before($observer) {
|
44 |
+
// Check order fraud here
|
45 |
+
// ...
|
46 |
+
$fraud = Mage::getSingleton('core/session')->getData('fraud');
|
47 |
+
if($fraud === 1) {
|
48 |
+
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
public function sales_order_place_after($observer) {
|
53 |
+
// Check order fraud here
|
54 |
+
// ...
|
55 |
+
|
56 |
+
$fraud = Mage::getSingleton('core/session')->getData('fraud');
|
57 |
+
if($fraud === 1) {
|
58 |
+
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
public function sales_order_invoice_save_after($observer)
|
63 |
+
{
|
64 |
+
try {
|
65 |
+
/* @var $order Magento_Sales_Model_Order_Invoice */
|
66 |
+
$this->invoice = $observer->getEvent()->getInvoice();
|
67 |
+
$this->invoice->sendEmail();
|
68 |
+
} catch (Mage_Core_Exception $e) {
|
69 |
+
Mage::log("Error sending invoice email: " . $e->getMessage());
|
70 |
+
}
|
71 |
+
return $this;
|
72 |
+
}
|
73 |
+
|
74 |
+
public function checkout_submit_all_after(Varien_Event_Observer $observer)
|
75 |
+
{
|
76 |
+
$fraud = Mage::getSingleton('core/session')->getData('fraud');
|
77 |
+
$comment = Mage::getSingleton('core/session')->getData('fraudMessage');
|
78 |
+
// Read setting config enabled fraud or not
|
79 |
+
if ($fraud === 1 && $order = $observer->getEvent()->getOrder()) {
|
80 |
+
$order->setState('fraud');
|
81 |
+
$order->setStatus('fraud');
|
82 |
+
if ($comment) {
|
83 |
+
$comment = 'An order is marked as Suspected Fraud. Because it contains: ' . $comment;
|
84 |
+
$order->addStatusHistoryComment($comment)
|
85 |
+
->setIsVisibleOnFront(false)
|
86 |
+
->setIsCustomerNotified(false);
|
87 |
+
}
|
88 |
+
$order->save();
|
89 |
+
|
90 |
+
// Update user to fraud
|
91 |
+
$session = Mage::getSingleton('customer/session');
|
92 |
+
if ($session->isLoggedIn()) {
|
93 |
+
$customer = $session->getCustomer();
|
94 |
+
$customer->setData('mark_fraud', 1);
|
95 |
+
$customer->save();
|
96 |
+
}
|
97 |
+
|
98 |
+
Mage::getSingleton('core/session')->unsetData('fraud');
|
99 |
+
Mage::getSingleton('core/session')->unsetData('fraudMessage');
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Update eway transaction for order
|
105 |
+
* @param Varien_Event_Observer $observer
|
106 |
+
*/
|
107 |
+
public function checkout_type_onepage_save_order_after(Varien_Event_Observer $observer)
|
108 |
+
{
|
109 |
+
$order = $observer->getData('order');
|
110 |
+
$order->setEwayTransactionId($order->getPayment()->getTransactionId());
|
111 |
+
$order->save();
|
112 |
+
|
113 |
+
}
|
114 |
+
/*
|
115 |
+
* create order of recurring profile
|
116 |
+
*
|
117 |
+
* @param Varien_Event_Observer $observer
|
118 |
+
*/
|
119 |
+
public function createRecurringOrder(Varien_Event_Observer $observer)
|
120 |
+
{
|
121 |
+
$profiles = $observer->getEvent()->getRecurringProfiles();
|
122 |
+
|
123 |
+
if (isset($profiles[0])) {
|
124 |
+
/** @var Mage_Sales_Model_Recurring_Profile $profile */
|
125 |
+
$profile = $profiles[0];
|
126 |
+
} else {
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
|
130 |
+
//if Billing Frequency <= 0 or isn't numeric, Status of recurring profile changed to canceled
|
131 |
+
if (!$profile->getPeriodFrequency()
|
132 |
+
|| (string)(int) $profile->getPeriodFrequency() !== ltrim($profile->getPeriodFrequency(), '0')
|
133 |
+
|| (int) $profile->getPeriodFrequency() <= 0
|
134 |
+
) {
|
135 |
+
$profile->cancel();
|
136 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Billing Frequency is wrong. It must be numeric and greater than 0. Status of recurring profile is changed to canceled'));
|
137 |
+
$session = Mage::getSingleton('checkout/type_onepage')->getCheckout();
|
138 |
+
$session->setLastRecurringProfileIds(null);
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
$quote = $observer->getEvent()->getQuote();
|
143 |
+
|
144 |
+
/** @var Eway_Rapid31_Model_RecurringProfile $recurringProfile */
|
145 |
+
$recurringProfile = Mage::getModel('ewayrapid/recurringProfile');
|
146 |
+
$orderItemInfo = $profile->getOrderItemInfo();
|
147 |
+
$buyRequest = unserialize($orderItemInfo['info_buyRequest']);
|
148 |
+
|
149 |
+
// timezone used as store's timezone
|
150 |
+
$startDate = isset($buyRequest['recurring_profile_start_datetime']) && $buyRequest['recurring_profile_start_datetime'] ? $buyRequest['recurring_profile_start_datetime'] : null;
|
151 |
+
|
152 |
+
$additional = $profile->getAdditionalInfo();
|
153 |
+
$token = $recurringProfile->processToken($quote);
|
154 |
+
$token = json_decode($token, true);
|
155 |
+
$additional['token'] = $token;
|
156 |
+
$additional['startDate'] = $startDate;
|
157 |
+
$additional['initialFee'] = true;
|
158 |
+
$profile->setAdditionalInfo($additional);
|
159 |
+
$profile->save();
|
160 |
+
|
161 |
+
// charge Initial Fee if It is greater than 0 and is numeric
|
162 |
+
if ($profile->getInitAmount()
|
163 |
+
&& (float) $profile->getInitAmount() > 0
|
164 |
+
//&& (string)(int) $profile->getInitAmount() === ltrim($profile->getInitAmount(), '0')
|
165 |
+
) {
|
166 |
+
try {
|
167 |
+
$recurringProfile->processInitialFee($profile);
|
168 |
+
} catch (Exception $e) {
|
169 |
+
$additional = $profile->getAdditionalInfo();
|
170 |
+
$additional['initialFee'] = false;
|
171 |
+
if ($profile->getInitMayFail() == '1') {
|
172 |
+
// Allow Initial Fee Failure = yes
|
173 |
+
// change status recurring profile = suspended
|
174 |
+
$profile->suspend();
|
175 |
+
$errorMessage = Mage::getSingleton('core/session')->getData('errorMessage');
|
176 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while making the transaction by Initial Fee (Error message: %s). Status of recurring profile is changed to suspended.', $errorMessage));
|
177 |
+
return;
|
178 |
+
|
179 |
+
} else {
|
180 |
+
// Allow Initial Fee Failure = no
|
181 |
+
// Auto Bill on Next Cycle = no
|
182 |
+
// set additionalInfo['outstanding'] = Initial Fee
|
183 |
+
if (!$profile->getBillFailedLater()) {
|
184 |
+
$additional['outstanding'] = $profile->getInitAmount();
|
185 |
+
}
|
186 |
+
}
|
187 |
+
$profile->setAdditionalInfo($additional);
|
188 |
+
$profile->save();
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
// check current time >= started time
|
193 |
+
if (!$startDate || $recurringProfile->checkRecurringTimeStart($startDate)) {
|
194 |
+
try {
|
195 |
+
// create order
|
196 |
+
// before day = current date // check if frequency >1day
|
197 |
+
// next day with current date
|
198 |
+
$recurringProfile->processRequest($profile);
|
199 |
+
} catch (Exception $e) {
|
200 |
+
$errorMessage = Mage::getSingleton('core/session')->getData('errorMessage');
|
201 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. (Error message: %s)', $errorMessage));
|
202 |
+
// suspend recurring profile when response data contains error and/or TransactionID is null
|
203 |
+
$checkPaymentFailures = $recurringProfile->checkMaxPaymentFailures($profile);
|
204 |
+
if (!$checkPaymentFailures) {
|
205 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Out of Payment failures. Status of recurring profile is changed to suspended.'));
|
206 |
+
}
|
207 |
+
return;
|
208 |
+
}
|
209 |
+
} else {
|
210 |
+
// not created order
|
211 |
+
// before day = null
|
212 |
+
// next day = date of started time
|
213 |
+
$additionalInfo = $profile->getAdditionalInfo();
|
214 |
+
$additionalInfo['nextDate'] = $startDate;
|
215 |
+
$profile->setAdditionalInfo($additionalInfo);
|
216 |
+
$profile->save();
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* load recurring profiles if methodcode = ewayrapid_saved or ewayrapid_ewayone
|
222 |
+
*
|
223 |
+
* @param array $methodCode
|
224 |
+
* @return array
|
225 |
+
*/
|
226 |
+
protected function _loadProfileByMethod($methodCode = array('ewayrapid_saved', 'ewayrapid_ewayone'))
|
227 |
+
{
|
228 |
+
$modelRecurringProfile = Mage::getModel('sales/recurring_profile')->getCollection()
|
229 |
+
->addFieldToFilter('method_code', array('in' => $methodCode))
|
230 |
+
->addFieldToFilter('state', 'active')
|
231 |
+
->addFieldToFilter('additional_info', array('notnull' => true))
|
232 |
+
->addFieldToFilter(
|
233 |
+
'period_max_cycles', array(
|
234 |
+
array('null' => true),
|
235 |
+
array('gt' => 0)
|
236 |
+
)
|
237 |
+
);
|
238 |
+
$profiles = array();
|
239 |
+
|
240 |
+
foreach ($modelRecurringProfile as $item) {
|
241 |
+
/** @var Mage_Sales_Model_Recurring_Profile $item */
|
242 |
+
$additionalInfo = unserialize($item->getAdditionalInfo());
|
243 |
+
$billingInfo = unserialize($item->getBillingAddressInfo());
|
244 |
+
$addressInfo = unserialize($item->getShippingAddressInfo());
|
245 |
+
$orderItemInfo = unserialize($item->getOrderItemInfo());
|
246 |
+
$orderInfo = unserialize($item->getOrderInfo());
|
247 |
+
$item->setBillingAddressInfo($billingInfo);
|
248 |
+
$item->setShippingAddressInfo($addressInfo);
|
249 |
+
$item->setOrderItemInfo($orderItemInfo);
|
250 |
+
$item->setAdditionalInfo($additionalInfo);
|
251 |
+
$item->setOrderInfo($orderInfo);
|
252 |
+
$profiles[] = $item;
|
253 |
+
}
|
254 |
+
return $profiles;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* cron recurring profile to create order
|
259 |
+
*/
|
260 |
+
public function cronRecurringOrder()
|
261 |
+
{
|
262 |
+
$profiles = $this->_loadProfileByMethod();
|
263 |
+
foreach ($profiles as $profile) {
|
264 |
+
/** @var Mage_Sales_Model_Recurring_Profile $profile */
|
265 |
+
/** @var Eway_Rapid31_Model_RecurringProfile $recurringProfile */
|
266 |
+
$recurringProfile = Mage::getModel('ewayrapid/recurringProfile');
|
267 |
+
|
268 |
+
$recurringProfile->updateNextDate($profile);
|
269 |
+
|
270 |
+
// check run cron job conditions
|
271 |
+
if ($recurringProfile->checkRecurringProfileRunCronJob($profile)) {
|
272 |
+
// check charge money initial Fee
|
273 |
+
$additional = $profile->getAdditionalInfo();
|
274 |
+
if ($additional['initialFee'] == false) {
|
275 |
+
if (!$profile->getInitMayFail() && $profile->getBillFailedLater()) {
|
276 |
+
try {
|
277 |
+
$recurringProfile->processInitialFee($profile);
|
278 |
+
$additional['initialFee'] = true;
|
279 |
+
$profile->setAdditionalInfo($additional);
|
280 |
+
$profile->save();
|
281 |
+
} catch (Exception $e) {
|
282 |
+
Mage::logException($e);
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
$profile->setIsCronJob(true);
|
288 |
+
|
289 |
+
try {
|
290 |
+
$recurringProfile->processRequest($profile);
|
291 |
+
} catch (Exception $e) {
|
292 |
+
$paymentFailures = $recurringProfile->checkMaxPaymentFailures($profile);
|
293 |
+
Mage::logException($e);
|
294 |
+
}
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
}
|
app/code/community/Eway/Rapid31/Model/RecurringProfile.php
CHANGED
@@ -1,531 +1,532 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Eway_Rapid31_Model_RecurringProfile
|
4 |
-
{
|
5 |
-
|
6 |
-
/**
|
7 |
-
* @var Mage_Sales_Model_Recurring_Profile
|
8 |
-
*/
|
9 |
-
protected $_recurringProfile;
|
10 |
-
/**
|
11 |
-
* eway transaction id
|
12 |
-
* @var string
|
13 |
-
*/
|
14 |
-
protected $_txdId;
|
15 |
-
/**
|
16 |
-
* total price of all nominal items. i.e $10*5 = $50
|
17 |
-
* @var float
|
18 |
-
*/
|
19 |
-
protected $_price;
|
20 |
-
/**
|
21 |
-
* shipping fee
|
22 |
-
* @var float
|
23 |
-
*/
|
24 |
-
protected $_shippingAmount;
|
25 |
-
/**
|
26 |
-
* tax amount
|
27 |
-
* @var float
|
28 |
-
*/
|
29 |
-
protected $_taxAmount;
|
30 |
-
/**
|
31 |
-
* grand total
|
32 |
-
* @var float
|
33 |
-
*/
|
34 |
-
protected $_amount;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* period type
|
38 |
-
*
|
39 |
-
* @var string
|
40 |
-
*/
|
41 |
-
protected $_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @param Mage_Sales_Model_Recurring_Profile $profile
|
45 |
-
* @throws Exception
|
46 |
-
*/
|
47 |
-
public function processRequest(Mage_Sales_Model_Recurring_Profile $profile)
|
48 |
-
{
|
49 |
-
$this->_recurringProfile = $profile;
|
50 |
-
try {
|
51 |
-
$this->_checkRecurringProfile();
|
52 |
-
$this->_checkoutRecurring();
|
53 |
-
$this->_processRecurringProfile();
|
54 |
-
} catch (Exception $e) {
|
55 |
-
throw $e;
|
56 |
-
}
|
57 |
-
$this->updateBeforeDate();
|
58 |
-
$this->nextDate();
|
59 |
-
$this->updatePeriodMaxCycles();
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* check eway active, check whether method code is eway
|
64 |
-
*/
|
65 |
-
protected function _checkRecurringProfile()
|
66 |
-
{
|
67 |
-
$methodCode = $this->_recurringProfile->getMethodCode();
|
68 |
-
if ($methodCode != 'ewayrapid_saved' && $methodCode != 'ewayrapid_ewayone') {
|
69 |
-
|
70 |
-
}
|
71 |
-
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
72 |
-
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* charge money for recurring item
|
78 |
-
*/
|
79 |
-
protected function _checkoutRecurring()
|
80 |
-
{
|
81 |
-
/** @var Mage_Sales_Model_Order $order */
|
82 |
-
$order = Mage::getModel('sales/order');
|
83 |
-
|
84 |
-
$item = new Varien_Object($this->_recurringProfile->getOrderItemInfo());
|
85 |
-
|
86 |
-
$this->_price = $item->getBasePrice() * $item->getQty();
|
87 |
-
|
88 |
-
$additionalInfo = $this->_recurringProfile->getAdditionalInfo();
|
89 |
-
|
90 |
-
// check isset TrialBilling
|
91 |
-
// Trial Billing Frequency <= 0 or isn't numeric => failure
|
92 |
-
if ($this->_recurringProfile->getTrialBillingAmount()
|
93 |
-
&& $this->_recurringProfile->getTrialPeriodFrequency()
|
94 |
-
&& $this->_recurringProfile->getTrialPeriodMaxCycles()
|
95 |
-
&& $this->_recurringProfile->getTrialPeriodUnit()
|
96 |
-
&& (string)(int) $this->_recurringProfile->getTrialPeriodFrequency() === ltrim($this->_recurringProfile->getTrialPeriodFrequency(), '0')
|
97 |
-
&& (int) $this->_recurringProfile->getTrialPeriodFrequency() > 0
|
98 |
-
) {
|
99 |
-
$trialPeriodMaxCycles = (int)$this->_recurringProfile->getTrialPeriodMaxCycles();
|
100 |
-
if (!isset($additionalInfo['trialPeriodMaxCycles'])) {
|
101 |
-
$additionalInfo['trialPeriodMaxCycles'] = $trialPeriodMaxCycles;
|
102 |
-
$this->_recurringProfile->setAdditionalInfo($additionalInfo);
|
103 |
-
$this->_price = $this->_recurringProfile->getTrialBillingAmount();
|
104 |
-
$this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
|
105 |
-
}
|
106 |
-
|
107 |
-
$this->
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
$this->
|
114 |
-
$this->
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
->
|
121 |
-
->
|
122 |
-
->
|
123 |
-
->
|
124 |
-
->
|
125 |
-
->
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
$
|
131 |
-
|
132 |
-
->
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
$
|
137 |
-
|
138 |
-
|
139 |
-
$order->
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
$payment
|
144 |
-
$payment->
|
145 |
-
$payment->
|
146 |
-
|
147 |
-
|
148 |
-
$
|
149 |
-
|
150 |
-
|
151 |
-
$tokenId
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
$paymentAction
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
*
|
175 |
-
*
|
176 |
-
* @throws
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
$this->
|
183 |
-
|
184 |
-
$additionalInfo
|
185 |
-
$additionalInfo
|
186 |
-
$this->_recurringProfile->
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
$
|
200 |
-
$
|
201 |
-
$
|
202 |
-
$
|
203 |
-
$
|
204 |
-
$
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
$productItemInfo->
|
210 |
-
$productItemInfo->
|
211 |
-
$productItemInfo->
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
$
|
217 |
-
$
|
218 |
-
$payment
|
219 |
-
|
220 |
-
->
|
221 |
-
|
222 |
-
$order->
|
223 |
-
$
|
224 |
-
$
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
$
|
230 |
-
|
231 |
-
->
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
$session
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
*
|
243 |
-
*
|
244 |
-
* @
|
245 |
-
* @
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
$
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
$ewaySave
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
$paymentObj
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
$ewaySave->
|
269 |
-
$
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
$
|
283 |
-
$additionalInfo = $
|
284 |
-
$additionalInfo
|
285 |
-
$this->_recurringProfile->
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
*
|
292 |
-
*
|
293 |
-
*
|
294 |
-
* Timezone of
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
//
|
300 |
-
|
301 |
-
|
302 |
-
$
|
303 |
-
$
|
304 |
-
$
|
305 |
-
$date->
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
$
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
$
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
$
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
$additionalInfo = $
|
328 |
-
$additionalInfo
|
329 |
-
$this->_recurringProfile->
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
//
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
$
|
343 |
-
$this->_recurringProfile->
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
*
|
351 |
-
*
|
352 |
-
* @param $
|
353 |
-
* @param $
|
354 |
-
* @param $
|
355 |
-
* @
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
list($
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
*
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
$
|
385 |
-
$
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
*
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
*
|
416 |
-
*
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
$order
|
423 |
-
$
|
424 |
-
$
|
425 |
-
$
|
426 |
-
|
427 |
-
->
|
428 |
-
|
429 |
-
|
430 |
-
$
|
431 |
-
|
432 |
-
|
433 |
-
$order->
|
434 |
-
|
435 |
-
|
436 |
-
$payment
|
437 |
-
$payment
|
438 |
-
$payment->
|
439 |
-
$payment->
|
440 |
-
|
441 |
-
|
442 |
-
$
|
443 |
-
|
444 |
-
|
445 |
-
$
|
446 |
-
$
|
447 |
-
|
448 |
-
|
449 |
-
$ewaySave
|
450 |
-
$
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
*
|
464 |
-
*
|
465 |
-
*
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
$
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
$
|
478 |
-
$
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
* @param
|
485 |
-
* @
|
486 |
-
*
|
487 |
-
*
|
488 |
-
* Maximum Payment Failures
|
489 |
-
* Maximum Payment Failures
|
490 |
-
*
|
491 |
-
* if countFailures
|
492 |
-
* if
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
//
|
503 |
-
|
504 |
-
|
505 |
-
$profile->
|
506 |
-
$profile->
|
507 |
-
|
508 |
-
|
509 |
-
$
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
//
|
514 |
-
// if countFailures
|
515 |
-
|
516 |
-
|
517 |
-
$
|
518 |
-
$profile->
|
519 |
-
|
520 |
-
|
521 |
-
$
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
$
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
|
|
531 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Eway_Rapid31_Model_RecurringProfile
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @var Mage_Sales_Model_Recurring_Profile
|
8 |
+
*/
|
9 |
+
protected $_recurringProfile;
|
10 |
+
/**
|
11 |
+
* eway transaction id
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
protected $_txdId;
|
15 |
+
/**
|
16 |
+
* total price of all nominal items. i.e $10*5 = $50
|
17 |
+
* @var float
|
18 |
+
*/
|
19 |
+
protected $_price;
|
20 |
+
/**
|
21 |
+
* shipping fee
|
22 |
+
* @var float
|
23 |
+
*/
|
24 |
+
protected $_shippingAmount;
|
25 |
+
/**
|
26 |
+
* tax amount
|
27 |
+
* @var float
|
28 |
+
*/
|
29 |
+
protected $_taxAmount;
|
30 |
+
/**
|
31 |
+
* grand total
|
32 |
+
* @var float
|
33 |
+
*/
|
34 |
+
protected $_amount;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* period type
|
38 |
+
*
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
protected $_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
45 |
+
* @throws Exception
|
46 |
+
*/
|
47 |
+
public function processRequest(Mage_Sales_Model_Recurring_Profile $profile)
|
48 |
+
{
|
49 |
+
$this->_recurringProfile = $profile;
|
50 |
+
try {
|
51 |
+
$this->_checkRecurringProfile();
|
52 |
+
$this->_checkoutRecurring();
|
53 |
+
$this->_processRecurringProfile();
|
54 |
+
} catch (Exception $e) {
|
55 |
+
throw $e;
|
56 |
+
}
|
57 |
+
$this->updateBeforeDate();
|
58 |
+
$this->nextDate();
|
59 |
+
$this->updatePeriodMaxCycles();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* check eway active, check whether method code is eway
|
64 |
+
*/
|
65 |
+
protected function _checkRecurringProfile()
|
66 |
+
{
|
67 |
+
$methodCode = $this->_recurringProfile->getMethodCode();
|
68 |
+
if ($methodCode != 'ewayrapid_saved' && $methodCode != 'ewayrapid_ewayone') {
|
69 |
+
Mage::throwException(sprintf('Method "%s" is not eWAY Rapid (Saved).', $methodCode));
|
70 |
+
}
|
71 |
+
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
72 |
+
Mage::throwException(sprintf('Method "%s" is not available.', $methodCode));
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* charge money for recurring item
|
78 |
+
*/
|
79 |
+
protected function _checkoutRecurring()
|
80 |
+
{
|
81 |
+
/** @var Mage_Sales_Model_Order $order */
|
82 |
+
$order = Mage::getModel('sales/order');
|
83 |
+
|
84 |
+
$item = new Varien_Object($this->_recurringProfile->getOrderItemInfo());
|
85 |
+
|
86 |
+
$this->_price = $item->getBasePrice() * $item->getQty();
|
87 |
+
|
88 |
+
$additionalInfo = $this->_recurringProfile->getAdditionalInfo();
|
89 |
+
|
90 |
+
// check isset TrialBilling
|
91 |
+
// Trial Billing Frequency <= 0 or isn't numeric => failure
|
92 |
+
if ($this->_recurringProfile->getTrialBillingAmount()
|
93 |
+
&& $this->_recurringProfile->getTrialPeriodFrequency()
|
94 |
+
&& $this->_recurringProfile->getTrialPeriodMaxCycles()
|
95 |
+
&& $this->_recurringProfile->getTrialPeriodUnit()
|
96 |
+
&& (string)(int) $this->_recurringProfile->getTrialPeriodFrequency() === ltrim($this->_recurringProfile->getTrialPeriodFrequency(), '0')
|
97 |
+
&& (int) $this->_recurringProfile->getTrialPeriodFrequency() > 0
|
98 |
+
) {
|
99 |
+
$trialPeriodMaxCycles = (int)$this->_recurringProfile->getTrialPeriodMaxCycles();
|
100 |
+
if (!isset($additionalInfo['trialPeriodMaxCycles'])) {
|
101 |
+
$additionalInfo['trialPeriodMaxCycles'] = $trialPeriodMaxCycles;
|
102 |
+
$this->_recurringProfile->setAdditionalInfo($additionalInfo);
|
103 |
+
$this->_price = $this->_recurringProfile->getTrialBillingAmount();
|
104 |
+
$this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
|
105 |
+
} elseif (isset($additionalInfo['trialPeriodMaxCycles']) && $additionalInfo['trialPeriodMaxCycles'] > 0) {
|
106 |
+
$this->_price = $this->_recurringProfile->getTrialBillingAmount();
|
107 |
+
$this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
// calculate total amount
|
112 |
+
$this->_shippingAmount = $item->getBaseShippingAmount();
|
113 |
+
$this->_taxAmount = $item->getBaseTaxAmount();
|
114 |
+
$this->_amount = $this->_price + $this->_shippingAmount + $this->_taxAmount;
|
115 |
+
|
116 |
+
// init order
|
117 |
+
/** @var Mage_Sales_Model_Order_Item $orderItem */
|
118 |
+
$orderItem = Mage::getModel('sales/order_item')
|
119 |
+
->setName($item->getName())
|
120 |
+
->setSku($item->getSku())
|
121 |
+
->setDescription($item->getDescription())
|
122 |
+
->setQtyOrdered($item->getQty())
|
123 |
+
->setBasePrice($item->getBasePrice())
|
124 |
+
->setBaseTaxAmount($item->getBaseTaxAmount())
|
125 |
+
->setBaseRowTotalInclTax($item->getBaseRowTotalInclTax());
|
126 |
+
|
127 |
+
$order->addItem($orderItem);
|
128 |
+
|
129 |
+
$shippingInfo = $this->_recurringProfile->getShippingAddressInfo();
|
130 |
+
$shippingAddress = Mage::getModel('sales/order_address')
|
131 |
+
->setData($shippingInfo)
|
132 |
+
->setId(null);
|
133 |
+
|
134 |
+
// get base currency code
|
135 |
+
$orderInfo = new Varien_Object($this->_recurringProfile->getOrderInfo());
|
136 |
+
$currencyCode = $orderInfo->getBaseCurrencyCode();
|
137 |
+
|
138 |
+
$order->setShippingAddress($shippingAddress);
|
139 |
+
$order->setBaseCurrencyCode($currencyCode);
|
140 |
+
|
141 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
142 |
+
$payment = Mage::getModel('sales/order_payment');
|
143 |
+
$payment->setOrder($order);
|
144 |
+
$payment->setIsRecurring(true);
|
145 |
+
$payment->setIsInitialFee(true);
|
146 |
+
|
147 |
+
$customerId = $this->_recurringProfile->getCustomerId();
|
148 |
+
$payment->setCustomerId($customerId);
|
149 |
+
|
150 |
+
$tokenId = $additionalInfo['token']['saved_token'];
|
151 |
+
$payment->setTokenId($tokenId);
|
152 |
+
|
153 |
+
/** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
|
154 |
+
$ewaySave = Mage::getModel('ewayrapid/method_saved');
|
155 |
+
|
156 |
+
$paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
|
157 |
+
if ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
|
158 |
+
$ewaySave->authorize($payment, $this->_amount);
|
159 |
+
} elseif ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
160 |
+
$ewaySave->capture($payment, $this->_amount);
|
161 |
+
}
|
162 |
+
if (!$payment->getTransactionId()) {
|
163 |
+
throw new Exception('Transaction is not available');
|
164 |
+
} else {
|
165 |
+
$this->_txdId = $payment->getTransactionId();
|
166 |
+
}
|
167 |
+
/** @todo: change status of order = "eWAY Authorised"
|
168 |
+
* now status order = "processing"
|
169 |
+
*/
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Process notification from recurring profile payments
|
174 |
+
*
|
175 |
+
* @throws Exception
|
176 |
+
* @throws Mage_Core_Exception
|
177 |
+
*/
|
178 |
+
protected function _processRecurringProfile()
|
179 |
+
{
|
180 |
+
try {
|
181 |
+
$this->_registerRecurringProfilePaymentCapture();
|
182 |
+
if ($this->_periodType == Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL) {
|
183 |
+
$additionalInfo = $this->_recurringProfile->getAdditionalInfo();
|
184 |
+
$additionalInfo['trialPeriodMaxCycles'] -= 1;
|
185 |
+
$this->_recurringProfile->setAdditionalInfo($additionalInfo);
|
186 |
+
$this->_recurringProfile->save();
|
187 |
+
}
|
188 |
+
} catch (Mage_Core_Exception $e) {
|
189 |
+
throw $e;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Register recurring payment notification, create and process order
|
195 |
+
*/
|
196 |
+
protected function _registerRecurringProfilePaymentCapture()
|
197 |
+
{
|
198 |
+
$price = $this->_price;
|
199 |
+
$tax = $this->_taxAmount;
|
200 |
+
$shipping = $this->_shippingAmount;
|
201 |
+
$grandTotal = $this->_amount;
|
202 |
+
$periodType = $this->_periodType;
|
203 |
+
$transactionId = $this->_txdId;
|
204 |
+
$ewayMessage = '';
|
205 |
+
|
206 |
+
$productItemInfo = new Varien_Object;
|
207 |
+
/** @todo: response doesn't contain period type / payment type */
|
208 |
+
$productItemInfo->setPaymentType($periodType);
|
209 |
+
$productItemInfo->setTaxAmount($tax);
|
210 |
+
$productItemInfo->setShippingAmount($shipping);
|
211 |
+
$productItemInfo->setPrice($price);
|
212 |
+
|
213 |
+
|
214 |
+
/** @var Mage_Sales_Model_Recurring_Profile $recurringProfile */
|
215 |
+
$recurringProfile = $this->_recurringProfile;
|
216 |
+
$order = $recurringProfile->createOrder($productItemInfo);
|
217 |
+
$payment = $order->getPayment();
|
218 |
+
$payment->setTransactionId($transactionId)
|
219 |
+
->setPreparedMessage($ewayMessage)
|
220 |
+
->setIsTransactionClosed(0);
|
221 |
+
$order->save();
|
222 |
+
$this->_recurringProfile->addOrderRelation($order->getId());
|
223 |
+
$payment->registerCaptureNotification($grandTotal);
|
224 |
+
$order->save();
|
225 |
+
|
226 |
+
// notify customer
|
227 |
+
if ($invoice = $payment->getCreatedInvoice()) {
|
228 |
+
$message = Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
|
229 |
+
$comment = $order->sendNewOrderEmail()->addStatusHistoryComment($message)
|
230 |
+
->setIsCustomerNotified(true)
|
231 |
+
->save();
|
232 |
+
}
|
233 |
+
|
234 |
+
if (!$recurringProfile->getIsCronJob()) {
|
235 |
+
$session = Mage::getSingleton('checkout/type_onepage')->getCheckout();
|
236 |
+
$session->setLastOrderId($order->getId());
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* process token if customer create and edit token when checkout with recurring profile
|
242 |
+
*
|
243 |
+
* @param Mage_Sales_Model_Quote $quote
|
244 |
+
* @return string
|
245 |
+
* @throws Exception
|
246 |
+
*/
|
247 |
+
public function processToken(Mage_Sales_Model_Quote $quote)
|
248 |
+
{
|
249 |
+
try {
|
250 |
+
$billing = $quote->getBillingAddress();
|
251 |
+
$payment = $quote->getPayment();
|
252 |
+
|
253 |
+
/** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
|
254 |
+
$ewaySave = Mage::getModel('ewayrapid/method_saved');
|
255 |
+
$ewaySave->setData('info_instance', $payment);
|
256 |
+
|
257 |
+
/** @var Mage_Sales_Model_Order $order */
|
258 |
+
$order = Mage::getModel('sales/order');
|
259 |
+
/*$order->setBillingAddress($billing);*/
|
260 |
+
|
261 |
+
/** @var Mage_Sales_Model_Order_Payment $paymentObj */
|
262 |
+
$paymentObj = Mage::getModel('sales/order_payment');
|
263 |
+
$paymentObj->setOrder($order);
|
264 |
+
|
265 |
+
$request = Mage::getModel('ewayrapid/request_token');
|
266 |
+
|
267 |
+
$ewaySave->_setBilling($billing);
|
268 |
+
$ewaySave->_shouldCreateOrUpdateToken($paymentObj, $request);
|
269 |
+
return $payment->getAdditionalData();
|
270 |
+
} catch (Exception $e) {
|
271 |
+
throw $e;
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* update day was run of recurring profile when cron job create order
|
277 |
+
*/
|
278 |
+
public function updateBeforeDate()
|
279 |
+
{
|
280 |
+
// timezone used as store's timezone
|
281 |
+
$currentDate = date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));
|
282 |
+
$additionalInfo = $this->_recurringProfile->getAdditionalInfo();
|
283 |
+
$additionalInfo['beforeDate'] = $currentDate;
|
284 |
+
$this->_recurringProfile->setAdditionalInfo($additionalInfo);
|
285 |
+
$this->_recurringProfile->save();
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
/**
|
290 |
+
* @param null $startDate
|
291 |
+
*
|
292 |
+
* calculate the next date create order of recurring profile
|
293 |
+
* Timezone of startDate is store's timezone
|
294 |
+
* Timezone of startDatetime load into recurring profile is store's timezone
|
295 |
+
*/
|
296 |
+
public function nextDate($startDate = null)
|
297 |
+
{
|
298 |
+
// when recurring profile loaded, startDate updated by currentDate
|
299 |
+
// timezone used as store's timezone
|
300 |
+
if ($startDate == null) {
|
301 |
+
$startDate = $this->_recurringProfile->getStartDatetime();
|
302 |
+
$date = new DateTime($startDate, new DateTimeZone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE));
|
303 |
+
$timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
304 |
+
$date->setTimezone(new DateTimeZone($timezone));
|
305 |
+
$startDate = $date->format('Y-m-d');
|
306 |
+
}
|
307 |
+
|
308 |
+
$frequency = (int)$this->_recurringProfile->getPeriodFrequency();
|
309 |
+
$unit = $this->_recurringProfile->getPeriodUnit();
|
310 |
+
|
311 |
+
if ($unit === 'week') {
|
312 |
+
$unit = 'day';
|
313 |
+
$frequency = $frequency * 7;
|
314 |
+
}
|
315 |
+
if ($unit === 'two weeks') {
|
316 |
+
$unit = 'day';
|
317 |
+
$frequency = $frequency * 14;
|
318 |
+
}
|
319 |
+
|
320 |
+
$newDate = date('Y-m-d', strtotime('+' . $frequency . $unit, strtotime($startDate)));
|
321 |
+
|
322 |
+
if (!$this->_checkDate($unit, $frequency, $startDate, $newDate)) {
|
323 |
+
$newDate = date('Y-m-d', strtotime('-1day', strtotime(date('Y-m-1', strtotime('+1month', strtotime($newDate))))));
|
324 |
+
}
|
325 |
+
|
326 |
+
$additionalInfo = $this->_recurringProfile->getAdditionalInfo();
|
327 |
+
$additionalInfo['nextDate'] = $newDate;
|
328 |
+
$this->_recurringProfile->setAdditionalInfo($additionalInfo);
|
329 |
+
$this->_recurringProfile->save();
|
330 |
+
}
|
331 |
+
|
332 |
+
/**
|
333 |
+
* update period max cycles of recurring profile when cron job create order
|
334 |
+
*/
|
335 |
+
public function updatePeriodMaxCycles()
|
336 |
+
{
|
337 |
+
// edit period max cycles if It is greater than or equal 0 and is numeric
|
338 |
+
// If period max cycles <= 0 or null, recurring profile will run forever
|
339 |
+
if ($periodMaxCycles = $this->_recurringProfile->getPeriodMaxCycles()) {
|
340 |
+
if ((string)(int) $periodMaxCycles === ltrim($periodMaxCycles, '0') && $periodMaxCycles > 0) {
|
341 |
+
$periodMaxCycles = (int) $periodMaxCycles - 1;
|
342 |
+
$this->_recurringProfile->setPeriodMaxCycles($periodMaxCycles);
|
343 |
+
$this->_recurringProfile->save();
|
344 |
+
}
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* check date valid
|
350 |
+
*
|
351 |
+
* @param $unit
|
352 |
+
* @param $frequency
|
353 |
+
* @param $startDate
|
354 |
+
* @param $newDate
|
355 |
+
* @return bool
|
356 |
+
*/
|
357 |
+
protected function _checkDate($unit, $frequency, $startDate, $newDate)
|
358 |
+
{
|
359 |
+
if ('day' === $unit) {
|
360 |
+
return true;
|
361 |
+
}
|
362 |
+
|
363 |
+
list($oldYear, $oldMonth, $oldDay) = explode('-', date('Y-m-d', strtotime($startDate)));
|
364 |
+
list($newYear, $newMonth, $newDay) = explode('-', date('Y-m-d', strtotime($newDate)));
|
365 |
+
|
366 |
+
if (
|
367 |
+
($oldDay + (int)('day' == $unit ? $frequency : 0)) == $newDay
|
368 |
+
&& ($oldMonth + (int)('month' == $unit ? $frequency : 0)) == $newMonth
|
369 |
+
&& ($oldYear + (int)('year' == $unit ? $frequency : 0)) == $newYear
|
370 |
+
) {
|
371 |
+
return true;
|
372 |
+
}
|
373 |
+
return false;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* check run cron job conditions
|
378 |
+
*
|
379 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
380 |
+
* @return bool
|
381 |
+
*/
|
382 |
+
public function checkRecurringProfileRunCronJob(Mage_Sales_Model_Recurring_Profile $profile)
|
383 |
+
{
|
384 |
+
$additionalInfo = $profile->getAdditionalInfo();
|
385 |
+
$timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
386 |
+
// timezone used as store's timezone
|
387 |
+
$nextDate = new DateTime(date("Y-m-d", strtotime($additionalInfo['nextDate'])), new DateTimeZone($timezone));
|
388 |
+
$currentDate = new DateTime(date("Y-m-d", Mage::getModel('core/date')->timestamp(time())), new DateTimeZone($timezone));
|
389 |
+
if (!isset($additionalInfo['beforeDate']) || $additionalInfo['beforeDate'] == null) {
|
390 |
+
if ($nextDate == $currentDate) {
|
391 |
+
return true;
|
392 |
+
}
|
393 |
+
} else {
|
394 |
+
$beforeDate = new DateTime(date("Y-m-d", strtotime($additionalInfo['beforeDate'])), new DateTimeZone($timezone));
|
395 |
+
if ($beforeDate < $currentDate && $nextDate == $currentDate) {
|
396 |
+
return true;
|
397 |
+
}
|
398 |
+
}
|
399 |
+
return false;
|
400 |
+
}
|
401 |
+
|
402 |
+
/**
|
403 |
+
* check current time >= started time
|
404 |
+
*
|
405 |
+
* @param null $startDate
|
406 |
+
* @return bool
|
407 |
+
*/
|
408 |
+
public function checkRecurringTimeStart($startDate = null)
|
409 |
+
{
|
410 |
+
// timezone used as store's timezone
|
411 |
+
return strtotime(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()))) >= strtotime($startDate);
|
412 |
+
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
* process Initial Fee
|
416 |
+
*
|
417 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
418 |
+
*/
|
419 |
+
public function processInitialFee(Mage_Sales_Model_Recurring_Profile $profile)
|
420 |
+
{
|
421 |
+
// charge Initial Fee
|
422 |
+
/** @var Mage_Sales_Model_Order $order */
|
423 |
+
$order = Mage::getModel('sales/order');
|
424 |
+
$amount = $profile->getInitAmount();
|
425 |
+
$shippingInfo = $profile->getShippingAddressInfo();
|
426 |
+
$shippingAddress = Mage::getModel('sales/order_address')
|
427 |
+
->setData($shippingInfo)
|
428 |
+
->setId(null);
|
429 |
+
|
430 |
+
$orderInfo = new Varien_Object($profile->getOrderInfo());
|
431 |
+
$currencyCode = $orderInfo->getBaseCurrencyCode();
|
432 |
+
|
433 |
+
$order->setShippingAddress($shippingAddress);
|
434 |
+
$order->setBaseCurrencyCode($currencyCode);
|
435 |
+
|
436 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
437 |
+
$payment = Mage::getModel('sales/order_payment');
|
438 |
+
$payment->setOrder($order);
|
439 |
+
$payment->setIsRecurring(true);
|
440 |
+
$payment->setIsInitialFee(true);
|
441 |
+
|
442 |
+
$customerId = $profile->getCustomerId();
|
443 |
+
$payment->setCustomerId($customerId);
|
444 |
+
|
445 |
+
$additionalInfo = $profile->getAdditionalInfo();
|
446 |
+
$tokenId = $additionalInfo['token']['saved_token'];
|
447 |
+
$payment->setTokenId($tokenId);
|
448 |
+
|
449 |
+
/** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
|
450 |
+
$ewaySave = Mage::getModel('ewayrapid/method_saved');
|
451 |
+
$paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
|
452 |
+
if ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
|
453 |
+
$ewaySave->authorize($payment, $amount);
|
454 |
+
} elseif ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
455 |
+
$ewaySave->capture($payment, $amount);
|
456 |
+
}
|
457 |
+
/** @todo: change status of order = "eWAY Authorised"
|
458 |
+
* now status order = "processing"
|
459 |
+
*/
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* If next date on profile is less than today, set next date to today
|
464 |
+
* (fixes missed days)
|
465 |
+
*
|
466 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
467 |
+
*/
|
468 |
+
public function updateNextDate(Mage_Sales_Model_Recurring_Profile $profile)
|
469 |
+
{
|
470 |
+
$timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
471 |
+
$additionalInfo = $profile->getAdditionalInfo();
|
472 |
+
// timezone used as store's timezone
|
473 |
+
$nextDate = new DateTime(date("Y-m-d", strtotime($additionalInfo['nextDate'])), new DateTimeZone($timezone));
|
474 |
+
// timezone used as store's timezone
|
475 |
+
$currentDate = new DateTime(date("Y-m-d", Mage::getModel('core/date')->timestamp(time())), new DateTimeZone($timezone));
|
476 |
+
if ($nextDate < $currentDate) {
|
477 |
+
$this->_recurringProfile = $profile;
|
478 |
+
$startDate = $currentDate->format('Y-m-d');
|
479 |
+
$this->nextDate($startDate);
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
/**
|
484 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
485 |
+
* @param bool $bool
|
486 |
+
* @return bool
|
487 |
+
*
|
488 |
+
* check Maximum Payment Failures
|
489 |
+
* Maximum Payment Failures <= 0 -> run forever
|
490 |
+
* Maximum Payment Failures > 0 -> save countFailures into additional Info
|
491 |
+
* if isset countFailures -> countFailures - 1
|
492 |
+
* if countFailures = 0 -> profile is suspended
|
493 |
+
* if Maximum Payment Failures = null -> run forever
|
494 |
+
*/
|
495 |
+
public function checkMaxPaymentFailures(Mage_Sales_Model_Recurring_Profile $profile, $bool = true)
|
496 |
+
{
|
497 |
+
$additional = $profile->getAdditionalInfo();
|
498 |
+
switch (true) {
|
499 |
+
// Maximum Payment Failures <= 0 or = null -> run forever
|
500 |
+
case (int) $profile->getSuspensionThreshold() <= 0:
|
501 |
+
break;
|
502 |
+
// Maximum Payment Failures > 0 -> save countFailures into additional Info
|
503 |
+
// if countFailures = 0 -> profile is suspended
|
504 |
+
case $profile->getSuspensionThreshold() && !isset($additional['paymentFailures']):
|
505 |
+
$additional['paymentFailures'] = (int) $profile->getSuspensionThreshold() - 1;
|
506 |
+
$profile->setAdditionalInfo($additional);
|
507 |
+
$profile->save();
|
508 |
+
if ($additional['paymentFailures'] == 0) {
|
509 |
+
$profile->suspend();
|
510 |
+
$bool = false;
|
511 |
+
}
|
512 |
+
break;
|
513 |
+
// Maximum Payment Failures > 0 -> save countFailures into additional Info
|
514 |
+
// if isset countFailures -> countFailures - 1
|
515 |
+
// if countFailures = 0 -> profile is suspended
|
516 |
+
case $profile->getSuspensionThreshold() && $additional['paymentFailures'] > 0:
|
517 |
+
$additional['paymentFailures'] -= 1;
|
518 |
+
$profile->setAdditionalInfo($additional);
|
519 |
+
$profile->save();
|
520 |
+
if ($additional['paymentFailures'] == 0) {
|
521 |
+
$profile->suspend();
|
522 |
+
$bool = false;
|
523 |
+
}
|
524 |
+
break;
|
525 |
+
default:
|
526 |
+
$profile->suspend();
|
527 |
+
$bool = false;
|
528 |
+
break;
|
529 |
+
}
|
530 |
+
return $bool;
|
531 |
+
}
|
532 |
}
|
app/code/community/Eway/Rapid31/Model/Request/Abstract.php
CHANGED
@@ -1,180 +1,182 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Eway_Rapid31_Model_Request_Abstract
|
5 |
-
*
|
6 |
-
* @method Eway_Rapid31_Model_Field_Customer getCustomer()
|
7 |
-
* @method Eway_Rapid31_Model_Request_Abstract setCustomer(Eway_Rapid31_Model_Field_Customer $value)
|
8 |
-
* @method Eway_Rapid31_Model_Field_ShippingAddress getShippingAddress()
|
9 |
-
* @method Eway_Rapid31_Model_Request_Abstract setShippingAddress(Eway_Rapid31_Model_Field_ShippingAddress $value)
|
10 |
-
* @method string getShippingMethod()
|
11 |
-
* @method Eway_Rapid31_Model_Request_Abstract setShippingMethod(string $value)
|
12 |
-
* @method array getItems()
|
13 |
-
* @method Eway_Rapid31_Model_Request_Abstract setItems(array $value)
|
14 |
-
* @method Eway_Rapid31_Model_Field_Payment getPayment()
|
15 |
-
* @method Eway_Rapid31_Model_Request_Abstract setPayment(Eway_Rapid31_Model_Field_Payment $value)
|
16 |
-
* @method string getDeviceID()
|
17 |
-
* @method Eway_Rapid31_Model_Request_Abstract setDeviceID(string $value)
|
18 |
-
* @method string getCustomerIP()
|
19 |
-
* @method Eway_Rapid31_Model_Request_Abstract setCustomerIP(string $value)
|
20 |
-
* @method string getPartnerID()
|
21 |
-
* @method Eway_Rapid31_Model_Request_Abstract setPartnerID(string $value)
|
22 |
-
* @method string getTransactionType()
|
23 |
-
* @method Eway_Rapid31_Model_Request_Abstract setTransactionType(string $value)
|
24 |
-
* @method string getMethod()
|
25 |
-
* @method Eway_Rapid31_Model_Request_Abstract setMethod(string $value)
|
26 |
-
* @method int getTransactionId()
|
27 |
-
* @method Eway_Rapid31_Model_Request_Abstract setTransactionId(int $value)
|
28 |
-
* @method Eway_Rapid31_Model_Field_Payment getRefund()
|
29 |
-
* @method Eway_Rapid31_Model_Request_Abstract setRefund(Eway_Rapid31_Model_Field_Payment $value)
|
30 |
-
* @method string getRedirectUrl()
|
31 |
-
* @method Eway_Rapid31_Model_Request_Abstract setRedirectUrl(string $value)
|
32 |
-
* @method string getCheckoutPayment()
|
33 |
-
* @method Eway_Rapid31_Model_Request_Abstract setCheckoutPayment(bool $value)
|
34 |
-
* @method string getCheckoutURL()
|
35 |
-
* @method Eway_Rapid31_Model_Request_Abstract setCheckoutURL(string $value)
|
36 |
-
* @method string getCancelUrl()
|
37 |
-
* @method Eway_Rapid31_Model_Request_Abstract setCancelUrl(string $value)
|
38 |
-
* @method Eway_Rapid31_Model_Request_Abstract setCustomerReadOnly(bool $value)
|
39 |
-
*/
|
40 |
-
abstract class Eway_Rapid31_Model_Request_Abstract extends Eway_Rapid31_Model_JsonSerializableAbstract
|
41 |
-
{
|
42 |
-
const DEBUG_FILE = 'ewayrapid31_api_request.log';
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @var Eway_Rapid31_Model_Config
|
46 |
-
*/
|
47 |
-
protected $_config = null;
|
48 |
-
|
49 |
-
protected function _construct()
|
50 |
-
{
|
51 |
-
$this->_config = Mage::getSingleton('ewayrapid/config');
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Do the main API request.
|
56 |
-
* All API request to eWAY should call this function with appropriate parameters, after set all necessary data.
|
57 |
-
*
|
58 |
-
* @param string $action can be one of POST, GET, DELETE or PUT
|
59 |
-
* @param string $method
|
60 |
-
* @return Eway_Rapid31_Model_Response
|
61 |
-
*/
|
62 |
-
protected function _doRapidAPI($action, $method = 'POST')
|
63 |
-
|
64 |
-
|
65 |
-
$
|
66 |
-
$this->
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
curl_setopt($ch,
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
curl_setopt($ch,
|
75 |
-
$this->
|
76 |
-
|
77 |
-
|
78 |
-
case '
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
curl_setopt($ch,
|
84 |
-
$this->
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
curl_setopt($ch,
|
90 |
-
curl_setopt($ch,
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$
|
96 |
-
|
97 |
-
|
98 |
-
$response->
|
99 |
-
$
|
100 |
-
|
101 |
-
|
102 |
-
$
|
103 |
-
|
104 |
-
|
105 |
-
$response->
|
106 |
-
$
|
107 |
-
|
108 |
-
|
109 |
-
$response->
|
110 |
-
$
|
111 |
-
|
112 |
-
|
113 |
-
$response->
|
114 |
-
|
115 |
-
|
116 |
-
$this->_log(
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
$cardDetails->
|
134 |
-
|
135 |
-
|
136 |
-
$this->_log(
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
$
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
->
|
172 |
-
->
|
173 |
-
->
|
174 |
-
->
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
180 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Eway_Rapid31_Model_Request_Abstract
|
5 |
+
*
|
6 |
+
* @method Eway_Rapid31_Model_Field_Customer getCustomer()
|
7 |
+
* @method Eway_Rapid31_Model_Request_Abstract setCustomer(Eway_Rapid31_Model_Field_Customer $value)
|
8 |
+
* @method Eway_Rapid31_Model_Field_ShippingAddress getShippingAddress()
|
9 |
+
* @method Eway_Rapid31_Model_Request_Abstract setShippingAddress(Eway_Rapid31_Model_Field_ShippingAddress $value)
|
10 |
+
* @method string getShippingMethod()
|
11 |
+
* @method Eway_Rapid31_Model_Request_Abstract setShippingMethod(string $value)
|
12 |
+
* @method array getItems()
|
13 |
+
* @method Eway_Rapid31_Model_Request_Abstract setItems(array $value)
|
14 |
+
* @method Eway_Rapid31_Model_Field_Payment getPayment()
|
15 |
+
* @method Eway_Rapid31_Model_Request_Abstract setPayment(Eway_Rapid31_Model_Field_Payment $value)
|
16 |
+
* @method string getDeviceID()
|
17 |
+
* @method Eway_Rapid31_Model_Request_Abstract setDeviceID(string $value)
|
18 |
+
* @method string getCustomerIP()
|
19 |
+
* @method Eway_Rapid31_Model_Request_Abstract setCustomerIP(string $value)
|
20 |
+
* @method string getPartnerID()
|
21 |
+
* @method Eway_Rapid31_Model_Request_Abstract setPartnerID(string $value)
|
22 |
+
* @method string getTransactionType()
|
23 |
+
* @method Eway_Rapid31_Model_Request_Abstract setTransactionType(string $value)
|
24 |
+
* @method string getMethod()
|
25 |
+
* @method Eway_Rapid31_Model_Request_Abstract setMethod(string $value)
|
26 |
+
* @method int getTransactionId()
|
27 |
+
* @method Eway_Rapid31_Model_Request_Abstract setTransactionId(int $value)
|
28 |
+
* @method Eway_Rapid31_Model_Field_Payment getRefund()
|
29 |
+
* @method Eway_Rapid31_Model_Request_Abstract setRefund(Eway_Rapid31_Model_Field_Payment $value)
|
30 |
+
* @method string getRedirectUrl()
|
31 |
+
* @method Eway_Rapid31_Model_Request_Abstract setRedirectUrl(string $value)
|
32 |
+
* @method string getCheckoutPayment()
|
33 |
+
* @method Eway_Rapid31_Model_Request_Abstract setCheckoutPayment(bool $value)
|
34 |
+
* @method string getCheckoutURL()
|
35 |
+
* @method Eway_Rapid31_Model_Request_Abstract setCheckoutURL(string $value)
|
36 |
+
* @method string getCancelUrl()
|
37 |
+
* @method Eway_Rapid31_Model_Request_Abstract setCancelUrl(string $value)
|
38 |
+
* @method Eway_Rapid31_Model_Request_Abstract setCustomerReadOnly(bool $value)
|
39 |
+
*/
|
40 |
+
abstract class Eway_Rapid31_Model_Request_Abstract extends Eway_Rapid31_Model_JsonSerializableAbstract
|
41 |
+
{
|
42 |
+
const DEBUG_FILE = 'ewayrapid31_api_request.log';
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @var Eway_Rapid31_Model_Config
|
46 |
+
*/
|
47 |
+
protected $_config = null;
|
48 |
+
|
49 |
+
protected function _construct()
|
50 |
+
{
|
51 |
+
$this->_config = Mage::getSingleton('ewayrapid/config');
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Do the main API request.
|
56 |
+
* All API request to eWAY should call this function with appropriate parameters, after set all necessary data.
|
57 |
+
*
|
58 |
+
* @param string $action can be one of POST, GET, DELETE or PUT
|
59 |
+
* @param string $method
|
60 |
+
* @return Eway_Rapid31_Model_Response
|
61 |
+
*/
|
62 |
+
protected function _doRapidAPI($action, $method = 'POST')
|
63 |
+
{
|
64 |
+
|
65 |
+
$url = $this->_config->getRapidAPIUrl($action);
|
66 |
+
$mode = $this->_config->isSandbox() ? '(Sandbox)' : '(Live)';
|
67 |
+
$this->_log('>>>>> START REQUEST ' . $mode . ' (' . $method . ') ' . ' : ' . $url);
|
68 |
+
|
69 |
+
$ch = curl_init($url);
|
70 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "X-EWAY-APIVERSION: 40"));
|
71 |
+
curl_setopt($ch, CURLOPT_USERPWD, $this->_config->getBasicAuthenticationHeader());
|
72 |
+
switch($method) {
|
73 |
+
case 'POST':
|
74 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
75 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->jsonSerialize());
|
76 |
+
$this->_logPostJSON();
|
77 |
+
break;
|
78 |
+
case 'GET':
|
79 |
+
case 'DELETE':
|
80 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
81 |
+
break;
|
82 |
+
case 'PUT':
|
83 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
84 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->jsonSerialize());
|
85 |
+
$this->_logPostJSON();
|
86 |
+
break;
|
87 |
+
}
|
88 |
+
|
89 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
90 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
91 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->_config->isEnableSSLVerification());
|
92 |
+
|
93 |
+
$result = curl_exec($ch);
|
94 |
+
|
95 |
+
$this->_log('<<<<< RESPONSE:');
|
96 |
+
$response = Mage::getModel('ewayrapid/response');
|
97 |
+
if (curl_errno($ch) != CURLE_OK) {
|
98 |
+
$response->isSuccess(false);
|
99 |
+
$response->setMessage(Mage::helper('ewayrapid')->__("There is an error in making API request: %s", curl_error($ch)));
|
100 |
+
$this->_log("There is an error in making API request: " . curl_error($ch));
|
101 |
+
} else {
|
102 |
+
$info = curl_getinfo($ch);
|
103 |
+
$httpCode = intval(trim($info['http_code']));
|
104 |
+
if ($httpCode == 401 || $httpCode == 404 || $httpCode == 403) {
|
105 |
+
$response->isSuccess(false);
|
106 |
+
$response->setMessage(Mage::helper('ewayrapid')->__("Please check the API Key and Password %s", $mode));
|
107 |
+
$this->_log('Access denied. HTTP_CODE = ' . $info['http_code']);
|
108 |
+
} elseif ($httpCode != 200) {
|
109 |
+
$response->isSuccess(false);
|
110 |
+
$response->setMessage(Mage::helper('ewayrapid')->__("Error connecting to payment gateway, please try again"));
|
111 |
+
$this->_log('Error connecting to payment gateway. HTTP_CODE = ' . $info['http_code']);
|
112 |
+
} else {
|
113 |
+
$response->isSuccess(true);
|
114 |
+
$response->decodeJSON($result);
|
115 |
+
if ($this->_config->isDebug()) {
|
116 |
+
$this->_log('SUCCESS. Response body: ');
|
117 |
+
$this->_log(print_r(json_decode($result, true), true));
|
118 |
+
}
|
119 |
+
$this->_log('SUCCESS. HTTP_CODE = ' . $info['http_code']);
|
120 |
+
}
|
121 |
+
curl_close($ch);
|
122 |
+
}
|
123 |
+
|
124 |
+
$this->_log('===== END REQUEST.');
|
125 |
+
return $response;
|
126 |
+
}
|
127 |
+
|
128 |
+
protected function _logPostJSON()
|
129 |
+
{
|
130 |
+
if ($this->_config->isDebug()) {
|
131 |
+
$cardDetails = null;
|
132 |
+
if ($this->getCustomer() && $this->getCustomer()->getCardDetails()) {
|
133 |
+
$cardDetails = $this->getCustomer()->getCardDetails();
|
134 |
+
$cardDetails->shouldBeMasked();
|
135 |
+
}
|
136 |
+
$this->_log('Request body:');
|
137 |
+
$this->_log(print_r($this->getJsonData(), true));
|
138 |
+
if ($cardDetails !== null) {
|
139 |
+
$cardDetails->shouldBeMasked(false);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
protected function _log($message, $file = self::DEBUG_FILE)
|
145 |
+
{
|
146 |
+
if ($this->_config->isDebug()) {
|
147 |
+
Mage::log($message, Zend_Log::DEBUG, $file, true);
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
protected function _fixTitle($title)
|
152 |
+
{
|
153 |
+
if ($title == 'n/a' || empty($title)) {
|
154 |
+
return 'Mr.';
|
155 |
+
}
|
156 |
+
return $title;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Get predicted increment order id
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
protected function _getIncrementOrderId($quote)
|
164 |
+
{
|
165 |
+
$orderConfig = Mage::getSingleton('eav/config')->getEntityType('order');
|
166 |
+
|
167 |
+
$entityStoreConfig = Mage::getModel('eav/entity_store')
|
168 |
+
->loadByEntityStore($orderConfig->getId(), $quote->getStoreId());
|
169 |
+
|
170 |
+
$incrementInstance = Mage::getModel($orderConfig->getIncrementModel())
|
171 |
+
->setPrefix($entityStoreConfig->getIncrementPrefix())
|
172 |
+
->setPadLength($orderConfig->getIncrementPadLength())
|
173 |
+
->setPadChar($orderConfig->getIncrementPadChar())
|
174 |
+
->setLastId($entityStoreConfig->getIncrementLastId())
|
175 |
+
->setEntityTypeId($entityStoreConfig->getEntityTypeId())
|
176 |
+
->setStoreId($entityStoreConfig->getStoreId());
|
177 |
+
|
178 |
+
$incrementId = $incrementInstance->getNextId();
|
179 |
+
|
180 |
+
return $incrementId;
|
181 |
+
}
|
182 |
}
|
app/code/community/Eway/Rapid31/Model/Request/Direct.php
CHANGED
@@ -1,340 +1,365 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_Request_Direct extends Eway_Rapid31_Model_Request_Abstract
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Call Transaction API (Authorized & Capture at the same time)
|
6 |
-
*
|
7 |
-
* @param Mage_Sales_Model_Order_Payment $payment
|
8 |
-
* @param float $amount
|
9 |
-
* @return Eway_Rapid31_Model_Request_Direct $this
|
10 |
-
*/
|
11 |
-
public function doTransaction(Mage_Sales_Model_Order_Payment $payment, $amount)
|
12 |
-
{
|
13 |
-
$this->_buildRequest($payment, $amount);
|
14 |
-
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT);
|
15 |
-
$response = $this->_doRapidAPI('Transaction');
|
16 |
-
|
17 |
-
// Save fraud information
|
18 |
-
|
19 |
-
$transaction = $this->getTransaction($response['TransactionID']);
|
20 |
-
if($transaction) {
|
21 |
-
$fraudAction = $transaction[0]['FraudAction'];
|
22 |
-
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
23 |
-
$captured = $transaction[0]['TransactionCaptured'];
|
24 |
-
unset($transaction);
|
25 |
-
}
|
26 |
-
|
27 |
-
if($response->isSuccess()) {
|
28 |
-
$payment->setTransactionId($response->getTransactionID());
|
29 |
-
$payment->setCcLast4($response->getCcLast4());
|
30 |
-
$beagleScore = $response->getBeagleScore() && $response->getData('BeagleScore') > 0 ? $response->getBeagleScore() : '';
|
31 |
-
$payment->setBeagleScore($beagleScore);
|
32 |
-
$payment->setBeagleVerification(serialize($response->getBeagleVerification()));
|
33 |
-
$payment->setFraudAction($fraudAction);
|
34 |
-
$payment->setFraudCodes($fraudCodes);
|
35 |
-
$payment->setTransactionCaptured($captured);
|
36 |
-
return $this;
|
37 |
-
} else {
|
38 |
-
Mage::throwException(
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
*
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
$
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
$payment->
|
72 |
-
$payment->
|
73 |
-
$
|
74 |
-
$payment->
|
75 |
-
$payment->
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$
|
111 |
-
$
|
112 |
-
|
113 |
-
$
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
$
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
if(
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
$
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
if($
|
166 |
-
$
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
$
|
232 |
-
$
|
233 |
-
$
|
234 |
-
|
235 |
-
$
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
$
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
->
|
272 |
-
|
273 |
-
->
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
->
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
$
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
->
|
287 |
-
->
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
$
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
$
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
$
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
$
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
$
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_Request_Direct extends Eway_Rapid31_Model_Request_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Call Transaction API (Authorized & Capture at the same time)
|
6 |
+
*
|
7 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
8 |
+
* @param float $amount
|
9 |
+
* @return Eway_Rapid31_Model_Request_Direct $this
|
10 |
+
*/
|
11 |
+
public function doTransaction(Mage_Sales_Model_Order_Payment $payment, $amount)
|
12 |
+
{
|
13 |
+
$this->_buildRequest($payment, $amount);
|
14 |
+
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT);
|
15 |
+
$response = $this->_doRapidAPI('Transaction');
|
16 |
+
|
17 |
+
// Save fraud information
|
18 |
+
|
19 |
+
$transaction = $this->getTransaction($response['TransactionID']);
|
20 |
+
if ($transaction) {
|
21 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
22 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
23 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
24 |
+
unset($transaction);
|
25 |
+
}
|
26 |
+
|
27 |
+
if ($response->isSuccess()) {
|
28 |
+
$payment->setTransactionId($response->getTransactionID());
|
29 |
+
$payment->setCcLast4($response->getCcLast4());
|
30 |
+
$beagleScore = $response->getBeagleScore() && $response->getData('BeagleScore') > 0 ? $response->getBeagleScore() : '';
|
31 |
+
$payment->setBeagleScore($beagleScore);
|
32 |
+
$payment->setBeagleVerification(serialize($response->getBeagleVerification()));
|
33 |
+
$payment->setFraudAction($fraudAction);
|
34 |
+
$payment->setFraudCodes($fraudCodes);
|
35 |
+
$payment->setTransactionCaptured($captured);
|
36 |
+
return $this;
|
37 |
+
} else {
|
38 |
+
Mage::throwException(
|
39 |
+
Mage::helper('ewayrapid')->__(
|
40 |
+
'An error occurred while making the transaction. Please try again. (Error message: %s)',
|
41 |
+
$response->getMessage()
|
42 |
+
)
|
43 |
+
);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Call Authorisation API (Authorized only)
|
49 |
+
*
|
50 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
51 |
+
* @param $amount
|
52 |
+
* @return Eway_Rapid31_Model_Request_Direct
|
53 |
+
*/
|
54 |
+
public function doAuthorisation(Mage_Sales_Model_Order_Payment $payment, $amount)
|
55 |
+
{
|
56 |
+
$this->_buildRequest($payment, $amount);
|
57 |
+
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
|
58 |
+
$response = $this->_doRapidAPI('Authorisation');
|
59 |
+
|
60 |
+
// Save fraud information
|
61 |
+
|
62 |
+
$transaction = $this->getTransaction($response['TransactionID']);
|
63 |
+
if ($transaction) {
|
64 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
65 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
66 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
67 |
+
unset($transaction);
|
68 |
+
}
|
69 |
+
|
70 |
+
if ($response->isSuccess()) {
|
71 |
+
$payment->setTransactionId($response->getTransactionID());
|
72 |
+
$payment->setIsTransactionClosed(0);
|
73 |
+
$beagleScore = $response->getBeagleScore() && $response->getData('BeagleScore') > 0 ? $response->getBeagleScore() : '';
|
74 |
+
$payment->setBeagleScore($beagleScore);
|
75 |
+
$payment->setBeagleVerification(serialize($response->getBeagleVerification()));
|
76 |
+
$payment->setCcLast4($response->getCcLast4());
|
77 |
+
$payment->setFraudAction($fraudAction);
|
78 |
+
$payment->setFraudCodes($fraudCodes);
|
79 |
+
$payment->setTransactionCaptured($captured);
|
80 |
+
return $this;
|
81 |
+
} else {
|
82 |
+
if ($payment->getIsRecurring()) {
|
83 |
+
Mage::getSingleton('core/session')->setData('errorMessage', $response->getMessage());
|
84 |
+
}
|
85 |
+
Mage::throwException(
|
86 |
+
Mage::helper('ewayrapid')->__(
|
87 |
+
'An error occurred while doing the authorisation. Please try again. (Error message: %s)',
|
88 |
+
$response->getMessage()
|
89 |
+
)
|
90 |
+
);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Call Capture API (do the Capture only, must Authorized previously)
|
96 |
+
*
|
97 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
98 |
+
* @param $amount
|
99 |
+
* @return Eway_Rapid31_Model_Request_Direct
|
100 |
+
*/
|
101 |
+
public function doCapturePayment(Mage_Sales_Model_Order_Payment $payment, $amount)
|
102 |
+
{
|
103 |
+
// Empty Varien_Object's data
|
104 |
+
$this->unsetData();
|
105 |
+
|
106 |
+
/* @var Mage_Sales_Model_Order_Invoice $invoice */
|
107 |
+
$invoice = Mage::registry('current_invoice');
|
108 |
+
$order = $payment->getOrder();
|
109 |
+
|
110 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
111 |
+
$paymentParam->setTotalAmount($amount)
|
112 |
+
->setCurrencyCode($order->getBaseCurrencyCode());
|
113 |
+
if ($invoice && $invoice->getIncrementId()) {
|
114 |
+
$paymentParam->setInvoiceNumber($invoice->getIncrementId())
|
115 |
+
->setInvoiceReference($invoice->getIncrementId())
|
116 |
+
->setInvoiceDescription(Mage::helper('ewayrapid')->__('Invoice created from Magento'));
|
117 |
+
}
|
118 |
+
$this->setPayment($paymentParam);
|
119 |
+
$this->setTransactionId($payment->getLastTransId());
|
120 |
+
|
121 |
+
$response = $this->_doRapidAPI('CapturePayment');
|
122 |
+
|
123 |
+
if ($response->isSuccess()) {
|
124 |
+
$payment->setTransactionId($response->getTransactionID());
|
125 |
+
return $this;
|
126 |
+
} else {
|
127 |
+
if ($payment->getIsRecurring()) {
|
128 |
+
Mage::getSingleton('core/session')->setData('errorMessage', $response->getMessage());
|
129 |
+
}
|
130 |
+
Mage::throwException(
|
131 |
+
Mage::helper('ewayrapid')->__(
|
132 |
+
'An error occurred while doing the capture. Please try again. (Error message: %s)',
|
133 |
+
$response->getMessage()
|
134 |
+
)
|
135 |
+
);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Call Refund API, must complete the transaction (Authorized & Capture) beforehand
|
141 |
+
*
|
142 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
143 |
+
* @param $amount
|
144 |
+
* @return Eway_Rapid31_Model_Request_Direct
|
145 |
+
*/
|
146 |
+
public function doRefund(Mage_Sales_Model_Order_Payment $payment, $amount)
|
147 |
+
{
|
148 |
+
// Empty Varien_Object's data
|
149 |
+
$this->unsetData();
|
150 |
+
|
151 |
+
$order = $payment->getOrder();
|
152 |
+
/* @var Mage_Sales_Model_Order_Creditmemo $creditMemo */
|
153 |
+
$creditMemo = Mage::registry('current_creditmemo');
|
154 |
+
|
155 |
+
$invoice = ($creditMemo ? $creditMemo->getInvoice() : null);
|
156 |
+
/* @var Mage_Sales_Model_Order_Invoice $invoice */
|
157 |
+
if (!$invoice || !$invoice->getTransactionId()) {
|
158 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the online refund: Invoice or transaction does not exist.'));
|
159 |
+
}
|
160 |
+
|
161 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
162 |
+
$paymentParam->setTotalAmount($amount)
|
163 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
164 |
+
->setTransactionID($invoice->getTransactionId());
|
165 |
+
if ($creditMemo && $creditMemo->getIncrementId()) {
|
166 |
+
$paymentParam->setInvoiceDescription("Creditmemo ID " . $creditMemo->getIncrementId());
|
167 |
+
}
|
168 |
+
|
169 |
+
if ($invoice && $invoice->getIncrementId()) {
|
170 |
+
$paymentParam->setInvoiceNumber($invoice->getIncrementId())
|
171 |
+
->setInvoiceReference($invoice->getIncrementId());
|
172 |
+
}
|
173 |
+
$this->setRefund($paymentParam);
|
174 |
+
|
175 |
+
$response = $this->_doRapidAPI('Transaction/' . $invoice->getTransactionId() . '/Refund');
|
176 |
+
|
177 |
+
if ($response->isSuccess()) {
|
178 |
+
$payment->setTransactionId($response->getTransactionID());
|
179 |
+
return $this;
|
180 |
+
} else {
|
181 |
+
Mage::throwException(
|
182 |
+
Mage::helper('ewayrapid')->__(
|
183 |
+
'An error occurred while doing the refund. Please try again. (Error message: %s)',
|
184 |
+
$response->getMessage()
|
185 |
+
)
|
186 |
+
);
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Call Cancel API, the transaction must be Authorized beforehand
|
192 |
+
*
|
193 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
194 |
+
* @return Eway_Rapid31_Model_Request_Direct
|
195 |
+
*/
|
196 |
+
public function doCancel(Mage_Sales_Model_Order_Payment $payment)
|
197 |
+
{
|
198 |
+
// Empty Varien_Object's data
|
199 |
+
$this->unsetData();
|
200 |
+
|
201 |
+
$transactionId = $payment->getLastTransId();
|
202 |
+
$this->setTransactionId($transactionId);
|
203 |
+
$response = $this->_doRapidAPI('CancelAuthorisation');
|
204 |
+
|
205 |
+
if ($response->isSuccess()) {
|
206 |
+
$payment->setTransactionId($response->getTransactionID());
|
207 |
+
$payment->setIsTransactionClosed(1);
|
208 |
+
return $this;
|
209 |
+
} else {
|
210 |
+
Mage::throwException(
|
211 |
+
Mage::helper('ewayrapid')->__(
|
212 |
+
'An error occurred while doing the cancel. Please try again. (Error message: %s)',
|
213 |
+
$response->getMessage()
|
214 |
+
)
|
215 |
+
);
|
216 |
+
}
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Build the request with necessary parameters for doAuthorisation() and doTransaction()
|
222 |
+
*
|
223 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
224 |
+
* @param $amount
|
225 |
+
* @return Eway_Rapid31_Model_Request_Direct
|
226 |
+
*/
|
227 |
+
protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
|
228 |
+
{
|
229 |
+
// Empty Varien_Object's data
|
230 |
+
$this->unsetData();
|
231 |
+
$methodInstance = $payment->getMethodInstance();
|
232 |
+
$infoInstance = $methodInstance->getInfoInstance();
|
233 |
+
$order = $payment->getOrder();
|
234 |
+
$billing = $order->getBillingAddress();
|
235 |
+
$shipping = $order->getShippingAddress();
|
236 |
+
|
237 |
+
// if item is virtual product
|
238 |
+
if (!$shipping) {
|
239 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
240 |
+
if ($quote->isVirtual()) {
|
241 |
+
$shipping = $quote->getBillingAddress();
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
if (Mage::helper('ewayrapid')->isBackendOrder()) {
|
246 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
|
247 |
+
} else {
|
248 |
+
$this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
|
249 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
|
250 |
+
}
|
251 |
+
$version = Mage::helper('ewayrapid')->getExtensionVersion();
|
252 |
+
$this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
|
253 |
+
$this->setShippingMethod('Other');
|
254 |
+
|
255 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
256 |
+
$paymentParam->setTotalAmount($amount)
|
257 |
+
->setCurrencyCode($order->getBaseCurrencyCode());
|
258 |
+
|
259 |
+
// add InvoiceDescription and InvoiceReference
|
260 |
+
$config = Mage::getModel('ewayrapid/config');
|
261 |
+
|
262 |
+
if ($config->shouldPassingInvoiceDescription()) {
|
263 |
+
$invoiceDescription = '';
|
264 |
+
foreach ($order->getAllVisibleItems() as $item) {
|
265 |
+
// Check in case multi-shipping
|
266 |
+
if (!$item->getQuoteParentItemId()) {
|
267 |
+
$invoiceDescription .= (int) $item->getQtyOrdered() . ' x ' .$item->getName() . ', ';
|
268 |
+
}
|
269 |
+
}
|
270 |
+
$invoiceDescription = trim($invoiceDescription, ', ');
|
271 |
+
$invoiceDescription = Mage::helper('ewayrapid')->limitInvoiceDescriptionLength($invoiceDescription);
|
272 |
+
|
273 |
+
$paymentParam->setInvoiceDescription($invoiceDescription);
|
274 |
+
}
|
275 |
+
|
276 |
+
if ($config->shouldPassingGuessOrder()) {
|
277 |
+
$paymentParam->setInvoiceReference($order->getIncrementId());
|
278 |
+
}
|
279 |
+
|
280 |
+
$this->setPayment($paymentParam);
|
281 |
+
|
282 |
+
$title = $this->_fixTitle($billing->getPrefix());
|
283 |
+
|
284 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
285 |
+
$customerParam->setTitle($title)
|
286 |
+
->setFirstName($billing->getFirstname())
|
287 |
+
->setLastName($billing->getLastname())
|
288 |
+
->setCompanyName($billing->getCompany())
|
289 |
+
->setJobDescription('')
|
290 |
+
->setStreet1($billing->getStreet1())
|
291 |
+
->setStreet2($billing->getStreet2())
|
292 |
+
->setCity($billing->getCity())
|
293 |
+
->setState($billing->getRegion())
|
294 |
+
->setPostalCode($billing->getPostcode())
|
295 |
+
->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
|
296 |
+
->setEmail($billing->getEmail())
|
297 |
+
->setPhone($billing->getTelephone())
|
298 |
+
->setMobile('')
|
299 |
+
->setComments('')
|
300 |
+
->setFax($billing->getFax())
|
301 |
+
->setUrl('');
|
302 |
+
$cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
|
303 |
+
$cardDetails->setName($infoInstance->getCcOwner())
|
304 |
+
->setNumber($infoInstance->getCcNumber())
|
305 |
+
->setExpiryMonth($infoInstance->getCcExpMonth())
|
306 |
+
->setExpiryYear($infoInstance->getCcExpYear())
|
307 |
+
->setCVN($infoInstance->getCcCid());
|
308 |
+
|
309 |
+
$customerParam->setCardDetails($cardDetails);
|
310 |
+
$this->setCustomer($customerParam);
|
311 |
+
|
312 |
+
if (!empty($shipping)) {
|
313 |
+
$shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
|
314 |
+
$shippingParam->setFirstName($shipping->getFirstname())
|
315 |
+
->setLastName($shipping->getLastname())
|
316 |
+
->setStreet1($shipping->getStreet1())
|
317 |
+
->setStreet2($shipping->getStreet2())
|
318 |
+
->setCity($shipping->getCity())
|
319 |
+
->setState($shipping->getRegion())
|
320 |
+
->setPostalCode($shipping->getPostcode())
|
321 |
+
->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))
|
322 |
+
->setEmail($shipping->getEmail())
|
323 |
+
->setPhone($shipping->getTelephone())
|
324 |
+
->setFax($shipping->getFax());
|
325 |
+
$this->setShippingAddress($shippingParam);
|
326 |
+
}
|
327 |
+
|
328 |
+
if ($methodInstance->getConfigData('transfer_cart_items')) {
|
329 |
+
$orderItems = $order->getAllVisibleItems();
|
330 |
+
$lineItems = array();
|
331 |
+
foreach ($orderItems as $orderItem) {
|
332 |
+
/* @var Mage_Sales_Model_Order_Item $orderItem */
|
333 |
+
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
|
334 |
+
$lineItem->setSKU($orderItem->getSku());
|
335 |
+
$lineItem->setDescription(substr($orderItem->getName(), 0, 26));
|
336 |
+
$lineItem->setQuantity($orderItem->getQtyOrdered());
|
337 |
+
$lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
|
338 |
+
$lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
|
339 |
+
$lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
|
340 |
+
$lineItems[] = $lineItem;
|
341 |
+
}
|
342 |
+
$this->setItems($lineItems);
|
343 |
+
}
|
344 |
+
|
345 |
+
return $this;
|
346 |
+
}
|
347 |
+
|
348 |
+
public function getTransaction($transactionNumber)
|
349 |
+
{
|
350 |
+
try {
|
351 |
+
$results = $this->_doRapidAPI("Transaction/$transactionNumber", 'GET');
|
352 |
+
if ($results->isSuccess()) {
|
353 |
+
return $results->getTransactions();
|
354 |
+
}
|
355 |
+
} catch (Exception $e) {
|
356 |
+
Mage::throwException(
|
357 |
+
Mage::helper('ewayrapid')->__(
|
358 |
+
'An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
|
359 |
+
$results->getMessage()
|
360 |
+
)
|
361 |
+
);
|
362 |
+
return false;
|
363 |
+
}
|
364 |
+
}
|
365 |
}
|
app/code/community/Eway/Rapid31/Model/Request/Sharedpage.php
CHANGED
@@ -1,639 +1,648 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Eway_Rapid31_Model_Request_Sharedpage extends Eway_Rapid31_Model_Request_Abstract
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* @var Mage_Sales_Model_Quote
|
7 |
-
*/
|
8 |
-
protected $_quote = null;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* @var Mage_Customer_Model_Session
|
12 |
-
*/
|
13 |
-
protected $_customerSession;
|
14 |
-
|
15 |
-
public function __construct($params = array())
|
16 |
-
{
|
17 |
-
if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
|
18 |
-
$this->_quote = $params['quote'];
|
19 |
-
} else {
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
$this->_config = Mage::getSingleton('ewayrapid/config');
|
24 |
-
$this->_customerSession = Mage::getSingleton('customer/session');
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* create AccessCode for process checkout
|
29 |
-
*
|
30 |
-
* @param null $returnUrl
|
31 |
-
* @param null $cancelUrl
|
32 |
-
* @return Eway_Rapid31_Model_Response
|
33 |
-
*/
|
34 |
-
public function createAccessCode($returnUrl = null, $cancelUrl = null)
|
35 |
-
{
|
36 |
-
// Empty Varien_Object's data
|
37 |
-
$this->unsetData();
|
38 |
-
$token = null;
|
39 |
-
$paypal = null;
|
40 |
-
$totalAmount = 0;
|
41 |
-
|
42 |
-
if ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD) {
|
43 |
-
if ($this->_isNewToken()) {
|
44 |
-
$returnUrl .= '?newToken=1';
|
45 |
-
$method = Eway_Rapid31_Model_Config::METHOD_CREATE_TOKEN;
|
46 |
-
} elseif ($token = $this->_editToken()) {
|
47 |
-
$returnUrl .= '?editToken=' . $token;
|
48 |
-
$token = Mage::helper('ewayrapid/customer')->getCustomerTokenId($token);
|
49 |
-
$method = Eway_Rapid31_Model_Config::METHOD_UPDATE_TOKEN;
|
50 |
-
}
|
51 |
-
} elseif ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD) {
|
52 |
-
if ($this->_isNewToken()) {
|
53 |
-
$returnUrl .= '?newToken=1';
|
54 |
-
if(Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE){
|
55 |
-
$method = Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT;
|
56 |
-
$totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
|
57 |
-
}else{
|
58 |
-
$method = Eway_Rapid31_Model_Config::METHOD_CREATE_TOKEN ;
|
59 |
-
}
|
60 |
-
} elseif ($token = $this->_editToken()) {
|
61 |
-
$returnUrl .= '?editToken=' . $token;
|
62 |
-
$token = Mage::helper('ewayrapid/customer')->getCustomerTokenId($token);
|
63 |
-
if(Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE){
|
64 |
-
$method = Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT;
|
65 |
-
$totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
|
66 |
-
}else{
|
67 |
-
$method = Eway_Rapid31_Model_Config::METHOD_UPDATE_TOKEN ;
|
68 |
-
}
|
69 |
-
}else{
|
70 |
-
if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
71 |
-
$method = Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT;
|
72 |
-
} else {
|
73 |
-
$method = Eway_Rapid31_Model_Config::METHOD_AUTHORISE;
|
74 |
-
}
|
75 |
-
$totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
|
76 |
-
$paypal = $this->_getPaypalCheckout();
|
77 |
-
if ($paypal === Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
|
78 |
-
$this->setCheckoutPayment(true);
|
79 |
-
$this->setCheckoutURL(Mage::getUrl('ewayrapid/sharedpage/review'));
|
80 |
-
}
|
81 |
-
}
|
82 |
-
} else {
|
83 |
-
if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
84 |
-
$method = Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT;
|
85 |
-
} else {
|
86 |
-
$method = Eway_Rapid31_Model_Config::METHOD_AUTHORISE;
|
87 |
-
}
|
88 |
-
$totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
|
89 |
-
$paypal = $this->_getPaypalCheckout();
|
90 |
-
if ($paypal === Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
|
91 |
-
$this->setCheckoutPayment(true);
|
92 |
-
$this->setCheckoutURL(Mage::getUrl('ewayrapid/sharedpage/review'));
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
$this->_buildRequest();
|
97 |
-
|
98 |
-
$customer = $this->getCustomer();
|
99 |
-
$customer->setTokenCustomerID($token ? $token : '');
|
100 |
-
$this->setCustomer($customer);
|
101 |
-
|
102 |
-
// prepare API
|
103 |
-
$this->setRedirectUrl($returnUrl);
|
104 |
-
$this->setCancelUrl($cancelUrl);
|
105 |
-
$this->setMethod($method);
|
106 |
-
|
107 |
-
if (Mage::helper('ewayrapid')->getTransferCartLineItems()) {
|
108 |
-
// add Shipping item and Line items
|
109 |
-
$lineItems = Mage::helper('ewayrapid')->getLineItems();
|
110 |
-
$this->setItems($lineItems);
|
111 |
-
}
|
112 |
-
|
113 |
-
// add Payment
|
114 |
-
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
115 |
-
$paymentParam->setTotalAmount($totalAmount);
|
116 |
-
$paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
|
117 |
-
|
118 |
-
// add InvoiceDescription and InvoiceReference
|
119 |
-
$config = Mage::getModel('ewayrapid/config');
|
120 |
-
|
121 |
-
if($config->shouldPassingInvoiceDescription()){
|
122 |
-
$invoiceDescription = '';
|
123 |
-
foreach($this->_quote->getAllVisibleItems() as $item){
|
124 |
-
// Check in case multi-shipping
|
125 |
-
if (!$item->getQuoteParentItem()) {
|
126 |
-
$invoiceDescription .= (int) $item->getQty() . ' x ' .$item->getName() . ', ';
|
127 |
-
}
|
128 |
-
}
|
129 |
-
$invoiceDescription = trim($invoiceDescription,', ');
|
130 |
-
$invoiceDescription = Mage::helper('ewayrapid')->limitInvoiceDescriptionLength($invoiceDescription);
|
131 |
-
|
132 |
-
$paymentParam->setInvoiceDescription($invoiceDescription);
|
133 |
-
}
|
134 |
-
|
135 |
-
if($config->shouldPassingGuessOrder()){
|
136 |
-
$incrementId = $this->_getIncrementOrderId($this->_quote);
|
137 |
-
$paymentParam->setInvoiceReference($incrementId);
|
138 |
-
$paymentParam->setInvoiceNumber($incrementId);
|
139 |
-
}
|
140 |
-
|
141 |
-
$this->setPayment($paymentParam);
|
142 |
-
|
143 |
-
if($this->_config->isSharedPageConnection()){
|
144 |
-
// add Verify options
|
145 |
-
$this->setVerifyCustomerEmail($this->_config->getVerifyEmail());
|
146 |
-
$this->setVerifyCustomerPhone($this->_config->getVerifyPhone());
|
147 |
-
|
148 |
-
// add Custom View
|
149 |
-
$this->setCustomView($this->_config->getCustomView());
|
150 |
-
|
151 |
-
}
|
152 |
-
|
153 |
-
$response = $this->_doRapidAPI('AccessCodesShared');
|
154 |
-
return $response;
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Call Authorisation API (Authorized only)
|
159 |
-
*
|
160 |
-
* @param Eway_Rapid31_Model_Response $response
|
161 |
-
* @return Eway_Rapid31_Model_Response
|
162 |
-
*/
|
163 |
-
public function doAuthorisation(Eway_Rapid31_Model_Response $response)
|
164 |
-
{
|
165 |
-
$this->unsetData();
|
166 |
-
|
167 |
-
$this->_buildRequest();
|
168 |
-
|
169 |
-
$cardData = $response->getCustomer();
|
170 |
-
if ($cardData['CardNumber'] && $cardData['CardName']) {
|
171 |
-
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
|
172 |
-
} else {
|
173 |
-
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
|
174 |
-
}
|
175 |
-
|
176 |
-
$items = $this->_quote->getAllVisibleItems();
|
177 |
-
$lineItems = array();
|
178 |
-
foreach ($items as $item) {
|
179 |
-
/* @var Mage_Sales_Model_Order_Item $item */
|
180 |
-
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
|
181 |
-
$lineItem->setSKU($item->getSku());
|
182 |
-
$lineItem->setDescription(substr($item->getName(), 0, 26));
|
183 |
-
$lineItem->setQuantity($item->getQty());
|
184 |
-
$lineItem->setUnitCost(round($item->getBasePrice() * 100));
|
185 |
-
$lineItem->setTax(round($item->getBaseTaxAmount() * 100));
|
186 |
-
$lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
|
187 |
-
$lineItems[] = $lineItem;
|
188 |
-
}
|
189 |
-
$this->setItems($lineItems);
|
190 |
-
|
191 |
-
$this->setItems(false);
|
192 |
-
|
193 |
-
// add Payment
|
194 |
-
$amount = round($this->_quote->getBaseGrandTotal() * 100);
|
195 |
-
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
196 |
-
$paymentParam->setTotalAmount($amount);
|
197 |
-
$paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
|
198 |
-
|
199 |
-
// add InvoiceDescription and InvoiceReference
|
200 |
-
$config = Mage::getModel('ewayrapid/config');
|
201 |
-
|
202 |
-
if($config->shouldPassingInvoiceDescription()){
|
203 |
-
$invoiceDescription = '';
|
204 |
-
foreach($this->_quote->getAllVisibleItems() as $item){
|
205 |
-
// Check in case multi-shipping
|
206 |
-
if (!$item->getQuoteParentItemId()) {
|
207 |
-
$invoiceDescription .= (int) $item->getQty() . ' x ' .$item->getName() . ', ';
|
208 |
-
}
|
209 |
-
}
|
210 |
-
$invoiceDescription = trim($invoiceDescription,', ');
|
211 |
-
$invoiceDescription = Mage::helper('ewayrapid')->limitInvoiceDescriptionLength($invoiceDescription);
|
212 |
-
|
213 |
-
$paymentParam->setInvoiceDescription($invoiceDescription);
|
214 |
-
}
|
215 |
-
|
216 |
-
if($config->shouldPassingGuessOrder()){
|
217 |
-
$incrementId = $this->_getIncrementOrderId($this->_quote);
|
218 |
-
$paymentParam->setInvoiceReference($incrementId);
|
219 |
-
}
|
220 |
-
|
221 |
-
$this->setPayment($paymentParam);
|
222 |
-
|
223 |
-
$customerParam = $this->getCustomer();
|
224 |
-
$customerParam->setTokenCustomerID($response->getTokenCustomerID());
|
225 |
-
$this->setCustomer($customerParam);
|
226 |
-
|
227 |
-
$response = $this->_doRapidAPI('Authorisation');
|
228 |
-
return $response;
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* Call Transaction API (Authorized & Capture at the same time)
|
233 |
-
*
|
234 |
-
* @param Eway_Rapid31_Model_Response $response
|
235 |
-
* @return Eway_Rapid31_Model_Response
|
236 |
-
*/
|
237 |
-
public function doTransaction(Eway_Rapid31_Model_Response $response)
|
238 |
-
{
|
239 |
-
$this->unsetData();
|
240 |
-
|
241 |
-
$this->_buildRequest();
|
242 |
-
|
243 |
-
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
|
244 |
-
|
245 |
-
$items = $this->_quote->getAllVisibleItems();
|
246 |
-
$lineItems = array();
|
247 |
-
foreach ($items as $item) {
|
248 |
-
/* @var Mage_Sales_Model_Order_Item $item */
|
249 |
-
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
|
250 |
-
$lineItem->setSKU($item->getSku());
|
251 |
-
$lineItem->setDescription(substr($item->getName(), 0, 26));
|
252 |
-
$lineItem->setQuantity($item->getQty());
|
253 |
-
$lineItem->setUnitCost(round($item->getBasePrice() * 100));
|
254 |
-
$lineItem->setTax(round($item->getBaseTaxAmount() * 100));
|
255 |
-
$lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
|
256 |
-
$lineItems[] = $lineItem;
|
257 |
-
}
|
258 |
-
$this->setItems($lineItems);
|
259 |
-
|
260 |
-
$this->setItems(false);
|
261 |
-
|
262 |
-
// add Payment
|
263 |
-
$amount = round($this->_quote->getBaseGrandTotal() * 100);
|
264 |
-
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
265 |
-
$paymentParam->setTotalAmount($amount);
|
266 |
-
$paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
|
267 |
-
$this->setPayment($paymentParam);
|
268 |
-
|
269 |
-
$customerParam = $this->getCustomer();
|
270 |
-
$customerParam->setTokenCustomerID($response->getTokenCustomerID());
|
271 |
-
|
272 |
-
$this->setCustomer($customerParam);
|
273 |
-
|
274 |
-
$response = $this->_doRapidAPI('Transaction');
|
275 |
-
return $response;
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Call Capture API (do the Capture only, must Authorized previously)
|
280 |
-
*
|
281 |
-
* @param Eway_Rapid31_Model_Response $response
|
282 |
-
* @return Eway_Rapid31_Model_Response
|
283 |
-
*/
|
284 |
-
public function doCapturePayment(Eway_Rapid31_Model_Response $response)
|
285 |
-
{
|
286 |
-
$this->setTransactionId($response->getTransactionID());
|
287 |
-
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT);
|
288 |
-
|
289 |
-
$response = $this->_doRapidAPI('CapturePayment');
|
290 |
-
return $response;
|
291 |
-
}
|
292 |
-
|
293 |
-
/**
|
294 |
-
* Build the request with necessary parameters for doAuthorisation(), doTransaction() and CreateAccessCode()
|
295 |
-
*
|
296 |
-
* @return $this
|
297 |
-
*/
|
298 |
-
protected function _buildRequest()
|
299 |
-
{
|
300 |
-
// prepare API
|
301 |
-
$this->setShippingMethod('Other');
|
302 |
-
$
|
303 |
-
$
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
|
309 |
-
}
|
310 |
-
$this->setCustomerReadOnly(true);
|
311 |
-
|
312 |
-
// add Billing Address
|
313 |
-
$billingAddress = $this->_quote->getBillingAddress();
|
314 |
-
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
315 |
-
|
316 |
-
$title = $this->_fixTitle($billingAddress->getPrefix());
|
317 |
-
|
318 |
-
$customerParam->setTitle($title)
|
319 |
-
->setFirstName($billingAddress->getFirstname())
|
320 |
-
->setLastName($billingAddress->getLastname())
|
321 |
-
->setCompanyName($billingAddress->getCompany())
|
322 |
-
->setJobDescription($billingAddress->getJobDescription())
|
323 |
-
->setStreet1($billingAddress->getStreet1())
|
324 |
-
->setStreet2($billingAddress->getStreet2())
|
325 |
-
->setCity($billingAddress->getCity())
|
326 |
-
->setState($billingAddress->getRegion())
|
327 |
-
->setPostalCode($billingAddress->getPostcode())
|
328 |
-
->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
|
329 |
-
->setEmail($billingAddress->getEmail())
|
330 |
-
->setPhone($billingAddress->getTelephone())
|
331 |
-
->setMobile($billingAddress->getMobile())
|
332 |
-
->setComments('')
|
333 |
-
->setFax($billingAddress->getFax())
|
334 |
-
->setUrl('');
|
335 |
-
$this->setCustomer($customerParam);
|
336 |
-
|
337 |
-
// add Shipping Address
|
338 |
-
$shippingAddress = $this->_quote->getShippingAddress();
|
339 |
-
|
340 |
-
// copy BillingAddress to ShippingAddress if checkout with guest or register
|
341 |
-
/**
|
342 |
-
$checkoutMethod = $this->_quote->getCheckoutMethod();
|
343 |
-
if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
|
344 |
-
|| $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
|
345 |
-
) {
|
346 |
-
$shippingAddress = $billingAddress;
|
347 |
-
}
|
348 |
-
*/
|
349 |
-
|
350 |
-
if (!empty($shippingAddress)) {
|
351 |
-
$shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
|
352 |
-
$shippingParam->setFirstName($shippingAddress->getFirstname())
|
353 |
-
->setLastName($shippingAddress->getLastname())
|
354 |
-
->setStreet1($shippingAddress->getStreet1())
|
355 |
-
->setStreet2($shippingAddress->getStreet2())
|
356 |
-
->setCity($shippingAddress->getCity())
|
357 |
-
->setState($shippingAddress->getRegion())
|
358 |
-
->setPostalCode($shippingAddress->getPostcode())
|
359 |
-
->setCountry(strtolower($shippingAddress->getCountryModel()->getIso2Code()))
|
360 |
-
->setEmail($shippingAddress->getEmail())
|
361 |
-
->setPhone($shippingAddress->getTelephone())
|
362 |
-
->setFax($shippingAddress->getFax());
|
363 |
-
$this->setShippingAddress($shippingParam);
|
364 |
-
}
|
365 |
-
|
366 |
-
return $this;
|
367 |
-
}
|
368 |
-
|
369 |
-
/**
|
370 |
-
* Get customer information by access code
|
371 |
-
*/
|
372 |
-
public function getInfoByAccessCode($accessCode)
|
373 |
-
{
|
374 |
-
$response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
|
375 |
-
return $response;
|
376 |
-
}
|
377 |
-
|
378 |
-
/**
|
379 |
-
* Get customer session object
|
380 |
-
*
|
381 |
-
* @return Mage_Customer_Model_Session
|
382 |
-
*/
|
383 |
-
public function getCustomerSession()
|
384 |
-
{
|
385 |
-
return $this->_customerSession;
|
386 |
-
}
|
387 |
-
|
388 |
-
/**
|
389 |
-
* check is new token when checkout
|
390 |
-
*
|
391 |
-
* @return bool
|
392 |
-
*/
|
393 |
-
protected function _isNewToken()
|
394 |
-
{
|
395 |
-
$info = $this->_quote->getPayment();
|
396 |
-
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
397 |
-
if ($token = Mage::getSingleton('core/session')->getData('newToken')) {
|
398 |
-
Mage::getSingleton('core/session')->unsetData('newToken');
|
399 |
-
return true;
|
400 |
-
}
|
401 |
-
return false;
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* get TokenCustomerID is selected of customer
|
406 |
-
*
|
407 |
-
* @return mixed
|
408 |
-
*/
|
409 |
-
protected function _editToken()
|
410 |
-
{
|
411 |
-
if ($token = Mage::getSingleton('core/session')->getData('editToken')) {
|
412 |
-
Mage::getSingleton('core/session')->unsetData('editToken');
|
413 |
-
return $token;
|
414 |
-
}
|
415 |
-
return $token;
|
416 |
-
}
|
417 |
-
|
418 |
-
/**
|
419 |
-
* check paypal option in eway not saved
|
420 |
-
*
|
421 |
-
* @return mixed|null
|
422 |
-
*/
|
423 |
-
protected function _getPaypalCheckout()
|
424 |
-
{
|
425 |
-
if ($paypal = Mage::getSingleton('core/session')->getData('sharedpagePaypal')) {
|
426 |
-
Mage::getModel('core/session')->unsetData('sharedpagePaypal');
|
427 |
-
return $paypal;
|
428 |
-
}
|
429 |
-
return null;
|
430 |
-
}
|
431 |
-
|
432 |
-
/**
|
433 |
-
* update customer when edit shipping address to paypal
|
434 |
-
*
|
435 |
-
* @param $accessCode
|
436 |
-
*/
|
437 |
-
public function updateCustomer($accessCode)
|
438 |
-
{
|
439 |
-
$response = $this->_doRapidAPI('Transaction/' . $accessCode, 'GET');
|
440 |
-
if ($response->isSuccess()) {
|
441 |
-
$customer = $this->_quote->getCustomer();
|
442 |
-
$billingAddress = $this->_quote->getBillingAddress();
|
443 |
-
$shippingAddress = $this->_quote->getShippingAddress();
|
444 |
-
$trans = $response->getTransactions();
|
445 |
-
|
446 |
-
if (isset($trans[0]['Customer'])) {
|
447 |
-
$billing = $trans[0]['Customer'];
|
448 |
-
$billingAddress->setFirstname($billing['FirstName'])
|
449 |
-
->setLastName($billing['LastName'])
|
450 |
-
->setCompany($billing['CompanyName'])
|
451 |
-
->setJobDescription($billing['JobDescription'])
|
452 |
-
->setStreet($billing['Street1'])
|
453 |
-
->setStreet2($billing['Street2'])
|
454 |
-
->setCity($billing['City'])
|
455 |
-
->setState($billing['State'])
|
456 |
-
->setPostcode($billing['PostalCode'])
|
457 |
-
->setCountryId(strtoupper($billing['Country']))
|
458 |
-
->setEmail($billing['Email'])
|
459 |
-
->setTelephone($billing['Phone'])
|
460 |
-
->setMobile($billing['Mobile'])
|
461 |
-
->setComments($billing['Comments'])
|
462 |
-
->setFax($billing['Fax'])
|
463 |
-
->setUrl($billing['Url']);
|
464 |
-
}
|
465 |
-
if (isset($trans[0]['ShippingAddress'])) {
|
466 |
-
$shipping = $trans[0]['ShippingAddress'];
|
467 |
-
$shippingAddress->setFirstname($shipping['FirstName'])
|
468 |
-
->setLastname($shipping['LastName'])
|
469 |
-
->setStreet($shipping['Street1'])
|
470 |
-
->setStreet2($shipping['Street2'])
|
471 |
-
->setCity($shipping['City'])
|
472 |
-
->setPostcode($shipping['PostalCode'])
|
473 |
-
->setCountryId(strtoupper($shipping['Country']))
|
474 |
-
->setEmail($shipping['Email'])
|
475 |
-
->setFax($shipping['Fax']);
|
476 |
-
|
477 |
-
if ($shipping['State']
|
478 |
-
&& $shipping['Country']
|
479 |
-
&& $region = Mage::getModel('directory/region')->loadByCode($shipping['State'], $shipping['Country'])
|
480 |
-
) {
|
481 |
-
$shippingAddress->setRegion($region->getName())
|
482 |
-
->setRegionId($region->getId());
|
483 |
-
}
|
484 |
-
if ($shipping['Phone']) {
|
485 |
-
$shippingAddress->setTelephone($shipping['Phone']);
|
486 |
-
}
|
487 |
-
}
|
488 |
-
$this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress)->save();
|
489 |
-
}
|
490 |
-
}
|
491 |
-
|
492 |
-
/**
|
493 |
-
* save token when checkout with eway saved
|
494 |
-
*
|
495 |
-
* @param Eway_Rapid31_Model_Response $response
|
496 |
-
* @param null $ccNumber
|
497 |
-
*/
|
498 |
-
public function saveTokenById(Eway_Rapid31_Model_Response $response, $ccNumber = null)
|
499 |
-
{
|
500 |
-
$this->unsetData();
|
501 |
-
|
502 |
-
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
503 |
-
$customerParam->setTokenCustomerID($response->getTokenCustomerID());
|
504 |
-
$this->setCustomer($customerParam);
|
505 |
-
$payment = Mage::getModel('ewayrapid/field_payment');
|
506 |
-
$payment->setTotalAmount(1);
|
507 |
-
$this->setPayment($payment);
|
508 |
-
$this->setRedirectUrl(Mage::getBaseUrl() . '/ewayrapid/sharedpage/saveToken');
|
509 |
-
$this->setMethod('');
|
510 |
-
|
511 |
-
$response = $this->_doRapidAPI('AccessCodesShared');
|
512 |
-
$token = true;
|
513 |
-
if ($response->isSuccess()) {
|
514 |
-
if (!$ccNumber) {
|
515 |
-
$token = $this->_createNewToken($response);
|
516 |
-
} else {
|
517 |
-
$token = $this->_updateToken($response, $ccNumber);
|
518 |
-
}
|
519 |
-
|
520 |
-
} else {
|
521 |
-
Mage::throwException(
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
'
|
547 |
-
'
|
548 |
-
'
|
549 |
-
'
|
550 |
-
'
|
551 |
-
'
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
*
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
'
|
579 |
-
'
|
580 |
-
'
|
581 |
-
'
|
582 |
-
'
|
583 |
-
'
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
639 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Eway_Rapid31_Model_Request_Sharedpage extends Eway_Rapid31_Model_Request_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @var Mage_Sales_Model_Quote
|
7 |
+
*/
|
8 |
+
protected $_quote = null;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @var Mage_Customer_Model_Session
|
12 |
+
*/
|
13 |
+
protected $_customerSession;
|
14 |
+
|
15 |
+
public function __construct($params = array())
|
16 |
+
{
|
17 |
+
if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
|
18 |
+
$this->_quote = $params['quote'];
|
19 |
+
} else {
|
20 |
+
Mage::throwException('Quote instance is required.');
|
21 |
+
}
|
22 |
+
|
23 |
+
$this->_config = Mage::getSingleton('ewayrapid/config');
|
24 |
+
$this->_customerSession = Mage::getSingleton('customer/session');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* create AccessCode for process checkout
|
29 |
+
*
|
30 |
+
* @param null $returnUrl
|
31 |
+
* @param null $cancelUrl
|
32 |
+
* @return Eway_Rapid31_Model_Response
|
33 |
+
*/
|
34 |
+
public function createAccessCode($returnUrl = null, $cancelUrl = null)
|
35 |
+
{
|
36 |
+
// Empty Varien_Object's data
|
37 |
+
$this->unsetData();
|
38 |
+
$token = null;
|
39 |
+
$paypal = null;
|
40 |
+
$totalAmount = 0;
|
41 |
+
|
42 |
+
if ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD) {
|
43 |
+
if ($this->_isNewToken()) {
|
44 |
+
$returnUrl .= '?newToken=1';
|
45 |
+
$method = Eway_Rapid31_Model_Config::METHOD_CREATE_TOKEN;
|
46 |
+
} elseif ($token = $this->_editToken()) {
|
47 |
+
$returnUrl .= '?editToken=' . $token;
|
48 |
+
$token = Mage::helper('ewayrapid/customer')->getCustomerTokenId($token);
|
49 |
+
$method = Eway_Rapid31_Model_Config::METHOD_UPDATE_TOKEN;
|
50 |
+
}
|
51 |
+
} elseif ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD) {
|
52 |
+
if ($this->_isNewToken()) {
|
53 |
+
$returnUrl .= '?newToken=1';
|
54 |
+
if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
55 |
+
$method = Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT;
|
56 |
+
$totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
|
57 |
+
} else {
|
58 |
+
$method = Eway_Rapid31_Model_Config::METHOD_CREATE_TOKEN ;
|
59 |
+
}
|
60 |
+
} elseif ($token = $this->_editToken()) {
|
61 |
+
$returnUrl .= '?editToken=' . $token;
|
62 |
+
$token = Mage::helper('ewayrapid/customer')->getCustomerTokenId($token);
|
63 |
+
if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
64 |
+
$method = Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT;
|
65 |
+
$totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
|
66 |
+
} else {
|
67 |
+
$method = Eway_Rapid31_Model_Config::METHOD_UPDATE_TOKEN ;
|
68 |
+
}
|
69 |
+
} else {
|
70 |
+
if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
71 |
+
$method = Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT;
|
72 |
+
} else {
|
73 |
+
$method = Eway_Rapid31_Model_Config::METHOD_AUTHORISE;
|
74 |
+
}
|
75 |
+
$totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
|
76 |
+
$paypal = $this->_getPaypalCheckout();
|
77 |
+
if ($paypal === Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
|
78 |
+
$this->setCheckoutPayment(true);
|
79 |
+
$this->setCheckoutURL(Mage::getUrl('ewayrapid/sharedpage/review'));
|
80 |
+
}
|
81 |
+
}
|
82 |
+
} else {
|
83 |
+
if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
84 |
+
$method = Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT;
|
85 |
+
} else {
|
86 |
+
$method = Eway_Rapid31_Model_Config::METHOD_AUTHORISE;
|
87 |
+
}
|
88 |
+
$totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
|
89 |
+
$paypal = $this->_getPaypalCheckout();
|
90 |
+
if ($paypal === Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
|
91 |
+
$this->setCheckoutPayment(true);
|
92 |
+
$this->setCheckoutURL(Mage::getUrl('ewayrapid/sharedpage/review'));
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
$this->_buildRequest();
|
97 |
+
|
98 |
+
$customer = $this->getCustomer();
|
99 |
+
$customer->setTokenCustomerID($token ? $token : '');
|
100 |
+
$this->setCustomer($customer);
|
101 |
+
|
102 |
+
// prepare API
|
103 |
+
$this->setRedirectUrl($returnUrl);
|
104 |
+
$this->setCancelUrl($cancelUrl);
|
105 |
+
$this->setMethod($method);
|
106 |
+
|
107 |
+
if (Mage::helper('ewayrapid')->getTransferCartLineItems()) {
|
108 |
+
// add Shipping item and Line items
|
109 |
+
$lineItems = Mage::helper('ewayrapid')->getLineItems();
|
110 |
+
$this->setItems($lineItems);
|
111 |
+
}
|
112 |
+
|
113 |
+
// add Payment
|
114 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
115 |
+
$paymentParam->setTotalAmount($totalAmount);
|
116 |
+
$paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
|
117 |
+
|
118 |
+
// add InvoiceDescription and InvoiceReference
|
119 |
+
$config = Mage::getModel('ewayrapid/config');
|
120 |
+
|
121 |
+
if ($config->shouldPassingInvoiceDescription()) {
|
122 |
+
$invoiceDescription = '';
|
123 |
+
foreach ($this->_quote->getAllVisibleItems() as $item) {
|
124 |
+
// Check in case multi-shipping
|
125 |
+
if (!$item->getQuoteParentItem()) {
|
126 |
+
$invoiceDescription .= (int) $item->getQty() . ' x ' .$item->getName() . ', ';
|
127 |
+
}
|
128 |
+
}
|
129 |
+
$invoiceDescription = trim($invoiceDescription, ', ');
|
130 |
+
$invoiceDescription = Mage::helper('ewayrapid')->limitInvoiceDescriptionLength($invoiceDescription);
|
131 |
+
|
132 |
+
$paymentParam->setInvoiceDescription($invoiceDescription);
|
133 |
+
}
|
134 |
+
|
135 |
+
if ($config->shouldPassingGuessOrder()) {
|
136 |
+
$incrementId = $this->_getIncrementOrderId($this->_quote);
|
137 |
+
$paymentParam->setInvoiceReference($incrementId);
|
138 |
+
$paymentParam->setInvoiceNumber($incrementId);
|
139 |
+
}
|
140 |
+
|
141 |
+
$this->setPayment($paymentParam);
|
142 |
+
|
143 |
+
if ($this->_config->isSharedPageConnection()) {
|
144 |
+
// add Verify options
|
145 |
+
$this->setVerifyCustomerEmail($this->_config->getVerifyEmail());
|
146 |
+
$this->setVerifyCustomerPhone($this->_config->getVerifyPhone());
|
147 |
+
|
148 |
+
// add Custom View
|
149 |
+
$this->setCustomView($this->_config->getCustomView());
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
+
$response = $this->_doRapidAPI('AccessCodesShared');
|
154 |
+
return $response;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Call Authorisation API (Authorized only)
|
159 |
+
*
|
160 |
+
* @param Eway_Rapid31_Model_Response $response
|
161 |
+
* @return Eway_Rapid31_Model_Response
|
162 |
+
*/
|
163 |
+
public function doAuthorisation(Eway_Rapid31_Model_Response $response)
|
164 |
+
{
|
165 |
+
$this->unsetData();
|
166 |
+
|
167 |
+
$this->_buildRequest();
|
168 |
+
|
169 |
+
$cardData = $response->getCustomer();
|
170 |
+
if ($cardData['CardNumber'] && $cardData['CardName']) {
|
171 |
+
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
|
172 |
+
} else {
|
173 |
+
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
|
174 |
+
}
|
175 |
+
|
176 |
+
$items = $this->_quote->getAllVisibleItems();
|
177 |
+
$lineItems = array();
|
178 |
+
foreach ($items as $item) {
|
179 |
+
/* @var Mage_Sales_Model_Order_Item $item */
|
180 |
+
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
|
181 |
+
$lineItem->setSKU($item->getSku());
|
182 |
+
$lineItem->setDescription(substr($item->getName(), 0, 26));
|
183 |
+
$lineItem->setQuantity($item->getQty());
|
184 |
+
$lineItem->setUnitCost(round($item->getBasePrice() * 100));
|
185 |
+
$lineItem->setTax(round($item->getBaseTaxAmount() * 100));
|
186 |
+
$lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
|
187 |
+
$lineItems[] = $lineItem;
|
188 |
+
}
|
189 |
+
$this->setItems($lineItems);
|
190 |
+
|
191 |
+
$this->setItems(false);
|
192 |
+
|
193 |
+
// add Payment
|
194 |
+
$amount = round($this->_quote->getBaseGrandTotal() * 100);
|
195 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
196 |
+
$paymentParam->setTotalAmount($amount);
|
197 |
+
$paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
|
198 |
+
|
199 |
+
// add InvoiceDescription and InvoiceReference
|
200 |
+
$config = Mage::getModel('ewayrapid/config');
|
201 |
+
|
202 |
+
if ($config->shouldPassingInvoiceDescription()) {
|
203 |
+
$invoiceDescription = '';
|
204 |
+
foreach ($this->_quote->getAllVisibleItems() as $item) {
|
205 |
+
// Check in case multi-shipping
|
206 |
+
if (!$item->getQuoteParentItemId()) {
|
207 |
+
$invoiceDescription .= (int) $item->getQty() . ' x ' .$item->getName() . ', ';
|
208 |
+
}
|
209 |
+
}
|
210 |
+
$invoiceDescription = trim($invoiceDescription, ', ');
|
211 |
+
$invoiceDescription = Mage::helper('ewayrapid')->limitInvoiceDescriptionLength($invoiceDescription);
|
212 |
+
|
213 |
+
$paymentParam->setInvoiceDescription($invoiceDescription);
|
214 |
+
}
|
215 |
+
|
216 |
+
if ($config->shouldPassingGuessOrder()) {
|
217 |
+
$incrementId = $this->_getIncrementOrderId($this->_quote);
|
218 |
+
$paymentParam->setInvoiceReference($incrementId);
|
219 |
+
}
|
220 |
+
|
221 |
+
$this->setPayment($paymentParam);
|
222 |
+
|
223 |
+
$customerParam = $this->getCustomer();
|
224 |
+
$customerParam->setTokenCustomerID($response->getTokenCustomerID());
|
225 |
+
$this->setCustomer($customerParam);
|
226 |
+
|
227 |
+
$response = $this->_doRapidAPI('Authorisation');
|
228 |
+
return $response;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Call Transaction API (Authorized & Capture at the same time)
|
233 |
+
*
|
234 |
+
* @param Eway_Rapid31_Model_Response $response
|
235 |
+
* @return Eway_Rapid31_Model_Response
|
236 |
+
*/
|
237 |
+
public function doTransaction(Eway_Rapid31_Model_Response $response)
|
238 |
+
{
|
239 |
+
$this->unsetData();
|
240 |
+
|
241 |
+
$this->_buildRequest();
|
242 |
+
|
243 |
+
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
|
244 |
+
|
245 |
+
$items = $this->_quote->getAllVisibleItems();
|
246 |
+
$lineItems = array();
|
247 |
+
foreach ($items as $item) {
|
248 |
+
/* @var Mage_Sales_Model_Order_Item $item */
|
249 |
+
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
|
250 |
+
$lineItem->setSKU($item->getSku());
|
251 |
+
$lineItem->setDescription(substr($item->getName(), 0, 26));
|
252 |
+
$lineItem->setQuantity($item->getQty());
|
253 |
+
$lineItem->setUnitCost(round($item->getBasePrice() * 100));
|
254 |
+
$lineItem->setTax(round($item->getBaseTaxAmount() * 100));
|
255 |
+
$lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
|
256 |
+
$lineItems[] = $lineItem;
|
257 |
+
}
|
258 |
+
$this->setItems($lineItems);
|
259 |
+
|
260 |
+
$this->setItems(false);
|
261 |
+
|
262 |
+
// add Payment
|
263 |
+
$amount = round($this->_quote->getBaseGrandTotal() * 100);
|
264 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
265 |
+
$paymentParam->setTotalAmount($amount);
|
266 |
+
$paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
|
267 |
+
$this->setPayment($paymentParam);
|
268 |
+
|
269 |
+
$customerParam = $this->getCustomer();
|
270 |
+
$customerParam->setTokenCustomerID($response->getTokenCustomerID());
|
271 |
+
|
272 |
+
$this->setCustomer($customerParam);
|
273 |
+
|
274 |
+
$response = $this->_doRapidAPI('Transaction');
|
275 |
+
return $response;
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Call Capture API (do the Capture only, must Authorized previously)
|
280 |
+
*
|
281 |
+
* @param Eway_Rapid31_Model_Response $response
|
282 |
+
* @return Eway_Rapid31_Model_Response
|
283 |
+
*/
|
284 |
+
public function doCapturePayment(Eway_Rapid31_Model_Response $response)
|
285 |
+
{
|
286 |
+
$this->setTransactionId($response->getTransactionID());
|
287 |
+
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT);
|
288 |
+
|
289 |
+
$response = $this->_doRapidAPI('CapturePayment');
|
290 |
+
return $response;
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Build the request with necessary parameters for doAuthorisation(), doTransaction() and CreateAccessCode()
|
295 |
+
*
|
296 |
+
* @return $this
|
297 |
+
*/
|
298 |
+
protected function _buildRequest()
|
299 |
+
{
|
300 |
+
// prepare API
|
301 |
+
$this->setShippingMethod('Other');
|
302 |
+
$version = Mage::helper('ewayrapid')->getExtensionVersion();
|
303 |
+
$this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
|
304 |
+
if (Mage::helper('ewayrapid')->isBackendOrder()) {
|
305 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
|
306 |
+
} else {
|
307 |
+
$this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
|
308 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
|
309 |
+
}
|
310 |
+
$this->setCustomerReadOnly(true);
|
311 |
+
|
312 |
+
// add Billing Address
|
313 |
+
$billingAddress = $this->_quote->getBillingAddress();
|
314 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
315 |
+
|
316 |
+
$title = $this->_fixTitle($billingAddress->getPrefix());
|
317 |
+
|
318 |
+
$customerParam->setTitle($title)
|
319 |
+
->setFirstName($billingAddress->getFirstname())
|
320 |
+
->setLastName($billingAddress->getLastname())
|
321 |
+
->setCompanyName($billingAddress->getCompany())
|
322 |
+
->setJobDescription($billingAddress->getJobDescription())
|
323 |
+
->setStreet1($billingAddress->getStreet1())
|
324 |
+
->setStreet2($billingAddress->getStreet2())
|
325 |
+
->setCity($billingAddress->getCity())
|
326 |
+
->setState($billingAddress->getRegion())
|
327 |
+
->setPostalCode($billingAddress->getPostcode())
|
328 |
+
->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
|
329 |
+
->setEmail($billingAddress->getEmail())
|
330 |
+
->setPhone($billingAddress->getTelephone())
|
331 |
+
->setMobile($billingAddress->getMobile())
|
332 |
+
->setComments('')
|
333 |
+
->setFax($billingAddress->getFax())
|
334 |
+
->setUrl('');
|
335 |
+
$this->setCustomer($customerParam);
|
336 |
+
|
337 |
+
// add Shipping Address
|
338 |
+
$shippingAddress = $this->_quote->getShippingAddress();
|
339 |
+
|
340 |
+
// copy BillingAddress to ShippingAddress if checkout with guest or register
|
341 |
+
/**
|
342 |
+
$checkoutMethod = $this->_quote->getCheckoutMethod();
|
343 |
+
if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
|
344 |
+
|| $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
|
345 |
+
) {
|
346 |
+
$shippingAddress = $billingAddress;
|
347 |
+
}
|
348 |
+
*/
|
349 |
+
|
350 |
+
if (!empty($shippingAddress)) {
|
351 |
+
$shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
|
352 |
+
$shippingParam->setFirstName($shippingAddress->getFirstname())
|
353 |
+
->setLastName($shippingAddress->getLastname())
|
354 |
+
->setStreet1($shippingAddress->getStreet1())
|
355 |
+
->setStreet2($shippingAddress->getStreet2())
|
356 |
+
->setCity($shippingAddress->getCity())
|
357 |
+
->setState($shippingAddress->getRegion())
|
358 |
+
->setPostalCode($shippingAddress->getPostcode())
|
359 |
+
->setCountry(strtolower($shippingAddress->getCountryModel()->getIso2Code()))
|
360 |
+
->setEmail($shippingAddress->getEmail())
|
361 |
+
->setPhone($shippingAddress->getTelephone())
|
362 |
+
->setFax($shippingAddress->getFax());
|
363 |
+
$this->setShippingAddress($shippingParam);
|
364 |
+
}
|
365 |
+
|
366 |
+
return $this;
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Get customer information by access code
|
371 |
+
*/
|
372 |
+
public function getInfoByAccessCode($accessCode)
|
373 |
+
{
|
374 |
+
$response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
|
375 |
+
return $response;
|
376 |
+
}
|
377 |
+
|
378 |
+
/**
|
379 |
+
* Get customer session object
|
380 |
+
*
|
381 |
+
* @return Mage_Customer_Model_Session
|
382 |
+
*/
|
383 |
+
public function getCustomerSession()
|
384 |
+
{
|
385 |
+
return $this->_customerSession;
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* check is new token when checkout
|
390 |
+
*
|
391 |
+
* @return bool
|
392 |
+
*/
|
393 |
+
protected function _isNewToken()
|
394 |
+
{
|
395 |
+
$info = $this->_quote->getPayment();
|
396 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
|
397 |
+
if ($token = Mage::getSingleton('core/session')->getData('newToken')) {
|
398 |
+
Mage::getSingleton('core/session')->unsetData('newToken');
|
399 |
+
return true;
|
400 |
+
}
|
401 |
+
return false;
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* get TokenCustomerID is selected of customer
|
406 |
+
*
|
407 |
+
* @return mixed
|
408 |
+
*/
|
409 |
+
protected function _editToken()
|
410 |
+
{
|
411 |
+
if ($token = Mage::getSingleton('core/session')->getData('editToken')) {
|
412 |
+
Mage::getSingleton('core/session')->unsetData('editToken');
|
413 |
+
return $token;
|
414 |
+
}
|
415 |
+
return $token;
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* check paypal option in eway not saved
|
420 |
+
*
|
421 |
+
* @return mixed|null
|
422 |
+
*/
|
423 |
+
protected function _getPaypalCheckout()
|
424 |
+
{
|
425 |
+
if ($paypal = Mage::getSingleton('core/session')->getData('sharedpagePaypal')) {
|
426 |
+
Mage::getModel('core/session')->unsetData('sharedpagePaypal');
|
427 |
+
return $paypal;
|
428 |
+
}
|
429 |
+
return null;
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* update customer when edit shipping address to paypal
|
434 |
+
*
|
435 |
+
* @param $accessCode
|
436 |
+
*/
|
437 |
+
public function updateCustomer($accessCode)
|
438 |
+
{
|
439 |
+
$response = $this->_doRapidAPI('Transaction/' . $accessCode, 'GET');
|
440 |
+
if ($response->isSuccess()) {
|
441 |
+
$customer = $this->_quote->getCustomer();
|
442 |
+
$billingAddress = $this->_quote->getBillingAddress();
|
443 |
+
$shippingAddress = $this->_quote->getShippingAddress();
|
444 |
+
$trans = $response->getTransactions();
|
445 |
+
|
446 |
+
if (isset($trans[0]['Customer'])) {
|
447 |
+
$billing = $trans[0]['Customer'];
|
448 |
+
$billingAddress->setFirstname($billing['FirstName'])
|
449 |
+
->setLastName($billing['LastName'])
|
450 |
+
->setCompany($billing['CompanyName'])
|
451 |
+
->setJobDescription($billing['JobDescription'])
|
452 |
+
->setStreet($billing['Street1'])
|
453 |
+
->setStreet2($billing['Street2'])
|
454 |
+
->setCity($billing['City'])
|
455 |
+
->setState($billing['State'])
|
456 |
+
->setPostcode($billing['PostalCode'])
|
457 |
+
->setCountryId(strtoupper($billing['Country']))
|
458 |
+
->setEmail($billing['Email'])
|
459 |
+
->setTelephone($billing['Phone'])
|
460 |
+
->setMobile($billing['Mobile'])
|
461 |
+
->setComments($billing['Comments'])
|
462 |
+
->setFax($billing['Fax'])
|
463 |
+
->setUrl($billing['Url']);
|
464 |
+
}
|
465 |
+
if (isset($trans[0]['ShippingAddress'])) {
|
466 |
+
$shipping = $trans[0]['ShippingAddress'];
|
467 |
+
$shippingAddress->setFirstname($shipping['FirstName'])
|
468 |
+
->setLastname($shipping['LastName'])
|
469 |
+
->setStreet($shipping['Street1'])
|
470 |
+
->setStreet2($shipping['Street2'])
|
471 |
+
->setCity($shipping['City'])
|
472 |
+
->setPostcode($shipping['PostalCode'])
|
473 |
+
->setCountryId(strtoupper($shipping['Country']))
|
474 |
+
->setEmail($shipping['Email'])
|
475 |
+
->setFax($shipping['Fax']);
|
476 |
+
|
477 |
+
if ($shipping['State']
|
478 |
+
&& $shipping['Country']
|
479 |
+
&& $region = Mage::getModel('directory/region')->loadByCode($shipping['State'], $shipping['Country'])
|
480 |
+
) {
|
481 |
+
$shippingAddress->setRegion($region->getName())
|
482 |
+
->setRegionId($region->getId());
|
483 |
+
}
|
484 |
+
if ($shipping['Phone']) {
|
485 |
+
$shippingAddress->setTelephone($shipping['Phone']);
|
486 |
+
}
|
487 |
+
}
|
488 |
+
$this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress)->save();
|
489 |
+
}
|
490 |
+
}
|
491 |
+
|
492 |
+
/**
|
493 |
+
* save token when checkout with eway saved
|
494 |
+
*
|
495 |
+
* @param Eway_Rapid31_Model_Response $response
|
496 |
+
* @param null $ccNumber
|
497 |
+
*/
|
498 |
+
public function saveTokenById(Eway_Rapid31_Model_Response $response, $ccNumber = null)
|
499 |
+
{
|
500 |
+
$this->unsetData();
|
501 |
+
|
502 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
503 |
+
$customerParam->setTokenCustomerID($response->getTokenCustomerID());
|
504 |
+
$this->setCustomer($customerParam);
|
505 |
+
$payment = Mage::getModel('ewayrapid/field_payment');
|
506 |
+
$payment->setTotalAmount(1);
|
507 |
+
$this->setPayment($payment);
|
508 |
+
$this->setRedirectUrl(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . '/ewayrapid/sharedpage/saveToken');
|
509 |
+
$this->setMethod('');
|
510 |
+
|
511 |
+
$response = $this->_doRapidAPI('AccessCodesShared');
|
512 |
+
$token = true;
|
513 |
+
if ($response->isSuccess()) {
|
514 |
+
if (!$ccNumber) {
|
515 |
+
$token = $this->_createNewToken($response);
|
516 |
+
} else {
|
517 |
+
$token = $this->_updateToken($response, $ccNumber);
|
518 |
+
}
|
519 |
+
|
520 |
+
} else {
|
521 |
+
Mage::throwException(
|
522 |
+
Mage::helper('ewayrapid')->__(
|
523 |
+
'An error occurred while creating new token. Please try again. (Error message: %s)',
|
524 |
+
$response->getMessage()
|
525 |
+
)
|
526 |
+
);
|
527 |
+
}
|
528 |
+
if (!$token) {
|
529 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while process token. Please try again.'));
|
530 |
+
}
|
531 |
+
return $response;
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* Create new token when checkout
|
536 |
+
*
|
537 |
+
* @param Eway_Rapid31_Model_Response $response
|
538 |
+
* @return $this
|
539 |
+
*/
|
540 |
+
protected function _createNewToken(Eway_Rapid31_Model_Response $response)
|
541 |
+
{
|
542 |
+
try {
|
543 |
+
$customer = $response->getCustomer();
|
544 |
+
|
545 |
+
$tokenInfo = array(
|
546 |
+
'Token' => $response->getTokenCustomerID(),
|
547 |
+
'Card' => $customer['CardNumber'] ? substr_replace($customer['CardNumber'], '******', 6, 6) : 'Paypal',
|
548 |
+
'Owner' => $customer['CardName'],
|
549 |
+
'StartMonth' => $customer['CardStartMonth'],
|
550 |
+
'StartYear' => $customer['CardStartYear'],
|
551 |
+
'IssueNumber' => $customer['CardIssueNumber'],
|
552 |
+
'ExpMonth' => $customer['CardExpiryMonth'],
|
553 |
+
'ExpYear' => (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear']),
|
554 |
+
'Type' => $this->checkCardType($customer['CardNumber']),
|
555 |
+
'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customer),
|
556 |
+
);
|
557 |
+
|
558 |
+
Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
|
559 |
+
return true;
|
560 |
+
} catch (Exception $e) {
|
561 |
+
return false;
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Update token when checkout with existing token
|
567 |
+
*
|
568 |
+
* @param Eway_Rapid31_Model_Response $response
|
569 |
+
* @param null $ccNumber
|
570 |
+
* @return $this
|
571 |
+
*/
|
572 |
+
protected function _updateToken(Eway_Rapid31_Model_Response $response, $ccNumber = null)
|
573 |
+
{
|
574 |
+
try {
|
575 |
+
$customer = $response->getCustomer();
|
576 |
+
|
577 |
+
$tokenInfo = array(
|
578 |
+
'Token' => $response->getTokenCustomerID(),
|
579 |
+
'Card' => $customer['CardNumber'] ? substr_replace($customer['CardNumber'], '******', 6, 6) : 'Paypal',
|
580 |
+
'Owner' => $customer['CardName'],
|
581 |
+
'StartMonth' => $customer['CardStartMonth'],
|
582 |
+
'StartYear' => $customer['CardStartYear'],
|
583 |
+
'IssueNumber' => $customer['CardIssueNumber'],
|
584 |
+
'ExpMonth' => $customer['CardExpiryMonth'],
|
585 |
+
'ExpYear' => (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear']),
|
586 |
+
'Type' => $this->checkCardType($customer['CardNumber']),
|
587 |
+
'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customer),
|
588 |
+
);
|
589 |
+
|
590 |
+
Mage::helper('ewayrapid/customer')->updateToken($ccNumber, $tokenInfo);
|
591 |
+
return true;
|
592 |
+
} catch (Exception $e) {
|
593 |
+
return false;
|
594 |
+
}
|
595 |
+
}
|
596 |
+
|
597 |
+
/**
|
598 |
+
* Get card type name by card number
|
599 |
+
* @param $num Card number
|
600 |
+
* @return string Card type name
|
601 |
+
*/
|
602 |
+
public function checkCardType($num)
|
603 |
+
{
|
604 |
+
if ($num == null) {
|
605 |
+
return Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD;
|
606 |
+
}
|
607 |
+
return Mage::getModel('ewayrapid/request_token')->checkCardType($num);
|
608 |
+
}
|
609 |
+
|
610 |
+
public function getShippingByCode($postalCode)
|
611 |
+
{
|
612 |
+
$groups = $this->_quote->getShippingAddress()
|
613 |
+
->collectShippingRates()
|
614 |
+
->getGroupedAllShippingRates();
|
615 |
+
// determine current selected code & name
|
616 |
+
foreach ($groups as $code => $rates) {
|
617 |
+
foreach ($rates as $rate) {
|
618 |
+
if (strtoupper($postalCode) == strtoupper($rate->getCode())) {
|
619 |
+
return $rate;
|
620 |
+
}
|
621 |
+
}
|
622 |
+
}
|
623 |
+
return false;
|
624 |
+
}
|
625 |
+
|
626 |
+
public function getMethod()
|
627 |
+
{
|
628 |
+
return Mage::getSingleton('core/session')->getData('ewayMethod');
|
629 |
+
}
|
630 |
+
|
631 |
+
public function getTransaction($transactionNumber)
|
632 |
+
{
|
633 |
+
try {
|
634 |
+
$results = $this->_doRapidAPI("Transaction/$transactionNumber", 'GET');
|
635 |
+
if ($results->isSuccess()) {
|
636 |
+
return $results->getTransactions();
|
637 |
+
}
|
638 |
+
} catch (Exception $e) {
|
639 |
+
Mage::throwException(
|
640 |
+
Mage::helper('ewayrapid')->__(
|
641 |
+
'An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
|
642 |
+
$results->getMessage()
|
643 |
+
)
|
644 |
+
);
|
645 |
+
return false;
|
646 |
+
}
|
647 |
+
}
|
648 |
}
|
app/code/community/Eway/Rapid31/Model/Request/Token.php
CHANGED
@@ -1,544 +1,557 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_Request_Token extends Eway_Rapid31_Model_Request_Direct
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Call create new customer token API
|
6 |
-
*
|
7 |
-
* @param Varien_Object $billing
|
8 |
-
* @param Varien_Object $infoInstance
|
9 |
-
* @return Eway_Rapid31_Model_Request_Token
|
10 |
-
*/
|
11 |
-
public function createNewToken(Varien_Object $billing, Varien_Object $infoInstance)
|
12 |
-
{
|
13 |
-
// Empty Varien_Object's data
|
14 |
-
$this->unsetData();
|
15 |
-
|
16 |
-
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
17 |
-
|
18 |
-
$title = $this->_fixTitle($billing->getPrefix());
|
19 |
-
|
20 |
-
$customerParam->setTitle($title)
|
21 |
-
->setFirstName($billing->getFirstname())
|
22 |
-
->setLastName($billing->getLastname())
|
23 |
-
->setCompanyName($billing->getCompany())
|
24 |
-
->setJobDescription($billing->getJobDescription())
|
25 |
-
->setStreet1($billing->getStreet1())
|
26 |
-
->setStreet2($billing->getStreet2())
|
27 |
-
->setCity($billing->getCity())
|
28 |
-
->setState($billing->getRegion())
|
29 |
-
->setPostalCode($billing->getPostcode())
|
30 |
-
->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
|
31 |
-
->setEmail($billing->getEmail())
|
32 |
-
->setPhone($billing->getTelephone())
|
33 |
-
->setMobile($billing->getMobile())
|
34 |
-
->setComments('')
|
35 |
-
->setFax($billing->getFax())
|
36 |
-
->setUrl('');
|
37 |
-
|
38 |
-
$cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
|
39 |
-
$cardDetails->setName($infoInstance->getCcOwner())
|
40 |
-
->setNumber($infoInstance->getCcNumber())
|
41 |
-
->setExpiryMonth($infoInstance->getCcExpMonth())
|
42 |
-
->setExpiryYear($infoInstance->getCcExpYear())
|
43 |
-
->setCVN($infoInstance->getCcCid())
|
44 |
-
->setStartMonth($infoInstance->getStartMonth())
|
45 |
-
->setStartYear($infoInstance->getStartYear())
|
46 |
-
->setIssueNumber($infoInstance->getIssueNumber());
|
47 |
-
$customerParam->setCardDetails($cardDetails);
|
48 |
-
$this->setCustomer($customerParam);
|
49 |
-
|
50 |
-
$response = $this->_doRapidAPI('Customer');
|
51 |
-
if ($response->isSuccess()) {
|
52 |
-
$customerReturn = $response->getCustomer();
|
53 |
-
$cardDetails = $customerReturn['CardDetails'];
|
54 |
-
unset($customerReturn['CardDetails']);
|
55 |
-
$customerReturn['RegionId'] = ((!$billing->getRegion() && $billing->getRegionId()) ? $billing->getRegionId() : '');
|
56 |
-
$tokenInfo = array(
|
57 |
-
'Token' => $response->getTokenCustomerID(),
|
58 |
-
'Card' => substr_replace($cardDetails['Number'], '******', 6, 6),
|
59 |
-
'Owner' => $infoInstance->getCcOwner(),
|
60 |
-
'ExpMonth' => $infoInstance->getCcExpMonth(),
|
61 |
-
'ExpYear' => $infoInstance->getCcExpYear(),
|
62 |
-
'Type' => $infoInstance->getCcType(),
|
63 |
-
'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customerReturn),
|
64 |
-
);
|
65 |
-
Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
|
66 |
-
return $this;
|
67 |
-
} else {
|
68 |
-
Mage::throwException(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
*
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
$
|
92 |
-
|
93 |
-
$customerParam
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
->
|
99 |
-
->
|
100 |
-
->
|
101 |
-
->
|
102 |
-
->
|
103 |
-
->
|
104 |
-
->
|
105 |
-
->
|
106 |
-
->
|
107 |
-
->
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
$
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
'
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
$
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
$
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
if
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
$
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
$
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
$
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
$this->
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
->
|
249 |
-
->
|
250 |
-
->
|
251 |
-
->
|
252 |
-
->
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
$
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
$
|
266 |
-
$lineItem
|
267 |
-
$lineItem->
|
268 |
-
$
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
*
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
$
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
->
|
302 |
-
->
|
303 |
-
->
|
304 |
-
->
|
305 |
-
->
|
306 |
-
->
|
307 |
-
->
|
308 |
-
->
|
309 |
-
->
|
310 |
-
->
|
311 |
-
->
|
312 |
-
->
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
if($
|
323 |
-
$returnUrl .= '&
|
324 |
-
}
|
325 |
-
if($infoInstance->
|
326 |
-
$returnUrl .= '&
|
327 |
-
}
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
$
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
$this->
|
343 |
-
$this->
|
344 |
-
$this->
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
$
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
$
|
370 |
-
|
371 |
-
|
372 |
-
$
|
373 |
-
$
|
374 |
-
$
|
375 |
-
$
|
376 |
-
|
377 |
-
$
|
378 |
-
$this->
|
379 |
-
$this->
|
380 |
-
|
381 |
-
$
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
'
|
405 |
-
'
|
406 |
-
'
|
407 |
-
'
|
408 |
-
'
|
409 |
-
'
|
410 |
-
'
|
411 |
-
'
|
412 |
-
'
|
413 |
-
'
|
414 |
-
'
|
415 |
-
'
|
416 |
-
'
|
417 |
-
'
|
418 |
-
|
419 |
-
|
420 |
-
'
|
421 |
-
'
|
422 |
-
'
|
423 |
-
|
424 |
-
|
425 |
-
'
|
426 |
-
'
|
427 |
-
'
|
428 |
-
|
429 |
-
'
|
430 |
-
'
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
'
|
457 |
-
'
|
458 |
-
'
|
459 |
-
'
|
460 |
-
'
|
461 |
-
'
|
462 |
-
'
|
463 |
-
'
|
464 |
-
'
|
465 |
-
'
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
'
|
470 |
-
'
|
471 |
-
'
|
472 |
-
'
|
473 |
-
'
|
474 |
-
'
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
'
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_Request_Token extends Eway_Rapid31_Model_Request_Direct
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Call create new customer token API
|
6 |
+
*
|
7 |
+
* @param Varien_Object $billing
|
8 |
+
* @param Varien_Object $infoInstance
|
9 |
+
* @return Eway_Rapid31_Model_Request_Token
|
10 |
+
*/
|
11 |
+
public function createNewToken(Varien_Object $billing, Varien_Object $infoInstance)
|
12 |
+
{
|
13 |
+
// Empty Varien_Object's data
|
14 |
+
$this->unsetData();
|
15 |
+
|
16 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
17 |
+
|
18 |
+
$title = $this->_fixTitle($billing->getPrefix());
|
19 |
+
|
20 |
+
$customerParam->setTitle($title)
|
21 |
+
->setFirstName($billing->getFirstname())
|
22 |
+
->setLastName($billing->getLastname())
|
23 |
+
->setCompanyName($billing->getCompany())
|
24 |
+
->setJobDescription($billing->getJobDescription())
|
25 |
+
->setStreet1($billing->getStreet1())
|
26 |
+
->setStreet2($billing->getStreet2())
|
27 |
+
->setCity($billing->getCity())
|
28 |
+
->setState($billing->getRegion())
|
29 |
+
->setPostalCode($billing->getPostcode())
|
30 |
+
->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
|
31 |
+
->setEmail($billing->getEmail())
|
32 |
+
->setPhone($billing->getTelephone())
|
33 |
+
->setMobile($billing->getMobile())
|
34 |
+
->setComments('')
|
35 |
+
->setFax($billing->getFax())
|
36 |
+
->setUrl('');
|
37 |
+
|
38 |
+
$cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
|
39 |
+
$cardDetails->setName($infoInstance->getCcOwner())
|
40 |
+
->setNumber($infoInstance->getCcNumber())
|
41 |
+
->setExpiryMonth($infoInstance->getCcExpMonth())
|
42 |
+
->setExpiryYear($infoInstance->getCcExpYear())
|
43 |
+
->setCVN($infoInstance->getCcCid())
|
44 |
+
->setStartMonth($infoInstance->getStartMonth())
|
45 |
+
->setStartYear($infoInstance->getStartYear())
|
46 |
+
->setIssueNumber($infoInstance->getIssueNumber());
|
47 |
+
$customerParam->setCardDetails($cardDetails);
|
48 |
+
$this->setCustomer($customerParam);
|
49 |
+
|
50 |
+
$response = $this->_doRapidAPI('Customer');
|
51 |
+
if ($response->isSuccess()) {
|
52 |
+
$customerReturn = $response->getCustomer();
|
53 |
+
$cardDetails = $customerReturn['CardDetails'];
|
54 |
+
unset($customerReturn['CardDetails']);
|
55 |
+
$customerReturn['RegionId'] = ((!$billing->getRegion() && $billing->getRegionId()) ? $billing->getRegionId() : '');
|
56 |
+
$tokenInfo = array(
|
57 |
+
'Token' => $response->getTokenCustomerID(),
|
58 |
+
'Card' => substr_replace($cardDetails['Number'], '******', 6, 6),
|
59 |
+
'Owner' => $infoInstance->getCcOwner(),
|
60 |
+
'ExpMonth' => $infoInstance->getCcExpMonth(),
|
61 |
+
'ExpYear' => $infoInstance->getCcExpYear(),
|
62 |
+
'Type' => $infoInstance->getCcType(),
|
63 |
+
'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customerReturn),
|
64 |
+
);
|
65 |
+
Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
|
66 |
+
return $this;
|
67 |
+
} else {
|
68 |
+
Mage::throwException(
|
69 |
+
Mage::helper('ewayrapid')->__(
|
70 |
+
'An error occurred while creating new token. Please try again. (Error message: %s)',
|
71 |
+
$response->getMessage()
|
72 |
+
)
|
73 |
+
);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Update current token
|
79 |
+
*
|
80 |
+
* @param Varien_Object $billing
|
81 |
+
* @param Varien_Object $infoInstance
|
82 |
+
* @return Eway_Rapid31_Model_Request_Token
|
83 |
+
*/
|
84 |
+
public function updateToken(Varien_Object $billing, Varien_Object $infoInstance)
|
85 |
+
{
|
86 |
+
if (!Mage::helper('ewayrapid')->isBackendOrder() && !Mage::getSingleton('ewayrapid/config')->canEditToken()) {
|
87 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('Customers are not allowed to edit token.'));
|
88 |
+
}
|
89 |
+
|
90 |
+
// Empty Varien_Object's data
|
91 |
+
$this->unsetData();
|
92 |
+
|
93 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
94 |
+
|
95 |
+
$title = $this->_fixTitle($billing->getPrefix());
|
96 |
+
|
97 |
+
$customerParam->setTitle($title)
|
98 |
+
->setFirstName($billing->getFirstname())
|
99 |
+
->setLastName($billing->getLastname())
|
100 |
+
->setCompanyName($billing->getCompany())
|
101 |
+
->setJobDescription($billing->getJobDescription())
|
102 |
+
->setStreet1($billing->getStreet1())
|
103 |
+
->setStreet2($billing->getStreet2())
|
104 |
+
->setCity($billing->getCity())
|
105 |
+
->setState($billing->getRegion())
|
106 |
+
->setPostalCode($billing->getPostcode())
|
107 |
+
->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
|
108 |
+
->setEmail($billing->getEmail())
|
109 |
+
->setPhone($billing->getTelephone())
|
110 |
+
->setMobile($billing->getMobile())
|
111 |
+
->setFax($billing->getFax());
|
112 |
+
|
113 |
+
$customerHelper = Mage::helper('ewayrapid/customer');
|
114 |
+
$customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken());
|
115 |
+
if ($customerTokenId) {
|
116 |
+
$customerParam->setTokenCustomerID($customerTokenId);
|
117 |
+
} else {
|
118 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
|
119 |
+
}
|
120 |
+
|
121 |
+
$cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
|
122 |
+
$cardDetails->setName($infoInstance->getCcOwner())
|
123 |
+
->setExpiryMonth($infoInstance->getCcExpMonth())
|
124 |
+
->setNumber('444433XXXXXX1111') // Required dummy card number for update to work
|
125 |
+
->setExpiryYear($infoInstance->getCcExpYear())
|
126 |
+
->setCVN($infoInstance->getCcCid());
|
127 |
+
$customerParam->setCardDetails($cardDetails);
|
128 |
+
|
129 |
+
$this->setCustomer($customerParam);
|
130 |
+
|
131 |
+
$response = $this->_doRapidAPI('Customer', 'PUT');
|
132 |
+
if ($response->isSuccess()) {
|
133 |
+
$customerReturn = $response->getCustomer();
|
134 |
+
$customerReturn['RegionId'] = ((!$billing->getRegion() && $billing->getRegionId()) ? $billing->getRegionId() : '');
|
135 |
+
unset($customerReturn['CardDetails']);
|
136 |
+
$tokenInfo = array(
|
137 |
+
'Token' => $response->getTokenCustomerID(),
|
138 |
+
'Owner' => $infoInstance->getCcOwner(),
|
139 |
+
'ExpMonth' => $infoInstance->getCcExpMonth(),
|
140 |
+
'ExpYear' => $infoInstance->getCcExpYear(),
|
141 |
+
'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customerReturn),
|
142 |
+
);
|
143 |
+
Mage::helper('ewayrapid/customer')->updateToken($infoInstance->getSavedToken(), $tokenInfo);
|
144 |
+
return $this;
|
145 |
+
} else {
|
146 |
+
Mage::throwException(
|
147 |
+
Mage::helper('ewayrapid')->__(
|
148 |
+
'An error occurred while updating token. Please try again. (Error message: %s)',
|
149 |
+
$response->getMessage()
|
150 |
+
)
|
151 |
+
);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
|
156 |
+
{
|
157 |
+
// Empty Varien_Object's data
|
158 |
+
$this->unsetData();
|
159 |
+
// in case recurring profile, $methodInstance is not exist, and $payment->getIsRecurring() is used
|
160 |
+
if (!$payment->getIsRecurring()) {
|
161 |
+
$methodInstance = $payment->getMethodInstance();
|
162 |
+
$infoInstance = $methodInstance->getInfoInstance();
|
163 |
+
Mage::helper('ewayrapid')->unserializeInfoInstace($infoInstance);
|
164 |
+
}
|
165 |
+
$order = $payment->getOrder();
|
166 |
+
$shipping = $order->getShippingAddress();
|
167 |
+
|
168 |
+
// if item is virtual product
|
169 |
+
if (!$shipping) {
|
170 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
171 |
+
if ($quote->isVirtual()) {
|
172 |
+
$shipping = $quote->getBillingAddress();
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
if (Mage::helper('ewayrapid')->isBackendOrder()) {
|
177 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
|
178 |
+
} elseif ($payment->getIsRecurring()) {
|
179 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_RECURRING);
|
180 |
+
} else {
|
181 |
+
$this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
|
182 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
|
183 |
+
}
|
184 |
+
$version = Mage::helper('ewayrapid')->getExtensionVersion();
|
185 |
+
$this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
|
186 |
+
$this->setShippingMethod('Other');
|
187 |
+
|
188 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
189 |
+
$paymentParam->setTotalAmount($amount)
|
190 |
+
->setCurrencyCode($order->getBaseCurrencyCode());
|
191 |
+
|
192 |
+
// add InvoiceDescription and InvoiceReference
|
193 |
+
$config = Mage::getModel('ewayrapid/config');
|
194 |
+
|
195 |
+
if ($config->shouldPassingInvoiceDescription()) {
|
196 |
+
$invoiceDescription = '';
|
197 |
+
foreach ($order->getAllVisibleItems() as $item) {
|
198 |
+
// Check in case multi-shipping
|
199 |
+
if (!$item->getQuoteParentItemId()) {
|
200 |
+
$invoiceDescription .= (int) $item->getQtyOrdered() . ' x ' .$item->getName() . ', ';
|
201 |
+
}
|
202 |
+
}
|
203 |
+
$invoiceDescription = trim($invoiceDescription, ', ');
|
204 |
+
$invoiceDescription = Mage::helper('ewayrapid')->limitInvoiceDescriptionLength($invoiceDescription);
|
205 |
+
|
206 |
+
$paymentParam->setInvoiceDescription($invoiceDescription);
|
207 |
+
}
|
208 |
+
|
209 |
+
if ($config->shouldPassingGuessOrder()) {
|
210 |
+
$paymentParam->setInvoiceReference($order->getIncrementId());
|
211 |
+
}
|
212 |
+
|
213 |
+
$this->setPayment($paymentParam);
|
214 |
+
|
215 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
216 |
+
$customerTokenId = null;
|
217 |
+
|
218 |
+
/** get $customerTokenId if product is recurring profile */
|
219 |
+
if ($payment->getIsRecurring()) {
|
220 |
+
$customer = Mage::getModel('customer/customer')->load($payment->getCustomerId());
|
221 |
+
$customerHelper = Mage::helper('ewayrapid/customer');
|
222 |
+
$customerHelper->setCurrentCustomer($customer);
|
223 |
+
$customerTokenId = $customerHelper->getCustomerTokenId($payment->getTokenId());
|
224 |
+
} else {
|
225 |
+
/** get $customerTokenId if product is normal item */
|
226 |
+
if ($infoInstance->getSavedToken()) {
|
227 |
+
$customerHelper = Mage::helper('ewayrapid/customer');
|
228 |
+
$customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken());
|
229 |
+
} else {
|
230 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
|
231 |
+
}
|
232 |
+
}
|
233 |
+
if ($customerTokenId) {
|
234 |
+
$customerParam->setTokenCustomerID($customerTokenId);
|
235 |
+
if ($this->getTransactionType() == Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE) {
|
236 |
+
$cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
|
237 |
+
$cardDetails->setCVN($infoInstance->getCcCid());
|
238 |
+
$customerParam->setCardDetails($cardDetails);
|
239 |
+
}
|
240 |
+
$this->setCustomer($customerParam);
|
241 |
+
} else {
|
242 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
|
243 |
+
}
|
244 |
+
|
245 |
+
if (!empty($shipping)) {
|
246 |
+
$shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
|
247 |
+
$shippingParam->setFirstName($shipping->getFirstname())
|
248 |
+
->setLastName($shipping->getLastname())
|
249 |
+
->setStreet1($shipping->getStreet1())
|
250 |
+
->setStreet2($shipping->getStreet2())
|
251 |
+
->setCity($shipping->getCity())
|
252 |
+
->setState($shipping->getRegion())
|
253 |
+
->setPostalCode($shipping->getPostcode())
|
254 |
+
->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))
|
255 |
+
->setEmail($shipping->getEmail())
|
256 |
+
->setPhone($shipping->getTelephone())
|
257 |
+
->setFax($shipping->getFax());
|
258 |
+
$this->setShippingAddress($shippingParam);
|
259 |
+
}
|
260 |
+
|
261 |
+
if ((isset($methodInstance) && $methodInstance->getConfigData('transfer_cart_items')) || $payment->getIsRecurring() || !$payment->getIsInitialFee()) {
|
262 |
+
$orderItems = $order->getAllVisibleItems();
|
263 |
+
$lineItems = array();
|
264 |
+
foreach ($orderItems as $orderItem) {
|
265 |
+
/* @var Mage_Sales_Model_Order_Item $orderItem */
|
266 |
+
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
|
267 |
+
$lineItem->setSKU($orderItem->getSku());
|
268 |
+
$lineItem->setDescription(substr($orderItem->getName(), 0, 26));
|
269 |
+
$lineItem->setQuantity($orderItem->getQtyOrdered());
|
270 |
+
$lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
|
271 |
+
$lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
|
272 |
+
$lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
|
273 |
+
$lineItems[] = $lineItem;
|
274 |
+
}
|
275 |
+
$this->setItems($lineItems);
|
276 |
+
}
|
277 |
+
|
278 |
+
|
279 |
+
return $this;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Create new AccessCode
|
284 |
+
* @param Varien_Object $billing
|
285 |
+
* @param Varien_Object $infoInstance
|
286 |
+
* @param string $method
|
287 |
+
* @param null $request
|
288 |
+
* @return Eway_Rapid31_Model_Response
|
289 |
+
*/
|
290 |
+
public function createAccessCode(Varien_Object $billing, Varien_Object $infoInstance,
|
291 |
+
$method = 'AccessCodes', $request = null)
|
292 |
+
{
|
293 |
+
// Empty Varien_Object's data
|
294 |
+
$tokenCustomerID = $request->get('TokenCustomerID');
|
295 |
+
$this->unsetData();
|
296 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
297 |
+
|
298 |
+
$title = $this->_fixTitle($billing->getPrefix());
|
299 |
+
|
300 |
+
$customerParam->setTokenCustomerID($tokenCustomerID)
|
301 |
+
->setTitle($title)
|
302 |
+
->setFirstName($billing->getFirstname())
|
303 |
+
->setLastName($billing->getLastname())
|
304 |
+
->setCompanyName($billing->getCompany())
|
305 |
+
->setJobDescription($billing->getJobDescription())
|
306 |
+
->setStreet1($billing->getStreet1())
|
307 |
+
->setStreet2($billing->getStreet2())
|
308 |
+
->setCity($billing->getCity())
|
309 |
+
->setState($billing->getRegion())
|
310 |
+
->setPostalCode($billing->getPostcode())
|
311 |
+
->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
|
312 |
+
->setEmail($billing->getEmail())
|
313 |
+
->setPhone($billing->getTelephone())
|
314 |
+
->setMobile($billing->getMobile())
|
315 |
+
->setComments('')
|
316 |
+
->setFax($billing->getFax())
|
317 |
+
->setUrl('');
|
318 |
+
|
319 |
+
$returnUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true)
|
320 |
+
. '/ewayrapid/mycards/saveToken?ccType='
|
321 |
+
. $infoInstance->getCcType() . '&expYear=' . $infoInstance->getCcExpYear();
|
322 |
+
if ($request->get('is_default') == 'on') {
|
323 |
+
$returnUrl .= '&is_default=on';
|
324 |
+
}
|
325 |
+
if ($infoInstance->getCcStartMonth()) {
|
326 |
+
$returnUrl .= '&startMonth=' . $infoInstance->getCcStartMonth();
|
327 |
+
}
|
328 |
+
if ($infoInstance->getCcStartYear()) {
|
329 |
+
$returnUrl .= '&startYear=' . $infoInstance->getCcStartYear();
|
330 |
+
}
|
331 |
+
if ($infoInstance->getCcIssueNumber()) {
|
332 |
+
$returnUrl .= '&issueNumber=' . $infoInstance->getCcIssueNumber();
|
333 |
+
}
|
334 |
+
// Binding address on url param
|
335 |
+
$returnUrl .= '&street1=' . base64_encode($billing->getStreet1())
|
336 |
+
. '&street2=' . base64_encode($billing->getStreet2());
|
337 |
+
$tokenId = $request->get('token_id');
|
338 |
+
if (!empty($tokenId)) { // ID token customer will be defined to update
|
339 |
+
$returnUrl = $returnUrl . '&token_id=' . $tokenId;
|
340 |
+
}
|
341 |
+
|
342 |
+
$this->setCustomer($customerParam);
|
343 |
+
$this->setRedirectUrl($returnUrl);
|
344 |
+
$this->setCancelUrl($returnUrl);
|
345 |
+
$this->setMethod(!empty($tokenCustomerID) ? 'UpdateTokenCustomer' : 'CreateTokenCustomer');
|
346 |
+
$this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
|
347 |
+
$version = Mage::helper('ewayrapid')->getExtensionVersion();
|
348 |
+
$this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
|
349 |
+
$this->setTransactionType("Purchase");
|
350 |
+
$this->setCustomerReadOnly(true);
|
351 |
+
|
352 |
+
// Create new access code
|
353 |
+
$response = $this->_doRapidAPI($method);
|
354 |
+
return $response;
|
355 |
+
}
|
356 |
+
|
357 |
+
/*
|
358 |
+
* Get customer information by access code
|
359 |
+
*/
|
360 |
+
public function getInfoByAccessCode($accessCode)
|
361 |
+
{
|
362 |
+
$response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
|
363 |
+
return $response;
|
364 |
+
}
|
365 |
+
|
366 |
+
public function saveInfoByTokenId($cardData)
|
367 |
+
{
|
368 |
+
// Empty Varien_Object's data
|
369 |
+
$this->unsetData();
|
370 |
+
|
371 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
372 |
+
$customerParam->setTokenCustomerID($cardData['token']);
|
373 |
+
$payment = Mage::getModel('ewayrapid/field_payment');
|
374 |
+
$payment->setTotalAmount(1);
|
375 |
+
$returnUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . '/ewayrapid/mycards';
|
376 |
+
|
377 |
+
$this->setCustomer($customerParam);
|
378 |
+
$this->setPayment($payment);
|
379 |
+
$this->setRedirectUrl($returnUrl);
|
380 |
+
$this->setMethod('');
|
381 |
+
$this->setTransactionType('');
|
382 |
+
$version = Mage::helper('ewayrapid')->getExtensionVersion();
|
383 |
+
$this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
|
384 |
+
$this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
|
385 |
+
|
386 |
+
$response = $this->_doRapidAPI('AccessCodes');
|
387 |
+
|
388 |
+
if ($cardData['token_id']) {
|
389 |
+
// Update card
|
390 |
+
$this->__updateTokenTransparentOrSharedPage($response, $cardData);
|
391 |
+
} else
|
392 |
+
// Create new token
|
393 |
+
$this->__createNewTokenTransparentOrSharedPage($response, $cardData);
|
394 |
+
return $this;
|
395 |
+
|
396 |
+
}
|
397 |
+
|
398 |
+
protected function __createNewTokenTransparentOrSharedPage($response, $cardData)
|
399 |
+
{
|
400 |
+
if ($response->isSuccess()) {
|
401 |
+
$data = $response->getData();
|
402 |
+
$customer = $data['Customer'];
|
403 |
+
$address = array(
|
404 |
+
//'TokenCustomerID' => $customer['TokenCustomerID'],
|
405 |
+
'Reference' => $customer['Reference'],
|
406 |
+
'Title' => $customer['Title'],
|
407 |
+
'FirstName' => $customer['FirstName'],
|
408 |
+
'LastName' => $customer['LastName'],
|
409 |
+
'CompanyName' => $customer['CompanyName'],
|
410 |
+
'JobDescription' => $customer['JobDescription'],
|
411 |
+
'Street1' => isset($cardData['street1'])? $cardData['street1'] : $customer['Street1'],
|
412 |
+
'Street2' => isset($cardData['street2']) ? $cardData['street2'] : $customer['Street2'],
|
413 |
+
'City' => $customer['City'],
|
414 |
+
'State' => $customer['State'],
|
415 |
+
'PostalCode' => $customer['PostalCode'],
|
416 |
+
'Country' => $customer['Country'],
|
417 |
+
'Email' => $customer['Email'],
|
418 |
+
'Phone' => $customer['Phone'],
|
419 |
+
'Mobile' => $customer['Mobile'],
|
420 |
+
'Comments' => $customer['Comments'],
|
421 |
+
'Fax' => $customer['Fax'],
|
422 |
+
'Url' => $customer['Url']
|
423 |
+
);
|
424 |
+
$tokenInfo = array(
|
425 |
+
'Token' => $response->getTokenCustomerID(),
|
426 |
+
'Card' => substr_replace($customer['CardNumber'], '******', 6, 6),
|
427 |
+
'Owner' => $customer['CardName'],
|
428 |
+
'StartMonth' => $cardData['startMonth'],
|
429 |
+
'StartYear' => $cardData['startYear'],
|
430 |
+
'IssueNumber' => $cardData['issueNumber'],
|
431 |
+
'ExpMonth' => $customer['CardExpiryMonth'],
|
432 |
+
'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
|
433 |
+
(strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
|
434 |
+
'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
|
435 |
+
'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
|
436 |
+
);
|
437 |
+
|
438 |
+
Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
|
439 |
+
return $this;
|
440 |
+
} else {
|
441 |
+
Mage::throwException(
|
442 |
+
Mage::helper('ewayrapid')->__(
|
443 |
+
'An error occurred while creating new token. Please try again. (Error message: %s)',
|
444 |
+
$response->getMessage()
|
445 |
+
)
|
446 |
+
);
|
447 |
+
}
|
448 |
+
}
|
449 |
+
|
450 |
+
protected function __updateTokenTransparentOrSharedPage($res, $cardData)
|
451 |
+
{
|
452 |
+
if ($res->isSuccess()) {
|
453 |
+
$data = $res->getData();
|
454 |
+
$customer = $data['Customer'];
|
455 |
+
$address = array(
|
456 |
+
//'TokenCustomerID' => $customer['TokenCustomerID'],
|
457 |
+
'Reference' => $customer['Reference'],
|
458 |
+
'Title' => $customer['Title'],
|
459 |
+
'FirstName' => $customer['FirstName'],
|
460 |
+
'LastName' => $customer['LastName'],
|
461 |
+
'CompanyName' => $customer['CompanyName'],
|
462 |
+
'JobDescription' => $customer['JobDescription'],
|
463 |
+
'Street1' => isset($cardData['street1'])? $cardData['street1'] : $customer['Street1'],
|
464 |
+
'Street2' => isset($cardData['street2']) ? $cardData['street2'] : $customer['Street2'],
|
465 |
+
'City' => $customer['City'],
|
466 |
+
'State' => $customer['State'],
|
467 |
+
'PostalCode' => $customer['PostalCode'],
|
468 |
+
'Country' => $customer['Country'],
|
469 |
+
'Email' => $customer['Email'],
|
470 |
+
'Phone' => $customer['Phone'],
|
471 |
+
'Mobile' => $customer['Mobile'],
|
472 |
+
'Comments' => $customer['Comments'],
|
473 |
+
'Fax' => $customer['Fax'],
|
474 |
+
'Url' => $customer['Url']
|
475 |
+
);
|
476 |
+
|
477 |
+
$tokenInfo = array(
|
478 |
+
'Token' => $res->getTokenCustomerID(),
|
479 |
+
'Owner' => $customer['CardName'],
|
480 |
+
'StartMonth' => $cardData['startMonth'],
|
481 |
+
'StartYear' => $cardData['startYear'],
|
482 |
+
'IssueNumber' => $cardData['issueNumber'],
|
483 |
+
'ExpMonth' => $customer['CardExpiryMonth'],
|
484 |
+
'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
|
485 |
+
(strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
|
486 |
+
'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
|
487 |
+
'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
|
488 |
+
);
|
489 |
+
//edit card number if connection type = shared page
|
490 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
491 |
+
|| Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
492 |
+
) {
|
493 |
+
$tokenInfo['Card'] = str_replace('X', '*', $customer['CardNumber']);
|
494 |
+
$tokenInfo['Card'] = str_replace('x', '*', $tokenInfo['Card']);
|
495 |
+
}
|
496 |
+
|
497 |
+
Mage::helper('ewayrapid/customer')->updateToken($cardData['token_id'], $tokenInfo);
|
498 |
+
return $this;
|
499 |
+
} else {
|
500 |
+
Mage::throwException(
|
501 |
+
Mage::helper('ewayrapid')->__(
|
502 |
+
'An error occurred while creating new token. Please try again. (Error message: %s)',
|
503 |
+
$res->getMessage()
|
504 |
+
)
|
505 |
+
);
|
506 |
+
}
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* Get card type name by card number
|
511 |
+
* @param $num Card number
|
512 |
+
* @return string Card type name
|
513 |
+
*/
|
514 |
+
public function checkCardType($num)
|
515 |
+
{
|
516 |
+
if (preg_match('/^(4026|417500|4508|4844|4913|4917)/', $num)) {
|
517 |
+
return 'VE';
|
518 |
+
}
|
519 |
+
if (preg_match('/^4/', $num)) {
|
520 |
+
return 'VI';
|
521 |
+
}
|
522 |
+
if (preg_match('/^(34|37)/', $num)) {
|
523 |
+
return 'AE';
|
524 |
+
}
|
525 |
+
if (preg_match('/^(5[1-5])/', $num)) {
|
526 |
+
return 'MC';
|
527 |
+
}
|
528 |
+
if (preg_match('/^(2131|1800)/', $num)) {
|
529 |
+
return 'JCB';
|
530 |
+
}
|
531 |
+
if (preg_match('/^36/', $num)) {
|
532 |
+
return 'DC';
|
533 |
+
}
|
534 |
+
if (preg_match('/^(5018|5020|5038|5893|6304|6759|6761|6762|6763)/', $num)) {
|
535 |
+
return 'ME';
|
536 |
+
}
|
537 |
+
|
538 |
+
return 'Unknown';
|
539 |
+
}
|
540 |
+
/**
|
541 |
+
* Check Card Name
|
542 |
+
* @param $card Card Info
|
543 |
+
* @return string Card name: paypal | masterpass | mastercard
|
544 |
+
*/
|
545 |
+
public function checkCardName($card)
|
546 |
+
{
|
547 |
+
$cardType = strtolower($card->getType());
|
548 |
+
if (preg_match('/^paypal/', $cardType)) {
|
549 |
+
return Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD;
|
550 |
+
}
|
551 |
+
$ccTypes = Mage::getSingleton('ewayrapid/system_config_source_cctype')->getAllowedTypes();
|
552 |
+
if (in_array(strtoupper($cardType), $ccTypes)) {
|
553 |
+
return Eway_Rapid31_Model_Config::CREDITCARD_METHOD;
|
554 |
+
}
|
555 |
+
return Eway_Rapid31_Model_Config::MASTERPASS_METHOD;
|
556 |
+
}
|
557 |
}
|
app/code/community/Eway/Rapid31/Model/Request/Transparent.php
CHANGED
@@ -1,752 +1,780 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Eway_Rapid31_Model_Request_Transparent extends Eway_Rapid31_Model_Request_Abstract
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Get AccessCode
|
7 |
-
*
|
8 |
-
* @param Mage_Sales_Model_Quote $quote
|
9 |
-
* @return Eway_Rapid31_Model_Response
|
10 |
-
*/
|
11 |
-
public function createAccessCode(Mage_Sales_Model_Quote $quote, $method = 'ProcessPayment', $action = 'AccessCodes')
|
12 |
-
{
|
13 |
-
// Empty Varien_Object's data
|
14 |
-
$this->unsetData();
|
15 |
-
|
16 |
-
$billingAddress = $quote->getBillingAddress();
|
17 |
-
|
18 |
-
$title = $this->_fixTitle($billingAddress->getPrefix());
|
19 |
-
|
20 |
-
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
21 |
-
$customerParam->setTitle($title)
|
22 |
-
->setFirstName($billingAddress->getFirstname())
|
23 |
-
->setLastName($billingAddress->getLastname())
|
24 |
-
->setCompanyName($billingAddress->getCompany())
|
25 |
-
->setJobDescription($billingAddress->getJobDescription())
|
26 |
-
->setStreet1($billingAddress->getStreet1())
|
27 |
-
->setStreet2($billingAddress->getStreet2())
|
28 |
-
->setCity($billingAddress->getCity())
|
29 |
-
->setState($billingAddress->getRegion())
|
30 |
-
->setPostalCode($billingAddress->getPostcode())
|
31 |
-
->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
|
32 |
-
->setEmail($billingAddress->getEmail())
|
33 |
-
->setPhone($billingAddress->getTelephone())
|
34 |
-
->setMobile($billingAddress->getMobile())
|
35 |
-
->setComments('')
|
36 |
-
->setFax($billingAddress->getFax())
|
37 |
-
->setUrl('');
|
38 |
-
|
39 |
-
if ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
40 |
-
|| ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD
|
41 |
-
&& Mage::getSingleton('core/session')->getSavedToken())
|
42 |
-
) {
|
43 |
-
$customerTokenId = Mage::getSingleton('core/session')->getSavedToken();
|
44 |
-
if (!$customerTokenId) {
|
45 |
-
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
|
46 |
-
} elseif (is_numeric($customerTokenId)) {
|
47 |
-
$customerHelper = Mage::helper('ewayrapid/customer');
|
48 |
-
$customerTokenId = $customerHelper->getCustomerTokenId($customerTokenId);
|
49 |
-
if ($customerTokenId) {
|
50 |
-
$customerParam->setTokenCustomerID($customerTokenId);
|
51 |
-
} else {
|
52 |
-
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
|
53 |
-
}
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
$this->setCustomer($customerParam);
|
58 |
-
|
59 |
-
$shippingAddress = $quote->getShippingAddress();
|
60 |
-
|
61 |
-
// copy BillingAddress to ShippingAddress if checkout with guest or register
|
62 |
-
/**
|
63 |
-
$checkoutMethod = $quote->getCheckoutMethod();
|
64 |
-
if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
|
65 |
-
|| $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
|
66 |
-
) {
|
67 |
-
$shippingAddress = $billingAddress;
|
68 |
-
}
|
69 |
-
*/
|
70 |
-
|
71 |
-
if (!empty($shippingAddress)) {
|
72 |
-
$shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
|
73 |
-
$shippingParam->setFirstName($shippingAddress->getFirstname())
|
74 |
-
->setLastName($shippingAddress->getLastname())
|
75 |
-
->setStreet1($shippingAddress->getStreet1())
|
76 |
-
->setStreet2($shippingAddress->getStreet2())
|
77 |
-
->setCity($shippingAddress->getCity())
|
78 |
-
->setState($shippingAddress->getRegion())
|
79 |
-
->setPostalCode($shippingAddress->getPostcode())
|
80 |
-
->setCountry(strtolower($shippingAddress->getCountryModel()->getIso2Code()))
|
81 |
-
->setEmail($shippingAddress->getEmail())
|
82 |
-
->setPhone($shippingAddress->getTelephone())
|
83 |
-
->setFax($shippingAddress->getFax());
|
84 |
-
$this->setShippingAddress($shippingParam);
|
85 |
-
}
|
86 |
-
|
87 |
-
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
88 |
-
$paymentParam->setTotalAmount(round($quote->getBaseGrandTotal() * 100));
|
89 |
-
if ($method == 'CreateTokenCustomer' || $method == 'UpdateTokenCustomer') {
|
90 |
-
$paymentParam->setTotalAmount(0);
|
91 |
-
}
|
92 |
-
|
93 |
-
// add InvoiceDescription and InvoiceReference
|
94 |
-
$config = Mage::getModel('ewayrapid/config');
|
95 |
-
|
96 |
-
if($config->shouldPassingInvoiceDescription()){
|
97 |
-
$invoiceDescription = '';
|
98 |
-
foreach($quote->getAllVisibleItems() as $item){
|
99 |
-
// Check in case multi-shipping
|
100 |
-
if (!$item->getQuoteParentItemId()) {
|
101 |
-
$invoiceDescription .= (int) $item->getQty() . ' x ' .$item->getName() . ', ';
|
102 |
-
}
|
103 |
-
}
|
104 |
-
$invoiceDescription = trim($invoiceDescription,', ');
|
105 |
-
$invoiceDescription = Mage::helper('ewayrapid')->limitInvoiceDescriptionLength($invoiceDescription);
|
106 |
-
|
107 |
-
$paymentParam->setInvoiceDescription($invoiceDescription);
|
108 |
-
}
|
109 |
-
|
110 |
-
if($config->shouldPassingGuessOrder()){
|
111 |
-
$incrementId = $this->_getIncrementOrderId($quote);
|
112 |
-
$paymentParam->setInvoiceReference($incrementId);
|
113 |
-
}
|
114 |
-
|
115 |
-
$paymentParam->setCurrencyCode($quote->getBaseCurrencyCode());
|
116 |
-
$this->setPayment($paymentParam);
|
117 |
-
|
118 |
-
$returnUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/callBack';
|
119 |
-
$cancelUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/cancel';
|
120 |
-
|
121 |
-
$this->setRedirectUrl($returnUrl);
|
122 |
-
|
123 |
-
//CheckOutUrl if using PayPal
|
124 |
-
$checkOutUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/review';
|
125 |
-
|
126 |
-
if (Mage::helper('ewayrapid/data')->getTransferCartLineItems()) {
|
127 |
-
// add Shipping item and Line items
|
128 |
-
$lineItems = Mage::helper('ewayrapid')->getLineItems();
|
129 |
-
$this->setItems($lineItems);
|
130 |
-
}
|
131 |
-
|
132 |
-
/*if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
133 |
-
$this->setItems(false);
|
134 |
-
}*/
|
135 |
-
|
136 |
-
if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
|
137 |
-
$this->setCheckoutPayment(true);
|
138 |
-
$this->setCheckoutURL($checkOutUrl);
|
139 |
-
$this->setItems(false);
|
140 |
-
}
|
141 |
-
|
142 |
-
$this->setCancelUrl($cancelUrl);
|
143 |
-
$this->setMethod($method);
|
144 |
-
$this->setShippingMethod('Other');
|
145 |
-
$
|
146 |
-
$
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
|
152 |
-
}
|
153 |
-
$this->setCustomerReadOnly(true);
|
154 |
-
|
155 |
-
$response = $this->_doRapidAPI($action);
|
156 |
-
if ($response->isSuccess()) {
|
157 |
-
return $response;
|
158 |
-
} else {
|
159 |
-
Mage::throwException(
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
return
|
178 |
-
}
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
->
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
->
|
239 |
-
->
|
240 |
-
->
|
241 |
-
->
|
242 |
-
->setPostcode($
|
243 |
-
->setCountryId(strtoupper($
|
244 |
-
->setEmail($
|
245 |
-
->
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
$
|
315 |
-
$
|
316 |
-
$
|
317 |
-
$
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
$
|
322 |
-
$
|
323 |
-
|
324 |
-
$
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
$tokenInfo['
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
'
|
340 |
-
'
|
341 |
-
|
342 |
-
'
|
343 |
-
|
344 |
-
'
|
345 |
-
'
|
346 |
-
'
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
$
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
'
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
$
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
$this->
|
549 |
-
|
550 |
-
$
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
//
|
576 |
-
$
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
$
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
$
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
$this->
|
598 |
-
|
599 |
-
$
|
600 |
-
|
601 |
-
$
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
->
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
$
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
$
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
$
|
661 |
-
|
662 |
-
$
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
$
|
684 |
-
|
685 |
-
$
|
686 |
-
|
687 |
-
|
688 |
-
$
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
}
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Eway_Rapid31_Model_Request_Transparent extends Eway_Rapid31_Model_Request_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Get AccessCode
|
7 |
+
*
|
8 |
+
* @param Mage_Sales_Model_Quote $quote
|
9 |
+
* @return Eway_Rapid31_Model_Response
|
10 |
+
*/
|
11 |
+
public function createAccessCode(Mage_Sales_Model_Quote $quote, $method = 'ProcessPayment', $action = 'AccessCodes')
|
12 |
+
{
|
13 |
+
// Empty Varien_Object's data
|
14 |
+
$this->unsetData();
|
15 |
+
|
16 |
+
$billingAddress = $quote->getBillingAddress();
|
17 |
+
|
18 |
+
$title = $this->_fixTitle($billingAddress->getPrefix());
|
19 |
+
|
20 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
21 |
+
$customerParam->setTitle($title)
|
22 |
+
->setFirstName($billingAddress->getFirstname())
|
23 |
+
->setLastName($billingAddress->getLastname())
|
24 |
+
->setCompanyName($billingAddress->getCompany())
|
25 |
+
->setJobDescription($billingAddress->getJobDescription())
|
26 |
+
->setStreet1($billingAddress->getStreet1())
|
27 |
+
->setStreet2($billingAddress->getStreet2())
|
28 |
+
->setCity($billingAddress->getCity())
|
29 |
+
->setState($billingAddress->getRegion())
|
30 |
+
->setPostalCode($billingAddress->getPostcode())
|
31 |
+
->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
|
32 |
+
->setEmail($billingAddress->getEmail())
|
33 |
+
->setPhone($billingAddress->getTelephone())
|
34 |
+
->setMobile($billingAddress->getMobile())
|
35 |
+
->setComments('')
|
36 |
+
->setFax($billingAddress->getFax())
|
37 |
+
->setUrl('');
|
38 |
+
|
39 |
+
if ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
40 |
+
|| ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD
|
41 |
+
&& Mage::getSingleton('core/session')->getSavedToken())
|
42 |
+
) {
|
43 |
+
$customerTokenId = Mage::getSingleton('core/session')->getSavedToken();
|
44 |
+
if (!$customerTokenId) {
|
45 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
|
46 |
+
} elseif (is_numeric($customerTokenId)) {
|
47 |
+
$customerHelper = Mage::helper('ewayrapid/customer');
|
48 |
+
$customerTokenId = $customerHelper->getCustomerTokenId($customerTokenId);
|
49 |
+
if ($customerTokenId) {
|
50 |
+
$customerParam->setTokenCustomerID($customerTokenId);
|
51 |
+
} else {
|
52 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->setCustomer($customerParam);
|
58 |
+
|
59 |
+
$shippingAddress = $quote->getShippingAddress();
|
60 |
+
|
61 |
+
// copy BillingAddress to ShippingAddress if checkout with guest or register
|
62 |
+
/**
|
63 |
+
$checkoutMethod = $quote->getCheckoutMethod();
|
64 |
+
if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
|
65 |
+
|| $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
|
66 |
+
) {
|
67 |
+
$shippingAddress = $billingAddress;
|
68 |
+
}
|
69 |
+
*/
|
70 |
+
|
71 |
+
if (!empty($shippingAddress)) {
|
72 |
+
$shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
|
73 |
+
$shippingParam->setFirstName($shippingAddress->getFirstname())
|
74 |
+
->setLastName($shippingAddress->getLastname())
|
75 |
+
->setStreet1($shippingAddress->getStreet1())
|
76 |
+
->setStreet2($shippingAddress->getStreet2())
|
77 |
+
->setCity($shippingAddress->getCity())
|
78 |
+
->setState($shippingAddress->getRegion())
|
79 |
+
->setPostalCode($shippingAddress->getPostcode())
|
80 |
+
->setCountry(strtolower($shippingAddress->getCountryModel()->getIso2Code()))
|
81 |
+
->setEmail($shippingAddress->getEmail())
|
82 |
+
->setPhone($shippingAddress->getTelephone())
|
83 |
+
->setFax($shippingAddress->getFax());
|
84 |
+
$this->setShippingAddress($shippingParam);
|
85 |
+
}
|
86 |
+
|
87 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
88 |
+
$paymentParam->setTotalAmount(round($quote->getBaseGrandTotal() * 100));
|
89 |
+
if ($method == 'CreateTokenCustomer' || $method == 'UpdateTokenCustomer') {
|
90 |
+
$paymentParam->setTotalAmount(0);
|
91 |
+
}
|
92 |
+
|
93 |
+
// add InvoiceDescription and InvoiceReference
|
94 |
+
$config = Mage::getModel('ewayrapid/config');
|
95 |
+
|
96 |
+
if ($config->shouldPassingInvoiceDescription()) {
|
97 |
+
$invoiceDescription = '';
|
98 |
+
foreach ($quote->getAllVisibleItems() as $item) {
|
99 |
+
// Check in case multi-shipping
|
100 |
+
if (!$item->getQuoteParentItemId()) {
|
101 |
+
$invoiceDescription .= (int) $item->getQty() . ' x ' .$item->getName() . ', ';
|
102 |
+
}
|
103 |
+
}
|
104 |
+
$invoiceDescription = trim($invoiceDescription, ', ');
|
105 |
+
$invoiceDescription = Mage::helper('ewayrapid')->limitInvoiceDescriptionLength($invoiceDescription);
|
106 |
+
|
107 |
+
$paymentParam->setInvoiceDescription($invoiceDescription);
|
108 |
+
}
|
109 |
+
|
110 |
+
if ($config->shouldPassingGuessOrder()) {
|
111 |
+
$incrementId = $this->_getIncrementOrderId($quote);
|
112 |
+
$paymentParam->setInvoiceReference($incrementId);
|
113 |
+
}
|
114 |
+
|
115 |
+
$paymentParam->setCurrencyCode($quote->getBaseCurrencyCode());
|
116 |
+
$this->setPayment($paymentParam);
|
117 |
+
|
118 |
+
$returnUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . '/ewayrapid/transparent/callBack';
|
119 |
+
$cancelUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . '/ewayrapid/transparent/cancel';
|
120 |
+
|
121 |
+
$this->setRedirectUrl($returnUrl);
|
122 |
+
|
123 |
+
//CheckOutUrl if using PayPal
|
124 |
+
$checkOutUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . '/ewayrapid/transparent/review';
|
125 |
+
|
126 |
+
if (Mage::helper('ewayrapid/data')->getTransferCartLineItems()) {
|
127 |
+
// add Shipping item and Line items
|
128 |
+
$lineItems = Mage::helper('ewayrapid')->getLineItems();
|
129 |
+
$this->setItems($lineItems);
|
130 |
+
}
|
131 |
+
|
132 |
+
/*if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
133 |
+
$this->setItems(false);
|
134 |
+
}*/
|
135 |
+
|
136 |
+
if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
|
137 |
+
$this->setCheckoutPayment(true);
|
138 |
+
$this->setCheckoutURL($checkOutUrl);
|
139 |
+
$this->setItems(false);
|
140 |
+
}
|
141 |
+
|
142 |
+
$this->setCancelUrl($cancelUrl);
|
143 |
+
$this->setMethod($method);
|
144 |
+
$this->setShippingMethod('Other');
|
145 |
+
$version = Mage::helper('ewayrapid')->getExtensionVersion();
|
146 |
+
$this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
|
147 |
+
if (Mage::helper('ewayrapid')->isBackendOrder()) {
|
148 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
|
149 |
+
} else {
|
150 |
+
$this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
|
151 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
|
152 |
+
}
|
153 |
+
$this->setCustomerReadOnly(true);
|
154 |
+
|
155 |
+
$response = $this->_doRapidAPI($action);
|
156 |
+
if ($response->isSuccess()) {
|
157 |
+
return $response;
|
158 |
+
} else {
|
159 |
+
Mage::throwException(
|
160 |
+
Mage::helper('ewayrapid')->__(
|
161 |
+
'An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
|
162 |
+
$response->getMessage()
|
163 |
+
)
|
164 |
+
);
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Get customer information by access code
|
170 |
+
* @param $accessCode
|
171 |
+
* @throws Mage_Core_Exception
|
172 |
+
*/
|
173 |
+
public function getInfoByAccessCode($accessCode)
|
174 |
+
{
|
175 |
+
$response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
|
176 |
+
if ($response->isSuccess()) {
|
177 |
+
return $response;
|
178 |
+
} else {
|
179 |
+
Mage::throwException(
|
180 |
+
Mage::helper('ewayrapid')->__(
|
181 |
+
'An error occurred while making the transaction. Please try again. (Error message: %s)',
|
182 |
+
$response->getMessage()
|
183 |
+
)
|
184 |
+
);
|
185 |
+
return false;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
public function getTransaction($accessCode)
|
190 |
+
{
|
191 |
+
try {
|
192 |
+
$results = $this->_doRapidAPI("Transaction/$accessCode", 'GET');
|
193 |
+
if ($results->isSuccess()) {
|
194 |
+
return $results->getTransactions();
|
195 |
+
}
|
196 |
+
} catch (Exception $e) {
|
197 |
+
Mage::throwException(
|
198 |
+
Mage::helper('ewayrapid')->__(
|
199 |
+
'An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
|
200 |
+
$results->getMessage()
|
201 |
+
)
|
202 |
+
);
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Update customer info
|
209 |
+
* @param $transId
|
210 |
+
* @return mixed
|
211 |
+
*/
|
212 |
+
public function updateCustomer($accessCode, Mage_Sales_Model_Quote $quote)
|
213 |
+
{
|
214 |
+
try {
|
215 |
+
$results = $this->_doRapidAPI("Transaction/$accessCode", 'GET');
|
216 |
+
if (!$results->isSuccess()) {
|
217 |
+
Mage::throwException(
|
218 |
+
Mage::helper('ewayrapid')->__(
|
219 |
+
'An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
|
220 |
+
$results->getMessage()
|
221 |
+
)
|
222 |
+
);
|
223 |
+
}
|
224 |
+
|
225 |
+
$customer = $quote->getCustomer();
|
226 |
+
$billingAddress = $quote->getBillingAddress();
|
227 |
+
$shippingAddress = $quote->getShippingAddress();
|
228 |
+
|
229 |
+
if ($results->isSuccess()) {
|
230 |
+
$trans = $results->getTransactions();
|
231 |
+
|
232 |
+
if (isset($trans[0]['Customer'])) {
|
233 |
+
$billing = $trans[0]['Customer'];
|
234 |
+
$billingAddress->setFirstname($billing['FirstName'])
|
235 |
+
->setLastName($billing['LastName'])
|
236 |
+
->setCompany($billing['CompanyName'])
|
237 |
+
->setJobDescription($billing['JobDescription'])
|
238 |
+
->setStreet($billing['Street1'])
|
239 |
+
->setStreet2($billing['Street2'])
|
240 |
+
->setCity($billing['City'])
|
241 |
+
->setState($billing['State'])
|
242 |
+
->setPostcode($billing['PostalCode'])
|
243 |
+
->setCountryId(strtoupper($billing['Country']))
|
244 |
+
->setEmail($billing['Email'])
|
245 |
+
->setTelephone($billing['Phone'])
|
246 |
+
->setMobile($billing['Mobile'])
|
247 |
+
->setComments($billing['Comments'])
|
248 |
+
->setFax($billing['Fax'])
|
249 |
+
->setUrl($billing['Url']);
|
250 |
+
}
|
251 |
+
if (isset($trans[0]['ShippingAddress'])) {
|
252 |
+
$shipping = $trans[0]['ShippingAddress'];
|
253 |
+
$shippingAddress->setFirstname($shipping['FirstName'])
|
254 |
+
->setLastname($shipping['LastName'])
|
255 |
+
->setStreet($shipping['Street1'])
|
256 |
+
->setStreet2($shipping['Street2'])
|
257 |
+
->setCity($shipping['City'])
|
258 |
+
->setPostcode($shipping['PostalCode'])
|
259 |
+
->setCountryId(strtoupper($shipping['Country']))
|
260 |
+
->setEmail($shipping['Email'])
|
261 |
+
->setFax($shipping['Fax']);
|
262 |
+
|
263 |
+
if ($shipping['State']
|
264 |
+
&& $shipping['Country']
|
265 |
+
&& $region = Mage::getModel('directory/region')->loadByCode($shipping['State'], $shipping['Country'])
|
266 |
+
) {
|
267 |
+
$shippingAddress->setRegion($region->getName())
|
268 |
+
->setRegionId($region->getId());
|
269 |
+
}
|
270 |
+
if ($shipping['Phone']) {
|
271 |
+
$shippingAddress->setTelephone($shipping['Phone']);
|
272 |
+
}
|
273 |
+
}
|
274 |
+
return $quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress)->save();
|
275 |
+
}
|
276 |
+
return false;
|
277 |
+
} catch (Exception $e) {
|
278 |
+
Mage::throwException($e->getMessage());
|
279 |
+
return false;
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* @param Mage_Sales_Model_Quote $quote
|
285 |
+
* @param $tokenInfo
|
286 |
+
* @param $tokenCustomerID
|
287 |
+
* @return bool
|
288 |
+
*/
|
289 |
+
public function addToken(Mage_Sales_Model_Quote $quote, $tokenInfo, $tokenCustomerID = 0)
|
290 |
+
{
|
291 |
+
try {
|
292 |
+
if (!$tokenCustomerID)
|
293 |
+
return false;
|
294 |
+
|
295 |
+
//Get Customer Card Info
|
296 |
+
$customerCard = $this->getCustomerCard($tokenCustomerID);
|
297 |
+
$cardetail = null;
|
298 |
+
if ($customerCard) {
|
299 |
+
$customer = $customerCard->getCustomer();
|
300 |
+
$cardetail = $customer && isset($customer['CardDetails']) ? $customer['CardDetails'] : null;
|
301 |
+
unset($customer);
|
302 |
+
}
|
303 |
+
|
304 |
+
$billingAddress = $quote->getBillingAddress();
|
305 |
+
|
306 |
+
$title = $this->_fixTitle($billingAddress->getPrefix());
|
307 |
+
|
308 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
309 |
+
$customerParam->setTitle($title)
|
310 |
+
->setFirstName($billingAddress->getFirstname())
|
311 |
+
->setLastName($billingAddress->getLastname())
|
312 |
+
->setCompanyName($billingAddress->getCompany())
|
313 |
+
->setJobDescription($billingAddress->getJobDescription())
|
314 |
+
->setStreet1($billingAddress->getStreet1())
|
315 |
+
->setStreet2($billingAddress->getStreet2())
|
316 |
+
->setCity($billingAddress->getCity())
|
317 |
+
->setState($billingAddress->getRegion())
|
318 |
+
->setPostalCode($billingAddress->getPostcode())
|
319 |
+
->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
|
320 |
+
->setEmail($billingAddress->getEmail())
|
321 |
+
->setPhone($billingAddress->getTelephone())
|
322 |
+
->setMobile($billingAddress->getMobile())
|
323 |
+
->setComments('')
|
324 |
+
->setFax($billingAddress->getFax())
|
325 |
+
->setUrl('');
|
326 |
+
$config = Mage::getSingleton('ewayrapid/config');
|
327 |
+
$cardNumber = null;
|
328 |
+
|
329 |
+
if ($tokenInfo['SavedType'] == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
330 |
+
$tokenInfo['ccType'] = "PayPal";
|
331 |
+
$cardNumber = "PayPal";
|
332 |
+
$tokenInfo['EWAY_CARDNAME'] = "PayPal";
|
333 |
+
$tokenInfo['EWAY_CARDEXPIRYMONTH'] = $tokenInfo['EWAY_CARDEXPIRYYEAR'] = '';
|
334 |
+
} elseif ($tokenInfo['SavedType'] == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
|
335 |
+
//$tokenInfo['ccType'] = "MC";
|
336 |
+
$cardNumber = $cardetail && isset($cardetail['Number']) ? substr_replace($cardetail['Number'], '******', 6, 6) : "MasterPass";
|
337 |
+
$cardNumber = substr_replace($cardNumber, '******', 6, 6);
|
338 |
+
$tokenInfo['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "MasterPass";
|
339 |
+
$tokenInfo['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : "";
|
340 |
+
$tokenInfo['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : "";
|
341 |
+
} else {
|
342 |
+
$cardNumber = $cardetail && isset($cardetail['Number']) ? $cardetail['Number'] : @Mage::helper('ewayrapid/data')->decryptSha256($tokenInfo['EWAY_CARDNUMBER'], $config->getBasicAuthenticationHeader());
|
343 |
+
$cardNumber = substr_replace($cardNumber, '******', 6, 6);
|
344 |
+
$tokenInfo['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "creditcard";
|
345 |
+
$tokenInfo['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : "";
|
346 |
+
$tokenInfo['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : "";
|
347 |
+
}
|
348 |
+
$type = isset($tokenInfo['ccType']) ? $tokenInfo['ccType'] : $this->checkCardType($cardNumber);
|
349 |
+
if ($type == 'Unknown') {
|
350 |
+
$type = $tokenInfo['SavedType'] == Eway_Rapid31_Model_Config::MASTERPASS_METHOD ? 'MasterPass' : 'CreditCard';
|
351 |
+
}
|
352 |
+
|
353 |
+
$tokenInfo['EWAY_CARDEXPIRYYEAR'] = $tokenInfo['EWAY_CARDEXPIRYYEAR'] && strlen($tokenInfo['EWAY_CARDEXPIRYYEAR']) == 2 ? '20' . $tokenInfo['EWAY_CARDEXPIRYYEAR'] : $cardetail['EWAY_CARDEXPIRYYEAR'];
|
354 |
+
$cardInfo = array(
|
355 |
+
'Token' => $tokenCustomerID,
|
356 |
+
'TokenCustomerID' => $tokenCustomerID,
|
357 |
+
'Card' => $cardNumber,
|
358 |
+
'Owner' => $tokenInfo['EWAY_CARDNAME'],
|
359 |
+
'StartMonth' => '',
|
360 |
+
'StartYear' => '',
|
361 |
+
'IssueNumber' => '',
|
362 |
+
'ExpMonth' => (int)$tokenInfo['EWAY_CARDEXPIRYMONTH'],
|
363 |
+
'ExpYear' => (int)$tokenInfo['EWAY_CARDEXPIRYYEAR'],
|
364 |
+
'Type' => $type,
|
365 |
+
'Address' => $customerParam,
|
366 |
+
);
|
367 |
+
|
368 |
+
Mage::helper('ewayrapid/customer')->addToken($cardInfo);
|
369 |
+
return true;
|
370 |
+
} catch (Exception $e) {
|
371 |
+
return false;
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* @param $id
|
377 |
+
* @param $info
|
378 |
+
* @return bool
|
379 |
+
*/
|
380 |
+
public function updateToken($id, $info = null)
|
381 |
+
{
|
382 |
+
try {
|
383 |
+
//Get Customer Card Info
|
384 |
+
$customerCard = $this->getCustomerCard($id);
|
385 |
+
$cardetail = null;
|
386 |
+
if ($customerCard) {
|
387 |
+
$customer = $customerCard->getCustomer();
|
388 |
+
$cardetail = $customer && isset($customer['CardDetails']) ? $customer['CardDetails'] : null;
|
389 |
+
unset($customer);
|
390 |
+
}
|
391 |
+
$cardetail['ExpiryYear'] = $cardetail['ExpiryYear'] && strlen($cardetail['ExpiryYear']) == 2 ? '20' . $cardetail['ExpiryYear'] : $cardetail['ExpiryYear'];
|
392 |
+
|
393 |
+
if ($info['SavedType'] == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
394 |
+
$tokenInfo['EWAY_CARDNAME'] = "PayPal";
|
395 |
+
} elseif ($info['SavedType'] == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
|
396 |
+
$info['ccType'] = "MC";
|
397 |
+
$info['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "MasterPass";
|
398 |
+
$info['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : "";
|
399 |
+
$info['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : "";
|
400 |
+
} else {
|
401 |
+
$info['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "PayPal";
|
402 |
+
$info['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : $info['EWAY_CARDEXPIRYMONTH'];
|
403 |
+
$info['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : $info['EWAY_CARDEXPIRYYEAR'];
|
404 |
+
}
|
405 |
+
|
406 |
+
$cardInfo = array(
|
407 |
+
'Owner' => $info['EWAY_CARDNAME'],
|
408 |
+
'StartMonth' => '',
|
409 |
+
'StartYear' => '',
|
410 |
+
'IssueNumber' => '',
|
411 |
+
'ExpMonth' => $info ? (int)$info['EWAY_CARDEXPIRYMONTH'] : '',
|
412 |
+
'ExpYear' => $info ? (int)$info['EWAY_CARDEXPIRYYEAR'] : '',
|
413 |
+
);
|
414 |
+
|
415 |
+
if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
416 |
+
$uid = Mage::getSingleton('core/session')->getPaypalSavedToken();
|
417 |
+
} elseif ($this->getTransMethod() == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
|
418 |
+
$uid = Mage::getSingleton('core/session')->getMasterpassSavedToken();
|
419 |
+
} else {
|
420 |
+
$uid = Mage::getSingleton('core/session')->getSavedToken();
|
421 |
+
}
|
422 |
+
|
423 |
+
Mage::helper('ewayrapid/customer')->updateToken($uid, $cardInfo);
|
424 |
+
return true;
|
425 |
+
} catch (Exception $e) {
|
426 |
+
return false;
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Get card type name by card number
|
432 |
+
* @param $num Card number
|
433 |
+
* @return string Card type name
|
434 |
+
*/
|
435 |
+
public function checkCardType($num)
|
436 |
+
{
|
437 |
+
return Mage::getModel('ewayrapid/request_token')->checkCardType($num);
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
442 |
+
* @return bool
|
443 |
+
*/
|
444 |
+
public function setTransaction(Mage_Sales_Model_Order_Payment $payment)
|
445 |
+
{
|
446 |
+
$payment->setTransactionId(Mage::getSingleton('core/session')->getTransactionId());
|
447 |
+
$payment->setIsTransactionClosed(0);
|
448 |
+
return $payment;
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Get shipping by code
|
453 |
+
*
|
454 |
+
* @param Mage_Sales_Model_Quote $quote
|
455 |
+
* @param $postalCode
|
456 |
+
* @return bool
|
457 |
+
*/
|
458 |
+
public function getShippingByCode(Mage_Sales_Model_Quote $quote, $postalCode)
|
459 |
+
{
|
460 |
+
$groups = $quote->getShippingAddress()->collectShippingRates()->getGroupedAllShippingRates();
|
461 |
+
// determine current selected code & name
|
462 |
+
foreach ($groups as $code => $rates) {
|
463 |
+
foreach ($rates as $rate) {
|
464 |
+
if (strtoupper($postalCode) == strtoupper($rate->getCode())) {
|
465 |
+
return $rate;
|
466 |
+
}
|
467 |
+
}
|
468 |
+
}
|
469 |
+
return false;
|
470 |
+
}
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Call Transaction API (Authorized & Capture at the same time)
|
474 |
+
*
|
475 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
476 |
+
* @param float $amount
|
477 |
+
* @return Eway_Rapid31_Model_Request_Direct $this
|
478 |
+
*/
|
479 |
+
public function doTransaction(Mage_Sales_Model_Quote $quote, $amount)
|
480 |
+
{
|
481 |
+
$this->_buildRequest($quote, $amount);
|
482 |
+
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
|
483 |
+
$response = $this->_doRapidAPI('Transaction');
|
484 |
+
|
485 |
+
if ($response->isSuccess()) {
|
486 |
+
$quote->setTransactionId($response->getTransactionID());
|
487 |
+
$quote->setCcLast4($response->getCcLast4());
|
488 |
+
$quote->save();
|
489 |
+
return $quote;
|
490 |
+
} else {
|
491 |
+
Mage::throwException(
|
492 |
+
Mage::helper('ewayrapid')->__(
|
493 |
+
'An error occurred while making the transaction. Please try again. (Error message: %s)',
|
494 |
+
$response->getMessage()
|
495 |
+
)
|
496 |
+
);
|
497 |
+
}
|
498 |
+
}
|
499 |
+
|
500 |
+
/**
|
501 |
+
* Call Authorisation API (Authorized only)
|
502 |
+
*
|
503 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
504 |
+
* @param $amount
|
505 |
+
* @return Eway_Rapid31_Model_Request_Direct
|
506 |
+
*/
|
507 |
+
public function doAuthorisation(Mage_Sales_Model_Quote $quote, $amount)
|
508 |
+
{
|
509 |
+
$this->_buildRequest($quote, $amount);
|
510 |
+
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
|
511 |
+
$response = $this->_doRapidAPI('Authorisation');
|
512 |
+
if ($response->isSuccess()) {
|
513 |
+
$quote->setTransactionId($response->getTransactionID());
|
514 |
+
$quote->setIsTransactionClosed(0);
|
515 |
+
$quote->setCcLast4($response->getCcLast4());
|
516 |
+
$beagleScore = $response->getBeagleScore() ? $response->getBeagleScore() : '';
|
517 |
+
$quote->setBeagleScore($beagleScore);
|
518 |
+
$quote->setBeagleVerification($response->getBeagleVerification());
|
519 |
+
$quote->save();
|
520 |
+
return $quote;
|
521 |
+
} else {
|
522 |
+
Mage::throwException(
|
523 |
+
Mage::helper('ewayrapid')->__(
|
524 |
+
'An error occurred while doing the authorisation. Please try again. (Error message: %s)',
|
525 |
+
$response->getMessage()
|
526 |
+
)
|
527 |
+
);
|
528 |
+
}
|
529 |
+
}
|
530 |
+
|
531 |
+
/**
|
532 |
+
* Call Capture API (do the Capture only, must Authorized previously)
|
533 |
+
*
|
534 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
535 |
+
* @param $amount
|
536 |
+
* @return Eway_Rapid31_Model_Request_Direct
|
537 |
+
*/
|
538 |
+
public function doCapturePayment(Mage_Sales_Model_Quote $quote, $amount)
|
539 |
+
{
|
540 |
+
// Empty Varien_Object's data
|
541 |
+
$this->unsetData();
|
542 |
+
|
543 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
544 |
+
$paymentParam->setTotalAmount($amount)
|
545 |
+
->setCurrencyCode($quote->getBaseCurrencyCode());
|
546 |
+
|
547 |
+
$this->setPayment($paymentParam);
|
548 |
+
$this->setTransactionId($quote->getTransactionId());
|
549 |
+
$this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
|
550 |
+
$response = $this->_doRapidAPI('CapturePayment');
|
551 |
+
|
552 |
+
if ($response->isSuccess()) {
|
553 |
+
$quote->setTransactionId($response->getTransactionID());
|
554 |
+
$quote->save();
|
555 |
+
return $quote;
|
556 |
+
} else {
|
557 |
+
Mage::throwException(
|
558 |
+
Mage::helper('ewayrapid')->__(
|
559 |
+
'An error occurred while doing the capture. Please try again. (Error message: %s)',
|
560 |
+
$response->getMessage()
|
561 |
+
)
|
562 |
+
);
|
563 |
+
}
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* Build the request with necessary parameters for doAuthorisation() and doTransaction()
|
568 |
+
*
|
569 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
570 |
+
* @param $amount
|
571 |
+
* @return Eway_Rapid31_Model_Request_Direct
|
572 |
+
*/
|
573 |
+
protected function _buildRequest(Mage_Sales_Model_Quote $quote, $amount)
|
574 |
+
{
|
575 |
+
// Empty Varien_Object's data
|
576 |
+
$this->unsetData();
|
577 |
+
|
578 |
+
$billing = $quote->getBillingAddress();
|
579 |
+
$shipping = $quote->getShippingAddress();
|
580 |
+
|
581 |
+
// copy BillingAddress to ShippingAddress if checkout with guest or register
|
582 |
+
$checkoutMethod = $quote->getCheckoutMethod();
|
583 |
+
if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
|
584 |
+
|| $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
|
585 |
+
) {
|
586 |
+
$shipping = $billing;
|
587 |
+
}
|
588 |
+
|
589 |
+
if (Mage::helper('ewayrapid')->isBackendOrder()) {
|
590 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
|
591 |
+
} else {
|
592 |
+
$this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
|
593 |
+
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
|
594 |
+
}
|
595 |
+
$version = Mage::helper('ewayrapid')->getExtensionVersion();
|
596 |
+
$this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
|
597 |
+
$this->setShippingMethod('Other');
|
598 |
+
|
599 |
+
$paymentParam = Mage::getModel('ewayrapid/field_payment');
|
600 |
+
$paymentParam->setTotalAmount($amount);
|
601 |
+
$paymentParam->setCurrencyCode($quote->getBaseCurrencyCode());
|
602 |
+
|
603 |
+
// add InvoiceDescription and InvoiceReference
|
604 |
+
$config = Mage::getModel('ewayrapid/config');
|
605 |
+
|
606 |
+
if ($config->shouldPassingInvoiceDescription()) {
|
607 |
+
$invoiceDescription = '';
|
608 |
+
foreach ($quote->getAllVisibleItems() as $item) {
|
609 |
+
// Check in case multi-shipping
|
610 |
+
if (!$item->getQuoteParentItemId()) {
|
611 |
+
$invoiceDescription .= (int) $item->getQty() . ' x ' .$item->getName() . ', ';
|
612 |
+
}
|
613 |
+
}
|
614 |
+
$invoiceDescription = trim($invoiceDescription, ', ');
|
615 |
+
$invoiceDescription = Mage::helper('ewayrapid')->limitInvoiceDescriptionLength($invoiceDescription);
|
616 |
+
|
617 |
+
$paymentParam->setInvoiceDescription($invoiceDescription);
|
618 |
+
}
|
619 |
+
|
620 |
+
if ($config->shouldPassingGuessOrder()) {
|
621 |
+
$incrementId = $this->_getIncrementOrderId($quote);
|
622 |
+
$paymentParam->setInvoiceReference($incrementId);
|
623 |
+
}
|
624 |
+
|
625 |
+
$this->setPayment($paymentParam);
|
626 |
+
|
627 |
+
$title = $this->_fixTitle($billing->getPrefix());
|
628 |
+
|
629 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
630 |
+
$customerParam->setTitle($title)
|
631 |
+
->setFirstName($billing->getFirstname())
|
632 |
+
->setLastName($billing->getLastname())
|
633 |
+
->setCompanyName($billing->getCompany())
|
634 |
+
->setJobDescription('')
|
635 |
+
->setStreet1($billing->getStreet1())
|
636 |
+
->setStreet2($billing->getStreet2())
|
637 |
+
->setCity($billing->getCity())
|
638 |
+
->setState($billing->getRegion())
|
639 |
+
->setPostalCode($billing->getPostcode())
|
640 |
+
->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
|
641 |
+
->setEmail($billing->getEmail())
|
642 |
+
->setPhone($billing->getTelephone())
|
643 |
+
->setMobile('')
|
644 |
+
->setComments('')
|
645 |
+
->setFax($billing->getFax())
|
646 |
+
->setUrl('');
|
647 |
+
|
648 |
+
$infoCard = Mage::getSingleton('core/session')->getInfoCard();
|
649 |
+
if ($infoCard && $infoCard->getCard() && $infoCard->getOwner() && !$this->getTokenInfo()) {
|
650 |
+
$cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
|
651 |
+
$cardDetails->setName($infoCard->getOwner())
|
652 |
+
->setNumber($infoCard->getCard())
|
653 |
+
->setExpiryMonth($infoCard->getExpMonth())
|
654 |
+
->setExpiryYear($infoCard->getExpYear())
|
655 |
+
->setCVN($infoCard->getCid());
|
656 |
+
$customerParam->setCardDetails($cardDetails);
|
657 |
+
}
|
658 |
+
|
659 |
+
if ($quote->getTokenCustomerID()) {
|
660 |
+
$customerParam->setTokenCustomerID($quote->getTokenCustomerID());
|
661 |
+
} elseif ($token = $this->getTokenInfo()) {
|
662 |
+
$customerParam->setTokenCustomerID($token->getToken() ? $token->getToken() : $token->getTokenCustomerID());
|
663 |
+
}
|
664 |
+
|
665 |
+
$this->setCustomer($customerParam);
|
666 |
+
|
667 |
+
if (!empty($shipping)) {
|
668 |
+
$shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
|
669 |
+
$shippingParam->setFirstName($shipping->getFirstname())
|
670 |
+
->setLastName($shipping->getLastname())
|
671 |
+
->setStreet1($shipping->getStreet1())
|
672 |
+
->setStreet2($shipping->getStreet2())
|
673 |
+
->setCity($shipping->getCity())
|
674 |
+
->setState($shipping->getRegion())
|
675 |
+
->setPostalCode($shipping->getPostcode())
|
676 |
+
->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))
|
677 |
+
->setEmail($shipping->getEmail())
|
678 |
+
->setPhone($shipping->getTelephone())
|
679 |
+
->setFax($shipping->getFax());
|
680 |
+
$this->setShippingAddress($shippingParam);
|
681 |
+
}
|
682 |
+
|
683 |
+
$orderItems = $quote->getAllVisibleItems();
|
684 |
+
$lineItems = array();
|
685 |
+
foreach ($orderItems as $orderItem) {
|
686 |
+
/* @var Mage_Sales_Model_Order_Item $orderItem */
|
687 |
+
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
|
688 |
+
$lineItem->setSKU($orderItem->getSku());
|
689 |
+
$lineItem->setDescription(substr($orderItem->getName(), 0, 26));
|
690 |
+
$lineItem->setQuantity($orderItem->getQtyOrdered());
|
691 |
+
$lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
|
692 |
+
$lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
|
693 |
+
$lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
|
694 |
+
$lineItems[] = $lineItem;
|
695 |
+
}
|
696 |
+
$this->setItems($lineItems);
|
697 |
+
if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
698 |
+
$this->setItems(false);
|
699 |
+
}
|
700 |
+
|
701 |
+
return $this;
|
702 |
+
}
|
703 |
+
|
704 |
+
/**
|
705 |
+
* @param $tokenCustomerID
|
706 |
+
* @throws Mage_Core_Exception
|
707 |
+
*/
|
708 |
+
public function getCustomerCard($tokenCustomerID)
|
709 |
+
{
|
710 |
+
// Empty Varien_Object's data
|
711 |
+
$this->unsetData();
|
712 |
+
|
713 |
+
$customerParam = Mage::getModel('ewayrapid/field_customer');
|
714 |
+
|
715 |
+
if ($tokenCustomerID) {
|
716 |
+
$customerParam->setTokenCustomerID($tokenCustomerID);
|
717 |
+
} else {
|
718 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
|
719 |
+
}
|
720 |
+
$this->setCustomer($customerParam);
|
721 |
+
|
722 |
+
$response = $this->_doRapidAPI('Customer', 'PUT');
|
723 |
+
if ($response->isSuccess()) {
|
724 |
+
return $response;
|
725 |
+
} else {
|
726 |
+
return false;
|
727 |
+
}
|
728 |
+
}
|
729 |
+
|
730 |
+
public function getMethod()
|
731 |
+
{
|
732 |
+
return Mage::getSingleton('core/session')->getMethod();
|
733 |
+
}
|
734 |
+
|
735 |
+
/**
|
736 |
+
* @return mixed
|
737 |
+
*/
|
738 |
+
public function getTransMethod()
|
739 |
+
{
|
740 |
+
$transMethod = Mage::getSingleton('core/session')->getTransparentNotsaved();
|
741 |
+
if (!$transMethod) {
|
742 |
+
$transMethod = Mage::getSingleton('core/session')->getTransparentSaved();
|
743 |
+
}
|
744 |
+
return $transMethod;
|
745 |
+
}
|
746 |
+
|
747 |
+
/**
|
748 |
+
* @return mixed
|
749 |
+
*/
|
750 |
+
public function getTokenInfo()
|
751 |
+
{
|
752 |
+
if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
753 |
+
$uid = Mage::getSingleton('core/session')->getPaypalSavedToken();
|
754 |
+
} elseif ($this->getTransMethod() == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
|
755 |
+
$uid = Mage::getSingleton('core/session')->getMasterpassSavedToken();
|
756 |
+
} else {
|
757 |
+
$uid = Mage::getSingleton('core/session')->getSavedToken();
|
758 |
+
}
|
759 |
+
if ($uid && $uid != Eway_Rapid31_Model_Config::TOKEN_NEW)
|
760 |
+
return Mage::helper('ewayrapid/customer')->getTokenById($uid);
|
761 |
+
return false;
|
762 |
+
}
|
763 |
+
|
764 |
+
/**
|
765 |
+
*
|
766 |
+
*/
|
767 |
+
public function unsetSessionData()
|
768 |
+
{
|
769 |
+
Mage::getSingleton('core/session')->unsTransparentNotsaved();
|
770 |
+
Mage::getSingleton('core/session')->unsTransparentSaved();
|
771 |
+
Mage::getSingleton('core/session')->unsSavedToken();
|
772 |
+
Mage::getSingleton('core/session')->unsTransactionId();
|
773 |
+
Mage::getSingleton('core/session')->unsFormActionUrl();
|
774 |
+
Mage::getSingleton('core/session')->unsPaypalSavedToken();
|
775 |
+
Mage::getSingleton('core/session')->unsMethod();
|
776 |
+
Mage::getSingleton('core/session')->unsCompleteCheckoutURL();
|
777 |
+
Mage::getSingleton('core/session')->unsMasterPassSavedToken();
|
778 |
+
Mage::getSingleton('core/session')->unsInfoCard();
|
779 |
+
}
|
780 |
}
|
app/code/community/Eway/Rapid31/Model/Resource/Setup.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Eway_Rapid31_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
4 |
-
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Eway_Rapid31_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
4 |
+
{
|
5 |
+
}
|
app/code/community/Eway/Rapid31/Model/Response.php
CHANGED
@@ -1,427 +1,426 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Eway_Rapid31_Model_Response
|
5 |
-
*
|
6 |
-
* @method Eway_Rapid31_Model_Response setMessage(string $value)
|
7 |
-
* @method string getAuthorisationCode()
|
8 |
-
* @method Eway_Rapid31_Model_Response setAuthorisationCode(string $value)
|
9 |
-
* @method string getResponseCode()
|
10 |
-
* @method Eway_Rapid31_Model_Response setResponseCode(string $value)
|
11 |
-
* @method string getResponseMessage()
|
12 |
-
* @method Eway_Rapid31_Model_Response setResponseMessage(string $value)
|
13 |
-
* @method int getTransactionID()
|
14 |
-
* @method Eway_Rapid31_Model_Response setTransactionID(int $value)
|
15 |
-
* @method bool getTransactionStatus()
|
16 |
-
* @method Eway_Rapid31_Model_Response setTransactionStatus(bool $value)
|
17 |
-
* @method long getTokenCustomerID()
|
18 |
-
* @method Eway_Rapid31_Model_Response setTokenCustomerID(long $value)
|
19 |
-
* @method array getVerification()
|
20 |
-
* @method Eway_Rapid31_Model_Response setVerification(array $value)
|
21 |
-
* @method array getErrors()
|
22 |
-
* @method Eway_Rapid31_Model_Response setErrors(array $value)
|
23 |
-
* @method string getCcLast4()
|
24 |
-
*/
|
25 |
-
class Eway_Rapid31_Model_Response extends Varien_Object
|
26 |
-
{
|
27 |
-
|
28 |
-
'F7000' => 'Undefined Fraud',
|
29 |
-
'V5000' => 'Undefined System',
|
30 |
-
'A0000' => 'Undefined Approved',
|
31 |
-
'A2000' => 'Transaction Approved',
|
32 |
-
'A2008' => 'Honour With Identification',
|
33 |
-
'A2010' => 'Approved For Partial Amount',
|
34 |
-
'A2011' => 'Approved VIP',
|
35 |
-
'A2016' => 'Approved Update Track 3',
|
36 |
-
|
37 |
-
'V6000' => 'Undefined Validation',
|
38 |
-
'V6001' => 'Invalid Request CustomerIP',
|
39 |
-
'V6002' => 'Invalid Request DeviceID',
|
40 |
-
'V6011' => 'Invalid Payment Amount',
|
41 |
-
'V6012' => 'Invalid Payment InvoiceDescription',
|
42 |
-
'V6013' => 'Invalid Payment InvoiceNumber',
|
43 |
-
'V6014' => 'Invalid Payment InvoiceReference',
|
44 |
-
'V6015' => 'Invalid Payment CurrencyCode',
|
45 |
-
'V6016' => 'Payment Required',
|
46 |
-
'V6017' => 'Payment CurrencyCode Required',
|
47 |
-
'V6018' => 'Unknown Payment CurrencyCode',
|
48 |
-
'V6021' => 'Cardholder Name Required',
|
49 |
-
'V6022' => 'Card Number Required',
|
50 |
-
'V6023' => 'CVN Required',
|
51 |
-
'V6031' => 'Invalid Card Number',
|
52 |
-
'V6032' => 'Invalid CVN',
|
53 |
-
'V6033' => 'Invalid Expiry Date',
|
54 |
-
'V6034' => 'Invalid Issue Number',
|
55 |
-
'V6035' => 'Invalid Start Date',
|
56 |
-
'V6036' => 'Invalid Month',
|
57 |
-
'V6037' => 'Invalid Year',
|
58 |
-
'V6040' => 'Invalid Token Customer Id',
|
59 |
-
'V6041' => 'Customer Required',
|
60 |
-
'V6042' => 'Customer First Name Required',
|
61 |
-
'V6043' => 'Customer Last Name Required',
|
62 |
-
'V6044' => 'Customer Country Code Required',
|
63 |
-
'V6045' => 'Customer Title Required',
|
64 |
-
'V6046' => 'Token Customer ID Required',
|
65 |
-
'V6047' => 'RedirectURL Required',
|
66 |
-
'V6051' => 'Invalid Customer First Name',
|
67 |
-
'V6052' => 'Invalid Customer Last Name',
|
68 |
-
'V6053' => 'Invalid Customer Country Code',
|
69 |
-
'V6054' => 'Invalid Customer Email',
|
70 |
-
'V6055' => 'Invalid Customer Phone',
|
71 |
-
'V6056' => 'Invalid Customer Mobile',
|
72 |
-
'V6057' => 'Invalid Customer Fax',
|
73 |
-
'V6058' => 'Invalid Customer Title',
|
74 |
-
'V6059' => 'Redirect URL Invalid',
|
75 |
-
'V6060' => 'Redirect URL Invalid',
|
76 |
-
'V6061' => 'Invalid Customer Reference',
|
77 |
-
'V6062' => 'Invalid Customer CompanyName',
|
78 |
-
'V6063' => 'Invalid Customer JobDescription',
|
79 |
-
'V6064' => 'Invalid Customer Street1',
|
80 |
-
'V6065' => 'Invalid Customer Street2',
|
81 |
-
'V6066' => 'Invalid Customer City',
|
82 |
-
'V6067' => 'Invalid Customer State',
|
83 |
-
'V6068' => 'Invalid Customer Postalcode',
|
84 |
-
'V6069' => 'Invalid Customer Email',
|
85 |
-
'V6070' => 'Invalid Customer Phone',
|
86 |
-
'V6071' => 'Invalid Customer Mobile',
|
87 |
-
'V6072' => 'Invalid Customer Comments',
|
88 |
-
'V6073' => 'Invalid Customer Fax',
|
89 |
-
'V6074' => 'Invalid Customer Url',
|
90 |
-
'V6075' => 'Invalid ShippingAddress FirstName',
|
91 |
-
'V6076' => 'Invalid ShippingAddress LastName',
|
92 |
-
'V6077' => 'Invalid ShippingAddress Street1',
|
93 |
-
'V6078' => 'Invalid ShippingAddress Street2',
|
94 |
-
'V6079' => 'Invalid ShippingAddress City',
|
95 |
-
'V6080' => 'Invalid ShippingAddress State',
|
96 |
-
'V6081' => 'Invalid ShippingAddress PostalCode',
|
97 |
-
'V6082' => 'Invalid ShippingAddress Email',
|
98 |
-
'V6083' => 'Invalid ShippingAddress Phone',
|
99 |
-
'V6084' => 'Invalid ShippingAddress Country',
|
100 |
-
'V6091' => 'Unknown Country Code',
|
101 |
-
'V6100' => 'Invalid name',
|
102 |
-
'V6101' => 'Invalid ExpiryMonth',
|
103 |
-
'V6102' => 'Invalid ExpiryYear',
|
104 |
-
'V6103' => 'Invalid StartMonth',
|
105 |
-
'V6104' => 'Invalid StartYear',
|
106 |
-
'V6105' => 'Invalid IssueNumber',
|
107 |
-
'V6106' => 'Invalid CVN',
|
108 |
-
'V6107' => 'Invalid AccessCode',
|
109 |
-
'V6108' => 'Invalid CustomerHostAddress',
|
110 |
-
'V6109' => 'Invalid UserAgent',
|
111 |
-
'V6110' => 'Invalid Number',
|
112 |
-
'V6111' => 'Unauthorised API Access, Account Not PCI Certified',
|
113 |
-
'V6112' => 'Redundant card details other than expiry year and month',
|
114 |
-
'V6113' => 'Invalid transaction for refund',
|
115 |
-
'V6114' => 'Gateway validation error',
|
116 |
-
'V6115' => 'Invalid DirectRefundRequest, Transaction ID ',
|
117 |
-
'V6116' => 'Invalid card data on original TransactionID ',
|
118 |
-
'V6117' => 'Invalid CreateAccessCodeSharedRequest, FooterText',
|
119 |
-
'V6118' => 'Invalid CreateAccessCodeSharedRequest, HeaderText',
|
120 |
-
'V6119' => 'Invalid CreateAccessCodeSharedRequest, Language',
|
121 |
-
'V6120' => 'Invalid CreateAccessCodeSharedRequest, LogoUrl ',
|
122 |
-
'V6121' => 'Invalid TransactionSearch, Filter Match Type',
|
123 |
-
'V6122' => 'Invalid TransactionSearch, Non numeric Transaction ID',
|
124 |
-
'V6123' => 'Invalid TransactionSearch,no TransactionID or AccessCode specified ',
|
125 |
-
'V6124' => 'Invalid Line Items. The line items have been provided however the totals do not match the TotalAmount field',
|
126 |
-
'V6125' => 'Selected Payment Type not enabled',
|
127 |
-
'V6126' => 'Invalid encrypted card number, decryption failed',
|
128 |
-
'V6127' => 'Invalid encrypted cvn, decryption failed',
|
129 |
-
'V6128' => 'Invalid Method for Payment Type',
|
130 |
-
'V6129' => 'Transaction has not been authorised for Capture/Cancellation',
|
131 |
-
'V6130' => 'Generic customer information error',
|
132 |
-
'V6131' => 'Generic shipping information error',
|
133 |
-
'V6132' => 'Transaction has already been completed or voided, operation not permitted',
|
134 |
-
'V6133' => 'Checkout not available for Payment Type',
|
135 |
-
'V6134' => 'Invalid Auth Transaction ID for Capture/Void',
|
136 |
-
'V6135' => 'PayPal Error Processing Refund',
|
137 |
-
'V6140' => 'Merchant account is suspended',
|
138 |
-
'V6141' => 'Invalid PayPal account details or API signature',
|
139 |
-
'V6142' => 'Authorise not available for Bank/Branch',
|
140 |
-
'V6150' => 'Invalid Refund Amount',
|
141 |
-
'V6151' => 'Refund amount greater than original transaction',
|
142 |
-
'V6152' => 'Original transaction already refunded for total amount',
|
143 |
-
'V6153' => 'Card type not support by merchant',
|
144 |
-
'V6160' => 'Encryption Method Not Supported',
|
145 |
-
'V6165' => 'Invalid Visa Checkout data or decryption failed',
|
146 |
-
|
147 |
-
'D4401' => 'Refer to Issuer',
|
148 |
-
'D4402' => 'Refer to Issuer, special',
|
149 |
-
'D4403' => 'No Merchant',
|
150 |
-
'D4404' => 'Pick Up Card',
|
151 |
-
'D4405' => 'Do Not Honour',
|
152 |
-
'D4406' => 'Error',
|
153 |
-
'D4407' => 'Pick Up Card, Special',
|
154 |
-
'D4409' => 'Request In Progress',
|
155 |
-
'D4412' => 'Invalid Transaction',
|
156 |
-
'D4413' => 'Invalid Amount',
|
157 |
-
'D4414' => 'Invalid Card Number',
|
158 |
-
'D4415' => 'No Issuer',
|
159 |
-
'D4419' => 'Re-enter Last Transaction',
|
160 |
-
'D4421' => 'No Method Taken',
|
161 |
-
'D4422' => 'Suspected Malfunction',
|
162 |
-
'D4423' => 'Unacceptable Transaction Fee',
|
163 |
-
'D4425' => 'Unable to Locate Record On File',
|
164 |
-
'D4430' => 'Format Error',
|
165 |
-
'D4431' => 'Bank Not Supported By Switch',
|
166 |
-
'D4433' => 'Expired Card, Capture',
|
167 |
-
'D4434' => 'Suspected Fraud, Retain Card',
|
168 |
-
'D4435' => 'Card Acceptor, Contact Acquirer, Retain Card',
|
169 |
-
'D4436' => 'Restricted Card, Retain Card',
|
170 |
-
'D4437' => 'Contact Acquirer Security Department, Retain Card',
|
171 |
-
'D4438' => 'PIN Tries Exceeded, Capture',
|
172 |
-
'D4439' => 'No Credit Account',
|
173 |
-
'D4440' => 'Function Not Supported',
|
174 |
-
'D4441' => 'Lost Card',
|
175 |
-
'D4442' => 'No Universal Account',
|
176 |
-
'D4443' => 'Stolen Card',
|
177 |
-
'D4444' => 'No Investment Account',
|
178 |
-
'D4451' => 'Insufficient Funds',
|
179 |
-
'D4452' => 'No Cheque Account',
|
180 |
-
'D4453' => 'No Savings Account',
|
181 |
-
'D4454' => 'Expired Card',
|
182 |
-
'D4455' => 'Incorrect PIN',
|
183 |
-
'D4456' => 'No Card Record',
|
184 |
-
'D4457' => 'Function Not Permitted to Cardholder',
|
185 |
-
'D4458' => 'Function Not Permitted to Terminal',
|
186 |
-
'D4460' => 'Acceptor Contact Acquirer',
|
187 |
-
'D4461' => 'Exceeds Withdrawal Limit',
|
188 |
-
'D4462' => 'Restricted Card',
|
189 |
-
'D4463' => 'Security Violation',
|
190 |
-
'D4464' => 'Original Amount Incorrect',
|
191 |
-
'D4466' => 'Acceptor Contact Acquirer, Security',
|
192 |
-
'D4467' => 'Capture Card',
|
193 |
-
'D4475' => 'PIN Tries Exceeded',
|
194 |
-
'D4482' => 'CVV Validation Error',
|
195 |
-
'D4490' => 'Cutoff In Progress',
|
196 |
-
'D4491' => 'Card Issuer Unavailable',
|
197 |
-
'D4492' => 'Unable To Route Transaction',
|
198 |
-
'D4493' => 'Cannot Complete, Violation Of The Law',
|
199 |
-
'D4494' => 'Duplicate Transaction',
|
200 |
-
'D4496' => 'System Error',
|
201 |
-
'D4497' => 'MasterPass Error',
|
202 |
-
'D4498' => 'PayPal Create Transaction Error',
|
203 |
-
'D4499' => 'Invalid Transaction for Auth/Void',
|
204 |
-
|
205 |
-
'S5000' => 'System Error',
|
206 |
-
'S5085' => 'Started 3dSecure',
|
207 |
-
'S5086' => 'Routed 3dSecure',
|
208 |
-
'S5087' => 'Completed 3dSecure',
|
209 |
-
'S5088' => 'PayPal Transaction Created',
|
210 |
-
'S5099' => 'Incomplete (Access Code in progress/incomplete)',
|
211 |
-
'S5010' => 'Unknown error returned by gateway',
|
212 |
-
);
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
'F7000' => 'Undefined Fraud Error',
|
217 |
-
'F7001' => 'Challenged Fraud',
|
218 |
-
'F7002' => 'Country Match Fraud',
|
219 |
-
'F7003' => 'High Risk Country Fraud',
|
220 |
-
'F7004' => 'Anonymous Proxy Fraud',
|
221 |
-
'F7005' => 'Transparent Proxy Fraud',
|
222 |
-
'F7006' => 'Free Email Fraud',
|
223 |
-
'F7007' => 'International Transaction Fraud',
|
224 |
-
'F7008' => 'Risk Score Fraud',
|
225 |
-
'F7009' => 'Denied Fraud',
|
226 |
-
'F9010' => 'High Risk Billing Country',
|
227 |
-
'F9011' => 'High Risk Credit Card Country',
|
228 |
-
'F9012' => 'High Risk Customer IP Address',
|
229 |
-
'F9013' => 'High Risk Email Address',
|
230 |
-
'F9014' => 'High Risk Shipping Country',
|
231 |
-
'F9015' => 'Multiple card numbers for single email address',
|
232 |
-
'F9016' => 'Multiple card numbers for single location',
|
233 |
-
'F9017' => 'Multiple email addresses for single card number',
|
234 |
-
'F9018' => 'Multiple email addresses for single location',
|
235 |
-
'F9019' => 'Multiple locations for single card number',
|
236 |
-
'F9020' => 'Multiple locations for single email address',
|
237 |
-
'F9021' => 'Suspicious Customer First Name',
|
238 |
-
'F9022' => 'Suspicious Customer Last Name',
|
239 |
-
'F9023' => 'Transaction Declined',
|
240 |
-
'F9024' => 'Multiple transactions for same address with known credit card',
|
241 |
-
'F9025' => 'Multiple transactions for same address with new credit card',
|
242 |
-
'F9026' => 'Multiple transactions for same email with new credit card',
|
243 |
-
'F9027' => 'Multiple transactions for same email with known credit card',
|
244 |
-
'F9028' => 'Multiple transactions for new credit card',
|
245 |
-
'F9029' => 'Multiple transactions for known credit card',
|
246 |
-
'F9030' => 'Multiple transactions for same email address',
|
247 |
-
'F9031' => 'Multiple transactions for same credit card',
|
248 |
-
'F9032' => 'Invalid Customer Last Name',
|
249 |
-
'F9033' => 'Invalid Billing Street',
|
250 |
-
'F9034' => 'Invalid Shipping Street',
|
251 |
-
'F9037' => 'Suspicious Customer Email Address',
|
252 |
-
'F9049' => 'Genuine Customer',
|
253 |
-
'F9050' => 'High Risk Email Address and amount',
|
254 |
-
'F9113' => 'Card issuing country differs from IP address country'
|
255 |
-
);
|
256 |
-
|
257 |
-
public function getMessage()
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
*
|
290 |
-
*
|
291 |
-
* @
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
$
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
$codeMessage =
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
$
|
322 |
-
$
|
323 |
-
$
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
&& !isset($json['
|
337 |
-
&& !isset($json['
|
338 |
-
&& !isset($json['
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
*
|
349 |
-
*
|
350 |
-
* @param
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
*
|
362 |
-
*
|
363 |
-
* @
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
*
|
373 |
-
*
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
$
|
379 |
-
$
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
$
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
*
|
397 |
-
*
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
($result['FraudAction'] == "
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
$
|
411 |
-
$
|
412 |
-
$
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
$
|
417 |
-
$
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
}
|
427 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Eway_Rapid31_Model_Response
|
5 |
+
*
|
6 |
+
* @method Eway_Rapid31_Model_Response setMessage(string $value)
|
7 |
+
* @method string getAuthorisationCode()
|
8 |
+
* @method Eway_Rapid31_Model_Response setAuthorisationCode(string $value)
|
9 |
+
* @method string getResponseCode()
|
10 |
+
* @method Eway_Rapid31_Model_Response setResponseCode(string $value)
|
11 |
+
* @method string getResponseMessage()
|
12 |
+
* @method Eway_Rapid31_Model_Response setResponseMessage(string $value)
|
13 |
+
* @method int getTransactionID()
|
14 |
+
* @method Eway_Rapid31_Model_Response setTransactionID(int $value)
|
15 |
+
* @method bool getTransactionStatus()
|
16 |
+
* @method Eway_Rapid31_Model_Response setTransactionStatus(bool $value)
|
17 |
+
* @method long getTokenCustomerID()
|
18 |
+
* @method Eway_Rapid31_Model_Response setTokenCustomerID(long $value)
|
19 |
+
* @method array getVerification()
|
20 |
+
* @method Eway_Rapid31_Model_Response setVerification(array $value)
|
21 |
+
* @method array getErrors()
|
22 |
+
* @method Eway_Rapid31_Model_Response setErrors(array $value)
|
23 |
+
* @method string getCcLast4()
|
24 |
+
*/
|
25 |
+
class Eway_Rapid31_Model_Response extends Varien_Object
|
26 |
+
{
|
27 |
+
protected $_codes = array(
|
28 |
+
'F7000' => 'Undefined Fraud',
|
29 |
+
'V5000' => 'Undefined System',
|
30 |
+
'A0000' => 'Undefined Approved',
|
31 |
+
'A2000' => 'Transaction Approved',
|
32 |
+
'A2008' => 'Honour With Identification',
|
33 |
+
'A2010' => 'Approved For Partial Amount',
|
34 |
+
'A2011' => 'Approved VIP',
|
35 |
+
'A2016' => 'Approved Update Track 3',
|
36 |
+
|
37 |
+
'V6000' => 'Undefined Validation',
|
38 |
+
'V6001' => 'Invalid Request CustomerIP',
|
39 |
+
'V6002' => 'Invalid Request DeviceID',
|
40 |
+
'V6011' => 'Invalid Payment Amount',
|
41 |
+
'V6012' => 'Invalid Payment InvoiceDescription',
|
42 |
+
'V6013' => 'Invalid Payment InvoiceNumber',
|
43 |
+
'V6014' => 'Invalid Payment InvoiceReference',
|
44 |
+
'V6015' => 'Invalid Payment CurrencyCode',
|
45 |
+
'V6016' => 'Payment Required',
|
46 |
+
'V6017' => 'Payment CurrencyCode Required',
|
47 |
+
'V6018' => 'Unknown Payment CurrencyCode',
|
48 |
+
'V6021' => 'Cardholder Name Required',
|
49 |
+
'V6022' => 'Card Number Required',
|
50 |
+
'V6023' => 'CVN Required',
|
51 |
+
'V6031' => 'Invalid Card Number',
|
52 |
+
'V6032' => 'Invalid CVN',
|
53 |
+
'V6033' => 'Invalid Expiry Date',
|
54 |
+
'V6034' => 'Invalid Issue Number',
|
55 |
+
'V6035' => 'Invalid Start Date',
|
56 |
+
'V6036' => 'Invalid Month',
|
57 |
+
'V6037' => 'Invalid Year',
|
58 |
+
'V6040' => 'Invalid Token Customer Id',
|
59 |
+
'V6041' => 'Customer Required',
|
60 |
+
'V6042' => 'Customer First Name Required',
|
61 |
+
'V6043' => 'Customer Last Name Required',
|
62 |
+
'V6044' => 'Customer Country Code Required',
|
63 |
+
'V6045' => 'Customer Title Required',
|
64 |
+
'V6046' => 'Token Customer ID Required',
|
65 |
+
'V6047' => 'RedirectURL Required',
|
66 |
+
'V6051' => 'Invalid Customer First Name',
|
67 |
+
'V6052' => 'Invalid Customer Last Name',
|
68 |
+
'V6053' => 'Invalid Customer Country Code',
|
69 |
+
'V6054' => 'Invalid Customer Email',
|
70 |
+
'V6055' => 'Invalid Customer Phone',
|
71 |
+
'V6056' => 'Invalid Customer Mobile',
|
72 |
+
'V6057' => 'Invalid Customer Fax',
|
73 |
+
'V6058' => 'Invalid Customer Title',
|
74 |
+
'V6059' => 'Redirect URL Invalid',
|
75 |
+
'V6060' => 'Redirect URL Invalid',
|
76 |
+
'V6061' => 'Invalid Customer Reference',
|
77 |
+
'V6062' => 'Invalid Customer CompanyName',
|
78 |
+
'V6063' => 'Invalid Customer JobDescription',
|
79 |
+
'V6064' => 'Invalid Customer Street1',
|
80 |
+
'V6065' => 'Invalid Customer Street2',
|
81 |
+
'V6066' => 'Invalid Customer City',
|
82 |
+
'V6067' => 'Invalid Customer State',
|
83 |
+
'V6068' => 'Invalid Customer Postalcode',
|
84 |
+
'V6069' => 'Invalid Customer Email',
|
85 |
+
'V6070' => 'Invalid Customer Phone',
|
86 |
+
'V6071' => 'Invalid Customer Mobile',
|
87 |
+
'V6072' => 'Invalid Customer Comments',
|
88 |
+
'V6073' => 'Invalid Customer Fax',
|
89 |
+
'V6074' => 'Invalid Customer Url',
|
90 |
+
'V6075' => 'Invalid ShippingAddress FirstName',
|
91 |
+
'V6076' => 'Invalid ShippingAddress LastName',
|
92 |
+
'V6077' => 'Invalid ShippingAddress Street1',
|
93 |
+
'V6078' => 'Invalid ShippingAddress Street2',
|
94 |
+
'V6079' => 'Invalid ShippingAddress City',
|
95 |
+
'V6080' => 'Invalid ShippingAddress State',
|
96 |
+
'V6081' => 'Invalid ShippingAddress PostalCode',
|
97 |
+
'V6082' => 'Invalid ShippingAddress Email',
|
98 |
+
'V6083' => 'Invalid ShippingAddress Phone',
|
99 |
+
'V6084' => 'Invalid ShippingAddress Country',
|
100 |
+
'V6091' => 'Unknown Country Code',
|
101 |
+
'V6100' => 'Invalid name',
|
102 |
+
'V6101' => 'Invalid ExpiryMonth',
|
103 |
+
'V6102' => 'Invalid ExpiryYear',
|
104 |
+
'V6103' => 'Invalid StartMonth',
|
105 |
+
'V6104' => 'Invalid StartYear',
|
106 |
+
'V6105' => 'Invalid IssueNumber',
|
107 |
+
'V6106' => 'Invalid CVN',
|
108 |
+
'V6107' => 'Invalid AccessCode',
|
109 |
+
'V6108' => 'Invalid CustomerHostAddress',
|
110 |
+
'V6109' => 'Invalid UserAgent',
|
111 |
+
'V6110' => 'Invalid Number',
|
112 |
+
'V6111' => 'Unauthorised API Access, Account Not PCI Certified',
|
113 |
+
'V6112' => 'Redundant card details other than expiry year and month',
|
114 |
+
'V6113' => 'Invalid transaction for refund',
|
115 |
+
'V6114' => 'Gateway validation error',
|
116 |
+
'V6115' => 'Invalid DirectRefundRequest, Transaction ID ',
|
117 |
+
'V6116' => 'Invalid card data on original TransactionID ',
|
118 |
+
'V6117' => 'Invalid CreateAccessCodeSharedRequest, FooterText',
|
119 |
+
'V6118' => 'Invalid CreateAccessCodeSharedRequest, HeaderText',
|
120 |
+
'V6119' => 'Invalid CreateAccessCodeSharedRequest, Language',
|
121 |
+
'V6120' => 'Invalid CreateAccessCodeSharedRequest, LogoUrl ',
|
122 |
+
'V6121' => 'Invalid TransactionSearch, Filter Match Type',
|
123 |
+
'V6122' => 'Invalid TransactionSearch, Non numeric Transaction ID',
|
124 |
+
'V6123' => 'Invalid TransactionSearch,no TransactionID or AccessCode specified ',
|
125 |
+
'V6124' => 'Invalid Line Items. The line items have been provided however the totals do not match the TotalAmount field',
|
126 |
+
'V6125' => 'Selected Payment Type not enabled',
|
127 |
+
'V6126' => 'Invalid encrypted card number, decryption failed',
|
128 |
+
'V6127' => 'Invalid encrypted cvn, decryption failed',
|
129 |
+
'V6128' => 'Invalid Method for Payment Type',
|
130 |
+
'V6129' => 'Transaction has not been authorised for Capture/Cancellation',
|
131 |
+
'V6130' => 'Generic customer information error',
|
132 |
+
'V6131' => 'Generic shipping information error',
|
133 |
+
'V6132' => 'Transaction has already been completed or voided, operation not permitted',
|
134 |
+
'V6133' => 'Checkout not available for Payment Type',
|
135 |
+
'V6134' => 'Invalid Auth Transaction ID for Capture/Void',
|
136 |
+
'V6135' => 'PayPal Error Processing Refund',
|
137 |
+
'V6140' => 'Merchant account is suspended',
|
138 |
+
'V6141' => 'Invalid PayPal account details or API signature',
|
139 |
+
'V6142' => 'Authorise not available for Bank/Branch',
|
140 |
+
'V6150' => 'Invalid Refund Amount',
|
141 |
+
'V6151' => 'Refund amount greater than original transaction',
|
142 |
+
'V6152' => 'Original transaction already refunded for total amount',
|
143 |
+
'V6153' => 'Card type not support by merchant',
|
144 |
+
'V6160' => 'Encryption Method Not Supported',
|
145 |
+
'V6165' => 'Invalid Visa Checkout data or decryption failed',
|
146 |
+
|
147 |
+
'D4401' => 'Refer to Issuer',
|
148 |
+
'D4402' => 'Refer to Issuer, special',
|
149 |
+
'D4403' => 'No Merchant',
|
150 |
+
'D4404' => 'Pick Up Card',
|
151 |
+
'D4405' => 'Do Not Honour',
|
152 |
+
'D4406' => 'Error',
|
153 |
+
'D4407' => 'Pick Up Card, Special',
|
154 |
+
'D4409' => 'Request In Progress',
|
155 |
+
'D4412' => 'Invalid Transaction',
|
156 |
+
'D4413' => 'Invalid Amount',
|
157 |
+
'D4414' => 'Invalid Card Number',
|
158 |
+
'D4415' => 'No Issuer',
|
159 |
+
'D4419' => 'Re-enter Last Transaction',
|
160 |
+
'D4421' => 'No Method Taken',
|
161 |
+
'D4422' => 'Suspected Malfunction',
|
162 |
+
'D4423' => 'Unacceptable Transaction Fee',
|
163 |
+
'D4425' => 'Unable to Locate Record On File',
|
164 |
+
'D4430' => 'Format Error',
|
165 |
+
'D4431' => 'Bank Not Supported By Switch',
|
166 |
+
'D4433' => 'Expired Card, Capture',
|
167 |
+
'D4434' => 'Suspected Fraud, Retain Card',
|
168 |
+
'D4435' => 'Card Acceptor, Contact Acquirer, Retain Card',
|
169 |
+
'D4436' => 'Restricted Card, Retain Card',
|
170 |
+
'D4437' => 'Contact Acquirer Security Department, Retain Card',
|
171 |
+
'D4438' => 'PIN Tries Exceeded, Capture',
|
172 |
+
'D4439' => 'No Credit Account',
|
173 |
+
'D4440' => 'Function Not Supported',
|
174 |
+
'D4441' => 'Lost Card',
|
175 |
+
'D4442' => 'No Universal Account',
|
176 |
+
'D4443' => 'Stolen Card',
|
177 |
+
'D4444' => 'No Investment Account',
|
178 |
+
'D4451' => 'Insufficient Funds',
|
179 |
+
'D4452' => 'No Cheque Account',
|
180 |
+
'D4453' => 'No Savings Account',
|
181 |
+
'D4454' => 'Expired Card',
|
182 |
+
'D4455' => 'Incorrect PIN',
|
183 |
+
'D4456' => 'No Card Record',
|
184 |
+
'D4457' => 'Function Not Permitted to Cardholder',
|
185 |
+
'D4458' => 'Function Not Permitted to Terminal',
|
186 |
+
'D4460' => 'Acceptor Contact Acquirer',
|
187 |
+
'D4461' => 'Exceeds Withdrawal Limit',
|
188 |
+
'D4462' => 'Restricted Card',
|
189 |
+
'D4463' => 'Security Violation',
|
190 |
+
'D4464' => 'Original Amount Incorrect',
|
191 |
+
'D4466' => 'Acceptor Contact Acquirer, Security',
|
192 |
+
'D4467' => 'Capture Card',
|
193 |
+
'D4475' => 'PIN Tries Exceeded',
|
194 |
+
'D4482' => 'CVV Validation Error',
|
195 |
+
'D4490' => 'Cutoff In Progress',
|
196 |
+
'D4491' => 'Card Issuer Unavailable',
|
197 |
+
'D4492' => 'Unable To Route Transaction',
|
198 |
+
'D4493' => 'Cannot Complete, Violation Of The Law',
|
199 |
+
'D4494' => 'Duplicate Transaction',
|
200 |
+
'D4496' => 'System Error',
|
201 |
+
'D4497' => 'MasterPass Error',
|
202 |
+
'D4498' => 'PayPal Create Transaction Error',
|
203 |
+
'D4499' => 'Invalid Transaction for Auth/Void',
|
204 |
+
|
205 |
+
'S5000' => 'System Error',
|
206 |
+
'S5085' => 'Started 3dSecure',
|
207 |
+
'S5086' => 'Routed 3dSecure',
|
208 |
+
'S5087' => 'Completed 3dSecure',
|
209 |
+
'S5088' => 'PayPal Transaction Created',
|
210 |
+
'S5099' => 'Incomplete (Access Code in progress/incomplete)',
|
211 |
+
'S5010' => 'Unknown error returned by gateway',
|
212 |
+
);
|
213 |
+
protected $_isSuccess = false;
|
214 |
+
|
215 |
+
protected $_messageCode = array(
|
216 |
+
'F7000' => 'Undefined Fraud Error',
|
217 |
+
'F7001' => 'Challenged Fraud',
|
218 |
+
'F7002' => 'Country Match Fraud',
|
219 |
+
'F7003' => 'High Risk Country Fraud',
|
220 |
+
'F7004' => 'Anonymous Proxy Fraud',
|
221 |
+
'F7005' => 'Transparent Proxy Fraud',
|
222 |
+
'F7006' => 'Free Email Fraud',
|
223 |
+
'F7007' => 'International Transaction Fraud',
|
224 |
+
'F7008' => 'Risk Score Fraud',
|
225 |
+
'F7009' => 'Denied Fraud',
|
226 |
+
'F9010' => 'High Risk Billing Country',
|
227 |
+
'F9011' => 'High Risk Credit Card Country',
|
228 |
+
'F9012' => 'High Risk Customer IP Address',
|
229 |
+
'F9013' => 'High Risk Email Address',
|
230 |
+
'F9014' => 'High Risk Shipping Country',
|
231 |
+
'F9015' => 'Multiple card numbers for single email address',
|
232 |
+
'F9016' => 'Multiple card numbers for single location',
|
233 |
+
'F9017' => 'Multiple email addresses for single card number',
|
234 |
+
'F9018' => 'Multiple email addresses for single location',
|
235 |
+
'F9019' => 'Multiple locations for single card number',
|
236 |
+
'F9020' => 'Multiple locations for single email address',
|
237 |
+
'F9021' => 'Suspicious Customer First Name',
|
238 |
+
'F9022' => 'Suspicious Customer Last Name',
|
239 |
+
'F9023' => 'Transaction Declined',
|
240 |
+
'F9024' => 'Multiple transactions for same address with known credit card',
|
241 |
+
'F9025' => 'Multiple transactions for same address with new credit card',
|
242 |
+
'F9026' => 'Multiple transactions for same email with new credit card',
|
243 |
+
'F9027' => 'Multiple transactions for same email with known credit card',
|
244 |
+
'F9028' => 'Multiple transactions for new credit card',
|
245 |
+
'F9029' => 'Multiple transactions for known credit card',
|
246 |
+
'F9030' => 'Multiple transactions for same email address',
|
247 |
+
'F9031' => 'Multiple transactions for same credit card',
|
248 |
+
'F9032' => 'Invalid Customer Last Name',
|
249 |
+
'F9033' => 'Invalid Billing Street',
|
250 |
+
'F9034' => 'Invalid Shipping Street',
|
251 |
+
'F9037' => 'Suspicious Customer Email Address',
|
252 |
+
'F9049' => 'Genuine Customer',
|
253 |
+
'F9050' => 'High Risk Email Address and amount',
|
254 |
+
'F9113' => 'Card issuing country differs from IP address country'
|
255 |
+
);
|
256 |
+
|
257 |
+
public function getMessage()
|
258 |
+
{
|
259 |
+
if ($this->getData('Message')) {
|
260 |
+
return $this->getData('Message');
|
261 |
+
}
|
262 |
+
|
263 |
+
$messageCode = $this->getResponseMessage();
|
264 |
+
if (empty($messageCode) && ($errors = $this->getErrors())) {
|
265 |
+
$messageCode = $errors[0];
|
266 |
+
}
|
267 |
+
|
268 |
+
if (empty($messageCode)) {
|
269 |
+
return Mage::helper('ewayrapid')->__("Unknown");
|
270 |
+
}
|
271 |
+
|
272 |
+
if (isset($this->_codes[$messageCode])) {
|
273 |
+
return $this->_codes[$messageCode];
|
274 |
+
} else {
|
275 |
+
return Mage::helper('ewayrapid')->__("%s", $this->replaceMessage($messageCode));
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
public function isSuccess($flag = null)
|
280 |
+
{
|
281 |
+
if ($flag !== null) {
|
282 |
+
$this->_isSuccess = $flag;
|
283 |
+
}
|
284 |
+
|
285 |
+
return $this->_isSuccess;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Decode response returned by eWAY API call
|
290 |
+
*
|
291 |
+
* @param $response
|
292 |
+
* @return Eway_Rapid31_Model_Response
|
293 |
+
*/
|
294 |
+
public function decodeJSON($response)
|
295 |
+
{
|
296 |
+
$json = json_decode($response, true);
|
297 |
+
$this->addData($json);
|
298 |
+
if (!empty($json['Customer']) && is_array($json['Customer'])) {
|
299 |
+
$this->_setIfNotEmpty($json['Customer'], 'TokenCustomerID');
|
300 |
+
if (!empty($json['Customer']['CardDetails']) && !empty($json['Customer']['CardDetails']['Number'])) {
|
301 |
+
$this->setData('CcLast4', substr($json['Customer']['CardDetails']['Number'], -4));
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
if (!empty($json['Errors'])) {
|
306 |
+
$this->setErrors(explode(',', $json['Errors']));
|
307 |
+
}
|
308 |
+
|
309 |
+
if (isset($json['TransactionStatus'])) {
|
310 |
+
// Use TransactionStatus if it's presented in response
|
311 |
+
$this->isSuccess((bool)$this->getTransactionStatus());
|
312 |
+
|
313 |
+
// Check response message has fraud code
|
314 |
+
if (isset($json['ResponseMessage']) && $this->isSuccess()) {
|
315 |
+
$codeMessage = str_replace(' ', '', $json['ResponseMessage']);
|
316 |
+
$codeMessage = explode(',', $codeMessage);
|
317 |
+
|
318 |
+
$result = preg_grep("/^F.*/", $codeMessage);
|
319 |
+
if (!empty($result)) {
|
320 |
+
$codes = array_flip($result);
|
321 |
+
$resultMatched = array_intersect_key($this->_messageCode, $codes);
|
322 |
+
$resultDefault = array_fill_keys(array_keys($codes), "Unknown fraud rule");
|
323 |
+
$resultMessages = array_merge($resultDefault, $resultMatched);
|
324 |
+
Mage::getSingleton('core/session')->setData('fraud', 1);
|
325 |
+
$fraudMessage = implode(', ', $resultMessages);
|
326 |
+
Mage::getSingleton('core/session')->setData('fraudMessage', $fraudMessage);
|
327 |
+
}
|
328 |
+
}
|
329 |
+
} else {
|
330 |
+
// Otherwise base on the Errors (Token transactions)
|
331 |
+
$this->isSuccess(!$this->getErrors());
|
332 |
+
|
333 |
+
// Catch empty response
|
334 |
+
if (!isset($json['TransactionStatus'])
|
335 |
+
&& !isset($json['TransactionID'])
|
336 |
+
&& !isset($json['Customer']['TokenCustomerID'])
|
337 |
+
&& !isset($json['AccessCode'])
|
338 |
+
&& !isset($json['Transactions'])) {
|
339 |
+
$this->isSuccess(false);
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
return $this;
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
* Sets a value in the object if present
|
348 |
+
*
|
349 |
+
* @param array $json
|
350 |
+
* @param string $key
|
351 |
+
*/
|
352 |
+
protected function _setIfNotEmpty($json, $key)
|
353 |
+
{
|
354 |
+
if (!empty($json[$key])) {
|
355 |
+
$this->setData($key, $json[$key]);
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Override Varien_Object::_underscore() to prevent transform of field name.
|
361 |
+
*
|
362 |
+
* @param string $name
|
363 |
+
* @return string
|
364 |
+
*/
|
365 |
+
protected function _underscore($name)
|
366 |
+
{
|
367 |
+
return $name;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* replace error code to message
|
372 |
+
*
|
373 |
+
* @param $message
|
374 |
+
*/
|
375 |
+
public function replaceMessage($message)
|
376 |
+
{
|
377 |
+
$results = $message;
|
378 |
+
$found = false;
|
379 |
+
if ($this->_codes) {
|
380 |
+
foreach ($this->_codes as $code => $mess) {
|
381 |
+
if (strpos($message, $code) !== false) {
|
382 |
+
$found = true;
|
383 |
+
$results = str_replace($results, $code, $mess);
|
384 |
+
}
|
385 |
+
}
|
386 |
+
}
|
387 |
+
if ($found) {
|
388 |
+
return $results;
|
389 |
+
} else {
|
390 |
+
return Mage::helper('ewayrapid')->__('Transaction failed.');
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Checks if the transaction was marked as challenged by Beagle anti-fraud
|
396 |
+
*
|
397 |
+
* @param array $result transaction result from eWAY
|
398 |
+
*/
|
399 |
+
protected function _checkfraud($result)
|
400 |
+
{
|
401 |
+
if (isset($result['FraudAction']) && !empty($result['FraudAction'])) {
|
402 |
+
|
403 |
+
// Challenged orders are Review or PreAuth/Allow that processed
|
404 |
+
if (($result['FraudAction'] == "Review") ||
|
405 |
+
($result['FraudAction'] == "PreAuth" && $this->isSuccess()) ||
|
406 |
+
($result['FraudAction'] == "Allow" && $this->isSuccess())) {
|
407 |
+
|
408 |
+
// Find fraud codes
|
409 |
+
$codeMessage = str_replace(' ', '', $result['ResponseMessage']);
|
410 |
+
$codeMessages = explode(',', $codeMessage);
|
411 |
+
$result = preg_grep("/^F.*/", $codeMessages);
|
412 |
+
$codes = array_flip($result);
|
413 |
+
|
414 |
+
// Convert to text and signal fraud
|
415 |
+
$resultMatched = array_intersect_key($this->_messageCode, $codes);
|
416 |
+
$resultDefault = array_fill_keys(array_keys($codes), "Unknown fraud rule");
|
417 |
+
$resultMessages = array_merge($resultDefault, $resultMatched);
|
418 |
+
Mage::getSingleton('core/session')->setData('fraud', 1);
|
419 |
+
$fraudMessage = implode(', ', $resultMessages);
|
420 |
+
Mage::getSingleton('core/session')->setData('fraudMessage', $fraudMessage);
|
421 |
+
|
422 |
+
}
|
423 |
+
|
424 |
+
}
|
425 |
+
}
|
|
|
426 |
}
|
app/code/community/Eway/Rapid31/Model/System/Config/Backend/Orderstatus.php
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_System_Config_Backend_Orderstatus extends Mage_Core_Model_Config_Data
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Set default new order status when changing payment action field
|
6 |
-
*
|
7 |
-
* @return Mage_Core_Model_Abstract|void
|
8 |
-
*/
|
9 |
-
protected function _beforeSave()
|
10 |
-
{
|
11 |
-
$paymentAction = $this->getFieldsetDataValue('payment_action');
|
12 |
-
// Check if payment action is changed
|
13 |
-
if($paymentAction != Mage::getStoreConfig('payment/ewayrapid_general/payment_action')) {
|
14 |
-
$defaultStatus = ( $paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE ?
|
15 |
-
Eway_Rapid31_Model_Config::ORDER_STATUS_CAPTURED :
|
16 |
-
Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED
|
17 |
-
);
|
18 |
-
|
19 |
-
$this->setValue($defaultStatus);
|
20 |
-
};
|
21 |
-
}
|
22 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_System_Config_Backend_Orderstatus extends Mage_Core_Model_Config_Data
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Set default new order status when changing payment action field
|
6 |
+
*
|
7 |
+
* @return Mage_Core_Model_Abstract|void
|
8 |
+
*/
|
9 |
+
protected function _beforeSave()
|
10 |
+
{
|
11 |
+
$paymentAction = $this->getFieldsetDataValue('payment_action');
|
12 |
+
// Check if payment action is changed
|
13 |
+
if ($paymentAction != Mage::getStoreConfig('payment/ewayrapid_general/payment_action')) {
|
14 |
+
$defaultStatus = ( $paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE ?
|
15 |
+
Eway_Rapid31_Model_Config::ORDER_STATUS_CAPTURED :
|
16 |
+
Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED
|
17 |
+
);
|
18 |
+
|
19 |
+
$this->setValue($defaultStatus);
|
20 |
+
};
|
21 |
+
}
|
22 |
}
|
app/code/community/Eway/Rapid31/Model/System/Config/Backend/Validation.php
CHANGED
@@ -1,48 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_System_Config_Backend_Validation extends Mage_Core_Model_Config_Data
|
3 |
-
{
|
4 |
-
protected function _beforeSave()
|
5 |
-
{
|
6 |
-
// Only do the validation in case eWAY Rapid solution is enabled
|
7 |
-
if($this->getValue() == 1) {
|
8 |
-
$errors = array();
|
9 |
-
$this->_validateAPIKey($errors);
|
10 |
-
$this->_validateEncryptionKey($errors);
|
11 |
-
$this->_validateCCTypes($errors);
|
12 |
-
|
13 |
-
if($count = count($errors)) {
|
14 |
-
for($i = 0; $i < $count - 1; $i++) {
|
15 |
-
Mage::getSingleton('adminhtml/session')->addError($errors[$i]);
|
16 |
-
}
|
17 |
-
Mage::throwException($errors[$count - 1]);
|
18 |
-
}
|
19 |
-
}
|
20 |
-
|
21 |
-
parent::_beforeSave();
|
22 |
-
}
|
23 |
-
|
24 |
-
protected function _validateAPIKey(&$errors)
|
25 |
-
{
|
26 |
-
$mode = $this->getFieldsetDataValue('mode');
|
27 |
-
if(!$this->getFieldsetDataValue($mode . '_api_key') || !$this->getFieldsetDataValue($mode . '_api_password')) {
|
28 |
-
$errors[] = Mage::helper('ewayrapid')->__(
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
48 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_System_Config_Backend_Validation extends Mage_Core_Model_Config_Data
|
3 |
+
{
|
4 |
+
protected function _beforeSave()
|
5 |
+
{
|
6 |
+
// Only do the validation in case eWAY Rapid solution is enabled
|
7 |
+
if ($this->getValue() == 1) {
|
8 |
+
$errors = array();
|
9 |
+
$this->_validateAPIKey($errors);
|
10 |
+
$this->_validateEncryptionKey($errors);
|
11 |
+
$this->_validateCCTypes($errors);
|
12 |
+
|
13 |
+
if ($count = count($errors)) {
|
14 |
+
for ($i = 0; $i < $count - 1; $i++) {
|
15 |
+
Mage::getSingleton('adminhtml/session')->addError($errors[$i]);
|
16 |
+
}
|
17 |
+
Mage::throwException($errors[$count - 1]);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
parent::_beforeSave();
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _validateAPIKey(&$errors)
|
25 |
+
{
|
26 |
+
$mode = $this->getFieldsetDataValue('mode');
|
27 |
+
if (!$this->getFieldsetDataValue($mode . '_api_key') || !$this->getFieldsetDataValue($mode . '_api_password')) {
|
28 |
+
$errors[] = Mage::helper('ewayrapid')->__(
|
29 |
+
"Please input eWAY API Key and API Password for %s mode.",
|
30 |
+
$mode == Eway_Rapid31_Model_Config::MODE_SANDBOX ? "Sandbox" : "Live"
|
31 |
+
);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _validateEncryptionKey(&$errors)
|
36 |
+
{
|
37 |
+
$mode = $this->getFieldsetDataValue('mode');
|
38 |
+
if (!$this->getFieldsetDataValue($mode . '_encryption_key')) {
|
39 |
+
$errors[] = Mage::helper('ewayrapid')->__(
|
40 |
+
"Client-side Encryption Key is required (%s).",
|
41 |
+
$mode == Eway_Rapid31_Model_Config::MODE_SANDBOX ? "Sandbox" : "Live"
|
42 |
+
);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function _validateCCTypes(&$errors)
|
47 |
+
{
|
48 |
+
if (!$this->getFieldsetDataValue('cctypes')) {
|
49 |
+
$errors[] = Mage::helper('ewayrapid')->__("Please choose at least one Accepted Credit Card Type for eWAY payment method.");
|
50 |
+
}
|
51 |
+
}
|
52 |
}
|
app/code/community/Eway/Rapid31/Model/System/Config/Source/Orderstatus.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_Model_System_Config_Source_Orderstatus extends Mage_Adminhtml_Model_System_Config_Source_Order_Status_Processing
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Filter out order status based on eWAY requirement
|
6 |
-
*
|
7 |
-
* @return array
|
8 |
-
*/
|
9 |
-
public function toOptionArray()
|
10 |
-
{
|
11 |
-
$options = parent::toOptionArray();
|
12 |
-
|
13 |
-
$paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
|
14 |
-
|
15 |
-
foreach($options as $key => $option) {
|
16 |
-
if(strpos($option['value'], '_ogone') !== false) {
|
17 |
-
unset($options[$key]);
|
18 |
-
}
|
19 |
-
|
20 |
-
if($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
21 |
-
if($option['value'] == Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED) {
|
22 |
-
unset($options[$key]);
|
23 |
-
}
|
24 |
-
} else {
|
25 |
-
if($option['value'] == Eway_Rapid31_Model_Config::ORDER_STATUS_CAPTURED) {
|
26 |
-
unset($options[$key]);
|
27 |
-
}
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
return $options;
|
32 |
-
}
|
33 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_Model_System_Config_Source_Orderstatus extends Mage_Adminhtml_Model_System_Config_Source_Order_Status_Processing
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Filter out order status based on eWAY requirement
|
6 |
+
*
|
7 |
+
* @return array
|
8 |
+
*/
|
9 |
+
public function toOptionArray()
|
10 |
+
{
|
11 |
+
$options = parent::toOptionArray();
|
12 |
+
|
13 |
+
$paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
|
14 |
+
|
15 |
+
foreach ($options as $key => $option) {
|
16 |
+
if (strpos($option['value'], '_ogone') !== false) {
|
17 |
+
unset($options[$key]);
|
18 |
+
}
|
19 |
+
|
20 |
+
if ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
21 |
+
if ($option['value'] == Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED) {
|
22 |
+
unset($options[$key]);
|
23 |
+
}
|
24 |
+
} else {
|
25 |
+
if ($option['value'] == Eway_Rapid31_Model_Config::ORDER_STATUS_CAPTURED) {
|
26 |
+
unset($options[$key]);
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
return $options;
|
32 |
+
}
|
33 |
}
|
app/code/community/Eway/Rapid31/Test/Model/Abstract.php
CHANGED
@@ -1,179 +1,179 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Eway_Rapid31_Test_Model_Abstract
|
5 |
-
*/
|
6 |
-
abstract class Eway_Rapid31_Test_Model_Abstract extends EcomDev_PHPUnit_Test_Case
|
7 |
-
{
|
8 |
-
public function setUp()
|
9 |
-
{
|
10 |
-
Mage::getConfig()->saveScopeSnapshot();
|
11 |
-
// Reset the config object
|
12 |
-
Mage::unregister('_singleton/ewayrapid/config');
|
13 |
-
}
|
14 |
-
|
15 |
-
public function tearDown()
|
16 |
-
{
|
17 |
-
Mage::getConfig()->loadScopeSnapshot();
|
18 |
-
$this->flushConfigCache();
|
19 |
-
}
|
20 |
-
|
21 |
-
public static function assertJsonMatch($json, $expectedValue, $exact = true)
|
22 |
-
{
|
23 |
-
if(is_string($json)) {
|
24 |
-
$json = json_decode($json, true);
|
25 |
-
}
|
26 |
-
|
27 |
-
if(is_string($expectedValue)) {
|
28 |
-
$expectedValue = json_decode($expectedValue, true);
|
29 |
-
}
|
30 |
-
|
31 |
-
// if the indexes don't match, return immediately
|
32 |
-
$diff = array_diff_assoc($json, $expectedValue);
|
33 |
-
if(count($diff)) {
|
34 |
-
self::fail("There are different items in input json: \n" . print_r($diff, true));
|
35 |
-
}
|
36 |
-
|
37 |
-
if($exact) {
|
38 |
-
$diff = array_diff_assoc($expectedValue, $json);
|
39 |
-
if(count($diff)) {
|
40 |
-
self::fail("There are different items in expected json: \n" . print_r($diff, true));
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
foreach($json as $k => $v) {
|
45 |
-
if(is_array($v)) {
|
46 |
-
self::assertJsonMatch($v, $expectedValue[$k], $exact);
|
47 |
-
}
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
public static function assertJsonContain($jsonNeedle, $jsonHaystack)
|
52 |
-
{
|
53 |
-
self::assertJsonMatch($jsonNeedle, $jsonHaystack, false);
|
54 |
-
}
|
55 |
-
|
56 |
-
public function getDummyCardDetails()
|
57 |
-
{
|
58 |
-
return Mage::getModel('ewayrapid/field_cardDetails')
|
59 |
-
->setName('Card Holder Name')
|
60 |
-
->setNumber('4444333322221111')
|
61 |
-
->setExpiryMonth('12')
|
62 |
-
->setExpiryYear('16')
|
63 |
-
->setStartMonth('')
|
64 |
-
->setStartYear('')
|
65 |
-
->setIssueNumber('')
|
66 |
-
->setCVN('123');
|
67 |
-
}
|
68 |
-
|
69 |
-
public function getDummyShippingAddress()
|
70 |
-
{
|
71 |
-
return Mage::getModel('ewayrapid/field_shippingAddress')
|
72 |
-
->setCity('Auckland')
|
73 |
-
->setFirstName('John')
|
74 |
-
->setLastName('Smith')
|
75 |
-
->setStreet1('Level 5')
|
76 |
-
->setStreet2('369 Queen Street')
|
77 |
-
->setCountry('nz')
|
78 |
-
->setPostalCode('1010')
|
79 |
-
->setPhone('09 889 0986')
|
80 |
-
->setState('');
|
81 |
-
}
|
82 |
-
|
83 |
-
public function getDummyLineItem($count = 1)
|
84 |
-
{
|
85 |
-
return Mage::getModel('ewayrapid/field_lineItem')
|
86 |
-
->setSKU('SKU' . $count)
|
87 |
-
->setDescription('Description' . $count)
|
88 |
-
->setQuantity(1)
|
89 |
-
->setUnitCost(100)
|
90 |
-
->setTax(0)
|
91 |
-
->setTotal(100);
|
92 |
-
}
|
93 |
-
|
94 |
-
public function getDummyLineItemArray($count = 3)
|
95 |
-
{
|
96 |
-
$lineItems = array();
|
97 |
-
for($i = 1; $i <= 3; $i++) {
|
98 |
-
$lineItems[] = $this->getDummyLineItem($i);
|
99 |
-
}
|
100 |
-
|
101 |
-
return $lineItems;
|
102 |
-
}
|
103 |
-
|
104 |
-
public function getDummyPayment()
|
105 |
-
{
|
106 |
-
return Mage::getModel('ewayrapid/field_payment')
|
107 |
-
->setTotalAmount(100)
|
108 |
-
->setInvoiceNumber('Inv 21540')
|
109 |
-
->setInvoiceDescription('Individual Invoice Description')
|
110 |
-
->setInvoiceReference('513456')
|
111 |
-
->setCurrencyCode('AUD');
|
112 |
-
}
|
113 |
-
|
114 |
-
public function getDummyCustomer()
|
115 |
-
{
|
116 |
-
return Mage::getModel('ewayrapid/field_customer')
|
117 |
-
->setCardDetails($this->getDummyCardDetails())
|
118 |
-
->setReference('A12345')
|
119 |
-
->setTitle('Mr.')
|
120 |
-
->setFirstName('John')
|
121 |
-
->setLastName('Smith')
|
122 |
-
->setCompanyName('Demo Shop 123')
|
123 |
-
->setJobDescription('Developer')
|
124 |
-
->setStreet1('Level 5')
|
125 |
-
->setStreet2('369 Queen Street')
|
126 |
-
->setCity('Auckland')
|
127 |
-
->setState('')
|
128 |
-
->setPostalCode('1010')
|
129 |
-
->setCountry('nz')
|
130 |
-
->setEmail('')
|
131 |
-
->setPhone('09 889 0986')
|
132 |
-
->setMobile('09 889 0986')
|
133 |
-
->setComments('')
|
134 |
-
->setFax('')
|
135 |
-
->setUrl('');
|
136 |
-
}
|
137 |
-
|
138 |
-
public function setConfig(array $data, $store = 'admin')
|
139 |
-
{
|
140 |
-
$config = Mage::getConfig();
|
141 |
-
foreach ($data as $path => $value) {
|
142 |
-
$fullPath = 'stores/' . $store . '/' . $path;
|
143 |
-
$config->setNode($fullPath, $value);
|
144 |
-
}
|
145 |
-
|
146 |
-
$this->flushConfigCache();
|
147 |
-
}
|
148 |
-
|
149 |
-
public function flushConfigCache()
|
150 |
-
{
|
151 |
-
// Flush website and store configuration caches
|
152 |
-
foreach (Mage::app()->getWebsites(true) as $website) {
|
153 |
-
EcomDev_Utils_Reflection::setRestrictedPropertyValue(
|
154 |
-
$website, '_configCache', array()
|
155 |
-
);
|
156 |
-
}
|
157 |
-
foreach (Mage::app()->getStores(true) as $store) {
|
158 |
-
EcomDev_Utils_Reflection::setRestrictedPropertyValue(
|
159 |
-
$store, '_configCache', array()
|
160 |
-
);
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
protected function _mockSessionObject()
|
165 |
-
{
|
166 |
-
$sessionMock = $this->getModelMockBuilder('adminhtml/session_quote')
|
167 |
-
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
168 |
-
->setMethods(null) // Enables original methods usage, because by default it overrides all methods
|
169 |
-
->getMock();
|
170 |
-
$this->replaceByMock('singleton', 'adminhtml/session_quote', $sessionMock);
|
171 |
-
|
172 |
-
$sessionMock = $this->getModelMockBuilder('customer/session')
|
173 |
-
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
174 |
-
->setMethods(null) // Enables original methods usage, because by default it overrides all methods
|
175 |
-
->getMock();
|
176 |
-
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
177 |
-
|
178 |
-
}
|
179 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Eway_Rapid31_Test_Model_Abstract
|
5 |
+
*/
|
6 |
+
abstract class Eway_Rapid31_Test_Model_Abstract extends EcomDev_PHPUnit_Test_Case
|
7 |
+
{
|
8 |
+
public function setUp()
|
9 |
+
{
|
10 |
+
Mage::getConfig()->saveScopeSnapshot();
|
11 |
+
// Reset the config object
|
12 |
+
Mage::unregister('_singleton/ewayrapid/config');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function tearDown()
|
16 |
+
{
|
17 |
+
Mage::getConfig()->loadScopeSnapshot();
|
18 |
+
$this->flushConfigCache();
|
19 |
+
}
|
20 |
+
|
21 |
+
public static function assertJsonMatch($json, $expectedValue, $exact = true)
|
22 |
+
{
|
23 |
+
if (is_string($json)) {
|
24 |
+
$json = json_decode($json, true);
|
25 |
+
}
|
26 |
+
|
27 |
+
if (is_string($expectedValue)) {
|
28 |
+
$expectedValue = json_decode($expectedValue, true);
|
29 |
+
}
|
30 |
+
|
31 |
+
// if the indexes don't match, return immediately
|
32 |
+
$diff = array_diff_assoc($json, $expectedValue);
|
33 |
+
if (count($diff)) {
|
34 |
+
self::fail("There are different items in input json: \n" . print_r($diff, true));
|
35 |
+
}
|
36 |
+
|
37 |
+
if ($exact) {
|
38 |
+
$diff = array_diff_assoc($expectedValue, $json);
|
39 |
+
if (count($diff)) {
|
40 |
+
self::fail("There are different items in expected json: \n" . print_r($diff, true));
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
foreach ($json as $k => $v) {
|
45 |
+
if (is_array($v)) {
|
46 |
+
self::assertJsonMatch($v, $expectedValue[$k], $exact);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
public static function assertJsonContain($jsonNeedle, $jsonHaystack)
|
52 |
+
{
|
53 |
+
self::assertJsonMatch($jsonNeedle, $jsonHaystack, false);
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getDummyCardDetails()
|
57 |
+
{
|
58 |
+
return Mage::getModel('ewayrapid/field_cardDetails')
|
59 |
+
->setName('Card Holder Name')
|
60 |
+
->setNumber('4444333322221111')
|
61 |
+
->setExpiryMonth('12')
|
62 |
+
->setExpiryYear('16')
|
63 |
+
->setStartMonth('')
|
64 |
+
->setStartYear('')
|
65 |
+
->setIssueNumber('')
|
66 |
+
->setCVN('123');
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getDummyShippingAddress()
|
70 |
+
{
|
71 |
+
return Mage::getModel('ewayrapid/field_shippingAddress')
|
72 |
+
->setCity('Auckland')
|
73 |
+
->setFirstName('John')
|
74 |
+
->setLastName('Smith')
|
75 |
+
->setStreet1('Level 5')
|
76 |
+
->setStreet2('369 Queen Street')
|
77 |
+
->setCountry('nz')
|
78 |
+
->setPostalCode('1010')
|
79 |
+
->setPhone('09 889 0986')
|
80 |
+
->setState('');
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getDummyLineItem($count = 1)
|
84 |
+
{
|
85 |
+
return Mage::getModel('ewayrapid/field_lineItem')
|
86 |
+
->setSKU('SKU' . $count)
|
87 |
+
->setDescription('Description' . $count)
|
88 |
+
->setQuantity(1)
|
89 |
+
->setUnitCost(100)
|
90 |
+
->setTax(0)
|
91 |
+
->setTotal(100);
|
92 |
+
}
|
93 |
+
|
94 |
+
public function getDummyLineItemArray($count = 3)
|
95 |
+
{
|
96 |
+
$lineItems = array();
|
97 |
+
for ($i = 1; $i <= 3; $i++) {
|
98 |
+
$lineItems[] = $this->getDummyLineItem($i);
|
99 |
+
}
|
100 |
+
|
101 |
+
return $lineItems;
|
102 |
+
}
|
103 |
+
|
104 |
+
public function getDummyPayment()
|
105 |
+
{
|
106 |
+
return Mage::getModel('ewayrapid/field_payment')
|
107 |
+
->setTotalAmount(100)
|
108 |
+
->setInvoiceNumber('Inv 21540')
|
109 |
+
->setInvoiceDescription('Individual Invoice Description')
|
110 |
+
->setInvoiceReference('513456')
|
111 |
+
->setCurrencyCode('AUD');
|
112 |
+
}
|
113 |
+
|
114 |
+
public function getDummyCustomer()
|
115 |
+
{
|
116 |
+
return Mage::getModel('ewayrapid/field_customer')
|
117 |
+
->setCardDetails($this->getDummyCardDetails())
|
118 |
+
->setReference('A12345')
|
119 |
+
->setTitle('Mr.')
|
120 |
+
->setFirstName('John')
|
121 |
+
->setLastName('Smith')
|
122 |
+
->setCompanyName('Demo Shop 123')
|
123 |
+
->setJobDescription('Developer')
|
124 |
+
->setStreet1('Level 5')
|
125 |
+
->setStreet2('369 Queen Street')
|
126 |
+
->setCity('Auckland')
|
127 |
+
->setState('')
|
128 |
+
->setPostalCode('1010')
|
129 |
+
->setCountry('nz')
|
130 |
+
->setEmail('')
|
131 |
+
->setPhone('09 889 0986')
|
132 |
+
->setMobile('09 889 0986')
|
133 |
+
->setComments('')
|
134 |
+
->setFax('')
|
135 |
+
->setUrl('');
|
136 |
+
}
|
137 |
+
|
138 |
+
public function setConfig(array $data, $store = 'admin')
|
139 |
+
{
|
140 |
+
$config = Mage::getConfig();
|
141 |
+
foreach ($data as $path => $value) {
|
142 |
+
$fullPath = 'stores/' . $store . '/' . $path;
|
143 |
+
$config->setNode($fullPath, $value);
|
144 |
+
}
|
145 |
+
|
146 |
+
$this->flushConfigCache();
|
147 |
+
}
|
148 |
+
|
149 |
+
public function flushConfigCache()
|
150 |
+
{
|
151 |
+
// Flush website and store configuration caches
|
152 |
+
foreach (Mage::app()->getWebsites(true) as $website) {
|
153 |
+
EcomDev_Utils_Reflection::setRestrictedPropertyValue(
|
154 |
+
$website, '_configCache', array()
|
155 |
+
);
|
156 |
+
}
|
157 |
+
foreach (Mage::app()->getStores(true) as $store) {
|
158 |
+
EcomDev_Utils_Reflection::setRestrictedPropertyValue(
|
159 |
+
$store, '_configCache', array()
|
160 |
+
);
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
protected function _mockSessionObject()
|
165 |
+
{
|
166 |
+
$sessionMock = $this->getModelMockBuilder('adminhtml/session_quote')
|
167 |
+
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
168 |
+
->setMethods(null) // Enables original methods usage, because by default it overrides all methods
|
169 |
+
->getMock();
|
170 |
+
$this->replaceByMock('singleton', 'adminhtml/session_quote', $sessionMock);
|
171 |
+
|
172 |
+
$sessionMock = $this->getModelMockBuilder('customer/session')
|
173 |
+
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
174 |
+
->setMethods(null) // Enables original methods usage, because by default it overrides all methods
|
175 |
+
->getMock();
|
176 |
+
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
177 |
+
|
178 |
+
}
|
179 |
}
|
app/code/community/Eway/Rapid31/Test/Model/Config.php
CHANGED
@@ -32,10 +32,12 @@ class Eway_Rapid31_Test_Model_Config extends Eway_Rapid31_Test_Model_Abstract
|
|
32 |
{
|
33 |
$this->_mockSessionObject();
|
34 |
|
35 |
-
$this->setConfig(
|
|
|
36 |
'payment/ewayrapid_notsaved/active' => 1,
|
37 |
'payment/ewayrapid_saved/active' => 1,
|
38 |
-
|
|
|
39 |
$this->assertEquals(1, Mage::getStoreConfig('payment/ewayrapid_notsaved/active'));
|
40 |
$this->assertEquals(1, Mage::getStoreConfig('payment/ewayrapid_saved/active'));
|
41 |
|
@@ -44,9 +46,11 @@ class Eway_Rapid31_Test_Model_Config extends Eway_Rapid31_Test_Model_Abstract
|
|
44 |
|
45 |
$this->assertFalse($methodNotSaved->getConfigData('active'));
|
46 |
$this->assertFalse($methodSaved->getConfigData('active'));
|
47 |
-
$this->setConfig(
|
|
|
48 |
'payment/ewayrapid_general/active' => 1,
|
49 |
-
|
|
|
50 |
$this->assertTrue($methodNotSaved->getConfigData('active'));
|
51 |
$this->assertTrue($methodSaved->getConfigData('active'));
|
52 |
}
|
@@ -55,9 +59,11 @@ class Eway_Rapid31_Test_Model_Config extends Eway_Rapid31_Test_Model_Abstract
|
|
55 |
{
|
56 |
$this->assertFalse(Mage::getModel('ewayrapid/config')->isEnableSSLVerification());
|
57 |
|
58 |
-
$this->setConfig(
|
|
|
59 |
'payment/ewayrapid_general/mode' => 'live',
|
60 |
-
|
|
|
61 |
|
62 |
$this->assertTrue(Mage::getModel('ewayrapid/config')->isEnableSSLVerification());
|
63 |
}
|
32 |
{
|
33 |
$this->_mockSessionObject();
|
34 |
|
35 |
+
$this->setConfig(
|
36 |
+
array(
|
37 |
'payment/ewayrapid_notsaved/active' => 1,
|
38 |
'payment/ewayrapid_saved/active' => 1,
|
39 |
+
)
|
40 |
+
);
|
41 |
$this->assertEquals(1, Mage::getStoreConfig('payment/ewayrapid_notsaved/active'));
|
42 |
$this->assertEquals(1, Mage::getStoreConfig('payment/ewayrapid_saved/active'));
|
43 |
|
46 |
|
47 |
$this->assertFalse($methodNotSaved->getConfigData('active'));
|
48 |
$this->assertFalse($methodSaved->getConfigData('active'));
|
49 |
+
$this->setConfig(
|
50 |
+
array(
|
51 |
'payment/ewayrapid_general/active' => 1,
|
52 |
+
)
|
53 |
+
);
|
54 |
$this->assertTrue($methodNotSaved->getConfigData('active'));
|
55 |
$this->assertTrue($methodSaved->getConfigData('active'));
|
56 |
}
|
59 |
{
|
60 |
$this->assertFalse(Mage::getModel('ewayrapid/config')->isEnableSSLVerification());
|
61 |
|
62 |
+
$this->setConfig(
|
63 |
+
array(
|
64 |
'payment/ewayrapid_general/mode' => 'live',
|
65 |
+
)
|
66 |
+
);
|
67 |
|
68 |
$this->assertTrue(Mage::getModel('ewayrapid/config')->isEnableSSLVerification());
|
69 |
}
|
app/code/community/Eway/Rapid31/Test/Model/CustomerToken.php
CHANGED
@@ -82,8 +82,7 @@ class Eway_Rapid31_Test_Model_CustomerToken extends Eway_Rapid31_Test_Model_Abst
|
|
82 |
->setToken('1234567891')
|
83 |
->setExpMonth(1)
|
84 |
->setExpYear(2015)
|
85 |
-
->setOwner('Hiep Ho 1')
|
86 |
-
;
|
87 |
$tokens[1] = $token;
|
88 |
|
89 |
$token = Mage::getModel('ewayrapid/customer_token')
|
@@ -94,8 +93,7 @@ class Eway_Rapid31_Test_Model_CustomerToken extends Eway_Rapid31_Test_Model_Abst
|
|
94 |
->setToken('1234567892')
|
95 |
->setExpMonth(2)
|
96 |
->setExpYear(2015)
|
97 |
-
->setOwner('Hiep Ho 2')
|
98 |
-
;
|
99 |
$tokens[2] = $token;
|
100 |
|
101 |
$token = Mage::getModel('ewayrapid/customer_token')
|
@@ -106,8 +104,7 @@ class Eway_Rapid31_Test_Model_CustomerToken extends Eway_Rapid31_Test_Model_Abst
|
|
106 |
->setToken('1234567893')
|
107 |
->setExpMonth(3)
|
108 |
->setExpYear(2015)
|
109 |
-
->setOwner('Hiep Ho 3')
|
110 |
-
;
|
111 |
$tokens[3] = $token;
|
112 |
|
113 |
$savedTokens->setTokens($tokens);
|
82 |
->setToken('1234567891')
|
83 |
->setExpMonth(1)
|
84 |
->setExpYear(2015)
|
85 |
+
->setOwner('Hiep Ho 1');
|
|
|
86 |
$tokens[1] = $token;
|
87 |
|
88 |
$token = Mage::getModel('ewayrapid/customer_token')
|
93 |
->setToken('1234567892')
|
94 |
->setExpMonth(2)
|
95 |
->setExpYear(2015)
|
96 |
+
->setOwner('Hiep Ho 2');
|
|
|
97 |
$tokens[2] = $token;
|
98 |
|
99 |
$token = Mage::getModel('ewayrapid/customer_token')
|
104 |
->setToken('1234567893')
|
105 |
->setExpMonth(3)
|
106 |
->setExpYear(2015)
|
107 |
+
->setOwner('Hiep Ho 3');
|
|
|
108 |
$tokens[3] = $token;
|
109 |
|
110 |
$savedTokens->setTokens($tokens);
|
app/code/community/Eway/Rapid31/Test/Model/JsonSerializable.php
CHANGED
@@ -3,7 +3,8 @@ class Eway_Rapid31_Test_Model_JsonSerializable extends Eway_Rapid31_Test_Model_A
|
|
3 |
{
|
4 |
public function testDummyData()
|
5 |
{
|
6 |
-
$this->assertJsonMatch(
|
|
|
7 |
'{ "FirstName": "John",
|
8 |
"LastName": "Smith",
|
9 |
"Street1": "Level 5",
|
@@ -12,9 +13,11 @@ class Eway_Rapid31_Test_Model_JsonSerializable extends Eway_Rapid31_Test_Model_A
|
|
12 |
"State": "",
|
13 |
"Country": "nz",
|
14 |
"PostalCode": "1010",
|
15 |
-
"Phone": "09 889 0986" }'
|
|
|
16 |
|
17 |
-
$this->assertJsonMatch(
|
|
|
18 |
'{ "Name": "Card Holder Name",
|
19 |
"Number": "4444333322221111",
|
20 |
"ExpiryMonth": "12",
|
@@ -22,25 +25,31 @@ class Eway_Rapid31_Test_Model_JsonSerializable extends Eway_Rapid31_Test_Model_A
|
|
22 |
"StartMonth" : "",
|
23 |
"StartYear" : "",
|
24 |
"IssueNumber": "",
|
25 |
-
"CVN": "123" }'
|
|
|
26 |
|
27 |
-
$this->assertJsonMatch(
|
|
|
28 |
'{ "SKU": "SKU1",
|
29 |
"Description": "Description1",
|
30 |
"Quantity": 1,
|
31 |
"UnitCost": 100,
|
32 |
"Tax": 0,
|
33 |
-
"Total": 100 }'
|
|
|
34 |
|
35 |
-
$this->assertJsonMatch(
|
|
|
36 |
'{ "TotalAmount": 100,
|
37 |
"InvoiceNumber": "Inv 21540",
|
38 |
"InvoiceDescription": "Individual Invoice Description",
|
39 |
"InvoiceReference": "513456",
|
40 |
"CurrencyCode": "AUD"
|
41 |
-
}'
|
|
|
42 |
|
43 |
-
$this->assertJsonMatch(
|
|
|
44 |
'{
|
45 |
"Reference": "A12345",
|
46 |
"Title": "Mr.",
|
@@ -70,7 +79,8 @@ class Eway_Rapid31_Test_Model_JsonSerializable extends Eway_Rapid31_Test_Model_A
|
|
70 |
"IssueNumber": "",
|
71 |
"CVN": "123"
|
72 |
}
|
73 |
-
}'
|
|
|
74 |
}
|
75 |
|
76 |
public function testRequestDirect()
|
@@ -87,8 +97,9 @@ class Eway_Rapid31_Test_Model_JsonSerializable extends Eway_Rapid31_Test_Model_A
|
|
87 |
->setTransactionType('Purchase')
|
88 |
->setMethod('ProcessPayment');
|
89 |
|
90 |
-
$this->assertJsonMatch(
|
91 |
-
|
|
|
92 |
"Reference": "A12345",
|
93 |
"Title": "Mr.",
|
94 |
"FirstName": "John",
|
@@ -168,14 +179,16 @@ class Eway_Rapid31_Test_Model_JsonSerializable extends Eway_Rapid31_Test_Model_A
|
|
168 |
"PartnerID": "04A0FD665F7348A295C5B9EE95400301",
|
169 |
"TransactionType": "Purchase",
|
170 |
"Method": "ProcessPayment"
|
171 |
-
}'
|
|
|
172 |
}
|
173 |
|
174 |
public function testMaskedCardDetails()
|
175 |
{
|
176 |
$cardDetails = $this->getDummyCardDetails();
|
177 |
$cardDetails->shouldBeMasked();
|
178 |
-
$this->assertJsonMatch(
|
|
|
179 |
'{ "Name": "Card Holder Name",
|
180 |
"Number": "444433******1111",
|
181 |
"ExpiryMonth": "**",
|
@@ -183,10 +196,12 @@ class Eway_Rapid31_Test_Model_JsonSerializable extends Eway_Rapid31_Test_Model_A
|
|
183 |
"StartMonth" : "",
|
184 |
"StartYear" : "",
|
185 |
"IssueNumber": "",
|
186 |
-
"CVN": "***" }'
|
|
|
187 |
|
188 |
$cardDetails->shouldBeMasked(false);
|
189 |
-
$this->assertJsonMatch(
|
|
|
190 |
'{ "Name": "Card Holder Name",
|
191 |
"Number": "4444333322221111",
|
192 |
"ExpiryMonth": "12",
|
@@ -194,6 +209,7 @@ class Eway_Rapid31_Test_Model_JsonSerializable extends Eway_Rapid31_Test_Model_A
|
|
194 |
"StartMonth" : "",
|
195 |
"StartYear" : "",
|
196 |
"IssueNumber": "",
|
197 |
-
"CVN": "123" }'
|
|
|
198 |
}
|
199 |
}
|
3 |
{
|
4 |
public function testDummyData()
|
5 |
{
|
6 |
+
$this->assertJsonMatch(
|
7 |
+
$this->getDummyShippingAddress()->jsonSerialize(),
|
8 |
'{ "FirstName": "John",
|
9 |
"LastName": "Smith",
|
10 |
"Street1": "Level 5",
|
13 |
"State": "",
|
14 |
"Country": "nz",
|
15 |
"PostalCode": "1010",
|
16 |
+
"Phone": "09 889 0986" }'
|
17 |
+
);
|
18 |
|
19 |
+
$this->assertJsonMatch(
|
20 |
+
$this->getDummyCardDetails()->jsonSerialize(),
|
21 |
'{ "Name": "Card Holder Name",
|
22 |
"Number": "4444333322221111",
|
23 |
"ExpiryMonth": "12",
|
25 |
"StartMonth" : "",
|
26 |
"StartYear" : "",
|
27 |
"IssueNumber": "",
|
28 |
+
"CVN": "123" }'
|
29 |
+
);
|
30 |
|
31 |
+
$this->assertJsonMatch(
|
32 |
+
$this->getDummyLineItem(1)->jsonSerialize(),
|
33 |
'{ "SKU": "SKU1",
|
34 |
"Description": "Description1",
|
35 |
"Quantity": 1,
|
36 |
"UnitCost": 100,
|
37 |
"Tax": 0,
|
38 |
+
"Total": 100 }'
|
39 |
+
);
|
40 |
|
41 |
+
$this->assertJsonMatch(
|
42 |
+
$this->getDummyPayment()->jsonSerialize(),
|
43 |
'{ "TotalAmount": 100,
|
44 |
"InvoiceNumber": "Inv 21540",
|
45 |
"InvoiceDescription": "Individual Invoice Description",
|
46 |
"InvoiceReference": "513456",
|
47 |
"CurrencyCode": "AUD"
|
48 |
+
}'
|
49 |
+
);
|
50 |
|
51 |
+
$this->assertJsonMatch(
|
52 |
+
$this->getDummyCustomer()->jsonSerialize(),
|
53 |
'{
|
54 |
"Reference": "A12345",
|
55 |
"Title": "Mr.",
|
79 |
"IssueNumber": "",
|
80 |
"CVN": "123"
|
81 |
}
|
82 |
+
}'
|
83 |
+
);
|
84 |
}
|
85 |
|
86 |
public function testRequestDirect()
|
97 |
->setTransactionType('Purchase')
|
98 |
->setMethod('ProcessPayment');
|
99 |
|
100 |
+
$this->assertJsonMatch(
|
101 |
+
$request->jsonSerialize(),
|
102 |
+
'{ "Customer": {
|
103 |
"Reference": "A12345",
|
104 |
"Title": "Mr.",
|
105 |
"FirstName": "John",
|
179 |
"PartnerID": "04A0FD665F7348A295C5B9EE95400301",
|
180 |
"TransactionType": "Purchase",
|
181 |
"Method": "ProcessPayment"
|
182 |
+
}'
|
183 |
+
);
|
184 |
}
|
185 |
|
186 |
public function testMaskedCardDetails()
|
187 |
{
|
188 |
$cardDetails = $this->getDummyCardDetails();
|
189 |
$cardDetails->shouldBeMasked();
|
190 |
+
$this->assertJsonMatch(
|
191 |
+
$cardDetails->jsonSerialize(),
|
192 |
'{ "Name": "Card Holder Name",
|
193 |
"Number": "444433******1111",
|
194 |
"ExpiryMonth": "**",
|
196 |
"StartMonth" : "",
|
197 |
"StartYear" : "",
|
198 |
"IssueNumber": "",
|
199 |
+
"CVN": "***" }'
|
200 |
+
);
|
201 |
|
202 |
$cardDetails->shouldBeMasked(false);
|
203 |
+
$this->assertJsonMatch(
|
204 |
+
$cardDetails->jsonSerialize(),
|
205 |
'{ "Name": "Card Holder Name",
|
206 |
"Number": "4444333322221111",
|
207 |
"ExpiryMonth": "12",
|
209 |
"StartMonth" : "",
|
210 |
"StartYear" : "",
|
211 |
"IssueNumber": "",
|
212 |
+
"CVN": "123" }'
|
213 |
+
);
|
214 |
}
|
215 |
}
|
app/code/community/Eway/Rapid31/Test/Model/Response.php
CHANGED
@@ -3,7 +3,8 @@ class Eway_Rapid31_Test_Model_Response extends EcomDev_PHPUnit_Test_Case
|
|
3 |
{
|
4 |
public function testResponse()
|
5 |
{
|
6 |
-
$response = Mage::getModel('ewayrapid/response')->decodeJSON(
|
|
|
7 |
{
|
8 |
"AuthorisationCode": "000000",
|
9 |
"ResponseCode": "58",
|
@@ -60,7 +61,8 @@ class Eway_Rapid31_Test_Model_Response extends EcomDev_PHPUnit_Test_Case
|
|
60 |
},
|
61 |
"Errors": null
|
62 |
}
|
63 |
-
'
|
|
|
64 |
|
65 |
$this->assertEquals('000000', $response->getAuthorisationCode());
|
66 |
$this->assertEquals('58', $response->getResponseCode());
|
3 |
{
|
4 |
public function testResponse()
|
5 |
{
|
6 |
+
$response = Mage::getModel('ewayrapid/response')->decodeJSON(
|
7 |
+
'
|
8 |
{
|
9 |
"AuthorisationCode": "000000",
|
10 |
"ResponseCode": "58",
|
61 |
},
|
62 |
"Errors": null
|
63 |
}
|
64 |
+
'
|
65 |
+
);
|
66 |
|
67 |
$this->assertEquals('000000', $response->getAuthorisationCode());
|
68 |
$this->assertEquals('58', $response->getResponseCode());
|
app/code/community/Eway/Rapid31/controllers/Adminhtml/EwayadminController.php
CHANGED
@@ -1,190 +1,238 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*/
|
5 |
-
class Eway_Rapid31_Adminhtml_EwayadminController extends Mage_Adminhtml_Controller_Action
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
$
|
41 |
-
$
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
$
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
$
|
122 |
-
|
123 |
-
$
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
$
|
131 |
-
|
132 |
-
$
|
133 |
-
|
134 |
-
$
|
135 |
-
$
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
$
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
}
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
$
|
166 |
-
|
167 |
-
$
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
$
|
174 |
-
$
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
$
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
class Eway_Rapid31_Adminhtml_EwayadminController extends Mage_Adminhtml_Controller_Action
|
6 |
+
{
|
7 |
+
const DEBUG_FILE = 'ewayrapid31_api_request.log';
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @var Eway_Rapid31_Model_Config
|
11 |
+
*/
|
12 |
+
protected $_config = null;
|
13 |
+
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
$this->_config = Mage::getSingleton('ewayrapid/config');
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _isAllowed()
|
20 |
+
{
|
21 |
+
return true;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function indexAction()
|
25 |
+
{
|
26 |
+
}
|
27 |
+
|
28 |
+
public function massEwayAuthorisedAction()
|
29 |
+
{
|
30 |
+
$data = Mage::app()->getRequest()->getPost();
|
31 |
+
if (is_array($data) & isset($data['order_ids'])) {
|
32 |
+
foreach ($data['order_ids'] as $id) {
|
33 |
+
$order = Mage::getModel('sales/order')->load($id);
|
34 |
+
$order->setData('state', 'processing');
|
35 |
+
$order->setData('status', Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED);
|
36 |
+
$order->save();
|
37 |
+
|
38 |
+
// Update user fraud status
|
39 |
+
$customerData = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
40 |
+
$customerData->setData('mark_fraud', 0);
|
41 |
+
$customerData->save();
|
42 |
+
|
43 |
+
// Re-order current order
|
44 |
+
// ...
|
45 |
+
}
|
46 |
+
}
|
47 |
+
// Redirect form
|
48 |
+
$this->_redirectUrl(Mage::helper("adminhtml")->getUrl("adminhtml/sales_order/index"));
|
49 |
+
}
|
50 |
+
|
51 |
+
public function massProcessingAction()
|
52 |
+
{
|
53 |
+
$data = Mage::app()->getRequest()->getPost();
|
54 |
+
if (is_array($data) & isset($data['order_ids'])) {
|
55 |
+
foreach ($data['order_ids'] as $id) {
|
56 |
+
$order = Mage::getModel('sales/order')->load($id);
|
57 |
+
$order->setData('state', 'processing');
|
58 |
+
$order->setData('status', 'processing');
|
59 |
+
$order->save();
|
60 |
+
|
61 |
+
// Update user fraud status
|
62 |
+
$customerData = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
63 |
+
$customerData->setData('mark_fraud', 0);
|
64 |
+
$customerData->save();
|
65 |
+
|
66 |
+
// Re-order current order
|
67 |
+
// ...
|
68 |
+
}
|
69 |
+
}
|
70 |
+
// Redirect form
|
71 |
+
$this->_redirectUrl(Mage::helper("adminhtml")->getUrl("adminhtml/sales_order/index"));
|
72 |
+
}
|
73 |
+
|
74 |
+
public function massVerifyEwayOrderAction()
|
75 |
+
{
|
76 |
+
$data = Mage::app()->getRequest()->getPost();
|
77 |
+
if (is_array($data) & isset($data['order_ids'])) {
|
78 |
+
|
79 |
+
foreach ($data['order_ids'] as $id) {
|
80 |
+
|
81 |
+
$order = Mage::getModel('sales/order')->load($id);
|
82 |
+
|
83 |
+
$result = $this->__getTransaction($order->getEwayTransactionId());
|
84 |
+
|
85 |
+
// Check return data
|
86 |
+
$resultDecode = json_decode($result);
|
87 |
+
|
88 |
+
$trans = (isset($resultDecode->Transactions) ? $resultDecode->Transactions : array());
|
89 |
+
if (!isset($trans[0])) {
|
90 |
+
continue; // go to next cycle when no element is exist
|
91 |
+
}
|
92 |
+
$tranId = $trans[0]->TransactionID;
|
93 |
+
|
94 |
+
if ($trans[0]->ResponseMessage == 'A2000' || $trans[0]->ResponseMessage == 'A2008') { // Success - Fraud order has been approved
|
95 |
+
// Create new transaction
|
96 |
+
$this->__createNewTransaction($order, $tranId);
|
97 |
+
// Update order status
|
98 |
+
$this->__updateStatusOrder($order);
|
99 |
+
// Un-mark fraud customer
|
100 |
+
$this->__unMarkFraudUser($order);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
// Redirect form
|
105 |
+
$this->_redirectReferer();
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Queries an eWAY Transacion
|
110 |
+
*
|
111 |
+
* @param int $transId
|
112 |
+
* @return string Raw JSON result
|
113 |
+
*/
|
114 |
+
private function __getTransaction($transId)
|
115 |
+
{
|
116 |
+
|
117 |
+
$url = $this->_config->getRapidAPIUrl('Transaction') . '/' . $transId;
|
118 |
+
$mode = $this->_config->isSandbox() ? '(Sandbox)' : '(Live)';
|
119 |
+
$this->_log('>>>>> START REQUEST ' . $mode . ' (GET) ' . ' : ' . $url);
|
120 |
+
|
121 |
+
$ch = curl_init($url);
|
122 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json", "X-EWAY-APIVERSION: 40"));
|
123 |
+
curl_setopt($ch, CURLOPT_USERPWD, $this->_config->getBasicAuthenticationHeader());
|
124 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
|
125 |
+
|
126 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
127 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
128 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->_config->isEnableSSLVerification());
|
129 |
+
|
130 |
+
$result = curl_exec($ch);
|
131 |
+
|
132 |
+
$this->_log('<<<<< RESPONSE:');
|
133 |
+
if ($this->_config->isDebug()) {
|
134 |
+
$this->_log('SUCCESS. Response body: ');
|
135 |
+
$this->_log(print_r(json_decode($result, true), true));
|
136 |
+
}
|
137 |
+
|
138 |
+
return $result;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Create new transaction with base order
|
143 |
+
*
|
144 |
+
* @param Mage_Sales_Model_Order $order
|
145 |
+
* @param int eWAY tranasction ID
|
146 |
+
*/
|
147 |
+
private function __createNewTransaction(Mage_Sales_Model_Order $order, $transId)
|
148 |
+
{
|
149 |
+
|
150 |
+
// Load transaction
|
151 |
+
$currentTrans = Mage::getModel('sales/order_payment_transaction')
|
152 |
+
->getCollection()
|
153 |
+
->addFieldToFilter('order_id', array('eq' => $order->getEntityId()));
|
154 |
+
foreach ($currentTrans as $t) {
|
155 |
+
}
|
156 |
+
if ($t == null) {
|
157 |
+
$t = new Mage_Sales_Model_Order_Payment_Transaction();
|
158 |
+
}
|
159 |
+
|
160 |
+
$trans = new Mage_Sales_Model_Order_Payment_Transaction();
|
161 |
+
// Load payment object
|
162 |
+
$payment = Mage::getModel('sales/order_payment')->load($t->getPaymentId());
|
163 |
+
|
164 |
+
$trans->setOrderPaymentObject($payment);
|
165 |
+
$trans->setOrder($order);
|
166 |
+
|
167 |
+
$trans->setParentId($t->getTransactionId());
|
168 |
+
$trans->setOrderId($order->getEntityId());
|
169 |
+
$trans->setPaymentId($t->getPaymentId());
|
170 |
+
// Get new TxnId
|
171 |
+
$break = true;
|
172 |
+
for ($i = 0; $i < 100; $i++) {
|
173 |
+
$transId++;
|
174 |
+
$newTrans = Mage::getModel('sales/order_payment_transaction')
|
175 |
+
->getCollection()
|
176 |
+
->addFieldToFilter('txn_id', array('eq' => $transId));
|
177 |
+
if (count($newTrans) == 0) {
|
178 |
+
$break = false;
|
179 |
+
break;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
if ($break) {
|
183 |
+
return false;
|
184 |
+
}
|
185 |
+
$trans->setTxnId($transId);
|
186 |
+
|
187 |
+
$trans->setParentTxnId($t->getTxnId());
|
188 |
+
$trans->setTxnType($t->getTxnType());
|
189 |
+
$trans->setIsClosed($t->getIsClosed());
|
190 |
+
$trans->setCreatedAt(date('Y-m-d H:i:s'));
|
191 |
+
|
192 |
+
try {
|
193 |
+
$trans->save();
|
194 |
+
} catch(Exception $e) {
|
195 |
+
// Do something
|
196 |
+
}
|
197 |
+
return true;
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
private function __updateStatusOrder(Mage_Sales_Model_Order $order)
|
202 |
+
{
|
203 |
+
$stateConfig = Mage::getStoreConfig('payment/ewayrapid_general/verify_eway_order');
|
204 |
+
|
205 |
+
$order->setState($stateConfig);
|
206 |
+
$order->setStatus($stateConfig);
|
207 |
+
$order->save();
|
208 |
+
}
|
209 |
+
|
210 |
+
private function __unMarkFraudUser(Mage_Sales_Model_Order $order)
|
211 |
+
{
|
212 |
+
if ($uid = $order->getCustomerId()) {
|
213 |
+
$customer = Mage::getModel('customer/customer')->load($uid);
|
214 |
+
$customer->setMarkFraud(0);
|
215 |
+
$customer->save();
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
public function ewayordersAction()
|
220 |
+
{
|
221 |
+
$this->loadLayout();
|
222 |
+
$this->renderLayout();
|
223 |
+
}
|
224 |
+
|
225 |
+
public function gridAction()
|
226 |
+
{
|
227 |
+
$this->loadLayout(false);
|
228 |
+
$this->renderLayout();
|
229 |
+
}
|
230 |
+
|
231 |
+
protected function _log($message, $file = self::DEBUG_FILE)
|
232 |
+
{
|
233 |
+
if ($this->_config->isDebug()) {
|
234 |
+
Mage::log($message, Zend_Log::DEBUG, $file, true);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
}
|
app/code/community/Eway/Rapid31/controllers/Adminhtml/Ewayrapid/SavedcardController.php
CHANGED
@@ -1,301 +1,307 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Eway_Rapid31_Adminhtml_Ewayrapid_SavedcardController extends Mage_Adminhtml_Controller_Action
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
$
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
$
|
23 |
-
|
24 |
-
$this->
|
25 |
-
|
26 |
-
$this->
|
27 |
-
|
28 |
-
$this->
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
$
|
45 |
-
|
46 |
-
$
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
$
|
76 |
-
$
|
77 |
-
|
78 |
-
$message['message'] = $this->__('
|
79 |
-
$message['success'] =
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
$
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
);
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$
|
111 |
-
$
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$this->
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
$
|
128 |
-
|
129 |
-
|
130 |
-
);
|
131 |
-
|
132 |
-
$
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
Mage::
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
*
|
162 |
-
*
|
163 |
-
* "
|
164 |
-
* "
|
165 |
-
* "
|
166 |
-
* "
|
167 |
-
* "
|
168 |
-
* "
|
169 |
-
* "
|
170 |
-
* "
|
171 |
-
* "
|
172 |
-
* "
|
173 |
-
* "
|
174 |
-
* "
|
175 |
-
* "
|
176 |
-
* "
|
177 |
-
* "
|
178 |
-
* "
|
179 |
-
* "
|
180 |
-
* "
|
181 |
-
* "
|
182 |
-
* "
|
183 |
-
* "
|
184 |
-
* "
|
185 |
-
*
|
186 |
-
*
|
187 |
-
*
|
188 |
-
*
|
189 |
-
*
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
//
|
197 |
-
//
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
$data =
|
202 |
-
|
203 |
-
|
204 |
-
$
|
205 |
-
$
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
$
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
);
|
224 |
-
|
225 |
-
|
226 |
-
$
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
'
|
258 |
-
'
|
259 |
-
'
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
$
|
273 |
-
$this->
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Eway_Rapid31_Adminhtml_Ewayrapid_SavedcardController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _isAllowed()
|
7 |
+
{
|
8 |
+
return true;
|
9 |
+
}
|
10 |
+
|
11 |
+
public function loadAction()
|
12 |
+
{
|
13 |
+
$request = $this->getRequest();
|
14 |
+
$tokenId = $request->getParam('token_id');
|
15 |
+
$message = array(
|
16 |
+
'message' => $this->__('Invalid request'),
|
17 |
+
'success' => false
|
18 |
+
);
|
19 |
+
|
20 |
+
if ($tokenId && is_numeric($tokenId) && $tokenId > 0) {
|
21 |
+
$customerId = $request->getParam('customer_id');
|
22 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
23 |
+
Mage::register('current_customer', $customer);
|
24 |
+
$this->loadLayout();
|
25 |
+
$this->getLayout()->getBlock('root')->setData('token_id', $tokenId);
|
26 |
+
$this->renderLayout();
|
27 |
+
} else {
|
28 |
+
$this->loadLayout();
|
29 |
+
$this->getLayout()->getBlock('root')->setData('token_id', 0);
|
30 |
+
$this->renderLayout();
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
public function newAction()
|
37 |
+
{
|
38 |
+
$this->_forward('edit');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function saveAction()
|
42 |
+
{
|
43 |
+
|
44 |
+
$request = $this->getRequest();
|
45 |
+
$params = $request->getParam('ewayrapid');
|
46 |
+
$customerId = $request->getParam('customer_id');
|
47 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
48 |
+
|
49 |
+
$message = array(
|
50 |
+
'success' => false,
|
51 |
+
'message' => Mage::helper('ewayrapid')->__('Invalid request')
|
52 |
+
);
|
53 |
+
|
54 |
+
Mage::register('current_customer', $customer);
|
55 |
+
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
56 |
+
$this->getResponse()->setBody(json_encode($message));
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
|
60 |
+
$apiRequest = Mage::getModel('ewayrapid/request_token');
|
61 |
+
try {
|
62 |
+
if (!$request->isPost() || !$params['address'] || !$params['payment']) {
|
63 |
+
$this->getResponse()->setBody(json_encode($message));
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
$tokenId = $params['token_id'];
|
68 |
+
if (is_numeric($tokenId) && $tokenId > 0) {
|
69 |
+
list($billingAddress, $infoInstance) = $this->_generateApiParams($params);
|
70 |
+
|
71 |
+
$infoInstance->setSavedToken($tokenId);
|
72 |
+
$apiRequest->updateToken($billingAddress, $infoInstance);
|
73 |
+
|
74 |
+
} else if (!$tokenId) {
|
75 |
+
list($billingAddress, $infoInstance) = $this->_generateApiParams($params);
|
76 |
+
$apiRequest->createNewToken($billingAddress, $infoInstance);
|
77 |
+
|
78 |
+
$message['message'] = $this->__('Your Credit Card has been saved successfully.');
|
79 |
+
$message['success'] = true;
|
80 |
+
} else {
|
81 |
+
$message['message'] = $this->__('Invalid token id');
|
82 |
+
$message['success'] = false;
|
83 |
+
$this->getResponse()->setBody(json_encode($message));
|
84 |
+
return;
|
85 |
+
}
|
86 |
+
} catch (Mage_Core_Exception $e) {
|
87 |
+
$message['message'] = $e->getMessage();
|
88 |
+
$this->getResponse()->setBody(json_encode($message));
|
89 |
+
return;
|
90 |
+
} catch (Exception $e){
|
91 |
+
$message['message'] = $e->getMessage();
|
92 |
+
$this->getResponse()->setBody(json_encode($message));
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
|
96 |
+
$this->loadLayout();
|
97 |
+
$this->renderLayout();
|
98 |
+
}
|
99 |
+
|
100 |
+
public function deleteAction()
|
101 |
+
{
|
102 |
+
$request = $this->getRequest();
|
103 |
+
$tokenId = $request->getParam('token_id');
|
104 |
+
$message = array(
|
105 |
+
'message' => $this->__('Invalid request'),
|
106 |
+
'success' => false
|
107 |
+
);
|
108 |
+
|
109 |
+
if ($tokenId && is_numeric($tokenId) && $tokenId > 0) {
|
110 |
+
$customerId = $request->getParam('customer_id');
|
111 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
112 |
+
Mage::register('current_customer', $customer);
|
113 |
+
Mage::helper('ewayrapid/customer')->deleteToken($tokenId);
|
114 |
+
$message['success'] = true;
|
115 |
+
$message['message'] = $this->__('Card deleted');
|
116 |
+
$this->getResponse()->setBody(json_encode($message));
|
117 |
+
return;
|
118 |
+
} else {
|
119 |
+
$this->getResponse()->setBody(json_encode($message));
|
120 |
+
return;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
public function getAccessCodeAction()
|
125 |
+
{
|
126 |
+
try{
|
127 |
+
$request = $this->getRequest();
|
128 |
+
$params = $request->getParam('ewayrapid');
|
129 |
+
$customerId = $request->getParam('customer_id');
|
130 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
131 |
+
|
132 |
+
$message = array(
|
133 |
+
'message' => $this->__('Invalid request'),
|
134 |
+
'success' => false
|
135 |
+
);
|
136 |
+
// Response data to client
|
137 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
138 |
+
|
139 |
+
// Enabled method save
|
140 |
+
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
141 |
+
$this->getResponse()->setBody(json_encode($message));
|
142 |
+
return;
|
143 |
+
}
|
144 |
+
|
145 |
+
Mage::register('current_customer', $customer);
|
146 |
+
$method = 'AccessCodes';
|
147 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
148 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE ||
|
149 |
+
Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
150 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
151 |
+
) {
|
152 |
+
$method = 'AccessCodesShared';
|
153 |
+
}
|
154 |
+
|
155 |
+
$request = $this->getRequest();
|
156 |
+
|
157 |
+
$apiRequest = Mage::getModel('ewayrapid/request_token');
|
158 |
+
list($billingAddress, $infoInstance) = $this->_generateApiParams($params);
|
159 |
+
$data = $apiRequest->createAccessCode($billingAddress, $infoInstance, $method, $request);
|
160 |
+
/*
|
161 |
+
* {"AccessCode":"C3AB9RIc_reC_FRm8nXsy36QddJm_-YlaZCc2ZHuhbOeR5RzX682kfgl_12-vipFpJiuPPcOyh-ToeWP--Px06J04mW1zhqKpyqRTsvz0ub9-URgih4V_rHDYoNxQHXq9Ho2l",
|
162 |
+
* "Customer":{
|
163 |
+
* "CardNumber":"",
|
164 |
+
* "CardStartMonth":"",
|
165 |
+
* "CardStartYear":"",
|
166 |
+
* "CardIssueNumber":"",
|
167 |
+
* "CardName":"",
|
168 |
+
* "CardExpiryMonth":"",
|
169 |
+
* "CardExpiryYear":"",
|
170 |
+
* "IsActive":false,
|
171 |
+
* "TokenCustomerID":null,
|
172 |
+
* "Reference":"",
|
173 |
+
* "Title":"Mr.",
|
174 |
+
* "FirstName":"binh",
|
175 |
+
* "LastName":"nguyen",
|
176 |
+
* "CompanyName":"aaaaaa",
|
177 |
+
* "JobDescription":"job",
|
178 |
+
* "Street1":"Product Attributes",
|
179 |
+
* "Street2":"def",
|
180 |
+
* "City":"city here",
|
181 |
+
* "State":"123",
|
182 |
+
* "PostalCode":"1234",
|
183 |
+
* "Country":"as",
|
184 |
+
* "Email":"4444ddd@gmail.com",
|
185 |
+
* "Phone":"0987654321",
|
186 |
+
* "Mobile":"4444444444",
|
187 |
+
* "Comments":"",
|
188 |
+
* "Fax":"4535343",
|
189 |
+
* "Url":""
|
190 |
+
* },
|
191 |
+
* "Payment":{"TotalAmount":0,"InvoiceNumber":null,"InvoiceDescription":null,"InvoiceReference":null,"CurrencyCode":"AUD"},
|
192 |
+
* "FormActionURL":"https:\/\/secure-au.sandbox.ewaypayments.com\/AccessCode\/C3AB9RIc_reC_FRm8nXsy36QddJm_-YlaZCc2ZHuhbOeR5RzX682kfgl_12-vipFpJiuPPcOyh-ToeWP--Px06J04mW1zhqKpyqRTsvz0ub9-URgih4V_rHDYoNxQHXq9Ho2l",
|
193 |
+
* "CompleteCheckoutURL":null,
|
194 |
+
* "Errors":null}
|
195 |
+
*/
|
196 |
+
// if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
197 |
+
// === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE||
|
198 |
+
// Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
199 |
+
// === Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
200 |
+
// ) {
|
201 |
+
// $data = $data->getData();
|
202 |
+
// }
|
203 |
+
$customerData = $data->getCustomer();
|
204 |
+
$data->setData('street1', $customerData['Street1']);
|
205 |
+
$data->setData('street2', $customerData['Street2']);
|
206 |
+
$data = json_encode($data->getData());
|
207 |
+
$this->getResponse()->setBody($data);
|
208 |
+
}catch (Mage_Core_Exception $e) {
|
209 |
+
$message['message'] = $e->getMessage();
|
210 |
+
$this->getResponse()->setBody(json_encode($message));
|
211 |
+
return;
|
212 |
+
} catch (Exception $e){
|
213 |
+
$message['message'] = $e->getMessage();
|
214 |
+
$this->getResponse()->setBody(json_encode($message));
|
215 |
+
return;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
public function savetokenAction()
|
220 |
+
{
|
221 |
+
$req = $this->getRequest();
|
222 |
+
|
223 |
+
$customerId = $req->getParam('customer_id');
|
224 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
225 |
+
Mage::register('current_customer', $customer);
|
226 |
+
$message = array(
|
227 |
+
'message' => $this->__('Invalid request'),
|
228 |
+
'success' => false
|
229 |
+
);
|
230 |
+
// Check load access code
|
231 |
+
$accessCode = $req->getParam('AccessCode');
|
232 |
+
$ccType = $req->getParam('ccType');
|
233 |
+
$expYear = $req->getParam('expYear');
|
234 |
+
$tokenId = $req->getParam('token_id');
|
235 |
+
|
236 |
+
if (isset($accessCode)) {
|
237 |
+
$apiRequest = Mage::getModel('ewayrapid/request_token');
|
238 |
+
// Retrieve data card by token key to save information
|
239 |
+
$result = $apiRequest->getInfoByAccessCode($accessCode);
|
240 |
+
$data = $result->getData();
|
241 |
+
|
242 |
+
$tokenCustomerId = $data['TokenCustomerID'];
|
243 |
+
|
244 |
+
/**
|
245 |
+
* TEST TOKEN ID NULL
|
246 |
+
*/
|
247 |
+
//$token_customer_id = null;
|
248 |
+
/**
|
249 |
+
* END TEST
|
250 |
+
*/
|
251 |
+
|
252 |
+
if (isset($tokenCustomerId) && !empty($tokenCustomerId)) {
|
253 |
+
$apiRequest = Mage::getModel('ewayrapid/request_token');
|
254 |
+
$street1 = $req->getParam('street1');
|
255 |
+
$street2 = $req->getParam('street2');
|
256 |
+
$cardData = array(
|
257 |
+
'token' => $tokenCustomerId,
|
258 |
+
'ccType' => $ccType,
|
259 |
+
'expYear' => $expYear,
|
260 |
+
'token_id' => $tokenId,
|
261 |
+
'startMonth' => $req->getParam('startMonth'),
|
262 |
+
'startYear' => $req->getParam('startYear'),
|
263 |
+
'issueNumber' => $req->getParam('issueNumber'),
|
264 |
+
'street1' => $street1,
|
265 |
+
'street2' => $street2
|
266 |
+
);
|
267 |
+
// Retrieve data card by token key and save information
|
268 |
+
$apiRequest->saveInfoByTokenId($cardData);
|
269 |
+
if ($req->getParam('is_default')) {
|
270 |
+
Mage::helper('ewayrapid/customer')->setDefaultToken($tokenId ? $tokenId : Mage::helper('ewayrapid/customer')->getLastTokenId());
|
271 |
+
}
|
272 |
+
$this->loadLayout();
|
273 |
+
$this->renderLayout();
|
274 |
+
return;
|
275 |
+
|
276 |
+
} else {
|
277 |
+
// If error, it will be showed message ERR-002
|
278 |
+
$message['message'] = $this->__('Failed to update Credit Card. Please try again later.');
|
279 |
+
$this->getResponse()->setBody(json_encode($message));
|
280 |
+
}
|
281 |
+
}
|
282 |
+
$this->getResponse()->setBody(json_encode($message));
|
283 |
+
return;
|
284 |
+
}
|
285 |
+
/**
|
286 |
+
* Generate params to post to eWAY gateway to create new token.
|
287 |
+
*
|
288 |
+
* @param Array $params
|
289 |
+
* @return array
|
290 |
+
*/
|
291 |
+
protected function _generateApiParams($params)
|
292 |
+
{
|
293 |
+
$billingAddress = Mage::getModel('customer/address');
|
294 |
+
$billingAddress->addData($params['address']);
|
295 |
+
$errors = $billingAddress->validate();
|
296 |
+
if ($errors !== true && is_array($errors)) {
|
297 |
+
Mage::throwException(implode("\n", $errors));
|
298 |
+
}
|
299 |
+
if ($params && isset($params['payment'])) {
|
300 |
+
$infoInstance = new Varien_Object($params['payment']);
|
301 |
+
} else {
|
302 |
+
$infoInstance = new Varien_Object();
|
303 |
+
}
|
304 |
+
|
305 |
+
return array($billingAddress, $infoInstance);
|
306 |
+
}
|
307 |
}
|
app/code/community/Eway/Rapid31/controllers/Adminhtml/Sales/Order/CreateController.php
CHANGED
@@ -1,303 +1,322 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*/
|
4 |
-
require_once 'Mage/Adminhtml/controllers/Sales/Order/CreateController.php';
|
5 |
-
|
6 |
-
|
7 |
-
class Eway_Rapid31_Adminhtml_Sales_Order_CreateController extends Mage_Adminhtml_Sales_Order_CreateController
|
8 |
-
{
|
9 |
-
/**
|
10 |
-
* @var Eway_Rapid31_Model_Request_Sharedpage
|
11 |
-
*/
|
12 |
-
protected $_checkout = null;
|
13 |
-
|
14 |
-
protected $_checkoutType = 'ewayrapid/request_sharedpage';
|
15 |
-
|
16 |
-
protected function _isAllowed()
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$
|
24 |
-
|
25 |
-
|
26 |
-
$this->_getSession()->
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
| Mage_Payment_Model_Method_Abstract::
|
33 |
-
| Mage_Payment_Model_Method_Abstract::
|
34 |
-
| Mage_Payment_Model_Method_Abstract::
|
35 |
-
|
36 |
-
$this->_getOrderCreateModel()->
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
'
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
$
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
$
|
107 |
-
$
|
108 |
-
|
109 |
-
)
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
->
|
162 |
-
|
163 |
-
|
164 |
-
->
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
$this->
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
} catch (
|
197 |
-
$this->
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
$
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
$
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
$response = $this->_checkout->
|
269 |
-
|
270 |
-
// Get Fraud Information
|
271 |
-
if($response->isSuccess()){
|
272 |
-
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
273 |
-
if($transaction) {
|
274 |
-
$fraudAction = $transaction[0]['FraudAction'];
|
275 |
-
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
276 |
-
$captured = $transaction[0]['TransactionCaptured'];
|
277 |
-
unset($transaction);
|
278 |
-
}
|
279 |
-
}
|
280 |
-
}
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
$response->
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*/
|
4 |
+
require_once 'Mage/Adminhtml/controllers/Sales/Order/CreateController.php';
|
5 |
+
|
6 |
+
|
7 |
+
class Eway_Rapid31_Adminhtml_Sales_Order_CreateController extends Mage_Adminhtml_Sales_Order_CreateController
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* @var Eway_Rapid31_Model_Request_Sharedpage
|
11 |
+
*/
|
12 |
+
protected $_checkout = null;
|
13 |
+
|
14 |
+
protected $_checkoutType = 'ewayrapid/request_sharedpage';
|
15 |
+
|
16 |
+
protected function _isAllowed()
|
17 |
+
{
|
18 |
+
return true;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function ewayIframeAction()
|
22 |
+
{
|
23 |
+
$this->_processActionData('save');
|
24 |
+
$postData = $this->getRequest()->getPost('order');
|
25 |
+
|
26 |
+
$this->_getSession()->unsetData('iframePostQuote');
|
27 |
+
$this->_getSession()->setData('iframePostQuote', $postData);
|
28 |
+
|
29 |
+
$paymentData = $this->getRequest()->getPost('payment');
|
30 |
+
if ($paymentData) {
|
31 |
+
$paymentData['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_INTERNAL
|
32 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY
|
33 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY
|
34 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX
|
35 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;
|
36 |
+
$this->_getOrderCreateModel()->setPaymentData($paymentData);
|
37 |
+
$this->_getOrderCreateModel()->getQuote()->getPayment()->addData($paymentData);
|
38 |
+
}
|
39 |
+
$quote = $this->_getOrderCreateModel()->getQuote();
|
40 |
+
|
41 |
+
try {
|
42 |
+
$checkout = Mage::getSingleton(
|
43 |
+
$this->_checkoutType, array(
|
44 |
+
'quote' => $quote
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
$redirectUrl = $this->getUrl('*/*/ewaysaveiframeorder');
|
49 |
+
//Init AccessCode
|
50 |
+
$data = $checkout->createAccessCode($redirectUrl, Mage::getUrl('*/*/cancel', array('_secure' => true)));
|
51 |
+
|
52 |
+
$redirectParams = array(
|
53 |
+
'AccessCode' => $data->getAccessCode()
|
54 |
+
);
|
55 |
+
|
56 |
+
//New/Edit or not saved token
|
57 |
+
$savedToken = $paymentData['saved_token'];
|
58 |
+
$saveCard = (isset($paymentData['save_card']) ? $paymentData['save_card'] : '');
|
59 |
+
|
60 |
+
if ($savedToken && is_numeric($savedToken)) {
|
61 |
+
$redirectParams['saved_token'] = $savedToken;
|
62 |
+
} elseif ($saveCard) {
|
63 |
+
$redirectParams['newToken'] = 1;
|
64 |
+
}
|
65 |
+
|
66 |
+
$redirectUrl = $this->getUrl('*/*/ewaysaveiframeorder', $redirectParams);
|
67 |
+
$result = array(
|
68 |
+
'success' => false,
|
69 |
+
'message' => '',
|
70 |
+
'url' => '',
|
71 |
+
'returnUrl' => $redirectUrl
|
72 |
+
);
|
73 |
+
|
74 |
+
if ($data->isSuccess()) {
|
75 |
+
//Mage::getSingleton('core/session')->setData('FormActionURL', $data->getFormActionURL());
|
76 |
+
if ($data->getSharedPaymentUrl()) {
|
77 |
+
$result['url'] = $data->getSharedPaymentUrl();
|
78 |
+
$result['success'] = true;
|
79 |
+
$this->getResponse()->setBody(json_encode($result));
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
} else {
|
83 |
+
$result['message'] = Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: ' . $data->getMessage() . ')');
|
84 |
+
$this->getResponse()->setBody(json_encode($result));
|
85 |
+
return;
|
86 |
+
}
|
87 |
+
} catch (Exception $e) {
|
88 |
+
$result['message'] = Mage::helper('ewayrapid')->__($e->getMessage());
|
89 |
+
$this->getResponse()->setBody(json_encode($result));
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
public function ewaySaveIframeOrderAction()
|
96 |
+
{
|
97 |
+
try {
|
98 |
+
$newToken = $this->getRequest()->getParam('newToken');
|
99 |
+
$editToken = $this->getRequest()->getParam('saved_token');
|
100 |
+
$accessCode = $this->getRequest()->getParam('AccessCode');
|
101 |
+
|
102 |
+
$orderModel = $this->_getOrderCreateModel()
|
103 |
+
->setIsValidate(true)
|
104 |
+
->importPostData($this->_getSession()->getData('iframePostQuote'));
|
105 |
+
|
106 |
+
$beagleScore = 0;
|
107 |
+
$beagleVerification = array();
|
108 |
+
|
109 |
+
$quote = $orderModel->getQuote();
|
110 |
+
$this->_checkout = $this->_checkout = Mage::getSingleton(
|
111 |
+
$this->_checkoutType, array(
|
112 |
+
'quote' => $quote
|
113 |
+
)
|
114 |
+
);
|
115 |
+
|
116 |
+
$response = $this->_checkout->getInfoByAccessCode($accessCode);
|
117 |
+
// Get Fraud Information
|
118 |
+
if ($response->isSuccess()) {
|
119 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
120 |
+
if ($transaction) {
|
121 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
122 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
123 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
124 |
+
unset($transaction);
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($response->getData('BeagleVerification')) {
|
129 |
+
$beagleVerification = $response->getData('BeagleVerification');
|
130 |
+
}
|
131 |
+
if ($response->getData('BeagleScore') && $response->getData('BeagleScore') > 0) {
|
132 |
+
$beagleScore = $response->getData('BeagleScore');
|
133 |
+
}
|
134 |
+
|
135 |
+
if ($newToken || $editToken) {
|
136 |
+
if ($response->getTokenCustomerID()) {
|
137 |
+
$response = $this->_checkout->saveTokenById($response, $editToken);
|
138 |
+
$response = $this->_processPayment($response);
|
139 |
+
if ($response->getData('BeagleVerification')) {
|
140 |
+
$beagleVerification = $response->getData('BeagleVerification');
|
141 |
+
}
|
142 |
+
if ($response->getData('BeagleScore') && $response->getData('BeagleScore') > 0) {
|
143 |
+
$beagleScore = $response->getData('BeagleScore');
|
144 |
+
}
|
145 |
+
} else {
|
146 |
+
Mage::throwException(
|
147 |
+
Mage::helper('ewayrapid')->__(
|
148 |
+
'An error occurred while making the transaction. Please try again. (Error message: %s)',
|
149 |
+
$response->getMessage()
|
150 |
+
)
|
151 |
+
);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
if ($response->isSuccess()) {
|
155 |
+
|
156 |
+
// Save fraud information
|
157 |
+
if (is_null($fraudAction)) {
|
158 |
+
$fraudAction = $response->getFraudAction();
|
159 |
+
}
|
160 |
+
if (is_null($fraudCodes)) {
|
161 |
+
$fraudCodes = $response->getFraudCodes();
|
162 |
+
}
|
163 |
+
if (is_null($captured)) {
|
164 |
+
$captured = $response->getTransactionCaptured();
|
165 |
+
}
|
166 |
+
|
167 |
+
$beagleScore = $beagleScore ? $beagleScore : '';
|
168 |
+
$orderModel->getQuote()->getPayment()
|
169 |
+
->setAdditionalInformation('successType', 'success')
|
170 |
+
->setBeagleScore($beagleScore)
|
171 |
+
->setBeagleVerification(serialize($beagleVerification))
|
172 |
+
->setFraudAction($fraudAction)
|
173 |
+
->setFraudCodes($fraudCodes)
|
174 |
+
->setTransactionCaptured($captured);
|
175 |
+
|
176 |
+
Mage::getSingleton('core/session')->setData('ewayTransactionID', $response->getTransactionID());
|
177 |
+
} else {
|
178 |
+
Mage::throwException(
|
179 |
+
Mage::helper('ewayrapid')->__(
|
180 |
+
'Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.',
|
181 |
+
$response->getMessage()
|
182 |
+
)
|
183 |
+
);
|
184 |
+
}
|
185 |
+
|
186 |
+
$order = $orderModel->createOrder();
|
187 |
+
$order->setEwayTransactionId($response->getTransactionID());
|
188 |
+
$order->save();
|
189 |
+
$this->_getSession()->clear();
|
190 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The order has been created.'));
|
191 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
192 |
+
$this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
|
193 |
+
} else {
|
194 |
+
$this->_redirect('*/sales_order/index');
|
195 |
+
}
|
196 |
+
} catch (Mage_Payment_Model_Info_Exception $e) {
|
197 |
+
$this->_getOrderCreateModel()->saveQuote();
|
198 |
+
$message = $e->getMessage();
|
199 |
+
if (!empty($message)) {
|
200 |
+
$this->_getSession()->addError($message);
|
201 |
+
}
|
202 |
+
$this->_redirect('*/*/');
|
203 |
+
} catch (Mage_Core_Exception $e) {
|
204 |
+
$message = $e->getMessage();
|
205 |
+
if (!empty($message)) {
|
206 |
+
$this->_getSession()->addError($message);
|
207 |
+
}
|
208 |
+
$this->_redirect('*/*/');
|
209 |
+
} catch (Exception $e) {
|
210 |
+
$this->_getSession()->addException($e, $this->__('Order saving error: %s', $e->getMessage()));
|
211 |
+
$this->_redirect('*/*/');
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* process Payment: authorize only or authorize & capture
|
217 |
+
*
|
218 |
+
* @param Eway_Rapid31_Model_Response $response
|
219 |
+
* @return Eway_Rapid31_Model_Response
|
220 |
+
* @throws Mage_Core_Exception
|
221 |
+
*/
|
222 |
+
protected function _processPayment(Eway_Rapid31_Model_Response $response)
|
223 |
+
{
|
224 |
+
$this->_initCheckout();
|
225 |
+
|
226 |
+
$cardData = $response->getCustomer();
|
227 |
+
|
228 |
+
if ($cardData['CardNumber'] && $cardData['CardName']) {
|
229 |
+
$response = $this->_checkout->doAuthorisation($response);
|
230 |
+
$beagleScore = $response->getBeagleScore();
|
231 |
+
|
232 |
+
// Get Fraud Information
|
233 |
+
if ($response->isSuccess()) {
|
234 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
235 |
+
if ($transaction) {
|
236 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
237 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
238 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
239 |
+
unset($transaction);
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
if ($response->isSuccess()
|
244 |
+
&& Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE
|
245 |
+
) {
|
246 |
+
$response = $this->_checkout->doCapturePayment($response);
|
247 |
+
|
248 |
+
// Reload Fraud Information
|
249 |
+
if ($response->isSuccess()) {
|
250 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
251 |
+
if ($transaction) {
|
252 |
+
if ($transaction[0]['FraudAction']) {
|
253 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
254 |
+
}
|
255 |
+
if (Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage'])) {
|
256 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
257 |
+
}
|
258 |
+
if ($transaction[0]['TransactionCaptured']) {
|
259 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
260 |
+
}
|
261 |
+
unset($transaction);
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
}
|
266 |
+
} else {
|
267 |
+
if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
|
268 |
+
$response = $this->_checkout->doAuthorisation($response);
|
269 |
+
|
270 |
+
// Get Fraud Information
|
271 |
+
if ($response->isSuccess()) {
|
272 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
273 |
+
if ($transaction) {
|
274 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
275 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
276 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
277 |
+
unset($transaction);
|
278 |
+
}
|
279 |
+
}
|
280 |
+
} elseif (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
281 |
+
$response = $this->_checkout->doTransaction($response);
|
282 |
+
|
283 |
+
// Get Fraud Information
|
284 |
+
if ($response->isSuccess()) {
|
285 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
286 |
+
if ($transaction) {
|
287 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
288 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
289 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
290 |
+
unset($transaction);
|
291 |
+
}
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
295 |
+
if (!$response->isSuccess()) {
|
296 |
+
Mage::throwException(
|
297 |
+
Mage::helper('ewayrapid')->__(
|
298 |
+
'Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.',
|
299 |
+
$response->getMessage()
|
300 |
+
)
|
301 |
+
);
|
302 |
+
}
|
303 |
+
|
304 |
+
if ($response->getBeagleScore() === null) {
|
305 |
+
$response->setBeagleScore($beagleScore);
|
306 |
+
}
|
307 |
+
$response->setFraudAction($fraudAction);
|
308 |
+
$response->setFraudCodes($fraudCodes);
|
309 |
+
$response->setTransactionCaptured($captured);
|
310 |
+
return $response;
|
311 |
+
}
|
312 |
+
|
313 |
+
private function _initCheckout()
|
314 |
+
{
|
315 |
+
$quote = $this->_getOrderCreateModel()->getQuote();
|
316 |
+
$this->_checkout = Mage::getSingleton(
|
317 |
+
$this->_checkoutType, array(
|
318 |
+
'quote' => $quote
|
319 |
+
)
|
320 |
+
);
|
321 |
+
}
|
322 |
}
|
app/code/community/Eway/Rapid31/controllers/MycardsController.php
CHANGED
@@ -1,402 +1,408 @@
|
|
1 |
-
<?php
|
2 |
-
class Eway_Rapid31_MycardsController extends Mage_Core_Controller_Front_Action
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Action predispatch
|
6 |
-
*
|
7 |
-
* Check customer authentication
|
8 |
-
*/
|
9 |
-
public function preDispatch()
|
10 |
-
{
|
11 |
-
parent::preDispatch();
|
12 |
-
$loginUrl = Mage::helper('customer')->getLoginUrl();
|
13 |
-
|
14 |
-
if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
|
15 |
-
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
16 |
-
}
|
17 |
-
}
|
18 |
-
|
19 |
-
protected function _getSession()
|
20 |
-
{
|
21 |
-
return Mage::getSingleton('customer/session');
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* List all active tokens of current logged in customer
|
26 |
-
*/
|
27 |
-
public function indexAction()
|
28 |
-
{
|
29 |
-
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
30 |
-
$this->_getSession()->addError($this->__('This feature has been disabled. Please contact site owner.'));
|
31 |
-
}
|
32 |
-
|
33 |
-
$this->loadLayout();
|
34 |
-
$this->_initLayoutMessages('customer/session');
|
35 |
-
|
36 |
-
$this->getLayout()->getBlock('head')->setTitle($this->__('My Credit Cards'));
|
37 |
-
|
38 |
-
if ($block = $this->getLayout()->getBlock('customer.account.link.back')) {
|
39 |
-
if (Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
40 |
-
$block->setRefererUrl($this->_getRefererUrl());
|
41 |
-
} else {
|
42 |
-
$block->setRefererUrl(Mage::getUrl('customer/account/'));
|
43 |
-
}
|
44 |
-
}
|
45 |
-
/*$session = Mage::getSingleton("customer/session", array('name'=>'frontend'));
|
46 |
-
$customer = $session->getCustomer();
|
47 |
-
// $customer->setMarkFraud(1);
|
48 |
-
// $customer->save();
|
49 |
-
echo '<pre>';
|
50 |
-
print_r($customer->getData());
|
51 |
-
die();*/
|
52 |
-
|
53 |
-
$this->renderLayout();
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Display create new token screen. Do nothing, just forward to editAction
|
58 |
-
*/
|
59 |
-
public function newAction()
|
60 |
-
{
|
61 |
-
$this->_forward('edit');
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Display edit form for both create new/edit token
|
66 |
-
*/
|
67 |
-
public function editAction()
|
68 |
-
{
|
69 |
-
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
70 |
-
$this->_redirect('*/*/');
|
71 |
-
return;
|
72 |
-
}
|
73 |
-
|
74 |
-
$this->loadLayout();
|
75 |
-
$this->_initLayoutMessages('customer/session');
|
76 |
-
|
77 |
-
$tokenId = $this->getRequest()->getParam('token_id');
|
78 |
-
if (is_numeric($tokenId)) {
|
79 |
-
Mage::register('current_token', Mage::helper('ewayrapid/customer')->getTokenById($tokenId)->setTokenId($tokenId));
|
80 |
-
$this->getLayout()->getBlock('head')->setTitle($this->__('Edit Credit Card'));
|
81 |
-
} else {
|
82 |
-
$this->getLayout()->getBlock('head')->setTitle($this->__('Add New Credit Card'));
|
83 |
-
}
|
84 |
-
$navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
|
85 |
-
if ($navigationBlock) {
|
86 |
-
$navigationBlock->setActive('ewayrapid/mycards');
|
87 |
-
}
|
88 |
-
|
89 |
-
if ($block = $this->getLayout()->getBlock('customer.account.link.back')) {
|
90 |
-
$block->setRefererUrl($this->_getRefererUrl());
|
91 |
-
}
|
92 |
-
$this->renderLayout();
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Handle edit form saving
|
97 |
-
*/
|
98 |
-
public function saveAction()
|
99 |
-
{
|
100 |
-
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
101 |
-
$this->_redirect('*/*/');
|
102 |
-
return;
|
103 |
-
}
|
104 |
-
|
105 |
-
$request = $this->getRequest();
|
106 |
-
|
107 |
-
$apiRequest = Mage::getModel('ewayrapid/request_token');
|
108 |
-
try {
|
109 |
-
if (!$request->isPost() || !$request->getParam('address') || !$request->getParam('payment')) {
|
110 |
-
Mage::throwException($this->__('Invalid request'));
|
111 |
-
}
|
112 |
-
|
113 |
-
$tokenId = $request->getParam('token_id');
|
114 |
-
if (is_numeric($tokenId)) {
|
115 |
-
list($billingAddress, $infoInstance) = $this->_generateApiParams($request);
|
116 |
-
|
117 |
-
$infoInstance->setSavedToken($tokenId);
|
118 |
-
|
119 |
-
$apiRequest->updateToken($billingAddress, $infoInstance);
|
120 |
-
if ($request->getParam('is_default')) {
|
121 |
-
Mage::helper('ewayrapid/customer')->setDefaultToken($tokenId);
|
122 |
-
}
|
123 |
-
$this->_getSession()->addSuccess($this->__('Your Credit Card has been saved successfully.'));
|
124 |
-
$this->_redirect('*/*/');
|
125 |
-
} else if (!$tokenId) {
|
126 |
-
list($billingAddress, $infoInstance) = $this->_generateApiParams($request);
|
127 |
-
$apiRequest->createNewToken($billingAddress, $infoInstance);
|
128 |
-
if ($request->getParam('is_default')) {
|
129 |
-
Mage::helper('ewayrapid/customer')->setDefaultToken(Mage::helper('ewayrapid/customer')->getLastTokenId());
|
130 |
-
}
|
131 |
-
$this->_getSession()->addSuccess($this->__('Your Credit Card has been saved successfully.'));
|
132 |
-
$this->_redirect('*/*/');
|
133 |
-
} else {
|
134 |
-
Mage::throwException($this->__('Invalid token id'));
|
135 |
-
}
|
136 |
-
} catch (Mage_Core_Exception $e) {
|
137 |
-
Mage::logException($e);
|
138 |
-
$token = Mage::getModel('ewayrapid/customer_token');
|
139 |
-
$customerInfo = ($apiRequest->getCustomer() ? $apiRequest->getCustomer() : Mage::getModel('ewayrapid/field_customer'));
|
140 |
-
$token->setOwner($infoInstance->getCcOwner())
|
141 |
-
->setExpMonth($infoInstance->getCcExpMonth())
|
142 |
-
->setExpYear($infoInstance->getCcExpYear())
|
143 |
-
->setAddress($customerInfo);
|
144 |
-
if (is_numeric($tokenId)) {
|
145 |
-
$oldToken = Mage::helper('ewayrapid/customer')->getTokenById($tokenId);
|
146 |
-
$token->setToken($oldToken->getToken())
|
147 |
-
->setCard($oldToken->getCard())
|
148 |
-
->setTokenId($tokenId);
|
149 |
-
}
|
150 |
-
|
151 |
-
$this->_getSession()->setTokenInfo($token);
|
152 |
-
$this->_getSession()->addError($e->getMessage());
|
153 |
-
$params = is_numeric($tokenId) ? array('token_id' => $tokenId) : array();
|
154 |
-
$this->_redirect('*/*/edit', $params);
|
155 |
-
}
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Generate params to post to eWAY gateway to create new token.
|
160 |
-
*
|
161 |
-
* @param Mage_Core_Controller_Request_Http $request
|
162 |
-
* @return array
|
163 |
-
*/
|
164 |
-
protected function _generateApiParams($request)
|
165 |
-
{
|
166 |
-
$billingAddress = Mage::getModel('customer/address');
|
167 |
-
$billingAddress->addData($request->getParam('address'));
|
168 |
-
$errors = $billingAddress->validate();
|
169 |
-
if ($errors !== true && is_array($errors)) {
|
170 |
-
Mage::throwException(implode('<br/>', $errors));
|
171 |
-
}
|
172 |
-
$infoInstance = new Varien_Object($request->getParam('payment'));
|
173 |
-
return array($billingAddress, $infoInstance);
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Make current token inactive
|
178 |
-
*/
|
179 |
-
public function deleteAction()
|
180 |
-
{
|
181 |
-
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
182 |
-
$this->_redirect('*/*/');
|
183 |
-
return;
|
184 |
-
}
|
185 |
-
|
186 |
-
try {
|
187 |
-
$tokenId = $this->getRequest()->getParam('token_id');
|
188 |
-
if (is_numeric($tokenId)) {
|
189 |
-
Mage::helper('ewayrapid/customer')->deleteToken($tokenId);
|
190 |
-
$this->_getSession()->addSuccess($this->__('Your Credit Card has been deleted successfully.'));
|
191 |
-
$this->_redirect('*/*/');
|
192 |
-
} else {
|
193 |
-
Mage::throwException($this->__('Invalid token id'));
|
194 |
-
}
|
195 |
-
} catch (Mage_Core_Exception $e) {
|
196 |
-
Mage::logException($e);
|
197 |
-
$this->_getSession()->addError($e->getMessage());
|
198 |
-
$this->_redirect('*/*/');
|
199 |
-
}
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Set this token as default.
|
204 |
-
*/
|
205 |
-
public function setdefaultAction()
|
206 |
-
{
|
207 |
-
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
208 |
-
$this->_redirect('*/*/');
|
209 |
-
return;
|
210 |
-
}
|
211 |
-
|
212 |
-
try {
|
213 |
-
$tokenId = $this->getRequest()->getParam('token_id');
|
214 |
-
if (is_numeric($tokenId)) {
|
215 |
-
Mage::helper('ewayrapid/customer')->setDefaultToken($tokenId);
|
216 |
-
$this->_getSession()->addSuccess($this->__('Your Credit Card has been saved successfully.'));
|
217 |
-
$this->_redirect('*/*/');
|
218 |
-
} else {
|
219 |
-
Mage::throwException($this->__('Invalid token id'));
|
220 |
-
}
|
221 |
-
} catch (Mage_Core_Exception $e) {
|
222 |
-
Mage::logException($e);
|
223 |
-
$this->_getSession()->addError($e->getMessage());
|
224 |
-
$this->_redirect('*/*/');
|
225 |
-
}
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Get access code with transparent redirect or responsive shared page type
|
230 |
-
*/
|
231 |
-
public function getAccessCodeAction()
|
232 |
-
{
|
233 |
-
// Response data to client
|
234 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
235 |
-
|
236 |
-
// Enabled method save
|
237 |
-
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
238 |
-
//$this->_redirect('*/*/');
|
239 |
-
$this->getResponse()->setBody(
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
*
|
277 |
-
*
|
278 |
-
* "
|
279 |
-
* "
|
280 |
-
* "
|
281 |
-
* "
|
282 |
-
* "
|
283 |
-
* "
|
284 |
-
* "
|
285 |
-
* "
|
286 |
-
* "
|
287 |
-
* "
|
288 |
-
* "
|
289 |
-
* "
|
290 |
-
* "
|
291 |
-
* "
|
292 |
-
* "
|
293 |
-
* "
|
294 |
-
* "
|
295 |
-
* "
|
296 |
-
* "
|
297 |
-
* "
|
298 |
-
* "
|
299 |
-
*
|
300 |
-
*
|
301 |
-
*
|
302 |
-
*
|
303 |
-
*
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
$
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
'
|
377 |
-
'
|
378 |
-
'
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
//
|
387 |
-
$
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
}
|
1 |
+
<?php
|
2 |
+
class Eway_Rapid31_MycardsController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Action predispatch
|
6 |
+
*
|
7 |
+
* Check customer authentication
|
8 |
+
*/
|
9 |
+
public function preDispatch()
|
10 |
+
{
|
11 |
+
parent::preDispatch();
|
12 |
+
$loginUrl = Mage::helper('customer')->getLoginUrl();
|
13 |
+
|
14 |
+
if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
|
15 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _getSession()
|
20 |
+
{
|
21 |
+
return Mage::getSingleton('customer/session');
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* List all active tokens of current logged in customer
|
26 |
+
*/
|
27 |
+
public function indexAction()
|
28 |
+
{
|
29 |
+
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
30 |
+
$this->_getSession()->addError($this->__('This feature has been disabled. Please contact site owner.'));
|
31 |
+
}
|
32 |
+
|
33 |
+
$this->loadLayout();
|
34 |
+
$this->_initLayoutMessages('customer/session');
|
35 |
+
|
36 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('My Credit Cards'));
|
37 |
+
|
38 |
+
if ($block = $this->getLayout()->getBlock('customer.account.link.back')) {
|
39 |
+
if (Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
40 |
+
$block->setRefererUrl($this->_getRefererUrl());
|
41 |
+
} else {
|
42 |
+
$block->setRefererUrl(Mage::getUrl('customer/account/'));
|
43 |
+
}
|
44 |
+
}
|
45 |
+
/*$session = Mage::getSingleton("customer/session", array('name'=>'frontend'));
|
46 |
+
$customer = $session->getCustomer();
|
47 |
+
// $customer->setMarkFraud(1);
|
48 |
+
// $customer->save();
|
49 |
+
echo '<pre>';
|
50 |
+
print_r($customer->getData());
|
51 |
+
die();*/
|
52 |
+
|
53 |
+
$this->renderLayout();
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Display create new token screen. Do nothing, just forward to editAction
|
58 |
+
*/
|
59 |
+
public function newAction()
|
60 |
+
{
|
61 |
+
$this->_forward('edit');
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Display edit form for both create new/edit token
|
66 |
+
*/
|
67 |
+
public function editAction()
|
68 |
+
{
|
69 |
+
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
70 |
+
$this->_redirect('*/*/');
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
$this->loadLayout();
|
75 |
+
$this->_initLayoutMessages('customer/session');
|
76 |
+
|
77 |
+
$tokenId = $this->getRequest()->getParam('token_id');
|
78 |
+
if (is_numeric($tokenId)) {
|
79 |
+
Mage::register('current_token', Mage::helper('ewayrapid/customer')->getTokenById($tokenId)->setTokenId($tokenId));
|
80 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('Edit Credit Card'));
|
81 |
+
} else {
|
82 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('Add New Credit Card'));
|
83 |
+
}
|
84 |
+
$navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
|
85 |
+
if ($navigationBlock) {
|
86 |
+
$navigationBlock->setActive('ewayrapid/mycards');
|
87 |
+
}
|
88 |
+
|
89 |
+
if ($block = $this->getLayout()->getBlock('customer.account.link.back')) {
|
90 |
+
$block->setRefererUrl($this->_getRefererUrl());
|
91 |
+
}
|
92 |
+
$this->renderLayout();
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Handle edit form saving
|
97 |
+
*/
|
98 |
+
public function saveAction()
|
99 |
+
{
|
100 |
+
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
101 |
+
$this->_redirect('*/*/');
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
|
105 |
+
$request = $this->getRequest();
|
106 |
+
|
107 |
+
$apiRequest = Mage::getModel('ewayrapid/request_token');
|
108 |
+
try {
|
109 |
+
if (!$request->isPost() || !$request->getParam('address') || !$request->getParam('payment')) {
|
110 |
+
Mage::throwException($this->__('Invalid request'));
|
111 |
+
}
|
112 |
+
|
113 |
+
$tokenId = $request->getParam('token_id');
|
114 |
+
if (is_numeric($tokenId)) {
|
115 |
+
list($billingAddress, $infoInstance) = $this->_generateApiParams($request);
|
116 |
+
|
117 |
+
$infoInstance->setSavedToken($tokenId);
|
118 |
+
|
119 |
+
$apiRequest->updateToken($billingAddress, $infoInstance);
|
120 |
+
if ($request->getParam('is_default')) {
|
121 |
+
Mage::helper('ewayrapid/customer')->setDefaultToken($tokenId);
|
122 |
+
}
|
123 |
+
$this->_getSession()->addSuccess($this->__('Your Credit Card has been saved successfully.'));
|
124 |
+
$this->_redirect('*/*/');
|
125 |
+
} else if (!$tokenId) {
|
126 |
+
list($billingAddress, $infoInstance) = $this->_generateApiParams($request);
|
127 |
+
$apiRequest->createNewToken($billingAddress, $infoInstance);
|
128 |
+
if ($request->getParam('is_default')) {
|
129 |
+
Mage::helper('ewayrapid/customer')->setDefaultToken(Mage::helper('ewayrapid/customer')->getLastTokenId());
|
130 |
+
}
|
131 |
+
$this->_getSession()->addSuccess($this->__('Your Credit Card has been saved successfully.'));
|
132 |
+
$this->_redirect('*/*/');
|
133 |
+
} else {
|
134 |
+
Mage::throwException($this->__('Invalid token id'));
|
135 |
+
}
|
136 |
+
} catch (Mage_Core_Exception $e) {
|
137 |
+
Mage::logException($e);
|
138 |
+
$token = Mage::getModel('ewayrapid/customer_token');
|
139 |
+
$customerInfo = ($apiRequest->getCustomer() ? $apiRequest->getCustomer() : Mage::getModel('ewayrapid/field_customer'));
|
140 |
+
$token->setOwner($infoInstance->getCcOwner())
|
141 |
+
->setExpMonth($infoInstance->getCcExpMonth())
|
142 |
+
->setExpYear($infoInstance->getCcExpYear())
|
143 |
+
->setAddress($customerInfo);
|
144 |
+
if (is_numeric($tokenId)) {
|
145 |
+
$oldToken = Mage::helper('ewayrapid/customer')->getTokenById($tokenId);
|
146 |
+
$token->setToken($oldToken->getToken())
|
147 |
+
->setCard($oldToken->getCard())
|
148 |
+
->setTokenId($tokenId);
|
149 |
+
}
|
150 |
+
|
151 |
+
$this->_getSession()->setTokenInfo($token);
|
152 |
+
$this->_getSession()->addError($e->getMessage());
|
153 |
+
$params = is_numeric($tokenId) ? array('token_id' => $tokenId) : array();
|
154 |
+
$this->_redirect('*/*/edit', $params);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Generate params to post to eWAY gateway to create new token.
|
160 |
+
*
|
161 |
+
* @param Mage_Core_Controller_Request_Http $request
|
162 |
+
* @return array
|
163 |
+
*/
|
164 |
+
protected function _generateApiParams($request)
|
165 |
+
{
|
166 |
+
$billingAddress = Mage::getModel('customer/address');
|
167 |
+
$billingAddress->addData($request->getParam('address'));
|
168 |
+
$errors = $billingAddress->validate();
|
169 |
+
if ($errors !== true && is_array($errors)) {
|
170 |
+
Mage::throwException(implode('<br/>', $errors));
|
171 |
+
}
|
172 |
+
$infoInstance = new Varien_Object($request->getParam('payment'));
|
173 |
+
return array($billingAddress, $infoInstance);
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Make current token inactive
|
178 |
+
*/
|
179 |
+
public function deleteAction()
|
180 |
+
{
|
181 |
+
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
182 |
+
$this->_redirect('*/*/');
|
183 |
+
return;
|
184 |
+
}
|
185 |
+
|
186 |
+
try {
|
187 |
+
$tokenId = $this->getRequest()->getParam('token_id');
|
188 |
+
if (is_numeric($tokenId)) {
|
189 |
+
Mage::helper('ewayrapid/customer')->deleteToken($tokenId);
|
190 |
+
$this->_getSession()->addSuccess($this->__('Your Credit Card has been deleted successfully.'));
|
191 |
+
$this->_redirect('*/*/');
|
192 |
+
} else {
|
193 |
+
Mage::throwException($this->__('Invalid token id'));
|
194 |
+
}
|
195 |
+
} catch (Mage_Core_Exception $e) {
|
196 |
+
Mage::logException($e);
|
197 |
+
$this->_getSession()->addError($e->getMessage());
|
198 |
+
$this->_redirect('*/*/');
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Set this token as default.
|
204 |
+
*/
|
205 |
+
public function setdefaultAction()
|
206 |
+
{
|
207 |
+
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
208 |
+
$this->_redirect('*/*/');
|
209 |
+
return;
|
210 |
+
}
|
211 |
+
|
212 |
+
try {
|
213 |
+
$tokenId = $this->getRequest()->getParam('token_id');
|
214 |
+
if (is_numeric($tokenId)) {
|
215 |
+
Mage::helper('ewayrapid/customer')->setDefaultToken($tokenId);
|
216 |
+
$this->_getSession()->addSuccess($this->__('Your Credit Card has been saved successfully.'));
|
217 |
+
$this->_redirect('*/*/');
|
218 |
+
} else {
|
219 |
+
Mage::throwException($this->__('Invalid token id'));
|
220 |
+
}
|
221 |
+
} catch (Mage_Core_Exception $e) {
|
222 |
+
Mage::logException($e);
|
223 |
+
$this->_getSession()->addError($e->getMessage());
|
224 |
+
$this->_redirect('*/*/');
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Get access code with transparent redirect or responsive shared page type
|
230 |
+
*/
|
231 |
+
public function getAccessCodeAction()
|
232 |
+
{
|
233 |
+
// Response data to client
|
234 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
235 |
+
|
236 |
+
// Enabled method save
|
237 |
+
if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
|
238 |
+
//$this->_redirect('*/*/');
|
239 |
+
$this->getResponse()->setBody(
|
240 |
+
json_encode(
|
241 |
+
array(
|
242 |
+
'msg' => 'Access denied!'
|
243 |
+
)
|
244 |
+
)
|
245 |
+
);
|
246 |
+
return;
|
247 |
+
}
|
248 |
+
|
249 |
+
// Check session timeout
|
250 |
+
$session = Mage::getSingleton('customer/session', array('name' => 'frontend'));
|
251 |
+
if (!$session->isLoggedIn()) {
|
252 |
+
$this->getResponse()->setBody(
|
253 |
+
json_encode(
|
254 |
+
array('login' => false)
|
255 |
+
)
|
256 |
+
);
|
257 |
+
return;
|
258 |
+
}
|
259 |
+
|
260 |
+
$method = 'AccessCodes';
|
261 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
262 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE ||
|
263 |
+
Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
264 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
265 |
+
) {
|
266 |
+
$method = 'AccessCodesShared';
|
267 |
+
}
|
268 |
+
|
269 |
+
$request = $this->getRequest();
|
270 |
+
|
271 |
+
$apiRequest = Mage::getModel('ewayrapid/request_token');
|
272 |
+
list($billingAddress, $infoInstance) = $this->_generateApiParams($request);
|
273 |
+
$data = $apiRequest->createAccessCode($billingAddress, $infoInstance, $method, $request);
|
274 |
+
|
275 |
+
/*
|
276 |
+
* {"AccessCode":"C3AB9RIc_reC_FRm8nXsy36QddJm_-YlaZCc2ZHuhbOeR5RzX682kfgl_12-vipFpJiuPPcOyh-ToeWP--Px06J04mW1zhqKpyqRTsvz0ub9-URgih4V_rHDYoNxQHXq9Ho2l",
|
277 |
+
* "Customer":{
|
278 |
+
* "CardNumber":"",
|
279 |
+
* "CardStartMonth":"",
|
280 |
+
* "CardStartYear":"",
|
281 |
+
* "CardIssueNumber":"",
|
282 |
+
* "CardName":"",
|
283 |
+
* "CardExpiryMonth":"",
|
284 |
+
* "CardExpiryYear":"",
|
285 |
+
* "IsActive":false,
|
286 |
+
* "TokenCustomerID":null,
|
287 |
+
* "Reference":"",
|
288 |
+
* "Title":"Mr.",
|
289 |
+
* "FirstName":"binh",
|
290 |
+
* "LastName":"nguyen",
|
291 |
+
* "CompanyName":"aaaaaa",
|
292 |
+
* "JobDescription":"job",
|
293 |
+
* "Street1":"Product Attributes",
|
294 |
+
* "Street2":"def",
|
295 |
+
* "City":"city here",
|
296 |
+
* "State":"123",
|
297 |
+
* "PostalCode":"1234",
|
298 |
+
* "Country":"as",
|
299 |
+
* "Email":"4444ddd@gmail.com",
|
300 |
+
* "Phone":"0987654321",
|
301 |
+
* "Mobile":"4444444444",
|
302 |
+
* "Comments":"",
|
303 |
+
* "Fax":"4535343",
|
304 |
+
* "Url":""
|
305 |
+
* },
|
306 |
+
* "Payment":{"TotalAmount":0,"InvoiceNumber":null,"InvoiceDescription":null,"InvoiceReference":null,"CurrencyCode":"AUD"},
|
307 |
+
* "FormActionURL":"https:\/\/secure-au.sandbox.ewaypayments.com\/AccessCode\/C3AB9RIc_reC_FRm8nXsy36QddJm_-YlaZCc2ZHuhbOeR5RzX682kfgl_12-vipFpJiuPPcOyh-ToeWP--Px06J04mW1zhqKpyqRTsvz0ub9-URgih4V_rHDYoNxQHXq9Ho2l",
|
308 |
+
* "CompleteCheckoutURL":null,
|
309 |
+
* "Errors":null}
|
310 |
+
*/
|
311 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
312 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
|
313 |
+
) {
|
314 |
+
$data = $data->getData();
|
315 |
+
return $this->_redirectUrl($data['SharedPaymentUrl']);
|
316 |
+
}
|
317 |
+
|
318 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
319 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME
|
320 |
+
) {
|
321 |
+
$redirectUrl = $apiRequest->getRedirectUrl();
|
322 |
+
|
323 |
+
$redirectUrl = Mage::getModel('core/url')->parseUrl($redirectUrl)
|
324 |
+
->setQueryParam('AccessCode', $data->getAccessCode());
|
325 |
+
|
326 |
+
$redirectUrl = Mage::getUrl('*/*/saveToken', $redirectUrl->getQueryParams());
|
327 |
+
|
328 |
+
$data->setReturnUrl($redirectUrl);
|
329 |
+
}
|
330 |
+
|
331 |
+
$data = json_encode($data->getData());
|
332 |
+
$this->getResponse()->setBody($data);
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Save or update token with Transparent or Shared page
|
337 |
+
*/
|
338 |
+
public function saveTokenAction()
|
339 |
+
{
|
340 |
+
|
341 |
+
// Check session timeout
|
342 |
+
$session = Mage::getSingleton('customer/session', array('name' => 'frontend'));
|
343 |
+
if (!$session->isLoggedIn()) {
|
344 |
+
$this->_redirect('*/*/');
|
345 |
+
return;
|
346 |
+
}
|
347 |
+
|
348 |
+
$req = $this->getRequest();
|
349 |
+
// Check load access code
|
350 |
+
$accessCode = $req->get('AccessCode');
|
351 |
+
$ccType = $req->get('ccType');
|
352 |
+
$expYear = $req->get('expYear');
|
353 |
+
$tokenId = $req->get('token_id');
|
354 |
+
|
355 |
+
if (isset($accessCode)) {
|
356 |
+
$apiRequest = Mage::getModel('ewayrapid/request_token');
|
357 |
+
// Retrieve data card by token key to save information
|
358 |
+
$result = $apiRequest->getInfoByAccessCode($accessCode);
|
359 |
+
$data = $result->getData();
|
360 |
+
|
361 |
+
$tokenCustomerId = $data['TokenCustomerID'];
|
362 |
+
|
363 |
+
/**
|
364 |
+
* TEST TOKEN ID NULL
|
365 |
+
*/
|
366 |
+
//$token_customer_id = null;
|
367 |
+
/**
|
368 |
+
* END TEST
|
369 |
+
*/
|
370 |
+
|
371 |
+
if (isset($tokenCustomerId) && !empty($tokenCustomerId)) {
|
372 |
+
$apiRequest = Mage::getModel('ewayrapid/request_token');
|
373 |
+
$street1 = $req->get('street1');
|
374 |
+
$street2 = $req->get('street2');
|
375 |
+
$cardData = array(
|
376 |
+
'token' => $tokenCustomerId,
|
377 |
+
'ccType' => $ccType,
|
378 |
+
'expYear' => $expYear,
|
379 |
+
'token_id' => $tokenId,
|
380 |
+
'startMonth' => $req->get('startMonth'),
|
381 |
+
'startYear' => $req->get('startYear'),
|
382 |
+
'issueNumber' => $req->get('issueNumber'),
|
383 |
+
'street1' => base64_decode($street1),
|
384 |
+
'street2' => base64_decode($street2)
|
385 |
+
);
|
386 |
+
// Retrieve data card by token key and save information
|
387 |
+
$apiRequest->saveInfoByTokenId($cardData);
|
388 |
+
if ($req->getParam('is_default')) {
|
389 |
+
//Mage::helper('ewayrapid/customer')->getLastTokenId()
|
390 |
+
Mage::helper('ewayrapid/customer')->setDefaultToken($tokenId ? $tokenId : Mage::helper('ewayrapid/customer')->getLastTokenId());
|
391 |
+
}
|
392 |
+
// Add flash message
|
393 |
+
$this->_getSession()->addSuccess($this->__('Your Credit Card has been saved successfully.'));
|
394 |
+
} else {
|
395 |
+
// If error, it will be showed message ERR-002
|
396 |
+
$this->_getSession()->addError($this->__('Failed to update Credit Card. Please try again later.'));
|
397 |
+
}
|
398 |
+
$this->_redirect('*/*/');
|
399 |
+
}
|
400 |
+
|
401 |
+
}
|
402 |
+
|
403 |
+
/*
|
404 |
+
public function queryFraudAction() {
|
405 |
+
$cron = new Eway_Rapid31_Model_EwayCron();
|
406 |
+
$cron->querySuspectFraud();
|
407 |
+
}*/
|
408 |
}
|
app/code/community/Eway/Rapid31/controllers/SharedpageController.php
CHANGED
@@ -1,460 +1,476 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once "Mage" . DS . "Checkout" . DS . "controllers" . DS . "OnepageController.php";
|
4 |
-
|
5 |
-
class Eway_Rapid31_SharedpageController extends Mage_Checkout_OnepageController
|
6 |
-
{
|
7 |
-
/**
|
8 |
-
* @var Mage_Sales_Model_Quote
|
9 |
-
*/
|
10 |
-
protected $_quote = null;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @var Eway_Rapid31_Model_Request_Sharedpage
|
14 |
-
*/
|
15 |
-
protected $_checkout = null;
|
16 |
-
|
17 |
-
protected $_checkoutType = 'ewayrapid/request_sharedpage';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* process checkout with eway Responsive Shared Page
|
21 |
-
*/
|
22 |
-
public function startAction()
|
23 |
-
{
|
24 |
-
// check method available
|
25 |
-
$method = $this->_getQuote()->getPayment()->getMethod();
|
26 |
-
if ($method !== Eway_Rapid31_Model_Config::PAYMENT_NOT_SAVED_METHOD
|
27 |
-
&& $method !== Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
28 |
-
&& $method !== Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD
|
29 |
-
) {
|
30 |
-
Mage::getSingleton('core/session')->addError($this->__('Payment method ' . $method . ' not available'));
|
31 |
-
$this->_redirect('checkout/cart');
|
32 |
-
return;
|
33 |
-
}
|
34 |
-
if (($method === Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
35 |
-
|| $method === Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD)
|
36 |
-
&& !Mage::helper('ewayrapid')->isSavedMethodEnabled()
|
37 |
-
) {
|
38 |
-
Mage::getSingleton('core/session')->addError($this->__('This feature has been disabled. Please contact site owner.'));
|
39 |
-
$this->_redirect('checkout/cart');
|
40 |
-
return;
|
41 |
-
}
|
42 |
-
|
43 |
-
try {
|
44 |
-
$this->_initCheckout();
|
45 |
-
$data = $this->_checkout->createAccessCode(Mage::getUrl('*/*/return', array('_secure'=>true)), Mage::getUrl('*/*/cancel', array('_secure'=>true)));
|
46 |
-
if ($data->isSuccess()) {
|
47 |
-
Mage::getSingleton('core/session')->setData('FormActionURL', $data->getFormActionURL());
|
48 |
-
if ($data->getSharedPaymentUrl()) {
|
49 |
-
$this->_redirectUrl($data->getSharedPaymentUrl());
|
50 |
-
return;
|
51 |
-
}
|
52 |
-
} else {
|
53 |
-
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: ' . $data->getMessage() . ')'));
|
54 |
-
$this->_redirect('checkout/cart');
|
55 |
-
return;
|
56 |
-
}
|
57 |
-
|
58 |
-
} catch (Exception $e) {
|
59 |
-
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__($e->getMessage()));
|
60 |
-
$this->_redirect('checkout/cart');
|
61 |
-
}
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* generate a Shared Payment URL for Rapid Iframe
|
66 |
-
*/
|
67 |
-
public function iframeAction()
|
68 |
-
{
|
69 |
-
// check method available
|
70 |
-
$method = $this->_getQuote()->getPayment()->getMethod();
|
71 |
-
if ($method !== Eway_Rapid31_Model_Config::PAYMENT_NOT_SAVED_METHOD
|
72 |
-
&& $method !== Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
73 |
-
&& $method !== Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD
|
74 |
-
) {
|
75 |
-
Mage::getSingleton('core/session')->addError($this->__('Payment method ' . $method . ' not available'));
|
76 |
-
$this->_redirect('checkout/cart');
|
77 |
-
return;
|
78 |
-
}
|
79 |
-
if (($method === Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
80 |
-
|| $method === Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD)
|
81 |
-
&& !Mage::helper('ewayrapid')->isSavedMethodEnabled()
|
82 |
-
) {
|
83 |
-
Mage::getSingleton('core/session')->addError($this->__('This feature has been disabled. Please contact site owner.'));
|
84 |
-
$this->_redirect('checkout/cart');
|
85 |
-
return;
|
86 |
-
}
|
87 |
-
|
88 |
-
try {
|
89 |
-
$this->_initCheckout();
|
90 |
-
$data = $this->_checkout->createAccessCode(Mage::getUrl('*/*/return', array('_secure'=>true)), Mage::getUrl('*/*/cancel', array('_secure'=>true)));
|
91 |
-
|
92 |
-
// Save redirect url for iframe callback
|
93 |
-
$redirectUrl = Mage::getModel('core/url')->parseUrl($this->_checkout->getRedirectUrl())
|
94 |
-
->setQueryParam('AccessCode'
|
95 |
-
|
96 |
-
$redirectUrl = Mage::getUrl('*/*/return', $redirectUrl->getQueryParams());
|
97 |
-
|
98 |
-
$result = array(
|
99 |
-
'success' => false,
|
100 |
-
'message' => '',
|
101 |
-
'url' => '',
|
102 |
-
'returnUrl' => $redirectUrl
|
103 |
-
);
|
104 |
-
|
105 |
-
if ($data->isSuccess()) {
|
106 |
-
Mage::getSingleton('core/session')->setData('FormActionURL', $data->getFormActionURL());
|
107 |
-
if ($data->getSharedPaymentUrl()) {
|
108 |
-
$result['url'] = $data->getSharedPaymentUrl();
|
109 |
-
$result['success'] = true;
|
110 |
-
$this->getResponse()->setBody(json_encode($result));
|
111 |
-
return;
|
112 |
-
}
|
113 |
-
} else {
|
114 |
-
$result['message'] = Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: ' . $data->getMessage() . ')');
|
115 |
-
$this->getResponse()->setBody(json_encode($result));
|
116 |
-
return;
|
117 |
-
}
|
118 |
-
|
119 |
-
} catch (Exception $e) {
|
120 |
-
$result['message'] = Mage::helper('ewayrapid')->__($e->getMessage());
|
121 |
-
$this->getResponse()->setBody(json_encode($result));
|
122 |
-
return;
|
123 |
-
}
|
124 |
-
}
|
125 |
-
|
126 |
-
public function cancelAction()
|
127 |
-
{
|
128 |
-
$this->_redirect('checkout/cart');
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* process payment when eway callback
|
133 |
-
*/
|
134 |
-
public function returnAction()
|
135 |
-
{
|
136 |
-
try {
|
137 |
-
$this->_initCheckout();
|
138 |
-
|
139 |
-
$newToken = $this->getRequest()->getParam('newToken');
|
140 |
-
$editToken = $this->getRequest()->getParam('editToken');
|
141 |
-
$accessCode = $this->getRequest()->getParam('AccessCode');
|
142 |
-
|
143 |
-
$beagleScore = 0;
|
144 |
-
$beagleVerification = array();
|
145 |
-
|
146 |
-
$response = $this->_checkout->getInfoByAccessCode($accessCode);
|
147 |
-
// Get Fraud Information
|
148 |
-
if($response->isSuccess()){
|
149 |
-
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
150 |
-
if($transaction) {
|
151 |
-
$fraudAction = $transaction[0]['FraudAction'];
|
152 |
-
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
153 |
-
$captured = $transaction[0]['TransactionCaptured'];
|
154 |
-
unset($transaction);
|
155 |
-
}
|
156 |
-
}
|
157 |
-
|
158 |
-
if($response->getData('BeagleVerification')){
|
159 |
-
$beagleVerification = $response->getData('BeagleVerification');
|
160 |
-
}
|
161 |
-
if($response->getData('BeagleScore') && $response->getData('BeagleScore') > 0){
|
162 |
-
$beagleScore = $response->getData('BeagleScore');
|
163 |
-
}
|
164 |
-
if ($editToken || $newToken) {
|
165 |
-
if ($response->getTokenCustomerID()) {
|
166 |
-
$method = $this->_getQuote()->getPayment()->getMethod();
|
167 |
-
if($method == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE){
|
168 |
-
// Authorize only require to call 2 requests, create token first, then use response to authorize payment
|
169 |
-
$response = $this->_checkout->saveTokenById($response, $editToken);
|
170 |
-
$response = $this->_processPayment($response);
|
171 |
-
}else{
|
172 |
-
// Authorize & Capture using TokenPayment will create request & charge payment in one call request.
|
173 |
-
// Don't need to call processPayment with token id
|
174 |
-
$this->_checkout->saveTokenById($response, $editToken);
|
175 |
-
}
|
176 |
-
if($response->getData('BeagleVerification')){
|
177 |
-
$beagleVerification = $response->getData('BeagleVerification');
|
178 |
-
}
|
179 |
-
if($response->getData('BeagleScore') && $response->getData('BeagleScore') > 0){
|
180 |
-
$beagleScore = $response->getData('BeagleScore');
|
181 |
-
}
|
182 |
-
} else {
|
183 |
-
Mage::throwException(
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
$
|
239 |
-
|
240 |
-
$
|
241 |
-
$
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
*
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
*
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
private function
|
296 |
-
{
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
);
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
) {
|
398 |
-
$
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
$
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
$
|
440 |
-
$
|
441 |
-
$
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once "Mage" . DS . "Checkout" . DS . "controllers" . DS . "OnepageController.php";
|
4 |
+
|
5 |
+
class Eway_Rapid31_SharedpageController extends Mage_Checkout_OnepageController
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var Mage_Sales_Model_Quote
|
9 |
+
*/
|
10 |
+
protected $_quote = null;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var Eway_Rapid31_Model_Request_Sharedpage
|
14 |
+
*/
|
15 |
+
protected $_checkout = null;
|
16 |
+
|
17 |
+
protected $_checkoutType = 'ewayrapid/request_sharedpage';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* process checkout with eway Responsive Shared Page
|
21 |
+
*/
|
22 |
+
public function startAction()
|
23 |
+
{
|
24 |
+
// check method available
|
25 |
+
$method = $this->_getQuote()->getPayment()->getMethod();
|
26 |
+
if ($method !== Eway_Rapid31_Model_Config::PAYMENT_NOT_SAVED_METHOD
|
27 |
+
&& $method !== Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
28 |
+
&& $method !== Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD
|
29 |
+
) {
|
30 |
+
Mage::getSingleton('core/session')->addError($this->__('Payment method ' . $method . ' not available'));
|
31 |
+
$this->_redirect('checkout/cart');
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
if (($method === Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
35 |
+
|| $method === Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD)
|
36 |
+
&& !Mage::helper('ewayrapid')->isSavedMethodEnabled()
|
37 |
+
) {
|
38 |
+
Mage::getSingleton('core/session')->addError($this->__('This feature has been disabled. Please contact site owner.'));
|
39 |
+
$this->_redirect('checkout/cart');
|
40 |
+
return;
|
41 |
+
}
|
42 |
+
|
43 |
+
try {
|
44 |
+
$this->_initCheckout();
|
45 |
+
$data = $this->_checkout->createAccessCode(Mage::getUrl('*/*/return', array('_secure'=>true)), Mage::getUrl('*/*/cancel', array('_secure'=>true)));
|
46 |
+
if ($data->isSuccess()) {
|
47 |
+
Mage::getSingleton('core/session')->setData('FormActionURL', $data->getFormActionURL());
|
48 |
+
if ($data->getSharedPaymentUrl()) {
|
49 |
+
$this->_redirectUrl($data->getSharedPaymentUrl());
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
} else {
|
53 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: ' . $data->getMessage() . ')'));
|
54 |
+
$this->_redirect('checkout/cart');
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
} catch (Exception $e) {
|
59 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__($e->getMessage()));
|
60 |
+
$this->_redirect('checkout/cart');
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* generate a Shared Payment URL for Rapid Iframe
|
66 |
+
*/
|
67 |
+
public function iframeAction()
|
68 |
+
{
|
69 |
+
// check method available
|
70 |
+
$method = $this->_getQuote()->getPayment()->getMethod();
|
71 |
+
if ($method !== Eway_Rapid31_Model_Config::PAYMENT_NOT_SAVED_METHOD
|
72 |
+
&& $method !== Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
73 |
+
&& $method !== Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD
|
74 |
+
) {
|
75 |
+
Mage::getSingleton('core/session')->addError($this->__('Payment method ' . $method . ' not available'));
|
76 |
+
$this->_redirect('checkout/cart');
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
if (($method === Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
80 |
+
|| $method === Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD)
|
81 |
+
&& !Mage::helper('ewayrapid')->isSavedMethodEnabled()
|
82 |
+
) {
|
83 |
+
Mage::getSingleton('core/session')->addError($this->__('This feature has been disabled. Please contact site owner.'));
|
84 |
+
$this->_redirect('checkout/cart');
|
85 |
+
return;
|
86 |
+
}
|
87 |
+
|
88 |
+
try {
|
89 |
+
$this->_initCheckout();
|
90 |
+
$data = $this->_checkout->createAccessCode(Mage::getUrl('*/*/return', array('_secure'=>true)), Mage::getUrl('*/*/cancel', array('_secure'=>true)));
|
91 |
+
|
92 |
+
// Save redirect url for iframe callback
|
93 |
+
$redirectUrl = Mage::getModel('core/url')->parseUrl($this->_checkout->getRedirectUrl())
|
94 |
+
->setQueryParam('AccessCode', $data['AccessCode']);
|
95 |
+
|
96 |
+
$redirectUrl = Mage::getUrl('*/*/return', $redirectUrl->getQueryParams());
|
97 |
+
|
98 |
+
$result = array(
|
99 |
+
'success' => false,
|
100 |
+
'message' => '',
|
101 |
+
'url' => '',
|
102 |
+
'returnUrl' => $redirectUrl
|
103 |
+
);
|
104 |
+
|
105 |
+
if ($data->isSuccess()) {
|
106 |
+
Mage::getSingleton('core/session')->setData('FormActionURL', $data->getFormActionURL());
|
107 |
+
if ($data->getSharedPaymentUrl()) {
|
108 |
+
$result['url'] = $data->getSharedPaymentUrl();
|
109 |
+
$result['success'] = true;
|
110 |
+
$this->getResponse()->setBody(json_encode($result));
|
111 |
+
return;
|
112 |
+
}
|
113 |
+
} else {
|
114 |
+
$result['message'] = Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: ' . $data->getMessage() . ')');
|
115 |
+
$this->getResponse()->setBody(json_encode($result));
|
116 |
+
return;
|
117 |
+
}
|
118 |
+
|
119 |
+
} catch (Exception $e) {
|
120 |
+
$result['message'] = Mage::helper('ewayrapid')->__($e->getMessage());
|
121 |
+
$this->getResponse()->setBody(json_encode($result));
|
122 |
+
return;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
public function cancelAction()
|
127 |
+
{
|
128 |
+
$this->_redirect('checkout/cart');
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* process payment when eway callback
|
133 |
+
*/
|
134 |
+
public function returnAction()
|
135 |
+
{
|
136 |
+
try {
|
137 |
+
$this->_initCheckout();
|
138 |
+
|
139 |
+
$newToken = $this->getRequest()->getParam('newToken');
|
140 |
+
$editToken = $this->getRequest()->getParam('editToken');
|
141 |
+
$accessCode = $this->getRequest()->getParam('AccessCode');
|
142 |
+
|
143 |
+
$beagleScore = 0;
|
144 |
+
$beagleVerification = array();
|
145 |
+
|
146 |
+
$response = $this->_checkout->getInfoByAccessCode($accessCode);
|
147 |
+
// Get Fraud Information
|
148 |
+
if ($response->isSuccess()) {
|
149 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
150 |
+
if ($transaction) {
|
151 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
152 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
153 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
154 |
+
unset($transaction);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
if ($response->getData('BeagleVerification')) {
|
159 |
+
$beagleVerification = $response->getData('BeagleVerification');
|
160 |
+
}
|
161 |
+
if ($response->getData('BeagleScore') && $response->getData('BeagleScore') > 0) {
|
162 |
+
$beagleScore = $response->getData('BeagleScore');
|
163 |
+
}
|
164 |
+
if ($editToken || $newToken) {
|
165 |
+
if ($response->getTokenCustomerID()) {
|
166 |
+
$method = $this->_getQuote()->getPayment()->getMethod();
|
167 |
+
if ($method == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
|
168 |
+
// Authorize only require to call 2 requests, create token first, then use response to authorize payment
|
169 |
+
$response = $this->_checkout->saveTokenById($response, $editToken);
|
170 |
+
$response = $this->_processPayment($response);
|
171 |
+
} else {
|
172 |
+
// Authorize & Capture using TokenPayment will create request & charge payment in one call request.
|
173 |
+
// Don't need to call processPayment with token id
|
174 |
+
$this->_checkout->saveTokenById($response, $editToken);
|
175 |
+
}
|
176 |
+
if ($response->getData('BeagleVerification')) {
|
177 |
+
$beagleVerification = $response->getData('BeagleVerification');
|
178 |
+
}
|
179 |
+
if ($response->getData('BeagleScore') && $response->getData('BeagleScore') > 0) {
|
180 |
+
$beagleScore = $response->getData('BeagleScore');
|
181 |
+
}
|
182 |
+
} else {
|
183 |
+
Mage::throwException(
|
184 |
+
Mage::helper('ewayrapid')->__(
|
185 |
+
'An error occurred while making the transaction. Please try again. (Error message: %s)',
|
186 |
+
$response->getMessage()
|
187 |
+
)
|
188 |
+
);
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
$orderId = null;
|
193 |
+
if ($response->isSuccess()) {
|
194 |
+
|
195 |
+
// Save fraud information
|
196 |
+
if (is_null($fraudAction)) {
|
197 |
+
$fraudAction = $response->getFraudAction();
|
198 |
+
}
|
199 |
+
if (is_null($fraudCodes)) {
|
200 |
+
$fraudCodes = $response->getFraudCodes();
|
201 |
+
}
|
202 |
+
if (is_null($captured)) {
|
203 |
+
$captured = $response->getTransactionCaptured();
|
204 |
+
}
|
205 |
+
|
206 |
+
$orderId = $this->storeOrder($response, $beagleScore, $beagleVerification, $fraudAction, $fraudCodes, $captured, 'success');
|
207 |
+
} else {
|
208 |
+
Mage::throwException(
|
209 |
+
Mage::helper('ewayrapid')->__(
|
210 |
+
'Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.',
|
211 |
+
$response->getMessage()
|
212 |
+
)
|
213 |
+
);
|
214 |
+
}
|
215 |
+
if ($orderId) {
|
216 |
+
$this->_redirect('checkout/onepage/success');
|
217 |
+
return;
|
218 |
+
}
|
219 |
+
} catch (Exception $e) {
|
220 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
221 |
+
Mage::logException($e);
|
222 |
+
$this->_redirect('checkout/cart');
|
223 |
+
return;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* save order
|
229 |
+
*
|
230 |
+
* @param Eway_Rapid31_Model_Response $response
|
231 |
+
* @param string $successType
|
232 |
+
* @return string
|
233 |
+
*/
|
234 |
+
private function storeOrder($response, $beagleScore, $beagleVerification, $fraudAction, $fraudCodes, $captured, $successType = 'success')
|
235 |
+
{
|
236 |
+
try {
|
237 |
+
// Clear the basket and save the order (including some info about how the payment went)
|
238 |
+
$this->getOnepage()->getQuote()->collectTotals();
|
239 |
+
$payment = $this->getOnepage()->getQuote()->getPayment();
|
240 |
+
$payment->setAdditionalInformation('successType', $successType);
|
241 |
+
$beagleScore = $beagleScore ? $beagleScore : '';
|
242 |
+
$payment->setBeagleScore($beagleScore);
|
243 |
+
$payment->setBeagleVerification(serialize($beagleVerification));
|
244 |
+
$payment->setFraudAction($fraudAction);
|
245 |
+
$payment->setFraudCodes($fraudCodes);
|
246 |
+
$payment->setTransactionCaptured($captured);
|
247 |
+
Mage::getSingleton('core/session')->setData('ewayTransactionID', $response->getTransactionID());
|
248 |
+
$orderId = $this->getOnepage()->saveOrder()->getLastOrderId();
|
249 |
+
$this->getOnepage()->getQuote()->setIsActive(1);
|
250 |
+
try {
|
251 |
+
$cartHelper = Mage::helper('checkout/cart');
|
252 |
+
//Get all items from cart
|
253 |
+
$items = $cartHelper->getCart()->getItems();
|
254 |
+
//Loop through all of cart items
|
255 |
+
foreach ($items as $item) {
|
256 |
+
$itemId = $item->getItemId();
|
257 |
+
//Remove items, one by one
|
258 |
+
$cartHelper->getCart()->removeItem($itemId)->save();
|
259 |
+
}
|
260 |
+
} catch (Exception $e) {
|
261 |
+
}
|
262 |
+
$this->getOnepage()->getQuote()->save();
|
263 |
+
return $orderId;
|
264 |
+
} catch (Exception $e) {
|
265 |
+
Mage::throwException(Mage::helper('ewayrapid')->__($e->getMessage()));
|
266 |
+
}
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Get one page checkout model
|
272 |
+
*
|
273 |
+
* @return Mage_Checkout_Model_Type_Onepage
|
274 |
+
*/
|
275 |
+
public function getOnepage()
|
276 |
+
{
|
277 |
+
return Mage::getSingleton('checkout/type_onepage');
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Return checkout session object
|
282 |
+
*
|
283 |
+
* @return Mage_Checkout_Model_Session
|
284 |
+
*/
|
285 |
+
private function _getCheckoutSession()
|
286 |
+
{
|
287 |
+
return Mage::getSingleton('checkout/session');
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Return checkout quote object
|
292 |
+
*
|
293 |
+
* @return Mage_Sales_Model_Quote
|
294 |
+
*/
|
295 |
+
private function _getQuote()
|
296 |
+
{
|
297 |
+
if (!$this->_quote) {
|
298 |
+
$this->_quote = $this->_getCheckoutSession()->getQuote();
|
299 |
+
}
|
300 |
+
return $this->_quote;
|
301 |
+
}
|
302 |
+
|
303 |
+
private function _initCheckout()
|
304 |
+
{
|
305 |
+
$quote = $this->_getQuote();
|
306 |
+
if (!$quote->hasItems() || $quote->getHasError()) {
|
307 |
+
$this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden');
|
308 |
+
Mage::throwException(Mage::helper('ewayrapid')->__('Unable to initialize Shared page Checkout.'));
|
309 |
+
}
|
310 |
+
$this->_checkout = Mage::getSingleton(
|
311 |
+
$this->_checkoutType, array(
|
312 |
+
'quote' => $quote
|
313 |
+
)
|
314 |
+
);
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* review order when checkout with paypal express
|
319 |
+
*/
|
320 |
+
public function reviewAction()
|
321 |
+
{
|
322 |
+
try {
|
323 |
+
$this->_initCheckout();
|
324 |
+
$accessCode = $this->getRequest()->getParam('AccessCode');
|
325 |
+
$this->_checkout->updateCustomer($accessCode);
|
326 |
+
$this->loadLayout();
|
327 |
+
$blockReview = $this->getLayout()->getBlock('eway.block.review');
|
328 |
+
$blockReview->setQuote($this->_getQuote());
|
329 |
+
$blockReview->setAccessCode($accessCode);
|
330 |
+
$blockReview->setActionUrl(Mage::getUrl('*/*/saveInfoShipping'));
|
331 |
+
$this->renderLayout();
|
332 |
+
return;
|
333 |
+
} catch (Exception $e) {
|
334 |
+
Mage::getSingleton('checkout/session')->addError(
|
335 |
+
$this->__('Unable to initialize Express Checkout review. Error message: ' . $e->getMessage())
|
336 |
+
);
|
337 |
+
Mage::logException($e);
|
338 |
+
}
|
339 |
+
$this->_redirect('checkout/cart');
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* save shipping total amount to quote
|
344 |
+
* send new shipping total amount to eway
|
345 |
+
*
|
346 |
+
* @throws Exception
|
347 |
+
* @throws Mage_Core_Exception
|
348 |
+
*/
|
349 |
+
public function saveInfoShippingAction()
|
350 |
+
{
|
351 |
+
$this->_initCheckout();
|
352 |
+
$formActionURL = Mage::getSingleton('core/session')->getData('FormActionURL');
|
353 |
+
if ($formActionURL) {
|
354 |
+
Mage::getSingleton('core/session')->unsetData('FormActionURL');
|
355 |
+
}
|
356 |
+
$shippingMethod = $this->getRequest()->getParam('shipping_method');
|
357 |
+
if ($shippingMethod) {
|
358 |
+
//Save to quote
|
359 |
+
$this->_quote->getShippingAddress()->setShippingMethod($shippingMethod)->save();
|
360 |
+
|
361 |
+
//Get price
|
362 |
+
$quote = $this->_getQuote();
|
363 |
+
$cRate = $this->_checkout->getShippingByCode($shippingMethod);
|
364 |
+
if ($cRate) {
|
365 |
+
echo json_encode(
|
366 |
+
array(
|
367 |
+
'form_action' => $formActionURL,
|
368 |
+
'input_post' => '<input type="hidden" name="EWAY_NEWSHIPPINGTOTAL" value="' . round($cRate->getPrice() * 100) . '" />'
|
369 |
+
)
|
370 |
+
);
|
371 |
+
} else {
|
372 |
+
Mage::throwException($this->__('Method not found.'));
|
373 |
+
}
|
374 |
+
} else {
|
375 |
+
Mage::throwException($this->__('Method not support.'));
|
376 |
+
}
|
377 |
+
die;
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* process Payment: authorize only or authorize & capture
|
382 |
+
*
|
383 |
+
* @param Eway_Rapid31_Model_Response $response
|
384 |
+
* @return Eway_Rapid31_Model_Response
|
385 |
+
* @throws Mage_Core_Exception
|
386 |
+
*/
|
387 |
+
protected function _processPayment(Eway_Rapid31_Model_Response $response)
|
388 |
+
{
|
389 |
+
$this->_initCheckout();
|
390 |
+
|
391 |
+
$cardData = $response->getCustomer();
|
392 |
+
|
393 |
+
if ($cardData['CardNumber'] && $cardData['CardName']) {
|
394 |
+
$beagleScore = $response->getBeagleScore();
|
395 |
+
|
396 |
+
// Get Fraud Information
|
397 |
+
if ($response->isSuccess()) {
|
398 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
399 |
+
if ($transaction) {
|
400 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
401 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
402 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
403 |
+
unset($transaction);
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
if ($response->isSuccess()
|
408 |
+
&& Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE
|
409 |
+
) {
|
410 |
+
$response = $this->_checkout->doAuthorisation($response);
|
411 |
+
|
412 |
+
// Reload Fraud Information
|
413 |
+
if ($response->isSuccess()) {
|
414 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
415 |
+
if ($transaction) {
|
416 |
+
if ($transaction[0]['FraudAction']) {
|
417 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
418 |
+
}
|
419 |
+
if (Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage'])) {
|
420 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
421 |
+
}
|
422 |
+
if ($transaction[0]['TransactionCaptured']) {
|
423 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
424 |
+
}
|
425 |
+
unset($transaction);
|
426 |
+
}
|
427 |
+
}
|
428 |
+
|
429 |
+
}
|
430 |
+
} else {
|
431 |
+
if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
|
432 |
+
$response = $this->_checkout->doAuthorisation($response);
|
433 |
+
|
434 |
+
// Get Fraud Information
|
435 |
+
if ($response->isSuccess()) {
|
436 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
437 |
+
if ($transaction) {
|
438 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
439 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
440 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
441 |
+
unset($transaction);
|
442 |
+
}
|
443 |
+
}
|
444 |
+
} elseif (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
445 |
+
$response = $this->_checkout->doTransaction($response);
|
446 |
+
|
447 |
+
// Get Fraud Information
|
448 |
+
if ($response->isSuccess()) {
|
449 |
+
$transaction = $this->_checkout->getTransaction($response['TransactionID']);
|
450 |
+
if ($transaction) {
|
451 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
452 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
453 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
454 |
+
unset($transaction);
|
455 |
+
}
|
456 |
+
}
|
457 |
+
}
|
458 |
+
}
|
459 |
+
if (!$response->isSuccess()) {
|
460 |
+
Mage::throwException(
|
461 |
+
Mage::helper('ewayrapid')->__(
|
462 |
+
'Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.',
|
463 |
+
$response->getMessage()
|
464 |
+
)
|
465 |
+
);
|
466 |
+
}
|
467 |
+
|
468 |
+
if ($response->getBeagleScore() === null) {
|
469 |
+
$response->setBeagleScore($beagleScore);
|
470 |
+
}
|
471 |
+
$response->setFraudAction($fraudAction);
|
472 |
+
$response->setFraudCodes($fraudCodes);
|
473 |
+
$response->setTransactionCaptured($captured);
|
474 |
+
return $response;
|
475 |
+
}
|
476 |
}
|
app/code/community/Eway/Rapid31/controllers/TestController.php
CHANGED
@@ -1,128 +1,128 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*/
|
5 |
-
class Eway_Rapid31_TestController extends Mage_Core_Controller_Front_Action
|
6 |
-
{
|
7 |
-
public function querySuspectFraudAction()
|
8 |
-
{
|
9 |
-
|
10 |
-
$
|
11 |
-
$file = $
|
12 |
-
// The new person to add to the file
|
13 |
-
$person = "John Smith " . rand(1, 9999) . "\n";
|
14 |
-
// Write the contents to the file,
|
15 |
-
// using the FILE_APPEND flag to append the content to the end of the file
|
16 |
-
// and the LOCK_EX flag to prevent anyone else writing to the file at the same time
|
17 |
-
file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
|
18 |
-
|
19 |
-
// Load orders with fraud in 7 days before from now
|
20 |
-
$orders = Mage::getModel('sales/order')->getCollection()
|
21 |
-
->addFieldToFilter('status', array('eq' => 'fraud')) // State fraud
|
22 |
-
->addFieldToFilter('eway_transaction_id', array('notnull' => ''))
|
23 |
-
->addFieldToFilter('created_at', array('to' => date('Y-m-d 23:59:59'), 'from' => date('Y-m-d 00:00:01', strtotime('-7 days'))));
|
24 |
-
|
25 |
-
foreach ($orders as $o) {
|
26 |
-
$transactionId = $o->getEwayTransactionId();
|
27 |
-
if ($transactionId) {
|
28 |
-
$result = $this->__getTransaction($transactionId);
|
29 |
-
// Check return data
|
30 |
-
$
|
31 |
-
|
32 |
-
$trans = $
|
33 |
-
$tranId = $trans[0]->TransactionID;
|
34 |
-
|
35 |
-
if ($trans[0]->ResponseMessage == 'A2000') { // Success - Fraud order has been approved
|
36 |
-
// Create new transaction
|
37 |
-
$this->__createNewTransaction($o, $tranId);
|
38 |
-
// Update order status
|
39 |
-
$this->__updateStatusOrder($o);
|
40 |
-
// Un-mark fraud customer
|
41 |
-
$this->__unMarkFraudUser($o);
|
42 |
-
}
|
43 |
-
}
|
44 |
-
}
|
45 |
-
// Response data to client
|
46 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
47 |
-
$this->getResponse()->setBody(count($orders));
|
48 |
-
}
|
49 |
-
|
50 |
-
private function __getTransaction($transId)
|
51 |
-
{
|
52 |
-
$ewayConfig = new Eway_Rapid31_Model_Config();
|
53 |
-
$url = 'https://api.sandbox.ewaypayments.com/Transaction/' . $transId;
|
54 |
-
$ch = curl_init($url);
|
55 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));
|
56 |
-
curl_setopt($ch, CURLOPT_USERPWD, $ewayConfig->getBasicAuthenticationHeader());
|
57 |
-
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
|
58 |
-
|
59 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
60 |
-
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
61 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $ewayConfig->isEnableSSLVerification());
|
62 |
-
|
63 |
-
$result = curl_exec($ch);
|
64 |
-
return $result;
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Re-create order with new transaction returned by Eway
|
69 |
-
* @param $data
|
70 |
-
*/
|
71 |
-
private function __createNewTransaction(Mage_Sales_Model_Order $order, $transId)
|
72 |
-
{
|
73 |
-
|
74 |
-
// Load transaction
|
75 |
-
$currentTrans = Mage::getModel('sales/order_payment_transaction')
|
76 |
-
->getCollection()
|
77 |
-
->addFieldToFilter('order_id', array('eq' => $order->getEntityId()));
|
78 |
-
foreach ($currentTrans as $t) {
|
79 |
-
}
|
80 |
-
if ($t == null) {
|
81 |
-
$t = new Mage_Sales_Model_Order_Payment_Transaction();
|
82 |
-
}
|
83 |
-
|
84 |
-
$trans = new Mage_Sales_Model_Order_Payment_Transaction();
|
85 |
-
// Load payment object
|
86 |
-
$payment = Mage::getModel('sales/order_payment')->load($t->getPaymentId());
|
87 |
-
|
88 |
-
$trans->setOrderPaymentObject($payment);
|
89 |
-
$trans->setOrder($order);
|
90 |
-
|
91 |
-
$trans->setParentId($t->getTransactionId());
|
92 |
-
$trans->setOrderId($order->getEntityId());
|
93 |
-
$trans->setPaymentId($t->getPaymentId());
|
94 |
-
$trans->setTxnId($transId);
|
95 |
-
$trans->setParentTxnId($t->getTxnId());
|
96 |
-
$trans->setTxnType($t->getTxnType());
|
97 |
-
$trans->setIsClosed($t->getIsClosed());
|
98 |
-
$trans->setCreatedAt(date('Y-m-d H:i:s'));
|
99 |
-
$trans->save();
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
private function __updateStatusOrder(Mage_Sales_Model_Order $order)
|
104 |
-
{
|
105 |
-
$order->setState('Processing');
|
106 |
-
$order->setStatus(Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED);
|
107 |
-
$order->save();
|
108 |
-
}
|
109 |
-
|
110 |
-
private function __unMarkFraudUser(Mage_Sales_Model_Order $order)
|
111 |
-
{
|
112 |
-
$uid = $order->getCustomerId();
|
113 |
-
$customer = Mage::getModel('customer/customer')->load($uid);
|
114 |
-
$customer->setMarkFraud(0);
|
115 |
-
$customer->save();
|
116 |
-
}
|
117 |
-
|
118 |
-
public function recurringAction()
|
119 |
-
{
|
120 |
-
try {
|
121 |
-
$modelObserver = Mage::getModel('ewayrapid/Observer');
|
122 |
-
$modelObserver->cronRecurringOrder();
|
123 |
-
echo "done";
|
124 |
-
} catch (Exception $e) {
|
125 |
-
throw $e;
|
126 |
-
}
|
127 |
-
}
|
128 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
class Eway_Rapid31_TestController extends Mage_Core_Controller_Front_Action
|
6 |
+
{
|
7 |
+
public function querySuspectFraudAction()
|
8 |
+
{
|
9 |
+
|
10 |
+
$basePath = Mage::getBaseDir('base');
|
11 |
+
$file = $basePath . DS .'var' . DS . 'report' . DS .'people.txt';
|
12 |
+
// The new person to add to the file
|
13 |
+
$person = "John Smith " . rand(1, 9999) . "\n";
|
14 |
+
// Write the contents to the file,
|
15 |
+
// using the FILE_APPEND flag to append the content to the end of the file
|
16 |
+
// and the LOCK_EX flag to prevent anyone else writing to the file at the same time
|
17 |
+
file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
|
18 |
+
|
19 |
+
// Load orders with fraud in 7 days before from now
|
20 |
+
$orders = Mage::getModel('sales/order')->getCollection()
|
21 |
+
->addFieldToFilter('status', array('eq' => 'fraud')) // State fraud
|
22 |
+
->addFieldToFilter('eway_transaction_id', array('notnull' => ''))
|
23 |
+
->addFieldToFilter('created_at', array('to' => date('Y-m-d 23:59:59'), 'from' => date('Y-m-d 00:00:01', strtotime('-7 days'))));
|
24 |
+
|
25 |
+
foreach ($orders as $o) {
|
26 |
+
$transactionId = $o->getEwayTransactionId();
|
27 |
+
if ($transactionId) {
|
28 |
+
$result = $this->__getTransaction($transactionId);
|
29 |
+
// Check return data
|
30 |
+
$resultDecode = json_decode($result);
|
31 |
+
|
32 |
+
$trans = $resultDecode->Transactions;
|
33 |
+
$tranId = $trans[0]->TransactionID;
|
34 |
+
|
35 |
+
if ($trans[0]->ResponseMessage == 'A2000') { // Success - Fraud order has been approved
|
36 |
+
// Create new transaction
|
37 |
+
$this->__createNewTransaction($o, $tranId);
|
38 |
+
// Update order status
|
39 |
+
$this->__updateStatusOrder($o);
|
40 |
+
// Un-mark fraud customer
|
41 |
+
$this->__unMarkFraudUser($o);
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
// Response data to client
|
46 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
47 |
+
$this->getResponse()->setBody(count($orders));
|
48 |
+
}
|
49 |
+
|
50 |
+
private function __getTransaction($transId)
|
51 |
+
{
|
52 |
+
$ewayConfig = new Eway_Rapid31_Model_Config();
|
53 |
+
$url = 'https://api.sandbox.ewaypayments.com/Transaction/' . $transId;
|
54 |
+
$ch = curl_init($url);
|
55 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));
|
56 |
+
curl_setopt($ch, CURLOPT_USERPWD, $ewayConfig->getBasicAuthenticationHeader());
|
57 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
|
58 |
+
|
59 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
60 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
61 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $ewayConfig->isEnableSSLVerification());
|
62 |
+
|
63 |
+
$result = curl_exec($ch);
|
64 |
+
return $result;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Re-create order with new transaction returned by Eway
|
69 |
+
* @param $data
|
70 |
+
*/
|
71 |
+
private function __createNewTransaction(Mage_Sales_Model_Order $order, $transId)
|
72 |
+
{
|
73 |
+
|
74 |
+
// Load transaction
|
75 |
+
$currentTrans = Mage::getModel('sales/order_payment_transaction')
|
76 |
+
->getCollection()
|
77 |
+
->addFieldToFilter('order_id', array('eq' => $order->getEntityId()));
|
78 |
+
foreach ($currentTrans as $t) {
|
79 |
+
}
|
80 |
+
if ($t == null) {
|
81 |
+
$t = new Mage_Sales_Model_Order_Payment_Transaction();
|
82 |
+
}
|
83 |
+
|
84 |
+
$trans = new Mage_Sales_Model_Order_Payment_Transaction();
|
85 |
+
// Load payment object
|
86 |
+
$payment = Mage::getModel('sales/order_payment')->load($t->getPaymentId());
|
87 |
+
|
88 |
+
$trans->setOrderPaymentObject($payment);
|
89 |
+
$trans->setOrder($order);
|
90 |
+
|
91 |
+
$trans->setParentId($t->getTransactionId());
|
92 |
+
$trans->setOrderId($order->getEntityId());
|
93 |
+
$trans->setPaymentId($t->getPaymentId());
|
94 |
+
$trans->setTxnId($transId);
|
95 |
+
$trans->setParentTxnId($t->getTxnId());
|
96 |
+
$trans->setTxnType($t->getTxnType());
|
97 |
+
$trans->setIsClosed($t->getIsClosed());
|
98 |
+
$trans->setCreatedAt(date('Y-m-d H:i:s'));
|
99 |
+
$trans->save();
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
private function __updateStatusOrder(Mage_Sales_Model_Order $order)
|
104 |
+
{
|
105 |
+
$order->setState('Processing');
|
106 |
+
$order->setStatus(Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED);
|
107 |
+
$order->save();
|
108 |
+
}
|
109 |
+
|
110 |
+
private function __unMarkFraudUser(Mage_Sales_Model_Order $order)
|
111 |
+
{
|
112 |
+
$uid = $order->getCustomerId();
|
113 |
+
$customer = Mage::getModel('customer/customer')->load($uid);
|
114 |
+
$customer->setMarkFraud(0);
|
115 |
+
$customer->save();
|
116 |
+
}
|
117 |
+
|
118 |
+
public function recurringAction()
|
119 |
+
{
|
120 |
+
try {
|
121 |
+
$modelObserver = Mage::getModel('ewayrapid/Observer');
|
122 |
+
$modelObserver->cronRecurringOrder();
|
123 |
+
echo "done";
|
124 |
+
} catch (Exception $e) {
|
125 |
+
throw $e;
|
126 |
+
}
|
127 |
+
}
|
128 |
}
|
app/code/community/Eway/Rapid31/controllers/TransparentController.php
CHANGED
@@ -1,557 +1,557 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once "Mage" . DS . "Checkout" . DS . "controllers" . DS . "OnepageController.php";
|
4 |
-
|
5 |
-
class Eway_Rapid31_TransparentController extends Mage_Checkout_OnepageController
|
6 |
-
{
|
7 |
-
/**
|
8 |
-
* @var Mage_Sales_Model_Quote
|
9 |
-
*/
|
10 |
-
protected $_quote;
|
11 |
-
|
12 |
-
public static $
|
13 |
-
|
14 |
-
protected $
|
15 |
-
protected $
|
16 |
-
protected $
|
17 |
-
protected $
|
18 |
-
protected $
|
19 |
-
protected $
|
20 |
-
protected $
|
21 |
-
|
22 |
-
function _getSession()
|
23 |
-
{
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
if (!$this->
|
27 |
-
$this->
|
28 |
-
}
|
29 |
-
|
30 |
-
$this->
|
31 |
-
|
32 |
-
if ($this->
|
33 |
-
|| $this->
|
34 |
-
$this->
|
35 |
-
}
|
36 |
-
$this->
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @return false|Eway_Rapid31_Model_Request_Transparent
|
41 |
-
*/
|
42 |
-
protected function transparentModel()
|
43 |
-
{
|
44 |
-
if (!self::$
|
45 |
-
self::$
|
46 |
-
}
|
47 |
-
return self::$
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* @return Eway_Rapid31_Helper_Data
|
52 |
-
*/
|
53 |
-
protected function helperData()
|
54 |
-
{
|
55 |
-
return Mage::helper('ewayrapid/data');
|
56 |
-
}
|
57 |
-
|
58 |
-
public function indexAction()
|
59 |
-
{
|
60 |
-
try {
|
61 |
-
|
62 |
-
} catch (Exception $e) {
|
63 |
-
Mage::throwException($e->getMessage());
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Action build link redirect checkout after Click Place Order
|
69 |
-
*/
|
70 |
-
public function buildAction()
|
71 |
-
{
|
72 |
-
try {
|
73 |
-
$this->_getSession();
|
74 |
-
$quote = $this->_getQuote();
|
75 |
-
/** @var Eway_Rapid31_Model_Request_Sharedpage $sharedpageModel */
|
76 |
-
|
77 |
-
$action = 'AccessCodes';
|
78 |
-
if ($this->
|
79 |
-
$methodData = Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT;
|
80 |
-
|
81 |
-
//Authorize Only
|
82 |
-
if ($this->helperData()->getPaymentAction() != Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE
|
83 |
-
|| $this->
|
84 |
-
if ($this->
|
85 |
-
$methodData = Eway_Rapid31_Model_Config::METHOD_CREATE_TOKEN;
|
86 |
-
else
|
87 |
-
$methodData = Eway_Rapid31_Model_Config::METHOD_UPDATE_TOKEN;
|
88 |
-
}
|
89 |
-
} else if($this->
|
90 |
-
if($visaCheckout = $this->getRequest()->getParam('visa_checkout_call_id')){
|
91 |
-
if($visaCheckout && $visaCheckout != ""){
|
92 |
-
Mage::getSingleton('core/session')->setData('visa_checkout_call_id', $visaCheckout);
|
93 |
-
}
|
94 |
-
}
|
95 |
-
$methodData = Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT;
|
96 |
-
|
97 |
-
if ($this->helperData()->getPaymentAction() != Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE
|
98 |
-
// && $this->transMethod != Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD
|
99 |
-
// && $this->transMethod != Eway_Rapid31_Model_Config::MASTERPASS_METHOD
|
100 |
-
// && $this->transMethod != Eway_Rapid31_Model_Config::VISA_CHECKOUT_METHOD
|
101 |
-
)
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
$
|
121 |
-
|
122 |
-
&& $this->
|
123 |
-
&& $this->
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
if (
|
136 |
-
|
137 |
-
|
138 |
-
|| $this->
|
139 |
-
|
140 |
-
|
141 |
-
$urlRedirect = Mage::getUrl('ewayrapid/transparent/
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|| Mage::getStoreConfig('
|
150 |
-
|| Mage::getStoreConfig('
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|| Mage::getStoreConfig('
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
$
|
223 |
-
|
224 |
-
|
225 |
-
$
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
$
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
$
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
$
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
$
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
$this->_redirect('checkout/
|
313 |
-
return;
|
314 |
-
}
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
$this->_redirectUrl(Mage::getUrl('checkout/cart/'));
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
* @
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
$this->getOnepage()->getQuote()->
|
395 |
-
$this->getOnepage()->getQuote()->getPayment()->
|
396 |
-
$
|
397 |
-
$this->getOnepage()->getQuote()->getPayment()->
|
398 |
-
$
|
399 |
-
$this->getOnepage()->getQuote()->getPayment()->
|
400 |
-
$this->getOnepage()->getQuote()->getPayment()->
|
401 |
-
$this->getOnepage()->getQuote()->getPayment()->
|
402 |
-
|
403 |
-
$this->getOnepage()->
|
404 |
-
|
405 |
-
$
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
$itemId
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
}
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
}
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
$
|
447 |
-
$blockReview
|
448 |
-
$blockReview->
|
449 |
-
$
|
450 |
-
|
451 |
-
$
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
'
|
497 |
-
|
498 |
-
)
|
499 |
-
} else {
|
500 |
-
$this->transparentModel()->unsetSessionData();
|
501 |
-
Mage::throwException($this->__('Method not found.'));
|
502 |
-
}
|
503 |
-
} else {
|
504 |
-
$this->transparentModel()->unsetSessionData();
|
505 |
-
Mage::throwException($this->__('Method not support.'));
|
506 |
-
}
|
507 |
-
die;
|
508 |
-
}
|
509 |
-
|
510 |
-
/**
|
511 |
-
* @param $orderId
|
512 |
-
* @return null
|
513 |
-
*/
|
514 |
-
private function _loadOrder($orderId)
|
515 |
-
{
|
516 |
-
try {
|
517 |
-
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
518 |
-
if ($order->getIncrementId() == $orderId) {
|
519 |
-
return $order;
|
520 |
-
}
|
521 |
-
return null;
|
522 |
-
} catch (Exception $e) {
|
523 |
-
Mage::throwException($e->getMessage());
|
524 |
-
}
|
525 |
-
}
|
526 |
-
|
527 |
-
/**
|
528 |
-
* Return checkout quote object
|
529 |
-
*
|
530 |
-
* @return Mage_Sale_Model_Quote
|
531 |
-
*/
|
532 |
-
private function _getQuote()
|
533 |
-
{
|
534 |
-
/** @var Mage_Sales_Model_Quote $this->_quote */
|
535 |
-
$this->_quote = $this->_getCheckoutSession()->getQuote();
|
536 |
-
return $this->_quote;
|
537 |
-
}
|
538 |
-
|
539 |
-
/**
|
540 |
-
* @return Mage_Core_Model_Abstract
|
541 |
-
*/
|
542 |
-
private function _getCheckoutSession()
|
543 |
-
{
|
544 |
-
return Mage::getSingleton('checkout/session');
|
545 |
-
}
|
546 |
-
|
547 |
-
/**
|
548 |
-
* Get one page checkout model
|
549 |
-
*
|
550 |
-
* @return Mage_Checkout_Model_Type_Onepage
|
551 |
-
*/
|
552 |
-
public function getOnepage()
|
553 |
-
{
|
554 |
-
return Mage::getSingleton('checkout/type_onepage');
|
555 |
-
}
|
556 |
-
|
557 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once "Mage" . DS . "Checkout" . DS . "controllers" . DS . "OnepageController.php";
|
4 |
+
|
5 |
+
class Eway_Rapid31_TransparentController extends Mage_Checkout_OnepageController
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var Mage_Sales_Model_Quote
|
9 |
+
*/
|
10 |
+
protected $_quote;
|
11 |
+
|
12 |
+
public static $transparentmodel;
|
13 |
+
|
14 |
+
protected $_methodPayment;
|
15 |
+
protected $_transMethod;
|
16 |
+
protected $_paypalSavedToken;
|
17 |
+
protected $_savedToken;
|
18 |
+
protected $_cardInfo;
|
19 |
+
protected $_masterPassSavedToken;
|
20 |
+
protected $_saveCard;
|
21 |
+
|
22 |
+
public function _getSession()
|
23 |
+
{
|
24 |
+
$this->_methodPayment = Mage::getSingleton('core/session')->getMethod();
|
25 |
+
$this->_transMethod = Mage::getSingleton('core/session')->getTransparentNotsaved();
|
26 |
+
if (!$this->_transMethod) {
|
27 |
+
$this->_transMethod = Mage::getSingleton('core/session')->getTransparentSaved();
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_saveCard = Mage::getSingleton('core/session')->getSaveCard();
|
31 |
+
|
32 |
+
if ($this->_methodPayment == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
|
33 |
+
|| $this->_methodPayment == Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD) {
|
34 |
+
$this->_savedToken = Mage::getSingleton('core/session')->getSavedToken();
|
35 |
+
}
|
36 |
+
$this->_cardInfo = Mage::getSingleton('core/session')->getCardInfo();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return false|Eway_Rapid31_Model_Request_Transparent
|
41 |
+
*/
|
42 |
+
protected function transparentModel()
|
43 |
+
{
|
44 |
+
if (!self::$transparentmodel) {
|
45 |
+
self::$transparentmodel = Mage::getModel('ewayrapid/request_transparent');
|
46 |
+
}
|
47 |
+
return self::$transparentmodel;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @return Eway_Rapid31_Helper_Data
|
52 |
+
*/
|
53 |
+
protected function helperData()
|
54 |
+
{
|
55 |
+
return Mage::helper('ewayrapid/data');
|
56 |
+
}
|
57 |
+
|
58 |
+
public function indexAction()
|
59 |
+
{
|
60 |
+
try {
|
61 |
+
|
62 |
+
} catch (Exception $e) {
|
63 |
+
Mage::throwException($e->getMessage());
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Action build link redirect checkout after Click Place Order
|
69 |
+
*/
|
70 |
+
public function buildAction()
|
71 |
+
{
|
72 |
+
try {
|
73 |
+
$this->_getSession();
|
74 |
+
$quote = $this->_getQuote();
|
75 |
+
/** @var Eway_Rapid31_Model_Request_Sharedpage $sharedpageModel */
|
76 |
+
|
77 |
+
$action = 'AccessCodes';
|
78 |
+
if ($this->_methodPayment == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD) {
|
79 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT;
|
80 |
+
|
81 |
+
//Authorize Only
|
82 |
+
if ($this->helperData()->getPaymentAction() != Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE
|
83 |
+
|| $this->_transMethod == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
84 |
+
if ($this->_savedToken == Eway_Rapid31_Model_Config::TOKEN_NEW)
|
85 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_CREATE_TOKEN;
|
86 |
+
else
|
87 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_UPDATE_TOKEN;
|
88 |
+
}
|
89 |
+
} else if ($this->_methodPayment == Eway_Rapid31_Model_Config::PAYMENT_EWAYONE_METHOD) {
|
90 |
+
if ($visaCheckout = $this->getRequest()->getParam('visa_checkout_call_id')) {
|
91 |
+
if ($visaCheckout && $visaCheckout != "") {
|
92 |
+
Mage::getSingleton('core/session')->setData('visa_checkout_call_id', $visaCheckout);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT;
|
96 |
+
|
97 |
+
if ($this->helperData()->getPaymentAction() != Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE
|
98 |
+
// && $this->transMethod != Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD
|
99 |
+
// && $this->transMethod != Eway_Rapid31_Model_Config::MASTERPASS_METHOD
|
100 |
+
// && $this->transMethod != Eway_Rapid31_Model_Config::VISA_CHECKOUT_METHOD
|
101 |
+
) {
|
102 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_AUTHORISE;
|
103 |
+
}
|
104 |
+
|
105 |
+
if ($this->_saveCard || ($this->_savedToken && is_numeric($this->_savedToken))) {
|
106 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT;
|
107 |
+
}
|
108 |
+
|
109 |
+
//Authorize Only
|
110 |
+
if ($this->helperData()->getPaymentAction() != Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE
|
111 |
+
|| $this->_transMethod == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD
|
112 |
+
) {
|
113 |
+
if ($this->_savedToken && $this->_savedToken == Eway_Rapid31_Model_Config::TOKEN_NEW && $this->_saveCard)
|
114 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_CREATE_TOKEN;
|
115 |
+
else if ($this->_savedToken && is_numeric($this->_savedToken))
|
116 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_UPDATE_TOKEN;
|
117 |
+
}
|
118 |
+
} else {
|
119 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT;
|
120 |
+
if ($this->helperData()->getPaymentAction() != Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE
|
121 |
+
&& $this->_transMethod != Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD
|
122 |
+
&& $this->_transMethod != Eway_Rapid31_Model_Config::MASTERPASS_METHOD
|
123 |
+
&& $this->_transMethod != Eway_Rapid31_Model_Config::VISA_CHECKOUT_METHOD
|
124 |
+
) {
|
125 |
+
$methodData = Eway_Rapid31_Model_Config::METHOD_AUTHORISE;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
$data = $this->transparentModel()->createAccessCode($quote, $methodData, $action);
|
130 |
+
if ($data['AccessCode']) {
|
131 |
+
//save FormActionURL, AccessCode
|
132 |
+
Mage::getSingleton('core/session')->setFormActionUrl($data['FormActionURL']);
|
133 |
+
if (isset($data['CompleteCheckoutURL']))
|
134 |
+
Mage::getSingleton('core/session')->setCompleteCheckoutURL($data['CompleteCheckoutURL']);
|
135 |
+
if ($this->_transMethod == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD
|
136 |
+
|| $this->_transMethod == Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD
|
137 |
+
|| $this->_transMethod == Eway_Rapid31_Model_Config::MASTERPASS_METHOD
|
138 |
+
|| $this->_transMethod == Eway_Rapid31_Model_Config::VISA_CHECKOUT_METHOD) {
|
139 |
+
$urlRedirect = Mage::getUrl('ewayrapid/transparent/redirect', array('_secure'=>true)) . '?AccessCode=' . $data['AccessCode'];
|
140 |
+
} else {
|
141 |
+
$urlRedirect = Mage::getUrl('ewayrapid/transparent/paynow', array('_secure'=>true)) . '?AccessCode=' . $data['AccessCode'];
|
142 |
+
}
|
143 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
144 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
|
145 |
+
&& Mage::getSingleton('core/session')->getCheckoutExtension()
|
146 |
+
/*(Mage::getStoreConfig('onestepcheckout/general/active')
|
147 |
+
|| Mage::getStoreConfig('opc/global/status')
|
148 |
+
|| Mage::getStoreConfig('firecheckout/general/enabled')
|
149 |
+
|| Mage::getStoreConfig('gomage_checkout/general/enabled')
|
150 |
+
|| Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links'))*/
|
151 |
+
) {
|
152 |
+
$this->_redirectUrl($urlRedirect);
|
153 |
+
return;
|
154 |
+
} else {
|
155 |
+
echo($urlRedirect);
|
156 |
+
}
|
157 |
+
} else {
|
158 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later.'));
|
159 |
+
$this->transparentModel()->unsetSessionData();
|
160 |
+
echo Mage::getUrl('checkout/cart/');
|
161 |
+
return;
|
162 |
+
}
|
163 |
+
//
|
164 |
+
} catch (Exception $e) {
|
165 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later.'));
|
166 |
+
$this->transparentModel()->unsetSessionData();
|
167 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
168 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
|
169 |
+
&& Mage::getSingleton('core/session')->getCheckoutExtension()
|
170 |
+
/*(Mage::getStoreConfig('onestepcheckout/general/active')
|
171 |
+
|| Mage::getStoreConfig('opc/global/status')
|
172 |
+
|| Mage::getStoreConfig('firecheckout/general/enabled')
|
173 |
+
|| Mage::getStoreConfig('gomage_checkout/general/enabled')
|
174 |
+
|| Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links'))*/
|
175 |
+
) {
|
176 |
+
$this->_redirectUrl(Mage::getUrl('checkout/cart/'));
|
177 |
+
return;
|
178 |
+
} else {
|
179 |
+
echo Mage::getUrl('checkout/cart/');
|
180 |
+
}
|
181 |
+
return;
|
182 |
+
}
|
183 |
+
die;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Action display form customer's detail card: Add new info
|
188 |
+
*/
|
189 |
+
public function paynowAction()
|
190 |
+
{
|
191 |
+
$this->loadLayout();
|
192 |
+
|
193 |
+
$accessCode = $this->getRequest()->getParam('AccessCode');
|
194 |
+
$this->getLayout()->getBlock('transparent.block.paynow')->setAccessCode($accessCode);
|
195 |
+
|
196 |
+
$this->renderLayout();
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Action display form customer's detail card: Add new info
|
201 |
+
*/
|
202 |
+
public function redirectAction()
|
203 |
+
{
|
204 |
+
$this->loadLayout();
|
205 |
+
|
206 |
+
$accessCode = $this->getRequest()->getParam('AccessCode');
|
207 |
+
$this->getLayout()->getBlock('transparent.block.checkout')->setAccessCode($accessCode);
|
208 |
+
|
209 |
+
$this->renderLayout();
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Action process at returnUrl
|
214 |
+
*/
|
215 |
+
public function callBackAction()
|
216 |
+
{
|
217 |
+
try {
|
218 |
+
$this->_getSession();
|
219 |
+
$quote = $this->_getQuote();
|
220 |
+
|
221 |
+
$accessCode = $this->getRequest()->getParam('AccessCode');
|
222 |
+
$orderId = $transactionID = $tokenCustomerID = 0;
|
223 |
+
|
224 |
+
$fraudAction = '';
|
225 |
+
$fraudCodes = '';
|
226 |
+
|
227 |
+
if ($this->_methodPayment == 'ewayrapid_notsaved'
|
228 |
+
|| ($this->_methodPayment == 'ewayrapid_ewayone' && !$this->_saveCard
|
229 |
+
&& (!$this->_savedToken || !is_numeric($this->_savedToken)))
|
230 |
+
) {
|
231 |
+
$dataResult = $this->resultProcess($accessCode);
|
232 |
+
$transactionID = $dataResult['TransactionID'];
|
233 |
+
|
234 |
+
$transaction = $this->transparentModel()->getTransaction($transactionID);
|
235 |
+
if ($transaction) {
|
236 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
237 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
238 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
239 |
+
unset($transaction);
|
240 |
+
}
|
241 |
+
} else {
|
242 |
+
$transaction = $this->transparentModel()->getTransaction($accessCode);
|
243 |
+
if ($transaction) {
|
244 |
+
$tokenCustomerID = $transaction && isset($transaction[0]['TokenCustomerID']) ? $transaction[0]['TokenCustomerID'] : null;
|
245 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
246 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
247 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
248 |
+
unset($transaction);
|
249 |
+
}
|
250 |
+
$quote->setTokenCustomerID($tokenCustomerID);
|
251 |
+
|
252 |
+
if ($this->_transMethod == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
253 |
+
/*
|
254 |
+
$dataResult = $this->resultProcess($accessCode);
|
255 |
+
$transactionID = $dataResult['TransactionID'];
|
256 |
+
*/
|
257 |
+
$quote = $this->transparentModel()->doTransaction($quote, round($this->_getQuote()->getBaseGrandTotal() * 100));
|
258 |
+
$transactionID = $quote->getTransactionId();
|
259 |
+
} else {
|
260 |
+
if ($this->helperData()->getPaymentAction() === Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE) {
|
261 |
+
$dataResult = $this->resultProcess($accessCode);
|
262 |
+
$transactionID = $dataResult['TransactionID'];
|
263 |
+
} else {
|
264 |
+
$quote = $this->transparentModel()->doAuthorisation($quote, round($this->_getQuote()->getBaseGrandTotal() * 100));
|
265 |
+
$transactionID = $quote->getTransactionId();
|
266 |
+
//$quote = $this->transparentModel()->doCapturePayment($quote, round($this->_getQuote()->getBaseGrandTotal() * 100));
|
267 |
+
|
268 |
+
// Reload fraud information after do authorisation
|
269 |
+
$transaction = $this->transparentModel()->getTransaction($transactionID);
|
270 |
+
if ($transaction) {
|
271 |
+
$fraudAction = $transaction[0]['FraudAction'];
|
272 |
+
$fraudCodes = Mage::helper('ewayrapid')->getFraudCodes($transaction[0]['ResponseMessage']);
|
273 |
+
$captured = $transaction[0]['TransactionCaptured'];
|
274 |
+
unset($transaction);
|
275 |
+
}
|
276 |
+
}
|
277 |
+
}
|
278 |
+
$quote->setTransactionId($transactionID);
|
279 |
+
|
280 |
+
//Save Token
|
281 |
+
if ($this->_methodPayment == 'ewayrapid_saved') {
|
282 |
+
$this->saveToken($quote, $tokenCustomerID);
|
283 |
+
} elseif ($this->_methodPayment == 'ewayrapid_ewayone' && $this->_saveCard) {
|
284 |
+
$this->saveToken($quote, $tokenCustomerID);
|
285 |
+
}
|
286 |
+
|
287 |
+
}
|
288 |
+
|
289 |
+
if ($transactionID) {
|
290 |
+
//Add Beagle Information
|
291 |
+
if (isset($dataResult)) {
|
292 |
+
$beagleScore = $dataResult->getBeagleScore();
|
293 |
+
$beagleVerification = $dataResult->getBeagleVerification();
|
294 |
+
} else {
|
295 |
+
$beagleScore = $quote->getBeagleScore();
|
296 |
+
$beagleVerification = $quote->getBeagleVerification();
|
297 |
+
}
|
298 |
+
Mage::getSingleton('core/session')->setTransactionId($transactionID);
|
299 |
+
//Save order
|
300 |
+
$orderId = $this->storeOrder($transactionID, $beagleScore, $beagleVerification, $fraudAction, $fraudCodes, $captured, 'success');
|
301 |
+
}
|
302 |
+
|
303 |
+
//unset all session's transaparent
|
304 |
+
$this->transparentModel()->unsetSessionData();
|
305 |
+
|
306 |
+
// Redirect to success page
|
307 |
+
if ($orderId) {
|
308 |
+
$this->_redirect('checkout/onepage/success');
|
309 |
+
return;
|
310 |
+
} else {
|
311 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Create order error. Please again.'));
|
312 |
+
$this->_redirect('checkout/cart/');
|
313 |
+
return;
|
314 |
+
}
|
315 |
+
} catch (Exception $e) {
|
316 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Call back error: ' . $e->getMessage()));
|
317 |
+
$this->transparentModel()->unsetSessionData();
|
318 |
+
if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
|
319 |
+
=== Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
|
320 |
+
&& Mage::getSingleton('core/session')->getCheckoutExtension()
|
321 |
+
/*(Mage::getStoreConfig('onestepcheckout/general/active')
|
322 |
+
|| Mage::getStoreConfig('opc/global/status')
|
323 |
+
|| Mage::getStoreConfig('firecheckout/general/enabled')
|
324 |
+
|| Mage::getStoreConfig('gomage_checkout/general/enabled')
|
325 |
+
|| Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links'))*/
|
326 |
+
) {
|
327 |
+
$this->_redirectUrl(Mage::getUrl('checkout/cart/'));
|
328 |
+
return;
|
329 |
+
} else {
|
330 |
+
//echo Mage::getUrl('checkout/cart/');
|
331 |
+
$this->_redirectUrl(Mage::getUrl('checkout/cart/'));
|
332 |
+
}
|
333 |
+
return;
|
334 |
+
}
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* @param $accessCode
|
339 |
+
*/
|
340 |
+
protected function resultProcess($accessCode)
|
341 |
+
{
|
342 |
+
return $this->transparentModel()->getInfoByAccessCode($accessCode);
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* @param $quote
|
347 |
+
* @param $tokenCustomerID
|
348 |
+
*/
|
349 |
+
protected function saveToken($quote, $tokenCustomerID)
|
350 |
+
{
|
351 |
+
if ($this->_savedToken == Eway_Rapid31_Model_Config::TOKEN_NEW || $this->_paypalSavedToken == Eway_Rapid31_Model_Config::TOKEN_NEW || $this->_masterPassSavedToken == Eway_Rapid31_Model_Config::TOKEN_NEW) {
|
352 |
+
$this->_cardInfo['SavedType'] = Eway_Rapid31_Model_Config::CREDITCARD_METHOD;
|
353 |
+
|
354 |
+
if ($this->_transMethod == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
|
355 |
+
$this->_cardInfo['SavedType'] = Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD;
|
356 |
+
} elseif ($this->_transMethod == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
|
357 |
+
$this->_cardInfo['SavedType'] = Eway_Rapid31_Model_Config::MASTERPASS_METHOD;
|
358 |
+
} elseif ($this->_transMethod == Eway_Rapid31_Model_Config::VISA_CHECKOUT_METHOD) {
|
359 |
+
$this->_cardInfo['SavedType'] = Eway_Rapid31_Model_Config::VISA_CHECKOUT_METHOD;
|
360 |
+
}
|
361 |
+
$this->transparentModel()->addToken($quote, $this->_cardInfo, $tokenCustomerID);
|
362 |
+
} else {
|
363 |
+
$this->transparentModel()->updateToken($tokenCustomerID, $this->_cardInfo);
|
364 |
+
}
|
365 |
+
return true;
|
366 |
+
}
|
367 |
+
|
368 |
+
protected function authorizeOnly()
|
369 |
+
{
|
370 |
+
|
371 |
+
}
|
372 |
+
/**
|
373 |
+
* Action Cancel
|
374 |
+
*/
|
375 |
+
public function cancelAction()
|
376 |
+
{
|
377 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Request eway api error. Please try again.'));
|
378 |
+
$this->transparentModel()->unsetSessionData();
|
379 |
+
$this->_redirect('checkout/cart');
|
380 |
+
return;
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* @param string $successType
|
385 |
+
* @param $transactionID
|
386 |
+
* @return string
|
387 |
+
*/
|
388 |
+
private function storeOrder($transactionID, $beagleScore, $beagleVerification, $fraudAction, $fraudCodes, $captured, $successType = 'success')
|
389 |
+
{
|
390 |
+
try {
|
391 |
+
//Clear the basket and save the order (including some info about how the payment went)
|
392 |
+
$this->getOnepage()->getQuote()->collectTotals();
|
393 |
+
$this->getOnepage()->getQuote()->getPayment()->setTransactionId($transactionID);
|
394 |
+
$this->getOnepage()->getQuote()->getPayment()->setAdditionalInformation('transactionId', $transactionID);
|
395 |
+
$this->getOnepage()->getQuote()->getPayment()->setAdditionalInformation('successType', $successType);
|
396 |
+
$beagleScore = $beagleScore && ($beagleScore > 0) ? $beagleScore : '';
|
397 |
+
$this->getOnepage()->getQuote()->getPayment()->setBeagleScore($beagleScore);
|
398 |
+
$this->getOnepage()->getQuote()->getPayment()->setBeagleVerification(serialize($beagleVerification));
|
399 |
+
$this->getOnepage()->getQuote()->getPayment()->setFraudAction($fraudAction);
|
400 |
+
$this->getOnepage()->getQuote()->getPayment()->setFraudCodes($fraudCodes);
|
401 |
+
$this->getOnepage()->getQuote()->getPayment()->setTransactionCaptured($captured);
|
402 |
+
Mage::getSingleton('core/session')->setData('transparentCheckout', true);
|
403 |
+
$orderId = $this->getOnepage()->saveOrder()->getLastOrderId();
|
404 |
+
|
405 |
+
$this->getOnepage()->getQuote()->setIsActive(1);
|
406 |
+
try {
|
407 |
+
$cartHelper = Mage::helper('checkout/cart');
|
408 |
+
|
409 |
+
//Get all items from cart
|
410 |
+
$items = $cartHelper->getCart()->getItems();
|
411 |
+
|
412 |
+
//Loop through all of cart items
|
413 |
+
foreach ($items as $item) {
|
414 |
+
$itemId = $item->getItemId();
|
415 |
+
//Remove items, one by one
|
416 |
+
$cartHelper->getCart()->removeItem($itemId)->save();
|
417 |
+
}
|
418 |
+
} catch (Exception $e) {
|
419 |
+
|
420 |
+
}
|
421 |
+
|
422 |
+
$this->getOnepage()->getQuote()->save();
|
423 |
+
Mage::getSingleton('core/session')->unsetData('transparentCheckout');
|
424 |
+
Mage::getSingleton('core/session')->unsCheckoutExtension();
|
425 |
+
return $orderId;
|
426 |
+
} catch (Exception $e) {
|
427 |
+
Mage::throwException($e->getMessage());
|
428 |
+
}
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Review shipping
|
433 |
+
*/
|
434 |
+
public function reviewAction()
|
435 |
+
{
|
436 |
+
try {
|
437 |
+
$accessCode = $this->getRequest()->getParam('AccessCode');
|
438 |
+
$quote = $this->transparentModel()->updateCustomer($accessCode, $this->_getQuote());
|
439 |
+
|
440 |
+
if (!$quote) {
|
441 |
+
$quote = $this->_getQuote();
|
442 |
+
}
|
443 |
+
|
444 |
+
$this->loadLayout();
|
445 |
+
$blockReview = $this->getLayout()->getBlock('eway.block.review');
|
446 |
+
$blockReview->setQuote($quote);
|
447 |
+
$blockReview->setAccessCode($accessCode);
|
448 |
+
$blockReview->setActionUrl(Mage::getUrl('*/*/saveInfoShipping'));
|
449 |
+
$this->renderLayout();
|
450 |
+
} catch (Exception $e) {
|
451 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Update customer info error: ' . $e->getMessage()));
|
452 |
+
$this->transparentModel()->unsetSessionData();
|
453 |
+
$this->_redirect('checkout/cart/');
|
454 |
+
return;
|
455 |
+
}
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
*
|
460 |
+
*/
|
461 |
+
public function saveCardInfoAction()
|
462 |
+
{
|
463 |
+
try {
|
464 |
+
$data = $this->getRequest()->getPost();
|
465 |
+
if (isset($data['EWAY_CARDNUMBER'])) {
|
466 |
+
$config = Mage::getSingleton('ewayrapid/config');
|
467 |
+
$data['EWAY_CARDNUMBER'] = $this->helperData()->encryptSha256($data['EWAY_CARDNUMBER'], $config->getBasicAuthenticationHeader());
|
468 |
+
}
|
469 |
+
Mage::getSingleton('core/session')->setCardInfo($data);
|
470 |
+
echo 1;
|
471 |
+
} catch (Exception $e) {
|
472 |
+
$this->transparentModel()->unsetSessionData();
|
473 |
+
Mage::throwException($e->getMessage());
|
474 |
+
}
|
475 |
+
die;
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
*
|
480 |
+
*/
|
481 |
+
public function saveInfoShippingAction()
|
482 |
+
{
|
483 |
+
$shippingMethod = $this->getRequest()->getParam('shipping_method');
|
484 |
+
if ($shippingMethod) {
|
485 |
+
//Get price
|
486 |
+
$quote = $this->_getQuote();
|
487 |
+
$cRate = $this->transparentModel()->getShippingByCode($quote, $shippingMethod);
|
488 |
+
|
489 |
+
//Save to quote
|
490 |
+
$quote->getShippingAddress()->setShippingMethod($shippingMethod)->save();
|
491 |
+
|
492 |
+
if ($cRate) {
|
493 |
+
echo json_encode(
|
494 |
+
array(
|
495 |
+
'form_action' => Mage::getSingleton('core/session')->getFormActionUrl(),
|
496 |
+
'input_post' => '<input type="hidden" name="EWAY_NEWSHIPPINGTOTAL" value="' . round($cRate->getPrice() * 100) . '" />',
|
497 |
+
)
|
498 |
+
);
|
499 |
+
} else {
|
500 |
+
$this->transparentModel()->unsetSessionData();
|
501 |
+
Mage::throwException($this->__('Method not found.'));
|
502 |
+
}
|
503 |
+
} else {
|
504 |
+
$this->transparentModel()->unsetSessionData();
|
505 |
+
Mage::throwException($this->__('Method not support.'));
|
506 |
+
}
|
507 |
+
die;
|
508 |
+
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* @param $orderId
|
512 |
+
* @return null
|
513 |
+
*/
|
514 |
+
private function _loadOrder($orderId)
|
515 |
+
{
|
516 |
+
try {
|
517 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
518 |
+
if ($order->getIncrementId() == $orderId) {
|
519 |
+
return $order;
|
520 |
+
}
|
521 |
+
return null;
|
522 |
+
} catch (Exception $e) {
|
523 |
+
Mage::throwException($e->getMessage());
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Return checkout quote object
|
529 |
+
*
|
530 |
+
* @return Mage_Sale_Model_Quote
|
531 |
+
*/
|
532 |
+
private function _getQuote()
|
533 |
+
{
|
534 |
+
/** @var Mage_Sales_Model_Quote $this->_quote */
|
535 |
+
$this->_quote = $this->_getCheckoutSession()->getQuote();
|
536 |
+
return $this->_quote;
|
537 |
+
}
|
538 |
+
|
539 |
+
/**
|
540 |
+
* @return Mage_Core_Model_Abstract
|
541 |
+
*/
|
542 |
+
private function _getCheckoutSession()
|
543 |
+
{
|
544 |
+
return Mage::getSingleton('checkout/session');
|
545 |
+
}
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Get one page checkout model
|
549 |
+
*
|
550 |
+
* @return Mage_Checkout_Model_Type_Onepage
|
551 |
+
*/
|
552 |
+
public function getOnepage()
|
553 |
+
{
|
554 |
+
return Mage::getSingleton('checkout/type_onepage');
|
555 |
+
}
|
556 |
+
|
557 |
}
|
app/code/community/Eway/Rapid31/etc/config.xml
CHANGED
@@ -1,382 +1,370 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Eway_Rapid31>
|
5 |
-
<version>1.4.
|
6 |
-
</Eway_Rapid31>
|
7 |
-
</modules>
|
8 |
-
<global>
|
9 |
-
<models>
|
10 |
-
<ewayrapid>
|
11 |
-
<class>Eway_Rapid31_Model</class>
|
12 |
-
<resourceModel>ewayrapid_resource</resourceModel>
|
13 |
-
</ewayrapid>
|
14 |
-
<ewayrapid_resource>
|
15 |
-
<class>Eway_Rapid31_Model_Resource</class>
|
16 |
-
</ewayrapid_resource>
|
17 |
-
</models>
|
18 |
-
|
19 |
-
<blocks>
|
20 |
-
<ewayrapid>
|
21 |
-
<class>Eway_Rapid31_Block</class>
|
22 |
-
</ewayrapid>
|
23 |
-
<adminhtml>
|
24 |
-
<rewrite>
|
25 |
-
<sales_order_grid>Eway_Rapid31_Block_Sales_Order_Grid</sales_order_grid>
|
26 |
-
<page_head>Eway_Rapid31_Block_Html_Head</page_head>
|
27 |
-
</rewrite>
|
28 |
-
</adminhtml>
|
29 |
-
</blocks>
|
30 |
-
|
31 |
-
<helpers>
|
32 |
-
<ewayrapid>
|
33 |
-
<class>Eway_Rapid31_Helper</class>
|
34 |
-
</ewayrapid>
|
35 |
-
</helpers>
|
36 |
-
<resources>
|
37 |
-
<ewayrapid_setup>
|
38 |
-
<setup>
|
39 |
-
<module>Eway_Rapid31</module>
|
40 |
-
<class>Eway_Rapid31_Model_Resource_Setup</class>
|
41 |
-
</setup>
|
42 |
-
</ewayrapid_setup>
|
43 |
-
</resources>
|
44 |
-
<payment>
|
45 |
-
<cc>
|
46 |
-
<types>
|
47 |
-
<DC>
|
48 |
-
<code>DC</code>
|
49 |
-
<name>Diners Club International</name>
|
50 |
-
<order>100</order>
|
51 |
-
</DC>
|
52 |
-
<VE>
|
53 |
-
<code>VE</code>
|
54 |
-
<name>Visa Electron</name>
|
55 |
-
<order>11</order>
|
56 |
-
</VE>
|
57 |
-
<ME>
|
58 |
-
<code>ME</code>
|
59 |
-
<name>Maestro</name>
|
60 |
-
<order>21</order>
|
61 |
-
</ME>
|
62 |
-
</types>
|
63 |
-
</cc>
|
64 |
-
</payment>
|
65 |
-
<fieldsets>
|
66 |
-
<sales_convert_quote_payment>
|
67 |
-
<fraud_action>
|
68 |
-
<to_order_payment>*</to_order_payment>
|
69 |
-
</fraud_action>
|
70 |
-
<fraud_codes>
|
71 |
-
<to_order_payment>*</to_order_payment>
|
72 |
-
</fraud_codes>
|
73 |
-
<transaction_captured>
|
74 |
-
<to_order_payment>*</to_order_payment>
|
75 |
-
</transaction_captured>
|
76 |
-
<beagle_score>
|
77 |
-
<to_order_payment>*</to_order_payment>
|
78 |
-
</beagle_score>
|
79 |
-
<beagle_verification>
|
80 |
-
<to_order_payment>*</to_order_payment>
|
81 |
-
</beagle_verification>
|
82 |
-
</sales_convert_quote_payment>
|
83 |
-
<sales_convert_order_payment>
|
84 |
-
<fraud_action>
|
85 |
-
<to_quote_payment>*</to_quote_payment>
|
86 |
-
</fraud_action>
|
87 |
-
<fraud_codes>
|
88 |
-
<to_order_payment>*</to_order_payment>
|
89 |
-
</fraud_codes>
|
90 |
-
<transaction_captured>
|
91 |
-
<to_order_payment>*</to_order_payment>
|
92 |
-
</transaction_captured>
|
93 |
-
<beagle_score>
|
94 |
-
<to_order_payment>*</to_order_payment>
|
95 |
-
</beagle_score>
|
96 |
-
<beagle_verification>
|
97 |
-
<to_order_payment>*</to_order_payment>
|
98 |
-
</beagle_verification>
|
99 |
-
</sales_convert_order_payment>
|
100 |
-
</fieldsets>
|
101 |
-
</global>
|
102 |
-
<frontend>
|
103 |
-
<
|
104 |
-
<
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
</
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
</
|
240 |
-
|
241 |
-
|
242 |
-
<admin>
|
243 |
-
<routers>
|
244 |
-
<
|
245 |
-
<
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
<
|
256 |
-
<
|
257 |
-
<
|
258 |
-
<
|
259 |
-
<
|
260 |
-
<
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
<
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
<
|
304 |
-
<
|
305 |
-
<
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
</
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
<
|
319 |
-
<
|
320 |
-
<
|
321 |
-
<
|
322 |
-
|
323 |
-
|
324 |
-
<
|
325 |
-
<
|
326 |
-
<
|
327 |
-
|
328 |
-
|
329 |
-
<
|
330 |
-
<
|
331 |
-
<
|
332 |
-
|
333 |
-
|
334 |
-
<
|
335 |
-
|
336 |
-
|
337 |
-
<
|
338 |
-
<
|
339 |
-
<
|
340 |
-
</
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
</
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
</run>
|
371 |
-
</eway_recurring_order>
|
372 |
-
<eway_rapid31>
|
373 |
-
<schedule>
|
374 |
-
<cron_expr>0 */3 * * *</cron_expr>
|
375 |
-
</schedule>
|
376 |
-
<run>
|
377 |
-
<model>ewayrapid/ewayCron::querySuspectFraud</model>
|
378 |
-
</run>
|
379 |
-
</eway_rapid31>
|
380 |
-
</jobs>
|
381 |
-
</crontab>
|
382 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Eway_Rapid31>
|
5 |
+
<version>1.4.1</version>
|
6 |
+
</Eway_Rapid31>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<ewayrapid>
|
11 |
+
<class>Eway_Rapid31_Model</class>
|
12 |
+
<resourceModel>ewayrapid_resource</resourceModel>
|
13 |
+
</ewayrapid>
|
14 |
+
<ewayrapid_resource>
|
15 |
+
<class>Eway_Rapid31_Model_Resource</class>
|
16 |
+
</ewayrapid_resource>
|
17 |
+
</models>
|
18 |
+
|
19 |
+
<blocks>
|
20 |
+
<ewayrapid>
|
21 |
+
<class>Eway_Rapid31_Block</class>
|
22 |
+
</ewayrapid>
|
23 |
+
<adminhtml>
|
24 |
+
<rewrite>
|
25 |
+
<sales_order_grid>Eway_Rapid31_Block_Sales_Order_Grid</sales_order_grid>
|
26 |
+
<page_head>Eway_Rapid31_Block_Html_Head</page_head>
|
27 |
+
</rewrite>
|
28 |
+
</adminhtml>
|
29 |
+
</blocks>
|
30 |
+
|
31 |
+
<helpers>
|
32 |
+
<ewayrapid>
|
33 |
+
<class>Eway_Rapid31_Helper</class>
|
34 |
+
</ewayrapid>
|
35 |
+
</helpers>
|
36 |
+
<resources>
|
37 |
+
<ewayrapid_setup>
|
38 |
+
<setup>
|
39 |
+
<module>Eway_Rapid31</module>
|
40 |
+
<class>Eway_Rapid31_Model_Resource_Setup</class>
|
41 |
+
</setup>
|
42 |
+
</ewayrapid_setup>
|
43 |
+
</resources>
|
44 |
+
<payment>
|
45 |
+
<cc>
|
46 |
+
<types>
|
47 |
+
<DC>
|
48 |
+
<code>DC</code>
|
49 |
+
<name>Diners Club International</name>
|
50 |
+
<order>100</order>
|
51 |
+
</DC>
|
52 |
+
<VE>
|
53 |
+
<code>VE</code>
|
54 |
+
<name>Visa Electron</name>
|
55 |
+
<order>11</order>
|
56 |
+
</VE>
|
57 |
+
<ME>
|
58 |
+
<code>ME</code>
|
59 |
+
<name>Maestro</name>
|
60 |
+
<order>21</order>
|
61 |
+
</ME>
|
62 |
+
</types>
|
63 |
+
</cc>
|
64 |
+
</payment>
|
65 |
+
<fieldsets>
|
66 |
+
<sales_convert_quote_payment>
|
67 |
+
<fraud_action>
|
68 |
+
<to_order_payment>*</to_order_payment>
|
69 |
+
</fraud_action>
|
70 |
+
<fraud_codes>
|
71 |
+
<to_order_payment>*</to_order_payment>
|
72 |
+
</fraud_codes>
|
73 |
+
<transaction_captured>
|
74 |
+
<to_order_payment>*</to_order_payment>
|
75 |
+
</transaction_captured>
|
76 |
+
<beagle_score>
|
77 |
+
<to_order_payment>*</to_order_payment>
|
78 |
+
</beagle_score>
|
79 |
+
<beagle_verification>
|
80 |
+
<to_order_payment>*</to_order_payment>
|
81 |
+
</beagle_verification>
|
82 |
+
</sales_convert_quote_payment>
|
83 |
+
<sales_convert_order_payment>
|
84 |
+
<fraud_action>
|
85 |
+
<to_quote_payment>*</to_quote_payment>
|
86 |
+
</fraud_action>
|
87 |
+
<fraud_codes>
|
88 |
+
<to_order_payment>*</to_order_payment>
|
89 |
+
</fraud_codes>
|
90 |
+
<transaction_captured>
|
91 |
+
<to_order_payment>*</to_order_payment>
|
92 |
+
</transaction_captured>
|
93 |
+
<beagle_score>
|
94 |
+
<to_order_payment>*</to_order_payment>
|
95 |
+
</beagle_score>
|
96 |
+
<beagle_verification>
|
97 |
+
<to_order_payment>*</to_order_payment>
|
98 |
+
</beagle_verification>
|
99 |
+
</sales_convert_order_payment>
|
100 |
+
</fieldsets>
|
101 |
+
</global>
|
102 |
+
<frontend>
|
103 |
+
<secure_url>
|
104 |
+
<eway_account_cards>/ewayrapid/mycards</eway_account_cards>
|
105 |
+
<eway_checkout_redirect>/ewayrapid/transparent</eway_checkout_redirect>
|
106 |
+
<eway_checkout_shared>/ewayrapid/sharedpage</eway_checkout_shared>
|
107 |
+
</secure_url>
|
108 |
+
<translate>
|
109 |
+
<modules>
|
110 |
+
<Eway_Rapid31>
|
111 |
+
<files>
|
112 |
+
<default>Eway_Rapid31.csv</default>
|
113 |
+
</files>
|
114 |
+
</Eway_Rapid31>
|
115 |
+
</modules>
|
116 |
+
</translate>
|
117 |
+
<layout>
|
118 |
+
<updates>
|
119 |
+
<ewayrapid>
|
120 |
+
<file>ewayrapid/layout.xml</file>
|
121 |
+
</ewayrapid>
|
122 |
+
</updates>
|
123 |
+
</layout>
|
124 |
+
<routers>
|
125 |
+
<ewayrapid>
|
126 |
+
<use>standard</use>
|
127 |
+
<args>
|
128 |
+
<module>Eway_Rapid31</module>
|
129 |
+
<frontName>ewayrapid</frontName>
|
130 |
+
</args>
|
131 |
+
</ewayrapid>
|
132 |
+
</routers>
|
133 |
+
|
134 |
+
<events>
|
135 |
+
|
136 |
+
<controller_action_predispatch_ewayrapid_mycards_index>
|
137 |
+
<observers>
|
138 |
+
<eway_rapid31_my_cards>
|
139 |
+
<type>singleton</type>
|
140 |
+
<class>ewayrapid/observer</class>
|
141 |
+
<method>myCards</method>
|
142 |
+
</eway_rapid31_my_cards>
|
143 |
+
</observers>
|
144 |
+
</controller_action_predispatch_ewayrapid_mycards_index>
|
145 |
+
|
146 |
+
<!-- Event default -->
|
147 |
+
<controller_action_predispatch_checkout_onepage_index>
|
148 |
+
<observers>
|
149 |
+
<eway_rapid31_check_customer_mark>
|
150 |
+
<type>singleton</type>
|
151 |
+
<class>ewayrapid/observer</class>
|
152 |
+
<method>checkCustomerMark</method>
|
153 |
+
</eway_rapid31_check_customer_mark>
|
154 |
+
</observers>
|
155 |
+
</controller_action_predispatch_checkout_onepage_index>
|
156 |
+
|
157 |
+
<sales_order_place_before>
|
158 |
+
<observers>
|
159 |
+
<sales_order_place_before>
|
160 |
+
<class>ewayrapid/observer</class>
|
161 |
+
<method>sales_order_place_before</method>
|
162 |
+
</sales_order_place_before>
|
163 |
+
</observers>
|
164 |
+
</sales_order_place_before>
|
165 |
+
|
166 |
+
<sales_order_place_after>
|
167 |
+
<observers>
|
168 |
+
<sales_order_place_after>
|
169 |
+
<class>ewayrapid/observer</class>
|
170 |
+
<method>sales_order_place_after</method>
|
171 |
+
</sales_order_place_after>
|
172 |
+
</observers>
|
173 |
+
</sales_order_place_after>
|
174 |
+
|
175 |
+
<sales_order_invoice_save_after>
|
176 |
+
<observers>
|
177 |
+
<sales_order_invoice_save_after>
|
178 |
+
<class>ewayrapid/observer</class>
|
179 |
+
<method>sales_order_invoice_save_after</method>
|
180 |
+
</sales_order_invoice_save_after>
|
181 |
+
</observers>
|
182 |
+
</sales_order_invoice_save_after>
|
183 |
+
<checkout_type_onepage_save_order_after>
|
184 |
+
<observers>
|
185 |
+
<checkout_type_onepage_save_order_after>
|
186 |
+
<class>ewayrapid/observer</class>
|
187 |
+
<method>checkout_type_onepage_save_order_after</method>
|
188 |
+
</checkout_type_onepage_save_order_after>
|
189 |
+
</observers>
|
190 |
+
</checkout_type_onepage_save_order_after>
|
191 |
+
|
192 |
+
<!--<sales_order_save_commit_before>
|
193 |
+
<observers>
|
194 |
+
<sales_order_save_commit_before>
|
195 |
+
<class>ewayrapid/observer</class>
|
196 |
+
<method>sales_order_save_commit_before</method>
|
197 |
+
</sales_order_save_commit_before>
|
198 |
+
</observers>
|
199 |
+
</sales_order_save_commit_before>
|
200 |
+
|
201 |
+
<sales_order_save_commit_after>
|
202 |
+
<observers>
|
203 |
+
<sales_order_save_commit_after>
|
204 |
+
<class>ewayrapid/observer</class>
|
205 |
+
<method>sales_order_save_commit_after</method>
|
206 |
+
</sales_order_save_commit_after>
|
207 |
+
</observers>
|
208 |
+
</sales_order_save_commit_after>-->
|
209 |
+
|
210 |
+
<checkout_submit_all_after>
|
211 |
+
<observers>
|
212 |
+
<checkout_submit_all_after>
|
213 |
+
<class>ewayrapid/observer</class>
|
214 |
+
<method>checkout_submit_all_after</method>
|
215 |
+
</checkout_submit_all_after>
|
216 |
+
</observers>
|
217 |
+
<observers>
|
218 |
+
<eway_recurring_profile>
|
219 |
+
<class>ewayrapid/observer</class>
|
220 |
+
<method>createRecurringOrder</method>
|
221 |
+
</eway_recurring_profile>
|
222 |
+
</observers>
|
223 |
+
</checkout_submit_all_after>
|
224 |
+
</events>
|
225 |
+
|
226 |
+
</frontend>
|
227 |
+
|
228 |
+
<!--
|
229 |
+
<admin>
|
230 |
+
<routers>
|
231 |
+
<ewayrapid_admin>
|
232 |
+
<use>admin</use>
|
233 |
+
<args>
|
234 |
+
<module>Eway_Rapid31_Adminhtml</module>
|
235 |
+
<frontName>ewayadmin</frontName>
|
236 |
+
</args>
|
237 |
+
</ewayrapid_admin>
|
238 |
+
</routers>
|
239 |
+
</admin>
|
240 |
+
-->
|
241 |
+
|
242 |
+
<admin>
|
243 |
+
<routers>
|
244 |
+
<adminhtml>
|
245 |
+
<args>
|
246 |
+
<modules>
|
247 |
+
<eway_rapid31_adminhtml after="Mage_Adminhtml">Eway_Rapid31_Adminhtml</eway_rapid31_adminhtml>
|
248 |
+
<eway_rapid31 before="-">Eway_Rapid31_Adminhtml</eway_rapid31>
|
249 |
+
</modules>
|
250 |
+
</args>
|
251 |
+
</adminhtml>
|
252 |
+
</routers>
|
253 |
+
</admin>
|
254 |
+
|
255 |
+
<adminhtml>
|
256 |
+
<translate>
|
257 |
+
<modules>
|
258 |
+
<Eway_Rapid31>
|
259 |
+
<files>
|
260 |
+
<default>Eway_Rapid31.csv</default>
|
261 |
+
</files>
|
262 |
+
</Eway_Rapid31>
|
263 |
+
</modules>
|
264 |
+
</translate>
|
265 |
+
<layout>
|
266 |
+
<updates>
|
267 |
+
<ewayrapid>
|
268 |
+
<file>ewayrapid/layout.xml</file>
|
269 |
+
</ewayrapid>
|
270 |
+
</updates>
|
271 |
+
</layout>
|
272 |
+
<!--<menu>
|
273 |
+
<system>
|
274 |
+
<children>
|
275 |
+
<eway_admin_index>
|
276 |
+
<title>Eway Mass</title>
|
277 |
+
<action>ewayadmin/index/index</action>
|
278 |
+
</eway_admin_index>
|
279 |
+
<eway_admin_mass_authorised>
|
280 |
+
<title>Eway Mass</title>
|
281 |
+
<action>ewayadmin/index/massEwayAuthorised</action>
|
282 |
+
</eway_admin_mass_authorised>
|
283 |
+
<eway_admin_mass_pending>
|
284 |
+
<title>Eway Mass</title>
|
285 |
+
<action>ewayadmin/index/massPending</action>
|
286 |
+
</eway_admin_mass_pending>
|
287 |
+
</children>
|
288 |
+
</system>
|
289 |
+
</menu>-->
|
290 |
+
<menu>
|
291 |
+
<sales>
|
292 |
+
<children>
|
293 |
+
<eway_orders>
|
294 |
+
<title>eWAY</title>
|
295 |
+
<action>adminhtml/ewayadmin/ewayorders</action>
|
296 |
+
<sort_order>100</sort_order>
|
297 |
+
</eway_orders>
|
298 |
+
</children>
|
299 |
+
</sales>
|
300 |
+
</menu>
|
301 |
+
</adminhtml>
|
302 |
+
<default>
|
303 |
+
<payment>
|
304 |
+
<ewayrapid_general>
|
305 |
+
<active>0</active>
|
306 |
+
<mode>sandbox</mode>
|
307 |
+
<sandbox_endpoint>https://api.sandbox.ewaypayments.com/</sandbox_endpoint>
|
308 |
+
<live_endpoint>https://api.ewaypayments.com/</live_endpoint>
|
309 |
+
<payment_action>authorize_capture</payment_action>
|
310 |
+
<connection_type>direct</connection_type>
|
311 |
+
<can_edit_token>1</can_edit_token>
|
312 |
+
<can_cancel_subscriptions>0</can_cancel_subscriptions>
|
313 |
+
<block_fraud_customers>1</block_fraud_customers>
|
314 |
+
<useccv>1</useccv>
|
315 |
+
<cctypes>VI,MC</cctypes>
|
316 |
+
<order_status>eway_captured</order_status>
|
317 |
+
<allowspecific>0</allowspecific>
|
318 |
+
<ssl_verification>0</ssl_verification>
|
319 |
+
<transfer_cart_items>1</transfer_cart_items>
|
320 |
+
<debug>0</debug>
|
321 |
+
<billing_agreement_title>eWAY Billing Agreement</billing_agreement_title>
|
322 |
+
</ewayrapid_general>
|
323 |
+
<ewayrapid_notsaved>
|
324 |
+
<model>ewayrapid/method_notsaved</model>
|
325 |
+
<active>0</active>
|
326 |
+
<title>Credit Card - eWAY (not saved)</title>
|
327 |
+
</ewayrapid_notsaved>
|
328 |
+
<ewayrapid_saved>
|
329 |
+
<model>ewayrapid/method_saved</model>
|
330 |
+
<active>0</active>
|
331 |
+
<title>Credit Card - eWAY (saved)</title>
|
332 |
+
</ewayrapid_saved>
|
333 |
+
<ewayrapid_ewayone>
|
334 |
+
<model>ewayrapid/method_ewayone</model>
|
335 |
+
<active>0</active>
|
336 |
+
<title>Credit Card - eWAY</title>
|
337 |
+
<save_card>1</save_card>
|
338 |
+
<save_text>Save my details</save_text>
|
339 |
+
<save_card_checked>1</save_card_checked>
|
340 |
+
</ewayrapid_ewayone>
|
341 |
+
</payment>
|
342 |
+
</default>
|
343 |
+
<phpunit>
|
344 |
+
<suite>
|
345 |
+
<modules>
|
346 |
+
<Eway_Rapid31/>
|
347 |
+
</modules>
|
348 |
+
</suite>
|
349 |
+
</phpunit>
|
350 |
+
<crontab>
|
351 |
+
<jobs>
|
352 |
+
<eway_recurring_order>
|
353 |
+
<schedule>
|
354 |
+
<cron_expr>0 * * * *</cron_expr>
|
355 |
+
</schedule>
|
356 |
+
<run>
|
357 |
+
<model>ewayrapid/observer::cronRecurringOrder</model>
|
358 |
+
</run>
|
359 |
+
</eway_recurring_order>
|
360 |
+
<eway_rapid31>
|
361 |
+
<schedule>
|
362 |
+
<cron_expr>0 */3 * * *</cron_expr>
|
363 |
+
</schedule>
|
364 |
+
<run>
|
365 |
+
<model>ewayrapid/ewayCron::querySuspectFraud</model>
|
366 |
+
</run>
|
367 |
+
</eway_rapid31>
|
368 |
+
</jobs>
|
369 |
+
</crontab>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
</config>
|
app/code/community/Eway/Rapid31/sql/ewayrapid_setup/install-0.1.0.php
CHANGED
@@ -6,7 +6,8 @@ $installer->startSetup();
|
|
6 |
|
7 |
$setup = Mage::getResourceModel('customer/setup', 'core_setup');
|
8 |
|
9 |
-
$setup->addAttribute(
|
|
|
10 |
'input' => '',
|
11 |
'type' => 'text',
|
12 |
'label' => '',
|
@@ -14,6 +15,7 @@ $setup->addAttribute('customer', 'saved_tokens_json', array(
|
|
14 |
'required' => '0',
|
15 |
'user_defined' => '0',
|
16 |
'backend' => 'ewayrapid/backend_savedtokens',
|
17 |
-
)
|
|
|
18 |
|
19 |
$installer->endSetup();
|
6 |
|
7 |
$setup = Mage::getResourceModel('customer/setup', 'core_setup');
|
8 |
|
9 |
+
$setup->addAttribute(
|
10 |
+
'customer', 'saved_tokens_json', array(
|
11 |
'input' => '',
|
12 |
'type' => 'text',
|
13 |
'label' => '',
|
15 |
'required' => '0',
|
16 |
'user_defined' => '0',
|
17 |
'backend' => 'ewayrapid/backend_savedtokens',
|
18 |
+
)
|
19 |
+
);
|
20 |
|
21 |
$installer->endSetup();
|
app/code/community/Eway/Rapid31/sql/ewayrapid_setup/upgrade-1.0.0-1.0.1.php
CHANGED
@@ -5,30 +5,33 @@ $installer = $this;
|
|
5 |
$installer->startSetup();
|
6 |
|
7 |
$installer->getConnection()
|
8 |
-
->addColumn(
|
9 |
-
|
10 |
-
|
|
|
11 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
12 |
'length' => 50,
|
13 |
'nullable' => true,
|
14 |
'comment' => 'eWAY Transaction ID'
|
15 |
-
|
16 |
);
|
17 |
|
18 |
$installer->getConnection()
|
19 |
-
->addColumn(
|
20 |
-
|
21 |
-
|
|
|
22 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
23 |
'length' => 50,
|
24 |
'nullable' => true,
|
25 |
'comment' => 'eWAY Transaction ID'
|
26 |
-
|
27 |
);
|
28 |
|
29 |
$setup = Mage::getResourceModel('customer/setup', 'core_setup');
|
30 |
|
31 |
-
$setup->addAttribute(
|
|
|
32 |
'input' => '',
|
33 |
'type' => 'int',
|
34 |
'label' => '',
|
@@ -36,6 +39,7 @@ $setup->addAttribute('customer', 'mark_fraud', array(
|
|
36 |
'required' => '0',
|
37 |
'user_defined' => '0',
|
38 |
'backend' => '',
|
39 |
-
)
|
|
|
40 |
|
41 |
$installer->endSetup();
|
5 |
$installer->startSetup();
|
6 |
|
7 |
$installer->getConnection()
|
8 |
+
->addColumn(
|
9 |
+
$installer->getTable('sales/order'),
|
10 |
+
'eway_transaction_id',
|
11 |
+
array(
|
12 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
13 |
'length' => 50,
|
14 |
'nullable' => true,
|
15 |
'comment' => 'eWAY Transaction ID'
|
16 |
+
)
|
17 |
);
|
18 |
|
19 |
$installer->getConnection()
|
20 |
+
->addColumn(
|
21 |
+
$installer->getTable('sales/quote'),
|
22 |
+
'transaction_id',
|
23 |
+
array(
|
24 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
25 |
'length' => 50,
|
26 |
'nullable' => true,
|
27 |
'comment' => 'eWAY Transaction ID'
|
28 |
+
)
|
29 |
);
|
30 |
|
31 |
$setup = Mage::getResourceModel('customer/setup', 'core_setup');
|
32 |
|
33 |
+
$setup->addAttribute(
|
34 |
+
'customer', 'mark_fraud', array(
|
35 |
'input' => '',
|
36 |
'type' => 'int',
|
37 |
'label' => '',
|
39 |
'required' => '0',
|
40 |
'user_defined' => '0',
|
41 |
'backend' => '',
|
42 |
+
)
|
43 |
+
);
|
44 |
|
45 |
$installer->endSetup();
|
app/code/community/Eway/Rapid31/sql/ewayrapid_setup/upgrade-1.0.1-1.0.3.php
CHANGED
@@ -6,7 +6,8 @@ $installer->startSetup();
|
|
6 |
|
7 |
$setup = Mage::getResourceModel('customer/setup', 'core_setup');
|
8 |
|
9 |
-
$setup->addAttribute(
|
|
|
10 |
'input' => 'select',
|
11 |
'type' => 'int',
|
12 |
'label' => 'Unblock Fraud Customer',
|
@@ -15,7 +16,8 @@ $setup->addAttribute('customer', 'block_fraud_customer', array(
|
|
15 |
'user_defined' => '0',
|
16 |
'default' => '0',
|
17 |
'source' => 'eav/entity_attribute_source_boolean'
|
18 |
-
)
|
|
|
19 |
|
20 |
try {
|
21 |
$attributeId = $setup->getAttributeId('customer', 'block_fraud_customer');
|
6 |
|
7 |
$setup = Mage::getResourceModel('customer/setup', 'core_setup');
|
8 |
|
9 |
+
$setup->addAttribute(
|
10 |
+
'customer', 'block_fraud_customer', array(
|
11 |
'input' => 'select',
|
12 |
'type' => 'int',
|
13 |
'label' => 'Unblock Fraud Customer',
|
16 |
'user_defined' => '0',
|
17 |
'default' => '0',
|
18 |
'source' => 'eav/entity_attribute_source_boolean'
|
19 |
+
)
|
20 |
+
);
|
21 |
|
22 |
try {
|
23 |
$attributeId = $setup->getAttributeId('customer', 'block_fraud_customer');
|
app/code/community/Eway/Rapid31/sql/ewayrapid_setup/upgrade-1.3.2-1.4.0.php
CHANGED
@@ -5,7 +5,8 @@ $installer = $this;
|
|
5 |
$installer->startSetup();
|
6 |
|
7 |
$installer->getConnection()
|
8 |
-
->addColumn(
|
|
|
9 |
'fraud_action',
|
10 |
array(
|
11 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
@@ -16,7 +17,8 @@ $installer->getConnection()
|
|
16 |
);
|
17 |
|
18 |
$installer->getConnection()
|
19 |
-
->addColumn(
|
|
|
20 |
'fraud_action',
|
21 |
array(
|
22 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
@@ -27,7 +29,8 @@ $installer->getConnection()
|
|
27 |
);
|
28 |
|
29 |
$installer->getConnection()
|
30 |
-
->addColumn(
|
|
|
31 |
'fraud_codes',
|
32 |
array(
|
33 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
@@ -38,7 +41,8 @@ $installer->getConnection()
|
|
38 |
);
|
39 |
|
40 |
$installer->getConnection()
|
41 |
-
->addColumn(
|
|
|
42 |
'fraud_codes',
|
43 |
array(
|
44 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
@@ -49,7 +53,8 @@ $installer->getConnection()
|
|
49 |
);
|
50 |
|
51 |
$installer->getConnection()
|
52 |
-
->addColumn(
|
|
|
53 |
'transaction_captured',
|
54 |
array(
|
55 |
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
@@ -60,7 +65,8 @@ $installer->getConnection()
|
|
60 |
);
|
61 |
|
62 |
$installer->getConnection()
|
63 |
-
->addColumn(
|
|
|
64 |
'transaction_captured',
|
65 |
array(
|
66 |
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
@@ -71,7 +77,8 @@ $installer->getConnection()
|
|
71 |
);
|
72 |
|
73 |
$installer->getConnection()
|
74 |
-
->addColumn(
|
|
|
75 |
'beagle_score',
|
76 |
array(
|
77 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
@@ -82,7 +89,8 @@ $installer->getConnection()
|
|
82 |
);
|
83 |
|
84 |
$installer->getConnection()
|
85 |
-
->addColumn(
|
|
|
86 |
'beagle_score',
|
87 |
array(
|
88 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
@@ -93,7 +101,8 @@ $installer->getConnection()
|
|
93 |
);
|
94 |
|
95 |
$installer->getConnection()
|
96 |
-
->addColumn(
|
|
|
97 |
'beagle_verification',
|
98 |
array(
|
99 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
@@ -104,7 +113,8 @@ $installer->getConnection()
|
|
104 |
);
|
105 |
|
106 |
$installer->getConnection()
|
107 |
-
->addColumn(
|
|
|
108 |
'beagle_verification',
|
109 |
array(
|
110 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
5 |
$installer->startSetup();
|
6 |
|
7 |
$installer->getConnection()
|
8 |
+
->addColumn(
|
9 |
+
$installer->getTable('sales/order_payment'),
|
10 |
'fraud_action',
|
11 |
array(
|
12 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
17 |
);
|
18 |
|
19 |
$installer->getConnection()
|
20 |
+
->addColumn(
|
21 |
+
$installer->getTable('sales/quote_payment'),
|
22 |
'fraud_action',
|
23 |
array(
|
24 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
29 |
);
|
30 |
|
31 |
$installer->getConnection()
|
32 |
+
->addColumn(
|
33 |
+
$installer->getTable('sales/order_payment'),
|
34 |
'fraud_codes',
|
35 |
array(
|
36 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
41 |
);
|
42 |
|
43 |
$installer->getConnection()
|
44 |
+
->addColumn(
|
45 |
+
$installer->getTable('sales/quote_payment'),
|
46 |
'fraud_codes',
|
47 |
array(
|
48 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
53 |
);
|
54 |
|
55 |
$installer->getConnection()
|
56 |
+
->addColumn(
|
57 |
+
$installer->getTable('sales/order_payment'),
|
58 |
'transaction_captured',
|
59 |
array(
|
60 |
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
65 |
);
|
66 |
|
67 |
$installer->getConnection()
|
68 |
+
->addColumn(
|
69 |
+
$installer->getTable('sales/quote_payment'),
|
70 |
'transaction_captured',
|
71 |
array(
|
72 |
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
77 |
);
|
78 |
|
79 |
$installer->getConnection()
|
80 |
+
->addColumn(
|
81 |
+
$installer->getTable('sales/order_payment'),
|
82 |
'beagle_score',
|
83 |
array(
|
84 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
89 |
);
|
90 |
|
91 |
$installer->getConnection()
|
92 |
+
->addColumn(
|
93 |
+
$installer->getTable('sales/quote_payment'),
|
94 |
'beagle_score',
|
95 |
array(
|
96 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
101 |
);
|
102 |
|
103 |
$installer->getConnection()
|
104 |
+
->addColumn(
|
105 |
+
$installer->getTable('sales/order_payment'),
|
106 |
'beagle_verification',
|
107 |
array(
|
108 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
113 |
);
|
114 |
|
115 |
$installer->getConnection()
|
116 |
+
->addColumn(
|
117 |
+
$installer->getTable('sales/quote_payment'),
|
118 |
'beagle_verification',
|
119 |
array(
|
120 |
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
app/design/adminhtml/default/default/layout/ewayrapid/layout.xml
CHANGED
@@ -1,79 +1,79 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<adminhtml_sales_order_create_index>
|
4 |
-
<reference name="head">
|
5 |
-
<action method="addExternalItem"><type>external_js</type><name>https://secure.ewaypayments.com/scripts/eCrypt.js</name><params/></action>
|
6 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
7 |
-
</reference>
|
8 |
-
<reference name="js">
|
9 |
-
<block type="core/template" name="ewayrapid.js" after="-">
|
10 |
-
<action method="setArea"><area>frontend</area></action>
|
11 |
-
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate" >
|
12 |
-
<template>ewayrapid/js.phtml</template>
|
13 |
-
</action>
|
14 |
-
</block>
|
15 |
-
</reference>
|
16 |
-
</adminhtml_sales_order_create_index>
|
17 |
-
<adminhtml_ewayadmin_ewayorders>
|
18 |
-
<reference name="menu">
|
19 |
-
<action method="setActive">
|
20 |
-
<menupath>sales/eway_orders</menupath>
|
21 |
-
</action>
|
22 |
-
</reference>
|
23 |
-
<reference name="content">
|
24 |
-
<block type="ewayrapid/adminhtml_sales_order" name="eway_orders" />
|
25 |
-
</reference>
|
26 |
-
</adminhtml_ewayadmin_ewayorders>
|
27 |
-
<adminhtml_ewayadmin_grid>
|
28 |
-
<update handle="formkey"/>
|
29 |
-
<block type="ewayrapid/adminhtml_sales_order_grid" name="eway_order.grid" output="toHtml"></block>
|
30 |
-
</adminhtml_ewayadmin_grid>
|
31 |
-
|
32 |
-
|
33 |
-
<adminhtml_customer_edit>
|
34 |
-
<reference name="head">
|
35 |
-
<action method="addExternalItem"><type>external_js</type><name>https://secure.ewaypayments.com/scripts/eCrypt.js</name><params/></action>
|
36 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
37 |
-
</reference>
|
38 |
-
<reference name="js">
|
39 |
-
<block type="core/template" name="ewayrapid.js" after="-">
|
40 |
-
<action method="setArea"><area>frontend</area></action>
|
41 |
-
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate" >
|
42 |
-
<template>ewayrapid/js.phtml</template>
|
43 |
-
</action>
|
44 |
-
</block>
|
45 |
-
</reference>
|
46 |
-
<reference name="customer_edit_tabs">
|
47 |
-
<block type="ewayrapid/adminhtml_customer_savedcard" name="admin.customer.savedcard" template="ewayrapid/customer/cardcontainer.phtml">
|
48 |
-
<block type="ewayrapid/adminhtml_customer_method" name="admin.customer.ewayrapid.method" template="ewayrapid/customer/method.phtml" before="-">
|
49 |
-
<action method="setCode"><code>ewayrapid</code></action>
|
50 |
-
<block type="ewayrapid/adminhtml_customer_edit_tab_cards" name="admin.customer.ewayrapid.cards" template="ewayrapid/customer/edit/tab/cards.phtml">
|
51 |
-
<action method="setCode"><code>ewayrapid</code></action>
|
52 |
-
</block>
|
53 |
-
<block type="ewayrapid/adminhtml_customer_edit_tab_form" name="admin.customer.ewayrapid.form" template="ewayrapid/customer/edit/tab/form.phtml">
|
54 |
-
<action method="setCode"><code>ewayrapid</code></action>
|
55 |
-
</block>
|
56 |
-
</block>
|
57 |
-
</block>
|
58 |
-
<action method="addTab"><name>admin.customer.savedcard</name><block>admin.customer.savedcard</block></action>
|
59 |
-
</reference>
|
60 |
-
</adminhtml_customer_edit>
|
61 |
-
|
62 |
-
<adminhtml_ewayrapid_savedcard_load>
|
63 |
-
<block type="ewayrapid/adminhtml_customer_edit_tab_form" name="root" template="ewayrapid/customer/edit/tab/form.phtml">
|
64 |
-
<action method="setCode"><code>ewayrapid</code></action>
|
65 |
-
</block>
|
66 |
-
</adminhtml_ewayrapid_savedcard_load>
|
67 |
-
|
68 |
-
<adminhtml_ewayrapid_savedcard_save>
|
69 |
-
<block type="ewayrapid/adminhtml_customer_edit_tab_cards" name="root" template="ewayrapid/customer/edit/tab/cards.phtml">
|
70 |
-
<action method="setCode"><code>ewayrapid</code></action>
|
71 |
-
</block>
|
72 |
-
</adminhtml_ewayrapid_savedcard_save>
|
73 |
-
|
74 |
-
<adminhtml_ewayrapid_savedcard_savetoken>
|
75 |
-
<block type="ewayrapid/adminhtml_customer_edit_tab_cards" name="root" template="ewayrapid/customer/edit/tab/cards.phtml">
|
76 |
-
<action method="setCode"><code>ewayrapid</code></action>
|
77 |
-
</block>
|
78 |
-
</adminhtml_ewayrapid_savedcard_savetoken>
|
79 |
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<adminhtml_sales_order_create_index>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addExternalItem"><type>external_js</type><name>https://secure.ewaypayments.com/scripts/eCrypt.js</name><params/></action>
|
6 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
7 |
+
</reference>
|
8 |
+
<reference name="js">
|
9 |
+
<block type="core/template" name="ewayrapid.js" after="-">
|
10 |
+
<action method="setArea"><area>frontend</area></action>
|
11 |
+
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate" >
|
12 |
+
<template>ewayrapid/js.phtml</template>
|
13 |
+
</action>
|
14 |
+
</block>
|
15 |
+
</reference>
|
16 |
+
</adminhtml_sales_order_create_index>
|
17 |
+
<adminhtml_ewayadmin_ewayorders>
|
18 |
+
<reference name="menu">
|
19 |
+
<action method="setActive">
|
20 |
+
<menupath>sales/eway_orders</menupath>
|
21 |
+
</action>
|
22 |
+
</reference>
|
23 |
+
<reference name="content">
|
24 |
+
<block type="ewayrapid/adminhtml_sales_order" name="eway_orders" />
|
25 |
+
</reference>
|
26 |
+
</adminhtml_ewayadmin_ewayorders>
|
27 |
+
<adminhtml_ewayadmin_grid>
|
28 |
+
<update handle="formkey"/>
|
29 |
+
<block type="ewayrapid/adminhtml_sales_order_grid" name="eway_order.grid" output="toHtml"></block>
|
30 |
+
</adminhtml_ewayadmin_grid>
|
31 |
+
|
32 |
+
|
33 |
+
<adminhtml_customer_edit>
|
34 |
+
<reference name="head">
|
35 |
+
<action method="addExternalItem"><type>external_js</type><name>https://secure.ewaypayments.com/scripts/eCrypt.js</name><params/></action>
|
36 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
37 |
+
</reference>
|
38 |
+
<reference name="js">
|
39 |
+
<block type="core/template" name="ewayrapid.js" after="-">
|
40 |
+
<action method="setArea"><area>frontend</area></action>
|
41 |
+
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate" >
|
42 |
+
<template>ewayrapid/js.phtml</template>
|
43 |
+
</action>
|
44 |
+
</block>
|
45 |
+
</reference>
|
46 |
+
<reference name="customer_edit_tabs">
|
47 |
+
<block type="ewayrapid/adminhtml_customer_savedcard" name="admin.customer.savedcard" template="ewayrapid/customer/cardcontainer.phtml">
|
48 |
+
<block type="ewayrapid/adminhtml_customer_method" name="admin.customer.ewayrapid.method" template="ewayrapid/customer/method.phtml" before="-">
|
49 |
+
<action method="setCode"><code>ewayrapid</code></action>
|
50 |
+
<block type="ewayrapid/adminhtml_customer_edit_tab_cards" name="admin.customer.ewayrapid.cards" template="ewayrapid/customer/edit/tab/cards.phtml">
|
51 |
+
<action method="setCode"><code>ewayrapid</code></action>
|
52 |
+
</block>
|
53 |
+
<block type="ewayrapid/adminhtml_customer_edit_tab_form" name="admin.customer.ewayrapid.form" template="ewayrapid/customer/edit/tab/form.phtml">
|
54 |
+
<action method="setCode"><code>ewayrapid</code></action>
|
55 |
+
</block>
|
56 |
+
</block>
|
57 |
+
</block>
|
58 |
+
<action method="addTab"><name>admin.customer.savedcard</name><block>admin.customer.savedcard</block></action>
|
59 |
+
</reference>
|
60 |
+
</adminhtml_customer_edit>
|
61 |
+
|
62 |
+
<adminhtml_ewayrapid_savedcard_load>
|
63 |
+
<block type="ewayrapid/adminhtml_customer_edit_tab_form" name="root" template="ewayrapid/customer/edit/tab/form.phtml">
|
64 |
+
<action method="setCode"><code>ewayrapid</code></action>
|
65 |
+
</block>
|
66 |
+
</adminhtml_ewayrapid_savedcard_load>
|
67 |
+
|
68 |
+
<adminhtml_ewayrapid_savedcard_save>
|
69 |
+
<block type="ewayrapid/adminhtml_customer_edit_tab_cards" name="root" template="ewayrapid/customer/edit/tab/cards.phtml">
|
70 |
+
<action method="setCode"><code>ewayrapid</code></action>
|
71 |
+
</block>
|
72 |
+
</adminhtml_ewayrapid_savedcard_save>
|
73 |
+
|
74 |
+
<adminhtml_ewayrapid_savedcard_savetoken>
|
75 |
+
<block type="ewayrapid/adminhtml_customer_edit_tab_cards" name="root" template="ewayrapid/customer/edit/tab/cards.phtml">
|
76 |
+
<action method="setCode"><code>ewayrapid</code></action>
|
77 |
+
</block>
|
78 |
+
</adminhtml_ewayrapid_savedcard_savetoken>
|
79 |
</layout>
|
app/design/adminhtml/default/default/template/ewayrapid/customer/edit/tab/cards.phtml
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
-
<div class="entry-edit-head">
|
2 |
-
<h4 class="icon-head head-customer-address-list"><?php echo $this->__('Saved Card') ?></h4>
|
3 |
-
</div>
|
4 |
-
<div class="fieldset" style="padding:0">
|
5 |
-
<ol>
|
6 |
-
<?php if ($this->checkCards()): ?>
|
7 |
-
<?php foreach ($this->getCards() as $id => $card): ?>
|
8 |
-
<?php if(!$card->getActive()) continue; ?>
|
9 |
-
<li class="item info-box" id="token-<?php echo $id ?>" style="cursor:default">
|
10 |
-
<h3 class="box-title">
|
11 |
-
<?php if ($card->getExpYear()): ?>
|
12 |
-
<small class="right"><?php echo $card->getExpMonth() . '/' . $card->getExpYear() ?></small>
|
13 |
-
<?php endif; ?>
|
14 |
-
<?php echo $this->__('Card: %s', $card->getCard()) ?>
|
15 |
-
</h3>
|
16 |
-
<address class="box-content" style="overflow:auto">
|
17 |
-
|
18 |
-
<?php echo $this->formatAddress($card->getAddress()) ?>
|
19 |
-
<div class="right">
|
20 |
-
<?php if(Mage::helper('ewayrapid')->checkCardName($card) != Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD): ?>
|
21 |
-
<button class="button" type="button" onclick="ewayrapid.editCard( <?php echo $id; ?> );">
|
22 |
-
<span><?php echo $this->__('Edit'); ?></span>
|
23 |
-
</button>
|
24 |
-
<?php endif; ?>
|
25 |
-
<button class="button" type="button" onclick="ewayrapid.deleteCard( <?php echo $id; ?> );">
|
26 |
-
<span><?php echo $this->__('Delete'); ?></span>
|
27 |
-
</button>
|
28 |
-
</div>
|
29 |
-
</address>
|
30 |
-
</li>
|
31 |
-
<?php endforeach; ?>
|
32 |
-
<?php else: ?>
|
33 |
-
<li class="item"><?php echo $this->__('No payment data saved yet.') ?></li>
|
34 |
-
<?php endif; ?>
|
35 |
-
</ol>
|
36 |
-
</div>
|
1 |
+
<div class="entry-edit-head">
|
2 |
+
<h4 class="icon-head head-customer-address-list"><?php echo $this->__('Saved Card') ?></h4>
|
3 |
+
</div>
|
4 |
+
<div class="fieldset" style="padding:0">
|
5 |
+
<ol>
|
6 |
+
<?php if ($this->checkCards()): ?>
|
7 |
+
<?php foreach ($this->getCards() as $id => $card): ?>
|
8 |
+
<?php if(!$card->getActive()) continue; ?>
|
9 |
+
<li class="item info-box" id="token-<?php echo $id ?>" style="cursor:default">
|
10 |
+
<h3 class="box-title">
|
11 |
+
<?php if ($card->getExpYear()): ?>
|
12 |
+
<small class="right"><?php echo $card->getExpMonth() . '/' . $card->getExpYear() ?></small>
|
13 |
+
<?php endif; ?>
|
14 |
+
<?php echo $this->__('Card: %s', $card->getCard()) ?>
|
15 |
+
</h3>
|
16 |
+
<address class="box-content" style="overflow:auto">
|
17 |
+
|
18 |
+
<?php echo $this->formatAddress($card->getAddress()) ?>
|
19 |
+
<div class="right">
|
20 |
+
<?php if(Mage::helper('ewayrapid')->checkCardName($card) != Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD): ?>
|
21 |
+
<button class="button" type="button" onclick="ewayrapid.editCard( <?php echo $id; ?> );">
|
22 |
+
<span><?php echo $this->__('Edit'); ?></span>
|
23 |
+
</button>
|
24 |
+
<?php endif; ?>
|
25 |
+
<button class="button" type="button" onclick="ewayrapid.deleteCard( <?php echo $id; ?> );">
|
26 |
+
<span><?php echo $this->__('Delete'); ?></span>
|
27 |
+
</button>
|
28 |
+
</div>
|
29 |
+
</address>
|
30 |
+
</li>
|
31 |
+
<?php endforeach; ?>
|
32 |
+
<?php else: ?>
|
33 |
+
<li class="item"><?php echo $this->__('No payment data saved yet.') ?></li>
|
34 |
+
<?php endif; ?>
|
35 |
+
</ol>
|
36 |
+
</div>
|
app/design/adminhtml/default/default/template/ewayrapid/customer/edit/tab/form.phtml
CHANGED
@@ -1,218 +1,218 @@
|
|
1 |
-
<div class="entry-edit-head">
|
2 |
-
<h4 class="icon-head head-customer-address-list">
|
3 |
-
<?php if( $this->isEdit() ): ?>
|
4 |
-
<?php echo $this->__('Editing Card %s', $this->getCard()->getCard()); ?>
|
5 |
-
<?php else: ?>
|
6 |
-
<?php echo $this->__('Add A Credit Card') ?>
|
7 |
-
<?php endif; ?>
|
8 |
-
</h4>
|
9 |
-
</div>
|
10 |
-
<div class="fieldset">
|
11 |
-
<input type="hidden" id="token_id" name="<?php echo $this->getCode(); ?>[token_id]" value="<?php echo $this->getTokenId() ? $this->getTokenId() : 0; ?>" />
|
12 |
-
<input type="hidden" name="<?php echo $this->getCode(); ?>[TokenCustomerID]" value="<?php echo $this->getCard()->getToken() ? $this->getCard()->getToken() : ''; ?>" />
|
13 |
-
<h4><?php echo $this->__('Cardholder Information') ?></h4>
|
14 |
-
<table class="form-list" cellspacing="0">
|
15 |
-
<tr>
|
16 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_title"><?php echo $this->__('Title') ?></label></td>
|
17 |
-
<td class="value">
|
18 |
-
<select id="<?php echo $this->getCode(); ?>_title" name="<?php echo $this->getCode(); ?>[address][title]">
|
19 |
-
<?php foreach ($this->getPrefixOptions() as $_option): ?>
|
20 |
-
<option
|
21 |
-
value="<?php echo $_option ?>"<?php if ($this->getCard()->getAddress()->getTitle() == $_option): ?>
|
22 |
-
selected="selected"<?php endif; ?>><?php echo $this->__($_option) ?></option>
|
23 |
-
<?php endforeach; ?>
|
24 |
-
</select>
|
25 |
-
</td>
|
26 |
-
</tr>
|
27 |
-
<tr>
|
28 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_fn"><?php echo $this->__('First Name') ?> <span class="required">*</span></label></td>
|
29 |
-
<td class="value">
|
30 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_fn" name="<?php echo $this->getCode(); ?>[address][firstname]"
|
31 |
-
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('FirstName')); ?>" />
|
32 |
-
</td>
|
33 |
-
</tr>
|
34 |
-
<tr>
|
35 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_ln"><?php echo $this->__('Last Name') ?> <span class="required">*</span></label></td>
|
36 |
-
<td class="value">
|
37 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_ln" name="<?php echo $this->getCode(); ?>[address][lastname]"
|
38 |
-
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('LastName')); ?>" />
|
39 |
-
</td>
|
40 |
-
</tr>
|
41 |
-
<tr>
|
42 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_company"><?php echo $this->__('Company') ?></label></td>
|
43 |
-
<td class="value">
|
44 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_company" name="<?php echo $this->getCode(); ?>[address][company]" class="input-text" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getCompanyName()); ?>" />
|
45 |
-
</td>
|
46 |
-
</tr>
|
47 |
-
<tr>
|
48 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_job_desc"><?php echo $this->__('Job Description') ?></label></td>
|
49 |
-
<td class="value">
|
50 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_job_desc" name="<?php echo $this->getCode(); ?>[address][job_description]" class="input-text" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getJobDescription()); ?>" />
|
51 |
-
</td>
|
52 |
-
</tr>
|
53 |
-
<tr>
|
54 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_street1"><?php echo $this->__('Street Address') ?> <span class="required">*</span></label></td>
|
55 |
-
<td class="value">
|
56 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_street1" name="<?php echo $this->getCode(); ?>[address][street][]"
|
57 |
-
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getStreet1()); ?>" />
|
58 |
-
</td>
|
59 |
-
</tr>
|
60 |
-
<tr>
|
61 |
-
<td></td>
|
62 |
-
<td class="value">
|
63 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_street2" name="<?php echo $this->getCode(); ?>[address][street][]"
|
64 |
-
class="input-text save-card-validate" data-validate="validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getStreet2()); ?>" />
|
65 |
-
</td>
|
66 |
-
</tr>
|
67 |
-
<tr>
|
68 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_city"><?php echo $this->__('City') ?> <span class="required">*</span></label></td>
|
69 |
-
<td class="value">
|
70 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_city" name="<?php echo $this->getCode(); ?>[address][city]"
|
71 |
-
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('City')); ?>" />
|
72 |
-
</td>
|
73 |
-
</tr>
|
74 |
-
<tr>
|
75 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_region_id"><?php echo $this->__('State/Province') ?> <span class="required">*</span></label></td>
|
76 |
-
<td class="value">
|
77 |
-
<select class="validate-select" title="State/Province" name="<?php echo $this->getCode(); ?>[address][region_id]" id="<?php echo $this->getCode(); ?>_region_id">
|
78 |
-
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
79 |
-
</select>
|
80 |
-
<script type="text/javascript">
|
81 |
-
$('<?php echo $this->getCode(); ?>_region_id').setAttribute('defaultValue', '<?php echo $this->getRegionId()?>');
|
82 |
-
</script>
|
83 |
-
<input type="text" class="input-text" title="State/Province" value="<?php echo $this->escapeHtml( $this->getCard()->getAddress()->getData('State') ); ?>" name="<?php echo $this->getCode(); ?>[address][region]" id="<?php echo $this->getCode(); ?>_region" />
|
84 |
-
</td>
|
85 |
-
</tr>
|
86 |
-
<tr>
|
87 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label></td>
|
88 |
-
<td class="value">
|
89 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_postcode" name="<?php echo $this->getCode(); ?>[address][postcode]"
|
90 |
-
class="input-text save-card-validate" data-validate="required-entry validate-zip-international validate-length maximum-length-30" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('PostalCode')); ?>" />
|
91 |
-
</td>
|
92 |
-
</tr>
|
93 |
-
<tr>
|
94 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_country"><?php echo $this->__('Country') ?> <span class="required">*</span></label></td>
|
95 |
-
<td class="value">
|
96 |
-
<?php echo Mage::helper('ewayrapid')->getCountryHtmlSelect( $this->getCode() . '[address][country_id]',strtoupper($this->getCard()->getAddress()->getCountry()), $this->getCode().'_country' ); ?>
|
97 |
-
</td>
|
98 |
-
</tr>
|
99 |
-
<tr>
|
100 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_telephone"><?php echo $this->__('Telephone') ?> <span class="required">*</span></label></td>
|
101 |
-
<td class="value">
|
102 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_telephone" name="<?php echo $this->getCode(); ?>[address][telephone]"
|
103 |
-
class="input-text save-card-validate" data-validate="required-entry eway-validate-phone validate-length maximum-length-32" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('Phone')); ?>" />
|
104 |
-
</td>
|
105 |
-
</tr>
|
106 |
-
<tr>
|
107 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_mobile"><?php echo $this->__('Mobile') ?></label></td>
|
108 |
-
<td class="value">
|
109 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_mobile" name="<?php echo $this->getCode(); ?>[address][mobile]"
|
110 |
-
class="input-text save-card-validate" data-validate="eway-validate-phone validate-length maximum-length-32" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getMobile()); ?>" />
|
111 |
-
</td>
|
112 |
-
</tr>
|
113 |
-
<tr>
|
114 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_email"><?php echo $this->__('Email') ?></label></td>
|
115 |
-
<td class="value">
|
116 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_email" name="<?php echo $this->getCode(); ?>[address][email]"
|
117 |
-
class="input-text save-card-validate" data-validate="validate-email validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getEmail()); ?>" />
|
118 |
-
</td>
|
119 |
-
</tr>
|
120 |
-
<tr>
|
121 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_fax"><?php echo $this->__('Fax') ?></label></td>
|
122 |
-
<td class="value">
|
123 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_fax" name="<?php echo $this->getCode(); ?>[address][fax]"
|
124 |
-
class="input-text save-card-validate" data-validate="eway-validate-phone validate-length maximum-length-32" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('Fax')); ?>" />
|
125 |
-
</td>
|
126 |
-
</tr>
|
127 |
-
</table>
|
128 |
-
|
129 |
-
<?php if(!Mage::helper('ewayrapid')->useIframeInBackend()): ?>
|
130 |
-
<h4><?php echo $this->__('Credit Card Information') ?></h4>
|
131 |
-
<table class="form-list" cellspacing="0" id="<?php echo $this->getCode(); ?>_ccInfo">
|
132 |
-
<tr>
|
133 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_cc_owner"><?php echo $this->__('Name on Card') ?> <span class="required">*</span></label></td>
|
134 |
-
<td class="value">
|
135 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_cc_owner" name="<?php echo $this->getCode(); ?>[payment][cc_owner]" title="<?php echo $this->__('Card Holder Name') ?>"
|
136 |
-
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getOwner()); ?>" autocomplete="off" />
|
137 |
-
</td>
|
138 |
-
</tr>
|
139 |
-
<tr>
|
140 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_cc_number"><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label></td>
|
141 |
-
<td class="value">
|
142 |
-
<input type="text" id="<?php echo $this->getCode(); ?>_saved_cc_number" name="<?php echo $this->getCode(); ?>[payment][cc_number]"
|
143 |
-
title="<?php echo $this->__('Credit Card Number') ?>" class="input-text save-card-validate"
|
144 |
-
data-validate="validate-cc-number validate-cc-type-auto validate-cc-type"
|
145 |
-
<?php if($this->isEdit()): ?>value="<?php echo $this->escapeHtml($this->getCard()->getCard()); ?>" disabled="disabled" <?php endif;?> autocomplete="off" />
|
146 |
-
<input type="hidden" id="<?php echo $this->getCode(); ?>_saved_cc_type" name="<?php echo $this->getCode(); ?>[payment][cc_type]"
|
147 |
-
value="<?php echo $this->getCard()->getType() ?>"/>
|
148 |
-
</td>
|
149 |
-
</tr>
|
150 |
-
<tr>
|
151 |
-
<td class="label"><label for="<?php echo $this->getCode(); ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label></td>
|
152 |
-
<td class="value">
|
153 |
-
<select id="<?php echo $this->getCode(); ?>_expiration" name="<?php echo $this->getCode(); ?>[payment][cc_exp_month]" class="month save-card-validate"
|
154 |
-
data-validate="validate-cc-exp required-entry" style="width:150px">
|
155 |
-
<option value=""><?php echo $this->__('Month') ?></option>
|
156 |
-
<?php $_ccExpMonth = $this->getCard()->getExpMonth() ?>
|
157 |
-
<?php foreach(Mage::getSingleton('payment/config')->getMonths() as $k=>$v ): ?>
|
158 |
-
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
159 |
-
<?php endforeach ?>
|
160 |
-
</select>
|
161 |
-
|
162 |
-
<select id="<?php echo $this->getCode(); ?>_expiration_yr" name="<?php echo $this->getCode(); ?>[payment][cc_exp_year]" class="year" style="width:80px">
|
163 |
-
<option value=""><?php echo $this->__('Year') ?></option>
|
164 |
-
<?php $_ccExpYear = $this->getCard()->getExpYear() ?>
|
165 |
-
<?php foreach(Mage::getSingleton('payment/config')->getYears() as $k=>$v ): ?>
|
166 |
-
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
167 |
-
<?php endforeach ?>
|
168 |
-
</select>
|
169 |
-
</td>
|
170 |
-
</tr>
|
171 |
-
<!-- --><?php //if( Mage::helper('payment')->getMethodInstance( $this->getCode() )->getConfigData('useccv') ): ?>
|
172 |
-
<!-- <tr>-->
|
173 |
-
<!-- <td class="label"><label for="--><?php //echo $this->getCode(); ?><!--_cc_cid">--><?php //echo $this->__('Card Verification Number') ?><!-- <span class="required">*</span></label></td>-->
|
174 |
-
<!-- <td class="value">-->
|
175 |
-
<!-- <input type="text" title="--><?php //echo $this->__('Card Verification Number') ?><!--" class="input-text cvv" id="--><?php //echo $this->getCode(); ?><!--_cc_cid" name="--><?php //echo $this->getCode(); ?><!--[payment][cc_cid]" value="" style="width:50px" autocomplete="off" />-->
|
176 |
-
<!-- </td>-->
|
177 |
-
<!-- </tr>-->
|
178 |
-
<!-- --><?php //endif; ?>
|
179 |
-
</table>
|
180 |
-
<!-- --><?php //$requireCvv = Mage::helper('payment')->getMethodInstance( $this->getCode() )->getAdvancedConfigData('require_ccv'); ?>
|
181 |
-
<!-- --><?php //if( $this->isEdit() && Mage::helper('payment')->getMethodInstance( $this->getCode() )->getConfigData('useccv') && $requireCvv ): ?>
|
182 |
-
<!-- <table class="form-list" cellspacing="0" id="--><?php //echo $this->getCode(); ?><!--_ccInfoCcv">-->
|
183 |
-
<!-- <tr>-->
|
184 |
-
<!-- <td class="label"><label for="--><?php //echo $this->getCode(); ?><!--_saved_cc_cid">--><?php //echo $this->__('Card Verification Number') ?><!-- <span class="required">*</span></label></td>-->
|
185 |
-
<!-- <td class="value">-->
|
186 |
-
<!-- <input type="text" title="--><?php //echo $this->__('Card Verification Number') ?><!--" class="input-text cvv" id="--><?php //echo $this->getCode(); ?><!--_saved_cc_cid" name="--><?php //echo $this->getCode(); ?><!--[payment][saved_cc_cid]" value="" style="width:50px" autocomplete="off" />-->
|
187 |
-
<!-- </td>-->
|
188 |
-
<!-- </tr>-->
|
189 |
-
<!-- </table>-->
|
190 |
-
<!-- --><?php //endif; ?>
|
191 |
-
<?php endif; ?>
|
192 |
-
<table class="form-list" cellspacing="0">
|
193 |
-
<tr>
|
194 |
-
<td class="label"></td>
|
195 |
-
<td class="value">
|
196 |
-
<button class="button" type="button" onclick="<?php echo $this->getCode(); ?>.saveCard(<?php echo $this->getCard()->getToken() ? $this->getCard()->getToken() : ''?>);"><span><?php echo $this->__('Save') ?></span></button>
|
197 |
-
<a href="#" onclick="<?php echo $this->getCode(); ?>.editCard(0); return false;"><?php echo $this->__('Cancel'); ?></a>
|
198 |
-
</td>
|
199 |
-
</tr>
|
200 |
-
</table>
|
201 |
-
</div>
|
202 |
-
<script type="text/javascript">
|
203 |
-
//<![CDATA[
|
204 |
-
new RegionUpdater('<?php echo $this->getCode(); ?>_country', '<?php echo $this->getCode(); ?>_region', '<?php echo $this->getCode(); ?>_region_id', <?php echo Mage::helper('directory')->getRegionJson() ?>, undefined, '<?php echo $this->getCode(); ?>_postcode');
|
205 |
-
|
206 |
-
function <?php echo $this->getCode(); ?>_clearAddrValidation() {
|
207 |
-
$('<?php echo $this->getCode(); ?>_region_id').removeClassName('required-entry').removeClassName('validate-select');
|
208 |
-
$('<?php echo $this->getCode(); ?>_country').removeClassName('required-entry').removeClassName('validate-select');
|
209 |
-
$('<?php echo $this->getCode(); ?>_region').removeClassName('required-entry');
|
210 |
-
$('<?php echo $this->getCode(); ?>_postcode').removeClassName('required-entry');
|
211 |
-
}
|
212 |
-
|
213 |
-
/* Prevent the region from holding up submit... */
|
214 |
-
document.observe("dom:loaded", function() {
|
215 |
-
<?php echo $this->getCode(); ?>_clearAddrValidation();
|
216 |
-
});
|
217 |
-
//]]>
|
218 |
-
</script>
|
1 |
+
<div class="entry-edit-head">
|
2 |
+
<h4 class="icon-head head-customer-address-list">
|
3 |
+
<?php if( $this->isEdit() ): ?>
|
4 |
+
<?php echo $this->__('Editing Card %s', $this->getCard()->getCard()); ?>
|
5 |
+
<?php else: ?>
|
6 |
+
<?php echo $this->__('Add A Credit Card') ?>
|
7 |
+
<?php endif; ?>
|
8 |
+
</h4>
|
9 |
+
</div>
|
10 |
+
<div class="fieldset">
|
11 |
+
<input type="hidden" id="token_id" name="<?php echo $this->getCode(); ?>[token_id]" value="<?php echo $this->getTokenId() ? $this->getTokenId() : 0; ?>" />
|
12 |
+
<input type="hidden" name="<?php echo $this->getCode(); ?>[TokenCustomerID]" value="<?php echo $this->getCard()->getToken() ? $this->getCard()->getToken() : ''; ?>" />
|
13 |
+
<h4><?php echo $this->__('Cardholder Information') ?></h4>
|
14 |
+
<table class="form-list" cellspacing="0">
|
15 |
+
<tr>
|
16 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_title"><?php echo $this->__('Title') ?></label></td>
|
17 |
+
<td class="value">
|
18 |
+
<select id="<?php echo $this->getCode(); ?>_title" name="<?php echo $this->getCode(); ?>[address][title]">
|
19 |
+
<?php foreach ($this->getPrefixOptions() as $_option): ?>
|
20 |
+
<option
|
21 |
+
value="<?php echo $_option ?>"<?php if ($this->getCard()->getAddress()->getTitle() == $_option): ?>
|
22 |
+
selected="selected"<?php endif; ?>><?php echo $this->__($_option) ?></option>
|
23 |
+
<?php endforeach; ?>
|
24 |
+
</select>
|
25 |
+
</td>
|
26 |
+
</tr>
|
27 |
+
<tr>
|
28 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_fn"><?php echo $this->__('First Name') ?> <span class="required">*</span></label></td>
|
29 |
+
<td class="value">
|
30 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_fn" name="<?php echo $this->getCode(); ?>[address][firstname]"
|
31 |
+
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('FirstName')); ?>" />
|
32 |
+
</td>
|
33 |
+
</tr>
|
34 |
+
<tr>
|
35 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_ln"><?php echo $this->__('Last Name') ?> <span class="required">*</span></label></td>
|
36 |
+
<td class="value">
|
37 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_ln" name="<?php echo $this->getCode(); ?>[address][lastname]"
|
38 |
+
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('LastName')); ?>" />
|
39 |
+
</td>
|
40 |
+
</tr>
|
41 |
+
<tr>
|
42 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_company"><?php echo $this->__('Company') ?></label></td>
|
43 |
+
<td class="value">
|
44 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_company" name="<?php echo $this->getCode(); ?>[address][company]" class="input-text" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getCompanyName()); ?>" />
|
45 |
+
</td>
|
46 |
+
</tr>
|
47 |
+
<tr>
|
48 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_job_desc"><?php echo $this->__('Job Description') ?></label></td>
|
49 |
+
<td class="value">
|
50 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_job_desc" name="<?php echo $this->getCode(); ?>[address][job_description]" class="input-text" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getJobDescription()); ?>" />
|
51 |
+
</td>
|
52 |
+
</tr>
|
53 |
+
<tr>
|
54 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_street1"><?php echo $this->__('Street Address') ?> <span class="required">*</span></label></td>
|
55 |
+
<td class="value">
|
56 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_street1" name="<?php echo $this->getCode(); ?>[address][street][]"
|
57 |
+
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getStreet1()); ?>" />
|
58 |
+
</td>
|
59 |
+
</tr>
|
60 |
+
<tr>
|
61 |
+
<td></td>
|
62 |
+
<td class="value">
|
63 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_street2" name="<?php echo $this->getCode(); ?>[address][street][]"
|
64 |
+
class="input-text save-card-validate" data-validate="validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getStreet2()); ?>" />
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
<tr>
|
68 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_city"><?php echo $this->__('City') ?> <span class="required">*</span></label></td>
|
69 |
+
<td class="value">
|
70 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_city" name="<?php echo $this->getCode(); ?>[address][city]"
|
71 |
+
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('City')); ?>" />
|
72 |
+
</td>
|
73 |
+
</tr>
|
74 |
+
<tr>
|
75 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_region_id"><?php echo $this->__('State/Province') ?> <span class="required">*</span></label></td>
|
76 |
+
<td class="value">
|
77 |
+
<select class="validate-select" title="State/Province" name="<?php echo $this->getCode(); ?>[address][region_id]" id="<?php echo $this->getCode(); ?>_region_id">
|
78 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
79 |
+
</select>
|
80 |
+
<script type="text/javascript">
|
81 |
+
$('<?php echo $this->getCode(); ?>_region_id').setAttribute('defaultValue', '<?php echo $this->getRegionId()?>');
|
82 |
+
</script>
|
83 |
+
<input type="text" class="input-text" title="State/Province" value="<?php echo $this->escapeHtml( $this->getCard()->getAddress()->getData('State') ); ?>" name="<?php echo $this->getCode(); ?>[address][region]" id="<?php echo $this->getCode(); ?>_region" />
|
84 |
+
</td>
|
85 |
+
</tr>
|
86 |
+
<tr>
|
87 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label></td>
|
88 |
+
<td class="value">
|
89 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_postcode" name="<?php echo $this->getCode(); ?>[address][postcode]"
|
90 |
+
class="input-text save-card-validate" data-validate="required-entry validate-zip-international validate-length maximum-length-30" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('PostalCode')); ?>" />
|
91 |
+
</td>
|
92 |
+
</tr>
|
93 |
+
<tr>
|
94 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_country"><?php echo $this->__('Country') ?> <span class="required">*</span></label></td>
|
95 |
+
<td class="value">
|
96 |
+
<?php echo Mage::helper('ewayrapid')->getCountryHtmlSelect( $this->getCode() . '[address][country_id]',strtoupper($this->getCard()->getAddress()->getCountry()), $this->getCode().'_country' ); ?>
|
97 |
+
</td>
|
98 |
+
</tr>
|
99 |
+
<tr>
|
100 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_telephone"><?php echo $this->__('Telephone') ?> <span class="required">*</span></label></td>
|
101 |
+
<td class="value">
|
102 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_telephone" name="<?php echo $this->getCode(); ?>[address][telephone]"
|
103 |
+
class="input-text save-card-validate" data-validate="required-entry eway-validate-phone validate-length maximum-length-32" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('Phone')); ?>" />
|
104 |
+
</td>
|
105 |
+
</tr>
|
106 |
+
<tr>
|
107 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_mobile"><?php echo $this->__('Mobile') ?></label></td>
|
108 |
+
<td class="value">
|
109 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_mobile" name="<?php echo $this->getCode(); ?>[address][mobile]"
|
110 |
+
class="input-text save-card-validate" data-validate="eway-validate-phone validate-length maximum-length-32" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getMobile()); ?>" />
|
111 |
+
</td>
|
112 |
+
</tr>
|
113 |
+
<tr>
|
114 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_email"><?php echo $this->__('Email') ?></label></td>
|
115 |
+
<td class="value">
|
116 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_email" name="<?php echo $this->getCode(); ?>[address][email]"
|
117 |
+
class="input-text save-card-validate" data-validate="validate-email validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getEmail()); ?>" />
|
118 |
+
</td>
|
119 |
+
</tr>
|
120 |
+
<tr>
|
121 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_fax"><?php echo $this->__('Fax') ?></label></td>
|
122 |
+
<td class="value">
|
123 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_fax" name="<?php echo $this->getCode(); ?>[address][fax]"
|
124 |
+
class="input-text save-card-validate" data-validate="eway-validate-phone validate-length maximum-length-32" value="<?php echo $this->escapeHtml($this->getCard()->getAddress()->getData('Fax')); ?>" />
|
125 |
+
</td>
|
126 |
+
</tr>
|
127 |
+
</table>
|
128 |
+
|
129 |
+
<?php if(!Mage::helper('ewayrapid')->useIframeInBackend()): ?>
|
130 |
+
<h4><?php echo $this->__('Credit Card Information') ?></h4>
|
131 |
+
<table class="form-list" cellspacing="0" id="<?php echo $this->getCode(); ?>_ccInfo">
|
132 |
+
<tr>
|
133 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_cc_owner"><?php echo $this->__('Name on Card') ?> <span class="required">*</span></label></td>
|
134 |
+
<td class="value">
|
135 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_cc_owner" name="<?php echo $this->getCode(); ?>[payment][cc_owner]" title="<?php echo $this->__('Card Holder Name') ?>"
|
136 |
+
class="input-text save-card-validate" data-validate="required-entry validate-length maximum-length-50" value="<?php echo $this->escapeHtml($this->getCard()->getOwner()); ?>" autocomplete="off" />
|
137 |
+
</td>
|
138 |
+
</tr>
|
139 |
+
<tr>
|
140 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_cc_number"><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label></td>
|
141 |
+
<td class="value">
|
142 |
+
<input type="text" id="<?php echo $this->getCode(); ?>_saved_cc_number" name="<?php echo $this->getCode(); ?>[payment][cc_number]"
|
143 |
+
title="<?php echo $this->__('Credit Card Number') ?>" class="input-text save-card-validate"
|
144 |
+
data-validate="validate-cc-number validate-cc-type-auto validate-cc-type"
|
145 |
+
<?php if($this->isEdit()): ?>value="<?php echo $this->escapeHtml($this->getCard()->getCard()); ?>" disabled="disabled" <?php endif;?> autocomplete="off" />
|
146 |
+
<input type="hidden" id="<?php echo $this->getCode(); ?>_saved_cc_type" name="<?php echo $this->getCode(); ?>[payment][cc_type]"
|
147 |
+
value="<?php echo $this->getCard()->getType() ?>"/>
|
148 |
+
</td>
|
149 |
+
</tr>
|
150 |
+
<tr>
|
151 |
+
<td class="label"><label for="<?php echo $this->getCode(); ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label></td>
|
152 |
+
<td class="value">
|
153 |
+
<select id="<?php echo $this->getCode(); ?>_expiration" name="<?php echo $this->getCode(); ?>[payment][cc_exp_month]" class="month save-card-validate"
|
154 |
+
data-validate="validate-cc-exp required-entry" style="width:150px">
|
155 |
+
<option value=""><?php echo $this->__('Month') ?></option>
|
156 |
+
<?php $_ccExpMonth = $this->getCard()->getExpMonth() ?>
|
157 |
+
<?php foreach(Mage::getSingleton('payment/config')->getMonths() as $k=>$v ): ?>
|
158 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
159 |
+
<?php endforeach ?>
|
160 |
+
</select>
|
161 |
+
|
162 |
+
<select id="<?php echo $this->getCode(); ?>_expiration_yr" name="<?php echo $this->getCode(); ?>[payment][cc_exp_year]" class="year" style="width:80px">
|
163 |
+
<option value=""><?php echo $this->__('Year') ?></option>
|
164 |
+
<?php $_ccExpYear = $this->getCard()->getExpYear() ?>
|
165 |
+
<?php foreach(Mage::getSingleton('payment/config')->getYears() as $k=>$v ): ?>
|
166 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
167 |
+
<?php endforeach ?>
|
168 |
+
</select>
|
169 |
+
</td>
|
170 |
+
</tr>
|
171 |
+
<!-- --><?php //if( Mage::helper('payment')->getMethodInstance( $this->getCode() )->getConfigData('useccv') ): ?>
|
172 |
+
<!-- <tr>-->
|
173 |
+
<!-- <td class="label"><label for="--><?php //echo $this->getCode(); ?><!--_cc_cid">--><?php //echo $this->__('Card Verification Number') ?><!-- <span class="required">*</span></label></td>-->
|
174 |
+
<!-- <td class="value">-->
|
175 |
+
<!-- <input type="text" title="--><?php //echo $this->__('Card Verification Number') ?><!--" class="input-text cvv" id="--><?php //echo $this->getCode(); ?><!--_cc_cid" name="--><?php //echo $this->getCode(); ?><!--[payment][cc_cid]" value="" style="width:50px" autocomplete="off" />-->
|
176 |
+
<!-- </td>-->
|
177 |
+
<!-- </tr>-->
|
178 |
+
<!-- --><?php //endif; ?>
|
179 |
+
</table>
|
180 |
+
<!-- --><?php //$requireCvv = Mage::helper('payment')->getMethodInstance( $this->getCode() )->getAdvancedConfigData('require_ccv'); ?>
|
181 |
+
<!-- --><?php //if( $this->isEdit() && Mage::helper('payment')->getMethodInstance( $this->getCode() )->getConfigData('useccv') && $requireCvv ): ?>
|
182 |
+
<!-- <table class="form-list" cellspacing="0" id="--><?php //echo $this->getCode(); ?><!--_ccInfoCcv">-->
|
183 |
+
<!-- <tr>-->
|
184 |
+
<!-- <td class="label"><label for="--><?php //echo $this->getCode(); ?><!--_saved_cc_cid">--><?php //echo $this->__('Card Verification Number') ?><!-- <span class="required">*</span></label></td>-->
|
185 |
+
<!-- <td class="value">-->
|
186 |
+
<!-- <input type="text" title="--><?php //echo $this->__('Card Verification Number') ?><!--" class="input-text cvv" id="--><?php //echo $this->getCode(); ?><!--_saved_cc_cid" name="--><?php //echo $this->getCode(); ?><!--[payment][saved_cc_cid]" value="" style="width:50px" autocomplete="off" />-->
|
187 |
+
<!-- </td>-->
|
188 |
+
<!-- </tr>-->
|
189 |
+
<!-- </table>-->
|
190 |
+
<!-- --><?php //endif; ?>
|
191 |
+
<?php endif; ?>
|
192 |
+
<table class="form-list" cellspacing="0">
|
193 |
+
<tr>
|
194 |
+
<td class="label"></td>
|
195 |
+
<td class="value">
|
196 |
+
<button class="button" type="button" onclick="<?php echo $this->getCode(); ?>.saveCard(<?php echo $this->getCard()->getToken() ? $this->getCard()->getToken() : ''?>);"><span><?php echo $this->__('Save') ?></span></button>
|
197 |
+
<a href="#" onclick="<?php echo $this->getCode(); ?>.editCard(0); return false;"><?php echo $this->__('Cancel'); ?></a>
|
198 |
+
</td>
|
199 |
+
</tr>
|
200 |
+
</table>
|
201 |
+
</div>
|
202 |
+
<script type="text/javascript">
|
203 |
+
//<![CDATA[
|
204 |
+
new RegionUpdater('<?php echo $this->getCode(); ?>_country', '<?php echo $this->getCode(); ?>_region', '<?php echo $this->getCode(); ?>_region_id', <?php echo Mage::helper('directory')->getRegionJson() ?>, undefined, '<?php echo $this->getCode(); ?>_postcode');
|
205 |
+
|
206 |
+
function <?php echo $this->getCode(); ?>_clearAddrValidation() {
|
207 |
+
$('<?php echo $this->getCode(); ?>_region_id').removeClassName('required-entry').removeClassName('validate-select');
|
208 |
+
$('<?php echo $this->getCode(); ?>_country').removeClassName('required-entry').removeClassName('validate-select');
|
209 |
+
$('<?php echo $this->getCode(); ?>_region').removeClassName('required-entry');
|
210 |
+
$('<?php echo $this->getCode(); ?>_postcode').removeClassName('required-entry');
|
211 |
+
}
|
212 |
+
|
213 |
+
/* Prevent the region from holding up submit... */
|
214 |
+
document.observe("dom:loaded", function() {
|
215 |
+
<?php echo $this->getCode(); ?>_clearAddrValidation();
|
216 |
+
});
|
217 |
+
//]]>
|
218 |
+
</script>
|
app/design/adminhtml/default/default/template/ewayrapid/customer/method.phtml
CHANGED
@@ -1,175 +1,175 @@
|
|
1 |
-
<?php if( !$this->isAjax() ): ?>
|
2 |
-
<table id="tokenbase-edit-<?php echo $this->getCode(); ?>" class="form-edit" cellspacing="0">
|
3 |
-
<?php endif; ?>
|
4 |
-
<tr>
|
5 |
-
<td id="<?php echo $this->getCode(); ?>-cards" class="address-list">
|
6 |
-
<?php echo $this->getChildHtml('admin.customer.ewayrapid.cards'); ?>
|
7 |
-
</td>
|
8 |
-
<td id="<?php echo $this->getCode(); ?>-form">
|
9 |
-
<?php echo $this->getChildHtml('admin.customer.ewayrapid.form'); ?>
|
10 |
-
</td>
|
11 |
-
</tr>
|
12 |
-
<?php if( !$this->isAjax() ): ?>
|
13 |
-
</table>
|
14 |
-
<?php endif; ?>
|
15 |
-
|
16 |
-
<?php if( !$this->isAjax() ): ?>
|
17 |
-
<script type="text/javascript">
|
18 |
-
var encryptKey = '<?php echo Mage::getSingleton('ewayrapid/config')->getEncryptionKey() ?>';
|
19 |
-
var accessCode = '';
|
20 |
-
var saveTokenResult = '';
|
21 |
-
//<![CDATA[
|
22 |
-
var <?php echo $this->getCode(); ?> = {
|
23 |
-
deleteCard: function( id ) {
|
24 |
-
if( confirm("<?php echo $this->__('Are you sure you want to delete this?'); ?>") ) {
|
25 |
-
Element.show('loading-mask');
|
26 |
-
new Ajax.Request("<?php echo $this->getUrl('*/ewayrapid_savedcard/delete', array('customer_id' => $this->getCustomer()->getId())); ?>", {
|
27 |
-
method: 'post',
|
28 |
-
parameters: "token_id="+id,
|
29 |
-
evalScripts: true,
|
30 |
-
onComplete: function(data) {
|
31 |
-
Element.hide('loading-mask');
|
32 |
-
|
33 |
-
try {
|
34 |
-
var json = data.responseText.evalJSON();
|
35 |
-
} catch(e) {}
|
36 |
-
|
37 |
-
if( typeof json != 'undefined' && json.success == false ) {
|
38 |
-
alert( json.message );
|
39 |
-
}
|
40 |
-
else {
|
41 |
-
$('token-'+id).hide();
|
42 |
-
<?php echo $this->getCode(); ?>.editCard(0);
|
43 |
-
}
|
44 |
-
}
|
45 |
-
});
|
46 |
-
}
|
47 |
-
},
|
48 |
-
|
49 |
-
editCard: function( id ) {
|
50 |
-
Element.show('loading-mask');
|
51 |
-
new Ajax.Request("<?php echo $this->getUrl('*/ewayrapid_savedcard/load', array('customer_id' => $this->getCustomer()->getId())); ?>", {
|
52 |
-
method: 'post',
|
53 |
-
parameters: "token_id="+id,
|
54 |
-
evalScripts: true,
|
55 |
-
onComplete: function(data) {
|
56 |
-
Element.hide('loading-mask');
|
57 |
-
|
58 |
-
try {
|
59 |
-
var json = data.responseText.evalJSON();
|
60 |
-
} catch(e) {}
|
61 |
-
|
62 |
-
if( typeof json != 'undefined' && json.success == false ) {
|
63 |
-
alert( json.message );
|
64 |
-
}
|
65 |
-
else {
|
66 |
-
$('<?php echo $this->getCode(); ?>-form').update( data.responseText );
|
67 |
-
}
|
68 |
-
}
|
69 |
-
});
|
70 |
-
},
|
71 |
-
|
72 |
-
saveCard: function(customertokenid) {
|
73 |
-
var form = $('edit_form');
|
74 |
-
form.writeAttribute('data-eway-encrypt-key', encryptKey);
|
75 |
-
if(!validateForm()){
|
76 |
-
return;
|
77 |
-
}
|
78 |
-
var ewayForm = new EwayForm();
|
79 |
-
var submitForm = ewayForm.encryptForm(form, true);
|
80 |
-
|
81 |
-
Element.show('loading-mask');
|
82 |
-
var url = '';
|
83 |
-
<?php if(Mage::helper('ewayrapid')->useIframeInBackend()): ?>
|
84 |
-
url = '<?php echo $this->getUrl('*/ewayrapid_savedcard/getAccessCode', array('customer_id' => $this->getCustomer()->getId())); ?>';
|
85 |
-
<?php else: ?>
|
86 |
-
url = '<?php echo $this->getUrl('*/ewayrapid_savedcard/save', array('customer_id' => $this->getCustomer()->getId())); ?>'
|
87 |
-
<?php endif; ?>
|
88 |
-
|
89 |
-
if(customertokenid){
|
90 |
-
url += 'TokenCustomerID/' + customertokenid;
|
91 |
-
}
|
92 |
-
new Ajax.Request(url, {
|
93 |
-
method: 'post',
|
94 |
-
parameters: Form.serialize(submitForm, true),
|
95 |
-
evalScripts: true,
|
96 |
-
onComplete: function(data) {
|
97 |
-
Element.hide('loading-mask');
|
98 |
-
try {
|
99 |
-
var json = data.responseText.evalJSON();
|
100 |
-
} catch(e) {}
|
101 |
-
|
102 |
-
if( typeof json != 'undefined' && json.success == false ) {
|
103 |
-
alert( json.message );
|
104 |
-
}
|
105 |
-
else {
|
106 |
-
<?php if(Mage::helper('ewayrapid')->useIframeInBackend()): ?>
|
107 |
-
var eWAYConfig = {
|
108 |
-
sharedPaymentUrl: json.SharedPaymentUrl
|
109 |
-
};
|
110 |
-
ewayReturnUrl = '<?php echo $this->getUrl('*/ewayrapid_savedcard/savetoken', array('customer_id' => $this->getCustomer()->getId())); ?>';
|
111 |
-
saveTokenResult = json;
|
112 |
-
Element.show('loading-mask');
|
113 |
-
eCrypt.showModalPayment(eWAYConfig, saveTokenCallBack);
|
114 |
-
<?php else: ?>
|
115 |
-
$('<?php echo $this->getCode(); ?>-cards').update(data.responseText);
|
116 |
-
<?php echo $this->getCode(); ?>.editCard(0);
|
117 |
-
<?php endif; ?>
|
118 |
-
}
|
119 |
-
}
|
120 |
-
});
|
121 |
-
}
|
122 |
-
}
|
123 |
-
|
124 |
-
function saveTokenCallBack (result, transactionID, errors) {
|
125 |
-
if (result == "Complete") {
|
126 |
-
var reqParams = {
|
127 |
-
// 'ccType': '',
|
128 |
-
// 'expYear': saveTokenResult.Customer.CardExpiryYear,
|
129 |
-
'token_id': $('token_id').value,
|
130 |
-
// 'startMonth': saveTokenResult.Customer.CardStartMonth,
|
131 |
-
// 'startYear': saveTokenResult.Customer.CardStartYear,
|
132 |
-
// 'issueNumber': saveTokenResult.Customer.CardIssueNumber,
|
133 |
-
'AccessCode': saveTokenResult.AccessCode,
|
134 |
-
'street1': saveTokenResult.street1,
|
135 |
-
'street2': saveTokenResult.street2
|
136 |
-
};
|
137 |
-
new Ajax.Request(ewayReturnUrl, {
|
138 |
-
method: 'post',
|
139 |
-
parameters: reqParams,
|
140 |
-
evalScripts: true,
|
141 |
-
onComplete: function(data) {
|
142 |
-
Element.hide('loading-mask');
|
143 |
-
try {
|
144 |
-
var json = data.responseText.evalJSON();
|
145 |
-
} catch(e) {}
|
146 |
-
|
147 |
-
if( typeof json != 'undefined' && json.success == false ) {
|
148 |
-
alert( json.message );
|
149 |
-
}
|
150 |
-
else {
|
151 |
-
$('<?php echo $this->getCode(); ?>-cards').update( data.responseText );
|
152 |
-
<?php echo $this->getCode(); ?>.editCard(0);
|
153 |
-
}
|
154 |
-
}
|
155 |
-
});
|
156 |
-
} else if (result == "Error") {
|
157 |
-
alert("There was a problem completing the payment: " + errors);
|
158 |
-
Element.hide('loading-mask');
|
159 |
-
} else{
|
160 |
-
Element.hide('loading-mask');
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
function validateForm(){
|
165 |
-
$$('.save-card-validate').each(function(ele){
|
166 |
-
var eleValidate = ele.getAttribute('data-validate');
|
167 |
-
ele.addClassName(eleValidate);
|
168 |
-
});
|
169 |
-
$('ewayrapid_region_id') && $('ewayrapid_region_id').addClassName('required-entry').addClassName('validate-select');
|
170 |
-
var validator = new Validation('edit_form');
|
171 |
-
return validator.validate();
|
172 |
-
}
|
173 |
-
//]]!>
|
174 |
-
</script>
|
175 |
-
<?php endif; ?>
|
1 |
+
<?php if( !$this->isAjax() ): ?>
|
2 |
+
<table id="tokenbase-edit-<?php echo $this->getCode(); ?>" class="form-edit" cellspacing="0">
|
3 |
+
<?php endif; ?>
|
4 |
+
<tr>
|
5 |
+
<td id="<?php echo $this->getCode(); ?>-cards" class="address-list">
|
6 |
+
<?php echo $this->getChildHtml('admin.customer.ewayrapid.cards'); ?>
|
7 |
+
</td>
|
8 |
+
<td id="<?php echo $this->getCode(); ?>-form">
|
9 |
+
<?php echo $this->getChildHtml('admin.customer.ewayrapid.form'); ?>
|
10 |
+
</td>
|
11 |
+
</tr>
|
12 |
+
<?php if( !$this->isAjax() ): ?>
|
13 |
+
</table>
|
14 |
+
<?php endif; ?>
|
15 |
+
|
16 |
+
<?php if( !$this->isAjax() ): ?>
|
17 |
+
<script type="text/javascript">
|
18 |
+
var encryptKey = '<?php echo Mage::getSingleton('ewayrapid/config')->getEncryptionKey() ?>';
|
19 |
+
var accessCode = '';
|
20 |
+
var saveTokenResult = '';
|
21 |
+
//<![CDATA[
|
22 |
+
var <?php echo $this->getCode(); ?> = {
|
23 |
+
deleteCard: function( id ) {
|
24 |
+
if( confirm("<?php echo $this->__('Are you sure you want to delete this?'); ?>") ) {
|
25 |
+
Element.show('loading-mask');
|
26 |
+
new Ajax.Request("<?php echo $this->getUrl('*/ewayrapid_savedcard/delete', array('customer_id' => $this->getCustomer()->getId())); ?>", {
|
27 |
+
method: 'post',
|
28 |
+
parameters: "token_id="+id,
|
29 |
+
evalScripts: true,
|
30 |
+
onComplete: function(data) {
|
31 |
+
Element.hide('loading-mask');
|
32 |
+
|
33 |
+
try {
|
34 |
+
var json = data.responseText.evalJSON();
|
35 |
+
} catch(e) {}
|
36 |
+
|
37 |
+
if( typeof json != 'undefined' && json.success == false ) {
|
38 |
+
alert( json.message );
|
39 |
+
}
|
40 |
+
else {
|
41 |
+
$('token-'+id).hide();
|
42 |
+
<?php echo $this->getCode(); ?>.editCard(0);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
});
|
46 |
+
}
|
47 |
+
},
|
48 |
+
|
49 |
+
editCard: function( id ) {
|
50 |
+
Element.show('loading-mask');
|
51 |
+
new Ajax.Request("<?php echo $this->getUrl('*/ewayrapid_savedcard/load', array('customer_id' => $this->getCustomer()->getId())); ?>", {
|
52 |
+
method: 'post',
|
53 |
+
parameters: "token_id="+id,
|
54 |
+
evalScripts: true,
|
55 |
+
onComplete: function(data) {
|
56 |
+
Element.hide('loading-mask');
|
57 |
+
|
58 |
+
try {
|
59 |
+
var json = data.responseText.evalJSON();
|
60 |
+
} catch(e) {}
|
61 |
+
|
62 |
+
if( typeof json != 'undefined' && json.success == false ) {
|
63 |
+
alert( json.message );
|
64 |
+
}
|
65 |
+
else {
|
66 |
+
$('<?php echo $this->getCode(); ?>-form').update( data.responseText );
|
67 |
+
}
|
68 |
+
}
|
69 |
+
});
|
70 |
+
},
|
71 |
+
|
72 |
+
saveCard: function(customertokenid) {
|
73 |
+
var form = $('edit_form');
|
74 |
+
form.writeAttribute('data-eway-encrypt-key', encryptKey);
|
75 |
+
if(!validateForm()){
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
var ewayForm = new EwayForm();
|
79 |
+
var submitForm = ewayForm.encryptForm(form, true);
|
80 |
+
|
81 |
+
Element.show('loading-mask');
|
82 |
+
var url = '';
|
83 |
+
<?php if(Mage::helper('ewayrapid')->useIframeInBackend()): ?>
|
84 |
+
url = '<?php echo $this->getUrl('*/ewayrapid_savedcard/getAccessCode', array('customer_id' => $this->getCustomer()->getId())); ?>';
|
85 |
+
<?php else: ?>
|
86 |
+
url = '<?php echo $this->getUrl('*/ewayrapid_savedcard/save', array('customer_id' => $this->getCustomer()->getId())); ?>'
|
87 |
+
<?php endif; ?>
|
88 |
+
|
89 |
+
if(customertokenid){
|
90 |
+
url += 'TokenCustomerID/' + customertokenid;
|
91 |
+
}
|
92 |
+
new Ajax.Request(url, {
|
93 |
+
method: 'post',
|
94 |
+
parameters: Form.serialize(submitForm, true),
|
95 |
+
evalScripts: true,
|
96 |
+
onComplete: function(data) {
|
97 |
+
Element.hide('loading-mask');
|
98 |
+
try {
|
99 |
+
var json = data.responseText.evalJSON();
|
100 |
+
} catch(e) {}
|
101 |
+
|
102 |
+
if( typeof json != 'undefined' && json.success == false ) {
|
103 |
+
alert( json.message );
|
104 |
+
}
|
105 |
+
else {
|
106 |
+
<?php if(Mage::helper('ewayrapid')->useIframeInBackend()): ?>
|
107 |
+
var eWAYConfig = {
|
108 |
+
sharedPaymentUrl: json.SharedPaymentUrl
|
109 |
+
};
|
110 |
+
ewayReturnUrl = '<?php echo $this->getUrl('*/ewayrapid_savedcard/savetoken', array('customer_id' => $this->getCustomer()->getId())); ?>';
|
111 |
+
saveTokenResult = json;
|
112 |
+
Element.show('loading-mask');
|
113 |
+
eCrypt.showModalPayment(eWAYConfig, saveTokenCallBack);
|
114 |
+
<?php else: ?>
|
115 |
+
$('<?php echo $this->getCode(); ?>-cards').update(data.responseText);
|
116 |
+
<?php echo $this->getCode(); ?>.editCard(0);
|
117 |
+
<?php endif; ?>
|
118 |
+
}
|
119 |
+
}
|
120 |
+
});
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
function saveTokenCallBack (result, transactionID, errors) {
|
125 |
+
if (result == "Complete") {
|
126 |
+
var reqParams = {
|
127 |
+
// 'ccType': '',
|
128 |
+
// 'expYear': saveTokenResult.Customer.CardExpiryYear,
|
129 |
+
'token_id': $('token_id').value,
|
130 |
+
// 'startMonth': saveTokenResult.Customer.CardStartMonth,
|
131 |
+
// 'startYear': saveTokenResult.Customer.CardStartYear,
|
132 |
+
// 'issueNumber': saveTokenResult.Customer.CardIssueNumber,
|
133 |
+
'AccessCode': saveTokenResult.AccessCode,
|
134 |
+
'street1': saveTokenResult.street1,
|
135 |
+
'street2': saveTokenResult.street2
|
136 |
+
};
|
137 |
+
new Ajax.Request(ewayReturnUrl, {
|
138 |
+
method: 'post',
|
139 |
+
parameters: reqParams,
|
140 |
+
evalScripts: true,
|
141 |
+
onComplete: function(data) {
|
142 |
+
Element.hide('loading-mask');
|
143 |
+
try {
|
144 |
+
var json = data.responseText.evalJSON();
|
145 |
+
} catch(e) {}
|
146 |
+
|
147 |
+
if( typeof json != 'undefined' && json.success == false ) {
|
148 |
+
alert( json.message );
|
149 |
+
}
|
150 |
+
else {
|
151 |
+
$('<?php echo $this->getCode(); ?>-cards').update( data.responseText );
|
152 |
+
<?php echo $this->getCode(); ?>.editCard(0);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
});
|
156 |
+
} else if (result == "Error") {
|
157 |
+
alert("There was a problem completing the payment: " + errors);
|
158 |
+
Element.hide('loading-mask');
|
159 |
+
} else{
|
160 |
+
Element.hide('loading-mask');
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
function validateForm(){
|
165 |
+
$$('.save-card-validate').each(function(ele){
|
166 |
+
var eleValidate = ele.getAttribute('data-validate');
|
167 |
+
ele.addClassName(eleValidate);
|
168 |
+
});
|
169 |
+
$('ewayrapid_region_id') && $('ewayrapid_region_id').addClassName('required-entry').addClassName('validate-select');
|
170 |
+
var validator = new Validation('edit_form');
|
171 |
+
return validator.validate();
|
172 |
+
}
|
173 |
+
//]]!>
|
174 |
+
</script>
|
175 |
+
<?php endif; ?>
|
app/design/adminhtml/default/default/template/ewayrapid/form/direct_ewayone.phtml
CHANGED
@@ -1,181 +1,182 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
$
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
<
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
<
|
67 |
-
|
68 |
-
<input type="
|
69 |
-
<
|
70 |
-
<
|
71 |
-
|
72 |
-
<div class="tool-tip-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
<
|
79 |
-
|
80 |
-
|
81 |
-
<?php $
|
82 |
-
<?php
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
<?php
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
<?php
|
99 |
-
|
100 |
-
|
101 |
-
<
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
<?php
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
<?php echo
|
133 |
-
|
134 |
-
|
135 |
-
'<?php echo $this->__('
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
AdminOrder.prototype.
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
$('
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
181 |
</script>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
$_code = $this->getMethodCode();
|
29 |
+
?>
|
30 |
+
|
31 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display: none">
|
32 |
+
<?php if($this->checkSaveCardAvailable()): ?>
|
33 |
+
<?php
|
34 |
+
$_tokens = $this->getTokenList();
|
35 |
+
$_defaultToken = isset($_tokens['default_token']) ? $_tokens['default_token'] : false;
|
36 |
+
?>
|
37 |
+
<li <?php echo count($_tokens['tokens']) <= 1 ? 'style="display:none;"' : '' ?>>
|
38 |
+
<div class="input-box">
|
39 |
+
<div class="v-fix">
|
40 |
+
<select id="ewayrapid_ewayone_token" name="payment[saved_token]" class="ewayrapid_ewayone_token">
|
41 |
+
<?php foreach($_tokens['tokens'] as $_key => $_token):
|
42 |
+
if ($_key == Eway_Rapid31_Model_Config::TOKEN_NEW || $this->checkCardName($_token) == Eway_Rapid31_Model_Config::CREDITCARD_METHOD): ?>
|
43 |
+
<?php /* @var Eway_Rapid31_Model_Customer_Token $_token */ ?>
|
44 |
+
<option value="<?php echo $_key ?>" <?php if($_key == $_defaultToken): ?>selected="selected"<?php endif; ?>>
|
45 |
+
<?php echo $_token->getCard() ?>
|
46 |
+
</option>
|
47 |
+
<?php endif; ?>
|
48 |
+
<?php endforeach; ?>
|
49 |
+
</select>
|
50 |
+
</div>
|
51 |
+
<?php if(Mage::getSingleton('ewayrapid/config')->canEditToken() && count($_tokens['tokens']) > 1): ?>
|
52 |
+
<div class="v-fix">
|
53 |
+
<a id="ewayrapid_ewayone_edit" class="ewayrapid_ewayone_edit" href="javascript:void(0);"><?php echo $this->__('Edit') ?></a>
|
54 |
+
</div>
|
55 |
+
<?php endif; ?>
|
56 |
+
</div>
|
57 |
+
</li>
|
58 |
+
<?php endif; ?>
|
59 |
+
<li class="saved_token_fields">
|
60 |
+
<label for="<?php echo $_code ?>_cc_owner"><em>*</em><?php echo $this->__('Name on Card') ?></label>
|
61 |
+
<div class="input-box">
|
62 |
+
<input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>" />
|
63 |
+
</div>
|
64 |
+
</li>
|
65 |
+
<li class="saved_token_fields">
|
66 |
+
<label for="<?php echo $_code ?>_cc_number"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
67 |
+
<div class="input-box help-disabled-cc">
|
68 |
+
<input type="text" id="<?php echo $_code ?>_cc_number" data-eway-encrypt-name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type-auto" value="" pattern="\d*"/>
|
69 |
+
<input type="hidden" id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" />
|
70 |
+
<a class="card-number-help" href="#"><?php echo $this->__('Help') ?></a>
|
71 |
+
<div class="tool-tip" id="cc-help-tool-tip" style="display:none;">
|
72 |
+
<div class="btn-close"><a href="#" id="cc-help-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
|
73 |
+
<div class="tool-tip-content">To use a new credit card number, please add another card</div>
|
74 |
+
</div>
|
75 |
+
</div>
|
76 |
+
</li>
|
77 |
+
<li class="saved_token_fields">
|
78 |
+
<label for="<?php echo $_code ?>_expiration"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
79 |
+
<div class="input-box">
|
80 |
+
<div class="v-fix">
|
81 |
+
<select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
|
82 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
83 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
84 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
85 |
+
<?php endforeach ?>
|
86 |
+
</select>
|
87 |
+
</div>
|
88 |
+
<div class="v-fix">
|
89 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
90 |
+
<select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
|
91 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
92 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
93 |
+
<?php endforeach ?>
|
94 |
+
</select>
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
</li>
|
98 |
+
<?php echo $this->getChildHtml() ?>
|
99 |
+
<?php if($this->hasVerification()): ?>
|
100 |
+
<li id="<?php echo $_code ?>_cc_type_cvv_div">
|
101 |
+
<label for="<?php echo $_code ?>_cc_cid"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
102 |
+
<div class="input-box">
|
103 |
+
<div class="v-fix">
|
104 |
+
<input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" data-eway-encrypt-name="payment[cc_cid]" value="" pattern="\d*"/>
|
105 |
+
</div>
|
106 |
+
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
107 |
+
</div>
|
108 |
+
</li>
|
109 |
+
<?php if ($this->getIsRecurring()) { ?>
|
110 |
+
<li>
|
111 |
+
<p>I authorize <?php echo Mage::app()->getStore()->getName(); ?> to charge the available balance
|
112 |
+
in my credit card for the future payments of this order. To make a change, I can go to
|
113 |
+
<a href="<?php echo Mage::getUrl('checkout/cart'); ?>">Cart</a>
|
114 |
+
</p>
|
115 |
+
<input type="checkbox" name="recurring-agree" class="recurring-agree required-entry"/><label class="lable-for-recurring" for="">Agree</label>
|
116 |
+
</li>
|
117 |
+
<?php } ?>
|
118 |
+
<?php endif; ?>
|
119 |
+
<?php if($this->checkSaveCardAvailable() && $this->getSaveCard()): ?>
|
120 |
+
<li id="eway_save_card" class="saved_token_fields">
|
121 |
+
<div class="v-fix">
|
122 |
+
<input type="checkbox" title="<?php echo $this->getSaveText() ?>" id="<?php echo $_code ?>_cc_save_card"
|
123 |
+
<?php echo $this->getSaveDefaultCheck() ? 'checked' : '' ?> name="payment[save_card]" value="1" pattern="\d*"/>
|
124 |
+
<label for="<?php echo $_code ?>_cc_save_card" ><?php echo $this->getSaveText() ?></label>
|
125 |
+
</div>
|
126 |
+
</li>
|
127 |
+
<?php endif; ?>
|
128 |
+
</ul>
|
129 |
+
<?php if(count($_tokens['tokens']) > 1): ?>
|
130 |
+
<script type="text/javascript">
|
131 |
+
var ewayPaymentToken = new EwayPaymentToken(
|
132 |
+
<?php echo $_tokens['tokens_json'] ?>,
|
133 |
+
<?php echo count($_tokens['tokens']) ?>,
|
134 |
+
false,
|
135 |
+
'<?php echo $this->__('Edit') ?>',
|
136 |
+
'<?php echo $this->__('Cancel edit') ?>'
|
137 |
+
);
|
138 |
+
|
139 |
+
$$('.help-disabled-cc a').each(function(element){
|
140 |
+
Event.observe(element, 'click', toggleToolTipCc);
|
141 |
+
});
|
142 |
+
|
143 |
+
function toggleToolTipCc(event){
|
144 |
+
if($('cc-help-tool-tip')){
|
145 |
+
$('cc-help-tool-tip').toggle();
|
146 |
+
}
|
147 |
+
Event.stop(event);
|
148 |
+
}
|
149 |
+
if($('cc-help-tool-tip-close')){
|
150 |
+
Event.observe($('cc-help-tool-tip-close'), 'click', toggleToolTipCc);
|
151 |
+
}
|
152 |
+
|
153 |
+
if(typeof AdminOrder.prototype.setPaymentMethodBackup == "undefined") {
|
154 |
+
AdminOrder.prototype.setPaymentMethodBackup = AdminOrder.prototype.setPaymentMethod;
|
155 |
+
AdminOrder.prototype.setPaymentMethod = function(method) {
|
156 |
+
AdminOrder.prototype.setPaymentMethodBackup(method);
|
157 |
+
if(EwayPayment.isEwayRapidMethod(method)) {
|
158 |
+
ewayPaymentToken.onSavedTokenChanged();
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
</script>
|
164 |
+
<?php endif; ?>
|
165 |
+
<script type="text/javascript">
|
166 |
+
$('p_method_ewayrapid_ewayone').observe('click', function () {
|
167 |
+
$('p_method_ewayrapid_ewayone').setAttribute('checked', 'true');
|
168 |
+
$('p_method_ewayrapid_notsaved') && $('p_method_ewayrapid_notsaved').removeAttribute('checked');
|
169 |
+
|
170 |
+
$$('#payment_form_ewayrapid_ewayone input[name*=payment]').each(function(inp) {
|
171 |
+
inp.removeAttribute('disabled');
|
172 |
+
});
|
173 |
+
|
174 |
+
$$('#payment_form_ewayrapid_ewayone select[name*=payment]').each(function(inp) {
|
175 |
+
inp.removeAttribute('disabled');
|
176 |
+
});
|
177 |
+
|
178 |
+
$$('#payment_form_ewayrapid_ewayone input[data-eway-encrypt-name*=payment]').each(function(inp) {
|
179 |
+
inp.removeAttribute('disabled');
|
180 |
+
});
|
181 |
+
});
|
182 |
</script>
|
app/design/adminhtml/default/default/template/ewayrapid/form/direct_notsaved.phtml
CHANGED
@@ -1,73 +1,74 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
<
|
32 |
-
<
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
<
|
38 |
-
<
|
39 |
-
|
40 |
-
<input type="
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
<
|
47 |
-
<
|
48 |
-
<?php $
|
49 |
-
<?php
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
<?php
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
<?php
|
63 |
-
|
64 |
-
|
65 |
-
<
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
73 |
</ul>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php $_code=$this->getMethodCode() ?>
|
28 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
29 |
+
<li>
|
30 |
+
<div class="input-box">
|
31 |
+
<label for="<?php echo $_code ?>_cc_owner"><?php echo $this->__('Name on Card') ?> <span class="required">*</span></label>
|
32 |
+
<br/>
|
33 |
+
<input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>" />
|
34 |
+
</div>
|
35 |
+
</li>
|
36 |
+
<li>
|
37 |
+
<label for="<?php echo $_code ?>_cc_number"><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label>
|
38 |
+
<br/>
|
39 |
+
<div class="input-box">
|
40 |
+
<input type="text" id="<?php echo $_code ?>_cc_number" data-eway-encrypt-name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type-auto" value="" />
|
41 |
+
<input type="hidden" id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" />
|
42 |
+
</div>
|
43 |
+
</li>
|
44 |
+
<li id="<?php echo $_code ?>_cc_type_exp_div">
|
45 |
+
<div class="input-box">
|
46 |
+
<label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label>
|
47 |
+
<br/>
|
48 |
+
<select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
|
49 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
50 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
51 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
52 |
+
<?php endforeach ?>
|
53 |
+
</select>
|
54 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
55 |
+
<select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
|
56 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
57 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
58 |
+
<?php endforeach ?>
|
59 |
+
</select>
|
60 |
+
</div>
|
61 |
+
</li>
|
62 |
+
<?php echo $this->getChildHtml() ?>
|
63 |
+
<?php if($this->hasVerification()): ?>
|
64 |
+
<li id="<?php echo $_code ?>_cc_type_cvv_div">
|
65 |
+
<label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
66 |
+
<div class="input-box">
|
67 |
+
<div class="v-fix">
|
68 |
+
<input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" data-eway-encrypt-name="payment[cc_cid]" value="" pattern="\d*"/>
|
69 |
+
</div>
|
70 |
+
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
71 |
+
</div>
|
72 |
+
</li>
|
73 |
+
<?php endif; ?>
|
74 |
</ul>
|
app/design/adminhtml/default/default/template/ewayrapid/form/direct_saved.phtml
CHANGED
@@ -1,109 +1,110 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
$
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
<
|
59 |
-
<
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
<
|
65 |
-
<
|
66 |
-
|
67 |
-
<input type="
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
<
|
74 |
-
<
|
75 |
-
<?php $
|
76 |
-
<?php
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
<?php
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
<?php echo
|
93 |
-
|
94 |
-
|
95 |
-
'<?php echo $this->__('
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
AdminOrder.prototype.
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
</
|
109 |
-
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php $_code=$this->getMethodCode() ?>
|
28 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display: none">
|
29 |
+
<li>
|
30 |
+
<div class="input-box">
|
31 |
+
<div class="v-fix" style="float: left; padding-right: 10px;">
|
32 |
+
<select id="ewayrapid_saved_token" name="payment[saved_token]" class="ewayrapid_saved_token">
|
33 |
+
<?php
|
34 |
+
$_tokens = $this->getTokenList();
|
35 |
+
$_defaultToken = isset($_tokens['default_token']) ? $_tokens['default_token'] : false;
|
36 |
+
?>
|
37 |
+
<?php foreach($_tokens['tokens'] as $_key => $_token):
|
38 |
+
if ($_key == Eway_Rapid31_Model_Config::TOKEN_NEW || $this->checkCardName($_token) == Eway_Rapid31_Model_Config::CREDITCARD_METHOD): ?>
|
39 |
+
<?php /* @var Eway_Rapid31_Model_Customer_Token $_token */ ?>
|
40 |
+
<option value="<?php echo $_key ?>" <?php if($_key == $_defaultToken): ?>selected="selected"<?php endif; ?>>
|
41 |
+
<?php echo $_token->getCard() ?>
|
42 |
+
</option>
|
43 |
+
<?php endif; ?>
|
44 |
+
<?php endforeach; ?>
|
45 |
+
</select>
|
46 |
+
</div>
|
47 |
+
<?php if(count($_tokens['tokens']) > 1): ?>
|
48 |
+
<div class="v-fix">
|
49 |
+
<a id="ewayrapid_saved_edit" class="ewayrapid_saved_edit" href="javascript:void(0);"><?php echo $this->__('Edit') ?></a>
|
50 |
+
</div>
|
51 |
+
<?php endif; ?>
|
52 |
+
</div>
|
53 |
+
<div style="clear: both;"></div>
|
54 |
+
</li>
|
55 |
+
|
56 |
+
<li class="saved_token_fields" style="display: none">
|
57 |
+
<div class="input-box">
|
58 |
+
<label for="<?php echo $_code ?>_cc_owner"><?php echo $this->__('Name on Card') ?> <span class="required">*</span></label>
|
59 |
+
<br/>
|
60 |
+
<input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>" />
|
61 |
+
</div>
|
62 |
+
</li>
|
63 |
+
<li class="saved_token_fields" style="display: none">
|
64 |
+
<label for="<?php echo $_code ?>_cc_number"><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label>
|
65 |
+
<br/>
|
66 |
+
<div class="input-box">
|
67 |
+
<input type="text" id="<?php echo $_code ?>_cc_number" data-eway-encrypt-name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type-auto" value="" />
|
68 |
+
<input type="hidden" id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" />
|
69 |
+
</div>
|
70 |
+
</li>
|
71 |
+
<li id="<?php echo $_code ?>_cc_type_exp_div" class="saved_token_fields" style="display: none">
|
72 |
+
<div class="input-box">
|
73 |
+
<label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label>
|
74 |
+
<br/>
|
75 |
+
<select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
|
76 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
77 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
78 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
79 |
+
<?php endforeach ?>
|
80 |
+
</select>
|
81 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
82 |
+
<select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
|
83 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
84 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
85 |
+
<?php endforeach ?>
|
86 |
+
</select>
|
87 |
+
</div>
|
88 |
+
</li>
|
89 |
+
<?php echo $this->getChildHtml() ?>
|
90 |
+
<script type="text/javascript">
|
91 |
+
var ewayPaymentToken = new EwayPaymentToken(
|
92 |
+
<?php echo $_tokens['tokens_json'] ?>,
|
93 |
+
<?php echo count($_tokens['tokens']) ?>,
|
94 |
+
true,
|
95 |
+
'<?php echo $this->__('Edit') ?>',
|
96 |
+
'<?php echo $this->__('Cancel edit') ?>'
|
97 |
+
)
|
98 |
+
|
99 |
+
if(typeof AdminOrder.prototype.setPaymentMethodBackup == "undefined") {
|
100 |
+
AdminOrder.prototype.setPaymentMethodBackup = AdminOrder.prototype.setPaymentMethod;
|
101 |
+
AdminOrder.prototype.setPaymentMethod = function(method) {
|
102 |
+
AdminOrder.prototype.setPaymentMethodBackup(method);
|
103 |
+
if(EwayPayment.isEwayRapidMethod(method)) {
|
104 |
+
ewayPaymentToken.onSavedTokenChanged();
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
</script>
|
109 |
+
</ul>
|
110 |
+
|
app/design/adminhtml/default/default/template/ewayrapid/form/sharedpage_ewayone.phtml
CHANGED
@@ -19,7 +19,8 @@
|
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category design
|
22 |
-
* @package base_default
|
|
|
23 |
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
*/
|
25 |
?>
|
@@ -28,14 +29,14 @@ $_code = $this->getMethodCode()
|
|
28 |
?>
|
29 |
<?php if($this->checkSaveCardAvailable()): ?>
|
30 |
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display: none;width: 80%;padding-top: 8px;">
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
<div class="input-box">
|
33 |
<div class="v-fix">
|
34 |
<select id="ewayrapid_ewayone_token" name="payment[saved_token]" class="ewayrapid_ewayone_token">
|
35 |
-
<?php
|
36 |
-
$_tokens = $this->getTokenList();
|
37 |
-
$_defaultToken = isset($_tokens['default_token']) ? $_tokens['default_token'] : false;
|
38 |
-
?>
|
39 |
<?php foreach($_tokens['tokens'] as $_key => $_token): ?>
|
40 |
<?php /* @var Eway_Rapid31_Model_Customer_Token $_token */ ?>
|
41 |
<option value="<?php echo $_key ?>" <?php if($_key == $_defaultToken): ?>selected="selected"<?php endif; ?>>
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category design
|
22 |
+
* @package base_default
|
23 |
+
|
24 |
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
*/
|
26 |
?>
|
29 |
?>
|
30 |
<?php if($this->checkSaveCardAvailable()): ?>
|
31 |
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display: none;width: 80%;padding-top: 8px;">
|
32 |
+
<?php
|
33 |
+
$_tokens = $this->getTokenList();
|
34 |
+
$_defaultToken = isset($_tokens['default_token']) ? $_tokens['default_token'] : false;
|
35 |
+
?>
|
36 |
+
<li <?php echo count($_tokens['tokens']) <= 1 ? 'style="display:none;"' : '' ?>>
|
37 |
<div class="input-box">
|
38 |
<div class="v-fix">
|
39 |
<select id="ewayrapid_ewayone_token" name="payment[saved_token]" class="ewayrapid_ewayone_token">
|
|
|
|
|
|
|
|
|
40 |
<?php foreach($_tokens['tokens'] as $_key => $_token): ?>
|
41 |
<?php /* @var Eway_Rapid31_Model_Customer_Token $_token */ ?>
|
42 |
<option value="<?php echo $_key ?>" <?php if($_key == $_defaultToken): ?>selected="selected"<?php endif; ?>>
|
app/design/adminhtml/default/default/template/ewayrapid/form/sharedpage_notsaved.phtml
CHANGED
@@ -1,28 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
$_code = $this->getMethodCode();
|
29 |
?>
|
app/design/adminhtml/default/default/template/ewayrapid/info/direct_ewayone.phtml
CHANGED
@@ -1,90 +1,90 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package default_default
|
23 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
-
*/
|
25 |
-
?>
|
26 |
-
<?php
|
27 |
-
$_helper = Mage::helper('ewayrapid');
|
28 |
-
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
29 |
-
$_info = $this->getInfo();
|
30 |
-
/* @var Mage_Sales_Model_Order_Payment $_info */
|
31 |
-
?>
|
32 |
-
<div class="cards-list">
|
33 |
-
|
34 |
-
<?php if (!$this->getHideTitle()): ?>
|
35 |
-
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
36 |
-
<?php endif;?>
|
37 |
-
|
38 |
-
<table class="info-table">
|
39 |
-
<tbody>
|
40 |
-
<?php if($_info->getTokenId()): ?>
|
41 |
-
<tr>
|
42 |
-
<td><?php echo $_helper->__('Payer ID') ?>:</td>
|
43 |
-
<td><?php echo $this->getTokenId() ?></td>
|
44 |
-
</tr>
|
45 |
-
<?php endif; ?>
|
46 |
-
|
47 |
-
<?php if($_info->getCcLast4()): ?>
|
48 |
-
<tr>
|
49 |
-
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
50 |
-
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
51 |
-
</tr>
|
52 |
-
<?php endif; ?>
|
53 |
-
|
54 |
-
<?php if($_info->getLastTransId()): ?>
|
55 |
-
<tr>
|
56 |
-
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
57 |
-
<td><?php echo $_info->getLastTransId(); ?></td>
|
58 |
-
</tr>
|
59 |
-
<?php endif; ?>
|
60 |
-
|
61 |
-
<?php if($_info['beagle_score'] > 0): ?>
|
62 |
-
<tr>
|
63 |
-
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
64 |
-
<td><?php echo $_info['beagle_score']; ?></td>
|
65 |
-
</tr>
|
66 |
-
<?php endif; ?>
|
67 |
-
|
68 |
-
<?php if(is_array($_info['beagle_verification'])): ?>
|
69 |
-
<?php $_verifications = array_filter(unserialize($_info['beagle_verification']) ) ?>
|
70 |
-
<?php endif; ?>
|
71 |
-
|
72 |
-
<?php if(!empty($_verifications)): ?>
|
73 |
-
<tr>
|
74 |
-
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
75 |
-
<td>
|
76 |
-
<?php $count = 0; ?>
|
77 |
-
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
78 |
-
<?php
|
79 |
-
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
80 |
-
?>
|
81 |
-
<span><?php echo $count ? ', ' : '' ?><?php echo $key . ': ' . $_verificationTitle ?></span>
|
82 |
-
<?php $count++ ?>
|
83 |
-
<?php endforeach; ?>
|
84 |
-
</td>
|
85 |
-
</tr>
|
86 |
-
<?php endif; ?>
|
87 |
-
|
88 |
-
</tbody>
|
89 |
-
</table>
|
90 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
+
*/
|
25 |
+
?>
|
26 |
+
<?php
|
27 |
+
$_helper = Mage::helper('ewayrapid');
|
28 |
+
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
29 |
+
$_info = $this->getInfo();
|
30 |
+
/* @var Mage_Sales_Model_Order_Payment $_info */
|
31 |
+
?>
|
32 |
+
<div class="cards-list">
|
33 |
+
|
34 |
+
<?php if (!$this->getHideTitle()): ?>
|
35 |
+
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
36 |
+
<?php endif;?>
|
37 |
+
|
38 |
+
<table class="info-table">
|
39 |
+
<tbody>
|
40 |
+
<?php if($_info->getTokenId()): ?>
|
41 |
+
<tr>
|
42 |
+
<td><?php echo $_helper->__('Payer ID') ?>:</td>
|
43 |
+
<td><?php echo $this->getTokenId() ?></td>
|
44 |
+
</tr>
|
45 |
+
<?php endif; ?>
|
46 |
+
|
47 |
+
<?php if($_info->getCcLast4()): ?>
|
48 |
+
<tr>
|
49 |
+
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
50 |
+
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
51 |
+
</tr>
|
52 |
+
<?php endif; ?>
|
53 |
+
|
54 |
+
<?php if($_info->getLastTransId()): ?>
|
55 |
+
<tr>
|
56 |
+
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
57 |
+
<td><?php echo $_info->getLastTransId(); ?></td>
|
58 |
+
</tr>
|
59 |
+
<?php endif; ?>
|
60 |
+
|
61 |
+
<?php if($_info['beagle_score'] > 0): ?>
|
62 |
+
<tr>
|
63 |
+
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
64 |
+
<td><?php echo $_info['beagle_score']; ?></td>
|
65 |
+
</tr>
|
66 |
+
<?php endif; ?>
|
67 |
+
|
68 |
+
<?php if(is_array($_info['beagle_verification'])): ?>
|
69 |
+
<?php $_verifications = array_filter(unserialize($_info['beagle_verification']) ) ?>
|
70 |
+
<?php endif; ?>
|
71 |
+
|
72 |
+
<?php if(!empty($_verifications)): ?>
|
73 |
+
<tr>
|
74 |
+
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
75 |
+
<td>
|
76 |
+
<?php $count = 0; ?>
|
77 |
+
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
78 |
+
<?php
|
79 |
+
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
80 |
+
?>
|
81 |
+
<span><?php echo $count ? ', ' : '' ?><?php echo $key . ': ' . $_verificationTitle ?></span>
|
82 |
+
<?php $count++ ?>
|
83 |
+
<?php endforeach; ?>
|
84 |
+
</td>
|
85 |
+
</tr>
|
86 |
+
<?php endif; ?>
|
87 |
+
|
88 |
+
</tbody>
|
89 |
+
</table>
|
90 |
+
</div>
|
app/design/adminhtml/default/default/template/ewayrapid/info/direct_notsaved.phtml
CHANGED
@@ -1,104 +1,104 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package default_default
|
23 |
-
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
?>
|
27 |
-
<?php
|
28 |
-
$_helper = Mage::helper('ewayrapid');
|
29 |
-
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
30 |
-
$_info = $this->getInfo();
|
31 |
-
/* @var Mage_Sales_Model_Order_Payment $_info */
|
32 |
-
$_additionalInfo = $_info->getAdditionalInformation();
|
33 |
-
?>
|
34 |
-
<div class="cards-list">
|
35 |
-
|
36 |
-
<?php if (!$this->getHideTitle()): ?>
|
37 |
-
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
38 |
-
<?php endif;?>
|
39 |
-
|
40 |
-
<table class="info-table">
|
41 |
-
<tbody>
|
42 |
-
<?php if($_info->getCcOwner()) : ?>
|
43 |
-
<tr>
|
44 |
-
<td><?php echo $_helper->__('Card Holder\'s Name') ?>:</td>
|
45 |
-
<td><?php echo $_info->getCcOwner(); ?></td>
|
46 |
-
</tr>
|
47 |
-
<?php endif;?>
|
48 |
-
|
49 |
-
<?php if($_info->getCcLast4()) : ?>
|
50 |
-
<tr>
|
51 |
-
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
52 |
-
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
53 |
-
</tr>
|
54 |
-
<?php endif;?>
|
55 |
-
|
56 |
-
<?php if($_info->getCcExpMonth()) : ?>
|
57 |
-
<tr>
|
58 |
-
<td><?php echo $_helper->__('Credit Card Expiry') ?>:</td>
|
59 |
-
<td><?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?></td>
|
60 |
-
</tr>
|
61 |
-
<?php endif;?>
|
62 |
-
|
63 |
-
<?php if($_info->getCcType()) : ?>
|
64 |
-
<tr>
|
65 |
-
<td><?php echo $_helper->__('Credit Card Type') ?>:</td>
|
66 |
-
<td><?php echo $this->getCcTypeName($_info->getCcType()); ?></td>
|
67 |
-
</tr>
|
68 |
-
<?php endif;?>
|
69 |
-
|
70 |
-
<?php if($_info->getLastTransId()) : ?>
|
71 |
-
<tr>
|
72 |
-
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
73 |
-
<td><?php echo $_info->getLastTransId(); ?></td>
|
74 |
-
</tr>
|
75 |
-
<?php endif;?>
|
76 |
-
|
77 |
-
<?php if($_info['beagle_score'] > 0): ?>
|
78 |
-
<tr>
|
79 |
-
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
80 |
-
<td><?php echo $_info['beagle_score']; ?></td>
|
81 |
-
</tr>
|
82 |
-
<?php endif; ?>
|
83 |
-
|
84 |
-
<?php if (isset($_info['beagle_verification'])):
|
85 |
-
$_verifications = array_filter(unserialize($_info['beagle_verification']) );
|
86 |
-
endif; ?>
|
87 |
-
<?php if(isset($_verifications) && !empty($_verifications)): ?>
|
88 |
-
<tr>
|
89 |
-
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
90 |
-
<td>
|
91 |
-
<?php $count = 0; ?>
|
92 |
-
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
93 |
-
<?php
|
94 |
-
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
95 |
-
?>
|
96 |
-
<span><?php echo $count ? ',' : '' ?><?php echo $key . ' : ' . $_verificationTitle ?></span>
|
97 |
-
<?php $count++ ?>
|
98 |
-
<?php endforeach; ?>
|
99 |
-
</td>
|
100 |
-
</tr>
|
101 |
-
<?php endif; ?>
|
102 |
-
</tbody>
|
103 |
-
</table>
|
104 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
$_helper = Mage::helper('ewayrapid');
|
29 |
+
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
30 |
+
$_info = $this->getInfo();
|
31 |
+
/* @var Mage_Sales_Model_Order_Payment $_info */
|
32 |
+
$_additionalInfo = $_info->getAdditionalInformation();
|
33 |
+
?>
|
34 |
+
<div class="cards-list">
|
35 |
+
|
36 |
+
<?php if (!$this->getHideTitle()): ?>
|
37 |
+
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
38 |
+
<?php endif;?>
|
39 |
+
|
40 |
+
<table class="info-table">
|
41 |
+
<tbody>
|
42 |
+
<?php if($_info->getCcOwner()) : ?>
|
43 |
+
<tr>
|
44 |
+
<td><?php echo $_helper->__('Card Holder\'s Name') ?>:</td>
|
45 |
+
<td><?php echo $_info->getCcOwner(); ?></td>
|
46 |
+
</tr>
|
47 |
+
<?php endif;?>
|
48 |
+
|
49 |
+
<?php if($_info->getCcLast4()) : ?>
|
50 |
+
<tr>
|
51 |
+
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
52 |
+
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
53 |
+
</tr>
|
54 |
+
<?php endif;?>
|
55 |
+
|
56 |
+
<?php if($_info->getCcExpMonth()) : ?>
|
57 |
+
<tr>
|
58 |
+
<td><?php echo $_helper->__('Credit Card Expiry') ?>:</td>
|
59 |
+
<td><?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?></td>
|
60 |
+
</tr>
|
61 |
+
<?php endif;?>
|
62 |
+
|
63 |
+
<?php if($_info->getCcType()) : ?>
|
64 |
+
<tr>
|
65 |
+
<td><?php echo $_helper->__('Credit Card Type') ?>:</td>
|
66 |
+
<td><?php echo $this->getCcTypeName($_info->getCcType()); ?></td>
|
67 |
+
</tr>
|
68 |
+
<?php endif;?>
|
69 |
+
|
70 |
+
<?php if($_info->getLastTransId()) : ?>
|
71 |
+
<tr>
|
72 |
+
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
73 |
+
<td><?php echo $_info->getLastTransId(); ?></td>
|
74 |
+
</tr>
|
75 |
+
<?php endif;?>
|
76 |
+
|
77 |
+
<?php if($_info['beagle_score'] > 0): ?>
|
78 |
+
<tr>
|
79 |
+
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
80 |
+
<td><?php echo $_info['beagle_score']; ?></td>
|
81 |
+
</tr>
|
82 |
+
<?php endif; ?>
|
83 |
+
|
84 |
+
<?php if (isset($_info['beagle_verification'])):
|
85 |
+
$_verifications = array_filter(unserialize($_info['beagle_verification']) );
|
86 |
+
endif; ?>
|
87 |
+
<?php if(isset($_verifications) && !empty($_verifications)): ?>
|
88 |
+
<tr>
|
89 |
+
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
90 |
+
<td>
|
91 |
+
<?php $count = 0; ?>
|
92 |
+
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
93 |
+
<?php
|
94 |
+
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
95 |
+
?>
|
96 |
+
<span><?php echo $count ? ',' : '' ?><?php echo $key . ' : ' . $_verificationTitle ?></span>
|
97 |
+
<?php $count++ ?>
|
98 |
+
<?php endforeach; ?>
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
+
<?php endif; ?>
|
102 |
+
</tbody>
|
103 |
+
</table>
|
104 |
+
</div>
|
app/design/adminhtml/default/default/template/ewayrapid/info/direct_saved.phtml
CHANGED
@@ -1,89 +1,89 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package default_default
|
23 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
-
*/
|
25 |
-
?>
|
26 |
-
<?php
|
27 |
-
$_helper = Mage::helper('ewayrapid');
|
28 |
-
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
29 |
-
$_info = $this->getInfo();
|
30 |
-
/* @var Mage_Sales_Model_Order_Payment $_info */
|
31 |
-
?>
|
32 |
-
<div class="cards-list">
|
33 |
-
|
34 |
-
<?php if (!$this->getHideTitle()): ?>
|
35 |
-
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
36 |
-
<?php endif;?>
|
37 |
-
|
38 |
-
<table class="info-table">
|
39 |
-
<tbody>
|
40 |
-
<?php if($_info->getTokenId()): ?>
|
41 |
-
<tr>
|
42 |
-
<td><?php echo $_helper->__('Payer ID') ?>:</td>
|
43 |
-
<td><?php echo $this->getTokenId() ?></td>
|
44 |
-
</tr>
|
45 |
-
<?php endif; ?>
|
46 |
-
|
47 |
-
<?php if($_info->getCcLast4()): ?>
|
48 |
-
<tr>
|
49 |
-
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
50 |
-
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
51 |
-
</tr>
|
52 |
-
<?php endif; ?>
|
53 |
-
|
54 |
-
<?php if($_info->getLastTransId()): ?>
|
55 |
-
<tr>
|
56 |
-
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
57 |
-
<td><?php echo $_info->getLastTransId(); ?></td>
|
58 |
-
</tr>
|
59 |
-
<?php endif; ?>
|
60 |
-
|
61 |
-
<?php if($_info['beagle_score'] > 0): ?>
|
62 |
-
<tr>
|
63 |
-
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
64 |
-
<td><?php echo $_info['beagle_score']; ?></td>
|
65 |
-
</tr>
|
66 |
-
<?php endif; ?>
|
67 |
-
|
68 |
-
<?php if (isset($_info['beagle_verification'])):
|
69 |
-
$_verifications = array_filter(unserialize($_info['beagle_verification']) );
|
70 |
-
endif; ?>
|
71 |
-
<?php if(isset($_verifications) && !empty($_verifications)): ?>
|
72 |
-
<tr>
|
73 |
-
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
74 |
-
<td>
|
75 |
-
<?php $count = 0; ?>
|
76 |
-
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
77 |
-
<?php
|
78 |
-
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
79 |
-
?>
|
80 |
-
<span><?php echo $count ? ',' : '' ?><?php echo $key . ' : ' . $_verificationTitle ?></span>
|
81 |
-
<?php $count++ ?>
|
82 |
-
<?php endforeach; ?>
|
83 |
-
</td>
|
84 |
-
</tr>
|
85 |
-
<?php endif; ?>
|
86 |
-
|
87 |
-
</tbody>
|
88 |
-
</table>
|
89 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
+
*/
|
25 |
+
?>
|
26 |
+
<?php
|
27 |
+
$_helper = Mage::helper('ewayrapid');
|
28 |
+
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
29 |
+
$_info = $this->getInfo();
|
30 |
+
/* @var Mage_Sales_Model_Order_Payment $_info */
|
31 |
+
?>
|
32 |
+
<div class="cards-list">
|
33 |
+
|
34 |
+
<?php if (!$this->getHideTitle()): ?>
|
35 |
+
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
36 |
+
<?php endif;?>
|
37 |
+
|
38 |
+
<table class="info-table">
|
39 |
+
<tbody>
|
40 |
+
<?php if($_info->getTokenId()): ?>
|
41 |
+
<tr>
|
42 |
+
<td><?php echo $_helper->__('Payer ID') ?>:</td>
|
43 |
+
<td><?php echo $this->getTokenId() ?></td>
|
44 |
+
</tr>
|
45 |
+
<?php endif; ?>
|
46 |
+
|
47 |
+
<?php if($_info->getCcLast4()): ?>
|
48 |
+
<tr>
|
49 |
+
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
50 |
+
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
51 |
+
</tr>
|
52 |
+
<?php endif; ?>
|
53 |
+
|
54 |
+
<?php if($_info->getLastTransId()): ?>
|
55 |
+
<tr>
|
56 |
+
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
57 |
+
<td><?php echo $_info->getLastTransId(); ?></td>
|
58 |
+
</tr>
|
59 |
+
<?php endif; ?>
|
60 |
+
|
61 |
+
<?php if($_info['beagle_score'] > 0): ?>
|
62 |
+
<tr>
|
63 |
+
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
64 |
+
<td><?php echo $_info['beagle_score']; ?></td>
|
65 |
+
</tr>
|
66 |
+
<?php endif; ?>
|
67 |
+
|
68 |
+
<?php if (isset($_info['beagle_verification'])):
|
69 |
+
$_verifications = array_filter(unserialize($_info['beagle_verification']) );
|
70 |
+
endif; ?>
|
71 |
+
<?php if(isset($_verifications) && !empty($_verifications)): ?>
|
72 |
+
<tr>
|
73 |
+
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
74 |
+
<td>
|
75 |
+
<?php $count = 0; ?>
|
76 |
+
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
77 |
+
<?php
|
78 |
+
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
79 |
+
?>
|
80 |
+
<span><?php echo $count ? ',' : '' ?><?php echo $key . ' : ' . $_verificationTitle ?></span>
|
81 |
+
<?php $count++ ?>
|
82 |
+
<?php endforeach; ?>
|
83 |
+
</td>
|
84 |
+
</tr>
|
85 |
+
<?php endif; ?>
|
86 |
+
|
87 |
+
</tbody>
|
88 |
+
</table>
|
89 |
+
</div>
|
app/design/adminhtml/default/default/template/ewayrapid/info/sharedpage_notsaved.phtml
CHANGED
@@ -1,103 +1,103 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package default_default
|
23 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
-
*/
|
25 |
-
?>
|
26 |
-
<?php
|
27 |
-
$_helper = Mage::helper('ewayrapid');
|
28 |
-
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
29 |
-
$_info = $this->getInfo();
|
30 |
-
/* @var Mage_Sales_Model_Order_Payment $_info */
|
31 |
-
$_additionalInfo = $_info->getAdditionalInformation();
|
32 |
-
?>
|
33 |
-
<div class="cards-list">
|
34 |
-
|
35 |
-
<?php if (!$this->getHideTitle()): ?>
|
36 |
-
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
37 |
-
<?php endif;?>
|
38 |
-
|
39 |
-
<table class="info-table">
|
40 |
-
<tbody>
|
41 |
-
<?php if($_info->getCcOwner()) : ?>
|
42 |
-
<tr>
|
43 |
-
<td><?php echo $_helper->__('Card Holder\'s Name') ?>:</td>
|
44 |
-
<td><?php echo $_info->getCcOwner(); ?></td>
|
45 |
-
</tr>
|
46 |
-
<?php endif;?>
|
47 |
-
|
48 |
-
<?php if($_info->getCcLast4()) : ?>
|
49 |
-
<tr>
|
50 |
-
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
51 |
-
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
52 |
-
</tr>
|
53 |
-
<?php endif;?>
|
54 |
-
|
55 |
-
<?php if($_info->getCcExpMonth()) : ?>
|
56 |
-
<tr>
|
57 |
-
<td><?php echo $_helper->__('Credit Card Expiry') ?>:</td>
|
58 |
-
<td><?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?></td>
|
59 |
-
</tr>
|
60 |
-
<?php endif;?>
|
61 |
-
|
62 |
-
<?php if($_info->getCcType()) : ?>
|
63 |
-
<tr>
|
64 |
-
<td><?php echo $_helper->__('Credit Card Type') ?>:</td>
|
65 |
-
<td><?php echo $this->getCcTypeName($_info->getCcType()); ?></td>
|
66 |
-
</tr>
|
67 |
-
<?php endif;?>
|
68 |
-
|
69 |
-
<?php if($_info->getLastTransId()) : ?>
|
70 |
-
<tr>
|
71 |
-
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
72 |
-
<td><?php echo $_info->getLastTransId(); ?></td>
|
73 |
-
</tr>
|
74 |
-
<?php endif;?>
|
75 |
-
|
76 |
-
<?php if($_info['beagle_score'] > 0): ?>
|
77 |
-
<tr>
|
78 |
-
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
79 |
-
<td><?php echo $_info['beagle_score']; ?></td>
|
80 |
-
</tr>
|
81 |
-
<?php endif; ?>
|
82 |
-
|
83 |
-
<?php if (isset($_info['beagle_verification'])):
|
84 |
-
$_verifications = array_filter(unserialize($_info['beagle_verification']) );
|
85 |
-
endif; ?>
|
86 |
-
<?php if(isset($_verifications) && !empty($_verifications)): ?>
|
87 |
-
<tr>
|
88 |
-
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
89 |
-
<td>
|
90 |
-
<?php $count = 0; ?>
|
91 |
-
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
92 |
-
<?php
|
93 |
-
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
94 |
-
?>
|
95 |
-
<span><?php echo $count ? ',' : '' ?><?php echo $key . ' : ' . $_verificationTitle ?></span>
|
96 |
-
<?php $count++ ?>
|
97 |
-
<?php endforeach; ?>
|
98 |
-
</td>
|
99 |
-
</tr>
|
100 |
-
<?php endif; ?>
|
101 |
-
</tbody>
|
102 |
-
</table>
|
103 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
+
*/
|
25 |
+
?>
|
26 |
+
<?php
|
27 |
+
$_helper = Mage::helper('ewayrapid');
|
28 |
+
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
29 |
+
$_info = $this->getInfo();
|
30 |
+
/* @var Mage_Sales_Model_Order_Payment $_info */
|
31 |
+
$_additionalInfo = $_info->getAdditionalInformation();
|
32 |
+
?>
|
33 |
+
<div class="cards-list">
|
34 |
+
|
35 |
+
<?php if (!$this->getHideTitle()): ?>
|
36 |
+
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
37 |
+
<?php endif;?>
|
38 |
+
|
39 |
+
<table class="info-table">
|
40 |
+
<tbody>
|
41 |
+
<?php if($_info->getCcOwner()) : ?>
|
42 |
+
<tr>
|
43 |
+
<td><?php echo $_helper->__('Card Holder\'s Name') ?>:</td>
|
44 |
+
<td><?php echo $_info->getCcOwner(); ?></td>
|
45 |
+
</tr>
|
46 |
+
<?php endif;?>
|
47 |
+
|
48 |
+
<?php if($_info->getCcLast4()) : ?>
|
49 |
+
<tr>
|
50 |
+
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
51 |
+
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
52 |
+
</tr>
|
53 |
+
<?php endif;?>
|
54 |
+
|
55 |
+
<?php if($_info->getCcExpMonth()) : ?>
|
56 |
+
<tr>
|
57 |
+
<td><?php echo $_helper->__('Credit Card Expiry') ?>:</td>
|
58 |
+
<td><?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?></td>
|
59 |
+
</tr>
|
60 |
+
<?php endif;?>
|
61 |
+
|
62 |
+
<?php if($_info->getCcType()) : ?>
|
63 |
+
<tr>
|
64 |
+
<td><?php echo $_helper->__('Credit Card Type') ?>:</td>
|
65 |
+
<td><?php echo $this->getCcTypeName($_info->getCcType()); ?></td>
|
66 |
+
</tr>
|
67 |
+
<?php endif;?>
|
68 |
+
|
69 |
+
<?php if($_info->getLastTransId()) : ?>
|
70 |
+
<tr>
|
71 |
+
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
72 |
+
<td><?php echo $_info->getLastTransId(); ?></td>
|
73 |
+
</tr>
|
74 |
+
<?php endif;?>
|
75 |
+
|
76 |
+
<?php if($_info['beagle_score'] > 0): ?>
|
77 |
+
<tr>
|
78 |
+
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
79 |
+
<td><?php echo $_info['beagle_score']; ?></td>
|
80 |
+
</tr>
|
81 |
+
<?php endif; ?>
|
82 |
+
|
83 |
+
<?php if (isset($_info['beagle_verification'])):
|
84 |
+
$_verifications = array_filter(unserialize($_info['beagle_verification']) );
|
85 |
+
endif; ?>
|
86 |
+
<?php if(isset($_verifications) && !empty($_verifications)): ?>
|
87 |
+
<tr>
|
88 |
+
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
89 |
+
<td>
|
90 |
+
<?php $count = 0; ?>
|
91 |
+
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
92 |
+
<?php
|
93 |
+
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
94 |
+
?>
|
95 |
+
<span><?php echo $count ? ',' : '' ?><?php echo $key . ' : ' . $_verificationTitle ?></span>
|
96 |
+
<?php $count++ ?>
|
97 |
+
<?php endforeach; ?>
|
98 |
+
</td>
|
99 |
+
</tr>
|
100 |
+
<?php endif; ?>
|
101 |
+
</tbody>
|
102 |
+
</table>
|
103 |
+
</div>
|
app/design/adminhtml/default/default/template/ewayrapid/info/sharedpage_saved.phtml
CHANGED
@@ -1,103 +1,103 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package default_default
|
23 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
-
*/
|
25 |
-
?>
|
26 |
-
<?php
|
27 |
-
$_helper = Mage::helper('ewayrapid');
|
28 |
-
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
29 |
-
$_info = $this->getInfo();
|
30 |
-
/* @var Mage_Sales_Model_Order_Payment $_info */
|
31 |
-
$_additionalInfo = $_info->getAdditionalInformation();
|
32 |
-
?>
|
33 |
-
<div class="cards-list">
|
34 |
-
|
35 |
-
<?php if (!$this->getHideTitle()): ?>
|
36 |
-
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
37 |
-
<?php endif;?>
|
38 |
-
|
39 |
-
<table class="info-table">
|
40 |
-
<tbody>
|
41 |
-
<?php if($_info->getCcOwner()) : ?>
|
42 |
-
<tr>
|
43 |
-
<td><?php echo $_helper->__('Card Holder\'s Name') ?>:</td>
|
44 |
-
<td><?php echo $_info->getCcOwner(); ?></td>
|
45 |
-
</tr>
|
46 |
-
<?php endif;?>
|
47 |
-
|
48 |
-
<?php if($_info->getCcLast4()) : ?>
|
49 |
-
<tr>
|
50 |
-
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
51 |
-
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
52 |
-
</tr>
|
53 |
-
<?php endif;?>
|
54 |
-
|
55 |
-
<?php if($_info->getCcExpMonth()) : ?>
|
56 |
-
<tr>
|
57 |
-
<td><?php echo $_helper->__('Credit Card Expiry') ?>:</td>
|
58 |
-
<td><?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?></td>
|
59 |
-
</tr>
|
60 |
-
<?php endif;?>
|
61 |
-
|
62 |
-
<?php if($_info->getCcType()) : ?>
|
63 |
-
<tr>
|
64 |
-
<td><?php echo $_helper->__('Credit Card Type') ?>:</td>
|
65 |
-
<td><?php echo $this->getCcTypeName($_info->getCcType()); ?></td>
|
66 |
-
</tr>
|
67 |
-
<?php endif;?>
|
68 |
-
|
69 |
-
<?php if($_info->getLastTransId()) : ?>
|
70 |
-
<tr>
|
71 |
-
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
72 |
-
<td><?php echo $_info->getLastTransId(); ?></td>
|
73 |
-
</tr>
|
74 |
-
<?php endif;?>
|
75 |
-
|
76 |
-
<?php if($_info['beagle_score'] > 0): ?>
|
77 |
-
<tr>
|
78 |
-
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
79 |
-
<td><?php echo $_info['beagle_score']; ?></td>
|
80 |
-
</tr>
|
81 |
-
<?php endif; ?>
|
82 |
-
|
83 |
-
<?php if (isset($_info['beagle_verification'])):
|
84 |
-
$_verifications = array_filter(unserialize($_info['beagle_verification']) );
|
85 |
-
endif; ?>
|
86 |
-
<?php if(isset($_verifications) && !empty($_verifications)): ?>
|
87 |
-
<tr>
|
88 |
-
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
89 |
-
<td>
|
90 |
-
<?php $count = 0; ?>
|
91 |
-
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
92 |
-
<?php
|
93 |
-
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
94 |
-
?>
|
95 |
-
<span><?php echo $count ? ',' : '' ?><?php echo $key . ' : ' . $_verificationTitle ?></span>
|
96 |
-
<?php $count++ ?>
|
97 |
-
<?php endforeach; ?>
|
98 |
-
</td>
|
99 |
-
</tr>
|
100 |
-
<?php endif; ?>
|
101 |
-
</tbody>
|
102 |
-
</table>
|
103 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
+
*/
|
25 |
+
?>
|
26 |
+
<?php
|
27 |
+
$_helper = Mage::helper('ewayrapid');
|
28 |
+
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
29 |
+
$_info = $this->getInfo();
|
30 |
+
/* @var Mage_Sales_Model_Order_Payment $_info */
|
31 |
+
$_additionalInfo = $_info->getAdditionalInformation();
|
32 |
+
?>
|
33 |
+
<div class="cards-list">
|
34 |
+
|
35 |
+
<?php if (!$this->getHideTitle()): ?>
|
36 |
+
<div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
|
37 |
+
<?php endif;?>
|
38 |
+
|
39 |
+
<table class="info-table">
|
40 |
+
<tbody>
|
41 |
+
<?php if($_info->getCcOwner()) : ?>
|
42 |
+
<tr>
|
43 |
+
<td><?php echo $_helper->__('Card Holder\'s Name') ?>:</td>
|
44 |
+
<td><?php echo $_info->getCcOwner(); ?></td>
|
45 |
+
</tr>
|
46 |
+
<?php endif;?>
|
47 |
+
|
48 |
+
<?php if($_info->getCcLast4()) : ?>
|
49 |
+
<tr>
|
50 |
+
<td><?php echo $_helper->__('Credit Card Number') ?>:</td>
|
51 |
+
<td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
|
52 |
+
</tr>
|
53 |
+
<?php endif;?>
|
54 |
+
|
55 |
+
<?php if($_info->getCcExpMonth()) : ?>
|
56 |
+
<tr>
|
57 |
+
<td><?php echo $_helper->__('Credit Card Expiry') ?>:</td>
|
58 |
+
<td><?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?></td>
|
59 |
+
</tr>
|
60 |
+
<?php endif;?>
|
61 |
+
|
62 |
+
<?php if($_info->getCcType()) : ?>
|
63 |
+
<tr>
|
64 |
+
<td><?php echo $_helper->__('Credit Card Type') ?>:</td>
|
65 |
+
<td><?php echo $this->getCcTypeName($_info->getCcType()); ?></td>
|
66 |
+
</tr>
|
67 |
+
<?php endif;?>
|
68 |
+
|
69 |
+
<?php if($_info->getLastTransId()) : ?>
|
70 |
+
<tr>
|
71 |
+
<td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
|
72 |
+
<td><?php echo $_info->getLastTransId(); ?></td>
|
73 |
+
</tr>
|
74 |
+
<?php endif;?>
|
75 |
+
|
76 |
+
<?php if($_info['beagle_score'] > 0): ?>
|
77 |
+
<tr>
|
78 |
+
<td><?php echo $_helper->__('Beagle Score') ?>:</td>
|
79 |
+
<td><?php echo $_info['beagle_score']; ?></td>
|
80 |
+
</tr>
|
81 |
+
<?php endif; ?>
|
82 |
+
|
83 |
+
<?php if (isset($_info['beagle_verification'])):
|
84 |
+
$_verifications = array_filter(unserialize($_info['beagle_verification']) );
|
85 |
+
endif; ?>
|
86 |
+
<?php if(isset($_verifications) && !empty($_verifications)): ?>
|
87 |
+
<tr>
|
88 |
+
<td><?php echo $_helper->__('Beagle Verification') ?>:</td>
|
89 |
+
<td>
|
90 |
+
<?php $count = 0; ?>
|
91 |
+
<?php foreach($_verifications as $key => $_verificationCode): ?>
|
92 |
+
<?php
|
93 |
+
$_verificationTitle = Mage::helper('ewayrapid')->getBeagleVerificationTitle($_verificationCode);
|
94 |
+
?>
|
95 |
+
<span><?php echo $count ? ',' : '' ?><?php echo $key . ' : ' . $_verificationTitle ?></span>
|
96 |
+
<?php $count++ ?>
|
97 |
+
<?php endforeach; ?>
|
98 |
+
</td>
|
99 |
+
</tr>
|
100 |
+
<?php endif; ?>
|
101 |
+
</tbody>
|
102 |
+
</table>
|
103 |
+
</div>
|
app/design/adminhtml/default/default/template/ewayrapid/pdf/direct_notsaved.phtml
CHANGED
@@ -1,54 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package default_default
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
<?php
|
37 |
-
<?php
|
38 |
-
<?php
|
39 |
-
|
40 |
-
|
41 |
-
<?php
|
42 |
-
<?php
|
43 |
-
|
44 |
-
|
45 |
-
<?php
|
46 |
-
<?php
|
47 |
-
|
48 |
-
|
49 |
-
<?php
|
50 |
-
<?php
|
51 |
-
|
52 |
-
|
53 |
-
<?php
|
|
|
54 |
<?php endif; ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
$_helper = Mage::helper('ewayrapid');
|
29 |
+
/* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
|
30 |
+
$_info = $this->getInfo();
|
31 |
+
/* @var Mage_Sales_Model_Order_Payment $_info */
|
32 |
+
|
33 |
+
?>
|
34 |
+
|
35 |
+
|
36 |
+
<?php echo $this->getMethod()->getTitle() ?>{{pdf_row_separator}}
|
37 |
+
<?php if($_info->getCcOwner()): ?>
|
38 |
+
<?php echo $_helper->__('Card Holder\'s Name') ?>: <?php echo $_info->getCcOwner(); ?>{{pdf_row_separator}}
|
39 |
+
<?php endif; ?>
|
40 |
+
|
41 |
+
<?php if($_info->getCcLast4()): ?>
|
42 |
+
<?php echo $_helper->__('Credit Card Number') ?>: <?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?>{{pdf_row_separator}}
|
43 |
+
<?php endif; ?>
|
44 |
+
|
45 |
+
<?php if($_info->getCcExpMonth()): ?>
|
46 |
+
<?php echo $_helper->__('Credit Card Expiry') ?>: <?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?>{{pdf_row_separator}}
|
47 |
+
<?php endif; ?>
|
48 |
+
|
49 |
+
<?php if($_info->getCcType()): ?>
|
50 |
+
<?php echo $_helper->__('Credit Card Type') ?>: <?php echo $this->getCcTypeName($_info->getCcType()); ?>{{pdf_row_separator}}
|
51 |
+
<?php endif; ?>
|
52 |
+
|
53 |
+
<?php if($_info->getLastTransId()): ?>
|
54 |
+
<?php echo $_helper->__('Last Transaction ID') ?>: <?php echo $_info->getLastTransId(); ?>{{pdf_row_separator}}
|
55 |
<?php endif; ?>
|
app/design/frontend/base/default/layout/ewayrapid/layout.xml
CHANGED
@@ -1,216 +1,216 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<checkout_onepage_index>
|
4 |
-
<reference name="head">
|
5 |
-
<block type="core/text" name="external_js">
|
6 |
-
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
7 |
-
</block>
|
8 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
9 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
10 |
-
</reference>
|
11 |
-
<reference name="content">
|
12 |
-
<block type="core/template" name="ewayrapid.js" after="-">
|
13 |
-
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
14 |
-
<template>ewayrapid/js.phtml</template>
|
15 |
-
</action>
|
16 |
-
</block>
|
17 |
-
</reference>
|
18 |
-
</checkout_onepage_index>
|
19 |
-
|
20 |
-
<checkout_multishipping_billing>
|
21 |
-
<reference name="head">
|
22 |
-
<block type="core/text" name="external_js">
|
23 |
-
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
24 |
-
</block>
|
25 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
26 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
27 |
-
</reference>
|
28 |
-
<reference name="content">
|
29 |
-
<block type="core/template" name="ewayrapid.js" after="-">
|
30 |
-
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
31 |
-
<template>ewayrapid/js.phtml</template>
|
32 |
-
</action>
|
33 |
-
<action method="setCheckoutExtension">
|
34 |
-
<name>MultiShippingAddress</name>
|
35 |
-
</action>
|
36 |
-
</block>
|
37 |
-
</reference>
|
38 |
-
</checkout_multishipping_billing>
|
39 |
-
|
40 |
-
<customer_account>
|
41 |
-
<reference name="customer_account_navigation">
|
42 |
-
<action ifconfig="payment/ewayrapid_ewayone/active" method="addLink" translate="label" module="ewayrapid">
|
43 |
-
<name>my-creditcards</name>
|
44 |
-
<path>ewayrapid/mycards/</path>
|
45 |
-
<label>My Credit Cards</label>
|
46 |
-
</action>
|
47 |
-
|
48 |
-
<action ifconfig="payment/ewayrapid_transparentRedirect/active" method="addLink" translate="label" module="ewayrapid">
|
49 |
-
<name>my-transparent-redirect-card</name>
|
50 |
-
<path>ewayrapid/transparentredirectcard/</path>
|
51 |
-
<label>My Transparent Redirect Card</label>
|
52 |
-
</action>
|
53 |
-
|
54 |
-
</reference>
|
55 |
-
</customer_account>
|
56 |
-
<ewayrapid_mycards_index>
|
57 |
-
<update handle="customer_account"/>
|
58 |
-
<reference name="my.account.wrapper">
|
59 |
-
<block type="ewayrapid/customer_mycards" template="ewayrapid/customer/mycards.phtml" name="ewayrapid.token.list"></block>
|
60 |
-
<block type="customer/account_dashboard" name="customer.account.link.back" template="customer/account/link/back.phtml"/>
|
61 |
-
</reference>
|
62 |
-
</ewayrapid_mycards_index>
|
63 |
-
|
64 |
-
<ewayrapid_mycards_edit>
|
65 |
-
<reference name="head">
|
66 |
-
<block type="core/text" name="external_js">
|
67 |
-
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
68 |
-
</block>
|
69 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
70 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
71 |
-
</reference>
|
72 |
-
<update handle="customer_account"/>
|
73 |
-
<reference name="my.account.wrapper">
|
74 |
-
<block type="ewayrapid/customer_edit" template="ewayrapid/customer/edit.phtml" name="ewayrapid.token.edit"></block>
|
75 |
-
</reference>
|
76 |
-
</ewayrapid_mycards_edit>
|
77 |
-
|
78 |
-
<onestepcheckout_index_index>
|
79 |
-
<reference name="head">
|
80 |
-
<block type="core/text" name="external_js">
|
81 |
-
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
82 |
-
</block>
|
83 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
84 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
85 |
-
</reference>
|
86 |
-
<reference name="before_body_end">
|
87 |
-
<block type="core/template" name="ewayrapid.js" after="-">
|
88 |
-
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
89 |
-
<template>ewayrapid/js.phtml</template>
|
90 |
-
</action>
|
91 |
-
<action method="setCheckoutExtension">
|
92 |
-
<name>OneStepCheckout</name>
|
93 |
-
</action>
|
94 |
-
</block>
|
95 |
-
</reference>
|
96 |
-
</onestepcheckout_index_index>
|
97 |
-
|
98 |
-
<firecheckout_index_index>
|
99 |
-
<reference name="head">
|
100 |
-
<block type="core/text" name="external_js">
|
101 |
-
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
102 |
-
</block>
|
103 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
104 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
105 |
-
</reference>
|
106 |
-
<reference name="before_body_end">
|
107 |
-
<block type="core/template" name="ewayrapid.js" after="-">
|
108 |
-
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
109 |
-
<template>ewayrapid/js.phtml</template>
|
110 |
-
</action>
|
111 |
-
<action method="setCheckoutExtension">
|
112 |
-
<name>FireCheckout</name>
|
113 |
-
</action>
|
114 |
-
</block>
|
115 |
-
</reference>
|
116 |
-
</firecheckout_index_index>
|
117 |
-
|
118 |
-
<opc_index_index>
|
119 |
-
<reference name="head">
|
120 |
-
<block type="core/text" name="external_js">
|
121 |
-
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
122 |
-
</block>
|
123 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
124 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
125 |
-
</reference>
|
126 |
-
<reference name="before_body_end">
|
127 |
-
<block type="core/template" name="ewayrapid.js" after="-">
|
128 |
-
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
129 |
-
<template>ewayrapid/js.phtml</template>
|
130 |
-
</action>
|
131 |
-
<action method="setCheckoutExtension">
|
132 |
-
<name>IWDOnePageCheckout</name>
|
133 |
-
</action>
|
134 |
-
</block>
|
135 |
-
</reference>
|
136 |
-
</opc_index_index>
|
137 |
-
|
138 |
-
<gomage_checkout_onepage_index>
|
139 |
-
<reference name="head">
|
140 |
-
<block type="core/text" name="external_js">
|
141 |
-
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
142 |
-
</block>
|
143 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
144 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
145 |
-
</reference>
|
146 |
-
<reference name="before_body_end">
|
147 |
-
<block type="core/template" name="ewayrapid.js" after="-">
|
148 |
-
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
149 |
-
<template>ewayrapid/js.phtml</template>
|
150 |
-
</action>
|
151 |
-
<action method="setCheckoutExtension">
|
152 |
-
<name>LightCheckout</name>
|
153 |
-
</action>
|
154 |
-
</block>
|
155 |
-
</reference>
|
156 |
-
</gomage_checkout_onepage_index>
|
157 |
-
|
158 |
-
<hanlder_transparent_layout_empty>
|
159 |
-
<update handle="default"/>
|
160 |
-
<reference name="root">
|
161 |
-
<action method="setTemplate">
|
162 |
-
<template>page/empty.phtml</template>
|
163 |
-
</action>
|
164 |
-
</reference>
|
165 |
-
</hanlder_transparent_layout_empty>
|
166 |
-
|
167 |
-
<hanlder_transparent_layout>
|
168 |
-
<update handle="default"/>
|
169 |
-
<reference name="head">
|
170 |
-
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
171 |
-
</reference>
|
172 |
-
<reference name="root">
|
173 |
-
<action method="setTemplate">
|
174 |
-
<template>page/1column.phtml</template>
|
175 |
-
</action>
|
176 |
-
</reference>
|
177 |
-
</hanlder_transparent_layout>
|
178 |
-
|
179 |
-
<ewayrapid_transparent_paynow>
|
180 |
-
<update handle="hanlder_transparent_layout_empty"/>
|
181 |
-
<reference name="content">
|
182 |
-
<block type="ewayrapid/redirect_transparent" name="transparent.block.paynow"/>
|
183 |
-
</reference>
|
184 |
-
</ewayrapid_transparent_paynow>
|
185 |
-
|
186 |
-
<ewayrapid_transparent_redirect>
|
187 |
-
<update handle="hanlder_transparent_layout_empty"/>
|
188 |
-
<reference name="content">
|
189 |
-
<block type="ewayrapid/redirect_transparentCheckout" name="transparent.block.checkout"/>
|
190 |
-
</reference>
|
191 |
-
</ewayrapid_transparent_redirect>
|
192 |
-
|
193 |
-
<ewayrapid_handle_review>
|
194 |
-
<label>Eway Paypal Order Review Form</label>
|
195 |
-
<remove name="right"/>
|
196 |
-
<remove name="left"/>
|
197 |
-
|
198 |
-
<reference name="root">
|
199 |
-
<action method="setTemplate">
|
200 |
-
<template>page/1column.phtml</template>
|
201 |
-
</action>
|
202 |
-
</reference>
|
203 |
-
<reference name="content">
|
204 |
-
<block type="ewayrapid/redirect_paypalReview" name="eway.block.review">
|
205 |
-
</block>
|
206 |
-
</reference>
|
207 |
-
</ewayrapid_handle_review>
|
208 |
-
|
209 |
-
<ewayrapid_transparent_review>
|
210 |
-
<update handle="ewayrapid_handle_review"/>
|
211 |
-
</ewayrapid_transparent_review>
|
212 |
-
|
213 |
-
<ewayrapid_sharedpage_review>
|
214 |
-
<update handle="ewayrapid_handle_review"/>
|
215 |
-
</ewayrapid_sharedpage_review>
|
216 |
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<checkout_onepage_index>
|
4 |
+
<reference name="head">
|
5 |
+
<block type="core/text" name="external_js">
|
6 |
+
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
7 |
+
</block>
|
8 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
9 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
10 |
+
</reference>
|
11 |
+
<reference name="content">
|
12 |
+
<block type="core/template" name="ewayrapid.js" after="-">
|
13 |
+
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
14 |
+
<template>ewayrapid/js.phtml</template>
|
15 |
+
</action>
|
16 |
+
</block>
|
17 |
+
</reference>
|
18 |
+
</checkout_onepage_index>
|
19 |
+
|
20 |
+
<checkout_multishipping_billing>
|
21 |
+
<reference name="head">
|
22 |
+
<block type="core/text" name="external_js">
|
23 |
+
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
24 |
+
</block>
|
25 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
26 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
27 |
+
</reference>
|
28 |
+
<reference name="content">
|
29 |
+
<block type="core/template" name="ewayrapid.js" after="-">
|
30 |
+
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
31 |
+
<template>ewayrapid/js.phtml</template>
|
32 |
+
</action>
|
33 |
+
<action method="setCheckoutExtension">
|
34 |
+
<name>MultiShippingAddress</name>
|
35 |
+
</action>
|
36 |
+
</block>
|
37 |
+
</reference>
|
38 |
+
</checkout_multishipping_billing>
|
39 |
+
|
40 |
+
<customer_account>
|
41 |
+
<reference name="customer_account_navigation">
|
42 |
+
<action ifconfig="payment/ewayrapid_ewayone/active" method="addLink" translate="label" module="ewayrapid">
|
43 |
+
<name>my-creditcards</name>
|
44 |
+
<path>ewayrapid/mycards/</path>
|
45 |
+
<label>My Credit Cards</label>
|
46 |
+
</action>
|
47 |
+
|
48 |
+
<action ifconfig="payment/ewayrapid_transparentRedirect/active" method="addLink" translate="label" module="ewayrapid">
|
49 |
+
<name>my-transparent-redirect-card</name>
|
50 |
+
<path>ewayrapid/transparentredirectcard/</path>
|
51 |
+
<label>My Transparent Redirect Card</label>
|
52 |
+
</action>
|
53 |
+
|
54 |
+
</reference>
|
55 |
+
</customer_account>
|
56 |
+
<ewayrapid_mycards_index>
|
57 |
+
<update handle="customer_account"/>
|
58 |
+
<reference name="my.account.wrapper">
|
59 |
+
<block type="ewayrapid/customer_mycards" template="ewayrapid/customer/mycards.phtml" name="ewayrapid.token.list"></block>
|
60 |
+
<block type="customer/account_dashboard" name="customer.account.link.back" template="customer/account/link/back.phtml"/>
|
61 |
+
</reference>
|
62 |
+
</ewayrapid_mycards_index>
|
63 |
+
|
64 |
+
<ewayrapid_mycards_edit>
|
65 |
+
<reference name="head">
|
66 |
+
<block type="core/text" name="external_js">
|
67 |
+
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
68 |
+
</block>
|
69 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
70 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
71 |
+
</reference>
|
72 |
+
<update handle="customer_account"/>
|
73 |
+
<reference name="my.account.wrapper">
|
74 |
+
<block type="ewayrapid/customer_edit" template="ewayrapid/customer/edit.phtml" name="ewayrapid.token.edit"></block>
|
75 |
+
</reference>
|
76 |
+
</ewayrapid_mycards_edit>
|
77 |
+
|
78 |
+
<onestepcheckout_index_index>
|
79 |
+
<reference name="head">
|
80 |
+
<block type="core/text" name="external_js">
|
81 |
+
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
82 |
+
</block>
|
83 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
84 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
85 |
+
</reference>
|
86 |
+
<reference name="before_body_end">
|
87 |
+
<block type="core/template" name="ewayrapid.js" after="-">
|
88 |
+
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
89 |
+
<template>ewayrapid/js.phtml</template>
|
90 |
+
</action>
|
91 |
+
<action method="setCheckoutExtension">
|
92 |
+
<name>OneStepCheckout</name>
|
93 |
+
</action>
|
94 |
+
</block>
|
95 |
+
</reference>
|
96 |
+
</onestepcheckout_index_index>
|
97 |
+
|
98 |
+
<firecheckout_index_index>
|
99 |
+
<reference name="head">
|
100 |
+
<block type="core/text" name="external_js">
|
101 |
+
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
102 |
+
</block>
|
103 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
104 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
105 |
+
</reference>
|
106 |
+
<reference name="before_body_end">
|
107 |
+
<block type="core/template" name="ewayrapid.js" after="-">
|
108 |
+
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
109 |
+
<template>ewayrapid/js.phtml</template>
|
110 |
+
</action>
|
111 |
+
<action method="setCheckoutExtension">
|
112 |
+
<name>FireCheckout</name>
|
113 |
+
</action>
|
114 |
+
</block>
|
115 |
+
</reference>
|
116 |
+
</firecheckout_index_index>
|
117 |
+
|
118 |
+
<opc_index_index>
|
119 |
+
<reference name="head">
|
120 |
+
<block type="core/text" name="external_js">
|
121 |
+
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
122 |
+
</block>
|
123 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
124 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
125 |
+
</reference>
|
126 |
+
<reference name="before_body_end">
|
127 |
+
<block type="core/template" name="ewayrapid.js" after="-">
|
128 |
+
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
129 |
+
<template>ewayrapid/js.phtml</template>
|
130 |
+
</action>
|
131 |
+
<action method="setCheckoutExtension">
|
132 |
+
<name>IWDOnePageCheckout</name>
|
133 |
+
</action>
|
134 |
+
</block>
|
135 |
+
</reference>
|
136 |
+
</opc_index_index>
|
137 |
+
|
138 |
+
<gomage_checkout_onepage_index>
|
139 |
+
<reference name="head">
|
140 |
+
<block type="core/text" name="external_js">
|
141 |
+
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>]]> </text> </action>
|
142 |
+
</block>
|
143 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
|
144 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
145 |
+
</reference>
|
146 |
+
<reference name="before_body_end">
|
147 |
+
<block type="core/template" name="ewayrapid.js" after="-">
|
148 |
+
<action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
|
149 |
+
<template>ewayrapid/js.phtml</template>
|
150 |
+
</action>
|
151 |
+
<action method="setCheckoutExtension">
|
152 |
+
<name>LightCheckout</name>
|
153 |
+
</action>
|
154 |
+
</block>
|
155 |
+
</reference>
|
156 |
+
</gomage_checkout_onepage_index>
|
157 |
+
|
158 |
+
<hanlder_transparent_layout_empty>
|
159 |
+
<update handle="default"/>
|
160 |
+
<reference name="root">
|
161 |
+
<action method="setTemplate">
|
162 |
+
<template>page/empty.phtml</template>
|
163 |
+
</action>
|
164 |
+
</reference>
|
165 |
+
</hanlder_transparent_layout_empty>
|
166 |
+
|
167 |
+
<hanlder_transparent_layout>
|
168 |
+
<update handle="default"/>
|
169 |
+
<reference name="head">
|
170 |
+
<action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
|
171 |
+
</reference>
|
172 |
+
<reference name="root">
|
173 |
+
<action method="setTemplate">
|
174 |
+
<template>page/1column.phtml</template>
|
175 |
+
</action>
|
176 |
+
</reference>
|
177 |
+
</hanlder_transparent_layout>
|
178 |
+
|
179 |
+
<ewayrapid_transparent_paynow>
|
180 |
+
<update handle="hanlder_transparent_layout_empty"/>
|
181 |
+
<reference name="content">
|
182 |
+
<block type="ewayrapid/redirect_transparent" name="transparent.block.paynow"/>
|
183 |
+
</reference>
|
184 |
+
</ewayrapid_transparent_paynow>
|
185 |
+
|
186 |
+
<ewayrapid_transparent_redirect>
|
187 |
+
<update handle="hanlder_transparent_layout_empty"/>
|
188 |
+
<reference name="content">
|
189 |
+
<block type="ewayrapid/redirect_transparentCheckout" name="transparent.block.checkout"/>
|
190 |
+
</reference>
|
191 |
+
</ewayrapid_transparent_redirect>
|
192 |
+
|
193 |
+
<ewayrapid_handle_review>
|
194 |
+
<label>Eway Paypal Order Review Form</label>
|
195 |
+
<remove name="right"/>
|
196 |
+
<remove name="left"/>
|
197 |
+
|
198 |
+
<reference name="root">
|
199 |
+
<action method="setTemplate">
|
200 |
+
<template>page/1column.phtml</template>
|
201 |
+
</action>
|
202 |
+
</reference>
|
203 |
+
<reference name="content">
|
204 |
+
<block type="ewayrapid/redirect_paypalReview" name="eway.block.review">
|
205 |
+
</block>
|
206 |
+
</reference>
|
207 |
+
</ewayrapid_handle_review>
|
208 |
+
|
209 |
+
<ewayrapid_transparent_review>
|
210 |
+
<update handle="ewayrapid_handle_review"/>
|
211 |
+
</ewayrapid_transparent_review>
|
212 |
+
|
213 |
+
<ewayrapid_sharedpage_review>
|
214 |
+
<update handle="ewayrapid_handle_review"/>
|
215 |
+
</ewayrapid_sharedpage_review>
|
216 |
</layout>
|
app/design/frontend/base/default/template/ewayrapid/customer/edit.phtml
CHANGED
@@ -1,706 +1,706 @@
|
|
1 |
-
<?php
|
2 |
-
$_token = $this->getCurrentToken();
|
3 |
-
$_address = $this->getCustomerAddress();
|
4 |
-
|
5 |
-
// Form Url
|
6 |
-
$connectionType = Mage::getStoreConfig('payment/ewayrapid_general/connection_type');
|
7 |
-
$formUrl = $this->getSaveUrl();
|
8 |
-
$transparent = false;
|
9 |
-
$iframe = false;
|
10 |
-
$submitFunction = '';
|
11 |
-
switch ($connectionType) {
|
12 |
-
case Eway_Rapid31_Model_Config::CONNECTION_DIRECT:
|
13 |
-
echo '<script type="text/javascript" src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>';
|
14 |
-
break;
|
15 |
-
case Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT:
|
16 |
-
$transparent = true;
|
17 |
-
$submitFunction = 'beforeSubmit';
|
18 |
-
break;
|
19 |
-
case Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE:
|
20 |
-
$formUrl = Mage::getBaseUrl() . '/ewayrapid/mycards/getAccessCode';
|
21 |
-
break;
|
22 |
-
case Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME:
|
23 |
-
$formUrl = Mage::getBaseUrl() . '/ewayrapid/mycards/getAccessCode';
|
24 |
-
$iframe = true;
|
25 |
-
$submitFunction = 'beforeSubmitIframe';
|
26 |
-
break;
|
27 |
-
default:
|
28 |
-
break;
|
29 |
-
}
|
30 |
-
?>
|
31 |
-
<?php if ($this->getTitle()): ?>
|
32 |
-
<div class="page-title">
|
33 |
-
<h1><?php echo $this->getTitle() ?></h1>
|
34 |
-
</div>
|
35 |
-
<?php endif; ?>
|
36 |
-
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
37 |
-
<div class="tool-tip" id="payment-tool-tip" style="display:none;">
|
38 |
-
<div class="btn-close"><a href="#" id="payment-tool-tip-close"
|
39 |
-
title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
|
40 |
-
<div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>"
|
41 |
-
alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>"
|
42 |
-
title="<?php echo $this->__('Card Verification Number Visual Reference') ?>"/>
|
43 |
-
</div>
|
44 |
-
</div>
|
45 |
-
<form action="<?php echo $formUrl ?>" method="post" id="form-validate">
|
46 |
-
<input type="hidden" name="EWAY_ACCESSCODE" id="eway_accesscode"/>
|
47 |
-
<?php
|
48 |
-
if ($_token->getTokenId()) {
|
49 |
-
?>
|
50 |
-
<input type="hidden" name="token_id" value="<?php echo $_token->getTokenId() ?>"/>
|
51 |
-
<input type="hidden" name="TokenCustomerID" value="<?php echo $_token->getToken() ?>"/>
|
52 |
-
<?php } ?>
|
53 |
-
|
54 |
-
<!-- Card info -->
|
55 |
-
<?php
|
56 |
-
if ($connectionType !== Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE && $connectionType !== Eway_Rapid31_Model_Config::CONNECTION_RAPID_IFRAME) {
|
57 |
-
?>
|
58 |
-
<div class="fieldset">
|
59 |
-
<?php echo $this->getBlockHtml('formkey') ?>
|
60 |
-
<h2 class="legend"><?php echo $this->__('Credit Card Information') ?></h2>
|
61 |
-
|
62 |
-
<div class="sp-methods">
|
63 |
-
<ul class="form-list">
|
64 |
-
<li>
|
65 |
-
<div class="input-box">
|
66 |
-
<label for="ewayrapid_saved_cc_owner"
|
67 |
-
class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
|
68 |
-
<input type="text" title="<?php echo $this->__('Name on Card') ?>"
|
69 |
-
class="input-text required-entry validate-length maximum-length-50"
|
70 |
-
id="ewayrapid_saved_cc_owner"
|
71 |
-
name="payment[cc_owner]" value="<?php echo $this->escapeHtml($_token->getOwner()) ?>"
|
72 |
-
__maxlength="50" autocomplete="off"/>
|
73 |
-
</div>
|
74 |
-
</li>
|
75 |
-
<li>
|
76 |
-
<label for="ewayrapid_saved_cc_number"
|
77 |
-
class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
78 |
-
|
79 |
-
<div class="input-box help-disabled-cc">
|
80 |
-
<input type="text" id="ewayrapid_saved_cc_number" data-eway-encrypt-name="payment[cc_number]"
|
81 |
-
title="<?php echo $this->__('Credit Card Number') ?>"
|
82 |
-
class="input-text <?php if (!$this->isEdit()): ?>validate-cc-number validate-cc-type-auto<?php endif; ?>"
|
83 |
-
autocomplete="off" <?php if ($this->isEdit()): ?>value="<?php echo $_token->getCard() ?>"
|
84 |
-
disabled="disabled" <?php endif; ?> pattern="\d*"/>
|
85 |
-
<input type="hidden" id="ewayrapid_saved_cc_type" name="payment[cc_type]"
|
86 |
-
value="<?php echo $_token->getType() ?>"/>
|
87 |
-
<?php if ($this->isEdit()): ?>
|
88 |
-
<input type="hidden" name="EWAY_CARDNUMBER" value="444433XXXXXX1111"/>
|
89 |
-
<a href="#"><?php echo $this->__('Help') ?></a>
|
90 |
-
<div class="tool-tip" id="cc-help-tool-tip" style="display:none;">
|
91 |
-
<div class="btn-close">
|
92 |
-
<a href="#" id="cc-help-tool-tip-close"
|
93 |
-
title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a>
|
94 |
-
</div>
|
95 |
-
<div class="tool-tip-content">To use a new credit card number, please add another card
|
96 |
-
</div>
|
97 |
-
</div>
|
98 |
-
<?php endif; ?>
|
99 |
-
</div>
|
100 |
-
</li>
|
101 |
-
|
102 |
-
<li id="ewayrapid_saved_cc_type_exp_div">
|
103 |
-
<label for="ewayrapid_saved_expiration"
|
104 |
-
class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
105 |
-
|
106 |
-
<div class="input-box">
|
107 |
-
<div class="v-fix">
|
108 |
-
<select id="ewayrapid_saved_expiration" name="payment[cc_exp_month]"
|
109 |
-
class="month validate-cc-exp required-entry" autocomplete="off">
|
110 |
-
<?php $_ccExpMonth = $_token->getExpMonth() ?>
|
111 |
-
<?php foreach ($this->getCcMonths() as $k => $v): ?>
|
112 |
-
<option
|
113 |
-
value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
114 |
-
<?php endforeach ?>
|
115 |
-
</select>
|
116 |
-
</div>
|
117 |
-
<div class="v-fix">
|
118 |
-
<?php $_ccExpYear = $_token->getExpYear() ?>
|
119 |
-
<select id="ewayrapid_saved_expiration_yr" name="payment[cc_exp_year]"
|
120 |
-
class="year required-entry" autocomplete="off">
|
121 |
-
<?php foreach ($this->getCcYears() as $k => $v): ?>
|
122 |
-
<option
|
123 |
-
value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
124 |
-
<?php endforeach ?>
|
125 |
-
</select>
|
126 |
-
</div>
|
127 |
-
</div>
|
128 |
-
</li>
|
129 |
-
|
130 |
-
<?php
|
131 |
-
if ($transparent) {
|
132 |
-
?>
|
133 |
-
<li class="value_from_date">
|
134 |
-
<label for="ewayrapid_saved_start_month"
|
135 |
-
class="required"><?php echo $this->__('Valid From Date') ?></label>
|
136 |
-
|
137 |
-
<div class="input-box">
|
138 |
-
<div class="v-fix">
|
139 |
-
<select id="ewayrapid_saved_start_month" name="payment[cc_start_month]"
|
140 |
-
class="month" autocomplete="off">
|
141 |
-
<?php $_ccStartMonth = $_token->getStartMonth() ?>
|
142 |
-
<?php foreach ($this->getCcMonths() as $k => $v): ?>
|
143 |
-
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccStartMonth): ?>
|
144 |
-
selected="selected"<?php endif ?>><?php echo $v ?></option>
|
145 |
-
<?php endforeach ?>
|
146 |
-
</select>
|
147 |
-
</div>
|
148 |
-
<div class="v-fix">
|
149 |
-
<?php $_ccStartYear = $_token->getStartYear() ?>
|
150 |
-
<select id="ewayrapid_saved_start_year" name="payment[cc_start_year]"
|
151 |
-
class="year" autocomplete="off">
|
152 |
-
<?php
|
153 |
-
$start_year = 0;
|
154 |
-
$inc = 0;
|
155 |
-
foreach ($this->getCcYears() as $k => $v) {
|
156 |
-
if ($inc == 1) {
|
157 |
-
$start_year = (int)$k;
|
158 |
-
break;
|
159 |
-
}
|
160 |
-
echo "<option value=''>Year</option>";
|
161 |
-
$inc++;
|
162 |
-
}
|
163 |
-
|
164 |
-
for ($i = 10; $i > 0; $i--) {
|
165 |
-
?>
|
166 |
-
<option value="<?php echo $start_year - $i ?>"
|
167 |
-
<?php if (($start_year - $i) == $_ccStartYear) { ?>
|
168 |
-
selected="selected"<?php } ?>>
|
169 |
-
<?php echo $start_year - $i ?>
|
170 |
-
</option>
|
171 |
-
<?php
|
172 |
-
}
|
173 |
-
|
174 |
-
$inc = 0;
|
175 |
-
foreach ($this->getCcYears() as $k => $v):
|
176 |
-
$inc++;
|
177 |
-
if ($inc == 1) {
|
178 |
-
continue;
|
179 |
-
}
|
180 |
-
?>
|
181 |
-
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccStartYear): ?>
|
182 |
-
selected="selected"<?php endif ?>><?php echo $v ?></option>
|
183 |
-
<?php
|
184 |
-
endforeach;
|
185 |
-
?>
|
186 |
-
</select>
|
187 |
-
</div>
|
188 |
-
</div>
|
189 |
-
</li>
|
190 |
-
<li>
|
191 |
-
<div class="input-box">
|
192 |
-
<label for="ewayrapid_saved_issue_number">
|
193 |
-
<?php echo $this->__('Issue Number') ?>
|
194 |
-
</label>
|
195 |
-
<input type="text" title="<?php echo $this->__('Issue Number') ?>"
|
196 |
-
class="input-text validate-length maximum-length-4"
|
197 |
-
id="ewayrapid_saved_issue_number"
|
198 |
-
name="payment[cc_issue_number]"
|
199 |
-
value="<?php echo $this->escapeHtml($_token->getIssueNumber()) ?>"
|
200 |
-
__maxlength="50" autocomplete="off"/>
|
201 |
-
</div>
|
202 |
-
</li>
|
203 |
-
<?php
|
204 |
-
}
|
205 |
-
?>
|
206 |
-
|
207 |
-
<?php if ($this->hasVerification()): ?>
|
208 |
-
<li id="ewayrapid_saved_cc_type_cvv_div">
|
209 |
-
<label for="ewayrapid_saved_cc_cid"
|
210 |
-
class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
211 |
-
|
212 |
-
<div class="input-box">
|
213 |
-
<div class="v-fix">
|
214 |
-
<input type="text" title="<?php echo $this->__('Card Verification Number') ?>"
|
215 |
-
class="input-text cvv required-entry validate-cc-cvn" id="ewayrapid_saved_cc_cid"
|
216 |
-
data-eway-encrypt-name="payment[cc_cid]" value="" autocomplete="off"
|
217 |
-
pattern="\d*"/>
|
218 |
-
</div>
|
219 |
-
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
220 |
-
</div>
|
221 |
-
</li>
|
222 |
-
<?php endif; ?>
|
223 |
-
<?php
|
224 |
-
$_defaultToken = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
225 |
-
if (!$_token->getToken() || ($_defaultToken && $_defaultToken != $_token->getTokenId())): ?>
|
226 |
-
<li>
|
227 |
-
<div class="v-fix" style="padding-right: 5px;">
|
228 |
-
<input type="checkbox" id="ewayrapid_saved_default" name="is_default"/>
|
229 |
-
</div>
|
230 |
-
<label for="ewayrapid_saved_default"><?php echo $this->__('Default Credit Card') ?></label>
|
231 |
-
</li>
|
232 |
-
<?php endif; ?>
|
233 |
-
</ul>
|
234 |
-
</div>
|
235 |
-
</div>
|
236 |
-
<?php
|
237 |
-
} else {
|
238 |
-
// Responsive shared page card data
|
239 |
-
// ....
|
240 |
-
$_defaultToken = Mage::helper('ewayrapid/customer')->getDefaultToken();
|
241 |
-
if (!$_token->getToken() || ($_defaultToken && $_defaultToken != $_token->getTokenId())): ?>
|
242 |
-
<ul>
|
243 |
-
<li>
|
244 |
-
<div class="v-fix" style="padding-right: 5px;">
|
245 |
-
<input type="checkbox" id="ewayrapid_saved_default" name="is_default"/>
|
246 |
-
</div>
|
247 |
-
<label for="ewayrapid_saved_default"><?php echo $this->__('Default Credit Card') ?></label>
|
248 |
-
</li>
|
249 |
-
</ul>
|
250 |
-
<?php endif;
|
251 |
-
} ?>
|
252 |
-
<div class="fieldset bill-address">
|
253 |
-
<h2 class="legend"><?php echo $this->__('Billing Address') ?></h2>
|
254 |
-
<ul class="form-list">
|
255 |
-
<li class="fields">
|
256 |
-
<div class="customer-name-prefix">
|
257 |
-
<div class="field name-prefix">
|
258 |
-
<label for="address_prefix"><?php echo $this->__('Title') ?></label>
|
259 |
-
|
260 |
-
<div class="input-box">
|
261 |
-
<select id="address_prefix" name="address[prefix]" title="<?php echo $this->__('Title') ?>">
|
262 |
-
<?php foreach ($this->getPrefixOptions() as $_option): ?>
|
263 |
-
<option
|
264 |
-
value="<?php echo $_option ?>"<?php if ($_address->getTitle() == $_option): ?>
|
265 |
-
selected="selected"<?php endif; ?>><?php echo $this->__($_option) ?></option>
|
266 |
-
<?php endforeach; ?>
|
267 |
-
</select>
|
268 |
-
</div>
|
269 |
-
</div>
|
270 |
-
<div class="field name-firstname">
|
271 |
-
<label for="address_firstname" class="required"><em>*</em><?php echo $this->__('First Name') ?>
|
272 |
-
</label>
|
273 |
-
|
274 |
-
<div class="input-box">
|
275 |
-
<input type="text" id="address_firstname" name="address[firstname]"
|
276 |
-
value="<?php echo $this->escapeHtml($_address->getFirstName()) ?>"
|
277 |
-
title="<?php echo $this->__('First Name') ?>"
|
278 |
-
__maxlength="50" class="input-text required-entry validate-length maximum-length-50"/>
|
279 |
-
</div>
|
280 |
-
</div>
|
281 |
-
<div class="field name-lastname">
|
282 |
-
<label for="address_lastname" class="required"><em>*</em><?php echo $this->__('Last Name') ?>
|
283 |
-
</label>
|
284 |
-
|
285 |
-
<div class="input-box">
|
286 |
-
<input type="text" id="address_lastname" name="address[lastname]"
|
287 |
-
value="<?php echo $this->escapeHtml($_address->getLastName()) ?>"
|
288 |
-
title="<?php echo $this->__('Last Name') ?>" __maxlength="50"
|
289 |
-
class="input-text required-entry validate-length maximum-length-50"/>
|
290 |
-
</div>
|
291 |
-
</div>
|
292 |
-
</div>
|
293 |
-
</li>
|
294 |
-
<li class="fields">
|
295 |
-
<div class="field">
|
296 |
-
<label for="address_company"><?php echo $this->__('Company') ?></label>
|
297 |
-
|
298 |
-
<div class="input-box">
|
299 |
-
<input type="text" name="address[company]" id="address_company"
|
300 |
-
title="<?php echo $this->__('Company') ?>" __maxlength="50"
|
301 |
-
value="<?php echo $this->escapeHtml($_address->getCompanyName()) ?>"
|
302 |
-
class="input-text validate-length maximum-length-50"/>
|
303 |
-
</div>
|
304 |
-
</div>
|
305 |
-
<div class="field">
|
306 |
-
<label for="address_job_description"><?php echo $this->__('Job Description') ?></label>
|
307 |
-
|
308 |
-
<div class="input-box">
|
309 |
-
<input type="text" name="address[job_description]" id="address_job_description"
|
310 |
-
title="<?php echo $this->__('Job Description') ?>" __maxlength="50"
|
311 |
-
value="<?php echo $this->escapeHtml($_address->getJobDescription()) ?>"
|
312 |
-
class="input-text validate-length maximum-length-50"/>
|
313 |
-
</div>
|
314 |
-
</div>
|
315 |
-
|
316 |
-
</li>
|
317 |
-
<li class="fields">
|
318 |
-
<div class="field">
|
319 |
-
<label for="address_telephone" class="required"><em>*</em><?php echo $this->__('Phone') ?></label>
|
320 |
-
|
321 |
-
<div class="input-box">
|
322 |
-
<input type="text" name="address[telephone]"
|
323 |
-
value="<?php echo $this->escapeHtml($_address->getPhone()) ?>"
|
324 |
-
title="<?php echo $this->__('Phone') ?>"
|
325 |
-
class="input-text required-entry eway-validate-phone validate-length maximum-length-32"
|
326 |
-
id="address_telephone" __maxlength="32"/>
|
327 |
-
</div>
|
328 |
-
</div>
|
329 |
-
<div class="field">
|
330 |
-
<label for="address_mobile"><?php echo $this->__('Mobile') ?></label>
|
331 |
-
|
332 |
-
<div class="input-box">
|
333 |
-
<input type="text" name="address[mobile]"
|
334 |
-
value="<?php echo $this->escapeHtml($_address->getMobile()) ?>"
|
335 |
-
title="<?php echo $this->__('Mobile') ?>"
|
336 |
-
class="input-text eway-validate-phone validate-length maximum-length-32"
|
337 |
-
id="address_mobile" __maxlength="32"/>
|
338 |
-
</div>
|
339 |
-
</div>
|
340 |
-
</li>
|
341 |
-
<li class="fields">
|
342 |
-
<div class="field">
|
343 |
-
<label for="address_email"><?php echo $this->__('Email') ?></label>
|
344 |
-
|
345 |
-
<div class="input-box">
|
346 |
-
<input type="text" name="address[email]" id="address_email" __maxlength="50"
|
347 |
-
title="<?php echo $this->__('Email') ?>"
|
348 |
-
value="<?php echo $this->escapeHtml($_address->getEmail()) ?>"
|
349 |
-
class="input-text validate-email validate-length maximum-length-50"/>
|
350 |
-
</div>
|
351 |
-
</div>
|
352 |
-
<div class="field">
|
353 |
-
<label for="address_fax"><?php echo $this->__('Fax') ?></label>
|
354 |
-
|
355 |
-
<div class="input-box">
|
356 |
-
<input type="text" name="address[fax]" id="address_fax" title="<?php echo $this->__('Fax') ?>"
|
357 |
-
value="<?php echo $this->escapeHtml($_address->getFax()) ?>"
|
358 |
-
class="input-text eway-validate-phone validate-length maximum-length-32" __maxlength="32"/>
|
359 |
-
</div>
|
360 |
-
</div>
|
361 |
-
</li>
|
362 |
-
<li class="wide">
|
363 |
-
<label for="address_street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
|
364 |
-
|
365 |
-
<div class="input-box">
|
366 |
-
<input type="text" name="address[street][]" __maxlength="50"
|
367 |
-
value="<?php echo $this->escapeHtml($_address->getStreet1()) ?>"
|
368 |
-
title="<?php echo $this->__('Street Address') ?>" id="address_street_1"
|
369 |
-
class="input-text required-entry validate-length maximum-length-50"/>
|
370 |
-
</div>
|
371 |
-
</li>
|
372 |
-
<li class="wide">
|
373 |
-
<div class="input-box">
|
374 |
-
<input type="text" name="address[street][]" __maxlength="50"
|
375 |
-
value="<?php echo $this->escapeHtml($_address->getStreet2()) ?>"
|
376 |
-
title="<?php echo $this->__('Street Address') ?>" id="address_street_2"
|
377 |
-
class="input-text validate-length maximum-length-50"/>
|
378 |
-
</div>
|
379 |
-
</li>
|
380 |
-
<li class="fields">
|
381 |
-
<div class="field">
|
382 |
-
<label for="address_city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
383 |
-
|
384 |
-
<div class="input-box">
|
385 |
-
<input type="text" name="address[city]" __maxlength="50"
|
386 |
-
value="<?php echo $_address->getCity() ?>" title="<?php echo $this->__('City') ?>"
|
387 |
-
class="input-text required-entry validate-length maximum-length-50" id="address_city"/>
|
388 |
-
</div>
|
389 |
-
</div>
|
390 |
-
<div class="field">
|
391 |
-
<label for="address_region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?>
|
392 |
-
</label>
|
393 |
-
|
394 |
-
<div class="input-box">
|
395 |
-
<select id="address_region_id" name="address[region_id]"
|
396 |
-
title="<?php echo $this->__('State/Province') ?>" class="validate-select"
|
397 |
-
style="display:none;">
|
398 |
-
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
399 |
-
</select>
|
400 |
-
<script type="text/javascript">
|
401 |
-
//<![CDATA[
|
402 |
-
$('address_region_id').setAttribute('defaultValue', "<?php echo $_address->getRegionId() ?>");
|
403 |
-
//]]>
|
404 |
-
</script>
|
405 |
-
<input type="text" id="address_region" name="address[region]" __maxlength="50"
|
406 |
-
value="<?php echo $this->escapeHtml($_address->getState()) ?>"
|
407 |
-
title="<?php echo $this->__('State/Province') ?>"
|
408 |
-
class="input-text validate-length maximum-length-50"/>
|
409 |
-
</div>
|
410 |
-
</div>
|
411 |
-
</li>
|
412 |
-
<li class="fields">
|
413 |
-
<div class="field">
|
414 |
-
<label for="address_zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
415 |
-
|
416 |
-
<div class="input-box">
|
417 |
-
<input type="text" name="address[postcode]"
|
418 |
-
value="<?php echo $this->escapeHtml($_address->getPostalCode()) ?>"
|
419 |
-
title="<?php echo $this->__('Zip/Postal Code') ?>" id="address_zip"
|
420 |
-
class="input-text validate-zip-international required-entry validate-length maximum-length-30"
|
421 |
-
__maxlength="30"/>
|
422 |
-
</div>
|
423 |
-
</div>
|
424 |
-
<div class="field">
|
425 |
-
<label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
426 |
-
|
427 |
-
<div class="input-box">
|
428 |
-
<?php echo $this->getCountryHtmlSelect(strtoupper($_address->getCountry()), 'address[country_id]', 'address_country') ?>
|
429 |
-
</div>
|
430 |
-
</div>
|
431 |
-
</li>
|
432 |
-
</ul>
|
433 |
-
</div>
|
434 |
-
<div class="buttons-set">
|
435 |
-
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
436 |
-
|
437 |
-
<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>">
|
438 |
-
<small>« </small><?php echo $this->__('Back') ?></a></p>
|
439 |
-
<?php
|
440 |
-
echo $transparent || $iframe ? '<button type="button" onclick="'.$submitFunction.'(this)" title="'
|
441 |
-
. $this->__('Save Credit Card') . '" class="button"><span><span>'
|
442 |
-
. $this->__('Save Credit Card') . '</span></span></button>'
|
443 |
-
. '<span id="save-please-wait" class="please-wait" style="display:none;">
|
444 |
-
<img class="v-middle" title="Loading..." alt="Loading..." src="'
|
445 |
-
. Mage::getBaseUrl() . '/skin/frontend/rwd/default/images/opc-ajax-loader.gif">
|
446 |
-
Please waiting ...
|
447 |
-
</span>'
|
448 |
-
: '<button type="submit" title="' . $this->__('Save Credit Card') . '" class="button"><span><span>' . $this->__('Save Credit Card') . '</span></span></button>';
|
449 |
-
?>
|
450 |
-
|
451 |
-
</div>
|
452 |
-
</form>
|
453 |
-
|
454 |
-
<script type="text/javascript">
|
455 |
-
//<![CDATA[
|
456 |
-
var dataForm = new VarienForm('form-validate', true);
|
457 |
-
new RegionUpdater('address_country', 'address_region', 'address_region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'address_zip');
|
458 |
-
EwayPayment.supportCardTypes = <?php echo json_encode(Mage::getSingleton('ewayrapid/config')->getSupportedCardTypes()) ?>;
|
459 |
-
|
460 |
-
$$('.cvv-what-is-this').each(function (element) {
|
461 |
-
Event.observe(element, 'click', toggleToolTip);
|
462 |
-
});
|
463 |
-
|
464 |
-
function toggleToolTip(event) {
|
465 |
-
if ($('payment-tool-tip')) {
|
466 |
-
$('payment-tool-tip').setStyle({
|
467 |
-
top: (Event.pointerY(event) - 200) + 'px'//,
|
468 |
-
})
|
469 |
-
$('payment-tool-tip').toggle();
|
470 |
-
}
|
471 |
-
Event.stop(event);
|
472 |
-
}
|
473 |
-
if ($('payment-tool-tip-close')) {
|
474 |
-
Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
|
475 |
-
}
|
476 |
-
|
477 |
-
$('form-validate').onsubmit = function () {
|
478 |
-
return (dataForm.validator && dataForm.validator.validate());
|
479 |
-
}
|
480 |
-
var ewayPayment = new EwayPayment($('form-validate'), '<?php echo Mage::getSingleton('ewayrapid/config')->getEncryptionKey() ?>');
|
481 |
-
|
482 |
-
$$('.help-disabled-cc a').each(function (element) {
|
483 |
-
Event.observe(element, 'click', toggleToolTipCc);
|
484 |
-
});
|
485 |
-
|
486 |
-
function toggleToolTipCc(event) {
|
487 |
-
if ($('cc-help-tool-tip')) {
|
488 |
-
$('cc-help-tool-tip').toggle();
|
489 |
-
}
|
490 |
-
Event.stop(event);
|
491 |
-
}
|
492 |
-
if ($('cc-help-tool-tip-close')) {
|
493 |
-
Event.observe($('cc-help-tool-tip-close'), 'click', toggleToolTipCc);
|
494 |
-
}
|
495 |
-
|
496 |
-
// TRANSPARENT REDIRECT
|
497 |
-
function beforeSubmit(obj) {
|
498 |
-
$('validate_from_date_message') != null ? $('validate_from_date_message').remove() : '';
|
499 |
-
$('ewayrapid_saved_start_month').removeClassName('validation-failed');
|
500 |
-
$('ewayrapid_saved_start_year').removeClassName('validation-failed');
|
501 |
-
$$('li.value_from_date')[0].removeClassName('validation-error');
|
502 |
-
|
503 |
-
if (typeof isTest !== 'undefined') {
|
504 |
-
// Alert error code ERR-012
|
505 |
-
alert('An error occurred while connecting to payment gateway. Please try again later.!');
|
506 |
-
return false;
|
507 |
-
}
|
508 |
-
|
509 |
-
//*********************************Valid From Date If Select********************************************************************
|
510 |
-
if($('ewayrapid_saved_start_year').value > 0 && $('ewayrapid_saved_start_month').value <= 0) {
|
511 |
-
$('validation-advice-year') && $('validation-advice-year').remove();
|
512 |
-
$('ewayrapid_saved_start_month').addClassName('validation-failed');
|
513 |
-
$('ewayrapid_saved_start_month').up('div').insert('<div class="validation-advice" id="validation-advice-month">Incorrect credit card from date.</div>');
|
514 |
-
return;
|
515 |
-
} else if($('ewayrapid_saved_start_year').value <= 0 && $('ewayrapid_saved_start_month').value > 0) {
|
516 |
-
$('validation-advice-month') && $('validation-advice-month').remove();
|
517 |
-
$('ewayrapid_saved_start_year').addClassName('validation-failed');
|
518 |
-
$('ewayrapid_saved_start_year').up('div').insert('<div class="validation-advice" id="validation-advice-year">Incorrect credit card from year.</div>');
|
519 |
-
return;
|
520 |
-
} else {
|
521 |
-
$('validation-advice-year') && $('validation-advice-year').remove();
|
522 |
-
$('validation-advice-month') && $('validation-advice-month').remove();
|
523 |
-
}
|
524 |
-
|
525 |
-
var from_date = new Date($('ewayrapid_saved_start_year').value + '-' + $('ewayrapid_saved_start_month').value).getTime();
|
526 |
-
var expiration_date = new Date($('ewayrapid_saved_expiration_yr').value + '-' + $('ewayrapid_saved_expiration').value).getTime();
|
527 |
-
if(Prototype.Browser.IE) {
|
528 |
-
from_date = new Date($('ewayrapid_saved_start_year').value, $('ewayrapid_saved_start_month').value, 1).getTime();
|
529 |
-
expiration_date = new Date($('ewayrapid_saved_expiration_yr').value, $('ewayrapid_saved_expiration').value, 1).getTime();
|
530 |
-
}
|
531 |
-
//console.log(from_date - expiration_date);
|
532 |
-
|
533 |
-
if(from_date - expiration_date > 0) {
|
534 |
-
$$('li.value_from_date')[0].insert({after: '<div style="" id="validate_from_date_message" ' +
|
535 |
-
'class="validation-advice">From Date is invalid. It must be earlier than Expiration Date.</div>'});
|
536 |
-
$('ewayrapid_saved_start_month').addClassName('validation-failed');
|
537 |
-
$('ewayrapid_saved_start_year').addClassName('validation-failed');
|
538 |
-
$$('li.value_from_date')[0].addClassName('validation-error');
|
539 |
-
return;
|
540 |
-
}
|
541 |
-
//******************************************************************************************************************************
|
542 |
-
|
543 |
-
var validate = dataForm.validator.validate();
|
544 |
-
if (!validate) {
|
545 |
-
return;
|
546 |
-
}
|
547 |
-
|
548 |
-
/*if ($('ewayrapid_saved_start_year').value != '' || $('ewayrapid_saved_start_month').value != '') {
|
549 |
-
if ((new Date($('ewayrapid_saved_expiration_yr').value + '-'
|
550 |
-
+ ($('ewayrapid_saved_expiration').value <= 9 ? '0' : '') + $('ewayrapid_saved_expiration').value).getTime() )
|
551 |
-
- ( new Date($('ewayrapid_saved_start_year').value + '-'
|
552 |
-
+ ($('ewayrapid_saved_start_month').value <= 9 ? '0' : '') + $('ewayrapid_saved_start_month').value).getTime() )
|
553 |
-
<= 0 ) {
|
554 |
-
$$('li.value_from_date')[0].insert({after: '<div style="" id="validate_from_date_message" ' +
|
555 |
-
'class="validation-advice">From Date is invalid. It must be earlier than Expiration Date.</div>'});
|
556 |
-
$('ewayrapid_saved_start_month').addClassName('validation-failed');
|
557 |
-
$('ewayrapid_saved_start_year').addClassName('validation-failed');
|
558 |
-
$$('li.value_from_date')[0].addClassName('validation-error');
|
559 |
-
return;
|
560 |
-
}
|
561 |
-
}*/
|
562 |
-
|
563 |
-
// Waiting
|
564 |
-
$(obj).setStyle({'display': 'none'});
|
565 |
-
$('save-please-wait').setStyle({'display': 'block'});
|
566 |
-
|
567 |
-
// Get access code
|
568 |
-
new Ajax.Request('<?php echo Mage::getBaseUrl() ?>/ewayrapid/mycards/getAccessCode',
|
569 |
-
{
|
570 |
-
method: 'post',
|
571 |
-
parameters: $('form-validate').serialize(true),
|
572 |
-
onSuccess: function (transport) {
|
573 |
-
if (transport.responseText) {
|
574 |
-
var data = JSON.parse(transport.responseText);
|
575 |
-
if (typeof data == 'object') {
|
576 |
-
|
577 |
-
// Check login require
|
578 |
-
if (data.login != undefined) {
|
579 |
-
alert('Session has expired');
|
580 |
-
window.location = window.location.href;
|
581 |
-
}
|
582 |
-
|
583 |
-
if (typeof data.AccessCode != 'undefined' & data.AccessCode != null) {
|
584 |
-
|
585 |
-
var actionUrl = data.FormActionURL;
|
586 |
-
$('form-validate').setAttribute('action', actionUrl);
|
587 |
-
// Change card info
|
588 |
-
$('ewayrapid_saved_cc_owner').setAttribute('name', 'EWAY_CARDNAME');
|
589 |
-
<?php
|
590 |
-
// Change card name if not edited
|
591 |
-
if (!$this->isEdit()) {
|
592 |
-
echo "$('ewayrapid_saved_cc_number').setAttribute('name', 'EWAY_CARDNUMBER');";
|
593 |
-
}
|
594 |
-
?>
|
595 |
-
$('ewayrapid_saved_expiration').setAttribute('name', 'EWAY_CARDEXPIRYMONTH');
|
596 |
-
$('ewayrapid_saved_expiration_yr').setAttribute('name', 'EWAY_CARDEXPIRYYEAR');
|
597 |
-
|
598 |
-
$('eway_accesscode').setValue(data.AccessCode);
|
599 |
-
$('form-validate').submit();
|
600 |
-
return;
|
601 |
-
}
|
602 |
-
else {
|
603 |
-
// Alert error code ERR-012
|
604 |
-
alert('An error occurred while connecting to payment gateway. Please try again later.!');
|
605 |
-
}
|
606 |
-
} else {
|
607 |
-
alert(transport.responseText)
|
608 |
-
}
|
609 |
-
|
610 |
-
// Remove style waiting
|
611 |
-
$(obj).setStyle({'display': 'block'});
|
612 |
-
$('save-please-wait').setStyle({'display': 'none'});
|
613 |
-
}
|
614 |
-
},
|
615 |
-
onFailure: function () {
|
616 |
-
alert('Something went wrong...')
|
617 |
-
}
|
618 |
-
});
|
619 |
-
return false;
|
620 |
-
}
|
621 |
-
|
622 |
-
// Iframe
|
623 |
-
|
624 |
-
ewayReturnUrl = '';
|
625 |
-
|
626 |
-
function eWayRapidCallback (result, transactionID, errors) {
|
627 |
-
if (resul
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|