Version Notes
# Major Highlights
- Implemented omni-chronous authorization
# Changes
- Refactored order post-processing
- Changed IPN endpoint URL
- Changed frontend layout and templates (no backward compatibility)
- Simplified frontend JS application
Download this release
Release Info
Developer | creativestyle GmbH |
Extension | Creativestyle_AmazonPayments |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.8.6 to 2.0.0
- app/code/community/Creativestyle/AmazonPayments/Block/Abstract.php +252 -88
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Debug.php +157 -71
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Debug/Section.php +34 -19
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Debug/Section/Table.php +14 -12
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Info.php +83 -35
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Abstract.php +71 -34
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Api.php +27 -15
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Api/Grid.php +66 -49
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Api/View.php +58 -28
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Exception.php +27 -15
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Exception/Grid.php +57 -43
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Exception/View.php +42 -22
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Grid/Abstract.php +78 -31
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Ipn.php +27 -15
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Ipn/Grid.php +68 -42
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Ipn/View.php +89 -28
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/View/Abstract.php +96 -36
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Notifications.php +25 -15
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Register.php +34 -24
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Renderer/Timestamp.php +16 -12
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Sales/Order.php +0 -25
- app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/SellerCentral.php +172 -112
- app/code/community/Creativestyle/AmazonPayments/Block/Button/Js.php +0 -61
- app/code/community/Creativestyle/AmazonPayments/Block/Checkout.php +25 -35
- app/code/community/Creativestyle/AmazonPayments/Block/Checkout/Abstract.php +29 -22
- app/code/community/Creativestyle/AmazonPayments/Block/Checkout/Js.php +0 -40
- app/code/community/Creativestyle/AmazonPayments/Block/Checkout/Notice.php +17 -13
- app/code/community/Creativestyle/AmazonPayments/Block/Checkout/SandboxToolbox.php +16 -13
- app/code/community/Creativestyle/AmazonPayments/Block/Customer/Account/Dashboard/Login.php +25 -12
- app/code/community/Creativestyle/AmazonPayments/Block/Js.php +156 -57
- app/code/community/Creativestyle/AmazonPayments/Block/Js/Interface.php +0 -20
- app/code/community/Creativestyle/AmazonPayments/Block/Login/Abstract.php +19 -18
- app/code/community/Creativestyle/AmazonPayments/Block/Login/Account/Confirm.php +21 -13
- app/code/community/Creativestyle/AmazonPayments/Block/Login/Account/Update.php +16 -11
- app/code/community/Creativestyle/AmazonPayments/Block/Login/Button.php +54 -14
- app/code/community/Creativestyle/AmazonPayments/Block/Login/Js.php +0 -28
- app/code/community/Creativestyle/AmazonPayments/Block/Login/Redirect.php +35 -14
- app/code/community/Creativestyle/AmazonPayments/Block/Onepage/Button.php +16 -36
- app/code/community/Creativestyle/AmazonPayments/Block/Pay/Abstract.php +33 -23
- app/code/community/Creativestyle/AmazonPayments/Block/Pay/Button.php +46 -15
- app/code/community/Creativestyle/AmazonPayments/Block/Payment/Info.php +21 -13
- app/code/community/Creativestyle/AmazonPayments/Block/Payment/Legacy/Info.php +21 -13
- app/code/community/Creativestyle/AmazonPayments/Controller/Action.php +28 -0
- app/code/community/Creativestyle/AmazonPayments/Controller/Adminhtml/Log/Action.php +197 -0
- app/code/community/Creativestyle/AmazonPayments/Exception.php +13 -9
- app/code/community/Creativestyle/AmazonPayments/Exception/InvalidStatus.php +0 -16
- app/code/community/Creativestyle/AmazonPayments/Exception/InvalidStatus/Recoverable.php +0 -16
- app/code/community/Creativestyle/AmazonPayments/Exception/InvalidStatus/Unrecoverable.php +0 -16
- app/code/community/Creativestyle/AmazonPayments/Exception/InvalidTransaction.php +83 -0
- app/code/community/Creativestyle/AmazonPayments/Exception/TransactionNotFound.php +45 -0
- app/code/community/Creativestyle/AmazonPayments/Helper/Data.php +120 -84
- app/code/community/Creativestyle/AmazonPayments/Helper/Debug.php +265 -88
- app/code/community/Creativestyle/AmazonPayments/Model/Api/Abstract.php +40 -14
- app/code/community/Creativestyle/AmazonPayments/Model/Api/Advanced.php +232 -94
- app/code/community/Creativestyle/AmazonPayments/Model/Api/Ipn.php +140 -13
- app/code/community/Creativestyle/AmazonPayments/Model/Api/Login.php +38 -17
- app/code/community/Creativestyle/AmazonPayments/Model/Checkout.php +43 -23
- app/code/community/Creativestyle/AmazonPayments/Model/Config.php +527 -233
- app/code/community/Creativestyle/AmazonPayments/Model/Log/Collection.php +57 -26
- app/code/community/Creativestyle/AmazonPayments/Model/Logger.php +87 -27
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Abstract.php +26 -12
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/AccountRegion.php +20 -15
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Authentication.php +15 -11
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/AuthorizationMode.php +18 -12
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Color.php +19 -12
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Color/LoginPay.php +15 -12
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Size.php +15 -11
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Size/LoginPay.php +15 -12
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Type/Login.php +15 -11
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Type/Pay.php +15 -11
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Frequency.php +14 -12
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/IpnActive.php +14 -12
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Language.php +62 -47
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/PaymentAction.php +14 -13
- app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Region.php +0 -35
- app/code/community/Creativestyle/AmazonPayments/Model/Observer.php +176 -186
- app/code/community/Creativestyle/AmazonPayments/Model/Payment/Abstract.php +476 -389
- app/code/community/Creativestyle/AmazonPayments/Model/Payment/Advanced.php +11 -11
- app/code/community/Creativestyle/AmazonPayments/Model/Payment/Advanced/Sandbox.php +12 -11
- app/code/community/Creativestyle/AmazonPayments/Model/Payment/Legacy.php +15 -12
- app/code/community/Creativestyle/AmazonPayments/Model/Processor/Ipn.php +0 -139
- app/code/community/Creativestyle/AmazonPayments/Model/Processor/Order.php +382 -406
- app/code/community/Creativestyle/AmazonPayments/Model/Processor/Payment.php +135 -117
- app/code/community/Creativestyle/AmazonPayments/Model/Processor/Transaction.php +922 -0
- app/code/community/Creativestyle/AmazonPayments/Model/Processor/Transaction/DataMapper.php +574 -0
- app/code/community/Creativestyle/AmazonPayments/Model/Processor/TransactionAdapter.php +0 -485
- app/code/community/Creativestyle/AmazonPayments/Model/{Setup.php → Resource/Setup.php} +45 -26
- app/code/community/Creativestyle/AmazonPayments/Model/Service/Login.php +87 -39
- app/code/community/Creativestyle/AmazonPayments/Model/Service/Quote.php +38 -17
- app/code/community/Creativestyle/AmazonPayments/Model/Simulator.php +45 -21
- app/code/community/Creativestyle/AmazonPayments/Model/System/Config/Backend/DataPolling/Cron.php +16 -12
- app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/DebugController.php +33 -17
- app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/Log/ApiController.php +27 -62
- app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/Log/ExceptionController.php +27 -62
- app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/Log/IpnController.php +27 -62
- app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/OrderController.php +40 -16
- app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/SystemController.php +60 -36
- app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/CheckoutController.php +0 -407
- app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/IpnController.php +14 -73
- app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/LoginController.php +83 -32
- app/code/community/Creativestyle/AmazonPayments/controllers/CheckoutController.php +575 -0
- app/code/community/Creativestyle/AmazonPayments/controllers/IpnController.php +170 -0
- app/code/community/Creativestyle/AmazonPayments/etc/config.xml +24 -31
- app/code/community/Creativestyle/AmazonPayments/etc/system.xml +6 -64
- app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-install-1.0.0.php +9 -8
- app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-install-1.6.2.php +19 -16
- app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-install-2.0.0.php +34 -0
- app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-1.1.6-1.2.0.php +18 -15
- app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-1.7.4-1.7.6.php +18 -15
- app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-1.7.8-1.8.2.php +9 -8
- app/design/adminhtml/default/default/template/creativestyle/amazonpayments/advanced/log/{notification → ipn}/view.phtml +35 -5
- app/design/frontend/base/default/layout/amazonpayments.xml +23 -28
- app/design/frontend/base/default/template/creativestyle/amazonpayments/button/js.phtml +0 -37
- app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout.phtml +17 -10
- app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/capture_notice.phtml +20 -18
- app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/js.phtml +0 -58
- app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/review/button.phtml +17 -8
- app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/review/coupon.phtml +26 -10
- app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/sandbox_toolbox.phtml +26 -13
- app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/shipping_method.phtml +9 -7
- app/design/frontend/base/default/template/creativestyle/amazonpayments/customer/account/dashboard/login.phtml +14 -8
- app/design/frontend/base/default/template/creativestyle/amazonpayments/js.phtml +42 -12
- app/design/frontend/base/default/template/creativestyle/amazonpayments/login/button.phtml +13 -11
- app/design/frontend/base/default/template/creativestyle/amazonpayments/login/button/account_login.phtml +36 -30
- app/design/frontend/base/default/template/creativestyle/amazonpayments/login/form/account_confirm.phtml +36 -16
- app/design/frontend/base/default/template/creativestyle/amazonpayments/login/form/account_update.phtml +42 -17
- app/design/frontend/base/default/template/creativestyle/amazonpayments/login/js.phtml +0 -17
- app/design/frontend/base/default/template/creativestyle/amazonpayments/login/logout.phtml +0 -17
- app/design/frontend/base/default/template/creativestyle/amazonpayments/login/redirect.phtml +11 -8
- app/design/frontend/base/default/template/creativestyle/amazonpayments/onepage/button.phtml +14 -27
- app/design/frontend/base/default/template/creativestyle/amazonpayments/pay/button.phtml +35 -26
- app/design/frontend/base/default/template/creativestyle/amazonpayments/payment/info.phtml +13 -8
- app/design/frontend/base/default/template/creativestyle/amazonpayments/payment/legacy/info.phtml +9 -8
- app/design/frontend/base/default/template/creativestyle/amazonpayments/payment/legacy/pdf/info.phtml +9 -7
- app/design/frontend/base/default/template/creativestyle/amazonpayments/payment/pdf/info.phtml +9 -7
- js/creativestyle/adminhtml/amazonpayments.min.js +1 -1
- js/creativestyle/amazonpayments.min.js +1 -0
- js/creativestyle/amazonpayments.toolbox.min.js +1 -0
- js/creativestyle/apa_checkout.js +0 -635
- js/creativestyle/apa_checkout.min.js +0 -1
- js/creativestyle/apa_sandbox_toolbox.min.js +0 -1
- package.xml +10 -11
app/code/community/Creativestyle/AmazonPayments/Block/Abstract.php
CHANGED
@@ -1,20 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
abstract class Creativestyle_AmazonPayments_Block_Abstract extends Mage_Core_Block_Template {
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
/**
|
19 |
* Instance of the current quote
|
20 |
*
|
@@ -22,147 +30,303 @@ abstract class Creativestyle_AmazonPayments_Block_Abstract extends Mage_Core_Blo
|
|
22 |
*/
|
23 |
protected $_quote = null;
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
return
|
48 |
}
|
49 |
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
if (null === $this->_quote) {
|
64 |
$this->_quote = $this->_getCheckoutSession()->getQuote();
|
65 |
}
|
|
|
66 |
return $this->_quote;
|
67 |
}
|
68 |
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
foreach ($this->_getQuote()->getAllVisibleItems() as $item) {
|
72 |
if ($item->getIsVirtual()) {
|
73 |
return true;
|
74 |
}
|
75 |
}
|
|
|
76 |
return false;
|
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 |
-
public function
|
112 |
-
|
|
|
113 |
}
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
return $this->_widgetHtmlId;
|
124 |
}
|
125 |
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
}
|
129 |
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
}
|
133 |
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
return $this->_getQuote()->isVirtual();
|
144 |
}
|
145 |
|
146 |
/**
|
147 |
-
*
|
148 |
*
|
149 |
* @return string
|
150 |
*/
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
155 |
}
|
156 |
-
} catch (Exception $e) {
|
157 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
158 |
}
|
159 |
-
return '';
|
160 |
-
}
|
161 |
|
162 |
-
|
163 |
-
if (Mage::helper('amazonpayments')->isMobileDevice()) return false;
|
164 |
-
return $this->_getConfig()->isAutoAuthenticationExperience() && $this->_isConnectionSecure()
|
165 |
-
|| $this->_getConfig()->isPopupAuthenticationExperience();
|
166 |
}
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
|
|
17 |
|
18 |
+
/**
|
19 |
+
* Amazon Payments abstract block
|
20 |
+
*
|
21 |
+
* @method $this setIdSuffix(string $value)
|
22 |
+
* @method string getIdSuffix()
|
23 |
+
*/
|
24 |
+
abstract class Creativestyle_AmazonPayments_Block_Abstract extends Mage_Core_Block_Template
|
25 |
+
{
|
26 |
/**
|
27 |
* Instance of the current quote
|
28 |
*
|
30 |
*/
|
31 |
protected $_quote = null;
|
32 |
|
33 |
+
/**
|
34 |
+
* ID attribute of the top level block container
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_containerId = null;
|
39 |
|
40 |
+
/**
|
41 |
+
* Prefix for automatically generated container ID
|
42 |
+
*
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_containerIdPrefix = '';
|
46 |
|
47 |
+
/**
|
48 |
+
* CSS class of the top level block container
|
49 |
+
*
|
50 |
+
* @var string
|
51 |
+
*/
|
52 |
+
protected $_containerClass = '';
|
53 |
|
54 |
+
/**
|
55 |
+
* Returns instance of Amazon Payments config object
|
56 |
+
*
|
57 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
58 |
+
*/
|
59 |
+
protected function _getConfig()
|
60 |
+
{
|
61 |
+
return Mage::getSingleton('amazonpayments/config');
|
62 |
}
|
63 |
|
64 |
+
/**
|
65 |
+
* Returns instance of the checkout session
|
66 |
+
*
|
67 |
+
* @return Mage_Checkout_Model_Session
|
68 |
+
*/
|
69 |
+
protected function _getCheckoutSession()
|
70 |
+
{
|
71 |
+
return Mage::getSingleton('checkout/session');
|
72 |
}
|
73 |
|
74 |
+
/**
|
75 |
+
* Returns instance of the customer session
|
76 |
+
*
|
77 |
+
* @return Mage_Customer_Model_Session
|
78 |
+
*/
|
79 |
+
protected function _getCustomerSession()
|
80 |
+
{
|
81 |
+
return Mage::getSingleton('customer/session');
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* Returns Amazon Pay helper
|
86 |
+
*
|
87 |
+
* @return Creativestyle_AmazonPayments_Helper_Data
|
88 |
+
*/
|
89 |
+
protected function _getHelper()
|
90 |
+
{
|
91 |
+
return $this->helper('amazonpayments');
|
92 |
}
|
93 |
|
94 |
+
/**
|
95 |
+
* Returns Magento core helper
|
96 |
+
*
|
97 |
+
* @return Mage_Core_Helper_Data
|
98 |
+
*/
|
99 |
+
protected function _getCoreHelper()
|
100 |
+
{
|
101 |
+
return $this->helper('core');
|
102 |
}
|
103 |
|
104 |
+
/**
|
105 |
+
* Returns instance of the current quote
|
106 |
+
*
|
107 |
+
* @return Mage_Sales_Model_Quote
|
108 |
+
*/
|
109 |
+
protected function _getQuote()
|
110 |
+
{
|
111 |
if (null === $this->_quote) {
|
112 |
$this->_quote = $this->_getCheckoutSession()->getQuote();
|
113 |
}
|
114 |
+
|
115 |
return $this->_quote;
|
116 |
}
|
117 |
|
118 |
+
/**
|
119 |
+
* Checks whether current request is secure
|
120 |
+
*
|
121 |
+
* @return bool
|
122 |
+
*/
|
123 |
+
protected function _isConnectionSecure()
|
124 |
+
{
|
125 |
+
return Mage::app()->getStore()->isCurrentlySecure();
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Checks whether current requester IP is allowed to display Amazon widgets
|
130 |
+
*
|
131 |
+
* @return bool
|
132 |
+
*/
|
133 |
+
protected function _isCurrentIpAllowed()
|
134 |
+
{
|
135 |
+
return $this->_getConfig()->isCurrentIpAllowed();
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Checks whether Amazon widgets are allowed to be shown
|
140 |
+
* in the current shop locale
|
141 |
+
*
|
142 |
+
* @return bool
|
143 |
+
*/
|
144 |
+
protected function _isCurrentLocaleAllowed()
|
145 |
+
{
|
146 |
+
return $this->_getConfig()->isCurrentLocaleAllowed();
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Checks whether current quote has at least one virtual item
|
151 |
+
*
|
152 |
+
* @return bool
|
153 |
+
*/
|
154 |
+
protected function _quoteHasVirtualItems()
|
155 |
+
{
|
156 |
+
if ($this->isQuoteVirtual()) {
|
157 |
+
return true;
|
158 |
+
}
|
159 |
+
|
160 |
foreach ($this->_getQuote()->getAllVisibleItems() as $item) {
|
161 |
if ($item->getIsVirtual()) {
|
162 |
return true;
|
163 |
}
|
164 |
}
|
165 |
+
|
166 |
return false;
|
167 |
}
|
168 |
|
169 |
+
/**
|
170 |
+
* Returns whether block shall be rendered or not
|
171 |
+
*
|
172 |
+
* @return bool
|
173 |
+
*/
|
174 |
+
protected function _isActive()
|
175 |
+
{
|
176 |
+
return ($this->isLoginActive() || $this->isPayActive())
|
177 |
+
&& $this->_isCurrentIpAllowed();
|
178 |
}
|
179 |
|
180 |
+
/**
|
181 |
+
* Render Amazon Payments block
|
182 |
+
*
|
183 |
+
* @return string
|
184 |
+
*/
|
185 |
+
protected function _toHtml()
|
186 |
+
{
|
187 |
+
try {
|
188 |
+
if ($this->_isActive()) {
|
189 |
+
return parent::_toHtml();
|
190 |
+
}
|
191 |
+
} catch (Exception $e) {
|
192 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
193 |
}
|
194 |
+
|
195 |
+
return '';
|
196 |
}
|
197 |
|
198 |
+
/**
|
199 |
+
* Encode provided $valueToEncode into the JSON format
|
200 |
+
*
|
201 |
+
* @param mixed $valueToEncode
|
202 |
+
* @return string
|
203 |
+
*/
|
204 |
+
protected function _jsonEncode($valueToEncode)
|
205 |
+
{
|
206 |
+
return $this->_getCoreHelper()->jsonEncode($valueToEncode);
|
207 |
}
|
208 |
|
209 |
+
/**
|
210 |
+
* Checks whether Amazon Pay is enabled
|
211 |
+
*
|
212 |
+
* @return bool
|
213 |
+
*/
|
214 |
+
public function isPayActive()
|
215 |
+
{
|
216 |
+
return $this->_getConfig()->isPayActive();
|
217 |
}
|
218 |
|
219 |
+
/**
|
220 |
+
* Checks whether Login with Amazon is enabled
|
221 |
+
*
|
222 |
+
* @return bool
|
223 |
+
*/
|
224 |
+
public function isLoginActive()
|
225 |
+
{
|
226 |
+
return $this->_getConfig()->isLoginActive();
|
227 |
}
|
228 |
|
229 |
/**
|
230 |
+
* Returns Merchant ID for the configured Amazon merchant account
|
231 |
+
*
|
232 |
+
* @return string
|
233 |
*/
|
234 |
+
public function getMerchantId()
|
235 |
+
{
|
236 |
+
return $this->_getConfig()->getMerchantId();
|
237 |
}
|
238 |
|
239 |
+
/**
|
240 |
+
* Returns Amazon app client ID
|
241 |
+
*
|
242 |
+
* @return string
|
243 |
+
*/
|
244 |
+
public function getClientId()
|
245 |
+
{
|
246 |
+
return $this->_getConfig()->getClientId();
|
|
|
247 |
}
|
248 |
|
249 |
+
/**
|
250 |
+
* Returns order reference ID saved in session data
|
251 |
+
*
|
252 |
+
* @return string|null
|
253 |
+
*/
|
254 |
+
public function getOrderReferenceId()
|
255 |
+
{
|
256 |
+
return $this->_getCheckoutSession()->getAmazonOrderReferenceId();
|
257 |
}
|
258 |
|
259 |
+
/**
|
260 |
+
* Returns display language
|
261 |
+
*
|
262 |
+
* @return null|string
|
263 |
+
*/
|
264 |
+
public function getDisplayLanguage()
|
265 |
+
{
|
266 |
+
return $this->_getConfig()->getDisplayLanguage();
|
267 |
}
|
268 |
|
269 |
+
/**
|
270 |
+
* Checks whether extension runs in sandbox mode
|
271 |
+
*
|
272 |
+
* @return bool
|
273 |
+
*/
|
274 |
+
public function isSandboxActive()
|
275 |
+
{
|
276 |
+
return $this->_getConfig()->isSandboxActive();
|
277 |
}
|
278 |
|
279 |
+
/**
|
280 |
+
* Checks whether popup authentication experience shall be used
|
281 |
+
*
|
282 |
+
* @return bool
|
283 |
+
*/
|
284 |
+
public function isPopupAuthenticationExperience()
|
285 |
+
{
|
286 |
+
if ($this->_getHelper()->isMobileDevice()) {
|
287 |
+
return false;
|
288 |
+
}
|
289 |
+
|
290 |
+
return $this->_getConfig()->isPopupAuthenticationExperience()
|
291 |
+
|| $this->_getConfig()->isAutoAuthenticationExperience()
|
292 |
+
&& ($this->_isConnectionSecure() || !$this->isLoginActive());
|
293 |
}
|
294 |
|
295 |
+
/**
|
296 |
+
* Checks whether current quote contains only virtual products
|
297 |
+
*
|
298 |
+
* @return bool
|
299 |
+
*/
|
300 |
+
public function isQuoteVirtual()
|
301 |
+
{
|
302 |
return $this->_getQuote()->isVirtual();
|
303 |
}
|
304 |
|
305 |
/**
|
306 |
+
* Returns ID of block's HTML container
|
307 |
*
|
308 |
* @return string
|
309 |
*/
|
310 |
+
public function getContainerId()
|
311 |
+
{
|
312 |
+
if (null === $this->_containerId) {
|
313 |
+
if ($containerIdSuffix = $this->getIdSuffix()) {
|
314 |
+
$this->_containerId = $this->_containerIdPrefix . ucfirst($containerIdSuffix);
|
315 |
+
} else {
|
316 |
+
$this->_containerId = uniqid($this->_containerIdPrefix);
|
317 |
}
|
|
|
|
|
318 |
}
|
|
|
|
|
319 |
|
320 |
+
return $this->_containerId;
|
|
|
|
|
|
|
321 |
}
|
322 |
|
323 |
+
/**
|
324 |
+
* Returns class name of block's HTML container
|
325 |
+
*
|
326 |
+
* @return string
|
327 |
+
*/
|
328 |
+
public function getContainerClass()
|
329 |
+
{
|
330 |
+
return $this->_containerClass;
|
331 |
+
}
|
332 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Debug.php
CHANGED
@@ -1,93 +1,179 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Debug extends Mage_Adminhtml_Block_Template
|
|
|
17 |
|
18 |
-
public function __construct()
|
|
|
19 |
parent::__construct();
|
20 |
$this->setTemplate('creativestyle/amazonpayments/debug.phtml');
|
21 |
}
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
$accordion = $this->getLayout()->createBlock('adminhtml/widget_accordion')->setId('amazonPaymentsDebug');
|
25 |
|
26 |
-
$accordion->addItem(
|
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 |
-
$accordion->addItem(
|
82 |
-
'
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
$this->setChild('debug_data', $accordion);
|
87 |
return parent::_prepareLayout();
|
88 |
}
|
89 |
|
90 |
-
public function getDownloadUrl()
|
|
|
91 |
return $this->getUrl('*/*/download');
|
92 |
}
|
93 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Debug extends Mage_Adminhtml_Block_Template
|
18 |
+
{
|
19 |
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
parent::__construct();
|
23 |
$this->setTemplate('creativestyle/amazonpayments/debug.phtml');
|
24 |
}
|
25 |
|
26 |
+
/**
|
27 |
+
* @return Creativestyle_AmazonPayments_Helper_Data
|
28 |
+
*/
|
29 |
+
protected function _getHelper()
|
30 |
+
{
|
31 |
+
return Mage::helper('amazonpayments');
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function _prepareLayout()
|
35 |
+
{
|
36 |
$accordion = $this->getLayout()->createBlock('adminhtml/widget_accordion')->setId('amazonPaymentsDebug');
|
37 |
|
38 |
+
$accordion->addItem(
|
39 |
+
'general',
|
40 |
+
array(
|
41 |
+
'title' => $this->_getHelper()->__('General Info'),
|
42 |
+
'content' => $this->getLayout()
|
43 |
+
->createBlock('amazonpayments/adminhtml_debug_section')
|
44 |
+
->setDebugArea('general')
|
45 |
+
->toHtml()
|
46 |
+
)
|
47 |
+
);
|
48 |
+
|
49 |
+
$accordion->addItem(
|
50 |
+
'stores',
|
51 |
+
array(
|
52 |
+
'title' => $this->_getHelper()->__('Stores'),
|
53 |
+
'content' => $this->getLayout()
|
54 |
+
->createBlock('amazonpayments/adminhtml_debug_section_table')
|
55 |
+
->setDebugArea('stores')
|
56 |
+
->toHtml()
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
$accordion->addItem(
|
61 |
+
'amazon_account',
|
62 |
+
array(
|
63 |
+
'title' => $this->_getHelper()->__('Amazon Payments Account'),
|
64 |
+
'content' => $this->getLayout()
|
65 |
+
->createBlock('amazonpayments/adminhtml_debug_section_table')
|
66 |
+
->setDebugArea('amazon_account')
|
67 |
+
->toHtml()
|
68 |
+
)
|
69 |
+
);
|
70 |
+
|
71 |
+
$accordion->addItem(
|
72 |
+
'amazon_general',
|
73 |
+
array(
|
74 |
+
'title' => $this->_getHelper()->__('General Settings'),
|
75 |
+
'content' => $this->getLayout()
|
76 |
+
->createBlock('amazonpayments/adminhtml_debug_section_table')
|
77 |
+
->setDebugArea('amazon_general')
|
78 |
+
->toHtml()
|
79 |
+
)
|
80 |
+
);
|
81 |
+
|
82 |
+
$accordion->addItem(
|
83 |
+
'amazon_email',
|
84 |
+
array(
|
85 |
+
'title' => $this->_getHelper()->__('Email Options'),
|
86 |
+
'content' => $this->getLayout()
|
87 |
+
->createBlock('amazonpayments/adminhtml_debug_section_table')
|
88 |
+
->setDebugArea('amazon_email')
|
89 |
+
->toHtml()
|
90 |
+
)
|
91 |
+
);
|
92 |
+
|
93 |
+
$accordion->addItem(
|
94 |
+
'amazon_design',
|
95 |
+
array(
|
96 |
+
'title' => $this->_getHelper()->__('Appearance Settings'),
|
97 |
+
'content' => $this->getLayout()
|
98 |
+
->createBlock('amazonpayments/adminhtml_debug_section_table')
|
99 |
+
->setDebugArea('amazon_design')
|
100 |
+
->toHtml()
|
101 |
+
)
|
102 |
+
);
|
103 |
+
|
104 |
+
$accordion->addItem(
|
105 |
+
'amazon_developer',
|
106 |
+
array(
|
107 |
+
'title' => $this->_getHelper()->__('Developer Options'),
|
108 |
+
'content' => $this->getLayout()
|
109 |
+
->createBlock('amazonpayments/adminhtml_debug_section_table')
|
110 |
+
->setDebugArea('amazon_developer')
|
111 |
+
->toHtml()
|
112 |
+
)
|
113 |
+
);
|
114 |
+
|
115 |
+
$accordion->addItem(
|
116 |
+
'magento_general',
|
117 |
+
array(
|
118 |
+
'title' => $this->_getHelper()->__('Magento Settings'),
|
119 |
+
'content' => $this->getLayout()
|
120 |
+
->createBlock('amazonpayments/adminhtml_debug_section_table')
|
121 |
+
->setDebugArea('magento_general')
|
122 |
+
->toHtml()
|
123 |
+
)
|
124 |
+
);
|
125 |
+
|
126 |
+
$accordion->addItem(
|
127 |
+
'cronjobs',
|
128 |
+
array(
|
129 |
+
'title' => $this->_getHelper()->__('Amazon Cronjobs'),
|
130 |
+
'content' => $this->getLayout()
|
131 |
+
->createBlock('amazonpayments/adminhtml_debug_section_table')
|
132 |
+
->setDebugArea('cronjobs')
|
133 |
+
->setShowKeys(false)
|
134 |
+
->toHtml()
|
135 |
+
)
|
136 |
+
);
|
137 |
+
|
138 |
+
$accordion->addItem(
|
139 |
+
'event_observers',
|
140 |
+
array(
|
141 |
+
'title' => $this->_getHelper()->__('Event Observers'),
|
142 |
+
'content' => $this->getLayout()
|
143 |
+
->createBlock('amazonpayments/adminhtml_debug_section')
|
144 |
+
->setDebugArea('event_observers')
|
145 |
+
->toHtml()
|
146 |
+
)
|
147 |
+
);
|
148 |
+
|
149 |
+
$accordion->addItem(
|
150 |
+
'magento_extensions',
|
151 |
+
array(
|
152 |
+
'title' => $this->_getHelper()->__('Installed Magento extensions'),
|
153 |
+
'content' => $this->getLayout()
|
154 |
+
->createBlock('amazonpayments/adminhtml_debug_section')
|
155 |
+
->setDebugArea('magento_extensions')
|
156 |
+
->toHtml()
|
157 |
+
)
|
158 |
+
);
|
159 |
+
|
160 |
+
$accordion->addItem(
|
161 |
+
'php_modules',
|
162 |
+
array(
|
163 |
+
'title' => $this->_getHelper()->__('Installed PHP modules'),
|
164 |
+
'content' => $this->getLayout()
|
165 |
+
->createBlock('amazonpayments/adminhtml_debug_section')
|
166 |
+
->setDebugArea('php_modules')
|
167 |
+
->toHtml()
|
168 |
+
)
|
169 |
+
);
|
170 |
|
171 |
$this->setChild('debug_data', $accordion);
|
172 |
return parent::_prepareLayout();
|
173 |
}
|
174 |
|
175 |
+
public function getDownloadUrl()
|
176 |
+
{
|
177 |
return $this->getUrl('*/*/download');
|
178 |
}
|
179 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Debug/Section.php
CHANGED
@@ -1,59 +1,74 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Debug_Section extends Mage_Adminhtml_Block_Template
|
17 |
-
|
18 |
protected $_id = null;
|
19 |
|
20 |
protected $_debugArea = 'general';
|
21 |
|
22 |
protected $_showKeys = true;
|
23 |
|
24 |
-
public function __construct()
|
|
|
25 |
parent::__construct();
|
26 |
$this->setTemplate('creativestyle/amazonpayments/debug/section.phtml');
|
27 |
}
|
28 |
|
29 |
-
public function getDebugData()
|
|
|
30 |
return Mage::helper('amazonpayments/debug')->getDebugData($this->_debugArea);
|
31 |
}
|
32 |
|
33 |
-
public function getSectionId()
|
|
|
34 |
if (null === $this->_id) {
|
35 |
$this->_id = 'amazon-payments-debug-section-' . uniqid();
|
36 |
}
|
|
|
37 |
return $this->_id;
|
38 |
}
|
39 |
|
40 |
-
public function setDebugArea($debugArea)
|
|
|
41 |
$this->_debugArea = $debugArea;
|
42 |
return $this;
|
43 |
}
|
44 |
|
45 |
-
public function setShowKeys($showKeys)
|
|
|
46 |
$this->_showKeys = (bool)$showKeys;
|
47 |
return $this;
|
48 |
}
|
49 |
|
50 |
-
public function showKeys()
|
|
|
51 |
return $this->_showKeys;
|
52 |
}
|
53 |
|
54 |
-
public function formatOutput($value)
|
55 |
-
|
56 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
return $value;
|
58 |
}
|
59 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Debug_Section extends Mage_Adminhtml_Block_Template
|
18 |
+
{
|
19 |
protected $_id = null;
|
20 |
|
21 |
protected $_debugArea = 'general';
|
22 |
|
23 |
protected $_showKeys = true;
|
24 |
|
25 |
+
public function __construct()
|
26 |
+
{
|
27 |
parent::__construct();
|
28 |
$this->setTemplate('creativestyle/amazonpayments/debug/section.phtml');
|
29 |
}
|
30 |
|
31 |
+
public function getDebugData()
|
32 |
+
{
|
33 |
return Mage::helper('amazonpayments/debug')->getDebugData($this->_debugArea);
|
34 |
}
|
35 |
|
36 |
+
public function getSectionId()
|
37 |
+
{
|
38 |
if (null === $this->_id) {
|
39 |
$this->_id = 'amazon-payments-debug-section-' . uniqid();
|
40 |
}
|
41 |
+
|
42 |
return $this->_id;
|
43 |
}
|
44 |
|
45 |
+
public function setDebugArea($debugArea)
|
46 |
+
{
|
47 |
$this->_debugArea = $debugArea;
|
48 |
return $this;
|
49 |
}
|
50 |
|
51 |
+
public function setShowKeys($showKeys)
|
52 |
+
{
|
53 |
$this->_showKeys = (bool)$showKeys;
|
54 |
return $this;
|
55 |
}
|
56 |
|
57 |
+
public function showKeys()
|
58 |
+
{
|
59 |
return $this->_showKeys;
|
60 |
}
|
61 |
|
62 |
+
public function formatOutput($value)
|
63 |
+
{
|
64 |
+
if (false === $value) {
|
65 |
+
return 'No';
|
66 |
+
}
|
67 |
+
|
68 |
+
if (true === $value) {
|
69 |
+
return 'Yes';
|
70 |
+
}
|
71 |
+
|
72 |
return $value;
|
73 |
}
|
74 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Debug/Section/Table.php
CHANGED
@@ -1,23 +1,25 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Debug_Section_Table extends
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
parent::__construct();
|
20 |
$this->setTemplate('creativestyle/amazonpayments/debug/section/table.phtml');
|
21 |
}
|
22 |
-
|
23 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Debug_Section_Table extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Debug_Section
|
19 |
+
{
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
parent::__construct();
|
23 |
$this->setTemplate('creativestyle/amazonpayments/debug/section/table.phtml');
|
24 |
}
|
|
|
25 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Info.php
CHANGED
@@ -1,32 +1,45 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Info extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
17 |
-
|
18 |
/**
|
19 |
* Store views collection
|
20 |
*/
|
21 |
protected $_storeCollection = null;
|
22 |
|
23 |
-
protected function _getInfo()
|
|
|
24 |
if (!$this->getChild('amazonpayments_register')) {
|
25 |
-
$this->setChild(
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
|
|
27 |
if (!$this->getChild('seller_central_config')) {
|
28 |
-
$this->setChild(
|
|
|
|
|
|
|
|
|
29 |
}
|
|
|
30 |
$this->setTemplate('creativestyle/amazonpayments/info.phtml');
|
31 |
$output = $this->toHtml();
|
32 |
return $output;
|
@@ -37,48 +50,61 @@ class Creativestyle_AmazonPayments_Block_Adminhtml_Info extends Mage_Adminhtml_B
|
|
37 |
*
|
38 |
* @return Mage_Core_Model_Resource_Store_Collection
|
39 |
*/
|
40 |
-
protected function _getStoreCollection()
|
|
|
41 |
if (null === $this->_storeCollection) {
|
42 |
$this->_storeCollection = Mage::getModel('core/store')->getCollection()->load();
|
43 |
}
|
|
|
44 |
return $this->_storeCollection;
|
45 |
}
|
46 |
|
47 |
-
public function getRegisterHtml()
|
|
|
48 |
if ($this->getChild('amazonpayments_register')) {
|
49 |
return $this->getChild('amazonpayments_register')->toHtml();
|
50 |
}
|
|
|
51 |
return '';
|
52 |
}
|
53 |
|
54 |
-
public function getSellerCentralConfigHtml()
|
|
|
55 |
if ($this->getChild('seller_central_config')) {
|
56 |
return $this->getChild('seller_central_config')->toHtml();
|
57 |
}
|
|
|
58 |
return '';
|
59 |
}
|
60 |
|
61 |
-
public function getExtensionVersion()
|
|
|
62 |
return (string)Mage::getConfig()->getNode('modules/Creativestyle_AmazonPayments/version');
|
63 |
}
|
64 |
|
65 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
|
|
|
|
66 |
return $this->_getInfo();
|
67 |
}
|
68 |
|
69 |
-
public function getUniqueId()
|
|
|
70 |
return 'AIOVPYYF70KB5.' . sha1('Creativestyle Amazon Payments Advanced Magento Extension' . Mage::getBaseUrl());
|
71 |
}
|
72 |
|
73 |
-
public function getValidationUrl()
|
|
|
74 |
return Mage::helper('adminhtml')->getUrl('adminhtml/amazonpayments_system/validate');
|
75 |
}
|
76 |
|
77 |
-
public function getInvalidJsonMsg()
|
|
|
78 |
return Mage::helper('amazonpayments')->__('This is not valid Seller Central configuration JSON');
|
79 |
}
|
80 |
|
81 |
-
public function getIpnUrl($sandbox = false)
|
|
|
82 |
$storeId = Mage::app()->getDefaultStoreView();
|
83 |
$urlParams = array(
|
84 |
'_current' => false,
|
@@ -86,22 +112,28 @@ class Creativestyle_AmazonPayments_Block_Adminhtml_Info extends Mage_Adminhtml_B
|
|
86 |
'_store' => $storeId,
|
87 |
'_forced_secure' => !$sandbox
|
88 |
);
|
89 |
-
$url = Mage::getModel('core/url')->setStore($storeId)->getUrl('amazonpayments/
|
|
|
90 |
$scheme = parse_url($url, PHP_URL_SCHEME);
|
|
|
91 |
if (!$sandbox && $scheme != 'https') {
|
92 |
return null;
|
93 |
}
|
|
|
94 |
return $url;
|
95 |
}
|
96 |
|
97 |
-
public function getJsOrigins()
|
|
|
98 |
$result = array();
|
99 |
foreach ($this->_getStoreCollection() as $store) {
|
100 |
$url = Mage::getModel('core/url')
|
101 |
->setStore($store->getId())
|
102 |
-
->getUrl(
|
103 |
-
'
|
104 |
-
|
|
|
|
|
105 |
$scheme = parse_url($url, PHP_URL_SCHEME);
|
106 |
if ($scheme == 'https') {
|
107 |
$host = parse_url($url, PHP_URL_HOST);
|
@@ -110,34 +142,50 @@ class Creativestyle_AmazonPayments_Block_Adminhtml_Info extends Mage_Adminhtml_B
|
|
110 |
if ($port) {
|
111 |
$origin .= ':' . $port;
|
112 |
}
|
|
|
113 |
$result[] = $origin;
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
$result = array_unique($result);
|
117 |
return Mage::helper('core')->jsonEncode($result);
|
118 |
}
|
119 |
|
120 |
-
public function getReturnUrls()
|
|
|
121 |
$result = array();
|
122 |
foreach ($this->_getStoreCollection() as $store) {
|
123 |
$urlModel = Mage::getModel('core/url');
|
124 |
$urls = array(
|
125 |
-
$urlModel->setStore($store->getId())->getUrl(
|
126 |
-
'
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
);
|
132 |
foreach ($urls as $url) {
|
|
|
133 |
$scheme = parse_url($url, PHP_URL_SCHEME);
|
|
|
134 |
if ($scheme == 'https') {
|
135 |
$result[] = $url;
|
136 |
}
|
137 |
}
|
138 |
}
|
|
|
139 |
$result = array_unique($result);
|
140 |
return Mage::helper('core')->jsonEncode($result);
|
141 |
}
|
142 |
-
|
143 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Info extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
18 |
+
{
|
19 |
/**
|
20 |
* Store views collection
|
21 |
*/
|
22 |
protected $_storeCollection = null;
|
23 |
|
24 |
+
protected function _getInfo()
|
25 |
+
{
|
26 |
if (!$this->getChild('amazonpayments_register')) {
|
27 |
+
$this->setChild(
|
28 |
+
'amazonpayments_register',
|
29 |
+
$this->getLayout()
|
30 |
+
->createBlock('amazonpayments/adminhtml_register')
|
31 |
+
->setHtmlId('simple-path-registration')
|
32 |
+
);
|
33 |
}
|
34 |
+
|
35 |
if (!$this->getChild('seller_central_config')) {
|
36 |
+
$this->setChild(
|
37 |
+
'seller_central_config',
|
38 |
+
$this->getLayout()->createBlock('amazonpayments/adminhtml_sellerCentral')
|
39 |
+
->setHtmlId('simple-path-seller-central')
|
40 |
+
);
|
41 |
}
|
42 |
+
|
43 |
$this->setTemplate('creativestyle/amazonpayments/info.phtml');
|
44 |
$output = $this->toHtml();
|
45 |
return $output;
|
50 |
*
|
51 |
* @return Mage_Core_Model_Resource_Store_Collection
|
52 |
*/
|
53 |
+
protected function _getStoreCollection()
|
54 |
+
{
|
55 |
if (null === $this->_storeCollection) {
|
56 |
$this->_storeCollection = Mage::getModel('core/store')->getCollection()->load();
|
57 |
}
|
58 |
+
|
59 |
return $this->_storeCollection;
|
60 |
}
|
61 |
|
62 |
+
public function getRegisterHtml()
|
63 |
+
{
|
64 |
if ($this->getChild('amazonpayments_register')) {
|
65 |
return $this->getChild('amazonpayments_register')->toHtml();
|
66 |
}
|
67 |
+
|
68 |
return '';
|
69 |
}
|
70 |
|
71 |
+
public function getSellerCentralConfigHtml()
|
72 |
+
{
|
73 |
if ($this->getChild('seller_central_config')) {
|
74 |
return $this->getChild('seller_central_config')->toHtml();
|
75 |
}
|
76 |
+
|
77 |
return '';
|
78 |
}
|
79 |
|
80 |
+
public function getExtensionVersion()
|
81 |
+
{
|
82 |
return (string)Mage::getConfig()->getNode('modules/Creativestyle_AmazonPayments/version');
|
83 |
}
|
84 |
|
85 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
86 |
+
{
|
87 |
+
$this->setElement($element);
|
88 |
return $this->_getInfo();
|
89 |
}
|
90 |
|
91 |
+
public function getUniqueId()
|
92 |
+
{
|
93 |
return 'AIOVPYYF70KB5.' . sha1('Creativestyle Amazon Payments Advanced Magento Extension' . Mage::getBaseUrl());
|
94 |
}
|
95 |
|
96 |
+
public function getValidationUrl()
|
97 |
+
{
|
98 |
return Mage::helper('adminhtml')->getUrl('adminhtml/amazonpayments_system/validate');
|
99 |
}
|
100 |
|
101 |
+
public function getInvalidJsonMsg()
|
102 |
+
{
|
103 |
return Mage::helper('amazonpayments')->__('This is not valid Seller Central configuration JSON');
|
104 |
}
|
105 |
|
106 |
+
public function getIpnUrl($sandbox = false)
|
107 |
+
{
|
108 |
$storeId = Mage::app()->getDefaultStoreView();
|
109 |
$urlParams = array(
|
110 |
'_current' => false,
|
112 |
'_store' => $storeId,
|
113 |
'_forced_secure' => !$sandbox
|
114 |
);
|
115 |
+
$url = Mage::getModel('core/url')->setStore($storeId)->getUrl('amazonpayments/ipn/', $urlParams);
|
116 |
+
// @codingStandardsIgnoreStart
|
117 |
$scheme = parse_url($url, PHP_URL_SCHEME);
|
118 |
+
// @codingStandardsIgnoreEnd
|
119 |
if (!$sandbox && $scheme != 'https') {
|
120 |
return null;
|
121 |
}
|
122 |
+
|
123 |
return $url;
|
124 |
}
|
125 |
|
126 |
+
public function getJsOrigins()
|
127 |
+
{
|
128 |
$result = array();
|
129 |
foreach ($this->_getStoreCollection() as $store) {
|
130 |
$url = Mage::getModel('core/url')
|
131 |
->setStore($store->getId())
|
132 |
+
->getUrl(
|
133 |
+
'/',
|
134 |
+
array('_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId())
|
135 |
+
);
|
136 |
+
// @codingStandardsIgnoreStart
|
137 |
$scheme = parse_url($url, PHP_URL_SCHEME);
|
138 |
if ($scheme == 'https') {
|
139 |
$host = parse_url($url, PHP_URL_HOST);
|
142 |
if ($port) {
|
143 |
$origin .= ':' . $port;
|
144 |
}
|
145 |
+
|
146 |
$result[] = $origin;
|
147 |
}
|
148 |
+
// @codingStandardsIgnoreEnd
|
149 |
}
|
150 |
+
|
151 |
$result = array_unique($result);
|
152 |
return Mage::helper('core')->jsonEncode($result);
|
153 |
}
|
154 |
|
155 |
+
public function getReturnUrls()
|
156 |
+
{
|
157 |
$result = array();
|
158 |
foreach ($this->_getStoreCollection() as $store) {
|
159 |
$urlModel = Mage::getModel('core/url');
|
160 |
$urls = array(
|
161 |
+
$urlModel->setStore($store->getId())->getUrl(
|
162 |
+
'amazonpayments/advanced_login/redirect',
|
163 |
+
array(
|
164 |
+
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
165 |
+
)
|
166 |
+
),
|
167 |
+
$urlModel->setStore($store->getId())->getUrl(
|
168 |
+
'amazonpayments/advanced_login/redirect',
|
169 |
+
array(
|
170 |
+
'target' => 'checkout',
|
171 |
+
'_current' => false,
|
172 |
+
'_secure' => true,
|
173 |
+
'_nosid' => true,
|
174 |
+
'_store' => $store->getId()
|
175 |
+
)
|
176 |
+
)
|
177 |
);
|
178 |
foreach ($urls as $url) {
|
179 |
+
// @codingStandardsIgnoreStart
|
180 |
$scheme = parse_url($url, PHP_URL_SCHEME);
|
181 |
+
// @codingStandardsIgnoreEnd
|
182 |
if ($scheme == 'https') {
|
183 |
$result[] = $url;
|
184 |
}
|
185 |
}
|
186 |
}
|
187 |
+
|
188 |
$result = array_unique($result);
|
189 |
return Mage::helper('core')->jsonEncode($result);
|
190 |
}
|
|
|
191 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Abstract.php
CHANGED
@@ -1,59 +1,96 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
abstract class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Abstract extends
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
parent::__construct();
|
22 |
$this->_blockGroup = 'amazonpayments';
|
|
|
|
|
23 |
$this->_removeButton('add');
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
$this->
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
return parent::_prepareLayout();
|
45 |
}
|
46 |
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
return $this->__('Download as CSV');
|
49 |
}
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
return $this->getUrl('*/*/download');
|
53 |
}
|
54 |
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
return 'head-amazonpayments-log ' . parent::getHeaderCssClass();
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Abstract extends
|
18 |
+
Mage_Adminhtml_Block_Widget_Grid_Container
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* @inheritdoc
|
22 |
+
*/
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
parent::__construct();
|
26 |
$this->_blockGroup = 'amazonpayments';
|
27 |
+
$this->_controller = 'adminhtml_log_' . $this->getLogType();
|
28 |
+
$this->_headerText = $this->__($this->getTitle());
|
29 |
$this->_removeButton('add');
|
30 |
}
|
31 |
|
32 |
+
/**
|
33 |
+
* @inheritdoc
|
34 |
+
*/
|
35 |
+
protected function _prepareLayout()
|
36 |
+
{
|
37 |
+
$logFilePath = Creativestyle_AmazonPayments_Model_Logger::getAbsoluteLogFilePath($this->getLogType());
|
38 |
+
$this->_addButton(
|
39 |
+
'download',
|
40 |
+
array(
|
41 |
+
'label' => $this->_getDownloadButtonLabel(),
|
42 |
+
'onclick' => 'setLocation(\'' . $this->_getDownloadUrl() .'\')',
|
43 |
+
'class' => 'scalable',
|
44 |
+
// @codingStandardsIgnoreStart
|
45 |
+
'disabled' => !file_exists($logFilePath)
|
46 |
+
// @codingStandardsIgnoreEnd
|
47 |
+
),
|
48 |
+
-1
|
49 |
+
);
|
50 |
return parent::_prepareLayout();
|
51 |
}
|
52 |
|
53 |
+
/**
|
54 |
+
* Returns log CSV download button label
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
protected function _getDownloadButtonLabel()
|
59 |
+
{
|
60 |
return $this->__('Download as CSV');
|
61 |
}
|
62 |
|
63 |
+
/**
|
64 |
+
* Returns log CSV download URL
|
65 |
+
*
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
protected function _getDownloadUrl()
|
69 |
+
{
|
70 |
return $this->getUrl('*/*/download');
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
+
* Returns CSS header class
|
75 |
+
*
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
public function getHeaderCssClass()
|
79 |
+
{
|
80 |
return 'head-amazonpayments-log ' . parent::getHeaderCssClass();
|
81 |
}
|
82 |
|
83 |
+
/**
|
84 |
+
* Returns the type of handled log
|
85 |
+
*
|
86 |
+
* @return string
|
87 |
+
*/
|
88 |
+
abstract public function getLogType();
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Returns page title for the log listing page
|
92 |
+
*
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
abstract public function getTitle();
|
96 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Api.php
CHANGED
@@ -1,26 +1,38 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Api extends
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
}
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Api extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Log_Abstract
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'api';
|
21 |
+
const LOG_TITLE = 'Amazon Pay API Calls';
|
22 |
|
23 |
+
/**
|
24 |
+
* @inheritdoc
|
25 |
+
*/
|
26 |
+
public function getLogType()
|
27 |
+
{
|
28 |
+
return self::LOG_TYPE;
|
29 |
}
|
30 |
|
31 |
+
/**
|
32 |
+
* @inheritdoc
|
33 |
+
*/
|
34 |
+
public function getTitle()
|
35 |
+
{
|
36 |
+
return self::LOG_TITLE;
|
37 |
+
}
|
38 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Api/Grid.php
CHANGED
@@ -1,65 +1,82 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Api_Grid extends
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$this->
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
$this->addColumn(
|
30 |
-
'
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
)
|
38 |
|
39 |
-
$this->addColumn(
|
40 |
-
'
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
'sortable' => false
|
51 |
-
));
|
52 |
-
|
53 |
-
$this->addColumn('response_code', array(
|
54 |
-
'header' => Mage::helper('amazonpayments')->__('Response code'),
|
55 |
-
'index' => 'response_code',
|
56 |
-
'align' => 'center',
|
57 |
-
'width' => '50px',
|
58 |
-
'filter' => false,
|
59 |
-
'sortable' => false
|
60 |
-
));
|
61 |
|
62 |
return parent::_prepareColumns();
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Api_Grid extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Log_Grid_Abstract
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'api';
|
21 |
|
22 |
+
/**
|
23 |
+
* @inheritdoc
|
24 |
+
*/
|
25 |
+
protected function _prepareColumns()
|
26 |
+
{
|
27 |
+
$this->addColumn(
|
28 |
+
'timestamp',
|
29 |
+
array(
|
30 |
+
'header' => $this->__('Date'),
|
31 |
+
'index' => 'timestamp',
|
32 |
+
'type' => 'datetime',
|
33 |
+
'width' => '150px',
|
34 |
+
'renderer' => 'Creativestyle_AmazonPayments_Block_Adminhtml_Renderer_Timestamp',
|
35 |
+
'filter' => false,
|
36 |
+
'sortable' => false
|
37 |
+
)
|
38 |
+
);
|
39 |
|
40 |
+
$this->addColumn(
|
41 |
+
'call_action',
|
42 |
+
array(
|
43 |
+
'header' => $this->__('Action'),
|
44 |
+
'index' => 'call_action',
|
45 |
+
'filter' => false,
|
46 |
+
'sortable' => false
|
47 |
+
)
|
48 |
+
);
|
49 |
|
50 |
+
$this->addColumn(
|
51 |
+
'call_url',
|
52 |
+
array(
|
53 |
+
'header' => $this->__('URL'),
|
54 |
+
'index' => 'call_url',
|
55 |
+
'filter' => false,
|
56 |
+
'sortable' => false
|
57 |
+
)
|
58 |
+
);
|
59 |
|
60 |
+
$this->addColumn(
|
61 |
+
'response_code',
|
62 |
+
array(
|
63 |
+
'header' => $this->__('Response code'),
|
64 |
+
'index' => 'response_code',
|
65 |
+
'align' => 'center',
|
66 |
+
'width' => '50px',
|
67 |
+
'filter' => false,
|
68 |
+
'sortable' => false
|
69 |
+
)
|
70 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
return parent::_prepareColumns();
|
73 |
}
|
74 |
|
75 |
+
/**
|
76 |
+
* @inheritdoc
|
77 |
+
*/
|
78 |
+
public function getLogType()
|
79 |
+
{
|
80 |
+
return self::LOG_TYPE;
|
81 |
+
}
|
82 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Api/View.php
CHANGED
@@ -1,53 +1,83 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Api_View extends
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
23 |
}
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
$queryStr = $this->_getLog()->getQuery();
|
28 |
$queryArray = array();
|
|
|
29 |
parse_str($queryStr, $queryArray);
|
|
|
30 |
if (!empty($queryArray)) {
|
31 |
$output = '';
|
32 |
foreach ($queryArray as $key => $value) {
|
33 |
$output .= $key .': ' . $value . "\n";
|
34 |
}
|
|
|
35 |
return $output;
|
36 |
}
|
|
|
37 |
return $queryStr;
|
38 |
}
|
39 |
-
return null;
|
40 |
-
}
|
41 |
|
42 |
-
|
43 |
-
parent::setLog($model);
|
44 |
-
if (is_object($model) && $model->getId()) {
|
45 |
-
$this->_headerText = $this->__('%s API Call | %s',
|
46 |
-
$model->getCallAction(),
|
47 |
-
$this->getTimestamp()
|
48 |
-
);
|
49 |
-
}
|
50 |
-
return $this;
|
51 |
}
|
52 |
-
|
53 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Api_View extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Log_View_Abstract
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'api';
|
21 |
+
const LOG_TITLE = 'Amazon Pay API Call';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
protected $_headerTextPattern = '%s API Call | %s';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @inheritdoc
|
30 |
+
*/
|
31 |
+
protected function _generateHeaderText()
|
32 |
+
{
|
33 |
+
if ($this->_getLog() && $this->_getLog()->getId()) {
|
34 |
+
return $this->__($this->_headerTextPattern, $this->_getLog()->getCallAction(), $this->getTimestamp());
|
35 |
+
}
|
36 |
+
|
37 |
+
return parent::_generateHeaderText();
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @inheritdoc
|
42 |
+
*/
|
43 |
+
public function getLogType()
|
44 |
+
{
|
45 |
+
return self::LOG_TYPE;
|
46 |
+
}
|
47 |
|
48 |
+
/**
|
49 |
+
* @inheritdoc
|
50 |
+
*/
|
51 |
+
public function getTitle()
|
52 |
+
{
|
53 |
+
return self::LOG_TITLE;
|
54 |
}
|
55 |
|
56 |
+
/**
|
57 |
+
* Returns API query string
|
58 |
+
*
|
59 |
+
* @return null|string
|
60 |
+
*/
|
61 |
+
public function getQuery()
|
62 |
+
{
|
63 |
+
if ($this->_getLog()) {
|
64 |
$queryStr = $this->_getLog()->getQuery();
|
65 |
$queryArray = array();
|
66 |
+
// @codingStandardsIgnoreStart
|
67 |
parse_str($queryStr, $queryArray);
|
68 |
+
// @codingStandardsIgnoreEnd
|
69 |
if (!empty($queryArray)) {
|
70 |
$output = '';
|
71 |
foreach ($queryArray as $key => $value) {
|
72 |
$output .= $key .': ' . $value . "\n";
|
73 |
}
|
74 |
+
|
75 |
return $output;
|
76 |
}
|
77 |
+
|
78 |
return $queryStr;
|
79 |
}
|
|
|
|
|
80 |
|
81 |
+
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
|
|
83 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Exception.php
CHANGED
@@ -1,26 +1,38 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Exception extends
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
}
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Exception extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Log_Abstract
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'exception';
|
21 |
+
const LOG_TITLE = 'Amazon Pay Exceptions';
|
22 |
|
23 |
+
/**
|
24 |
+
* @inheritdoc
|
25 |
+
*/
|
26 |
+
public function getLogType()
|
27 |
+
{
|
28 |
+
return self::LOG_TYPE;
|
29 |
}
|
30 |
|
31 |
+
/**
|
32 |
+
* @inheritdoc
|
33 |
+
*/
|
34 |
+
public function getTitle()
|
35 |
+
{
|
36 |
+
return self::LOG_TITLE;
|
37 |
+
}
|
38 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Exception/Grid.php
CHANGED
@@ -1,58 +1,72 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Exception_Grid extends
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$this->
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
$this->addColumn(
|
30 |
-
'
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
'header' => Mage::helper('amazonpayments')->__('Exception message'),
|
41 |
-
'index' => 'exception_message',
|
42 |
-
'filter' => false,
|
43 |
-
'sortable' => false
|
44 |
-
));
|
45 |
-
|
46 |
-
$this->addColumn('exception_code', array(
|
47 |
-
'header' => Mage::helper('amazonpayments')->__('Exception code'),
|
48 |
-
'index' => 'exception_code',
|
49 |
-
'align' => 'center',
|
50 |
-
'width' => '50px',
|
51 |
-
'filter' => false,
|
52 |
-
'sortable' => false
|
53 |
-
));
|
54 |
|
55 |
return parent::_prepareColumns();
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Exception_Grid extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Log_Grid_Abstract
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'exception';
|
21 |
|
22 |
+
/**
|
23 |
+
* @inheritdoc
|
24 |
+
*/
|
25 |
+
protected function _prepareColumns()
|
26 |
+
{
|
27 |
+
$this->addColumn(
|
28 |
+
'timestamp',
|
29 |
+
array(
|
30 |
+
'header' => $this->__('Date'),
|
31 |
+
'index' => 'timestamp',
|
32 |
+
'type' => 'datetime',
|
33 |
+
'width' => '150px',
|
34 |
+
'renderer' => 'Creativestyle_AmazonPayments_Block_Adminhtml_Renderer_Timestamp',
|
35 |
+
'filter' => false,
|
36 |
+
'sortable' => false
|
37 |
+
)
|
38 |
+
);
|
39 |
|
40 |
+
$this->addColumn(
|
41 |
+
'exception_message',
|
42 |
+
array(
|
43 |
+
'header' => $this->__('Exception message'),
|
44 |
+
'index' => 'exception_message',
|
45 |
+
'filter' => false,
|
46 |
+
'sortable' => false
|
47 |
+
)
|
48 |
+
);
|
49 |
|
50 |
+
$this->addColumn(
|
51 |
+
'exception_code',
|
52 |
+
array(
|
53 |
+
'header' => $this->__('Exception code'),
|
54 |
+
'index' => 'exception_code',
|
55 |
+
'align' => 'center',
|
56 |
+
'width' => '50px',
|
57 |
+
'filter' => false,
|
58 |
+
'sortable' => false
|
59 |
+
)
|
60 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
return parent::_prepareColumns();
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
+
* @inheritdoc
|
67 |
+
*/
|
68 |
+
public function getLogType()
|
69 |
+
{
|
70 |
+
return self::LOG_TYPE;
|
71 |
+
}
|
72 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Exception/View.php
CHANGED
@@ -1,35 +1,55 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Exception_View extends
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
$this->setTemplate('creativestyle/amazonpayments/advanced/log/exception/view.phtml');
|
23 |
-
}
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
}
|
32 |
-
|
|
|
33 |
}
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Exception_View extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Log_View_Abstract
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'exception';
|
21 |
+
const LOG_TITLE = 'Amazon Pay Exception';
|
22 |
|
23 |
+
/**
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
protected $_headerTextPattern = 'Amazon Pay Exception | %s';
|
|
|
|
|
27 |
|
28 |
+
/**
|
29 |
+
* @inheritdoc
|
30 |
+
*/
|
31 |
+
protected function _generateHeaderText()
|
32 |
+
{
|
33 |
+
if ($this->_getLog() && $this->_getLog()->getId()) {
|
34 |
+
return $this->__($this->_headerTextPattern, $this->getTimestamp());
|
35 |
}
|
36 |
+
|
37 |
+
return parent::_generateHeaderText();
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
+
* @inheritdoc
|
42 |
+
*/
|
43 |
+
public function getLogType()
|
44 |
+
{
|
45 |
+
return self::LOG_TYPE;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @inheritdoc
|
50 |
+
*/
|
51 |
+
public function getTitle()
|
52 |
+
{
|
53 |
+
return self::LOG_TITLE;
|
54 |
+
}
|
55 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Grid/Abstract.php
CHANGED
@@ -1,51 +1,98 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Grid_Abstract extends Mage_Adminhtml_Block_Widget_Grid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
23 |
return parent::_prepareCollection();
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
)
|
39 |
-
)
|
40 |
-
|
41 |
-
'sortable' => false,
|
42 |
-
'is_system' => true
|
43 |
-
));
|
44 |
return parent::_prepareColumns();
|
45 |
}
|
46 |
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
return $this->getUrl('*/*/view', array('id' => $row->getId()));
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Grid_Abstract extends Mage_Adminhtml_Block_Widget_Grid
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @inheritdoc
|
21 |
+
*/
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
parent::__construct();
|
25 |
+
$this->setId('amazonpayments_log_' . $this->getLogType() . '_grid');
|
26 |
+
$this->setFilterVisibility(false);
|
27 |
+
$this->setSaveParametersInSession(true);
|
28 |
+
}
|
29 |
|
30 |
+
/**
|
31 |
+
* Returns collection of the logs of the given type
|
32 |
+
*
|
33 |
+
* @return Creativestyle_AmazonPayments_Model_Log_Collection
|
34 |
+
*/
|
35 |
+
protected function _getLogCollection()
|
36 |
+
{
|
37 |
+
/** @var Creativestyle_AmazonPayments_Model_Log_Collection $collection */
|
38 |
+
$collection = Mage::getModel('amazonpayments/log_collection');
|
39 |
+
return $collection->setLogType($this->getLogType());
|
40 |
+
}
|
41 |
|
42 |
+
/**
|
43 |
+
* @inheritdoc
|
44 |
+
*/
|
45 |
+
protected function _prepareCollection()
|
46 |
+
{
|
47 |
+
$this->setCollection($this->_getLogCollection());
|
48 |
return parent::_prepareCollection();
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
+
* Prepares columns for the log grid
|
53 |
+
*
|
54 |
+
* @return $this
|
55 |
+
*/
|
56 |
+
protected function _prepareColumns()
|
57 |
+
{
|
58 |
+
$this->addColumn(
|
59 |
+
'preview_action',
|
60 |
+
array(
|
61 |
+
'header' => $this->__('Preview'),
|
62 |
+
'type' => 'action',
|
63 |
+
'align' => 'center',
|
64 |
+
'width' => '50px',
|
65 |
+
'getter' => 'getId',
|
66 |
+
'filter' => false,
|
67 |
+
'sortable' => false,
|
68 |
+
'is_system' => true,
|
69 |
+
'actions' => array(
|
70 |
+
array(
|
71 |
+
'caption' => $this->__('Preview'),
|
72 |
+
'url' => array('base' => '*/*/view'),
|
73 |
+
'field' => 'id'
|
74 |
+
)
|
75 |
)
|
76 |
+
)
|
77 |
+
);
|
|
|
|
|
|
|
78 |
return parent::_prepareColumns();
|
79 |
}
|
80 |
|
81 |
+
/**
|
82 |
+
* Returns row url for js event handlers
|
83 |
+
*
|
84 |
+
* @param Varien_Object $row
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public function getRowUrl($row)
|
88 |
+
{
|
89 |
return $this->getUrl('*/*/view', array('id' => $row->getId()));
|
90 |
}
|
91 |
|
92 |
+
/**
|
93 |
+
* Returns the type of handled log
|
94 |
+
*
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
abstract public function getLogType();
|
98 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Ipn.php
CHANGED
@@ -1,26 +1,38 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Ipn extends
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
}
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Ipn extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Log_Abstract
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'ipn';
|
21 |
+
const LOG_TITLE = 'IPN Notifications';
|
22 |
|
23 |
+
/**
|
24 |
+
* @inheritdoc
|
25 |
+
*/
|
26 |
+
public function getLogType()
|
27 |
+
{
|
28 |
+
return self::LOG_TYPE;
|
29 |
}
|
30 |
|
31 |
+
/**
|
32 |
+
* @inheritdoc
|
33 |
+
*/
|
34 |
+
public function getTitle()
|
35 |
+
{
|
36 |
+
return self::LOG_TITLE;
|
37 |
+
}
|
38 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Ipn/Grid.php
CHANGED
@@ -1,58 +1,84 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Ipn_Grid extends
|
17 |
-
|
18 |
-
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
$this->addColumn(
|
30 |
-
'
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
38 |
|
39 |
-
$this->addColumn(
|
40 |
-
'
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
$this->addColumn(
|
47 |
-
'
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
54 |
|
55 |
return parent::_prepareColumns();
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Ipn_Grid extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Log_Grid_Abstract
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'ipn';
|
21 |
|
22 |
+
/**
|
23 |
+
* @inheritdoc
|
24 |
+
*/
|
25 |
+
protected function _prepareColumns()
|
26 |
+
{
|
27 |
+
$this->addColumn(
|
28 |
+
'timestamp',
|
29 |
+
array(
|
30 |
+
'header' => $this->__('Date'),
|
31 |
+
'index' => 'timestamp',
|
32 |
+
'type' => 'datetime',
|
33 |
+
'width' => '150px',
|
34 |
+
'renderer' => 'Creativestyle_AmazonPayments_Block_Adminhtml_Renderer_Timestamp',
|
35 |
+
'filter' => false,
|
36 |
+
'sortable' => false
|
37 |
+
)
|
38 |
+
);
|
39 |
|
40 |
+
$this->addColumn(
|
41 |
+
'notification_type',
|
42 |
+
array(
|
43 |
+
'header' => $this->__('Notification type'),
|
44 |
+
'index' => 'notification_type',
|
45 |
+
'type' => 'text',
|
46 |
+
'filter' => false,
|
47 |
+
'sortable' => false
|
48 |
+
)
|
49 |
+
);
|
50 |
|
51 |
+
$this->addColumn(
|
52 |
+
'transaction_id',
|
53 |
+
array(
|
54 |
+
'header' => $this->__('Transaction ID'),
|
55 |
+
'index' => 'transaction_id',
|
56 |
+
'type' => 'text',
|
57 |
+
'filter' => false,
|
58 |
+
'sortable' => false
|
59 |
+
)
|
60 |
+
);
|
61 |
|
62 |
+
$this->addColumn(
|
63 |
+
'response_code',
|
64 |
+
array(
|
65 |
+
'header' => $this->__('Response code'),
|
66 |
+
'index' => 'response_code',
|
67 |
+
'align' => 'center',
|
68 |
+
'width' => '80px',
|
69 |
+
'filter' => false,
|
70 |
+
'sortable' => false
|
71 |
+
)
|
72 |
+
);
|
73 |
|
74 |
return parent::_prepareColumns();
|
75 |
}
|
76 |
|
77 |
+
/**
|
78 |
+
* @inheritdoc
|
79 |
+
*/
|
80 |
+
public function getLogType()
|
81 |
+
{
|
82 |
+
return self::LOG_TYPE;
|
83 |
+
}
|
84 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/Ipn/View.php
CHANGED
@@ -1,47 +1,108 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Ipn_View extends
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
23 |
}
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
}
|
|
|
33 |
return null;
|
34 |
}
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
);
|
43 |
}
|
44 |
-
return $this;
|
45 |
-
}
|
46 |
|
|
|
|
|
47 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_Ipn_View extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Adminhtml_Log_View_Abstract
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'ipn';
|
21 |
+
const LOG_TITLE = 'IPN Notification';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
protected $_headerTextPattern = 'IPN %s | %s';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @inheritdoc
|
30 |
+
*/
|
31 |
+
protected function _generateHeaderText()
|
32 |
+
{
|
33 |
+
if ($this->_getLog() && $this->_getLog()->getId()) {
|
34 |
+
return $this->__(
|
35 |
+
$this->_headerTextPattern,
|
36 |
+
$this->_getLog()->getNotificationType()
|
37 |
+
? $this->_getLog()->getNotificationType()
|
38 |
+
: 'UnknownNotification',
|
39 |
+
$this->getTimestamp()
|
40 |
+
);
|
41 |
+
}
|
42 |
+
|
43 |
+
return parent::_generateHeaderText();
|
44 |
+
}
|
45 |
|
46 |
+
/**
|
47 |
+
* @inheritdoc
|
48 |
+
*/
|
49 |
+
public function getLogType()
|
50 |
+
{
|
51 |
+
return self::LOG_TYPE;
|
52 |
}
|
53 |
|
54 |
+
/**
|
55 |
+
* @inheritdoc
|
56 |
+
*/
|
57 |
+
public function getTitle()
|
58 |
+
{
|
59 |
+
return self::LOG_TITLE;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Returns IPN request body
|
64 |
+
*
|
65 |
+
* @return null|string
|
66 |
+
*/
|
67 |
+
public function getRequestBody()
|
68 |
+
{
|
69 |
+
if ($this->_getLog() && $this->_getLog()->getRequestBody()) {
|
70 |
+
try {
|
71 |
+
// @codingStandardsIgnoreStart
|
72 |
+
return Zend_Json::prettyPrint(
|
73 |
+
stripslashes($this->_getLog()->getRequestBody()),
|
74 |
+
array('indent' => ' ')
|
75 |
+
);
|
76 |
+
// @codingStandardsIgnoreEnd
|
77 |
+
} catch (Exception $e) {
|
78 |
+
return null;
|
79 |
}
|
80 |
}
|
81 |
+
|
82 |
return null;
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
+
* Returns admin link to the transaction page
|
87 |
+
*
|
88 |
+
* @return null|string
|
89 |
+
*/
|
90 |
+
public function getTransactionLink()
|
91 |
+
{
|
92 |
+
/** @var Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection $transactionCollection */
|
93 |
+
$transactionCollection = Mage::getModel('sales/order_payment_transaction')
|
94 |
+
->getCollection()
|
95 |
+
->addFieldToFilter('txn_id', $this->_getLog()->getTransactionId())
|
96 |
+
->setPageSize(1)
|
97 |
+
->setCurPage(1);
|
98 |
+
|
99 |
+
foreach ($transactionCollection as $transaction) {
|
100 |
+
return $this->getUrl(
|
101 |
+
'adminhtml/sales_transactions/view',
|
102 |
+
array('txn_id' => $transaction->getId())
|
103 |
);
|
104 |
}
|
|
|
|
|
105 |
|
106 |
+
return null;
|
107 |
+
}
|
108 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Log/View/Abstract.php
CHANGED
@@ -1,34 +1,62 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Log_View_Abstract extends
|
17 |
-
|
|
|
18 |
/**
|
19 |
-
*
|
20 |
*
|
21 |
-
* @var Varien_Object
|
22 |
*/
|
23 |
protected $_model = null;
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
parent::__construct();
|
27 |
-
$this->
|
28 |
-
|
29 |
-
|
30 |
-
'
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
|
34 |
/**
|
@@ -36,43 +64,75 @@ class Creativestyle_AmazonPayments_Block_Adminhtml_Log_View_Abstract extends Mag
|
|
36 |
*
|
37 |
* @return Varien_Object
|
38 |
*/
|
39 |
-
protected function _getLog()
|
|
|
40 |
return $this->_model;
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
-
*
|
45 |
-
*
|
46 |
-
* @param string $name
|
47 |
-
* @return string
|
48 |
*/
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
return
|
58 |
-
|
|
|
59 |
}
|
60 |
}
|
61 |
|
62 |
-
|
|
|
|
|
|
|
|
|
63 |
if (null !== $this->_getLog()) {
|
|
|
64 |
return Mage::app()->getLocale()->date($this->_getLog()->getTimestamp());
|
|
|
65 |
}
|
|
|
66 |
return null;
|
67 |
}
|
68 |
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
$this->_model = $model;
|
71 |
return $this;
|
72 |
}
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
return 'icon-head head-amazonpayments-log ' . parent::getHeaderCssClass();
|
76 |
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Block_Adminhtml_Log_View_Abstract extends
|
18 |
+
Mage_Adminhtml_Block_Widget_Container
|
19 |
+
{
|
20 |
/**
|
21 |
+
* Log model instance
|
22 |
*
|
23 |
+
* @var Varien_Object|null
|
24 |
*/
|
25 |
protected $_model = null;
|
26 |
|
27 |
+
/**
|
28 |
+
* @inheritdoc
|
29 |
+
*/
|
30 |
+
public function __construct()
|
31 |
+
{
|
32 |
parent::__construct();
|
33 |
+
$this->_controller = 'adminhtml_log_' . $this->getLogType();
|
34 |
+
$this->setTemplate('creativestyle/amazonpayments/advanced/log/' . $this->getLogType() . '/view.phtml');
|
35 |
+
$this->_addButton(
|
36 |
+
'back',
|
37 |
+
array(
|
38 |
+
'label' => Mage::helper('adminhtml')->__('Back'),
|
39 |
+
'onclick' => 'window.location.href=\'' . $this->getUrl('*/*/') . '\'',
|
40 |
+
'class' => 'back',
|
41 |
+
)
|
42 |
+
);
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @inheritdoc
|
47 |
+
*/
|
48 |
+
protected function _beforeToHtml()
|
49 |
+
{
|
50 |
+
$this->_headerText = $this->_generateHeaderText();
|
51 |
+
return parent::_beforeToHtml();
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
protected function _generateHeaderText()
|
58 |
+
{
|
59 |
+
return $this->__($this->getTitle());
|
60 |
}
|
61 |
|
62 |
/**
|
64 |
*
|
65 |
* @return Varien_Object
|
66 |
*/
|
67 |
+
protected function _getLog()
|
68 |
+
{
|
69 |
return $this->_model;
|
70 |
}
|
71 |
|
72 |
/**
|
73 |
+
* @inheritdoc
|
|
|
|
|
|
|
74 |
*/
|
75 |
+
public function __call($method, $args)
|
76 |
+
{
|
77 |
+
switch (substr($method, 0, 3)) {
|
78 |
+
case 'get':
|
79 |
+
$key = $this->_underscore(substr($method, 3));
|
80 |
+
if ($this->_getLog() && $this->_getLog()->hasData($key)) {
|
81 |
+
return $this->_getLog()->getData($key);
|
82 |
+
}
|
83 |
+
return parent::__call($method, $args);
|
84 |
+
default:
|
85 |
+
return parent::__call($method, $args);
|
86 |
}
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
+
* @return null|Zend_Date
|
91 |
+
*/
|
92 |
+
public function getTimestamp()
|
93 |
+
{
|
94 |
if (null !== $this->_getLog()) {
|
95 |
+
// @codingStandardsIgnoreStart
|
96 |
return Mage::app()->getLocale()->date($this->_getLog()->getTimestamp());
|
97 |
+
// @codingStandardsIgnoreEnd
|
98 |
}
|
99 |
+
|
100 |
return null;
|
101 |
}
|
102 |
|
103 |
+
/**
|
104 |
+
* Sets log model for the view block
|
105 |
+
*
|
106 |
+
* @param Varien_Object $model
|
107 |
+
* @return $this
|
108 |
+
*/
|
109 |
+
public function setLog($model)
|
110 |
+
{
|
111 |
$this->_model = $model;
|
112 |
return $this;
|
113 |
}
|
114 |
|
115 |
+
/**
|
116 |
+
* Returns CSS header class
|
117 |
+
*
|
118 |
+
* @return string
|
119 |
+
*/
|
120 |
+
public function getHeaderCssClass()
|
121 |
+
{
|
122 |
return 'icon-head head-amazonpayments-log ' . parent::getHeaderCssClass();
|
123 |
}
|
124 |
|
125 |
+
/**
|
126 |
+
* Returns the type of handled log
|
127 |
+
*
|
128 |
+
* @return string
|
129 |
+
*/
|
130 |
+
abstract public function getLogType();
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Returns page title for the log listing page
|
134 |
+
*
|
135 |
+
* @return string
|
136 |
+
*/
|
137 |
+
abstract public function getTitle();
|
138 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Notifications.php
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template
|
17 |
-
|
18 |
/**
|
19 |
* Store views collection
|
20 |
*/
|
@@ -25,27 +26,36 @@ class Creativestyle_AmazonPayments_Block_Adminhtml_Notifications extends Mage_Ad
|
|
25 |
*
|
26 |
* @return Mage_Core_Model_Resource_Store_Collection
|
27 |
*/
|
28 |
-
protected function _getStoreCollection()
|
|
|
29 |
if (null === $this->_storeCollection) {
|
30 |
$this->_storeCollection = Mage::getModel('core/store')->getCollection()->load();
|
31 |
}
|
|
|
32 |
return $this->_storeCollection;
|
33 |
}
|
34 |
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
return Mage::getSingleton('amazonpayments/config');
|
37 |
}
|
38 |
|
39 |
-
public function isLegacyAccount()
|
|
|
40 |
foreach ($this->_getStoreCollection() as $store) {
|
41 |
-
$active = $this->_getConfig()->
|
42 |
$merchantId = $this->_getConfig()->getMerchantId($store);
|
43 |
$clientId = $this->_getConfig()->getClientId($store);
|
44 |
if ($active && $merchantId && !$clientId) {
|
45 |
return true;
|
46 |
}
|
47 |
}
|
|
|
48 |
return false;
|
49 |
}
|
50 |
-
|
51 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2016 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2016 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template
|
18 |
+
{
|
19 |
/**
|
20 |
* Store views collection
|
21 |
*/
|
26 |
*
|
27 |
* @return Mage_Core_Model_Resource_Store_Collection
|
28 |
*/
|
29 |
+
protected function _getStoreCollection()
|
30 |
+
{
|
31 |
if (null === $this->_storeCollection) {
|
32 |
$this->_storeCollection = Mage::getModel('core/store')->getCollection()->load();
|
33 |
}
|
34 |
+
|
35 |
return $this->_storeCollection;
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
+
* Returns Amazon Pay config model instance
|
40 |
+
*
|
41 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
42 |
+
*/
|
43 |
+
protected function _getConfig()
|
44 |
+
{
|
45 |
return Mage::getSingleton('amazonpayments/config');
|
46 |
}
|
47 |
|
48 |
+
public function isLegacyAccount()
|
49 |
+
{
|
50 |
foreach ($this->_getStoreCollection() as $store) {
|
51 |
+
$active = $this->_getConfig()->isPayActive($store);
|
52 |
$merchantId = $this->_getConfig()->getMerchantId($store);
|
53 |
$clientId = $this->_getConfig()->getClientId($store);
|
54 |
if ($active && $merchantId && !$clientId) {
|
55 |
return true;
|
56 |
}
|
57 |
}
|
58 |
+
|
59 |
return false;
|
60 |
}
|
|
|
61 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Register.php
CHANGED
@@ -1,55 +1,65 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Register extends Mage_Adminhtml_Block_Template
|
17 |
-
|
18 |
-
protected function _construct()
|
|
|
19 |
$this->setTemplate('creativestyle/amazonpayments/register.phtml');
|
20 |
return parent::_construct();
|
21 |
}
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
return Mage::getSingleton('amazonpayments/config');
|
25 |
}
|
26 |
|
27 |
-
public function getAccountRegionOptions()
|
|
|
28 |
return Mage::getSingleton('amazonpayments/lookup_accountRegion')->toOptionArray();
|
29 |
}
|
30 |
|
31 |
-
public function getLanguageOptions()
|
|
|
32 |
return Mage::getSingleton('amazonpayments/lookup_language')->toOptionArray();
|
33 |
}
|
34 |
|
35 |
-
public function getDefaultAccountRegion()
|
|
|
36 |
return Mage::getStoreConfig('currency/options/base');
|
37 |
-
switch (Mage::getStoreConfig('currency/options/base')) {
|
38 |
-
case 'GBP':
|
39 |
-
return 'GBP';
|
40 |
-
default:
|
41 |
-
return 'EUR';
|
42 |
-
}
|
43 |
}
|
44 |
|
45 |
-
public function getDefaultLanguage()
|
46 |
-
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
-
public function getState()
|
|
|
50 |
if ($this->_getConfig()->getMerchantId()) {
|
51 |
return 0;
|
52 |
}
|
|
|
53 |
return 1;
|
54 |
}
|
55 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Register extends Mage_Adminhtml_Block_Template
|
18 |
+
{
|
19 |
+
protected function _construct()
|
20 |
+
{
|
21 |
$this->setTemplate('creativestyle/amazonpayments/register.phtml');
|
22 |
return parent::_construct();
|
23 |
}
|
24 |
|
25 |
+
/**
|
26 |
+
* Returns Amazon Pay config model instance
|
27 |
+
*
|
28 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
29 |
+
*/
|
30 |
+
protected function _getConfig()
|
31 |
+
{
|
32 |
return Mage::getSingleton('amazonpayments/config');
|
33 |
}
|
34 |
|
35 |
+
public function getAccountRegionOptions()
|
36 |
+
{
|
37 |
return Mage::getSingleton('amazonpayments/lookup_accountRegion')->toOptionArray();
|
38 |
}
|
39 |
|
40 |
+
public function getLanguageOptions()
|
41 |
+
{
|
42 |
return Mage::getSingleton('amazonpayments/lookup_language')->toOptionArray();
|
43 |
}
|
44 |
|
45 |
+
public function getDefaultAccountRegion()
|
46 |
+
{
|
47 |
return Mage::getStoreConfig('currency/options/base');
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
|
50 |
+
public function getDefaultLanguage()
|
51 |
+
{
|
52 |
+
/** @var Creativestyle_AmazonPayments_Model_Lookup_Language $languageLookupModel */
|
53 |
+
$languageLookupModel = Mage::getSingleton('amazonpayments/lookup_language');
|
54 |
+
return $languageLookupModel->getLanguageByLocale(Mage::app()->getLocale()->getLocaleCode(), true);
|
55 |
}
|
56 |
|
57 |
+
public function getState()
|
58 |
+
{
|
59 |
if ($this->_getConfig()->getMerchantId()) {
|
60 |
return 0;
|
61 |
}
|
62 |
+
|
63 |
return 1;
|
64 |
}
|
65 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Renderer/Timestamp.php
CHANGED
@@ -1,23 +1,27 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Renderer_Timestamp extends
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
$value = $row->getData($this->getColumn()->getIndex());
|
|
|
20 |
return Mage::getSingleton('core/date')->date('Y-m-d\TH:i:s', $value);
|
|
|
21 |
}
|
22 |
-
|
23 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_Renderer_Timestamp extends
|
18 |
+
Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
19 |
+
{
|
20 |
+
public function render(Varien_Object $row)
|
21 |
+
{
|
22 |
$value = $row->getData($this->getColumn()->getIndex());
|
23 |
+
// @codingStandardsIgnoreStart
|
24 |
return Mage::getSingleton('core/date')->date('Y-m-d\TH:i:s', $value);
|
25 |
+
// @codingStandardsIgnoreEnd
|
26 |
}
|
|
|
27 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/Sales/Order.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_Sales_Order extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
17 |
-
|
18 |
-
public function __construct() {
|
19 |
-
$this->_controller = 'order';
|
20 |
-
$this->_headerText = Mage::helper('sales')->__('Orders');
|
21 |
-
parent::__construct();
|
22 |
-
$this->_removeButton('add');
|
23 |
-
}
|
24 |
-
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Block/Adminhtml/SellerCentral.php
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Adminhtml_SellerCentral extends Mage_Adminhtml_Block_Template
|
17 |
-
|
18 |
protected $_configOptions = null;
|
19 |
|
20 |
protected $_ipnUrls = null;
|
@@ -36,12 +37,14 @@ class Creativestyle_AmazonPayments_Block_Adminhtml_SellerCentral extends Mage_Ad
|
|
36 |
protected $_merchantIds = null;
|
37 |
protected $_clientIds = null;
|
38 |
|
39 |
-
protected function _construct()
|
|
|
40 |
$this->setTemplate('creativestyle/amazonpayments/seller_central.phtml');
|
41 |
return parent::_construct();
|
42 |
}
|
43 |
|
44 |
-
protected function _getConfig()
|
|
|
45 |
return Mage::getSingleton('amazonpayments/config');
|
46 |
}
|
47 |
|
@@ -50,51 +53,63 @@ class Creativestyle_AmazonPayments_Block_Adminhtml_SellerCentral extends Mage_Ad
|
|
50 |
*
|
51 |
* @return Mage_Core_Model_Resource_Store_Collection
|
52 |
*/
|
53 |
-
protected function _getStoreCollection()
|
|
|
54 |
if (null === $this->_storeCollection) {
|
55 |
$this->_storeCollection = Mage::getModel('core/store')->getCollection()->load();
|
56 |
}
|
|
|
57 |
return $this->_storeCollection;
|
58 |
}
|
59 |
|
60 |
-
protected function _getStoreGroup($groupId)
|
|
|
61 |
if (!isset($this->_storeGroups[$groupId])) {
|
62 |
$this->_storeGroups[$groupId] = Mage::getModel('core/store_group')->load($groupId);
|
63 |
}
|
|
|
64 |
return $this->_storeGroups[$groupId];
|
65 |
}
|
66 |
|
67 |
-
protected function _getMerchantId($storeId)
|
|
|
68 |
if (null === $this->_merchantIds) {
|
69 |
$this->_merchantIds = array();
|
70 |
foreach ($this->_getStoreCollection() as $store) {
|
71 |
$this->_merchantIds[$store->getId()] = $this->_getConfig()->getMerchantId($store->getId());
|
72 |
}
|
73 |
}
|
|
|
74 |
if (isset($this->_merchantIds[$storeId])) {
|
75 |
return $this->_merchantIds[$storeId];
|
76 |
}
|
|
|
77 |
return null;
|
78 |
}
|
79 |
|
80 |
-
protected function _getClientId($storeId)
|
|
|
81 |
if (null === $this->_clientIds) {
|
82 |
$this->_clientIds = array();
|
83 |
foreach ($this->_getStoreCollection() as $store) {
|
84 |
$this->_clientIds[$store->getId()] = $this->_getConfig()->getClientId($store->getId());
|
85 |
}
|
86 |
}
|
|
|
87 |
if (isset($this->_clientIds[$storeId])) {
|
88 |
return $this->_clientIds[$storeId];
|
89 |
}
|
|
|
90 |
return null;
|
91 |
}
|
92 |
|
93 |
-
protected function _getDefaultStoreViewId($groupId)
|
|
|
94 |
return $this->_getStoreGroup($groupId)->getDefaultStoreId();
|
95 |
}
|
96 |
|
97 |
-
protected function _getIpnUrls()
|
|
|
98 |
if (null === $this->_ipnUrls) {
|
99 |
$this->_ipnUrls = array();
|
100 |
foreach ($this->_getStoreCollection() as $store) {
|
@@ -102,11 +117,14 @@ class Creativestyle_AmazonPayments_Block_Adminhtml_SellerCentral extends Mage_Ad
|
|
102 |
'_current' => false,
|
103 |
'_nosid' => true,
|
104 |
'_store' => $store->getId(),
|
105 |
-
'_secure' => !$this->_getConfig()->
|
106 |
);
|
107 |
-
$url = Mage::getModel('core/url')
|
|
|
|
|
108 |
$scheme = parse_url($url, PHP_URL_SCHEME);
|
109 |
-
|
|
|
110 |
$merchantId = $this->_getMerchantId($store->getId());
|
111 |
$defaultStoreId = $this->_getDefaultStoreViewId($store->getGroupId());
|
112 |
if (array_search($url, $this->_ipnUrls) != $merchantId || $defaultStoreId == $store->getId()) {
|
@@ -115,10 +133,97 @@ class Creativestyle_AmazonPayments_Block_Adminhtml_SellerCentral extends Mage_Ad
|
|
115 |
}
|
116 |
}
|
117 |
}
|
|
|
118 |
return $this->_ipnUrls;
|
119 |
}
|
120 |
|
121 |
-
protected function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
$placeholder = <<<EOH
|
123 |
<em>I couldn't find any IPN endpoint URL :( Please double check if following conditions set is met in any store view:
|
124 |
<ul>
|
@@ -129,16 +234,16 @@ EOH;
|
|
129 |
|
130 |
$html = '';
|
131 |
$ipnUrls = $this->_getIpnUrls();
|
132 |
-
$ipnUrlsCount = count($ipnUrls);
|
133 |
foreach ($ipnUrls as $merchantId => $ipnUrl) {
|
134 |
-
|
135 |
$html .= '<div class="section-config">';
|
136 |
-
$html .= sprintf(
|
|
|
137 |
$htmlId . '_' . $merchantId,
|
138 |
$htmlId . '_' . $merchantId,
|
139 |
$this->helper('amazonpayments')->__('<span class="close">Click to reveal config for </span>%s', $merchantId)
|
140 |
);
|
141 |
-
$html .= sprintf(
|
|
|
142 |
$htmlId . '_' . $merchantId,
|
143 |
$htmlId . '_' . $merchantId
|
144 |
);
|
@@ -150,41 +255,12 @@ EOH;
|
|
150 |
$html .= 'Fieldset.applyCollapse(\'' . $htmlId . '_' . $merchantId . '\');' . "\n";
|
151 |
$html .= '//]]></script>' . "\n";
|
152 |
}
|
153 |
-
return $html ? $html : $placeholder;
|
154 |
-
}
|
155 |
|
156 |
-
|
157 |
-
if (null === $this->_jsOrigins) {
|
158 |
-
$this->_jsOrigins = array();
|
159 |
-
foreach ($this->_getStoreCollection() as $store) {
|
160 |
-
$secureUrl = Mage::getModel('core/url')
|
161 |
-
->setStore($store->getId())
|
162 |
-
->getUrl('/', array(
|
163 |
-
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
164 |
-
)
|
165 |
-
);
|
166 |
-
$scheme = parse_url($secureUrl, PHP_URL_SCHEME);
|
167 |
-
if ($scheme == 'https') {
|
168 |
-
$host = parse_url($secureUrl, PHP_URL_HOST);
|
169 |
-
$origin = 'https://' . $host;
|
170 |
-
$port = parse_url($secureUrl, PHP_URL_PORT);
|
171 |
-
if ($port) {
|
172 |
-
$origin .= ':' . $port;
|
173 |
-
}
|
174 |
-
$merchantId = $this->_getClientId($store->getId());
|
175 |
-
if (!isset($this->_jsOrigins[$merchantId])) {
|
176 |
-
$this->_jsOrigins[$merchantId] = array();
|
177 |
-
}
|
178 |
-
if (array_search($origin, $this->_jsOrigins[$merchantId]) === false) {
|
179 |
-
$this->_jsOrigins[$merchantId][] = $origin;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
}
|
183 |
-
}
|
184 |
-
return $this->_jsOrigins;
|
185 |
}
|
186 |
|
187 |
-
protected function _getJavascriptOriginsHtml($htmlId)
|
|
|
188 |
$placeholder = <<<EOH
|
189 |
<em>I couldn't find any JS origin URL :( Please double check if following conditions set is met in any store view:
|
190 |
<ul>
|
@@ -195,15 +271,16 @@ EOH;
|
|
195 |
|
196 |
$html = '';
|
197 |
$jsOrigins = $this->_getJavascriptOrigins();
|
198 |
-
$jsOriginsCount = count($jsOrigins);
|
199 |
foreach ($jsOrigins as $merchantId => $origins) {
|
200 |
$html .= '<div class="section-config">';
|
201 |
-
$html .= sprintf(
|
|
|
202 |
$htmlId . '_' . $merchantId,
|
203 |
$htmlId . '_' . $merchantId,
|
204 |
$this->helper('amazonpayments')->__('<span class="close">Click to reveal config for </span>%s', $merchantId)
|
205 |
);
|
206 |
-
$html .= sprintf(
|
|
|
207 |
$htmlId . '_' . $merchantId,
|
208 |
$htmlId . '_' . $merchantId
|
209 |
);
|
@@ -212,6 +289,7 @@ EOH;
|
|
212 |
foreach ($origins as $origin) {
|
213 |
$jsOriginsHtml[] = sprintf('<a class="nobr" href="%s">%s</a>', $origin, $origin);
|
214 |
}
|
|
|
215 |
$html .= implode('<br/>', $jsOriginsHtml);
|
216 |
$html .= '</div>';
|
217 |
$html .= '</div>';
|
@@ -219,46 +297,12 @@ EOH;
|
|
219 |
$html .= 'Fieldset.applyCollapse(\'' . $htmlId . '_' . $merchantId . '\');' . "\n";
|
220 |
$html .= '//]]></script>' . "\n";
|
221 |
}
|
222 |
-
return $html ? $html : $placeholder;
|
223 |
-
}
|
224 |
|
225 |
-
|
226 |
-
if (null === $this->_returnUrls) {
|
227 |
-
$this->_returnUrls = array();
|
228 |
-
foreach ($this->_getStoreCollection() as $store) {
|
229 |
-
$urlModel = Mage::getModel('core/url');
|
230 |
-
$urls = array(
|
231 |
-
$urlModel->setStore($store->getId())->getUrl('amazonpayments/advanced_login/redirect', array(
|
232 |
-
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
233 |
-
)),
|
234 |
-
$urlModel->setStore($store->getId())->getUrl('amazonpayments/advanced_login/redirect', array(
|
235 |
-
'target' => 'checkout', '_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
236 |
-
))
|
237 |
-
);
|
238 |
-
foreach ($urls as $url) {
|
239 |
-
$scheme = parse_url($url, PHP_URL_SCHEME);
|
240 |
-
if ($scheme == 'https') {
|
241 |
-
$host = parse_url($url, PHP_URL_HOST);
|
242 |
-
$origin = 'https://' . $host;
|
243 |
-
$port = parse_url($url, PHP_URL_PORT);
|
244 |
-
if ($port) {
|
245 |
-
$origin .= ':' . $port;
|
246 |
-
}
|
247 |
-
$merchantId = $this->_getClientId($store->getId());
|
248 |
-
if (!isset($this->_returnUrls[$merchantId])) {
|
249 |
-
$this->_returnUrls[$merchantId] = array();
|
250 |
-
}
|
251 |
-
if (array_search($url, $this->_returnUrls[$merchantId]) === false) {
|
252 |
-
$this->_returnUrls[$merchantId][] = $url;
|
253 |
-
}
|
254 |
-
}
|
255 |
-
}
|
256 |
-
}
|
257 |
-
}
|
258 |
-
return $this->_returnUrls;
|
259 |
}
|
260 |
|
261 |
-
protected function _getReturnUrlsHtml($htmlId)
|
|
|
262 |
$placeholder = <<<EOH
|
263 |
<em>I couldn't find any return URL :( Please double check if following conditions set is met in any store view:
|
264 |
<ul>
|
@@ -269,15 +313,16 @@ EOH;
|
|
269 |
|
270 |
$html = '';
|
271 |
$returnUrls = $this->_getReturnUrls();
|
272 |
-
$returnUrlsCount = count($returnUrls);
|
273 |
foreach ($returnUrls as $merchantId => $urls) {
|
274 |
$html .= '<div class="section-config">';
|
275 |
-
$html .= sprintf(
|
|
|
276 |
$htmlId . '_' . $merchantId,
|
277 |
$htmlId . '_' . $merchantId,
|
278 |
$this->helper('amazonpayments')->__('<span class="close">Click to reveal config for </span>%s', $merchantId)
|
279 |
);
|
280 |
-
$html .= sprintf(
|
|
|
281 |
$htmlId . '_' . $merchantId,
|
282 |
$htmlId . '_' . $merchantId
|
283 |
);
|
@@ -286,6 +331,7 @@ EOH;
|
|
286 |
foreach ($urls as $url) {
|
287 |
$returnUrlsHtml[] = sprintf('<a class="nobr" href="%s">%s</a>', $url, $url);
|
288 |
}
|
|
|
289 |
$html .= implode('<br/>', $returnUrlsHtml);
|
290 |
$html .= '</div>';
|
291 |
$html .= '</div>';
|
@@ -293,16 +339,19 @@ EOH;
|
|
293 |
$html .= 'Fieldset.applyCollapse(\'' . $htmlId . '_' . $merchantId . '\');' . "\n";
|
294 |
$html .= '//]]></script>' . "\n";
|
295 |
}
|
|
|
296 |
return $html ? $html : $placeholder;
|
297 |
}
|
298 |
|
299 |
-
public function getSellerCentralConfigOptions()
|
|
|
300 |
if (null === $this->_configOptions) {
|
301 |
$ipnUrls = $this->_getIpnUrlsHtml($this->getHtmlId() . '_ipn_urls');
|
302 |
$javascriptOrigins = $this->_getJavascriptOriginsHtml($this->getHtmlId() . '_allowed_javascript_origins');
|
303 |
$returnUrls = $this->_getReturnUrlsHtml($this->getHtmlId() . '_allowed_return_urls');
|
304 |
$this->_configOptions = array(
|
305 |
-
new Varien_Object(
|
|
|
306 |
'id' => 'ipn_url',
|
307 |
'label' => $this->helper('amazonpayments')->__('IPN endpoint URL'),
|
308 |
'value' => $ipnUrls,
|
@@ -315,8 +364,10 @@ EOH;
|
|
315 |
'amazonpayments_general_active' => 1,
|
316 |
'amazonpayments_general_ipn_active' => 1
|
317 |
)
|
318 |
-
|
319 |
-
|
|
|
|
|
320 |
'id' => 'allowed_javascript_origins',
|
321 |
'label' => $this->helper('amazonpayments')->__('Allowed JavaScript Origins'),
|
322 |
'value' => $javascriptOrigins,
|
@@ -328,8 +379,10 @@ EOH;
|
|
328 |
'depends' => array(
|
329 |
'amazonpayments_login_active' => 1
|
330 |
)
|
331 |
-
|
332 |
-
|
|
|
|
|
333 |
'id' => 'allowed_return_urls',
|
334 |
'label' => $this->helper('amazonpayments')->__('Allowed Return URLs'),
|
335 |
'value' => $returnUrls,
|
@@ -341,21 +394,28 @@ EOH;
|
|
341 |
'depends' => array(
|
342 |
'amazonpayments_login_active' => 1
|
343 |
)
|
344 |
-
|
|
|
345 |
);
|
346 |
}
|
|
|
347 |
return $this->_configOptions;
|
348 |
}
|
|
|
349 |
|
350 |
-
public function getDependencyJs()
|
351 |
-
|
|
|
|
|
|
|
352 |
}
|
353 |
|
354 |
-
public function getState()
|
|
|
355 |
if ($this->_getConfig()->getMerchantId()) {
|
356 |
return 1;
|
357 |
}
|
|
|
358 |
return 0;
|
359 |
}
|
360 |
-
|
361 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2015 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2015 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Adminhtml_SellerCentral extends Mage_Adminhtml_Block_Template
|
18 |
+
{
|
19 |
protected $_configOptions = null;
|
20 |
|
21 |
protected $_ipnUrls = null;
|
37 |
protected $_merchantIds = null;
|
38 |
protected $_clientIds = null;
|
39 |
|
40 |
+
protected function _construct()
|
41 |
+
{
|
42 |
$this->setTemplate('creativestyle/amazonpayments/seller_central.phtml');
|
43 |
return parent::_construct();
|
44 |
}
|
45 |
|
46 |
+
protected function _getConfig()
|
47 |
+
{
|
48 |
return Mage::getSingleton('amazonpayments/config');
|
49 |
}
|
50 |
|
53 |
*
|
54 |
* @return Mage_Core_Model_Resource_Store_Collection
|
55 |
*/
|
56 |
+
protected function _getStoreCollection()
|
57 |
+
{
|
58 |
if (null === $this->_storeCollection) {
|
59 |
$this->_storeCollection = Mage::getModel('core/store')->getCollection()->load();
|
60 |
}
|
61 |
+
|
62 |
return $this->_storeCollection;
|
63 |
}
|
64 |
|
65 |
+
protected function _getStoreGroup($groupId)
|
66 |
+
{
|
67 |
if (!isset($this->_storeGroups[$groupId])) {
|
68 |
$this->_storeGroups[$groupId] = Mage::getModel('core/store_group')->load($groupId);
|
69 |
}
|
70 |
+
|
71 |
return $this->_storeGroups[$groupId];
|
72 |
}
|
73 |
|
74 |
+
protected function _getMerchantId($storeId)
|
75 |
+
{
|
76 |
if (null === $this->_merchantIds) {
|
77 |
$this->_merchantIds = array();
|
78 |
foreach ($this->_getStoreCollection() as $store) {
|
79 |
$this->_merchantIds[$store->getId()] = $this->_getConfig()->getMerchantId($store->getId());
|
80 |
}
|
81 |
}
|
82 |
+
|
83 |
if (isset($this->_merchantIds[$storeId])) {
|
84 |
return $this->_merchantIds[$storeId];
|
85 |
}
|
86 |
+
|
87 |
return null;
|
88 |
}
|
89 |
|
90 |
+
protected function _getClientId($storeId)
|
91 |
+
{
|
92 |
if (null === $this->_clientIds) {
|
93 |
$this->_clientIds = array();
|
94 |
foreach ($this->_getStoreCollection() as $store) {
|
95 |
$this->_clientIds[$store->getId()] = $this->_getConfig()->getClientId($store->getId());
|
96 |
}
|
97 |
}
|
98 |
+
|
99 |
if (isset($this->_clientIds[$storeId])) {
|
100 |
return $this->_clientIds[$storeId];
|
101 |
}
|
102 |
+
|
103 |
return null;
|
104 |
}
|
105 |
|
106 |
+
protected function _getDefaultStoreViewId($groupId)
|
107 |
+
{
|
108 |
return $this->_getStoreGroup($groupId)->getDefaultStoreId();
|
109 |
}
|
110 |
|
111 |
+
protected function _getIpnUrls()
|
112 |
+
{
|
113 |
if (null === $this->_ipnUrls) {
|
114 |
$this->_ipnUrls = array();
|
115 |
foreach ($this->_getStoreCollection() as $store) {
|
117 |
'_current' => false,
|
118 |
'_nosid' => true,
|
119 |
'_store' => $store->getId(),
|
120 |
+
'_secure' => !$this->_getConfig()->isSandboxActive($store->getId())
|
121 |
);
|
122 |
+
$url = Mage::getModel('core/url')
|
123 |
+
->setStore($store->getId())->getUrl('amazonpayments/ipn/', $urlParams);
|
124 |
+
// @codingStandardsIgnoreStart
|
125 |
$scheme = parse_url($url, PHP_URL_SCHEME);
|
126 |
+
// @codingStandardsIgnoreEnd
|
127 |
+
if ($scheme == 'https' || $this->_getConfig()->isSandboxActive($store->getId())) {
|
128 |
$merchantId = $this->_getMerchantId($store->getId());
|
129 |
$defaultStoreId = $this->_getDefaultStoreViewId($store->getGroupId());
|
130 |
if (array_search($url, $this->_ipnUrls) != $merchantId || $defaultStoreId == $store->getId()) {
|
133 |
}
|
134 |
}
|
135 |
}
|
136 |
+
|
137 |
return $this->_ipnUrls;
|
138 |
}
|
139 |
|
140 |
+
protected function _getJavascriptOrigins()
|
141 |
+
{
|
142 |
+
if (null === $this->_jsOrigins) {
|
143 |
+
$this->_jsOrigins = array();
|
144 |
+
foreach ($this->_getStoreCollection() as $store) {
|
145 |
+
$secureUrl = Mage::getModel('core/url')
|
146 |
+
->setStore($store->getId())
|
147 |
+
->getUrl(
|
148 |
+
'/',
|
149 |
+
array(
|
150 |
+
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
151 |
+
)
|
152 |
+
);
|
153 |
+
// @codingStandardsIgnoreStart
|
154 |
+
$scheme = parse_url($secureUrl, PHP_URL_SCHEME);
|
155 |
+
if ($scheme == 'https') {
|
156 |
+
$host = parse_url($secureUrl, PHP_URL_HOST);
|
157 |
+
$origin = 'https://' . $host;
|
158 |
+
$port = parse_url($secureUrl, PHP_URL_PORT);
|
159 |
+
if ($port) {
|
160 |
+
$origin .= ':' . $port;
|
161 |
+
}
|
162 |
+
|
163 |
+
$merchantId = $this->_getClientId($store->getId());
|
164 |
+
if (!isset($this->_jsOrigins[$merchantId])) {
|
165 |
+
$this->_jsOrigins[$merchantId] = array();
|
166 |
+
}
|
167 |
+
|
168 |
+
if (array_search($origin, $this->_jsOrigins[$merchantId]) === false) {
|
169 |
+
$this->_jsOrigins[$merchantId][] = $origin;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
// @codingStandardsIgnoreEnd
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
return $this->_jsOrigins;
|
177 |
+
}
|
178 |
+
|
179 |
+
protected function _getReturnUrls()
|
180 |
+
{
|
181 |
+
if (null === $this->_returnUrls) {
|
182 |
+
$this->_returnUrls = array();
|
183 |
+
foreach ($this->_getStoreCollection() as $store) {
|
184 |
+
$urlModel = Mage::getModel('core/url');
|
185 |
+
$urls = array(
|
186 |
+
$urlModel->setStore($store->getId())->getUrl(
|
187 |
+
'amazonpayments/advanced_login/redirect',
|
188 |
+
array(
|
189 |
+
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
190 |
+
)
|
191 |
+
),
|
192 |
+
$urlModel->setStore($store->getId())->getUrl(
|
193 |
+
'amazonpayments/advanced_login/redirect',
|
194 |
+
array(
|
195 |
+
'target' => 'checkout',
|
196 |
+
'_current' => false,
|
197 |
+
'_secure' => true,
|
198 |
+
'_nosid' => true,
|
199 |
+
'_store' => $store->getId()
|
200 |
+
)
|
201 |
+
)
|
202 |
+
);
|
203 |
+
foreach ($urls as $url) {
|
204 |
+
// @codingStandardsIgnoreStart
|
205 |
+
$scheme = parse_url($url, PHP_URL_SCHEME);
|
206 |
+
// @codingStandardsIgnoreEnd
|
207 |
+
if ($scheme == 'https') {
|
208 |
+
$merchantId = $this->_getClientId($store->getId());
|
209 |
+
if (!isset($this->_returnUrls[$merchantId])) {
|
210 |
+
$this->_returnUrls[$merchantId] = array();
|
211 |
+
}
|
212 |
+
|
213 |
+
if (array_search($url, $this->_returnUrls[$merchantId]) === false) {
|
214 |
+
$this->_returnUrls[$merchantId][] = $url;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
return $this->_returnUrls;
|
222 |
+
}
|
223 |
+
|
224 |
+
// @codingStandardsIgnoreStart
|
225 |
+
protected function _getIpnUrlsHtml($htmlId)
|
226 |
+
{
|
227 |
$placeholder = <<<EOH
|
228 |
<em>I couldn't find any IPN endpoint URL :( Please double check if following conditions set is met in any store view:
|
229 |
<ul>
|
234 |
|
235 |
$html = '';
|
236 |
$ipnUrls = $this->_getIpnUrls();
|
|
|
237 |
foreach ($ipnUrls as $merchantId => $ipnUrl) {
|
|
|
238 |
$html .= '<div class="section-config">';
|
239 |
+
$html .= sprintf(
|
240 |
+
'<div class="entry-edit-head collapseable"><a id="%s-head" href="#" onclick="Fieldset.toggleCollapse(\'%s\'); return false;">%s</a></div>',
|
241 |
$htmlId . '_' . $merchantId,
|
242 |
$htmlId . '_' . $merchantId,
|
243 |
$this->helper('amazonpayments')->__('<span class="close">Click to reveal config for </span>%s', $merchantId)
|
244 |
);
|
245 |
+
$html .= sprintf(
|
246 |
+
'<input id="%s-state" name="config_state[%s]" type="hidden" value="1">',
|
247 |
$htmlId . '_' . $merchantId,
|
248 |
$htmlId . '_' . $merchantId
|
249 |
);
|
255 |
$html .= 'Fieldset.applyCollapse(\'' . $htmlId . '_' . $merchantId . '\');' . "\n";
|
256 |
$html .= '//]]></script>' . "\n";
|
257 |
}
|
|
|
|
|
258 |
|
259 |
+
return $html ? $html : $placeholder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
}
|
261 |
|
262 |
+
protected function _getJavascriptOriginsHtml($htmlId)
|
263 |
+
{
|
264 |
$placeholder = <<<EOH
|
265 |
<em>I couldn't find any JS origin URL :( Please double check if following conditions set is met in any store view:
|
266 |
<ul>
|
271 |
|
272 |
$html = '';
|
273 |
$jsOrigins = $this->_getJavascriptOrigins();
|
|
|
274 |
foreach ($jsOrigins as $merchantId => $origins) {
|
275 |
$html .= '<div class="section-config">';
|
276 |
+
$html .= sprintf(
|
277 |
+
'<div class="entry-edit-head collapseable"><a id="%s-head" href="#" onclick="Fieldset.toggleCollapse(\'%s\'); return false;">%s</a></div>',
|
278 |
$htmlId . '_' . $merchantId,
|
279 |
$htmlId . '_' . $merchantId,
|
280 |
$this->helper('amazonpayments')->__('<span class="close">Click to reveal config for </span>%s', $merchantId)
|
281 |
);
|
282 |
+
$html .= sprintf(
|
283 |
+
'<input id="%s-state" name="config_state[%s]" type="hidden" value="1">',
|
284 |
$htmlId . '_' . $merchantId,
|
285 |
$htmlId . '_' . $merchantId
|
286 |
);
|
289 |
foreach ($origins as $origin) {
|
290 |
$jsOriginsHtml[] = sprintf('<a class="nobr" href="%s">%s</a>', $origin, $origin);
|
291 |
}
|
292 |
+
|
293 |
$html .= implode('<br/>', $jsOriginsHtml);
|
294 |
$html .= '</div>';
|
295 |
$html .= '</div>';
|
297 |
$html .= 'Fieldset.applyCollapse(\'' . $htmlId . '_' . $merchantId . '\');' . "\n";
|
298 |
$html .= '//]]></script>' . "\n";
|
299 |
}
|
|
|
|
|
300 |
|
301 |
+
return $html ? $html : $placeholder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
}
|
303 |
|
304 |
+
protected function _getReturnUrlsHtml($htmlId)
|
305 |
+
{
|
306 |
$placeholder = <<<EOH
|
307 |
<em>I couldn't find any return URL :( Please double check if following conditions set is met in any store view:
|
308 |
<ul>
|
313 |
|
314 |
$html = '';
|
315 |
$returnUrls = $this->_getReturnUrls();
|
|
|
316 |
foreach ($returnUrls as $merchantId => $urls) {
|
317 |
$html .= '<div class="section-config">';
|
318 |
+
$html .= sprintf(
|
319 |
+
'<div class="entry-edit-head collapseable"><a id="%s-head" href="#" onclick="Fieldset.toggleCollapse(\'%s\'); return false;">%s</a></div>',
|
320 |
$htmlId . '_' . $merchantId,
|
321 |
$htmlId . '_' . $merchantId,
|
322 |
$this->helper('amazonpayments')->__('<span class="close">Click to reveal config for </span>%s', $merchantId)
|
323 |
);
|
324 |
+
$html .= sprintf(
|
325 |
+
'<input id="%s-state" name="config_state[%s]" type="hidden" value="1">',
|
326 |
$htmlId . '_' . $merchantId,
|
327 |
$htmlId . '_' . $merchantId
|
328 |
);
|
331 |
foreach ($urls as $url) {
|
332 |
$returnUrlsHtml[] = sprintf('<a class="nobr" href="%s">%s</a>', $url, $url);
|
333 |
}
|
334 |
+
|
335 |
$html .= implode('<br/>', $returnUrlsHtml);
|
336 |
$html .= '</div>';
|
337 |
$html .= '</div>';
|
339 |
$html .= 'Fieldset.applyCollapse(\'' . $htmlId . '_' . $merchantId . '\');' . "\n";
|
340 |
$html .= '//]]></script>' . "\n";
|
341 |
}
|
342 |
+
|
343 |
return $html ? $html : $placeholder;
|
344 |
}
|
345 |
|
346 |
+
public function getSellerCentralConfigOptions()
|
347 |
+
{
|
348 |
if (null === $this->_configOptions) {
|
349 |
$ipnUrls = $this->_getIpnUrlsHtml($this->getHtmlId() . '_ipn_urls');
|
350 |
$javascriptOrigins = $this->_getJavascriptOriginsHtml($this->getHtmlId() . '_allowed_javascript_origins');
|
351 |
$returnUrls = $this->_getReturnUrlsHtml($this->getHtmlId() . '_allowed_return_urls');
|
352 |
$this->_configOptions = array(
|
353 |
+
new Varien_Object(
|
354 |
+
array(
|
355 |
'id' => 'ipn_url',
|
356 |
'label' => $this->helper('amazonpayments')->__('IPN endpoint URL'),
|
357 |
'value' => $ipnUrls,
|
364 |
'amazonpayments_general_active' => 1,
|
365 |
'amazonpayments_general_ipn_active' => 1
|
366 |
)
|
367 |
+
)
|
368 |
+
),
|
369 |
+
new Varien_Object(
|
370 |
+
array(
|
371 |
'id' => 'allowed_javascript_origins',
|
372 |
'label' => $this->helper('amazonpayments')->__('Allowed JavaScript Origins'),
|
373 |
'value' => $javascriptOrigins,
|
379 |
'depends' => array(
|
380 |
'amazonpayments_login_active' => 1
|
381 |
)
|
382 |
+
)
|
383 |
+
),
|
384 |
+
new Varien_Object(
|
385 |
+
array(
|
386 |
'id' => 'allowed_return_urls',
|
387 |
'label' => $this->helper('amazonpayments')->__('Allowed Return URLs'),
|
388 |
'value' => $returnUrls,
|
394 |
'depends' => array(
|
395 |
'amazonpayments_login_active' => 1
|
396 |
)
|
397 |
+
)
|
398 |
+
)
|
399 |
);
|
400 |
}
|
401 |
+
|
402 |
return $this->_configOptions;
|
403 |
}
|
404 |
+
// @codingStandardsIgnoreEnd
|
405 |
|
406 |
+
public function getDependencyJs()
|
407 |
+
{
|
408 |
+
return '<script type="text/javascript">'
|
409 |
+
. 'new FormElementDependenceController(' . $this->_getDependsJson() . ');'
|
410 |
+
. '</script>';
|
411 |
}
|
412 |
|
413 |
+
public function getState()
|
414 |
+
{
|
415 |
if ($this->_getConfig()->getMerchantId()) {
|
416 |
return 1;
|
417 |
}
|
418 |
+
|
419 |
return 0;
|
420 |
}
|
|
|
421 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Button/Js.php
DELETED
@@ -1,61 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Button_Js
|
17 |
-
extends Creativestyle_AmazonPayments_Block_Abstract
|
18 |
-
implements Creativestyle_AmazonPayments_Block_Js_Interface {
|
19 |
-
|
20 |
-
public function getUrlParams() {
|
21 |
-
if ($this->isLoginActive()) {
|
22 |
-
$params = array(
|
23 |
-
'login' => $this->getLoginRedirectUrl(),
|
24 |
-
'pay' => $this->getPayRedirectUrl()
|
25 |
-
);
|
26 |
-
} else {
|
27 |
-
$params = array(
|
28 |
-
'checkout' => $this->getCheckoutUrl()
|
29 |
-
);
|
30 |
-
}
|
31 |
-
return $this->helper('core')->jsonEncode($params);
|
32 |
-
}
|
33 |
-
|
34 |
-
public function getDesignParams() {
|
35 |
-
if ($this->isLoginActive()) {
|
36 |
-
$params = array(
|
37 |
-
'payButton' => array(
|
38 |
-
'type' => $this->_getConfig()->getButtonType(),
|
39 |
-
'size' => $this->_getConfig()->getButtonSize(),
|
40 |
-
'color' => $this->_getConfig()->getButtonColor()
|
41 |
-
),
|
42 |
-
'loginButton' => array(
|
43 |
-
'type' => $this->_getConfig()->getButtonType(null, 'login'),
|
44 |
-
'size' => $this->_getConfig()->getButtonSize(null, 'login'),
|
45 |
-
'color' => $this->_getConfig()->getButtonColor(null, 'login')
|
46 |
-
)
|
47 |
-
);
|
48 |
-
return $this->helper('core')->jsonEncode($params);
|
49 |
-
}
|
50 |
-
return '{}';
|
51 |
-
}
|
52 |
-
|
53 |
-
public function getDisplayLanguage() {
|
54 |
-
return $this->_getConfig()->getDisplayLanguage();
|
55 |
-
}
|
56 |
-
|
57 |
-
public function getCallbackName() {
|
58 |
-
return 'window.onAmazonPaymentsReady';
|
59 |
-
}
|
60 |
-
|
61 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Block/Checkout.php
CHANGED
@@ -1,46 +1,36 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Checkout extends
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
public function getMerchantId() {
|
27 |
-
return $this->_getConfig()->getMerchantId();
|
28 |
}
|
29 |
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
-
|
34 |
-
public function isLive() {
|
35 |
-
return !$this->_getConfig()->isSandbox();
|
36 |
-
}
|
37 |
-
|
38 |
-
public function isVirtual() {
|
39 |
-
return $this->getQuote()->isVirtual();
|
40 |
-
}
|
41 |
-
|
42 |
-
public function isResponsive() {
|
43 |
-
return $this->_getConfig()->isResponsive();
|
44 |
-
}
|
45 |
-
|
46 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Checkout extends Creativestyle_AmazonPayments_Block_Checkout_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Checks whether to show transaction simulation toolbox or not
|
21 |
+
*
|
22 |
+
* @return bool
|
23 |
+
*/
|
24 |
+
public function showSandboxToolbox()
|
25 |
+
{
|
26 |
+
return $this->_getConfig()->isSandboxToolboxActive();
|
|
|
|
|
27 |
}
|
28 |
|
29 |
+
/**
|
30 |
+
* @inheritdoc
|
31 |
+
*/
|
32 |
+
public function getContainerClass()
|
33 |
+
{
|
34 |
+
return 'apa' . ($this->isQuoteVirtual() ? ' apa-virtual-checkout' : '');
|
35 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Checkout/Abstract.php
CHANGED
@@ -1,34 +1,41 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
abstract class Creativestyle_AmazonPayments_Block_Checkout_Abstract extends
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
if (
|
20 |
-
|
21 |
-
&& $this->_getConfig()->isCurrentLocaleAllowed()
|
22 |
-
&& $this->_isConnectionSecure())
|
23 |
-
{
|
24 |
-
$methodInstance = $this->isLive() ? Mage::getModel('amazonpayments/payment_advanced') : Mage::getModel('amazonpayments/payment_advanced_sandbox');
|
25 |
-
return $methodInstance->isAvailable($this->_getQuote());
|
26 |
}
|
27 |
-
return false;
|
28 |
-
}
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
|
|
|
|
|
34 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Block_Checkout_Abstract extends
|
18 |
+
Creativestyle_AmazonPayments_Block_Pay_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* @inheritdoc
|
22 |
+
*/
|
23 |
+
protected function _isActive()
|
24 |
+
{
|
25 |
+
if (!$this->isPayActive() || !$this->_isCurrentIpAllowed() || !$this->_isCurrentLocaleAllowed()) {
|
26 |
+
return false;
|
27 |
+
}
|
28 |
|
29 |
+
// hide for orders with virtual items when Login with Amazon is disabled
|
30 |
+
if (!$this->isLoginActive() && $this->_quoteHasVirtualItems()) {
|
31 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
|
|
|
|
33 |
|
34 |
+
/** @var Creativestyle_AmazonPayments_Model_Payment_Abstract $paymentMethodInstance */
|
35 |
+
$paymentMethodInstance = $this->isSandboxActive()
|
36 |
+
? Mage::getModel('amazonpayments/payment_advanced_sandbox')
|
37 |
+
: Mage::getModel('amazonpayments/payment_advanced');
|
38 |
|
39 |
+
return $paymentMethodInstance->isAvailable($this->_getQuote());
|
40 |
+
}
|
41 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Checkout/Js.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Checkout_Js
|
17 |
-
extends Creativestyle_AmazonPayments_Block_Checkout_Abstract
|
18 |
-
implements Creativestyle_AmazonPayments_Block_Js_Interface {
|
19 |
-
|
20 |
-
public function getAddressBookWidgetSize() {
|
21 |
-
return $this->_getConfig()->getAddressBookWidgetSize();
|
22 |
-
}
|
23 |
-
|
24 |
-
public function getWalletWidgetSize() {
|
25 |
-
return $this->_getConfig()->getWalletWidgetSize();
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getQuoteBaseGrandTotal() {
|
29 |
-
return (float)$this->_getQuote()->getBaseGrandTotal();
|
30 |
-
}
|
31 |
-
|
32 |
-
public function isResponsive() {
|
33 |
-
return $this->_getConfig()->isResponsive();
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getCallbackName() {
|
37 |
-
return 'window.onAmazonPaymentsReady';
|
38 |
-
}
|
39 |
-
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Block/Checkout/Notice.php
CHANGED
@@ -1,22 +1,26 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Checkout_Notice extends Creativestyle_AmazonPayments_Block_Checkout_Abstract
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
-
|
22 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Checkout_Notice extends Creativestyle_AmazonPayments_Block_Checkout_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @inheritdoc
|
21 |
+
*/
|
22 |
+
protected function _isActive()
|
23 |
+
{
|
24 |
+
return parent::_isActive() && $this->_getConfig()->captureImmediately();
|
25 |
}
|
|
|
26 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Checkout/SandboxToolbox.php
CHANGED
@@ -1,22 +1,25 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Checkout_SandboxToolbox
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
}
|
21 |
-
|
22 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Checkout_SandboxToolbox
|
18 |
+
extends Creativestyle_AmazonPayments_Block_Checkout_Abstract
|
19 |
+
{
|
20 |
+
public function getSimulationOptions()
|
21 |
+
{
|
22 |
+
return $this->_getCoreHelper()
|
23 |
+
->jsonEncode(Creativestyle_AmazonPayments_Model_Simulator::getAvailableSimulations());
|
24 |
}
|
|
|
25 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Customer/Account/Dashboard/Login.php
CHANGED
@@ -1,25 +1,38 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Customer_Account_Dashboard_Login
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
19 |
return $this->_getConfig()->isLoginActive();
|
20 |
}
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
return (bool)$this->_getCustomerSession()->getCustomer()->getAmazonUserId();
|
24 |
}
|
25 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Customer_Account_Dashboard_Login
|
18 |
+
extends Creativestyle_AmazonPayments_Block_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* @inheritdoc
|
22 |
+
*/
|
23 |
+
protected function _isActive()
|
24 |
+
{
|
25 |
return $this->_getConfig()->isLoginActive();
|
26 |
}
|
27 |
|
28 |
+
/**
|
29 |
+
* Checks whether Magento customer account is connected
|
30 |
+
* with Amazon customer account
|
31 |
+
*
|
32 |
+
* @return bool
|
33 |
+
*/
|
34 |
+
protected function isCustomerConnectedWithAmazon()
|
35 |
+
{
|
36 |
return (bool)$this->_getCustomerSession()->getCustomer()->getAmazonUserId();
|
37 |
}
|
38 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Js.php
CHANGED
@@ -1,81 +1,180 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Js extends Creativestyle_AmazonPayments_Block_Abstract {
|
17 |
-
|
18 |
-
protected $_callbacks = null;
|
19 |
-
protected $_scripts = null;
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
-
return $this;
|
31 |
}
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
}
|
41 |
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
$this->_addCallback($block->toHtml(), $block->getCallbackName());
|
54 |
-
} else if ($block->toHtml()) {
|
55 |
-
$this->_addScript($block->toHtml());
|
56 |
-
}
|
57 |
-
}
|
58 |
-
}
|
59 |
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
-
if (
|
63 |
-
|
64 |
-
if (is_array($callbackFunctions)) {
|
65 |
-
array_unshift($callbackFunctions, $callbackName . ' = function() {');
|
66 |
-
array_push($callbackFunctions, '};');
|
67 |
-
$output .= implode("\n", $callbackFunctions) . "\n\n";
|
68 |
-
}
|
69 |
-
}
|
70 |
}
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
-
return
|
79 |
}
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
/**
|
19 |
+
* Amazon Pay JS block
|
20 |
+
*
|
21 |
+
* @method $this setIsCheckout(int $value)
|
22 |
+
* @method int getIsCheckout()
|
23 |
+
* @method $this setIsLogout(int $value)
|
24 |
+
* @method int getIsLogout()
|
25 |
+
*/
|
26 |
+
class Creativestyle_AmazonPayments_Block_Js extends Creativestyle_AmazonPayments_Block_Abstract
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* @inheritdoc
|
30 |
+
*/
|
31 |
+
protected function _construct()
|
32 |
+
{
|
33 |
+
parent::_construct();
|
34 |
+
if (!$this->hasData('template')) {
|
35 |
+
$this->setTemplate('creativestyle/amazonpayments/js.phtml');
|
36 |
}
|
|
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* Returns Widgets JS library URL
|
41 |
+
*
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function getWidgetJsUrl()
|
45 |
+
{
|
46 |
+
return $this->_getConfig()->getWidgetJsUrl();
|
47 |
}
|
48 |
|
49 |
+
/**
|
50 |
+
* Returns JS app configuration
|
51 |
+
*
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
public function getJsConfig()
|
55 |
+
{
|
56 |
+
$jsConfig = array(
|
57 |
+
'merchantId' => $this->getMerchantId(),
|
58 |
+
'clientId' => $this->getClientId(),
|
59 |
+
'live' => !$this->isSandboxActive(),
|
60 |
+
'popup' => $this->isPopupAuthenticationExperience(),
|
61 |
+
'virtual' => $this->isQuoteVirtual(),
|
62 |
+
'language' => $this->getDisplayLanguage(),
|
63 |
+
'pay' => array(
|
64 |
+
'selector' => $this->getPayButtonSelector(),
|
65 |
+
'callbackUrl' => $this->getPayButtonCallbackUrl(),
|
66 |
+
'design' => $this->getPayButtonDesignParams()
|
67 |
+
),
|
68 |
+
'login' => $this->isLoginActive() ? array(
|
69 |
+
'selector' => $this->getLoginButtonSelector(),
|
70 |
+
'callbackUrl' => $this->getLoginButtonCallbackUrl(),
|
71 |
+
'design' => $this->getLoginButtonDesignParams()
|
72 |
+
) : null,
|
73 |
+
'checkoutUrl' => $this->getCheckoutUrl(),
|
74 |
+
'currency' => Mage::app()->getStore()->getBaseCurrencyCode()
|
75 |
+
);
|
76 |
+
return Mage::helper('core')->jsonEncode($jsConfig);
|
77 |
}
|
78 |
|
79 |
+
/**
|
80 |
+
* @return null|string
|
81 |
+
*/
|
82 |
+
public function getCheckoutUrl()
|
83 |
+
{
|
84 |
+
return Mage::getUrl('amazonpayments/checkout');
|
85 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
+
/**
|
88 |
+
* Returns callback URL for Amazon Pay button
|
89 |
+
*
|
90 |
+
* @return string|null
|
91 |
+
*/
|
92 |
+
public function getPayButtonCallbackUrl()
|
93 |
+
{
|
94 |
+
// no callback URL for APA button
|
95 |
+
if (!$this->isLoginActive()) {
|
96 |
+
return null;
|
97 |
+
}
|
98 |
|
99 |
+
if ($this->isPopupAuthenticationExperience()) {
|
100 |
+
return Mage::getUrl('amazonpayments/advanced_login', array('target' => 'checkout'));
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
+
return Mage::getUrl('amazonpayments/advanced_login/redirect', array('target' => 'checkout'));
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Returns Amazon Pay button design params
|
108 |
+
*
|
109 |
+
* @return array|null
|
110 |
+
*/
|
111 |
+
public function getPayButtonDesignParams()
|
112 |
+
{
|
113 |
+
return $this->_getConfig()->getPayButtonDesign();
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Returns Amazon Pay buttons DOM selector
|
118 |
+
*
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
public function getPayButtonSelector()
|
122 |
+
{
|
123 |
+
return sprintf('.%s', Creativestyle_AmazonPayments_Block_Pay_Button::WIDGET_CONTAINER_ID_PREFIX);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Returns callback URL for Login with Amazon button
|
128 |
+
*
|
129 |
+
* @return string
|
130 |
+
*/
|
131 |
+
public function getLoginButtonCallbackUrl()
|
132 |
+
{
|
133 |
+
if ($this->isPopupAuthenticationExperience()) {
|
134 |
+
return Mage::getUrl('amazonpayments/advanced_login');
|
135 |
}
|
136 |
|
137 |
+
return Mage::getUrl('amazonpayments/advanced_login/redirect');
|
138 |
}
|
139 |
|
140 |
+
/**
|
141 |
+
* Returns Login with Amazon button design params
|
142 |
+
*
|
143 |
+
* @return array
|
144 |
+
*/
|
145 |
+
public function getLoginButtonDesignParams()
|
146 |
+
{
|
147 |
+
return $this->_getConfig()->getLoginButtonDesign();
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Returns Login with Amazon buttons DOM selector
|
152 |
+
*
|
153 |
+
* @return string|null
|
154 |
+
*/
|
155 |
+
public function getLoginButtonSelector()
|
156 |
+
{
|
157 |
+
return $this->isLoginActive()
|
158 |
+
? sprintf('.%s', Creativestyle_AmazonPayments_Block_Login_Button::WIDGET_CONTAINER_ID_PREFIX)
|
159 |
+
: null;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Returns JSON-formatted checkout URLs
|
164 |
+
*
|
165 |
+
* @return string
|
166 |
+
*/
|
167 |
+
public function getCheckoutUrls()
|
168 |
+
{
|
169 |
+
$urls = array(
|
170 |
+
'saveShipping' => $this->getUrl('amazonpayments/checkout/saveShipping'),
|
171 |
+
'saveShippingMethod' => $this->getUrl('amazonpayments/checkout/saveShippingMethod'),
|
172 |
+
'saveOrder' => $this->getUrl('amazonpayments/checkout/saveOrder'),
|
173 |
+
'saveCoupon' => $this->getUrl('amazonpayments/checkout/couponPost'),
|
174 |
+
'clearOrderReference' => $this->getUrl('amazonpayments/checkout/clearOrderReference'),
|
175 |
+
'cancelOrderReference' => $this->getUrl('amazonpayments/checkout/cancelOrderReference'),
|
176 |
+
'failure' => $this->getUrl('checkout/cart')
|
177 |
+
);
|
178 |
+
return $this->_jsonEncode($urls);
|
179 |
+
}
|
180 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Js/Interface.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
interface Creativestyle_AmazonPayments_Block_Js_Interface {
|
17 |
-
|
18 |
-
public function getCallbackName();
|
19 |
-
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Block/Login/Abstract.php
CHANGED
@@ -1,27 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
abstract class Creativestyle_AmazonPayments_Block_Login_Abstract extends Creativestyle_AmazonPayments_Block_Abstract
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
&&
|
|
|
25 |
}
|
26 |
-
|
27 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Block_Login_Abstract extends Creativestyle_AmazonPayments_Block_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @inheritdoc
|
21 |
+
*/
|
22 |
+
protected function _isActive()
|
23 |
+
{
|
24 |
+
return $this->isLoginActive()
|
25 |
+
&& $this->_isCurrentIpAllowed()
|
26 |
+
&& ($this->_isConnectionSecure() || !$this->isPopupAuthenticationExperience());
|
27 |
}
|
|
|
28 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Login/Account/Confirm.php
CHANGED
@@ -1,26 +1,34 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Login_Account_Confirm extends Creativestyle_AmazonPayments_Block_Login_Abstract
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
return $this->getUrl('*/*/', array('_current' => true));
|
20 |
}
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
23 |
return $this->helper('customer')->getForgotPasswordUrl();
|
24 |
}
|
25 |
-
|
26 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Login_Account_Confirm extends Creativestyle_AmazonPayments_Block_Login_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
public function getPostActionUrl()
|
23 |
+
{
|
24 |
return $this->getUrl('*/*/', array('_current' => true));
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
+
* @return string
|
29 |
+
*/
|
30 |
+
public function getForgotPasswordUrl()
|
31 |
+
{
|
32 |
return $this->helper('customer')->getForgotPasswordUrl();
|
33 |
}
|
|
|
34 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Login/Account/Update.php
CHANGED
@@ -1,21 +1,26 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Login_Account_Update extends Mage_Customer_Block_Form_Register
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
return $this->getUrl('*/*/', array('_current' => true));
|
20 |
}
|
21 |
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Login_Account_Update extends Mage_Customer_Block_Form_Register
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
public function getPostActionUrl()
|
23 |
+
{
|
24 |
return $this->getUrl('*/*/', array('_current' => true));
|
25 |
}
|
26 |
|
app/code/community/Creativestyle/AmazonPayments/Block/Login/Button.php
CHANGED
@@ -1,37 +1,77 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Login_Button extends Creativestyle_AmazonPayments_Block_Login_Abstract
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
parent::_construct();
|
20 |
if (!$this->hasData('template')) {
|
21 |
$this->setTemplate('creativestyle/amazonpayments/login/button.phtml');
|
22 |
}
|
23 |
}
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
if ($this->_getCustomerSession()->isLoggedIn()
|
27 |
&& $this->_getCustomerSession()->getCustomer()->getAmazonUserId()) {
|
28 |
return false;
|
29 |
}
|
|
|
30 |
return parent::_isActive();
|
31 |
}
|
32 |
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
-
|
37 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Login with Amazon button block
|
20 |
+
*
|
21 |
+
* @method string getButtonType()
|
22 |
+
* @method $this setButtonType(string $value)
|
23 |
+
* @method string getButtonSize()
|
24 |
+
* @method $this setButtonSize(string $value)
|
25 |
+
* @method string getButtonColor()
|
26 |
+
* @method $this setButtonColor(string $value)
|
27 |
*/
|
28 |
+
class Creativestyle_AmazonPayments_Block_Login_Button extends Creativestyle_AmazonPayments_Block_Login_Abstract
|
29 |
+
{
|
30 |
+
const WIDGET_CONTAINER_ID_PREFIX = 'loginButtonWidget';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @inheritdoc
|
34 |
+
*/
|
35 |
+
protected $_containerIdPrefix = self::WIDGET_CONTAINER_ID_PREFIX;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @inheritdoc
|
39 |
+
*/
|
40 |
+
protected $_containerClass = self::WIDGET_CONTAINER_ID_PREFIX;
|
41 |
|
42 |
+
/**
|
43 |
+
* @inheritdoc
|
44 |
+
*/
|
45 |
+
protected function _construct()
|
46 |
+
{
|
47 |
parent::_construct();
|
48 |
if (!$this->hasData('template')) {
|
49 |
$this->setTemplate('creativestyle/amazonpayments/login/button.phtml');
|
50 |
}
|
51 |
}
|
52 |
|
53 |
+
/**
|
54 |
+
* @inheritdoc
|
55 |
+
*/
|
56 |
+
protected function _isActive()
|
57 |
+
{
|
58 |
if ($this->_getCustomerSession()->isLoggedIn()
|
59 |
&& $this->_getCustomerSession()->getCustomer()->getAmazonUserId()) {
|
60 |
return false;
|
61 |
}
|
62 |
+
|
63 |
return parent::_isActive();
|
64 |
}
|
65 |
|
66 |
+
/**
|
67 |
+
* Checks if custom design is set for the button
|
68 |
+
*
|
69 |
+
* @return bool
|
70 |
+
*/
|
71 |
+
public function isCustomDesignSet()
|
72 |
+
{
|
73 |
+
return $this->hasData('button_type')
|
74 |
+
|| $this->hasData('button_size')
|
75 |
+
|| $this->hasData('button_color');
|
76 |
}
|
|
|
77 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Login/Js.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Login_Js
|
17 |
-
extends Creativestyle_AmazonPayments_Block_Login_Abstract
|
18 |
-
implements Creativestyle_AmazonPayments_Block_Js_Interface {
|
19 |
-
|
20 |
-
public function getClientId() {
|
21 |
-
return $this->_getConfig()->getClientId();
|
22 |
-
}
|
23 |
-
|
24 |
-
public function getCallbackName() {
|
25 |
-
return 'window.onAmazonLoginReady';
|
26 |
-
}
|
27 |
-
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Block/Login/Redirect.php
CHANGED
@@ -1,39 +1,60 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Login_Redirect extends Creativestyle_AmazonPayments_Block_Login_Abstract
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
if ($this->hasData('access_token_param_name')) {
|
20 |
return $this->getData('access_token_param_name');
|
21 |
}
|
|
|
22 |
return 'access_token';
|
23 |
}
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
if ($this->hasData('redirect_url')) {
|
27 |
return $this->getData('redirect_url');
|
28 |
}
|
|
|
29 |
return $this->getFailureUrl();
|
30 |
}
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
if ($this->hasData('failure_url')) {
|
34 |
return $this->getData('failure_url');
|
35 |
}
|
|
|
36 |
return $this->getUrl('customer/account/login');
|
37 |
}
|
38 |
-
|
39 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2015 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2015 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Login_Redirect extends Creativestyle_AmazonPayments_Block_Login_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Returns access token param name
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function getAccessTokenParamName()
|
25 |
+
{
|
26 |
if ($this->hasData('access_token_param_name')) {
|
27 |
return $this->getData('access_token_param_name');
|
28 |
}
|
29 |
+
|
30 |
return 'access_token';
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
* Returns redirect URL
|
35 |
+
*
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
public function getRedirectUrl()
|
39 |
+
{
|
40 |
if ($this->hasData('redirect_url')) {
|
41 |
return $this->getData('redirect_url');
|
42 |
}
|
43 |
+
|
44 |
return $this->getFailureUrl();
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
+
* Returns failure URL
|
49 |
+
*
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
public function getFailureUrl()
|
53 |
+
{
|
54 |
if ($this->hasData('failure_url')) {
|
55 |
return $this->getData('failure_url');
|
56 |
}
|
57 |
+
|
58 |
return $this->getUrl('customer/account/login');
|
59 |
}
|
|
|
60 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Onepage/Button.php
CHANGED
@@ -1,49 +1,29 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Onepage_Button extends
|
17 |
-
|
18 |
/**
|
19 |
-
* @
|
20 |
*/
|
21 |
-
protected function
|
22 |
{
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Render Amazon Payments button
|
28 |
-
*
|
29 |
-
* @return string
|
30 |
-
*/
|
31 |
-
protected function _toHtml() {
|
32 |
-
try {
|
33 |
-
if ($this->_isActive()) {
|
34 |
-
if ($this->isLoginActive()) {
|
35 |
-
$button = $this->getChild('onepage.amazonpayments.button.login');
|
36 |
-
} else {
|
37 |
-
$button = $this->getChild('onepage.amazonpayments.button.pay');
|
38 |
-
}
|
39 |
-
if ($button) {
|
40 |
-
return $button->toHtml();
|
41 |
-
}
|
42 |
-
}
|
43 |
-
} catch (Exception $e) {
|
44 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
45 |
}
|
46 |
-
return parent::_toHtml();
|
47 |
}
|
48 |
-
|
49 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Onepage_Button extends Creativestyle_AmazonPayments_Block_Pay_Button
|
18 |
+
{
|
19 |
/**
|
20 |
+
* @inheritdoc
|
21 |
*/
|
22 |
+
protected function _construct()
|
23 |
{
|
24 |
+
parent::_construct();
|
25 |
+
if (!$this->hasData('template')) {
|
26 |
+
$this->setTemplate('creativestyle/amazonpayments/onepage/button.phtml');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
|
|
28 |
}
|
|
|
29 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Pay/Abstract.php
CHANGED
@@ -1,35 +1,45 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
abstract class Creativestyle_AmazonPayments_Block_Pay_Abstract extends Creativestyle_AmazonPayments_Block_Abstract
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
if (($this->
|
22 |
-
|
23 |
-
&& $this->_getConfig()->isCurrentLocaleAllowed()
|
24 |
-
&& ($this->_isConnectionSecure() || !$this->isPopup()))
|
25 |
-
{
|
26 |
-
if (!$this->isLoginActive() && $this->_quoteHasVirtualItems()) {
|
27 |
-
return false;
|
28 |
-
}
|
29 |
-
$methodInstance = $this->isLive() ? Mage::getModel('amazonpayments/payment_advanced') : Mage::getModel('amazonpayments/payment_advanced_sandbox');
|
30 |
-
return $methodInstance->isAvailable($this->_getQuote());
|
31 |
}
|
32 |
-
return false;
|
33 |
-
}
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Block_Pay_Abstract extends Creativestyle_AmazonPayments_Block_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @inheritdoc
|
21 |
+
*/
|
22 |
+
protected function _isActive()
|
23 |
+
{
|
24 |
+
if (!$this->isPayActive() || !$this->_isCurrentIpAllowed() || !$this->_isCurrentLocaleAllowed()) {
|
25 |
+
return false;
|
26 |
+
}
|
27 |
|
28 |
+
// hide for orders with virtual items when Login with Amazon is disabled
|
29 |
+
if (!$this->isLoginActive() && $this->_quoteHasVirtualItems()) {
|
30 |
+
return false;
|
31 |
+
}
|
32 |
|
33 |
+
// hide for Login and popup enabled, when request wasn't secure
|
34 |
+
if ($this->isLoginActive() && $this->isPopupAuthenticationExperience() && !$this->_isConnectionSecure()) {
|
35 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
|
|
|
|
37 |
|
38 |
+
/** @var Creativestyle_AmazonPayments_Model_Payment_Abstract $paymentMethodInstance */
|
39 |
+
$paymentMethodInstance = $this->isSandboxActive()
|
40 |
+
? Mage::getModel('amazonpayments/payment_advanced_sandbox')
|
41 |
+
: Mage::getModel('amazonpayments/payment_advanced');
|
42 |
+
|
43 |
+
return $paymentMethodInstance->isAvailable($this->_getQuote());
|
44 |
+
}
|
45 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Pay/Button.php
CHANGED
@@ -1,33 +1,64 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Pay_Button extends Creativestyle_AmazonPayments_Block_Pay_Abstract {
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
parent::_construct();
|
20 |
if (!$this->hasData('template')) {
|
21 |
$this->setTemplate('creativestyle/amazonpayments/pay/button.phtml');
|
22 |
}
|
23 |
}
|
24 |
|
25 |
-
public function getButtonWidgetUrl()
|
26 |
-
|
|
|
27 |
}
|
28 |
|
29 |
-
public function isCustomDesignSet()
|
30 |
-
|
|
|
31 |
}
|
32 |
-
|
33 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
|
|
17 |
|
18 |
+
/**
|
19 |
+
* Amazon Pay button block
|
20 |
+
*
|
21 |
+
* @method int getEnableOr()
|
22 |
+
* @method $this setEnableOr(int $value)
|
23 |
+
* @method string getButtonType()
|
24 |
+
* @method $this setButtonType(string $value)
|
25 |
+
* @method string getButtonSize()
|
26 |
+
* @method $this setButtonSize(string $value)
|
27 |
+
* @method string getButtonColor()
|
28 |
+
* @method $this setButtonColor(string $value)
|
29 |
+
*/
|
30 |
+
class Creativestyle_AmazonPayments_Block_Pay_Button extends Creativestyle_AmazonPayments_Block_Pay_Abstract
|
31 |
+
{
|
32 |
+
const WIDGET_CONTAINER_ID_PREFIX = 'payButtonWidget';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @inheritdoc
|
36 |
+
*/
|
37 |
+
protected $_containerIdPrefix = self::WIDGET_CONTAINER_ID_PREFIX;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @inheritdoc
|
41 |
+
*/
|
42 |
+
protected $_containerClass = self::WIDGET_CONTAINER_ID_PREFIX;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @inheritdoc
|
46 |
+
*/
|
47 |
+
protected function _construct()
|
48 |
+
{
|
49 |
parent::_construct();
|
50 |
if (!$this->hasData('template')) {
|
51 |
$this->setTemplate('creativestyle/amazonpayments/pay/button.phtml');
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
public function getButtonWidgetUrl()
|
56 |
+
{
|
57 |
+
return $this->_getConfig()->getPayButtonUrl();
|
58 |
}
|
59 |
|
60 |
+
public function isCustomDesignSet()
|
61 |
+
{
|
62 |
+
return $this->hasData('button_type') || $this->hasData('button_size') || $this->hasData('button_color');
|
63 |
}
|
|
|
64 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Payment/Info.php
CHANGED
@@ -1,28 +1,36 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Payment_Info extends Mage_Payment_Block_Info
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
parent::_construct();
|
20 |
$this->setTemplate('creativestyle/amazonpayments/payment/info.phtml');
|
21 |
}
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
$this->setTemplate('creativestyle/amazonpayments/payment/pdf/info.phtml');
|
25 |
return $this->toHtml();
|
26 |
}
|
27 |
-
|
28 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Payment_Info extends Mage_Payment_Block_Info
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @inheritdoc
|
21 |
+
*/
|
22 |
+
protected function _construct()
|
23 |
+
{
|
24 |
parent::_construct();
|
25 |
$this->setTemplate('creativestyle/amazonpayments/payment/info.phtml');
|
26 |
}
|
27 |
|
28 |
+
/**
|
29 |
+
* @inheritdoc
|
30 |
+
*/
|
31 |
+
public function toPdf()
|
32 |
+
{
|
33 |
$this->setTemplate('creativestyle/amazonpayments/payment/pdf/info.phtml');
|
34 |
return $this->toHtml();
|
35 |
}
|
|
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Block/Payment/Legacy/Info.php
CHANGED
@@ -1,28 +1,36 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Block_Payment_Legacy_Info extends Mage_Payment_Block_Info
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
parent::_construct();
|
20 |
$this->setTemplate('creativestyle/amazonpayments/payment/legacy/info.phtml');
|
21 |
}
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
$this->setTemplate('creativestyle/amazonpayments/payment/legacy/pdf/info.phtml');
|
25 |
return $this->toHtml();
|
26 |
}
|
27 |
-
|
28 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2016 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2016 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Block_Payment_Legacy_Info extends Mage_Payment_Block_Info
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @inheritdoc
|
21 |
+
*/
|
22 |
+
protected function _construct()
|
23 |
+
{
|
24 |
parent::_construct();
|
25 |
$this->setTemplate('creativestyle/amazonpayments/payment/legacy/info.phtml');
|
26 |
}
|
27 |
|
28 |
+
/**
|
29 |
+
* @inheritdoc
|
30 |
+
*/
|
31 |
+
public function toPdf()
|
32 |
+
{
|
33 |
$this->setTemplate('creativestyle/amazonpayments/payment/legacy/pdf/info.phtml');
|
34 |
return $this->toHtml();
|
35 |
}
|
|
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Controller/Action.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
class Creativestyle_AmazonPayments_Controller_Action extends Mage_Core_Controller_Front_Action
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Returns Amazon Pay config model instance
|
21 |
+
*
|
22 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
23 |
+
*/
|
24 |
+
protected function _getConfig()
|
25 |
+
{
|
26 |
+
return Mage::getSingleton('amazonpayments/config');
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Creativestyle/AmazonPayments/Controller/Adminhtml/Log/Action.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Controller_Adminhtml_Log_Action extends Mage_Adminhtml_Controller_Action
|
18 |
+
{
|
19 |
+
const TITLE_AMAZON_PAY = 'Amazon Pay';
|
20 |
+
const TITLE_LOGS = 'Log preview';
|
21 |
+
const TITLE_PREVIEW = 'Preview';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
protected $_titlePrefix = array(
|
27 |
+
self::TITLE_AMAZON_PAY,
|
28 |
+
self::TITLE_LOGS
|
29 |
+
);
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Returns Amazon Pay config model instance
|
33 |
+
*
|
34 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
35 |
+
*/
|
36 |
+
protected function _getConfig()
|
37 |
+
{
|
38 |
+
return Mage::getSingleton('amazonpayments/config');
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Returns collection of the logs of the given type
|
43 |
+
*
|
44 |
+
* @return Creativestyle_AmazonPayments_Model_Log_Collection
|
45 |
+
*/
|
46 |
+
protected function _getLogCollection()
|
47 |
+
{
|
48 |
+
/** @var Creativestyle_AmazonPayments_Model_Log_Collection $collection */
|
49 |
+
$collection = Mage::getModel('amazonpayments/log_collection');
|
50 |
+
return $collection->setLogType($this->getLogType());
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Returns log of given ID
|
55 |
+
*
|
56 |
+
* @param $logId
|
57 |
+
* @return Varien_Object|null
|
58 |
+
*/
|
59 |
+
protected function _getLogById($logId)
|
60 |
+
{
|
61 |
+
return $this->_getLogCollection()->getItemById($logId);
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Returns array of titles for log list page
|
66 |
+
*
|
67 |
+
* @return array
|
68 |
+
*/
|
69 |
+
protected function _getListPageTitleArray()
|
70 |
+
{
|
71 |
+
return array_merge($this->_titlePrefix, array($this->getTitle()));
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Returns array of titles for log preview page
|
76 |
+
*
|
77 |
+
* @return array
|
78 |
+
*/
|
79 |
+
protected function _getViewPageTitleArray()
|
80 |
+
{
|
81 |
+
return array_merge($this->_getListPageTitleArray(), array(self::TITLE_PREVIEW));
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Returns log preview block instance
|
86 |
+
*
|
87 |
+
* @return Creativestyle_AmazonPayments_Block_Adminhtml_Log_View_Abstract
|
88 |
+
*/
|
89 |
+
protected function _getLogPreviewBlock()
|
90 |
+
{
|
91 |
+
return $this->getLayout()->createBlock('amazonpayments/adminhtml_log_' . $this->getLogType() . '_view');
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Adds given log preview block to the current layout
|
96 |
+
*
|
97 |
+
* @param Varien_Object $log
|
98 |
+
* @return $this
|
99 |
+
*/
|
100 |
+
protected function _addLogPreviewContent(Varien_Object $log)
|
101 |
+
{
|
102 |
+
$this->_addContent($this->_getLogPreviewBlock()->setLog($log));
|
103 |
+
return $this;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @inheritdoc
|
108 |
+
*/
|
109 |
+
protected function _isAllowed()
|
110 |
+
{
|
111 |
+
return Mage::getSingleton('admin/session')
|
112 |
+
->isAllowed('admin/creativestyle/amazonpayments/log/' . $this->getLogType());
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @param array $titles
|
117 |
+
* @return $this
|
118 |
+
*/
|
119 |
+
protected function _initAction(array $titles)
|
120 |
+
{
|
121 |
+
$this->loadLayout()->_setActiveMenu('creativestyle/amazonpayments/log/' . $this->getLogType());
|
122 |
+
foreach ($titles as $title) {
|
123 |
+
$localizedTitle = $this->__($title);
|
124 |
+
$this->_addBreadcrumb($localizedTitle, $localizedTitle)
|
125 |
+
->_title($localizedTitle);
|
126 |
+
}
|
127 |
+
|
128 |
+
return $this;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Logs listing action
|
133 |
+
*/
|
134 |
+
public function indexAction()
|
135 |
+
{
|
136 |
+
$this->_initAction($this->_getListPageTitleArray())
|
137 |
+
->renderLayout();
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Log preview action
|
142 |
+
*/
|
143 |
+
public function viewAction()
|
144 |
+
{
|
145 |
+
$logId = $this->getRequest()->getParam('id');
|
146 |
+
$log = $this->_getLogById($logId);
|
147 |
+
if ($log && $log->getId()) {
|
148 |
+
$this->_initAction($this->_getViewPageTitleArray())
|
149 |
+
->_addLogPreviewContent($log)
|
150 |
+
->renderLayout();
|
151 |
+
} else {
|
152 |
+
Mage::getSingleton('adminhtml/session')
|
153 |
+
->addError(Mage::helper('amazonpayments')->__('Log does not exist'));
|
154 |
+
$this->_redirect('*/*/');
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Logs download action
|
160 |
+
*/
|
161 |
+
public function downloadAction()
|
162 |
+
{
|
163 |
+
$logFilePath = Creativestyle_AmazonPayments_Model_Logger::getAbsoluteLogFilePath($this->getLogType());
|
164 |
+
// @codingStandardsIgnoreStart
|
165 |
+
if (file_exists($logFilePath)) {
|
166 |
+
$output = implode(
|
167 |
+
$this->_getConfig()->getLogDelimiter(),
|
168 |
+
Creativestyle_AmazonPayments_Model_Logger::getColumnMapping($this->getLogType())
|
169 |
+
) . "\n";
|
170 |
+
$output .= file_get_contents($logFilePath);
|
171 |
+
Mage::app()->getResponse()->setHeader('Content-type', 'text/csv');
|
172 |
+
Mage::app()->getResponse()->setHeader(
|
173 |
+
'Content-disposition',
|
174 |
+
'attachment;filename=' . basename($logFilePath)
|
175 |
+
);
|
176 |
+
Mage::app()->getResponse()->setHeader('Content-Length', filesize($logFilePath));
|
177 |
+
Mage::app()->getResponse()->setBody($output);
|
178 |
+
} else {
|
179 |
+
$this->_redirect('*/*/');
|
180 |
+
}
|
181 |
+
// @codingStandardsIgnoreEnd
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Returns the type of handled log
|
186 |
+
*
|
187 |
+
* @return string
|
188 |
+
*/
|
189 |
+
abstract public function getLogType();
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Returns page title for the handled log type
|
193 |
+
*
|
194 |
+
* @return string
|
195 |
+
*/
|
196 |
+
abstract public function getTitle();
|
197 |
+
}
|
app/code/community/Creativestyle/AmazonPayments/Exception.php
CHANGED
@@ -1,16 +1,20 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Exception extends Mage_Core_Exception
|
|
|
|
1 |
<?php
|
2 |
+
// @codingStandardsIgnoreFile
|
3 |
/**
|
4 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
5 |
+
* for Magento 1.x
|
|
|
6 |
*
|
7 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
8 |
+
*
|
9 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
10 |
+
* this software, is not allowed without explicit written permission granted
|
11 |
+
* by creativestyle GmbH
|
12 |
*
|
13 |
* @category Creativestyle
|
14 |
* @package Creativestyle_AmazonPayments
|
15 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
16 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
17 |
*/
|
18 |
+
class Creativestyle_AmazonPayments_Exception extends Mage_Core_Exception
|
19 |
+
{
|
20 |
+
}
|
app/code/community/Creativestyle/AmazonPayments/Exception/InvalidStatus.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2015 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Exception_InvalidStatus extends Creativestyle_AmazonPayments_Exception {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Exception/InvalidStatus/Recoverable.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2015 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Exception_InvalidStatus_Recoverable extends Creativestyle_AmazonPayments_Exception_InvalidStatus {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Exception/InvalidStatus/Unrecoverable.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2016 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Exception_InvalidStatus_Unrecoverable extends Creativestyle_AmazonPayments_Exception_InvalidStatus {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Exception/InvalidTransaction.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
class Creativestyle_AmazonPayments_Exception_InvalidTransaction extends Creativestyle_AmazonPayments_Exception
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
protected $_state;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
protected $_transactionType;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param string $txnType
|
31 |
+
* @param array $state
|
32 |
+
* @param string $message
|
33 |
+
* @param int $code
|
34 |
+
* @param Throwable|null $previous
|
35 |
+
*/
|
36 |
+
public function __construct($txnType, array $state, $message = "", $code = 0, Throwable $previous = null)
|
37 |
+
{
|
38 |
+
parent::__construct($message, $code, $previous);
|
39 |
+
$this->_transactionType = $txnType;
|
40 |
+
$this->_state = $state;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param string $key
|
45 |
+
* @return mixed|null
|
46 |
+
*/
|
47 |
+
protected function _getStateAttribute($key)
|
48 |
+
{
|
49 |
+
if (array_key_exists($key, $this->_state)) {
|
50 |
+
return $this->_state[$key];
|
51 |
+
}
|
52 |
+
|
53 |
+
return null;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @return mixed|null
|
58 |
+
*/
|
59 |
+
public function getState()
|
60 |
+
{
|
61 |
+
return $this->_getStateAttribute(
|
62 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_KEY
|
63 |
+
);
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @return mixed|null
|
68 |
+
*/
|
69 |
+
public function getReasonCode()
|
70 |
+
{
|
71 |
+
return $this->_getStateAttribute(
|
72 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_REASON_CODE_KEY
|
73 |
+
);
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
public function getType()
|
80 |
+
{
|
81 |
+
return $this->_transactionType;
|
82 |
+
}
|
83 |
+
}
|
app/code/community/Creativestyle/AmazonPayments/Exception/TransactionNotFound.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
class Creativestyle_AmazonPayments_Exception_TransactionNotFound extends Creativestyle_AmazonPayments_Exception
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
protected $_transactionId;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
protected $_messagePattern = 'Payment transaction (%s) not found';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param string $txnId
|
31 |
+
*/
|
32 |
+
public function __construct($txnId)
|
33 |
+
{
|
34 |
+
parent::__construct(sprintf($this->_messagePattern, $txnId), 404);
|
35 |
+
$this->_transactionId = $txnId;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
public function getTxnId()
|
42 |
+
{
|
43 |
+
return $this->_transactionId;
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Creativestyle/AmazonPayments/Helper/Data.php
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
|
17 |
/**
|
@@ -20,9 +21,15 @@
|
|
20 |
* @category Creativestyle
|
21 |
* @package Creativestyle_AmazonPayments
|
22 |
*/
|
23 |
-
class Creativestyle_AmazonPayments_Helper_Data extends Mage_Core_Helper_Abstract
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return Mage::getSingleton('amazonpayments/config');
|
27 |
}
|
28 |
|
@@ -30,14 +37,16 @@ class Creativestyle_AmazonPayments_Helper_Data extends Mage_Core_Helper_Abstract
|
|
30 |
* Sends an email to the customer if authorization has been declined
|
31 |
*
|
32 |
* @param Mage_Sales_Model_Order $order
|
33 |
-
*
|
34 |
-
* @return Creativestyle_AmazonPayments_Helper_Data
|
35 |
*/
|
36 |
-
public function sendAuthorizationDeclinedEmail($order)
|
|
|
|
|
37 |
$translate = Mage::getSingleton('core/translate');
|
38 |
$translate->setTranslateInline(false);
|
39 |
-
$mailTemplate = Mage::getModel('core/email_template');
|
40 |
|
|
|
|
|
41 |
$mailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $order->getStore()->getId()))
|
42 |
->sendTransactional(
|
43 |
$this->_getConfig()->getAuthorizationDeclinedEmailTemplate($order->getStore()->getId()),
|
@@ -59,7 +68,8 @@ class Creativestyle_AmazonPayments_Helper_Data extends Mage_Core_Helper_Abstract
|
|
59 |
*
|
60 |
* @return array
|
61 |
*/
|
62 |
-
public function getAvailablePaymentMethods()
|
|
|
63 |
return array(
|
64 |
'amazonpayments_advanced',
|
65 |
'amazonpayments_advanced_sandbox'
|
@@ -71,115 +81,141 @@ class Creativestyle_AmazonPayments_Helper_Data extends Mage_Core_Helper_Abstract
|
|
71 |
*
|
72 |
* @return bool
|
73 |
*/
|
74 |
-
public function isMobileDevice()
|
|
|
75 |
$userAgent = Mage::app()->getRequest()->getServer('HTTP_USER_AGENT');
|
76 |
if (empty($userAgent)) {
|
77 |
return false;
|
78 |
}
|
79 |
-
return preg_match('/iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini/', $userAgent);
|
80 |
-
}
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
if (is_array($statusArray) && array_key_exists('State', $statusArray)) {
|
88 |
-
return $statusArray['State'];
|
89 |
-
}
|
90 |
-
return null;
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
-
*
|
|
|
95 |
*
|
96 |
-
* @param
|
97 |
-
* @param string $
|
98 |
-
*
|
99 |
-
* @return array|string|null
|
100 |
*/
|
101 |
-
public function
|
102 |
-
|
103 |
-
if (is_array($additionalInformation)) {
|
104 |
-
if (null !== $key) {
|
105 |
-
if (array_key_exists($key, $additionalInformation)) {
|
106 |
-
return $additionalInformation[$key];
|
107 |
-
}
|
108 |
-
} else {
|
109 |
-
return $additionalInformation;
|
110 |
-
}
|
111 |
-
}
|
112 |
-
return null;
|
113 |
-
}
|
114 |
-
|
115 |
-
public function getTransactionReasonCode($transaction) {
|
116 |
-
$statusArray = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
|
117 |
-
if (is_array($statusArray) && array_key_exists('ReasonCode', $statusArray)) {
|
118 |
-
return $statusArray['ReasonCode'];
|
119 |
-
}
|
120 |
-
return null;
|
121 |
-
}
|
122 |
-
|
123 |
-
public function explodeCustomerName($customerName, $emptyValuePlaceholder = 'n/a') {
|
124 |
$explodedName = explode(' ', trim($customerName));
|
125 |
$result = array();
|
126 |
if (count($explodedName) > 1) {
|
127 |
$result['firstname'] = array_shift($explodedName);
|
128 |
$result['lastname'] = implode(' ', $explodedName);
|
129 |
} else {
|
130 |
-
$result['firstname'] = $emptyValuePlaceholder
|
|
|
131 |
$result['lastname'] = reset($explodedName);
|
132 |
}
|
|
|
133 |
return new Varien_Object($result);
|
134 |
}
|
135 |
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
return 'creativestyle/css/amazonpayments.css';
|
139 |
}
|
|
|
|
|
140 |
}
|
141 |
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
if ($this->_getConfig()->isResponsive()) {
|
145 |
return 'creativestyle/css/amazonpayments-responsive-widgets.css';
|
146 |
} else {
|
147 |
return 'creativestyle/css/amazonpayments-widgets.css';
|
148 |
}
|
149 |
}
|
150 |
-
}
|
151 |
|
152 |
-
|
153 |
-
if ($this->_getConfig()->isActive()) {
|
154 |
-
if ($this->_getConfig()->isSandbox()) {
|
155 |
-
return 'creativestyle/apa_checkout.js';
|
156 |
-
}
|
157 |
-
return 'creativestyle/apa_checkout.min.js';
|
158 |
-
}
|
159 |
}
|
160 |
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
return 'prototype/tooltip.js';
|
164 |
}
|
|
|
|
|
165 |
}
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
->toHtml();
|
174 |
}
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
->toHtml();
|
183 |
}
|
184 |
-
|
185 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
|
18 |
/**
|
21 |
* @category Creativestyle
|
22 |
* @package Creativestyle_AmazonPayments
|
23 |
*/
|
24 |
+
class Creativestyle_AmazonPayments_Helper_Data extends Mage_Core_Helper_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Returns instance of Amazon Payments config object
|
28 |
+
*
|
29 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
30 |
+
*/
|
31 |
+
protected function _getConfig()
|
32 |
+
{
|
33 |
return Mage::getSingleton('amazonpayments/config');
|
34 |
}
|
35 |
|
37 |
* Sends an email to the customer if authorization has been declined
|
38 |
*
|
39 |
* @param Mage_Sales_Model_Order $order
|
40 |
+
* @return $this
|
|
|
41 |
*/
|
42 |
+
public function sendAuthorizationDeclinedEmail($order)
|
43 |
+
{
|
44 |
+
/** @var Mage_Core_Model_Translate $translate */
|
45 |
$translate = Mage::getSingleton('core/translate');
|
46 |
$translate->setTranslateInline(false);
|
|
|
47 |
|
48 |
+
/** @var Mage_Core_Model_Email_Template $mailTemplate */
|
49 |
+
$mailTemplate = Mage::getModel('core/email_template');
|
50 |
$mailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $order->getStore()->getId()))
|
51 |
->sendTransactional(
|
52 |
$this->_getConfig()->getAuthorizationDeclinedEmailTemplate($order->getStore()->getId()),
|
68 |
*
|
69 |
* @return array
|
70 |
*/
|
71 |
+
public function getAvailablePaymentMethods()
|
72 |
+
{
|
73 |
return array(
|
74 |
'amazonpayments_advanced',
|
75 |
'amazonpayments_advanced_sandbox'
|
81 |
*
|
82 |
* @return bool
|
83 |
*/
|
84 |
+
public function isMobileDevice()
|
85 |
+
{
|
86 |
$userAgent = Mage::app()->getRequest()->getServer('HTTP_USER_AGENT');
|
87 |
if (empty($userAgent)) {
|
88 |
return false;
|
89 |
}
|
|
|
|
|
90 |
|
91 |
+
return preg_match(
|
92 |
+
'/iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile'
|
93 |
+
.'|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini/',
|
94 |
+
$userAgent
|
95 |
+
);
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* Splits customer name into first and last name
|
100 |
+
* and returns it as an object
|
101 |
*
|
102 |
+
* @param string $customerName
|
103 |
+
* @param string $emptyValuePlaceholder
|
104 |
+
* @return Varien_Object
|
|
|
105 |
*/
|
106 |
+
public function explodeCustomerName($customerName, $emptyValuePlaceholder = 'n/a')
|
107 |
+
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
$explodedName = explode(' ', trim($customerName));
|
109 |
$result = array();
|
110 |
if (count($explodedName) > 1) {
|
111 |
$result['firstname'] = array_shift($explodedName);
|
112 |
$result['lastname'] = implode(' ', $explodedName);
|
113 |
} else {
|
114 |
+
$result['firstname'] = $emptyValuePlaceholder
|
115 |
+
? Mage::helper('amazonpayments')->__($emptyValuePlaceholder) : null;
|
116 |
$result['lastname'] = reset($explodedName);
|
117 |
}
|
118 |
+
|
119 |
return new Varien_Object($result);
|
120 |
}
|
121 |
|
122 |
+
/**
|
123 |
+
* Returns extension common CSS
|
124 |
+
*
|
125 |
+
* @return string|null
|
126 |
+
*/
|
127 |
+
public function getHeadCss()
|
128 |
+
{
|
129 |
+
if ($this->_getConfig()->isPayActive() || $this->_getConfig()->isLoginActive()) {
|
130 |
return 'creativestyle/css/amazonpayments.css';
|
131 |
}
|
132 |
+
|
133 |
+
return null;
|
134 |
}
|
135 |
|
136 |
+
/**
|
137 |
+
* Returns Amazon Pay widgets CSS
|
138 |
+
*
|
139 |
+
* @return string|null
|
140 |
+
*/
|
141 |
+
public function getWidgetsCss()
|
142 |
+
{
|
143 |
+
if ($this->_getConfig()->isPayActive()) {
|
144 |
if ($this->_getConfig()->isResponsive()) {
|
145 |
return 'creativestyle/css/amazonpayments-responsive-widgets.css';
|
146 |
} else {
|
147 |
return 'creativestyle/css/amazonpayments-widgets.css';
|
148 |
}
|
149 |
}
|
|
|
150 |
|
151 |
+
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
|
154 |
+
/**
|
155 |
+
* Returns Prototype Tooltip library JS
|
156 |
+
*
|
157 |
+
* @return string|null
|
158 |
+
*/
|
159 |
+
public function getTooltipJs()
|
160 |
+
{
|
161 |
+
if ($this->_getConfig()->isPayActive()) {
|
162 |
return 'prototype/tooltip.js';
|
163 |
}
|
164 |
+
|
165 |
+
return null;
|
166 |
}
|
167 |
|
168 |
+
/**
|
169 |
+
* Returns Amazon Pay button HTML markup
|
170 |
+
*
|
171 |
+
* @param string|null $buttonType
|
172 |
+
* @param string|null $buttonSize
|
173 |
+
* @param string|null $buttonColor
|
174 |
+
* @param string|null $idSuffix
|
175 |
+
* @return string
|
176 |
+
*/
|
177 |
+
public function getPayWithAmazonButton(
|
178 |
+
$buttonType = null,
|
179 |
+
$buttonSize = null,
|
180 |
+
$buttonColor = null,
|
181 |
+
$idSuffix = null
|
182 |
+
) {
|
183 |
+
/** @var Mage_Core_Model_Layout $layout */
|
184 |
+
$layout = Mage::getSingleton('core/layout');
|
185 |
+
/** @var Creativestyle_AmazonPayments_Block_Pay_Button $block */
|
186 |
+
$block = $layout->createBlock('amazonpayments/pay_button');
|
187 |
+
|
188 |
+
return $block->setButtonType($buttonType)
|
189 |
+
->setButtonSize($buttonSize)
|
190 |
+
->setButtonColor($buttonColor)
|
191 |
+
->setIdSuffix($idSuffix)
|
192 |
->toHtml();
|
193 |
}
|
194 |
|
195 |
+
/**
|
196 |
+
* Returns Login with Amazon button HTML markup
|
197 |
+
*
|
198 |
+
* @param string|null $buttonType
|
199 |
+
* @param string|null $buttonSize
|
200 |
+
* @param string|null $buttonColor
|
201 |
+
* @param string|null $idSuffix
|
202 |
+
* @return string
|
203 |
+
*/
|
204 |
+
public function getLoginWithAmazonButton(
|
205 |
+
$buttonType = null,
|
206 |
+
$buttonSize = null,
|
207 |
+
$buttonColor = null,
|
208 |
+
$idSuffix = null
|
209 |
+
) {
|
210 |
+
/** @var Mage_Core_Model_Layout $layout */
|
211 |
+
$layout = Mage::getSingleton('core/layout');
|
212 |
+
/** @var Creativestyle_AmazonPayments_Block_Login_Button $block */
|
213 |
+
$block = $layout->createBlock('amazonpayments/login_button');
|
214 |
+
|
215 |
+
return $block->setButtonType($buttonType)
|
216 |
+
->setButtonSize($buttonSize)
|
217 |
+
->setButtonColor($buttonColor)
|
218 |
+
->setIdSuffix($idSuffix)
|
219 |
->toHtml();
|
220 |
}
|
|
|
221 |
}
|
app/code/community/Creativestyle/AmazonPayments/Helper/Debug.php
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
|
17 |
/**
|
@@ -20,8 +21,8 @@
|
|
20 |
* @category Creativestyle
|
21 |
* @package Creativestyle_AmazonPayments
|
22 |
*/
|
23 |
-
class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstract
|
24 |
-
|
25 |
/**
|
26 |
* Debug data array
|
27 |
*/
|
@@ -37,12 +38,16 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
37 |
*/
|
38 |
protected $_storeCollection = null;
|
39 |
|
|
|
|
|
|
|
40 |
protected $_configOutputCallbacks = array();
|
41 |
|
42 |
/**
|
43 |
* Constructor, sets necessary callbacks for config options output
|
44 |
*/
|
45 |
-
public function __construct()
|
|
|
46 |
$this->_configOutputCallbacks = array(
|
47 |
'amazonpayments/account/access_key' => array($this, '_validateAccessKey'),
|
48 |
'amazonpayments/account/secret_key' => array($this, '_validateSecretKey'),
|
@@ -60,23 +65,59 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
60 |
/**
|
61 |
* Checks if for given config option callback function shall be used
|
62 |
* On of the purposes of callbacks is to hide the confidential data
|
|
|
|
|
|
|
|
|
63 |
*/
|
64 |
-
protected function _formatConfigValueOutput($key, $value)
|
|
|
65 |
if (array_key_exists($key, $this->_configOutputCallbacks)) {
|
|
|
66 |
return call_user_func_array($this->_configOutputCallbacks[$key], array($value));
|
|
|
67 |
}
|
|
|
68 |
return $value;
|
69 |
}
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
/**
|
72 |
* Gets and returns current timestamp for time-related data
|
73 |
*
|
74 |
* @return int
|
75 |
*/
|
76 |
-
protected function _getCurrentTimestamp()
|
|
|
77 |
if (null === $this->_currentTimestamp) {
|
78 |
$this->_currentTimestamp = Mage::getSingleton('core/date')->gmtTimestamp();
|
79 |
}
|
|
|
80 |
return $this->_currentTimestamp;
|
81 |
}
|
82 |
|
@@ -85,10 +126,12 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
85 |
*
|
86 |
* @return string
|
87 |
*/
|
88 |
-
protected function _getMagentoEdition()
|
89 |
-
|
|
|
90 |
return Mage::getEdition() . ' Edition';
|
91 |
}
|
|
|
92 |
return '';
|
93 |
}
|
94 |
|
@@ -99,7 +142,8 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
99 |
* @param int|string $end
|
100 |
* @return string
|
101 |
*/
|
102 |
-
protected function _getElapsedTime($start, $end)
|
|
|
103 |
if (!($start && $end)) return 'No';
|
104 |
$diff = $end - $start;
|
105 |
$days = (int)($diff / 86400);
|
@@ -119,7 +163,8 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
119 |
* @param string $eventName
|
120 |
* @return array
|
121 |
*/
|
122 |
-
protected function _getEventObservers($eventName)
|
|
|
123 |
$observers = array();
|
124 |
$areas = array(
|
125 |
Mage_Core_Model_App_Area::AREA_GLOBAL,
|
@@ -131,13 +176,16 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
131 |
$eventConfig = Mage::getConfig()->getEventConfig($area, $eventName);
|
132 |
if ($eventConfig) {
|
133 |
foreach ($eventConfig->observers->children() as $obsName => $obsConfig) {
|
134 |
-
$class = Mage::getConfig()->getModelClassName(
|
|
|
|
|
135 |
$method = (string)$obsConfig->method;
|
136 |
$args = implode(', ', (array)$obsConfig->args);
|
137 |
$observers[$area] = $class . '::' . $method . '(' . $args . ')';
|
138 |
}
|
139 |
}
|
140 |
}
|
|
|
141 |
return $observers;
|
142 |
}
|
143 |
|
@@ -146,10 +194,12 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
146 |
*
|
147 |
* @return Mage_Core_Model_Resource_Store_Collection
|
148 |
*/
|
149 |
-
protected function _getStoreCollection()
|
|
|
150 |
if (null === $this->_storeCollection) {
|
151 |
$this->_storeCollection = Mage::getModel('core/store')->getCollection()->load();
|
152 |
}
|
|
|
153 |
return $this->_storeCollection;
|
154 |
}
|
155 |
|
@@ -158,7 +208,8 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
158 |
*
|
159 |
* @return array
|
160 |
*/
|
161 |
-
protected function _getStoreData()
|
|
|
162 |
$stores = array();
|
163 |
$baseUrl = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL);
|
164 |
$secureUrl = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);
|
@@ -166,7 +217,9 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
166 |
$stores['Code'][0] = 'admin';
|
167 |
$stores['Base URL'][0] = sprintf('<a href="%s">%s</a>', $baseUrl, $baseUrl);
|
168 |
$stores['Secure URL'][0] = sprintf('<a href="%s">%s</a>', $secureUrl, $secureUrl);
|
169 |
-
$stores['Use SSL on frontend'][0] = Mage::getStoreConfigFlag(
|
|
|
|
|
170 |
$stores['IPN URL'][0] = false;
|
171 |
$stores['Allowed JavaScript Origin'][0] = false;
|
172 |
$stores['Allowed Return URLs'][0] = false;
|
@@ -177,40 +230,71 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
177 |
$stores['Group ID'][0] = '0';
|
178 |
$stores['Website ID'][0] = '0';
|
179 |
foreach ($this->_getStoreCollection() as $store) {
|
180 |
-
$baseUrl = Mage::getModel('core/url')->setStore($store->getId())->getUrl(
|
181 |
-
'
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
))
|
186 |
-
|
187 |
-
'_current' => false, '_nosid' => true, '_store' => $store->getId()
|
188 |
-
));
|
189 |
-
$allowedJsOrigin = Mage::getModel('core/url')->setStore($store->getId())->getUrl('/', array(
|
190 |
-
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
191 |
-
));
|
192 |
-
$allowedReturnUrls = array(
|
193 |
-
Mage::getModel('core/url')->setStore($store->getId())->getUrl('amazonpayments/advanced_login/redirect', array(
|
194 |
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
195 |
-
)
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
);
|
200 |
$stores['__titles__'][$store->getCode()] = $store->getName();
|
201 |
$stores['Code'][$store->getCode()] = $store->getCode();
|
202 |
$stores['Base URL'][$store->getCode()] = sprintf('<a href="%s">%s</a>', $baseUrl, $baseUrl);
|
203 |
$stores['Secure URL'][$store->getCode()] = sprintf('<a href="%s">%s</a>', $secureUrl, $secureUrl);
|
204 |
-
$stores['Use SSL on frontend'][$store->getCode()] = Mage::getStoreConfigFlag(
|
|
|
|
|
205 |
$stores['IPN URL'][$store->getCode()] = sprintf('<a href="%s">%s</a>', $ipnUrl, $ipnUrl);
|
206 |
-
$stores['Allowed JavaScript Origin'][$store->getCode()] = sprintf(
|
207 |
-
|
208 |
-
|
209 |
-
$stores['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
$stores['Store ID'][$store->getCode()] = $store->getId();
|
211 |
$stores['Group ID'][$store->getCode()] = $store->getGroupId();
|
212 |
$stores['Website ID'][$store->getCode()] = $store->getWebsiteId();
|
213 |
}
|
|
|
214 |
return $stores;
|
215 |
}
|
216 |
|
@@ -219,10 +303,13 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
219 |
*
|
220 |
* @return array
|
221 |
*/
|
222 |
-
protected function _getGeneralDebugData()
|
|
|
223 |
return array(
|
224 |
-
'Amazon Pay extension version' => (string)Mage::getConfig()
|
225 |
-
|
|
|
|
|
226 |
? OffAmazonPaymentsService_Client::APPLICATION_LIBRARY_VERSION
|
227 |
: defined('OffAmazonPayments_OffAmazonPaymentsServiceUtils::APPLICATION_LIBRARY_VERSION')
|
228 |
? OffAmazonPayments_OffAmazonPaymentsServiceUtils::APPLICATION_LIBRARY_VERSION
|
@@ -231,8 +318,10 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
231 |
'PHP version' => PHP_VERSION,
|
232 |
'Suhosin installed' => defined('SUHOSIN_PATCH') || extension_loaded('suhosin'),
|
233 |
'Magento Compiler enabled' => defined('COMPILER_INCLUDE_PATH'),
|
234 |
-
'Amazon User ID attribute present' => Mage::getResourceModel('catalog/eav_attribute')
|
235 |
-
|
|
|
|
|
236 |
);
|
237 |
}
|
238 |
|
@@ -242,7 +331,8 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
242 |
* @param string $configPath
|
243 |
* @return array
|
244 |
*/
|
245 |
-
protected function _getConfigData($configPath)
|
|
|
246 |
$settings = array();
|
247 |
$defaultScopeSettings = Mage::getStoreConfig($configPath);
|
248 |
if ($defaultScopeSettings) {
|
@@ -252,13 +342,18 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
252 |
$keys[] = $key;
|
253 |
$settings[$key][0] = $this->_formatConfigValueOutput($configPath . '/' . $key, $value);
|
254 |
}
|
|
|
255 |
foreach ($this->_getStoreCollection() as $store) {
|
256 |
$settings['__titles__'][$store->getCode()] = $store->getName();
|
257 |
foreach ($keys as $key) {
|
258 |
-
$settings[$key][$store->getCode()] = $this->_formatConfigValueOutput(
|
|
|
|
|
|
|
259 |
}
|
260 |
}
|
261 |
}
|
|
|
262 |
return $settings;
|
263 |
}
|
264 |
|
@@ -267,34 +362,78 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
267 |
*
|
268 |
* @return array
|
269 |
*/
|
270 |
-
protected function _getMagentoGeneralData()
|
|
|
271 |
$settings = array();
|
272 |
$settings['__titles__'][0] = '<em>__default__</em>';
|
273 |
-
$settings['Allow guest checkout'][0] = Mage::getStoreConfigFlag(
|
274 |
-
|
275 |
-
|
276 |
-
$settings['
|
277 |
-
|
278 |
-
|
279 |
-
$settings['
|
280 |
-
|
281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
$settings['Minimal order amount enabled'][0] = Mage::getStoreConfigFlag('sales/minimum_order/active');
|
283 |
-
$settings['Minimal order amount'][0] = Mage::getStoreConfigFlag('sales/minimum_order/active')
|
|
|
284 |
foreach ($this->_getStoreCollection() as $store) {
|
285 |
$settings['__titles__'][$store->getCode()] = $store->getName();
|
286 |
-
$settings['Allow guest checkout'][$store->getCode()] = Mage::getStoreConfigFlag(
|
287 |
-
|
288 |
-
|
289 |
-
$settings['
|
290 |
-
|
291 |
-
|
292 |
-
$settings['
|
293 |
-
|
294 |
-
|
295 |
-
$settings['
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
}
|
|
|
298 |
return $settings;
|
299 |
}
|
300 |
|
@@ -303,7 +442,8 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
303 |
*
|
304 |
* @return array
|
305 |
*/
|
306 |
-
protected function _getCronjobsData()
|
|
|
307 |
$cronjobs = array('__titles__' => array(
|
308 |
'job_code' => 'Job code',
|
309 |
'job_id' => 'Job ID',
|
@@ -315,24 +455,43 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
315 |
'created_at' => 'Created at'
|
316 |
));
|
317 |
$cronSchedule = Mage::getModel('cron/schedule')->getCollection()
|
318 |
-
->addFieldToFilter(
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
->setOrder('job_code', 'ASC')
|
320 |
->setOrder('scheduled_at', 'DESC')
|
321 |
->setOrder('executed_at', 'DESC')
|
322 |
->setOrder('finished_at', 'DESC')
|
323 |
->setOrder('created_at', 'DESC')
|
324 |
->load();
|
325 |
-
|
326 |
foreach ($cronSchedule as $cron) {
|
327 |
$cronjobs[$cron->getId()]['job_code'] = $cron->getJobCode();
|
328 |
$cronjobs[$cron->getId()]['job_id'] = $cron->getId();
|
329 |
$cronjobs[$cron->getId()]['status'] = $cron->getStatus();
|
330 |
$cronjobs[$cron->getId()]['messages'] = $cron->getMessages();
|
331 |
-
$cronjobs[$cron->getId()]['scheduled_at'] =
|
332 |
-
|
333 |
-
|
334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
}
|
|
|
336 |
return $cronjobs;
|
337 |
}
|
338 |
|
@@ -341,13 +500,15 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
341 |
*
|
342 |
* @return array
|
343 |
*/
|
344 |
-
protected function _getEventsData()
|
|
|
345 |
$eventObservers = array();
|
346 |
$events = Mage::getConfig()->getNode('global/creativestyle/amazonpayments/debug/events');
|
347 |
$events = $events ? $events->asArray() : array();
|
348 |
foreach ($events as $eventName => $eventData) {
|
349 |
$eventObservers[$eventName] = $this->_getEventObservers($eventName);
|
350 |
}
|
|
|
351 |
return $eventObservers;
|
352 |
}
|
353 |
|
@@ -356,16 +517,26 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
356 |
*
|
357 |
* @return array
|
358 |
*/
|
359 |
-
protected function _getMagentoExtensionsData()
|
|
|
360 |
$extensions = array();
|
361 |
$modules = Mage::getConfig()->getNode('modules')->asArray();
|
362 |
foreach ($modules as $key => $data) {
|
363 |
-
$extensions[$key] = isset($data['active']) && ($data['active'] == 'false' || !$data['active'])
|
|
|
|
|
364 |
}
|
|
|
365 |
return $extensions;
|
366 |
}
|
367 |
|
368 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
return array(
|
370 |
'cURL' => function_exists('curl_init'),
|
371 |
'PCRE' => function_exists('preg_replace'),
|
@@ -380,7 +551,8 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
380 |
* @param string $accessKey
|
381 |
* @return bool
|
382 |
*/
|
383 |
-
protected function _validateAccessKey($accessKey)
|
|
|
384 |
if (preg_match('/^[a-z0-9]{20}$/i', trim($accessKey))) return true;
|
385 |
return false;
|
386 |
}
|
@@ -391,7 +563,8 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
391 |
* @param string $secretKey
|
392 |
* @return bool
|
393 |
*/
|
394 |
-
protected function _validateSecretKey($secretKey)
|
|
|
395 |
if (preg_match('/\\s{1,}/', trim($secretKey))) return false;
|
396 |
return true;
|
397 |
}
|
@@ -402,7 +575,8 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
402 |
* @param string|int $value
|
403 |
* @return bool
|
404 |
*/
|
405 |
-
protected function _convertToBool($value)
|
|
|
406 |
return (bool)$value;
|
407 |
}
|
408 |
|
@@ -410,7 +584,8 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
410 |
* @param string|null $debugArea
|
411 |
* @return array
|
412 |
*/
|
413 |
-
public function getDebugData($debugArea = null)
|
|
|
414 |
if (null === $this->_debugData) {
|
415 |
$this->_debugData = array(
|
416 |
'type' => 'APA',
|
@@ -431,11 +606,13 @@ class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstrac
|
|
431 |
'php_modules' => $this->_getPhpModulesData()
|
432 |
);
|
433 |
}
|
|
|
434 |
if (null === $debugArea) {
|
435 |
return $this->_debugData;
|
436 |
} else if (array_key_exists($debugArea, $this->_debugData)) {
|
437 |
return $this->_debugData[$debugArea];
|
438 |
}
|
|
|
439 |
return array();
|
440 |
}
|
441 |
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
|
18 |
/**
|
21 |
* @category Creativestyle
|
22 |
* @package Creativestyle_AmazonPayments
|
23 |
*/
|
24 |
+
class Creativestyle_AmazonPayments_Helper_Debug extends Mage_Core_Helper_Abstract
|
25 |
+
{
|
26 |
/**
|
27 |
* Debug data array
|
28 |
*/
|
38 |
*/
|
39 |
protected $_storeCollection = null;
|
40 |
|
41 |
+
/**
|
42 |
+
* @var array
|
43 |
+
*/
|
44 |
protected $_configOutputCallbacks = array();
|
45 |
|
46 |
/**
|
47 |
* Constructor, sets necessary callbacks for config options output
|
48 |
*/
|
49 |
+
public function __construct()
|
50 |
+
{
|
51 |
$this->_configOutputCallbacks = array(
|
52 |
'amazonpayments/account/access_key' => array($this, '_validateAccessKey'),
|
53 |
'amazonpayments/account/secret_key' => array($this, '_validateSecretKey'),
|
65 |
/**
|
66 |
* Checks if for given config option callback function shall be used
|
67 |
* On of the purposes of callbacks is to hide the confidential data
|
68 |
+
*
|
69 |
+
* @param string $key
|
70 |
+
* @param string $value
|
71 |
+
* @return string
|
72 |
*/
|
73 |
+
protected function _formatConfigValueOutput($key, $value)
|
74 |
+
{
|
75 |
if (array_key_exists($key, $this->_configOutputCallbacks)) {
|
76 |
+
// @codingStandardsIgnoreStart
|
77 |
return call_user_func_array($this->_configOutputCallbacks[$key], array($value));
|
78 |
+
// @codingStandardsIgnoreEnd
|
79 |
}
|
80 |
+
|
81 |
return $value;
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* Formats input date into date with timezone offset
|
86 |
+
* Input date must be in GMT timezone
|
87 |
+
*
|
88 |
+
* @param string $format
|
89 |
+
* @param int|string $input date in GMT timezone
|
90 |
+
* @return string
|
91 |
+
*/
|
92 |
+
protected function _formatDate($format, $input)
|
93 |
+
{
|
94 |
+
// @codingStandardsIgnoreStart
|
95 |
+
return Mage::getSingleton('core/date')->date($format, $input);
|
96 |
+
// @codingStandardsIgnoreEnd
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Formats price value
|
101 |
+
*
|
102 |
+
* @param float $value
|
103 |
+
* @return mixed
|
104 |
+
*/
|
105 |
+
protected function _formatCurrency($value)
|
106 |
+
{
|
107 |
+
return Mage::helper('core')->currency($value, true, false);
|
108 |
+
}
|
109 |
+
|
110 |
/**
|
111 |
* Gets and returns current timestamp for time-related data
|
112 |
*
|
113 |
* @return int
|
114 |
*/
|
115 |
+
protected function _getCurrentTimestamp()
|
116 |
+
{
|
117 |
if (null === $this->_currentTimestamp) {
|
118 |
$this->_currentTimestamp = Mage::getSingleton('core/date')->gmtTimestamp();
|
119 |
}
|
120 |
+
|
121 |
return $this->_currentTimestamp;
|
122 |
}
|
123 |
|
126 |
*
|
127 |
* @return string
|
128 |
*/
|
129 |
+
protected function _getMagentoEdition()
|
130 |
+
{
|
131 |
+
if (method_exists('Mage', 'getEdition')) {
|
132 |
return Mage::getEdition() . ' Edition';
|
133 |
}
|
134 |
+
|
135 |
return '';
|
136 |
}
|
137 |
|
142 |
* @param int|string $end
|
143 |
* @return string
|
144 |
*/
|
145 |
+
protected function _getElapsedTime($start, $end)
|
146 |
+
{
|
147 |
if (!($start && $end)) return 'No';
|
148 |
$diff = $end - $start;
|
149 |
$days = (int)($diff / 86400);
|
163 |
* @param string $eventName
|
164 |
* @return array
|
165 |
*/
|
166 |
+
protected function _getEventObservers($eventName)
|
167 |
+
{
|
168 |
$observers = array();
|
169 |
$areas = array(
|
170 |
Mage_Core_Model_App_Area::AREA_GLOBAL,
|
176 |
$eventConfig = Mage::getConfig()->getEventConfig($area, $eventName);
|
177 |
if ($eventConfig) {
|
178 |
foreach ($eventConfig->observers->children() as $obsName => $obsConfig) {
|
179 |
+
$class = Mage::getConfig()->getModelClassName(
|
180 |
+
$obsConfig->class ? (string)$obsConfig->class : $obsConfig->getClassName()
|
181 |
+
);
|
182 |
$method = (string)$obsConfig->method;
|
183 |
$args = implode(', ', (array)$obsConfig->args);
|
184 |
$observers[$area] = $class . '::' . $method . '(' . $args . ')';
|
185 |
}
|
186 |
}
|
187 |
}
|
188 |
+
|
189 |
return $observers;
|
190 |
}
|
191 |
|
194 |
*
|
195 |
* @return Mage_Core_Model_Resource_Store_Collection
|
196 |
*/
|
197 |
+
protected function _getStoreCollection()
|
198 |
+
{
|
199 |
if (null === $this->_storeCollection) {
|
200 |
$this->_storeCollection = Mage::getModel('core/store')->getCollection()->load();
|
201 |
}
|
202 |
+
|
203 |
return $this->_storeCollection;
|
204 |
}
|
205 |
|
208 |
*
|
209 |
* @return array
|
210 |
*/
|
211 |
+
protected function _getStoreData()
|
212 |
+
{
|
213 |
$stores = array();
|
214 |
$baseUrl = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL);
|
215 |
$secureUrl = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);
|
217 |
$stores['Code'][0] = 'admin';
|
218 |
$stores['Base URL'][0] = sprintf('<a href="%s">%s</a>', $baseUrl, $baseUrl);
|
219 |
$stores['Secure URL'][0] = sprintf('<a href="%s">%s</a>', $secureUrl, $secureUrl);
|
220 |
+
$stores['Use SSL on frontend'][0] = Mage::getStoreConfigFlag(
|
221 |
+
Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT
|
222 |
+
);
|
223 |
$stores['IPN URL'][0] = false;
|
224 |
$stores['Allowed JavaScript Origin'][0] = false;
|
225 |
$stores['Allowed Return URLs'][0] = false;
|
230 |
$stores['Group ID'][0] = '0';
|
231 |
$stores['Website ID'][0] = '0';
|
232 |
foreach ($this->_getStoreCollection() as $store) {
|
233 |
+
$baseUrl = Mage::getModel('core/url')->setStore($store->getId())->getUrl(
|
234 |
+
'/', array(
|
235 |
+
'_current' => false, '_nosid' => true, '_store' => $store->getId()
|
236 |
+
)
|
237 |
+
);
|
238 |
+
$secureUrl = Mage::getModel('core/url')->setStore($store->getId())->getUrl(
|
239 |
+
'/', array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
241 |
+
)
|
242 |
+
);
|
243 |
+
$ipnUrl = Mage::getModel('core/url')->setStore($store->getId())->getUrl(
|
244 |
+
'amazonpayments/ipn', array(
|
245 |
+
'_current' => false, '_nosid' => true, '_store' => $store->getId()
|
246 |
+
)
|
247 |
+
);
|
248 |
+
$allowedJsOrigin = Mage::getModel('core/url')->setStore($store->getId())->getUrl(
|
249 |
+
'/', array(
|
250 |
+
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
251 |
+
)
|
252 |
+
);
|
253 |
+
$allowedReturnUrls = array(
|
254 |
+
Mage::getModel('core/url')->setStore($store->getId())->getUrl(
|
255 |
+
'amazonpayments/advanced_login/redirect', array(
|
256 |
+
'_current' => false, '_secure' => true, '_nosid' => true, '_store' => $store->getId()
|
257 |
+
)
|
258 |
+
),
|
259 |
+
Mage::getModel('core/url')->setStore($store->getId())->getUrl(
|
260 |
+
'amazonpayments/advanced_login/redirect', array(
|
261 |
+
'target' => 'checkout',
|
262 |
+
'_current' => false,
|
263 |
+
'_secure' => true,
|
264 |
+
'_nosid' => true,
|
265 |
+
'_store' => $store->getId()
|
266 |
+
)
|
267 |
+
),
|
268 |
);
|
269 |
$stores['__titles__'][$store->getCode()] = $store->getName();
|
270 |
$stores['Code'][$store->getCode()] = $store->getCode();
|
271 |
$stores['Base URL'][$store->getCode()] = sprintf('<a href="%s">%s</a>', $baseUrl, $baseUrl);
|
272 |
$stores['Secure URL'][$store->getCode()] = sprintf('<a href="%s">%s</a>', $secureUrl, $secureUrl);
|
273 |
+
$stores['Use SSL on frontend'][$store->getCode()] = Mage::getStoreConfigFlag(
|
274 |
+
Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT, $store->getId()
|
275 |
+
);
|
276 |
$stores['IPN URL'][$store->getCode()] = sprintf('<a href="%s">%s</a>', $ipnUrl, $ipnUrl);
|
277 |
+
$stores['Allowed JavaScript Origin'][$store->getCode()] = sprintf(
|
278 |
+
'<a href="%s">%s</a>', $allowedJsOrigin, $allowedJsOrigin
|
279 |
+
);
|
280 |
+
$stores['Allowed Return URLs'][$store->getCode()] = implode(
|
281 |
+
"\n", array_map(
|
282 |
+
function ($url) {
|
283 |
+
return sprintf('<a href="%s">%s</a>', $url, $url);
|
284 |
+
}, $allowedReturnUrls
|
285 |
+
)
|
286 |
+
);
|
287 |
+
$stores['Locale'][$store->getCode()] = Mage::getStoreConfig(
|
288 |
+
Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store->getId()
|
289 |
+
);
|
290 |
+
$stores['Timezone'][$store->getCode()] = Mage::getStoreConfig(
|
291 |
+
Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store->getId()
|
292 |
+
);
|
293 |
$stores['Store ID'][$store->getCode()] = $store->getId();
|
294 |
$stores['Group ID'][$store->getCode()] = $store->getGroupId();
|
295 |
$stores['Website ID'][$store->getCode()] = $store->getWebsiteId();
|
296 |
}
|
297 |
+
|
298 |
return $stores;
|
299 |
}
|
300 |
|
303 |
*
|
304 |
* @return array
|
305 |
*/
|
306 |
+
protected function _getGeneralDebugData()
|
307 |
+
{
|
308 |
return array(
|
309 |
+
'Amazon Pay extension version' => (string)Mage::getConfig()
|
310 |
+
->getNode('modules/Creativestyle_AmazonPayments/version'),
|
311 |
+
'Amazon Pay SDK library version'
|
312 |
+
=> defined('OffAmazonPaymentsService_Client::APPLICATION_LIBRARY_VERSION')
|
313 |
? OffAmazonPaymentsService_Client::APPLICATION_LIBRARY_VERSION
|
314 |
: defined('OffAmazonPayments_OffAmazonPaymentsServiceUtils::APPLICATION_LIBRARY_VERSION')
|
315 |
? OffAmazonPayments_OffAmazonPaymentsServiceUtils::APPLICATION_LIBRARY_VERSION
|
318 |
'PHP version' => PHP_VERSION,
|
319 |
'Suhosin installed' => defined('SUHOSIN_PATCH') || extension_loaded('suhosin'),
|
320 |
'Magento Compiler enabled' => defined('COMPILER_INCLUDE_PATH'),
|
321 |
+
'Amazon User ID attribute present' => Mage::getResourceModel('catalog/eav_attribute')
|
322 |
+
->loadByCode('customer', 'amazon_user_id')->getId() ? true : false,
|
323 |
+
'Current timestamp' => $this->_getCurrentTimestamp() . ' <em><'
|
324 |
+
. $this->_formatDate("Y-m-d H:i:s", $this->_getCurrentTimestamp()) . '></em>'
|
325 |
);
|
326 |
}
|
327 |
|
331 |
* @param string $configPath
|
332 |
* @return array
|
333 |
*/
|
334 |
+
protected function _getConfigData($configPath)
|
335 |
+
{
|
336 |
$settings = array();
|
337 |
$defaultScopeSettings = Mage::getStoreConfig($configPath);
|
338 |
if ($defaultScopeSettings) {
|
342 |
$keys[] = $key;
|
343 |
$settings[$key][0] = $this->_formatConfigValueOutput($configPath . '/' . $key, $value);
|
344 |
}
|
345 |
+
|
346 |
foreach ($this->_getStoreCollection() as $store) {
|
347 |
$settings['__titles__'][$store->getCode()] = $store->getName();
|
348 |
foreach ($keys as $key) {
|
349 |
+
$settings[$key][$store->getCode()] = $this->_formatConfigValueOutput(
|
350 |
+
$configPath . '/' . $key,
|
351 |
+
Mage::getStoreConfig($configPath . '/' . $key, $store->getId())
|
352 |
+
);
|
353 |
}
|
354 |
}
|
355 |
}
|
356 |
+
|
357 |
return $settings;
|
358 |
}
|
359 |
|
362 |
*
|
363 |
* @return array
|
364 |
*/
|
365 |
+
protected function _getMagentoGeneralData()
|
366 |
+
{
|
367 |
$settings = array();
|
368 |
$settings['__titles__'][0] = '<em>__default__</em>';
|
369 |
+
$settings['Allow guest checkout'][0] = Mage::getStoreConfigFlag(
|
370 |
+
Mage_Checkout_Helper_Data::XML_PATH_GUEST_CHECKOUT
|
371 |
+
);
|
372 |
+
$settings['Allowed countries'][0] = str_replace(
|
373 |
+
',', ', ', Mage::getStoreConfig('general/country/allow')
|
374 |
+
);
|
375 |
+
$settings['Optional postcode countries'][0] = str_replace(
|
376 |
+
',', ', ', Mage::getStoreConfig('general/country/optional_zip_countries')
|
377 |
+
);
|
378 |
+
$settings['Base currency'][0] = Mage::getStoreConfig(
|
379 |
+
Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE
|
380 |
+
);
|
381 |
+
$settings['Validate REMOTE_ADDR'][0] = Mage::getStoreConfigFlag(
|
382 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_REMOTE_ADDR
|
383 |
+
);
|
384 |
+
$settings['Validate HTTP_VIA'][0] = Mage::getStoreConfigFlag(
|
385 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_HTTP_VIA
|
386 |
+
);
|
387 |
+
$settings['Validate HTTP_X_FORWARDED_FOR'][0] = Mage::getStoreConfigFlag(
|
388 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_X_FORWARDED
|
389 |
+
);
|
390 |
+
$settings['Validate HTTP_USER_AGENT'][0] = Mage::getStoreConfigFlag(
|
391 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_USER_AGENT
|
392 |
+
);
|
393 |
+
$settings['Use SID on frontend'][0] = Mage::getStoreConfigFlag(
|
394 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_FRONTEND_SID
|
395 |
+
);
|
396 |
$settings['Minimal order amount enabled'][0] = Mage::getStoreConfigFlag('sales/minimum_order/active');
|
397 |
+
$settings['Minimal order amount'][0] = Mage::getStoreConfigFlag('sales/minimum_order/active')
|
398 |
+
? $this->_formatCurrency(Mage::getStoreConfig('sales/minimum_order/amount')) : false;
|
399 |
foreach ($this->_getStoreCollection() as $store) {
|
400 |
$settings['__titles__'][$store->getCode()] = $store->getName();
|
401 |
+
$settings['Allow guest checkout'][$store->getCode()] = Mage::getStoreConfigFlag(
|
402 |
+
Mage_Checkout_Helper_Data::XML_PATH_GUEST_CHECKOUT, $store->getId()
|
403 |
+
);
|
404 |
+
$settings['Allowed countries'][$store->getCode()] = str_replace(
|
405 |
+
',', ', ', Mage::getStoreConfig('general/country/allow', $store->getId())
|
406 |
+
);
|
407 |
+
$settings['Optional postcode countries'][$store->getCode()] = str_replace(
|
408 |
+
',', ', ', Mage::getStoreConfig('general/country/optional_zip_countries', $store->getId())
|
409 |
+
);
|
410 |
+
$settings['Base currency'][$store->getCode()] = Mage::getStoreConfig(
|
411 |
+
Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE, $store->getId()
|
412 |
+
);
|
413 |
+
$settings['Validate REMOTE_ADDR'][$store->getCode()] = Mage::getStoreConfigFlag(
|
414 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_REMOTE_ADDR, $store->getId()
|
415 |
+
);
|
416 |
+
$settings['Validate HTTP_VIA'][$store->getCode()] = Mage::getStoreConfigFlag(
|
417 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_HTTP_VIA, $store->getId()
|
418 |
+
);
|
419 |
+
$settings['Validate HTTP_X_FORWARDED_FOR'][$store->getCode()] = Mage::getStoreConfigFlag(
|
420 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_X_FORWARDED, $store->getId()
|
421 |
+
);
|
422 |
+
$settings['Validate HTTP_USER_AGENT'][$store->getCode()] = Mage::getStoreConfigFlag(
|
423 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_USER_AGENT, $store->getId()
|
424 |
+
);
|
425 |
+
$settings['Use SID on frontend'][$store->getCode()] = Mage::getStoreConfigFlag(
|
426 |
+
Mage_Core_Model_Session_Abstract::XML_PATH_USE_FRONTEND_SID, $store->getId()
|
427 |
+
);
|
428 |
+
$settings['Minimal order amount enabled'][$store->getCode()] = Mage::getStoreConfigFlag(
|
429 |
+
'sales/minimum_order/active', $store->getId()
|
430 |
+
);
|
431 |
+
$settings['Minimal order amount'][$store->getCode()] =
|
432 |
+
Mage::getStoreConfigFlag('sales/minimum_order/active', $store->getId())
|
433 |
+
? $this->_formatCurrency(Mage::getStoreConfig('sales/minimum_order/amount', $store->getId()))
|
434 |
+
: false;
|
435 |
}
|
436 |
+
|
437 |
return $settings;
|
438 |
}
|
439 |
|
442 |
*
|
443 |
* @return array
|
444 |
*/
|
445 |
+
protected function _getCronjobsData()
|
446 |
+
{
|
447 |
$cronjobs = array('__titles__' => array(
|
448 |
'job_code' => 'Job code',
|
449 |
'job_id' => 'Job ID',
|
455 |
'created_at' => 'Created at'
|
456 |
));
|
457 |
$cronSchedule = Mage::getModel('cron/schedule')->getCollection()
|
458 |
+
->addFieldToFilter(
|
459 |
+
'job_code',
|
460 |
+
array(
|
461 |
+
'amazonpayments_advanced_log_rotate',
|
462 |
+
'amazonpayments_advanced_data_poll'
|
463 |
+
)
|
464 |
+
)
|
465 |
->setOrder('job_code', 'ASC')
|
466 |
->setOrder('scheduled_at', 'DESC')
|
467 |
->setOrder('executed_at', 'DESC')
|
468 |
->setOrder('finished_at', 'DESC')
|
469 |
->setOrder('created_at', 'DESC')
|
470 |
->load();
|
471 |
+
|
472 |
foreach ($cronSchedule as $cron) {
|
473 |
$cronjobs[$cron->getId()]['job_code'] = $cron->getJobCode();
|
474 |
$cronjobs[$cron->getId()]['job_id'] = $cron->getId();
|
475 |
$cronjobs[$cron->getId()]['status'] = $cron->getStatus();
|
476 |
$cronjobs[$cron->getId()]['messages'] = $cron->getMessages();
|
477 |
+
$cronjobs[$cron->getId()]['scheduled_at'] =
|
478 |
+
($cron->getScheduledAt() && $cron->getScheduledAt() != '0000-00-00 00:00:00')
|
479 |
+
? $this->_formatDate("Y-m-d H:i:s", $cron->getScheduledAt())
|
480 |
+
: '';
|
481 |
+
$cronjobs[$cron->getId()]['executed_at'] =
|
482 |
+
($cron->getExecutedAt() && $cron->getExecutedAt() != '0000-00-00 00:00:00')
|
483 |
+
? $this->_formatDate("Y-m-d H:i:s", $cron->getExecutedAt())
|
484 |
+
: '';
|
485 |
+
$cronjobs[$cron->getId()]['finished_at'] =
|
486 |
+
($cron->getFinishedAt() && $cron->getFinishedAt() != '0000-00-00 00:00:00')
|
487 |
+
? $this->_formatDate("Y-m-d H:i:s", $cron->getFinishedAt())
|
488 |
+
: '';
|
489 |
+
$cronjobs[$cron->getId()]['created_at'] =
|
490 |
+
($cron->getCreatedAt() && $cron->getCreatedAt() != '0000-00-00 00:00:00')
|
491 |
+
? $this->_formatDate("Y-m-d H:i:s", $cron->getCreatedAt())
|
492 |
+
: '';
|
493 |
}
|
494 |
+
|
495 |
return $cronjobs;
|
496 |
}
|
497 |
|
500 |
*
|
501 |
* @return array
|
502 |
*/
|
503 |
+
protected function _getEventsData()
|
504 |
+
{
|
505 |
$eventObservers = array();
|
506 |
$events = Mage::getConfig()->getNode('global/creativestyle/amazonpayments/debug/events');
|
507 |
$events = $events ? $events->asArray() : array();
|
508 |
foreach ($events as $eventName => $eventData) {
|
509 |
$eventObservers[$eventName] = $this->_getEventObservers($eventName);
|
510 |
}
|
511 |
+
|
512 |
return $eventObservers;
|
513 |
}
|
514 |
|
517 |
*
|
518 |
* @return array
|
519 |
*/
|
520 |
+
protected function _getMagentoExtensionsData()
|
521 |
+
{
|
522 |
$extensions = array();
|
523 |
$modules = Mage::getConfig()->getNode('modules')->asArray();
|
524 |
foreach ($modules as $key => $data) {
|
525 |
+
$extensions[$key] = isset($data['active']) && ($data['active'] == 'false' || !$data['active'])
|
526 |
+
? false
|
527 |
+
: (isset($data['version']) && $data['version'] ? $data['version'] : true);
|
528 |
}
|
529 |
+
|
530 |
return $extensions;
|
531 |
}
|
532 |
|
533 |
+
/**
|
534 |
+
* Checks if required PHP modules are present
|
535 |
+
*
|
536 |
+
* @return array
|
537 |
+
*/
|
538 |
+
protected function _getPhpModulesData()
|
539 |
+
{
|
540 |
return array(
|
541 |
'cURL' => function_exists('curl_init'),
|
542 |
'PCRE' => function_exists('preg_replace'),
|
551 |
* @param string $accessKey
|
552 |
* @return bool
|
553 |
*/
|
554 |
+
protected function _validateAccessKey($accessKey)
|
555 |
+
{
|
556 |
if (preg_match('/^[a-z0-9]{20}$/i', trim($accessKey))) return true;
|
557 |
return false;
|
558 |
}
|
563 |
* @param string $secretKey
|
564 |
* @return bool
|
565 |
*/
|
566 |
+
protected function _validateSecretKey($secretKey)
|
567 |
+
{
|
568 |
if (preg_match('/\\s{1,}/', trim($secretKey))) return false;
|
569 |
return true;
|
570 |
}
|
575 |
* @param string|int $value
|
576 |
* @return bool
|
577 |
*/
|
578 |
+
protected function _convertToBool($value)
|
579 |
+
{
|
580 |
return (bool)$value;
|
581 |
}
|
582 |
|
584 |
* @param string|null $debugArea
|
585 |
* @return array
|
586 |
*/
|
587 |
+
public function getDebugData($debugArea = null)
|
588 |
+
{
|
589 |
if (null === $this->_debugData) {
|
590 |
$this->_debugData = array(
|
591 |
'type' => 'APA',
|
606 |
'php_modules' => $this->_getPhpModulesData()
|
607 |
);
|
608 |
}
|
609 |
+
|
610 |
if (null === $debugArea) {
|
611 |
return $this->_debugData;
|
612 |
} else if (array_key_exists($debugArea, $this->_debugData)) {
|
613 |
return $this->_debugData[$debugArea];
|
614 |
}
|
615 |
+
|
616 |
return array();
|
617 |
}
|
618 |
|
app/code/community/Creativestyle/AmazonPayments/Model/Api/Abstract.php
CHANGED
@@ -1,34 +1,60 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
abstract class Creativestyle_AmazonPayments_Model_Api_Abstract
|
17 |
-
|
|
|
|
|
|
|
18 |
protected $_api = null;
|
|
|
|
|
|
|
|
|
19 |
protected $_store = null;
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
return Mage::getSingleton('amazonpayments/config');
|
23 |
}
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return $this->_getConfig()->getMerchantId($this->_store);
|
27 |
}
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
$this->_store = $store;
|
31 |
return $this;
|
32 |
}
|
33 |
-
|
34 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Model_Api_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @var mixed
|
21 |
+
*/
|
22 |
protected $_api = null;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var mixed
|
26 |
+
*/
|
27 |
protected $_store = null;
|
28 |
|
29 |
+
/**
|
30 |
+
* Returns instance of Amazon Payments config object
|
31 |
+
*
|
32 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
33 |
+
*/
|
34 |
+
protected function _getConfig()
|
35 |
+
{
|
36 |
return Mage::getSingleton('amazonpayments/config');
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* Returns Merchant ID for the configured Amazon merchant account
|
41 |
+
*
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function getMerchantId()
|
45 |
+
{
|
46 |
return $this->_getConfig()->getMerchantId($this->_store);
|
47 |
}
|
48 |
|
49 |
+
/**
|
50 |
+
* Sets store view scope for API connection
|
51 |
+
*
|
52 |
+
* @param mixed $store
|
53 |
+
* @return $this
|
54 |
+
*/
|
55 |
+
public function setStore($store = null)
|
56 |
+
{
|
57 |
$this->_store = $store;
|
58 |
return $this;
|
59 |
}
|
|
|
60 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Api/Advanced.php
CHANGED
@@ -1,33 +1,52 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Api_Advanced extends Creativestyle_AmazonPayments_Model_Api_Abstract
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
if (null === $this->_api) {
|
20 |
-
$this->_api = new OffAmazonPaymentsService_Client(
|
|
|
|
|
21 |
}
|
|
|
22 |
return $this->_api;
|
23 |
}
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
$response = $this->_getApi()->getOrderReferenceDetails($request);
|
32 |
if ($response->isSetGetOrderReferenceDetailsResult()) {
|
33 |
$result = $response->getGetOrderReferenceDetailsResult();
|
@@ -35,26 +54,46 @@ class Creativestyle_AmazonPayments_Model_Api_Advanced extends Creativestyle_Amaz
|
|
35 |
return $result->getOrderReferenceDetails();
|
36 |
}
|
37 |
}
|
|
|
38 |
return null;
|
39 |
}
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
)
|
56 |
)
|
57 |
-
)
|
|
|
58 |
$response = $this->_getApi()->setOrderReferenceDetails($request);
|
59 |
if ($response->isSetSetOrderReferenceDetailsResult()) {
|
60 |
$result = $response->getSetOrderReferenceDetailsResult();
|
@@ -62,71 +101,120 @@ class Creativestyle_AmazonPayments_Model_Api_Advanced extends Creativestyle_Amaz
|
|
62 |
return $result->getOrderReferenceDetails();
|
63 |
}
|
64 |
}
|
|
|
65 |
return null;
|
66 |
}
|
67 |
|
68 |
-
public function confirmOrderReference($orderReferenceId)
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
73 |
$response = $this->_getApi()->confirmOrderReference($request);
|
74 |
return $response;
|
75 |
}
|
76 |
|
77 |
-
public function cancelOrderReference($orderReferenceId)
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
82 |
$response = $this->_getApi()->cancelOrderReference($request);
|
83 |
return $response;
|
84 |
}
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
if (null !== $closureReason) {
|
92 |
$request->setClosureReason($closureReason);
|
93 |
}
|
|
|
94 |
$response = $this->_getApi()->closeOrderReference($request);
|
95 |
return $response;
|
96 |
}
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
if (null !== $sellerAuthorizationNote) {
|
110 |
$request->setSellerAuthorizationNote($sellerAuthorizationNote);
|
111 |
}
|
|
|
112 |
if (null !== $transactionTimeout) {
|
113 |
$request->setTransactionTimeout($transactionTimeout);
|
114 |
}
|
|
|
115 |
$response = $this->_getApi()->authorize($request);
|
116 |
if ($response->isSetAuthorizeResult()) {
|
117 |
$result = $response->getAuthorizeResult();
|
118 |
if ($result->isSetAuthorizationDetails()) {
|
119 |
-
|
|
|
120 |
}
|
121 |
}
|
|
|
122 |
return null;
|
123 |
}
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
$response = $this->_getApi()->getAuthorizationDetails($request);
|
131 |
if ($response->isSetGetAuthorizationDetailsResult()) {
|
132 |
$result = $response->getGetAuthorizationDetailsResult();
|
@@ -134,22 +222,40 @@ class Creativestyle_AmazonPayments_Model_Api_Advanced extends Creativestyle_Amaz
|
|
134 |
return $result->getAuthorizationDetails();
|
135 |
}
|
136 |
}
|
|
|
137 |
return null;
|
138 |
}
|
139 |
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
)
|
149 |
-
)
|
150 |
if (null !== $sellerCaptureNote) {
|
151 |
$request->setSellerCaptureNote($sellerCaptureNote);
|
152 |
}
|
|
|
153 |
$response = $this->_getApi()->capture($request);
|
154 |
if ($response->isSetCaptureResult()) {
|
155 |
$result = $response->getCaptureResult();
|
@@ -157,14 +263,19 @@ class Creativestyle_AmazonPayments_Model_Api_Advanced extends Creativestyle_Amaz
|
|
157 |
return $result->getCaptureDetails();
|
158 |
}
|
159 |
}
|
|
|
160 |
return null;
|
161 |
}
|
162 |
|
163 |
-
public function getCaptureDetails($captureId)
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
|
|
|
|
|
|
168 |
$response = $this->_getApi()->getCaptureDetails($request);
|
169 |
if ($response->isSetGetCaptureDetailsResult()) {
|
170 |
$result = $response->getGetCaptureDetailsResult();
|
@@ -172,22 +283,40 @@ class Creativestyle_AmazonPayments_Model_Api_Advanced extends Creativestyle_Amaz
|
|
172 |
return $result->getCaptureDetails();
|
173 |
}
|
174 |
}
|
|
|
175 |
return null;
|
176 |
}
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
)
|
187 |
-
)
|
188 |
if (null !== $sellerRefundNote) {
|
189 |
$request->setSellerRefundNote($sellerRefundNote);
|
190 |
}
|
|
|
191 |
$response = $this->_getApi()->refund($request);
|
192 |
if ($response->isSetRefundResult()) {
|
193 |
$result = $response->getRefundResult();
|
@@ -195,14 +324,23 @@ class Creativestyle_AmazonPayments_Model_Api_Advanced extends Creativestyle_Amaz
|
|
195 |
return $result->getRefundDetails();
|
196 |
}
|
197 |
}
|
|
|
198 |
return null;
|
199 |
}
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
$response = $this->_getApi()->getRefundDetails($request);
|
207 |
if ($response->isSetGetRefundDetailsResult()) {
|
208 |
$result = $response->getGetRefundDetailsResult();
|
@@ -210,7 +348,7 @@ class Creativestyle_AmazonPayments_Model_Api_Advanced extends Creativestyle_Amaz
|
|
210 |
return $result->getRefundDetails();
|
211 |
}
|
212 |
}
|
|
|
213 |
return null;
|
214 |
}
|
215 |
-
|
216 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Api_Advanced extends Creativestyle_AmazonPayments_Model_Api_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Returns Amazon Pay API client instance
|
21 |
+
*
|
22 |
+
* @return OffAmazonPaymentsService_Client
|
23 |
+
*/
|
24 |
+
protected function _getApi()
|
25 |
+
{
|
26 |
if (null === $this->_api) {
|
27 |
+
$this->_api = new OffAmazonPaymentsService_Client(
|
28 |
+
$this->_getConfig()->getApiConnectionParams($this->_store)
|
29 |
+
);
|
30 |
}
|
31 |
+
|
32 |
return $this->_api;
|
33 |
}
|
34 |
|
35 |
+
/**
|
36 |
+
* @param string $orderReferenceId
|
37 |
+
* @param string|null $accessToken
|
38 |
+
* @return OffAmazonPaymentsService_Model_OrderReferenceDetails|null
|
39 |
+
*/
|
40 |
+
public function getOrderReferenceDetails($orderReferenceId, $accessToken = null)
|
41 |
+
{
|
42 |
+
$request = new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest(
|
43 |
+
array(
|
44 |
+
'SellerId' => $this->getMerchantId(),
|
45 |
+
'AmazonOrderReferenceId' => $orderReferenceId,
|
46 |
+
'AddressConsentToken' => $accessToken
|
47 |
+
)
|
48 |
+
);
|
49 |
+
|
50 |
$response = $this->_getApi()->getOrderReferenceDetails($request);
|
51 |
if ($response->isSetGetOrderReferenceDetailsResult()) {
|
52 |
$result = $response->getGetOrderReferenceDetailsResult();
|
54 |
return $result->getOrderReferenceDetails();
|
55 |
}
|
56 |
}
|
57 |
+
|
58 |
return null;
|
59 |
}
|
60 |
|
61 |
+
/**
|
62 |
+
* @param float $orderAmount
|
63 |
+
* @param string $orderCurrency
|
64 |
+
* @param string $orderReferenceId
|
65 |
+
* @param string|null $magentoOrderId
|
66 |
+
* @param string|null $storeName
|
67 |
+
* @return null|OffAmazonPaymentsService_Model_OrderReferenceDetails
|
68 |
+
*/
|
69 |
+
public function setOrderReferenceDetails(
|
70 |
+
$orderAmount,
|
71 |
+
$orderCurrency,
|
72 |
+
$orderReferenceId,
|
73 |
+
$magentoOrderId = null,
|
74 |
+
$storeName = null
|
75 |
+
) {
|
76 |
+
$request = new OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest(
|
77 |
+
array(
|
78 |
+
'SellerId' => $this->getMerchantId(),
|
79 |
+
'AmazonOrderReferenceId' => $orderReferenceId,
|
80 |
+
'OrderReferenceAttributes' => array(
|
81 |
+
'PlatformId' => 'AIOVPYYF70KB5',
|
82 |
+
'OrderTotal' => array(
|
83 |
+
'Amount' => $orderAmount,
|
84 |
+
'CurrencyCode' => $orderCurrency
|
85 |
+
),
|
86 |
+
'SellerOrderAttributes' => array(
|
87 |
+
'SellerOrderId' => $magentoOrderId ? $magentoOrderId : null,
|
88 |
+
'StoreName' => $storeName ? $storeName : null,
|
89 |
+
'CustomInformation' => 'Created by Creativestyle_AmazonPayments/'
|
90 |
+
. (string)Mage::getConfig()->getNode('modules/Creativestyle_AmazonPayments/version')
|
91 |
+
. ' (Platform=Magento/' . trim(Mage::getVersion()) . ')'
|
92 |
+
)
|
93 |
)
|
94 |
)
|
95 |
+
);
|
96 |
+
|
97 |
$response = $this->_getApi()->setOrderReferenceDetails($request);
|
98 |
if ($response->isSetSetOrderReferenceDetailsResult()) {
|
99 |
$result = $response->getSetOrderReferenceDetailsResult();
|
101 |
return $result->getOrderReferenceDetails();
|
102 |
}
|
103 |
}
|
104 |
+
|
105 |
return null;
|
106 |
}
|
107 |
|
108 |
+
public function confirmOrderReference($orderReferenceId)
|
109 |
+
{
|
110 |
+
$request = new OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest(
|
111 |
+
array(
|
112 |
+
'SellerId' => $this->getMerchantId(),
|
113 |
+
'AmazonOrderReferenceId' => $orderReferenceId
|
114 |
+
)
|
115 |
+
);
|
116 |
$response = $this->_getApi()->confirmOrderReference($request);
|
117 |
return $response;
|
118 |
}
|
119 |
|
120 |
+
public function cancelOrderReference($orderReferenceId)
|
121 |
+
{
|
122 |
+
$request = new OffAmazonPaymentsService_Model_CancelOrderReferenceRequest(
|
123 |
+
array(
|
124 |
+
'SellerId' => $this->getMerchantId(),
|
125 |
+
'AmazonOrderReferenceId' => $orderReferenceId
|
126 |
+
)
|
127 |
+
);
|
128 |
$response = $this->_getApi()->cancelOrderReference($request);
|
129 |
return $response;
|
130 |
}
|
131 |
|
132 |
+
/**
|
133 |
+
* @param string $orderReferenceId
|
134 |
+
* @param string|null $closureReason
|
135 |
+
* @return OffAmazonPaymentsService_Model_CloseOrderReferenceResponse
|
136 |
+
*/
|
137 |
+
public function closeOrderReference($orderReferenceId, $closureReason = null)
|
138 |
+
{
|
139 |
+
$request = new OffAmazonPaymentsService_Model_CloseOrderReferenceRequest(
|
140 |
+
array(
|
141 |
+
'SellerId' => $this->getMerchantId(),
|
142 |
+
'AmazonOrderReferenceId' => $orderReferenceId,
|
143 |
+
)
|
144 |
+
);
|
145 |
if (null !== $closureReason) {
|
146 |
$request->setClosureReason($closureReason);
|
147 |
}
|
148 |
+
|
149 |
$response = $this->_getApi()->closeOrderReference($request);
|
150 |
return $response;
|
151 |
}
|
152 |
|
153 |
+
/**
|
154 |
+
* @param float $authorizationAmount
|
155 |
+
* @param string $authorizationCurrency
|
156 |
+
* @param string $authorizationReferenceId
|
157 |
+
* @param string $orderReferenceId
|
158 |
+
* @param int|null $transactionTimeout
|
159 |
+
* @param bool $captureNow
|
160 |
+
* @param string|null $sellerAuthorizationNote
|
161 |
+
* @return OffAmazonPaymentsService_Model_AuthorizationDetails|null
|
162 |
+
*/
|
163 |
+
public function authorize(
|
164 |
+
$authorizationAmount,
|
165 |
+
$authorizationCurrency,
|
166 |
+
$authorizationReferenceId,
|
167 |
+
$orderReferenceId,
|
168 |
+
$transactionTimeout = null,
|
169 |
+
$captureNow = false,
|
170 |
+
$sellerAuthorizationNote = null
|
171 |
+
) {
|
172 |
+
$request = new OffAmazonPaymentsService_Model_AuthorizeRequest(
|
173 |
+
array(
|
174 |
+
'SellerId' => $this->getMerchantId(),
|
175 |
+
'AmazonOrderReferenceId' => $orderReferenceId,
|
176 |
+
'AuthorizationReferenceId' => $authorizationReferenceId,
|
177 |
+
'AuthorizationAmount' => array(
|
178 |
+
'Amount' => $authorizationAmount,
|
179 |
+
'CurrencyCode' => $authorizationCurrency
|
180 |
+
),
|
181 |
+
'CaptureNow' => $captureNow
|
182 |
+
)
|
183 |
+
);
|
184 |
+
|
185 |
if (null !== $sellerAuthorizationNote) {
|
186 |
$request->setSellerAuthorizationNote($sellerAuthorizationNote);
|
187 |
}
|
188 |
+
|
189 |
if (null !== $transactionTimeout) {
|
190 |
$request->setTransactionTimeout($transactionTimeout);
|
191 |
}
|
192 |
+
|
193 |
$response = $this->_getApi()->authorize($request);
|
194 |
if ($response->isSetAuthorizeResult()) {
|
195 |
$result = $response->getAuthorizeResult();
|
196 |
if ($result->isSetAuthorizationDetails()) {
|
197 |
+
$resp = $result->getAuthorizationDetails();
|
198 |
+
return $resp;
|
199 |
}
|
200 |
}
|
201 |
+
|
202 |
return null;
|
203 |
}
|
204 |
|
205 |
+
/**
|
206 |
+
* @param string $authorizationId
|
207 |
+
* @return null|OffAmazonPaymentsService_Model_AuthorizationDetails
|
208 |
+
*/
|
209 |
+
public function getAuthorizationDetails($authorizationId)
|
210 |
+
{
|
211 |
+
$request = new OffAmazonPaymentsService_Model_GetAuthorizationDetailsRequest(
|
212 |
+
array(
|
213 |
+
'SellerId' => $this->getMerchantId(),
|
214 |
+
'AmazonAuthorizationId' => $authorizationId
|
215 |
+
)
|
216 |
+
);
|
217 |
+
|
218 |
$response = $this->_getApi()->getAuthorizationDetails($request);
|
219 |
if ($response->isSetGetAuthorizationDetailsResult()) {
|
220 |
$result = $response->getGetAuthorizationDetailsResult();
|
222 |
return $result->getAuthorizationDetails();
|
223 |
}
|
224 |
}
|
225 |
+
|
226 |
return null;
|
227 |
}
|
228 |
|
229 |
+
/**
|
230 |
+
* @param float $captureAmount
|
231 |
+
* @param string $captureCurrency
|
232 |
+
* @param string $captureReferenceId
|
233 |
+
* @param string $authParentId
|
234 |
+
* @param string|null $sellerCaptureNote
|
235 |
+
* @return null|OffAmazonPaymentsService_Model_CaptureDetails
|
236 |
+
*/
|
237 |
+
public function capture(
|
238 |
+
$captureAmount,
|
239 |
+
$captureCurrency,
|
240 |
+
$captureReferenceId,
|
241 |
+
$authParentId,
|
242 |
+
$sellerCaptureNote = null
|
243 |
+
) {
|
244 |
+
$request = new OffAmazonPaymentsService_Model_CaptureRequest(
|
245 |
+
array(
|
246 |
+
'SellerId' => $this->getMerchantId(),
|
247 |
+
'AmazonAuthorizationId' => $authParentId,
|
248 |
+
'CaptureReferenceId' => $captureReferenceId,
|
249 |
+
'CaptureAmount' => array(
|
250 |
+
'Amount' => $captureAmount,
|
251 |
+
'CurrencyCode' => $captureCurrency
|
252 |
+
)
|
253 |
)
|
254 |
+
);
|
255 |
if (null !== $sellerCaptureNote) {
|
256 |
$request->setSellerCaptureNote($sellerCaptureNote);
|
257 |
}
|
258 |
+
|
259 |
$response = $this->_getApi()->capture($request);
|
260 |
if ($response->isSetCaptureResult()) {
|
261 |
$result = $response->getCaptureResult();
|
263 |
return $result->getCaptureDetails();
|
264 |
}
|
265 |
}
|
266 |
+
|
267 |
return null;
|
268 |
}
|
269 |
|
270 |
+
public function getCaptureDetails($captureId)
|
271 |
+
{
|
272 |
+
$request = new OffAmazonPaymentsService_Model_GetCaptureDetailsRequest(
|
273 |
+
array(
|
274 |
+
'SellerId' => $this->getMerchantId(),
|
275 |
+
'AmazonCaptureId' => $captureId
|
276 |
+
)
|
277 |
+
);
|
278 |
+
|
279 |
$response = $this->_getApi()->getCaptureDetails($request);
|
280 |
if ($response->isSetGetCaptureDetailsResult()) {
|
281 |
$result = $response->getGetCaptureDetailsResult();
|
283 |
return $result->getCaptureDetails();
|
284 |
}
|
285 |
}
|
286 |
+
|
287 |
return null;
|
288 |
}
|
289 |
|
290 |
+
/**
|
291 |
+
* @param float $refundAmount
|
292 |
+
* @param string $refundCurrency
|
293 |
+
* @param string $refundReferenceId
|
294 |
+
* @param string $captureParentId
|
295 |
+
* @param string|null $sellerRefundNote
|
296 |
+
* @return null|OffAmazonPaymentsService_Model_RefundDetails
|
297 |
+
*/
|
298 |
+
public function refund(
|
299 |
+
$refundAmount,
|
300 |
+
$refundCurrency,
|
301 |
+
$refundReferenceId,
|
302 |
+
$captureParentId,
|
303 |
+
$sellerRefundNote = null
|
304 |
+
) {
|
305 |
+
$request = new OffAmazonPaymentsService_Model_RefundRequest(
|
306 |
+
array(
|
307 |
+
'SellerId' => $this->getMerchantId(),
|
308 |
+
'AmazonCaptureId' => $captureParentId,
|
309 |
+
'RefundReferenceId' => $refundReferenceId,
|
310 |
+
'RefundAmount' => array(
|
311 |
+
'Amount' => $refundAmount,
|
312 |
+
'CurrencyCode' => $refundCurrency
|
313 |
+
)
|
314 |
)
|
315 |
+
);
|
316 |
if (null !== $sellerRefundNote) {
|
317 |
$request->setSellerRefundNote($sellerRefundNote);
|
318 |
}
|
319 |
+
|
320 |
$response = $this->_getApi()->refund($request);
|
321 |
if ($response->isSetRefundResult()) {
|
322 |
$result = $response->getRefundResult();
|
324 |
return $result->getRefundDetails();
|
325 |
}
|
326 |
}
|
327 |
+
|
328 |
return null;
|
329 |
}
|
330 |
|
331 |
+
/**
|
332 |
+
* @param string $refundId
|
333 |
+
* @return null|OffAmazonPaymentsService_Model_RefundDetails
|
334 |
+
*/
|
335 |
+
public function getRefundDetails($refundId)
|
336 |
+
{
|
337 |
+
$request = new OffAmazonPaymentsService_Model_GetRefundDetailsRequest(
|
338 |
+
array(
|
339 |
+
'SellerId' => $this->getMerchantId(),
|
340 |
+
'AmazonRefundId' => $refundId
|
341 |
+
)
|
342 |
+
);
|
343 |
+
|
344 |
$response = $this->_getApi()->getRefundDetails($request);
|
345 |
if ($response->isSetGetRefundDetailsResult()) {
|
346 |
$result = $response->getGetRefundDetailsResult();
|
348 |
return $result->getRefundDetails();
|
349 |
}
|
350 |
}
|
351 |
+
|
352 |
return null;
|
353 |
}
|
|
|
354 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Api/Ipn.php
CHANGED
@@ -1,34 +1,161 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Api_Ipn extends Creativestyle_AmazonPayments_Model_Api_Abstract
|
17 |
-
|
18 |
const NOTIFICATION_TYPE_ORDER_REFERENCE = 'OrderReferenceNotification';
|
19 |
const NOTIFICATION_TYPE_AUTHORIZATION = 'AuthorizationNotification';
|
20 |
const NOTIFICATION_TYPE_CAPTURE = 'CaptureNotification';
|
21 |
const NOTIFICATION_TYPE_REFUND = 'RefundNotification';
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
if (null === $this->_api) {
|
25 |
-
$this->_api = new OffAmazonPaymentsNotifications_Client(
|
|
|
|
|
26 |
}
|
|
|
27 |
return $this->_api;
|
28 |
}
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
return $this->_getApi()->parseRawMessage($headers, $body);
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Api_Ipn extends Creativestyle_AmazonPayments_Model_Api_Abstract
|
18 |
+
{
|
19 |
const NOTIFICATION_TYPE_ORDER_REFERENCE = 'OrderReferenceNotification';
|
20 |
const NOTIFICATION_TYPE_AUTHORIZATION = 'AuthorizationNotification';
|
21 |
const NOTIFICATION_TYPE_CAPTURE = 'CaptureNotification';
|
22 |
const NOTIFICATION_TYPE_REFUND = 'RefundNotification';
|
23 |
|
24 |
+
/**
|
25 |
+
* @return OffAmazonPaymentsNotifications_Client
|
26 |
+
*/
|
27 |
+
protected function _getApi()
|
28 |
+
{
|
29 |
if (null === $this->_api) {
|
30 |
+
$this->_api = new OffAmazonPaymentsNotifications_Client(
|
31 |
+
$this->_getConfig()->getApiConnectionParams($this->_store)
|
32 |
+
);
|
33 |
}
|
34 |
+
|
35 |
return $this->_api;
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
+
* Extracts transaction data from IPN notification
|
40 |
+
*
|
41 |
+
* @param OffAmazonPaymentsNotifications_Model_NotificationImpl $notification
|
42 |
+
* @return array
|
43 |
+
* @throws Creativestyle_AmazonPayments_Exception
|
44 |
+
*/
|
45 |
+
protected function _getTransactionDetailsFromNotification($notification)
|
46 |
+
{
|
47 |
+
switch ($notification->getNotificationType()) {
|
48 |
+
case self::NOTIFICATION_TYPE_ORDER_REFERENCE:
|
49 |
+
/** @var OffAmazonPaymentsNotifications_Model_OrderReferenceNotification $notification */
|
50 |
+
if ($notification->isSetOrderReference()) {
|
51 |
+
return array(null, $notification->getOrderReference()->getAmazonOrderReferenceId());
|
52 |
+
}
|
53 |
+
break;
|
54 |
+
case self::NOTIFICATION_TYPE_AUTHORIZATION:
|
55 |
+
/** @var OffAmazonPaymentsNotifications_Model_AuthorizationNotification $notification */
|
56 |
+
if ($notification->isSetAuthorizationDetails()) {
|
57 |
+
return array(null, $notification->getAuthorizationDetails()->getAmazonAuthorizationId());
|
58 |
+
}
|
59 |
+
break;
|
60 |
+
case self::NOTIFICATION_TYPE_CAPTURE:
|
61 |
+
/** @var OffAmazonPaymentsNotifications_Model_CaptureNotification $notification */
|
62 |
+
if ($notification->isSetCaptureDetails()) {
|
63 |
+
return array(
|
64 |
+
$notification->getCaptureDetails(),
|
65 |
+
$notification->getCaptureDetails()->getAmazonCaptureId()
|
66 |
+
);
|
67 |
+
}
|
68 |
+
break;
|
69 |
+
case self::NOTIFICATION_TYPE_REFUND:
|
70 |
+
/** @var OffAmazonPaymentsNotifications_Model_RefundNotification $notification */
|
71 |
+
if ($notification->isSetRefundDetails()) {
|
72 |
+
return array(
|
73 |
+
$notification->getRefundDetails(),
|
74 |
+
$notification->getRefundDetails()->getAmazonRefundId()
|
75 |
+
);
|
76 |
+
}
|
77 |
+
break;
|
78 |
+
default:
|
79 |
+
throw new Creativestyle_AmazonPayments_Exception('Unknown IPN notification type', 500);
|
80 |
+
}
|
81 |
+
|
82 |
+
throw new Creativestyle_AmazonPayments_Exception(
|
83 |
+
sprintf('Invalid IPN %s data', $notification->getNotificationType()),
|
84 |
+
400
|
85 |
+
);
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Returns order instance for transaction of given ID
|
90 |
+
*
|
91 |
+
* @param string $transactionId
|
92 |
+
* @return int
|
93 |
+
* @throws Creativestyle_AmazonPayments_Exception_TransactionNotFound
|
94 |
+
*/
|
95 |
+
protected function _lookupOrderIdByTransactionId($transactionId)
|
96 |
+
{
|
97 |
+
/** @var Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection $transactionCollection */
|
98 |
+
$transactionCollection = Mage::getModel('sales/order_payment_transaction')
|
99 |
+
->getCollection()
|
100 |
+
->addFieldToFilter('txn_id', $transactionId)
|
101 |
+
->setPageSize(1)
|
102 |
+
->setCurPage(1);
|
103 |
+
|
104 |
+
foreach ($transactionCollection as $transaction) {
|
105 |
+
return (int)$transaction->getOrderId();
|
106 |
+
}
|
107 |
+
|
108 |
+
throw new Creativestyle_AmazonPayments_Exception_TransactionNotFound($transactionId);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @param $transactionId
|
113 |
+
* @return Mage_Sales_Model_Order_Payment
|
114 |
+
* @throws Creativestyle_AmazonPayments_Exception
|
115 |
+
*/
|
116 |
+
protected function _lookupPaymentByTransactionId($transactionId)
|
117 |
+
{
|
118 |
+
$order = Mage::getModel('sales/order')->load($this->_lookupOrderIdByTransactionId($transactionId));
|
119 |
+
if ($order->getId()) {
|
120 |
+
return $order->getPayment();
|
121 |
+
}
|
122 |
+
|
123 |
+
throw new Creativestyle_AmazonPayments_Exception('Order for the payment transaction not found', 500);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Converts a http POST body and headers into a notification object
|
128 |
+
*
|
129 |
+
* @param array $headers
|
130 |
+
* @param string $body
|
131 |
+
* @return OffAmazonPaymentsNotifications_Model_NotificationImpl
|
132 |
+
*/
|
133 |
+
public function parseMessage($headers, $body)
|
134 |
+
{
|
135 |
return $this->_getApi()->parseRawMessage($headers, $body);
|
136 |
}
|
137 |
|
138 |
+
/**
|
139 |
+
* Process notification object and updates corresponding sales entities
|
140 |
+
*
|
141 |
+
* @param OffAmazonPaymentsNotifications_Model_NotificationImpl $notification
|
142 |
+
* @return string|null
|
143 |
+
* @throws Creativestyle_AmazonPayments_Exception
|
144 |
+
*/
|
145 |
+
public function processNotification($notification)
|
146 |
+
{
|
147 |
+
if ($notification) {
|
148 |
+
list($transactionDetails, $transactionId) = $this->_getTransactionDetailsFromNotification($notification);
|
149 |
+
$payment = $this->_lookupPaymentByTransactionId($transactionId);
|
150 |
+
$transaction = $payment->lookupTransaction($transactionId);
|
151 |
+
$payment->getMethodInstance()
|
152 |
+
->importTransactionDetails($payment, $transaction, new Varien_Object(), $transactionDetails);
|
153 |
+
$payment->getOrder()
|
154 |
+
->addRelatedObject($transaction)
|
155 |
+
->save();
|
156 |
+
return $transactionId;
|
157 |
+
}
|
158 |
+
|
159 |
+
throw new Creativestyle_AmazonPayments_Exception('Invalid IPN notification data', 400);
|
160 |
+
}
|
161 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Api/Login.php
CHANGED
@@ -1,29 +1,36 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Api_Login extends Creativestyle_AmazonPayments_Model_Api_Abstract
|
|
|
17 |
|
18 |
-
protected function _initApi($path, $params = null)
|
|
|
19 |
$url = trim($this->_getConfig()->getLoginApiUrl($this->_store), '/') . '/' . vsprintf($path, $params);
|
|
|
20 |
$this->_api = curl_init($url);
|
21 |
curl_setopt($this->_api, CURLOPT_RETURNTRANSFER, true);
|
|
|
22 |
return $this;
|
23 |
}
|
24 |
|
25 |
-
protected function _call()
|
|
|
26 |
if (null !== $this->_api) {
|
|
|
27 |
$response = curl_exec($this->_api);
|
28 |
|
29 |
if ($response === false) {
|
@@ -38,36 +45,50 @@ class Creativestyle_AmazonPayments_Model_Api_Login extends Creativestyle_AmazonP
|
|
38 |
curl_close($this->_api);
|
39 |
$this->_api = null;
|
40 |
if ($responseData->getError()) {
|
41 |
-
throw new Creativestyle_AmazonPayments_Exception(
|
|
|
|
|
|
|
|
|
42 |
}
|
|
|
|
|
43 |
return $responseData;
|
44 |
}
|
|
|
45 |
return null;
|
46 |
}
|
47 |
|
48 |
-
protected function _setAuthorizationHeader($header)
|
|
|
49 |
if (null !== $this->_api) {
|
|
|
50 |
curl_setopt($this->_api, CURLOPT_HTTPHEADER, array('Authorization: bearer ' . $header));
|
|
|
51 |
}
|
|
|
52 |
return $this;
|
53 |
}
|
54 |
|
55 |
-
protected function _processApiResponse($response)
|
|
|
56 |
if ($response !== false) {
|
57 |
$responseData = json_decode($response, true);
|
58 |
if (!empty($responseData)) {
|
59 |
return new Varien_Object($responseData);
|
60 |
}
|
61 |
}
|
|
|
62 |
return null;
|
63 |
}
|
64 |
|
65 |
-
public function getTokenInfo($accessToken)
|
|
|
66 |
return $this->_initApi('auth/o2/tokeninfo?access_token=%s', array(urlencode($accessToken)))->_call();
|
67 |
}
|
68 |
|
69 |
-
public function getUserProfile($accessToken)
|
|
|
70 |
return $this->_initApi('user/profile')->_setAuthorizationHeader($accessToken)->_call();
|
71 |
}
|
72 |
-
|
73 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Api_Login extends Creativestyle_AmazonPayments_Model_Api_Abstract
|
18 |
+
{
|
19 |
|
20 |
+
protected function _initApi($path, $params = null)
|
21 |
+
{
|
22 |
$url = trim($this->_getConfig()->getLoginApiUrl($this->_store), '/') . '/' . vsprintf($path, $params);
|
23 |
+
// @codingStandardsIgnoreStart
|
24 |
$this->_api = curl_init($url);
|
25 |
curl_setopt($this->_api, CURLOPT_RETURNTRANSFER, true);
|
26 |
+
// @codingStandardsIgnoreEnd
|
27 |
return $this;
|
28 |
}
|
29 |
|
30 |
+
protected function _call()
|
31 |
+
{
|
32 |
if (null !== $this->_api) {
|
33 |
+
// @codingStandardsIgnoreStart
|
34 |
$response = curl_exec($this->_api);
|
35 |
|
36 |
if ($response === false) {
|
45 |
curl_close($this->_api);
|
46 |
$this->_api = null;
|
47 |
if ($responseData->getError()) {
|
48 |
+
throw new Creativestyle_AmazonPayments_Exception(
|
49 |
+
'[LWA-API:' . $responseData->getError() . '] '
|
50 |
+
. ($responseData->hasErrorDescription()
|
51 |
+
? $responseData->getErrorDescription() : $responseData->getError())
|
52 |
+
);
|
53 |
}
|
54 |
+
// @codingStandardsIgnoreEnd
|
55 |
+
|
56 |
return $responseData;
|
57 |
}
|
58 |
+
|
59 |
return null;
|
60 |
}
|
61 |
|
62 |
+
protected function _setAuthorizationHeader($header)
|
63 |
+
{
|
64 |
if (null !== $this->_api) {
|
65 |
+
// @codingStandardsIgnoreStart
|
66 |
curl_setopt($this->_api, CURLOPT_HTTPHEADER, array('Authorization: bearer ' . $header));
|
67 |
+
// @codingStandardsIgnoreEnd
|
68 |
}
|
69 |
+
|
70 |
return $this;
|
71 |
}
|
72 |
|
73 |
+
protected function _processApiResponse($response)
|
74 |
+
{
|
75 |
if ($response !== false) {
|
76 |
$responseData = json_decode($response, true);
|
77 |
if (!empty($responseData)) {
|
78 |
return new Varien_Object($responseData);
|
79 |
}
|
80 |
}
|
81 |
+
|
82 |
return null;
|
83 |
}
|
84 |
|
85 |
+
public function getTokenInfo($accessToken)
|
86 |
+
{
|
87 |
return $this->_initApi('auth/o2/tokeninfo?access_token=%s', array(urlencode($accessToken)))->_call();
|
88 |
}
|
89 |
|
90 |
+
public function getUserProfile($accessToken)
|
91 |
+
{
|
92 |
return $this->_initApi('user/profile')->_setAuthorizationHeader($accessToken)->_call();
|
93 |
}
|
|
|
94 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Checkout.php
CHANGED
@@ -1,36 +1,47 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Checkout extends Mage_Checkout_Model_Type_Onepage
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
return Mage::getSingleton('amazonpayments/config');
|
20 |
}
|
21 |
|
22 |
-
protected function _getPaymentMethod()
|
23 |
-
|
|
|
24 |
return array('method' => 'amazonpayments_advanced_sandbox');
|
25 |
}
|
|
|
26 |
return array('method' => 'amazonpayments_advanced');
|
27 |
}
|
28 |
|
29 |
-
protected function _sanitizeShippingAddress($addressData)
|
|
|
30 |
$allowedCountries = explode(',', (string)Mage::getStoreConfig('general/country/allow'));
|
31 |
if (!(isset($addressData['country_id']) && in_array($addressData['country_id'], $allowedCountries))) {
|
32 |
$addressData['country_id'] = null;
|
33 |
}
|
|
|
34 |
return $addressData;
|
35 |
}
|
36 |
|
@@ -44,10 +55,12 @@ class Creativestyle_AmazonPayments_Model_Checkout extends Mage_Checkout_Model_Ty
|
|
44 |
if ($couponCode = $this->getCheckout()->getCartCouponCode()) {
|
45 |
$this->getQuote()->setCouponCode($couponCode);
|
46 |
}
|
|
|
47 |
return $this;
|
48 |
}
|
49 |
|
50 |
-
public function savePayment($data)
|
|
|
51 |
$data = $this->_getPaymentMethod();
|
52 |
if ($this->getQuote()->isVirtual()) {
|
53 |
$this->getQuote()->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
@@ -78,7 +91,8 @@ class Creativestyle_AmazonPayments_Model_Checkout extends Mage_Checkout_Model_Ty
|
|
78 |
return array();
|
79 |
}
|
80 |
|
81 |
-
public function saveShipping($data, $customerAddressId)
|
|
|
82 |
if (empty($data)) {
|
83 |
return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid data.'));
|
84 |
}
|
@@ -122,15 +136,18 @@ class Creativestyle_AmazonPayments_Model_Checkout extends Mage_Checkout_Model_Ty
|
|
122 |
return array();
|
123 |
}
|
124 |
|
125 |
-
public function saveShippingMethod($shippingMethod)
|
|
|
126 |
if (empty($shippingMethod)) {
|
127 |
$this->getQuote()->getShippingAddress()->unsetShippingMethod();
|
128 |
return array();
|
129 |
}
|
|
|
130 |
$rate = $this->getQuote()->getShippingAddress()->getShippingRateByCode($shippingMethod);
|
131 |
if (!$rate) {
|
132 |
-
|
133 |
}
|
|
|
134 |
$this->getQuote()->getShippingAddress()
|
135 |
->setShippingMethod($shippingMethod)
|
136 |
->collectTotals()
|
@@ -143,7 +160,8 @@ class Creativestyle_AmazonPayments_Model_Checkout extends Mage_Checkout_Model_Ty
|
|
143 |
return array();
|
144 |
}
|
145 |
|
146 |
-
public function saveOrder()
|
|
|
147 |
$this->getQuote()->collectTotals();
|
148 |
$this->validate();
|
149 |
$isNewCustomer = false;
|
@@ -160,6 +178,7 @@ class Creativestyle_AmazonPayments_Model_Checkout extends Mage_Checkout_Model_Ty
|
|
160 |
break;
|
161 |
}
|
162 |
|
|
|
163 |
$service = Mage::getModel('amazonpayments/service_quote', $this->getQuote());
|
164 |
$service->submitOrder();
|
165 |
|
@@ -177,15 +196,16 @@ class Creativestyle_AmazonPayments_Model_Checkout extends Mage_Checkout_Model_Ty
|
|
177 |
|
178 |
$order = $service->getOrder();
|
179 |
if ($order) {
|
180 |
-
Mage::dispatchEvent(
|
181 |
-
|
|
|
|
|
182 |
|
183 |
// add order information to the session
|
184 |
$this->_checkoutSession->setLastOrderId($order->getId())
|
185 |
->setLastRealOrderId($order->getIncrementId())
|
186 |
-
->
|
187 |
->setAmazonSequenceNumber(null);
|
188 |
-
|
189 |
}
|
190 |
|
191 |
Mage::dispatchEvent(
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Checkout extends Mage_Checkout_Model_Type_Onepage
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Returns instance of Amazon Payments config object
|
21 |
+
*
|
22 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
23 |
+
*/
|
24 |
+
protected function _getConfig()
|
25 |
+
{
|
26 |
return Mage::getSingleton('amazonpayments/config');
|
27 |
}
|
28 |
|
29 |
+
protected function _getPaymentMethod()
|
30 |
+
{
|
31 |
+
if ($this->_getConfig()->isSandboxActive()) {
|
32 |
return array('method' => 'amazonpayments_advanced_sandbox');
|
33 |
}
|
34 |
+
|
35 |
return array('method' => 'amazonpayments_advanced');
|
36 |
}
|
37 |
|
38 |
+
protected function _sanitizeShippingAddress($addressData)
|
39 |
+
{
|
40 |
$allowedCountries = explode(',', (string)Mage::getStoreConfig('general/country/allow'));
|
41 |
if (!(isset($addressData['country_id']) && in_array($addressData['country_id'], $allowedCountries))) {
|
42 |
$addressData['country_id'] = null;
|
43 |
}
|
44 |
+
|
45 |
return $addressData;
|
46 |
}
|
47 |
|
55 |
if ($couponCode = $this->getCheckout()->getCartCouponCode()) {
|
56 |
$this->getQuote()->setCouponCode($couponCode);
|
57 |
}
|
58 |
+
|
59 |
return $this;
|
60 |
}
|
61 |
|
62 |
+
public function savePayment($data)
|
63 |
+
{
|
64 |
$data = $this->_getPaymentMethod();
|
65 |
if ($this->getQuote()->isVirtual()) {
|
66 |
$this->getQuote()->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
91 |
return array();
|
92 |
}
|
93 |
|
94 |
+
public function saveShipping($data, $customerAddressId)
|
95 |
+
{
|
96 |
if (empty($data)) {
|
97 |
return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid data.'));
|
98 |
}
|
136 |
return array();
|
137 |
}
|
138 |
|
139 |
+
public function saveShippingMethod($shippingMethod)
|
140 |
+
{
|
141 |
if (empty($shippingMethod)) {
|
142 |
$this->getQuote()->getShippingAddress()->unsetShippingMethod();
|
143 |
return array();
|
144 |
}
|
145 |
+
|
146 |
$rate = $this->getQuote()->getShippingAddress()->getShippingRateByCode($shippingMethod);
|
147 |
if (!$rate) {
|
148 |
+
throw new Creativestyle_AmazonPayments_Exception(Mage::helper('checkout')->__('Invalid shipping method.'));
|
149 |
}
|
150 |
+
|
151 |
$this->getQuote()->getShippingAddress()
|
152 |
->setShippingMethod($shippingMethod)
|
153 |
->collectTotals()
|
160 |
return array();
|
161 |
}
|
162 |
|
163 |
+
public function saveOrder()
|
164 |
+
{
|
165 |
$this->getQuote()->collectTotals();
|
166 |
$this->validate();
|
167 |
$isNewCustomer = false;
|
178 |
break;
|
179 |
}
|
180 |
|
181 |
+
/** @var Creativestyle_AmazonPayments_Model_Service_Quote $service */
|
182 |
$service = Mage::getModel('amazonpayments/service_quote', $this->getQuote());
|
183 |
$service->submitOrder();
|
184 |
|
196 |
|
197 |
$order = $service->getOrder();
|
198 |
if ($order) {
|
199 |
+
Mage::dispatchEvent(
|
200 |
+
'checkout_type_onepage_save_order_after',
|
201 |
+
array('order' => $order, 'quote' => $this->getQuote())
|
202 |
+
);
|
203 |
|
204 |
// add order information to the session
|
205 |
$this->_checkoutSession->setLastOrderId($order->getId())
|
206 |
->setLastRealOrderId($order->getIncrementId())
|
207 |
+
->setAmazonOrderReferenceId(null)
|
208 |
->setAmazonSequenceNumber(null);
|
|
|
209 |
}
|
210 |
|
211 |
Mage::dispatchEvent(
|
app/code/community/Creativestyle/AmazonPayments/Model/Config.php
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Config
|
17 |
-
|
18 |
const XML_PATH_ACCOUNT_MERCHANT_ID = 'amazonpayments/account/merchant_id';
|
19 |
const XML_PATH_ACCOUNT_ACCESS_KEY = 'amazonpayments/account/access_key';
|
20 |
const XML_PATH_ACCOUNT_SECRET_KEY = 'amazonpayments/account/secret_key';
|
@@ -60,113 +61,121 @@ class Creativestyle_AmazonPayments_Model_Config {
|
|
60 |
const XML_PATH_DEVELOPER_ALLOWED_IPS = 'amazonpayments/developer/allowed_ips';
|
61 |
const XML_PATH_DEVELOPER_LOG_ACTIVE = 'amazonpayments/developer/log_active';
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
protected $
|
69 |
-
|
70 |
-
protected function _getConfig($store = null) {
|
71 |
-
if (!array_key_exists($store, $this->_config)) {
|
72 |
-
$this->_config[$store] = array(
|
73 |
-
'merchantId' => $this->getMerchantId($store),
|
74 |
-
'accessKey' => trim(Mage::getStoreConfig(self::XML_PATH_ACCOUNT_ACCESS_KEY, $store)),
|
75 |
-
'secretKey' => trim(Mage::getStoreConfig(self::XML_PATH_ACCOUNT_SECRET_KEY, $store)),
|
76 |
-
'applicationName' => 'Creativestyle Amazon Payments Advanced Magento Extension',
|
77 |
-
'applicationVersion' => Mage::getConfig()->getNode('modules/Creativestyle_AmazonPayments/version'),
|
78 |
-
'region' => $this->getRegion($store),
|
79 |
-
'environment' => $this->isSandbox($store) ? 'sandbox' : 'live',
|
80 |
-
'serviceURL' => '',
|
81 |
-
'widgetURL' => '',
|
82 |
-
'caBundleFile' => $this->getCaBundleFile(),
|
83 |
-
'clientId' => '',
|
84 |
-
'cnName' => 'sns.amazonaws.com'
|
85 |
-
);
|
86 |
-
}
|
87 |
-
return $this->_config[$store];
|
88 |
-
}
|
89 |
-
|
90 |
-
protected function _getGlobalData() {
|
91 |
-
if (null === $this->_globalData) {
|
92 |
-
$this->_globalData = Mage::getConfig()->getNode('global/creativestyle/amazonpayments')->asArray();
|
93 |
-
}
|
94 |
-
return $this->_globalData;
|
95 |
-
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
return
|
106 |
}
|
107 |
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
return $
|
117 |
-
}
|
118 |
-
|
119 |
-
public function getMerchantValues($store = null) {
|
120 |
-
if (null === $this->_merchantValues) {
|
121 |
-
$this->_merchantValues = OffAmazonPaymentsService_MerchantValuesBuilder::create(array(
|
122 |
-
'merchantId' => $this->getConnectionData('merchantId', $store),
|
123 |
-
'accessKey' => $this->getConnectionData('accessKey', $store),
|
124 |
-
'secretKey' => $this->getConnectionData('secretKey', $store),
|
125 |
-
'applicationName' => $this->getConnectionData('applicationName', $store),
|
126 |
-
'applicationVersion' => $this->getConnectionData('applicationVersion', $store),
|
127 |
-
'region' => $this->getConnectionData('region', $store),
|
128 |
-
'environment' => $this->getConnectionData('environment', $store),
|
129 |
-
'serviceUrl' => $this->getConnectionData('serviceURL', $store),
|
130 |
-
'widgetUrl' => $this->getConnectionData('widgetURL', $store),
|
131 |
-
'caBundleFile' => $this->getConnectionData('caBundleFile', $store),
|
132 |
-
'clientId' => $this->getConnectionData('clientId', $store),
|
133 |
-
'cnName' => $this->getConnectionData('cnName', $store)
|
134 |
-
))->build();
|
135 |
-
}
|
136 |
-
return $this->_merchantValues;
|
137 |
}
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
143 |
}
|
144 |
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
156 |
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
return Mage::getStoreConfigFlag(self::XML_PATH_DEVELOPER_LOG_ACTIVE, $store);
|
159 |
}
|
160 |
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
}
|
168 |
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
switch (Mage::getStoreConfig(self::XML_PATH_ACCOUNT_REGION, $store)) {
|
171 |
case 'EUR':
|
172 |
return 'de';
|
@@ -177,176 +186,327 @@ class Creativestyle_AmazonPayments_Model_Config {
|
|
177 |
}
|
178 |
}
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
-
|
185 |
-
return Mage::getStoreConfig(self::XML_PATH_LOGIN_CLIENT_ID, $store);
|
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 |
-
return null;
|
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 |
-
return Mage::
|
266 |
}
|
267 |
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
}
|
277 |
-
return Mage::getStoreConfig(self::XML_PATH_DESIGN_BUTTON_SIZE, $store);
|
278 |
-
}
|
279 |
|
280 |
-
|
281 |
-
return new Varien_Object(array(
|
282 |
-
'width' => Mage::getStoreConfig(self::XML_PATH_DESIGN_ADDRESS_WIDTH, $store) . 'px',
|
283 |
-
'height' => Mage::getStoreConfig(self::XML_PATH_DESIGN_ADDRESS_HEIGHT, $store) . 'px'
|
284 |
-
));
|
285 |
}
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
293 |
|
294 |
-
|
295 |
-
return Mage::getStoreConfig(self::XML_PATH_GENERAL_PAYMENT_ACTION, $store);
|
296 |
}
|
297 |
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
-
|
306 |
-
return Mage::getStoreConfig(self::XML_PATH_GENERAL_PAYMENT_ACTION, $store) == Creativestyle_AmazonPayments_Model_Payment_Abstract::ACTION_AUTHORIZE_CAPTURE;
|
307 |
}
|
308 |
|
309 |
-
|
310 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
}
|
312 |
|
313 |
-
|
314 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
}
|
316 |
|
317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
return Mage::getStoreConfig(self::XML_PATH_GENERAL_NEW_ORDER_STATUS, $store);
|
319 |
}
|
320 |
|
321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
return Mage::getStoreConfig(self::XML_PATH_GENERAL_ORDER_STATUS, $store);
|
323 |
}
|
324 |
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
|
333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
return Mage::getStoreConfig(self::XML_PATH_EMAIL_DECLINED_TEMPLATE, $store);
|
335 |
}
|
336 |
|
337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
return Mage::getStoreConfig(self::XML_PATH_EMAIL_DECLINED_IDENTITY, $store);
|
339 |
}
|
340 |
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
public function isCurrentIpAllowed($store = null) {
|
350 |
$allowedIps = trim(Mage::getStoreConfig(self::XML_PATH_DEVELOPER_ALLOWED_IPS, $store), ' ,');
|
351 |
if ($allowedIps) {
|
352 |
$allowedIps = explode(',', str_replace(' ', '', $allowedIps));
|
@@ -355,22 +515,34 @@ class Creativestyle_AmazonPayments_Model_Config {
|
|
355 |
if (Mage::app()->getRequest()->getServer('HTTP_X_FORWARDED_FOR')) {
|
356 |
$currentIp = Mage::app()->getRequest()->getServer('HTTP_X_FORWARDED_FOR');
|
357 |
}
|
|
|
358 |
return in_array($currentIp, $allowedIps);
|
359 |
}
|
360 |
}
|
|
|
361 |
return true;
|
362 |
}
|
363 |
|
364 |
-
|
365 |
-
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
return true;
|
368 |
}
|
|
|
369 |
$currentLocale = Mage::app()->getLocale()->getLocaleCode();
|
370 |
$language = strtolower($currentLocale);
|
371 |
-
if (strpos($language, '_')) {
|
372 |
$language = substr($language, 0, strpos($language, '_'));
|
373 |
}
|
|
|
374 |
switch ($this->getRegion($store)) {
|
375 |
case 'de':
|
376 |
return ($language == 'de');
|
@@ -382,38 +554,117 @@ class Creativestyle_AmazonPayments_Model_Config {
|
|
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 |
return '';
|
410 |
}
|
411 |
|
412 |
/**
|
413 |
-
*
|
|
|
|
|
414 |
* @return string
|
415 |
*/
|
416 |
-
public function getStoreName($store = null)
|
|
|
417 |
$storeName = Mage::getStoreConfig(self::XML_PATH_STORE_NAME, $store);
|
418 |
$storeName = $storeName
|
419 |
? $storeName
|
@@ -424,4 +675,47 @@ class Creativestyle_AmazonPayments_Model_Config {
|
|
424 |
);
|
425 |
return $storeName;
|
426 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Config
|
18 |
+
{
|
19 |
const XML_PATH_ACCOUNT_MERCHANT_ID = 'amazonpayments/account/merchant_id';
|
20 |
const XML_PATH_ACCOUNT_ACCESS_KEY = 'amazonpayments/account/access_key';
|
21 |
const XML_PATH_ACCOUNT_SECRET_KEY = 'amazonpayments/account/secret_key';
|
61 |
const XML_PATH_DEVELOPER_ALLOWED_IPS = 'amazonpayments/developer/allowed_ips';
|
62 |
const XML_PATH_DEVELOPER_LOG_ACTIVE = 'amazonpayments/developer/log_active';
|
63 |
|
64 |
+
/**
|
65 |
+
* Global config data array
|
66 |
+
*
|
67 |
+
* @var array|null
|
68 |
+
*/
|
69 |
+
protected $_globalConfigData = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
+
/**
|
72 |
+
* Returns configured authentication experience
|
73 |
+
*
|
74 |
+
* @param mixed|null $store
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
protected function _getAuthenticationExperience($store = null)
|
78 |
+
{
|
79 |
+
return Mage::getStoreConfig(self::XML_PATH_LOGIN_AUTHENTICATION, $store);
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* Checks whether Amazon Pay is enabled
|
84 |
+
*
|
85 |
+
* @param mixed|null $store
|
86 |
+
* @return bool
|
87 |
+
*/
|
88 |
+
public function isPayActive($store = null)
|
89 |
+
{
|
90 |
+
return Mage::getStoreConfigFlag(self::XML_PATH_GENERAL_ACTIVE, $store);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
|
93 |
+
/**
|
94 |
+
* Checks whether Login with Amazon is enabled
|
95 |
+
*
|
96 |
+
* @param mixed|null $store
|
97 |
+
* @return bool
|
98 |
+
*/
|
99 |
+
public function isLoginActive($store = null)
|
100 |
+
{
|
101 |
+
return Mage::getStoreConfigFlag(self::XML_PATH_LOGIN_ACTIVE, $store);
|
102 |
}
|
103 |
|
104 |
+
/**
|
105 |
+
* Checks whether IPN is enabled
|
106 |
+
*
|
107 |
+
* @param mixed|null $store
|
108 |
+
* @return bool
|
109 |
+
*/
|
110 |
+
public function isIpnActive($store = null)
|
111 |
+
{
|
112 |
+
return Mage::getStoreConfigFlag(self::XML_PATH_GENERAL_IPN_ACTIVE, $store);
|
113 |
}
|
114 |
|
115 |
+
/**
|
116 |
+
* Checks whether extension runs in sandbox mode
|
117 |
+
*
|
118 |
+
* @param mixed|null $store
|
119 |
+
* @return bool
|
120 |
+
*/
|
121 |
+
public function isSandboxActive($store = null)
|
122 |
+
{
|
123 |
+
return Mage::getStoreConfigFlag(self::XML_PATH_GENERAL_SANDBOX, $store);
|
124 |
}
|
125 |
|
126 |
+
/**
|
127 |
+
* Checks whether simulation toolbox shall be displayed in the checkout
|
128 |
+
*
|
129 |
+
* @param mixed|null $store
|
130 |
+
* @return bool
|
131 |
+
*/
|
132 |
+
public function isSandboxToolboxActive($store = null)
|
133 |
+
{
|
134 |
+
return $this->isSandboxActive($store)
|
135 |
+
&& Mage::getStoreConfigFlag(self::XML_PATH_GENERAL_SANDBOX_TOOLBOX, $store);
|
136 |
}
|
137 |
|
138 |
+
/**
|
139 |
+
* Checks whether debug logging is enabled
|
140 |
+
*
|
141 |
+
* @param mixed|null $store
|
142 |
+
* @return bool
|
143 |
+
*/
|
144 |
+
public function isLoggingActive($store = null)
|
145 |
+
{
|
146 |
return Mage::getStoreConfigFlag(self::XML_PATH_DEVELOPER_LOG_ACTIVE, $store);
|
147 |
}
|
148 |
|
149 |
+
/**
|
150 |
+
* Returns Merchant ID for the configured Amazon merchant account
|
151 |
+
*
|
152 |
+
* @param mixed|null $store
|
153 |
+
* @return string
|
154 |
+
*/
|
155 |
+
public function getMerchantId($store = null)
|
156 |
+
{
|
157 |
+
return trim(strtoupper(Mage::getStoreConfig(self::XML_PATH_ACCOUNT_MERCHANT_ID, $store)));
|
158 |
}
|
159 |
|
160 |
+
/**
|
161 |
+
* Returns Amazon app client ID
|
162 |
+
*
|
163 |
+
* @param mixed|null $store
|
164 |
+
* @return string
|
165 |
+
*/
|
166 |
+
public function getClientId($store = null)
|
167 |
+
{
|
168 |
+
return Mage::getStoreConfig(self::XML_PATH_LOGIN_CLIENT_ID, $store);
|
169 |
}
|
170 |
|
171 |
+
/**
|
172 |
+
* Returns merchant's region
|
173 |
+
*
|
174 |
+
* @param mixed|null $store
|
175 |
+
* @return string|null
|
176 |
+
*/
|
177 |
+
public function getRegion($store = null)
|
178 |
+
{
|
179 |
switch (Mage::getStoreConfig(self::XML_PATH_ACCOUNT_REGION, $store)) {
|
180 |
case 'EUR':
|
181 |
return 'de';
|
186 |
}
|
187 |
}
|
188 |
|
189 |
+
/**
|
190 |
+
* Returns display language for Amazon widgets
|
191 |
+
*
|
192 |
+
* @param mixed|null $store
|
193 |
+
* @return string|null
|
194 |
+
*/
|
195 |
+
public function getDisplayLanguage($store = null)
|
196 |
+
{
|
197 |
+
$displayLanguage = Mage::getStoreConfig(self::XML_PATH_LOGIN_LANGUAGE, $store);
|
198 |
+
if (!$displayLanguage) {
|
199 |
+
/** @var Creativestyle_AmazonPayments_Model_Lookup_Language $languageLookupModel */
|
200 |
+
$languageLookupModel = Mage::getSingleton('amazonpayments/lookup_language');
|
201 |
+
$displayLanguage = $languageLookupModel->getLanguageByLocale();
|
202 |
+
}
|
203 |
|
204 |
+
return $displayLanguage;
|
|
|
205 |
}
|
206 |
|
207 |
+
/**
|
208 |
+
* Checks whether authentication experience is set to automatic mode
|
209 |
+
*
|
210 |
+
* @param mixed|null $store
|
211 |
+
* @return bool
|
212 |
+
*/
|
213 |
+
public function isAutoAuthenticationExperience($store = null)
|
214 |
+
{
|
215 |
+
return $this->_getAuthenticationExperience($store)
|
216 |
+
== Creativestyle_AmazonPayments_Model_Lookup_Authentication::AUTO_EXPERIENCE;
|
217 |
}
|
218 |
|
219 |
+
/**
|
220 |
+
* Checks whether authentication experience is set to popup
|
221 |
+
*
|
222 |
+
* @param mixed|null $store
|
223 |
+
* @return bool
|
224 |
+
*/
|
225 |
+
public function isPopupAuthenticationExperience($store = null)
|
226 |
+
{
|
227 |
+
return $this->_getAuthenticationExperience($store)
|
228 |
+
== Creativestyle_AmazonPayments_Model_Lookup_Authentication::POPUP_EXPERIENCE;
|
229 |
}
|
230 |
|
231 |
+
/**
|
232 |
+
* Checks whether authentication experience is set to redirect
|
233 |
+
*
|
234 |
+
* @param mixed|null $store
|
235 |
+
* @return bool
|
236 |
+
*/
|
237 |
+
public function isRedirectAuthenticationExperience($store = null)
|
238 |
+
{
|
239 |
+
return $this->_getAuthenticationExperience($store)
|
240 |
+
== Creativestyle_AmazonPayments_Model_Lookup_Authentication::REDIRECT_EXPERIENCE;
|
241 |
}
|
242 |
|
243 |
+
/**
|
244 |
+
* Returns configured payment action
|
245 |
+
*
|
246 |
+
* @param mixed|null $store
|
247 |
+
* @return string
|
248 |
+
*/
|
249 |
+
public function getPaymentAction($store = null)
|
250 |
+
{
|
251 |
+
return Mage::getStoreConfig(self::XML_PATH_GENERAL_PAYMENT_ACTION, $store);
|
252 |
}
|
253 |
|
254 |
+
/**
|
255 |
+
* Checks whether order amount shall be authorized immediately after the order is placed
|
256 |
+
*
|
257 |
+
* @param mixed|null $store
|
258 |
+
* @return bool
|
259 |
+
*/
|
260 |
+
public function authorizeImmediately($store = null)
|
261 |
+
{
|
262 |
+
return in_array(
|
263 |
+
$this->getPaymentAction($store),
|
264 |
+
array(
|
265 |
+
Creativestyle_AmazonPayments_Model_Payment_Abstract::ACTION_AUTHORIZE,
|
266 |
+
Creativestyle_AmazonPayments_Model_Payment_Abstract::ACTION_AUTHORIZE_CAPTURE
|
267 |
+
)
|
268 |
+
);
|
269 |
}
|
270 |
|
271 |
+
/**
|
272 |
+
* Checks whether order amount shall be captured immediately after the order is placed
|
273 |
+
*
|
274 |
+
* @param mixed|null $store
|
275 |
+
* @return bool
|
276 |
+
*/
|
277 |
+
public function captureImmediately($store = null)
|
278 |
+
{
|
279 |
+
return $this->getPaymentAction($store)
|
280 |
+
== Creativestyle_AmazonPayments_Model_Payment_Abstract::ACTION_AUTHORIZE_CAPTURE;
|
281 |
}
|
282 |
|
283 |
+
/**
|
284 |
+
* Checks whether manual authorization is allowed
|
285 |
+
*
|
286 |
+
* @param mixed|null $store
|
287 |
+
* @return bool
|
288 |
+
*/
|
289 |
+
public function isManualAuthorizationAllowed($store = null)
|
290 |
+
{
|
291 |
+
return $this->getPaymentAction($store)
|
292 |
+
== Creativestyle_AmazonPayments_Model_Payment_Abstract::ACTION_MANUAL;
|
293 |
}
|
294 |
|
295 |
+
/**
|
296 |
+
* Checks whether shop is allowed to process the payment
|
297 |
+
*
|
298 |
+
* @param mixed|null $store
|
299 |
+
* @return bool
|
300 |
+
*/
|
301 |
+
public function isPaymentProcessingAllowed($store = null)
|
302 |
+
{
|
303 |
+
return $this->getPaymentAction($store)
|
304 |
+
!= Creativestyle_AmazonPayments_Model_Payment_Abstract::ACTION_ERP;
|
|
|
|
|
305 |
}
|
306 |
|
307 |
+
/**
|
308 |
+
* Returns authorization request mode (sync, async)
|
309 |
+
*
|
310 |
+
* @param mixed|null $store
|
311 |
+
* @return string
|
312 |
+
*/
|
313 |
+
public function getAuthorizationMode($store = null)
|
314 |
+
{
|
315 |
+
return Mage::getStoreConfig(self::XML_PATH_GENERAL_AUTHORIZATION_MODE, $store);
|
316 |
}
|
317 |
|
318 |
+
/**
|
319 |
+
* Checks if authorization should be requested synchronously
|
320 |
+
*
|
321 |
+
* @param mixed|null $store
|
322 |
+
* @return bool
|
323 |
+
*/
|
324 |
+
public function isAuthorizationSynchronous($store = null)
|
325 |
+
{
|
326 |
+
return in_array(
|
327 |
+
$this->getAuthorizationMode($store),
|
328 |
+
array(
|
329 |
+
Creativestyle_AmazonPayments_Model_Lookup_AuthorizationMode::AUTO,
|
330 |
+
Creativestyle_AmazonPayments_Model_Lookup_AuthorizationMode::SYNCHRONOUS
|
331 |
+
)
|
332 |
+
);
|
333 |
}
|
334 |
|
335 |
+
/**
|
336 |
+
* Checks if authorization should be re-requested asynchronously,
|
337 |
+
* after synchronous authorization fails with TransactionTimedOut
|
338 |
+
* declined state
|
339 |
+
*
|
340 |
+
* @param mixed|null $store
|
341 |
+
* @return bool
|
342 |
+
*/
|
343 |
+
public function isAuthorizationOmnichronous($store = null)
|
344 |
+
{
|
345 |
+
return in_array(
|
346 |
+
$this->getAuthorizationMode($store),
|
347 |
+
array(
|
348 |
+
Creativestyle_AmazonPayments_Model_Lookup_AuthorizationMode::AUTO
|
349 |
+
)
|
350 |
+
);
|
351 |
}
|
352 |
|
353 |
+
/**
|
354 |
+
* Checks whether checkout widgets are configured to be
|
355 |
+
* displayed in responsive mode
|
356 |
+
|
357 |
+
* @param mixed|null $store
|
358 |
+
* @return bool
|
359 |
+
*/
|
360 |
+
public function isResponsive($store = null)
|
361 |
+
{
|
362 |
+
return Mage::getStoreConfigFlag(self::XML_PATH_DESIGN_RESPONSIVE, $store);
|
363 |
}
|
364 |
|
365 |
+
/**
|
366 |
+
* @param mixed|null $store
|
367 |
+
* @return string
|
368 |
+
*/
|
369 |
+
public function getPayButtonSize($store = null)
|
370 |
+
{
|
371 |
+
if ($this->isLoginActive()) {
|
372 |
+
return Mage::getStoreConfig(self::XML_PATH_DESIGN_PAY_BUTTON_SIZE, $store);
|
373 |
}
|
|
|
|
|
374 |
|
375 |
+
return Mage::getStoreConfig(self::XML_PATH_DESIGN_BUTTON_SIZE, $store);
|
|
|
|
|
|
|
|
|
376 |
}
|
377 |
|
378 |
+
/**
|
379 |
+
* @param mixed|null $store
|
380 |
+
* @return string
|
381 |
+
*/
|
382 |
+
public function getPayButtonColor($store = null)
|
383 |
+
{
|
384 |
+
if ($this->isLoginActive()) {
|
385 |
+
return Mage::getStoreConfig(self::XML_PATH_DESIGN_PAY_BUTTON_COLOR, $store);
|
386 |
+
}
|
387 |
|
388 |
+
return Mage::getStoreConfig(self::XML_PATH_DESIGN_BUTTON_COLOR, $store);
|
|
|
389 |
}
|
390 |
|
391 |
+
/**
|
392 |
+
* @param mixed|null $store
|
393 |
+
* @return string|null
|
394 |
+
*/
|
395 |
+
public function getPayButtonUrl($store = null)
|
396 |
+
{
|
397 |
+
if (!$this->isLoginActive()) {
|
398 |
+
$buttonUrls = $this->getGlobalConfigData('button_urls');
|
399 |
+
$env = $this->isSandboxActive($store) ? 'sandbox' : 'live';
|
400 |
+
if (isset($buttonUrls[$this->getRegion($store)][$env])) {
|
401 |
+
return sprintf(
|
402 |
+
'%s?sellerId=%s&size=%s&color=%s',
|
403 |
+
$buttonUrls[$this->getRegion($store)][$env],
|
404 |
+
$this->getMerchantId($store),
|
405 |
+
$this->getPayButtonSize($store),
|
406 |
+
$this->getPayButtonColor($store)
|
407 |
+
);
|
408 |
+
}
|
409 |
+
}
|
410 |
|
411 |
+
return null;
|
|
|
412 |
}
|
413 |
|
414 |
+
/**
|
415 |
+
* Returns Amazon Pay button design params
|
416 |
+
*
|
417 |
+
* @param mixed|null $store
|
418 |
+
* @return array
|
419 |
+
*/
|
420 |
+
public function getPayButtonDesign($store = null)
|
421 |
+
{
|
422 |
+
return array(
|
423 |
+
'type' => Mage::getStoreConfig(self::XML_PATH_DESIGN_PAY_BUTTON_TYPE, $store),
|
424 |
+
'size' => Mage::getStoreConfig(self::XML_PATH_DESIGN_PAY_BUTTON_SIZE, $store),
|
425 |
+
'color' => Mage::getStoreConfig(self::XML_PATH_DESIGN_PAY_BUTTON_COLOR, $store)
|
426 |
+
);
|
427 |
}
|
428 |
|
429 |
+
/**
|
430 |
+
* Returns Login with Amazon button design params
|
431 |
+
*
|
432 |
+
* @param mixed|null $store
|
433 |
+
* @return array
|
434 |
+
*/
|
435 |
+
public function getLoginButtonDesign($store = null)
|
436 |
+
{
|
437 |
+
return array(
|
438 |
+
'type' => Mage::getStoreConfig(self::XML_PATH_DESIGN_LOGIN_BUTTON_TYPE, $store),
|
439 |
+
'size' => Mage::getStoreConfig(self::XML_PATH_DESIGN_LOGIN_BUTTON_SIZE, $store),
|
440 |
+
'color' => Mage::getStoreConfig(self::XML_PATH_DESIGN_LOGIN_BUTTON_COLOR, $store)
|
441 |
+
);
|
442 |
}
|
443 |
|
444 |
+
/**
|
445 |
+
* Returns status for newly created order
|
446 |
+
*
|
447 |
+
* @param mixed|null $store
|
448 |
+
* @return string
|
449 |
+
*/
|
450 |
+
public function getNewOrderStatus($store = null)
|
451 |
+
{
|
452 |
return Mage::getStoreConfig(self::XML_PATH_GENERAL_NEW_ORDER_STATUS, $store);
|
453 |
}
|
454 |
|
455 |
+
/**
|
456 |
+
* Returns status for order with confirmed authorization
|
457 |
+
*
|
458 |
+
* @param mixed|null $store
|
459 |
+
* @return string
|
460 |
+
*/
|
461 |
+
public function getAuthorizedOrderStatus($store = null)
|
462 |
+
{
|
463 |
return Mage::getStoreConfig(self::XML_PATH_GENERAL_ORDER_STATUS, $store);
|
464 |
}
|
465 |
|
466 |
+
/**
|
467 |
+
* Returns status for the order on hold
|
468 |
+
*
|
469 |
+
* @param mixed|null $store
|
470 |
+
* @return string
|
471 |
+
*/
|
472 |
+
public function getHoldedOrderStatus($store = null)
|
473 |
+
{
|
474 |
+
return Mage::getModel('sales/order_status')
|
475 |
+
->setStore($store)
|
476 |
+
->loadDefaultByState(Mage_Sales_Model_Order::STATE_HOLDED)
|
477 |
+
->getStatus();
|
478 |
}
|
479 |
|
480 |
+
/**
|
481 |
+
* Returns e-mail template for declined authorization
|
482 |
+
*
|
483 |
+
* @param mixed|null $store
|
484 |
+
* @return string
|
485 |
+
*/
|
486 |
+
public function getAuthorizationDeclinedEmailTemplate($store = null)
|
487 |
+
{
|
488 |
return Mage::getStoreConfig(self::XML_PATH_EMAIL_DECLINED_TEMPLATE, $store);
|
489 |
}
|
490 |
|
491 |
+
/**
|
492 |
+
* Returns e-mail sender identity for declined authorization
|
493 |
+
*
|
494 |
+
* @param mixed|null $store
|
495 |
+
* @return string
|
496 |
+
*/
|
497 |
+
public function getAuthorizationDeclinedEmailIdentity($store = null)
|
498 |
+
{
|
499 |
return Mage::getStoreConfig(self::XML_PATH_EMAIL_DECLINED_IDENTITY, $store);
|
500 |
}
|
501 |
|
502 |
+
/**
|
503 |
+
* Checks whether current requester IP is allowed to display Amazon widgets
|
504 |
+
*
|
505 |
+
* @param mixed|null $store
|
506 |
+
* @return bool
|
507 |
+
*/
|
508 |
+
public function isCurrentIpAllowed($store = null)
|
509 |
+
{
|
|
|
510 |
$allowedIps = trim(Mage::getStoreConfig(self::XML_PATH_DEVELOPER_ALLOWED_IPS, $store), ' ,');
|
511 |
if ($allowedIps) {
|
512 |
$allowedIps = explode(',', str_replace(' ', '', $allowedIps));
|
515 |
if (Mage::app()->getRequest()->getServer('HTTP_X_FORWARDED_FOR')) {
|
516 |
$currentIp = Mage::app()->getRequest()->getServer('HTTP_X_FORWARDED_FOR');
|
517 |
}
|
518 |
+
|
519 |
return in_array($currentIp, $allowedIps);
|
520 |
}
|
521 |
}
|
522 |
+
|
523 |
return true;
|
524 |
}
|
525 |
|
526 |
+
/**
|
527 |
+
* Checks whether Amazon widgets are allowed to be shown
|
528 |
+
* in the current shop locale
|
529 |
+
*
|
530 |
+
* @param mixed|null $store
|
531 |
+
* @return bool
|
532 |
+
*/
|
533 |
+
public function isCurrentLocaleAllowed($store = null)
|
534 |
+
{
|
535 |
+
// no locale restriction when Login is enabled
|
536 |
+
if ($this->isLoginActive($store)) {
|
537 |
return true;
|
538 |
}
|
539 |
+
|
540 |
$currentLocale = Mage::app()->getLocale()->getLocaleCode();
|
541 |
$language = strtolower($currentLocale);
|
542 |
+
if (strpos($language, '_') !== 0) {
|
543 |
$language = substr($language, 0, strpos($language, '_'));
|
544 |
}
|
545 |
+
|
546 |
switch ($this->getRegion($store)) {
|
547 |
case 'de':
|
548 |
return ($language == 'de');
|
554 |
}
|
555 |
}
|
556 |
|
557 |
+
/**
|
558 |
+
* Returns global config data
|
559 |
+
*
|
560 |
+
* @param string|null $key
|
561 |
+
* @return string|array
|
562 |
+
*/
|
563 |
+
public function getGlobalConfigData($key = null)
|
564 |
+
{
|
565 |
+
if (null === $this->_globalConfigData) {
|
566 |
+
$this->_globalConfigData = Mage::getConfig()->getNode('global/creativestyle/amazonpayments')->asArray();
|
567 |
+
}
|
568 |
+
|
569 |
+
if (null !== $key) {
|
570 |
+
if (array_key_exists($key, $this->_globalConfigData)) {
|
571 |
+
return $this->_globalConfigData[$key];
|
572 |
+
}
|
573 |
+
|
574 |
+
return null;
|
575 |
+
}
|
576 |
+
|
577 |
+
return $this->_globalConfigData;
|
578 |
}
|
579 |
|
580 |
+
/**
|
581 |
+
* Returns path to the custom CA bundle file
|
582 |
+
*
|
583 |
+
* @return string|null
|
584 |
+
*/
|
585 |
+
public function getCaBundlePath()
|
586 |
+
{
|
587 |
+
return $this->getGlobalConfigData('ca_bundle');
|
588 |
}
|
589 |
|
590 |
+
/**
|
591 |
+
* Returns array of params needed for API connection
|
592 |
+
*
|
593 |
+
* @param mixed|null $store
|
594 |
+
* @return array
|
595 |
+
*/
|
596 |
+
public function getApiConnectionParams($store = null)
|
597 |
+
{
|
598 |
+
return array(
|
599 |
+
'merchantId' => $this->getMerchantId($store),
|
600 |
+
'accessKey' => trim(Mage::getStoreConfig(self::XML_PATH_ACCOUNT_ACCESS_KEY, $store)),
|
601 |
+
'secretKey' => trim(Mage::getStoreConfig(self::XML_PATH_ACCOUNT_SECRET_KEY, $store)),
|
602 |
+
'applicationName' => 'Creativestyle Amazon Payments Advanced Magento Extension',
|
603 |
+
'applicationVersion' => Mage::getConfig()->getNode('modules/Creativestyle_AmazonPayments/version'),
|
604 |
+
'region' => $this->getRegion($store),
|
605 |
+
'environment' => $this->isSandboxActive($store) ? 'sandbox' : 'live',
|
606 |
+
'serviceUrl' => null,
|
607 |
+
'widgetUrl' => null,
|
608 |
+
'caBundleFile' => $this->getCaBundlePath(),
|
609 |
+
'clientId' => null,
|
610 |
+
'cnName' => 'sns.amazonaws.com'
|
611 |
+
);
|
612 |
}
|
613 |
|
614 |
+
/**
|
615 |
+
* Returns Amazon API Merchant Values object
|
616 |
+
*
|
617 |
+
* @param mixed|null $store
|
618 |
+
* @return OffAmazonPaymentsService_MerchantValues
|
619 |
+
*/
|
620 |
+
public function getApiMerchantValues($store = null)
|
621 |
+
{
|
622 |
+
/** @var OffAmazonPaymentsService_MerchantValuesBuilder $apiMerchantValuesBuilder */
|
623 |
+
$apiMerchantValuesBuilder = OffAmazonPaymentsService_MerchantValuesBuilder::create(
|
624 |
+
$this->getApiConnectionParams($store)
|
625 |
+
);
|
626 |
+
return $apiMerchantValuesBuilder->build();
|
627 |
+
}
|
628 |
+
|
629 |
+
/**
|
630 |
+
* Returns Widgets JS library URL
|
631 |
+
*
|
632 |
+
* @param mixed|null $store
|
633 |
+
* @return string
|
634 |
+
*/
|
635 |
+
public function getWidgetJsUrl($store = null)
|
636 |
+
{
|
637 |
+
if ($this->isLoginActive($store)) {
|
638 |
+
return $this->getApiMerchantValues($store)->getWidgetUrl();
|
639 |
}
|
640 |
+
|
641 |
+
return str_replace('lpa/', '', $this->getApiMerchantValues($store)->getWidgetUrl());
|
642 |
}
|
643 |
|
644 |
+
/**
|
645 |
+
* Returns Login API URL
|
646 |
+
*
|
647 |
+
* @param mixed|null $store
|
648 |
+
* @return string
|
649 |
+
*/
|
650 |
+
public function getLoginApiUrl($store = null)
|
651 |
+
{
|
652 |
+
$apiUrls = $this->getGlobalConfigData('login_api_urls');
|
653 |
+
if (isset($apiUrls[$this->getRegion($store)][$this->isSandboxActive($store) ? 'sandbox' : 'live'])) {
|
654 |
+
return $apiUrls[$this->getRegion($store)][$this->isSandboxActive($store) ? 'sandbox' : 'live'];
|
655 |
+
}
|
656 |
+
|
657 |
return '';
|
658 |
}
|
659 |
|
660 |
/**
|
661 |
+
* Returns configured store name
|
662 |
+
*
|
663 |
+
* @param mixed|null $store
|
664 |
* @return string
|
665 |
*/
|
666 |
+
public function getStoreName($store = null)
|
667 |
+
{
|
668 |
$storeName = Mage::getStoreConfig(self::XML_PATH_STORE_NAME, $store);
|
669 |
$storeName = $storeName
|
670 |
? $storeName
|
675 |
);
|
676 |
return $storeName;
|
677 |
}
|
678 |
+
|
679 |
+
/**
|
680 |
+
* Returns entity ID of the recently polled payment transaction
|
681 |
+
*
|
682 |
+
* @return string|null
|
683 |
+
*/
|
684 |
+
public function getRecentPolledTransaction()
|
685 |
+
{
|
686 |
+
return Mage::getStoreConfig(self::XML_PATH_GENERAL_RECENT_POLLED_TXN);
|
687 |
+
}
|
688 |
+
|
689 |
+
/**
|
690 |
+
* Sets recently polled payment transaction
|
691 |
+
*
|
692 |
+
* @param int $txnId
|
693 |
+
*/
|
694 |
+
public function setRecentPolledTransaction($txnId)
|
695 |
+
{
|
696 |
+
Mage::getConfig()->saveConfig(self::XML_PATH_GENERAL_RECENT_POLLED_TXN, $txnId)->cleanCache();
|
697 |
+
}
|
698 |
+
|
699 |
+
/**
|
700 |
+
* Returns CSV log fields delimiter character
|
701 |
+
*
|
702 |
+
* @return string
|
703 |
+
*/
|
704 |
+
public function getLogDelimiter()
|
705 |
+
{
|
706 |
+
return ';';
|
707 |
+
}
|
708 |
+
|
709 |
+
/**
|
710 |
+
* Returns CSV log fields enclosure character
|
711 |
+
* @return string
|
712 |
+
*/
|
713 |
+
public function getLogEnclosure()
|
714 |
+
{
|
715 |
+
return '"';
|
716 |
+
}
|
717 |
+
|
718 |
+
/*
|
719 |
+
|
720 |
+
*/
|
721 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Log/Collection.php
CHANGED
@@ -1,61 +1,81 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Log_Collection extends Varien_Data_Collection
|
17 |
-
|
|
|
|
|
|
|
18 |
protected $_logType = 'exception';
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
return Mage::getSingleton('amazonpayments/config');
|
22 |
}
|
23 |
|
24 |
-
protected function _applyFilters($log)
|
|
|
25 |
if (!empty($this->_filters)) {
|
26 |
foreach ($log as $field => $value) {
|
27 |
if ($filter = $this->getFilter($field)) {
|
28 |
$filterValue = $filter->getValue();
|
29 |
if (isset($filterValue['like'])) {
|
30 |
-
if (strpos(strtolower($value), strtolower(trim((string)($filterValue['like']), ' %\'')))
|
|
|
31 |
return null;
|
32 |
}
|
33 |
}
|
34 |
}
|
35 |
}
|
36 |
}
|
|
|
37 |
return $log;
|
38 |
}
|
39 |
|
40 |
-
protected function _loadData()
|
|
|
41 |
if ($this->isLoaded()) {
|
42 |
return $this;
|
43 |
}
|
44 |
|
45 |
$logFilePath = Creativestyle_AmazonPayments_Model_Logger::getAbsoluteLogFilePath($this->_logType);
|
46 |
|
|
|
47 |
if (file_exists($logFilePath)) {
|
48 |
-
|
49 |
$logArray = array();
|
50 |
|
51 |
if (($fileHandle = fopen($logFilePath, 'r')) !== false) {
|
52 |
$id = 0;
|
53 |
$columnMapping = Creativestyle_AmazonPayments_Model_Logger::getColumnMapping($this->_logType);
|
54 |
-
while (($row = fgetcsv(
|
|
|
|
|
|
|
|
|
|
|
55 |
$log = array('id' => ++$id);
|
56 |
foreach ($columnMapping as $index => $columnName) {
|
57 |
$log[$columnName] = isset($row[$index]) ? $row[$index] : '';
|
58 |
}
|
|
|
59 |
if ($log = $this->_applyFilters($log)) {
|
60 |
$logArray[] = new Varien_Object($log);
|
61 |
}
|
@@ -75,45 +95,56 @@ class Creativestyle_AmazonPayments_Model_Log_Collection extends Varien_Data_Coll
|
|
75 |
if ($isPaginated && ($count < $from || $count > $to)) {
|
76 |
continue;
|
77 |
}
|
|
|
78 |
$this->addItem($log);
|
79 |
}
|
80 |
}
|
81 |
}
|
|
|
82 |
|
83 |
return $this;
|
84 |
}
|
85 |
|
86 |
-
protected function _sortArray()
|
|
|
87 |
if (!empty($this->_items)) {
|
88 |
krsort($this->_items);
|
89 |
}
|
|
|
90 |
return $this;
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
-
* @param
|
95 |
-
* @param mixed $condition
|
|
|
96 |
*/
|
97 |
-
public function addAttributeToFilter($attribute, $condition = null)
|
|
|
98 |
$this->addFilter($attribute, $condition);
|
99 |
return $this;
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
-
* @param
|
104 |
-
* @param mixed $condition
|
|
|
105 |
*/
|
106 |
-
public function addFieldToFilter($attribute, $condition = null)
|
|
|
107 |
return $this->addAttributeToFilter($attribute, $condition);
|
108 |
}
|
109 |
|
110 |
-
|
|
|
|
|
111 |
return $this->_loadData();
|
112 |
}
|
|
|
113 |
|
114 |
-
public function setLogType($logType)
|
|
|
115 |
$this->_logType = $logType;
|
116 |
return $this;
|
117 |
}
|
118 |
-
|
119 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Log_Collection extends Varien_Data_Collection
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
protected $_logType = 'exception';
|
23 |
|
24 |
+
/**
|
25 |
+
* Returns Amazon Pay config model instance
|
26 |
+
*
|
27 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
28 |
+
*/
|
29 |
+
protected function _getConfig()
|
30 |
+
{
|
31 |
return Mage::getSingleton('amazonpayments/config');
|
32 |
}
|
33 |
|
34 |
+
protected function _applyFilters($log)
|
35 |
+
{
|
36 |
if (!empty($this->_filters)) {
|
37 |
foreach ($log as $field => $value) {
|
38 |
if ($filter = $this->getFilter($field)) {
|
39 |
$filterValue = $filter->getValue();
|
40 |
if (isset($filterValue['like'])) {
|
41 |
+
if (strpos(strtolower($value), strtolower(trim((string)($filterValue['like']), ' %\'')))
|
42 |
+
=== false) {
|
43 |
return null;
|
44 |
}
|
45 |
}
|
46 |
}
|
47 |
}
|
48 |
}
|
49 |
+
|
50 |
return $log;
|
51 |
}
|
52 |
|
53 |
+
protected function _loadData()
|
54 |
+
{
|
55 |
if ($this->isLoaded()) {
|
56 |
return $this;
|
57 |
}
|
58 |
|
59 |
$logFilePath = Creativestyle_AmazonPayments_Model_Logger::getAbsoluteLogFilePath($this->_logType);
|
60 |
|
61 |
+
// @codingStandardsIgnoreStart
|
62 |
if (file_exists($logFilePath)) {
|
|
|
63 |
$logArray = array();
|
64 |
|
65 |
if (($fileHandle = fopen($logFilePath, 'r')) !== false) {
|
66 |
$id = 0;
|
67 |
$columnMapping = Creativestyle_AmazonPayments_Model_Logger::getColumnMapping($this->_logType);
|
68 |
+
while (($row = fgetcsv(
|
69 |
+
$fileHandle,
|
70 |
+
0,
|
71 |
+
$this->_getConfig()->getLogDelimiter(),
|
72 |
+
$this->_getConfig()->getLogEnclosure()
|
73 |
+
)) !== false) {
|
74 |
$log = array('id' => ++$id);
|
75 |
foreach ($columnMapping as $index => $columnName) {
|
76 |
$log[$columnName] = isset($row[$index]) ? $row[$index] : '';
|
77 |
}
|
78 |
+
|
79 |
if ($log = $this->_applyFilters($log)) {
|
80 |
$logArray[] = new Varien_Object($log);
|
81 |
}
|
95 |
if ($isPaginated && ($count < $from || $count > $to)) {
|
96 |
continue;
|
97 |
}
|
98 |
+
|
99 |
$this->addItem($log);
|
100 |
}
|
101 |
}
|
102 |
}
|
103 |
+
// @codingStandardsIgnoreEnd
|
104 |
|
105 |
return $this;
|
106 |
}
|
107 |
|
108 |
+
protected function _sortArray()
|
109 |
+
{
|
110 |
if (!empty($this->_items)) {
|
111 |
krsort($this->_items);
|
112 |
}
|
113 |
+
|
114 |
return $this;
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
+
* @param string $attribute
|
119 |
+
* @param mixed|null $condition
|
120 |
+
* @return $this
|
121 |
*/
|
122 |
+
public function addAttributeToFilter($attribute, $condition = null)
|
123 |
+
{
|
124 |
$this->addFilter($attribute, $condition);
|
125 |
return $this;
|
126 |
}
|
127 |
|
128 |
/**
|
129 |
+
* @param string $attribute
|
130 |
+
* @param mixed|null $condition
|
131 |
+
* @return Creativestyle_AmazonPayments_Model_Log_Collection
|
132 |
*/
|
133 |
+
public function addFieldToFilter($attribute, $condition = null)
|
134 |
+
{
|
135 |
return $this->addAttributeToFilter($attribute, $condition);
|
136 |
}
|
137 |
|
138 |
+
// @codingStandardsIgnoreStart
|
139 |
+
public function loadData($printQuery = false, $logQuery = false)
|
140 |
+
{
|
141 |
return $this->_loadData();
|
142 |
}
|
143 |
+
// @codingStandardsIgnoreEnd
|
144 |
|
145 |
+
public function setLogType($logType)
|
146 |
+
{
|
147 |
$this->_logType = $logType;
|
148 |
return $this;
|
149 |
}
|
|
|
150 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Logger.php
CHANGED
@@ -1,25 +1,26 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
final class Creativestyle_AmazonPayments_Model_Logger
|
17 |
-
|
18 |
const AMAZON_LOG_DIR = 'amazonpayments';
|
19 |
|
20 |
-
const AMAZON_API_LOG_FILE = '
|
21 |
-
const AMAZON_EXCEPTION_LOG_FILE = '
|
22 |
-
const AMAZON_IPN_LOG_FILE = '
|
23 |
|
24 |
const LOGFILE_ROTATION_SIZE = 8;
|
25 |
|
@@ -28,7 +29,8 @@ final class Creativestyle_AmazonPayments_Model_Logger {
|
|
28 |
*
|
29 |
* @return Creativestyle_AmazonPayments_Model_Config
|
30 |
*/
|
31 |
-
|
|
|
32 |
return Mage::getSingleton('amazonpayments/config');
|
33 |
}
|
34 |
|
@@ -38,12 +40,16 @@ final class Creativestyle_AmazonPayments_Model_Logger {
|
|
38 |
* @param string $logType
|
39 |
* @return string|null
|
40 |
*/
|
41 |
-
public static function getAbsoluteLogFilePath($logType)
|
|
|
42 |
try {
|
43 |
$logDir = Mage::getBaseDir('log') . DS . self::AMAZON_LOG_DIR;
|
|
|
44 |
if (!is_dir($logDir)) {
|
45 |
mkdir($logDir, 0777, true);
|
46 |
}
|
|
|
|
|
47 |
switch ($logType) {
|
48 |
case 'api':
|
49 |
return $logDir . DS . self::AMAZON_API_LOG_FILE;
|
@@ -55,6 +61,7 @@ final class Creativestyle_AmazonPayments_Model_Logger {
|
|
55 |
} catch (Exception $e) {
|
56 |
Mage::logException($e);
|
57 |
}
|
|
|
58 |
return null;
|
59 |
}
|
60 |
|
@@ -63,15 +70,23 @@ final class Creativestyle_AmazonPayments_Model_Logger {
|
|
63 |
*
|
64 |
* @param array $callData
|
65 |
*/
|
66 |
-
public static function logApiCall($callData)
|
|
|
67 |
if (self::_getConfig()->isLoggingActive()) {
|
68 |
array_unshift($callData, Mage::getModel('core/date')->gmtTimestamp());
|
|
|
69 |
if (($fileHandle = fopen(self::getAbsoluteLogFilePath('api'), 'a')) !== false) {
|
70 |
-
fputcsv(
|
|
|
|
|
|
|
|
|
|
|
71 |
fclose($fileHandle);
|
72 |
} else {
|
73 |
Mage::log('AMAZON PAY: unable to open ' . self::getAbsoluteLogFilePath('api') . ' for writing.');
|
74 |
}
|
|
|
75 |
}
|
76 |
}
|
77 |
|
@@ -80,7 +95,8 @@ final class Creativestyle_AmazonPayments_Model_Logger {
|
|
80 |
*
|
81 |
* @param array $callData
|
82 |
*/
|
83 |
-
public static function logIpnCall($callData)
|
|
|
84 |
if (self::_getConfig()->isLoggingActive()) {
|
85 |
array_unshift($callData, Mage::getModel('core/date')->gmtTimestamp());
|
86 |
$callData['message_xml'] = '';
|
@@ -93,18 +109,27 @@ final class Creativestyle_AmazonPayments_Model_Logger {
|
|
93 |
$callData['message_xml'] = $requestBody['Message']['NotificationData'];
|
94 |
$requestBody['Message']['NotificationData'] = 'see XML message';
|
95 |
}
|
|
|
96 |
$callData['request_body'] = Mage::helper('core')->jsonEncode($requestBody);
|
97 |
}
|
98 |
} catch (Exception $e) {
|
99 |
Mage::logException($e);
|
100 |
}
|
101 |
}
|
|
|
|
|
102 |
if (($fileHandle = fopen(self::getAbsoluteLogFilePath('ipn'), 'a')) !== false) {
|
103 |
-
fputcsv(
|
|
|
|
|
|
|
|
|
|
|
104 |
fclose($fileHandle);
|
105 |
} else {
|
106 |
Mage::log('AMAZON PAY: unable to open ' . self::getAbsoluteLogFilePath('ipn') . ' for writing.');
|
107 |
}
|
|
|
108 |
}
|
109 |
}
|
110 |
|
@@ -113,8 +138,10 @@ final class Creativestyle_AmazonPayments_Model_Logger {
|
|
113 |
*
|
114 |
* @param Exception $e
|
115 |
*/
|
116 |
-
public static function logException(Exception $e)
|
|
|
117 |
if (self::_getConfig()->isLoggingActive()) {
|
|
|
118 |
if (($fileHandle = fopen(self::getAbsoluteLogFilePath('exception'), 'a')) !== false) {
|
119 |
$exceptionData = array(
|
120 |
'timestamp' => Mage::getModel('core/date')->gmtTimestamp(),
|
@@ -122,35 +149,68 @@ final class Creativestyle_AmazonPayments_Model_Logger {
|
|
122 |
'exception_message' => $e->getMessage(),
|
123 |
'exception_trace' => $e->getTraceAsString()
|
124 |
);
|
125 |
-
fputcsv(
|
|
|
|
|
|
|
|
|
|
|
126 |
fclose($fileHandle);
|
127 |
} else {
|
128 |
Mage::log('AMAZON PAY: unable to open ' . self::getAbsoluteLogFilePath('exception') . ' for writing.');
|
129 |
}
|
|
|
130 |
}
|
131 |
}
|
132 |
|
133 |
-
public static function getColumnMapping($logType)
|
|
|
134 |
switch ($logType) {
|
135 |
case 'api':
|
136 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
case 'exception':
|
138 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
139 |
case 'ipn':
|
140 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
}
|
|
|
142 |
return null;
|
143 |
}
|
144 |
|
145 |
-
public static function rotateLogfiles()
|
|
|
146 |
$logTypes = array('api', 'exception', 'ipn');
|
147 |
$maxFilesize = self::LOGFILE_ROTATION_SIZE * 1048576;
|
148 |
foreach ($logTypes as $logType) {
|
149 |
$filepath = self::getAbsoluteLogFilePath($logType);
|
|
|
150 |
if (file_exists($filepath) && filesize($filepath) > $maxFilesize) {
|
151 |
rename($filepath, $filepath . '.' . Mage::getModel('core/date')->date("Ymdhis"));
|
152 |
}
|
|
|
153 |
}
|
154 |
}
|
155 |
-
|
156 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
final class Creativestyle_AmazonPayments_Model_Logger
|
18 |
+
{
|
19 |
const AMAZON_LOG_DIR = 'amazonpayments';
|
20 |
|
21 |
+
const AMAZON_API_LOG_FILE = 'api_log.csv';
|
22 |
+
const AMAZON_EXCEPTION_LOG_FILE = 'exception_log.csv';
|
23 |
+
const AMAZON_IPN_LOG_FILE = 'ipn_log.csv';
|
24 |
|
25 |
const LOGFILE_ROTATION_SIZE = 8;
|
26 |
|
29 |
*
|
30 |
* @return Creativestyle_AmazonPayments_Model_Config
|
31 |
*/
|
32 |
+
protected static function _getConfig()
|
33 |
+
{
|
34 |
return Mage::getSingleton('amazonpayments/config');
|
35 |
}
|
36 |
|
40 |
* @param string $logType
|
41 |
* @return string|null
|
42 |
*/
|
43 |
+
public static function getAbsoluteLogFilePath($logType)
|
44 |
+
{
|
45 |
try {
|
46 |
$logDir = Mage::getBaseDir('log') . DS . self::AMAZON_LOG_DIR;
|
47 |
+
// @codingStandardsIgnoreStart
|
48 |
if (!is_dir($logDir)) {
|
49 |
mkdir($logDir, 0777, true);
|
50 |
}
|
51 |
+
// @codingStandardsIgnoreEnd
|
52 |
+
|
53 |
switch ($logType) {
|
54 |
case 'api':
|
55 |
return $logDir . DS . self::AMAZON_API_LOG_FILE;
|
61 |
} catch (Exception $e) {
|
62 |
Mage::logException($e);
|
63 |
}
|
64 |
+
|
65 |
return null;
|
66 |
}
|
67 |
|
70 |
*
|
71 |
* @param array $callData
|
72 |
*/
|
73 |
+
public static function logApiCall($callData)
|
74 |
+
{
|
75 |
if (self::_getConfig()->isLoggingActive()) {
|
76 |
array_unshift($callData, Mage::getModel('core/date')->gmtTimestamp());
|
77 |
+
// @codingStandardsIgnoreStart
|
78 |
if (($fileHandle = fopen(self::getAbsoluteLogFilePath('api'), 'a')) !== false) {
|
79 |
+
fputcsv(
|
80 |
+
$fileHandle,
|
81 |
+
$callData,
|
82 |
+
self::_getConfig()->getLogDelimiter(),
|
83 |
+
self::_getConfig()->getLogEnclosure()
|
84 |
+
);
|
85 |
fclose($fileHandle);
|
86 |
} else {
|
87 |
Mage::log('AMAZON PAY: unable to open ' . self::getAbsoluteLogFilePath('api') . ' for writing.');
|
88 |
}
|
89 |
+
// @codingStandardsIgnoreEnd
|
90 |
}
|
91 |
}
|
92 |
|
95 |
*
|
96 |
* @param array $callData
|
97 |
*/
|
98 |
+
public static function logIpnCall($callData)
|
99 |
+
{
|
100 |
if (self::_getConfig()->isLoggingActive()) {
|
101 |
array_unshift($callData, Mage::getModel('core/date')->gmtTimestamp());
|
102 |
$callData['message_xml'] = '';
|
109 |
$callData['message_xml'] = $requestBody['Message']['NotificationData'];
|
110 |
$requestBody['Message']['NotificationData'] = 'see XML message';
|
111 |
}
|
112 |
+
|
113 |
$callData['request_body'] = Mage::helper('core')->jsonEncode($requestBody);
|
114 |
}
|
115 |
} catch (Exception $e) {
|
116 |
Mage::logException($e);
|
117 |
}
|
118 |
}
|
119 |
+
|
120 |
+
// @codingStandardsIgnoreStart
|
121 |
if (($fileHandle = fopen(self::getAbsoluteLogFilePath('ipn'), 'a')) !== false) {
|
122 |
+
fputcsv(
|
123 |
+
$fileHandle,
|
124 |
+
$callData,
|
125 |
+
self::_getConfig()->getLogDelimiter(),
|
126 |
+
self::_getConfig()->getLogEnclosure()
|
127 |
+
);
|
128 |
fclose($fileHandle);
|
129 |
} else {
|
130 |
Mage::log('AMAZON PAY: unable to open ' . self::getAbsoluteLogFilePath('ipn') . ' for writing.');
|
131 |
}
|
132 |
+
// @codingStandardsIgnoreEnd
|
133 |
}
|
134 |
}
|
135 |
|
138 |
*
|
139 |
* @param Exception $e
|
140 |
*/
|
141 |
+
public static function logException(Exception $e)
|
142 |
+
{
|
143 |
if (self::_getConfig()->isLoggingActive()) {
|
144 |
+
// @codingStandardsIgnoreStart
|
145 |
if (($fileHandle = fopen(self::getAbsoluteLogFilePath('exception'), 'a')) !== false) {
|
146 |
$exceptionData = array(
|
147 |
'timestamp' => Mage::getModel('core/date')->gmtTimestamp(),
|
149 |
'exception_message' => $e->getMessage(),
|
150 |
'exception_trace' => $e->getTraceAsString()
|
151 |
);
|
152 |
+
fputcsv(
|
153 |
+
$fileHandle,
|
154 |
+
$exceptionData,
|
155 |
+
self::_getConfig()->getLogDelimiter(),
|
156 |
+
self::_getConfig()->getLogEnclosure()
|
157 |
+
);
|
158 |
fclose($fileHandle);
|
159 |
} else {
|
160 |
Mage::log('AMAZON PAY: unable to open ' . self::getAbsoluteLogFilePath('exception') . ' for writing.');
|
161 |
}
|
162 |
+
// @codingStandardsIgnoreEnd
|
163 |
}
|
164 |
}
|
165 |
|
166 |
+
public static function getColumnMapping($logType)
|
167 |
+
{
|
168 |
switch ($logType) {
|
169 |
case 'api':
|
170 |
+
return array(
|
171 |
+
'timestamp',
|
172 |
+
'call_url',
|
173 |
+
'call_action',
|
174 |
+
'query',
|
175 |
+
'response_code',
|
176 |
+
'response_error',
|
177 |
+
'response_headers',
|
178 |
+
'response_body'
|
179 |
+
);
|
180 |
case 'exception':
|
181 |
+
return array(
|
182 |
+
'timestamp',
|
183 |
+
'exception_code',
|
184 |
+
'exception_message',
|
185 |
+
'exception_trace'
|
186 |
+
);
|
187 |
case 'ipn':
|
188 |
+
return array(
|
189 |
+
'timestamp',
|
190 |
+
'notification_type',
|
191 |
+
'transaction_id',
|
192 |
+
'response_code',
|
193 |
+
'response_error',
|
194 |
+
'request_headers',
|
195 |
+
'request_body',
|
196 |
+
'message_xml'
|
197 |
+
);
|
198 |
}
|
199 |
+
|
200 |
return null;
|
201 |
}
|
202 |
|
203 |
+
public static function rotateLogfiles()
|
204 |
+
{
|
205 |
$logTypes = array('api', 'exception', 'ipn');
|
206 |
$maxFilesize = self::LOGFILE_ROTATION_SIZE * 1048576;
|
207 |
foreach ($logTypes as $logType) {
|
208 |
$filepath = self::getAbsoluteLogFilePath($logType);
|
209 |
+
// @codingStandardsIgnoreStart
|
210 |
if (file_exists($filepath) && filesize($filepath) > $maxFilesize) {
|
211 |
rename($filepath, $filepath . '.' . Mage::getModel('core/date')->date("Ymdhis"));
|
212 |
}
|
213 |
+
// @codingStandardsIgnoreEnd
|
214 |
}
|
215 |
}
|
|
|
216 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Abstract.php
CHANGED
@@ -1,30 +1,44 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Abstract extends Varien_Object
|
17 |
-
|
|
|
|
|
|
|
18 |
protected $_options = null;
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
$result = array();
|
22 |
$_options = $this->toOptionArray();
|
23 |
foreach ($_options as $_option) {
|
24 |
-
if (isset($_option['label']) && isset($_option['value']))
|
25 |
$result[$_option['value']] = $_option['label'];
|
|
|
26 |
}
|
|
|
27 |
return $result;
|
28 |
}
|
29 |
|
|
|
|
|
|
|
|
|
30 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Model_Lookup_Abstract extends Varien_Object
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @var array|null
|
21 |
+
*/
|
22 |
protected $_options = null;
|
23 |
|
24 |
+
/**
|
25 |
+
* @return array
|
26 |
+
*/
|
27 |
+
public function getOptions()
|
28 |
+
{
|
29 |
$result = array();
|
30 |
$_options = $this->toOptionArray();
|
31 |
foreach ($_options as $_option) {
|
32 |
+
if (isset($_option['label']) && isset($_option['value'])) {
|
33 |
$result[$_option['value']] = $_option['label'];
|
34 |
+
}
|
35 |
}
|
36 |
+
|
37 |
return $result;
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
+
* @return array
|
42 |
+
*/
|
43 |
+
abstract public function toOptionArray();
|
44 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/AccountRegion.php
CHANGED
@@ -1,25 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_AccountRegion extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
17 |
-
|
18 |
-
protected function _getRegions()
|
19 |
-
|
|
|
20 |
}
|
21 |
|
22 |
-
public function toOptionArray()
|
|
|
23 |
if (null === $this->_options) {
|
24 |
$this->_options = array();
|
25 |
foreach ($this->_getRegions() as $region => $regionName) {
|
@@ -29,15 +32,17 @@ class Creativestyle_AmazonPayments_Model_Lookup_AccountRegion extends Creativest
|
|
29 |
);
|
30 |
}
|
31 |
}
|
|
|
32 |
return $this->_options;
|
33 |
}
|
34 |
|
35 |
-
public function getRegionLabelByCode($code)
|
|
|
36 |
$regions = $this->getOptions();
|
37 |
if (array_key_exists($code, $regions)) {
|
38 |
return $regions[$code];
|
39 |
}
|
|
|
40 |
return null;
|
41 |
}
|
42 |
-
|
43 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2016 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2016 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_AccountRegion extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
18 |
+
{
|
19 |
+
protected function _getRegions()
|
20 |
+
{
|
21 |
+
return Mage::getSingleton('amazonpayments/config')->getGlobalConfigData('account_regions');
|
22 |
}
|
23 |
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
if (null === $this->_options) {
|
27 |
$this->_options = array();
|
28 |
foreach ($this->_getRegions() as $region => $regionName) {
|
32 |
);
|
33 |
}
|
34 |
}
|
35 |
+
|
36 |
return $this->_options;
|
37 |
}
|
38 |
|
39 |
+
public function getRegionLabelByCode($code)
|
40 |
+
{
|
41 |
$regions = $this->getOptions();
|
42 |
if (array_key_exists($code, $regions)) {
|
43 |
return $regions[$code];
|
44 |
}
|
45 |
+
|
46 |
return null;
|
47 |
}
|
|
|
48 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Authentication.php
CHANGED
@@ -1,25 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Authentication
|
17 |
-
|
|
|
18 |
const AUTO_EXPERIENCE = 'auto';
|
19 |
const POPUP_EXPERIENCE = 'popup';
|
20 |
const REDIRECT_EXPERIENCE = 'redirect';
|
21 |
|
22 |
-
public function toOptionArray()
|
|
|
23 |
if (null === $this->_options) {
|
24 |
$this->_options = array(
|
25 |
array('value' => self::AUTO_EXPERIENCE, 'label' => Mage::helper('amazonpayments')->__('Auto')),
|
@@ -27,6 +30,7 @@ class Creativestyle_AmazonPayments_Model_Lookup_Authentication extends Creatives
|
|
27 |
array('value' => self::REDIRECT_EXPERIENCE, 'label' => Mage::helper('amazonpayments')->__('Redirect')),
|
28 |
);
|
29 |
}
|
|
|
30 |
return $this->_options;
|
31 |
}
|
32 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2015 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2015 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_Authentication
|
18 |
+
extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
19 |
+
{
|
20 |
const AUTO_EXPERIENCE = 'auto';
|
21 |
const POPUP_EXPERIENCE = 'popup';
|
22 |
const REDIRECT_EXPERIENCE = 'redirect';
|
23 |
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
if (null === $this->_options) {
|
27 |
$this->_options = array(
|
28 |
array('value' => self::AUTO_EXPERIENCE, 'label' => Mage::helper('amazonpayments')->__('Auto')),
|
30 |
array('value' => self::REDIRECT_EXPERIENCE, 'label' => Mage::helper('amazonpayments')->__('Redirect')),
|
31 |
);
|
32 |
}
|
33 |
+
|
34 |
return $this->_options;
|
35 |
}
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/AuthorizationMode.php
CHANGED
@@ -1,30 +1,36 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_AuthorizationMode
|
17 |
-
|
|
|
|
|
18 |
const ASYNCHRONOUS = 'asynchronous';
|
19 |
const SYNCHRONOUS = 'synchronous';
|
20 |
|
21 |
-
public function toOptionArray()
|
|
|
22 |
if (null === $this->_options) {
|
23 |
$this->_options = array(
|
24 |
-
array('value' => self::
|
25 |
array('value' => self::SYNCHRONOUS, 'label' => Mage::helper('amazonpayments')->__('Synchronous')),
|
|
|
26 |
);
|
27 |
}
|
|
|
28 |
return $this->_options;
|
29 |
}
|
30 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2015 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_AuthorizationMode
|
18 |
+
extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
19 |
+
{
|
20 |
+
const AUTO = 'auto';
|
21 |
const ASYNCHRONOUS = 'asynchronous';
|
22 |
const SYNCHRONOUS = 'synchronous';
|
23 |
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
if (null === $this->_options) {
|
27 |
$this->_options = array(
|
28 |
+
array('value' => self::AUTO, 'label' => Mage::helper('amazonpayments')->__('Auto')),
|
29 |
array('value' => self::SYNCHRONOUS, 'label' => Mage::helper('amazonpayments')->__('Synchronous')),
|
30 |
+
array('value' => self::ASYNCHRONOUS, 'label' => Mage::helper('amazonpayments')->__('Asynchronous'))
|
31 |
);
|
32 |
}
|
33 |
+
|
34 |
return $this->_options;
|
35 |
}
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Color.php
CHANGED
@@ -1,30 +1,37 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Color
|
17 |
-
|
|
|
18 |
const COLOR_ORANGE = 'orange';
|
19 |
const COLOR_TAN = 'tan';
|
20 |
|
21 |
-
public function toOptionArray()
|
|
|
22 |
if (null === $this->_options) {
|
23 |
$this->_options = array(
|
24 |
-
array(
|
|
|
|
|
|
|
25 |
array('value' => self::COLOR_TAN, 'label' => Mage::helper('amazonpayments')->__('Tan')),
|
26 |
);
|
27 |
}
|
|
|
28 |
return $this->_options;
|
29 |
}
|
30 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Color
|
18 |
+
extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
19 |
+
{
|
20 |
const COLOR_ORANGE = 'orange';
|
21 |
const COLOR_TAN = 'tan';
|
22 |
|
23 |
+
public function toOptionArray()
|
24 |
+
{
|
25 |
if (null === $this->_options) {
|
26 |
$this->_options = array(
|
27 |
+
array(
|
28 |
+
'value' => self::COLOR_ORANGE,
|
29 |
+
'label' => Mage::helper('amazonpayments')->__('Orange (recommended)')
|
30 |
+
),
|
31 |
array('value' => self::COLOR_TAN, 'label' => Mage::helper('amazonpayments')->__('Tan')),
|
32 |
);
|
33 |
}
|
34 |
+
|
35 |
return $this->_options;
|
36 |
}
|
37 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Color/LoginPay.php
CHANGED
@@ -1,25 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Color_LoginPay
|
17 |
-
|
|
|
18 |
const COLOR_GOLD = 'Gold';
|
19 |
const COLOR_DARK_GRAY = 'DarkGray';
|
20 |
const COLOR_LIGHT_GRAY= 'LightGray';
|
21 |
|
22 |
-
public function toOptionArray()
|
|
|
23 |
if (null === $this->_options) {
|
24 |
$this->_options = array(
|
25 |
array('value' => self::COLOR_GOLD, 'label' => Mage::helper('amazonpayments')->__('Gold')),
|
@@ -27,7 +30,7 @@ class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Color_LoginPay ext
|
|
27 |
array('value' => self::COLOR_LIGHT_GRAY, 'label' => Mage::helper('amazonpayments')->__('Light gray'))
|
28 |
);
|
29 |
}
|
|
|
30 |
return $this->_options;
|
31 |
}
|
32 |
-
|
33 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Color_LoginPay
|
18 |
+
extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
19 |
+
{
|
20 |
const COLOR_GOLD = 'Gold';
|
21 |
const COLOR_DARK_GRAY = 'DarkGray';
|
22 |
const COLOR_LIGHT_GRAY= 'LightGray';
|
23 |
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
if (null === $this->_options) {
|
27 |
$this->_options = array(
|
28 |
array('value' => self::COLOR_GOLD, 'label' => Mage::helper('amazonpayments')->__('Gold')),
|
30 |
array('value' => self::COLOR_LIGHT_GRAY, 'label' => Mage::helper('amazonpayments')->__('Light gray'))
|
31 |
);
|
32 |
}
|
33 |
+
|
34 |
return $this->_options;
|
35 |
}
|
|
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Size.php
CHANGED
@@ -1,25 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Size
|
17 |
-
|
|
|
18 |
const SIZE_MEDIUM = 'medium';
|
19 |
const SIZE_LARGE = 'large';
|
20 |
const SIZE_XLARGE = 'x-large';
|
21 |
|
22 |
-
public function toOptionArray()
|
|
|
23 |
if (null === $this->_options) {
|
24 |
$this->_options = array(
|
25 |
array('value' => self::SIZE_MEDIUM, 'label' => Mage::helper('amazonpayments')->__('Medium')),
|
@@ -27,6 +30,7 @@ class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Size extends Creat
|
|
27 |
array('value' => self::SIZE_XLARGE, 'label' => Mage::helper('amazonpayments')->__('X-Large'))
|
28 |
);
|
29 |
}
|
|
|
30 |
return $this->_options;
|
31 |
}
|
32 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Size
|
18 |
+
extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
19 |
+
{
|
20 |
const SIZE_MEDIUM = 'medium';
|
21 |
const SIZE_LARGE = 'large';
|
22 |
const SIZE_XLARGE = 'x-large';
|
23 |
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
if (null === $this->_options) {
|
27 |
$this->_options = array(
|
28 |
array('value' => self::SIZE_MEDIUM, 'label' => Mage::helper('amazonpayments')->__('Medium')),
|
30 |
array('value' => self::SIZE_XLARGE, 'label' => Mage::helper('amazonpayments')->__('X-Large'))
|
31 |
);
|
32 |
}
|
33 |
+
|
34 |
return $this->_options;
|
35 |
}
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Size/LoginPay.php
CHANGED
@@ -1,26 +1,29 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Size_LoginPay
|
17 |
-
|
|
|
18 |
const SIZE_SMALL = 'small';
|
19 |
const SIZE_MEDIUM = 'medium';
|
20 |
const SIZE_LARGE = 'large';
|
21 |
const SIZE_XLARGE = 'x-large';
|
22 |
|
23 |
-
public function toOptionArray()
|
|
|
24 |
if (null === $this->_options) {
|
25 |
$this->_options = array(
|
26 |
array('value' => self::SIZE_SMALL, 'label' => Mage::helper('amazonpayments')->__('Small')),
|
@@ -29,7 +32,7 @@ class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Size_LoginPay exte
|
|
29 |
array('value' => self::SIZE_XLARGE, 'label' => Mage::helper('amazonpayments')->__('X-Large'))
|
30 |
);
|
31 |
}
|
|
|
32 |
return $this->_options;
|
33 |
}
|
34 |
-
|
35 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Size_LoginPay
|
18 |
+
extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
19 |
+
{
|
20 |
const SIZE_SMALL = 'small';
|
21 |
const SIZE_MEDIUM = 'medium';
|
22 |
const SIZE_LARGE = 'large';
|
23 |
const SIZE_XLARGE = 'x-large';
|
24 |
|
25 |
+
public function toOptionArray()
|
26 |
+
{
|
27 |
if (null === $this->_options) {
|
28 |
$this->_options = array(
|
29 |
array('value' => self::SIZE_SMALL, 'label' => Mage::helper('amazonpayments')->__('Small')),
|
32 |
array('value' => self::SIZE_XLARGE, 'label' => Mage::helper('amazonpayments')->__('X-Large'))
|
33 |
);
|
34 |
}
|
35 |
+
|
36 |
return $this->_options;
|
37 |
}
|
|
|
38 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Type/Login.php
CHANGED
@@ -1,25 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Type_Login
|
17 |
-
|
|
|
18 |
const TYPE_FULL = 'LwA';
|
19 |
const TYPE_SHORT = 'Login';
|
20 |
const TYPE_LOGO = 'A';
|
21 |
|
22 |
-
public function toOptionArray()
|
|
|
23 |
if (null === $this->_options) {
|
24 |
$this->_options = array(
|
25 |
array('value' => self::TYPE_FULL, 'label' => Mage::helper('amazonpayments')->__('Login with Amazon')),
|
@@ -27,6 +30,7 @@ class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Type_Login extends
|
|
27 |
array('value' => self::TYPE_LOGO, 'label' => Mage::helper('amazonpayments')->__('Amazon logo'))
|
28 |
);
|
29 |
}
|
|
|
30 |
return $this->_options;
|
31 |
}
|
32 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Type_Login
|
18 |
+
extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
19 |
+
{
|
20 |
const TYPE_FULL = 'LwA';
|
21 |
const TYPE_SHORT = 'Login';
|
22 |
const TYPE_LOGO = 'A';
|
23 |
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
if (null === $this->_options) {
|
27 |
$this->_options = array(
|
28 |
array('value' => self::TYPE_FULL, 'label' => Mage::helper('amazonpayments')->__('Login with Amazon')),
|
30 |
array('value' => self::TYPE_LOGO, 'label' => Mage::helper('amazonpayments')->__('Amazon logo'))
|
31 |
);
|
32 |
}
|
33 |
+
|
34 |
return $this->_options;
|
35 |
}
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Design/Button/Type/Pay.php
CHANGED
@@ -1,25 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Type_Pay
|
17 |
-
|
|
|
18 |
const TYPE_FULL = 'PwA';
|
19 |
const TYPE_SHORT = 'Pay';
|
20 |
const TYPE_LOGO = 'A';
|
21 |
|
22 |
-
public function toOptionArray()
|
|
|
23 |
if (null === $this->_options) {
|
24 |
$this->_options = array(
|
25 |
array('value' => self::TYPE_FULL, 'label' => Mage::helper('amazonpayments')->__('Amazon Pay')),
|
@@ -27,6 +30,7 @@ class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Type_Pay extends C
|
|
27 |
array('value' => self::TYPE_LOGO, 'label' => Mage::helper('amazonpayments')->__('Amazon logo'))
|
28 |
);
|
29 |
}
|
|
|
30 |
return $this->_options;
|
31 |
}
|
32 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_Design_Button_Type_Pay
|
18 |
+
extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
19 |
+
{
|
20 |
const TYPE_FULL = 'PwA';
|
21 |
const TYPE_SHORT = 'Pay';
|
22 |
const TYPE_LOGO = 'A';
|
23 |
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
if (null === $this->_options) {
|
27 |
$this->_options = array(
|
28 |
array('value' => self::TYPE_FULL, 'label' => Mage::helper('amazonpayments')->__('Amazon Pay')),
|
30 |
array('value' => self::TYPE_LOGO, 'label' => Mage::helper('amazonpayments')->__('Amazon logo'))
|
31 |
);
|
32 |
}
|
33 |
+
|
34 |
return $this->_options;
|
35 |
}
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Frequency.php
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Frequency extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
17 |
-
|
18 |
const FREQUENCY_5_MINUTES = '5 minutes';
|
19 |
const FREQUENCY_10_MINUTES = '10 minutes';
|
20 |
const FREQUENCY_15_MINUTES = '15 minutes';
|
@@ -32,7 +33,8 @@ class Creativestyle_AmazonPayments_Model_Lookup_Frequency extends Creativestyle_
|
|
32 |
const FREQUENCY_15_DAYS = '15 days';
|
33 |
const FREQUENCY_30_DAYS = '30 days';
|
34 |
|
35 |
-
public function toOptionArray()
|
|
|
36 |
if (null === $this->_options) {
|
37 |
$this->_options = array(
|
38 |
array(
|
@@ -101,7 +103,7 @@ class Creativestyle_AmazonPayments_Model_Lookup_Frequency extends Creativestyle_
|
|
101 |
)
|
102 |
);
|
103 |
}
|
|
|
104 |
return $this->_options;
|
105 |
}
|
106 |
-
|
107 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_Frequency extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
18 |
+
{
|
19 |
const FREQUENCY_5_MINUTES = '5 minutes';
|
20 |
const FREQUENCY_10_MINUTES = '10 minutes';
|
21 |
const FREQUENCY_15_MINUTES = '15 minutes';
|
33 |
const FREQUENCY_15_DAYS = '15 days';
|
34 |
const FREQUENCY_30_DAYS = '30 days';
|
35 |
|
36 |
+
public function toOptionArray()
|
37 |
+
{
|
38 |
if (null === $this->_options) {
|
39 |
$this->_options = array(
|
40 |
array(
|
103 |
)
|
104 |
);
|
105 |
}
|
106 |
+
|
107 |
return $this->_options;
|
108 |
}
|
|
|
109 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/IpnActive.php
CHANGED
@@ -1,21 +1,23 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_IpnActive extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
17 |
-
|
18 |
-
public function toOptionArray()
|
|
|
19 |
if (null === $this->_options) {
|
20 |
$this->_options = array(
|
21 |
array(
|
@@ -28,7 +30,7 @@ class Creativestyle_AmazonPayments_Model_Lookup_IpnActive extends Creativestyle_
|
|
28 |
)
|
29 |
);
|
30 |
}
|
|
|
31 |
return $this->_options;
|
32 |
}
|
33 |
-
|
34 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_IpnActive extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
18 |
+
{
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
if (null === $this->_options) {
|
22 |
$this->_options = array(
|
23 |
array(
|
30 |
)
|
31 |
);
|
32 |
}
|
33 |
+
|
34 |
return $this->_options;
|
35 |
}
|
|
|
36 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Language.php
CHANGED
@@ -1,71 +1,86 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Language extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
17 |
-
|
18 |
const LANGUAGE_EN_GB = 'en-GB';
|
19 |
const LANGUAGE_DE_DE = 'de-DE';
|
20 |
const LANGUAGE_FR_FR = 'fr-FR';
|
21 |
const LANGUAGE_IT_IT = 'it-IT';
|
22 |
const LANGUAGE_ES_ES = 'es-ES';
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
if (null === $this->_options) {
|
26 |
-
$this->_options = array(
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
array(
|
32 |
-
'value' =>
|
33 |
-
'label' => Mage::helper('amazonpayments')->__(
|
34 |
-
)
|
35 |
-
|
36 |
-
'value' => self::LANGUAGE_DE_DE,
|
37 |
-
'label' => Mage::helper('amazonpayments')->__('German')
|
38 |
-
),
|
39 |
-
array(
|
40 |
-
'value' => self::LANGUAGE_FR_FR,
|
41 |
-
'label' => Mage::helper('amazonpayments')->__('French')
|
42 |
-
),
|
43 |
-
array(
|
44 |
-
'value' => self::LANGUAGE_IT_IT,
|
45 |
-
'label' => Mage::helper('amazonpayments')->__('Italian')
|
46 |
-
),
|
47 |
-
array(
|
48 |
-
'value' => self::LANGUAGE_ES_ES,
|
49 |
-
'label' => Mage::helper('amazonpayments')->__('Spanish')
|
50 |
-
)
|
51 |
-
);
|
52 |
}
|
|
|
53 |
return $this->_options;
|
54 |
}
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
}
|
67 |
}
|
|
|
68 |
return null;
|
69 |
}
|
70 |
-
|
71 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_Language extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
18 |
+
{
|
19 |
const LANGUAGE_EN_GB = 'en-GB';
|
20 |
const LANGUAGE_DE_DE = 'de-DE';
|
21 |
const LANGUAGE_FR_FR = 'fr-FR';
|
22 |
const LANGUAGE_IT_IT = 'it-IT';
|
23 |
const LANGUAGE_ES_ES = 'es-ES';
|
24 |
|
25 |
+
/**
|
26 |
+
* Array of allowed display languages for Amazon widgets
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
protected $_allowedLanguages = array(
|
31 |
+
self::LANGUAGE_EN_GB => 'English',
|
32 |
+
self::LANGUAGE_DE_DE => 'German',
|
33 |
+
self::LANGUAGE_FR_FR => 'French',
|
34 |
+
self::LANGUAGE_IT_IT => 'Italian',
|
35 |
+
self::LANGUAGE_ES_ES => 'Spanish'
|
36 |
+
);
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function toOptionArray()
|
42 |
+
{
|
43 |
if (null === $this->_options) {
|
44 |
+
$this->_options = array(array(
|
45 |
+
'value' => '',
|
46 |
+
'label' => Mage::helper('amazonpayments')->__('Auto')
|
47 |
+
));
|
48 |
+
foreach ($this->_allowedLanguages as $languageCode => $languageName) {
|
49 |
+
$this->_options[] = array(
|
50 |
+
'value' => $languageCode,
|
51 |
+
'label' => Mage::helper('amazonpayments')->__($languageName)
|
52 |
+
);
|
53 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
+
|
56 |
return $this->_options;
|
57 |
}
|
58 |
|
59 |
+
/**
|
60 |
+
* @param string|null $locale
|
61 |
+
* @param bool $isoFormatReturn
|
62 |
+
* @return string|null
|
63 |
+
*/
|
64 |
+
public function getLanguageByLocale($locale = null, $isoFormatReturn = false)
|
65 |
+
{
|
66 |
+
if (null === $locale) {
|
67 |
+
$locale = Mage::app()->getLocale()->getLocaleCode();
|
68 |
}
|
69 |
+
|
70 |
+
$amazonLocale = str_replace('_', '-', $locale);
|
71 |
+
|
72 |
+
if (in_array($amazonLocale, array_keys($this->_allowedLanguages))) {
|
73 |
+
return $isoFormatReturn ? $locale : $amazonLocale;
|
74 |
+
}
|
75 |
+
|
76 |
+
$localeLanguagePart = substr($locale, 0, 2);
|
77 |
+
|
78 |
+
foreach ($this->_allowedLanguages as $languageCode => $languageName) {
|
79 |
+
if (false !== strpos($languageCode, $localeLanguagePart)) {
|
80 |
+
return $isoFormatReturn ? str_replace('-', '_', $languageCode) : $languageCode;
|
81 |
}
|
82 |
}
|
83 |
+
|
84 |
return null;
|
85 |
}
|
|
|
86 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/PaymentAction.php
CHANGED
@@ -1,21 +1,23 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_PaymentAction extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
17 |
-
|
18 |
-
public function toOptionArray()
|
|
|
19 |
if (null === $this->_options) {
|
20 |
$this->_options = array(
|
21 |
array(
|
@@ -36,8 +38,7 @@ class Creativestyle_AmazonPayments_Model_Lookup_PaymentAction extends Creativest
|
|
36 |
)
|
37 |
);
|
38 |
}
|
|
|
39 |
return $this->_options;
|
40 |
}
|
41 |
-
|
42 |
}
|
43 |
-
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Lookup_PaymentAction extends Creativestyle_AmazonPayments_Model_Lookup_Abstract
|
18 |
+
{
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
if (null === $this->_options) {
|
22 |
$this->_options = array(
|
23 |
array(
|
38 |
)
|
39 |
);
|
40 |
}
|
41 |
+
|
42 |
return $this->_options;
|
43 |
}
|
|
|
44 |
}
|
|
app/code/community/Creativestyle/AmazonPayments/Model/Lookup/Region.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Lookup_Region extends Creativestyle_AmazonPayments_Model_Lookup_Abstract {
|
17 |
-
|
18 |
-
protected function _getRegions() {
|
19 |
-
return Mage::getSingleton('amazonpayments/config')->getGlobalDataValue('regions');
|
20 |
-
}
|
21 |
-
|
22 |
-
public function toOptionArray() {
|
23 |
-
if (null === $this->_options) {
|
24 |
-
$this->_options = array();
|
25 |
-
foreach ($this->_getRegions() as $region => $regionName) {
|
26 |
-
$this->_options[] = array(
|
27 |
-
'value' => $region,
|
28 |
-
'label' => Mage::helper('amazonpayments')->__($regionName)
|
29 |
-
);
|
30 |
-
}
|
31 |
-
}
|
32 |
-
return $this->_options;
|
33 |
-
}
|
34 |
-
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Model/Observer.php
CHANGED
@@ -1,108 +1,132 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Observer
|
|
|
17 |
|
18 |
const DATA_POLL_TRANSACTION_LIMIT = 36;
|
19 |
const DATA_POLL_SLEEP_BETWEEN_TIME = 300000;
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
protected function _getConfig()
|
|
|
27 |
return Mage::getSingleton('amazonpayments/config');
|
28 |
}
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
// **********************************************************************
|
33 |
-
// Transactions details fetching routines
|
34 |
-
|
35 |
/**
|
36 |
-
*
|
37 |
*
|
38 |
-
* @
|
39 |
*/
|
40 |
-
protected function
|
41 |
-
|
42 |
-
|
43 |
-
->importTransactionInfo($transaction);
|
44 |
-
return $transaction->save();
|
45 |
}
|
46 |
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
55 |
->addFieldToFilter('is_closed', 0)
|
56 |
->setOrder('transaction_id', 'asc');
|
57 |
|
58 |
-
$recentPolledTransaction = $this->_getConfig()->getRecentPolledTransaction()
|
59 |
-
if ($recentPolledTransaction) {
|
60 |
$collection->addFieldToFilter('transaction_id', array('gt' => (int)$recentPolledTransaction));
|
61 |
}
|
62 |
|
63 |
-
$collection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
|
|
|
|
65 |
$recentTransactionId = null;
|
66 |
$count = 0;
|
67 |
-
$dateModel = Mage::getModel('core/date');
|
68 |
|
69 |
-
|
|
|
70 |
try {
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
$recentTransactionId = $this->_fetchTransactionInfo($transaction)->getId();
|
81 |
-
$count++;
|
82 |
-
usleep(self::DATA_POLL_SLEEP_BETWEEN_TIME);
|
83 |
-
}
|
84 |
-
break;
|
85 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_OPEN:
|
86 |
-
$txnAge = floor(($dateModel->timestamp() - $dateModel->timestamp($transaction->getCreatedAt())) / (60 * 60 * 24));
|
87 |
-
if (($txnType == Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER && $txnAge > 180) ||
|
88 |
-
($txnType == Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH && $txnAge > 30)) {
|
89 |
-
$recentTransactionId = $this->_fetchTransactionInfo($transaction)->getId();
|
90 |
-
$count++;
|
91 |
-
usleep(self::DATA_POLL_SLEEP_BETWEEN_TIME);
|
92 |
-
}
|
93 |
-
break;
|
94 |
-
case null:
|
95 |
-
$recentTransactionId = $this->_fetchTransactionInfo($transaction)->getId();
|
96 |
-
$count++;
|
97 |
-
usleep(self::DATA_POLL_SLEEP_BETWEEN_TIME);
|
98 |
break;
|
|
|
99 |
|
|
|
100 |
}
|
101 |
-
|
|
|
|
|
|
|
102 |
break;
|
103 |
}
|
104 |
-
} catch (Exception $e) {
|
105 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
106 |
}
|
107 |
}
|
108 |
|
@@ -112,88 +136,51 @@ class Creativestyle_AmazonPayments_Model_Observer {
|
|
112 |
|
113 |
$this->_getConfig()->setRecentPolledTransaction($recentTransactionId);
|
114 |
|
115 |
-
}
|
116 |
-
|
117 |
-
protected function _shouldUpdateParentTransaction($transaction) {
|
118 |
-
switch ($transaction->getTxnType() && !$transaction->getData('skip_update_parent_transaction')) {
|
119 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
|
120 |
-
return in_array($this->_getTransactionStatus($transaction), array(
|
121 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED,
|
122 |
-
/* temporary disabled as resulting in missing panrent order transaction for auth & capture */
|
123 |
-
// Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED
|
124 |
-
));
|
125 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
|
126 |
-
return in_array($this->_getTransactionStatus($transaction), array(
|
127 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_COMPLETED,
|
128 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED,
|
129 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED
|
130 |
-
));
|
131 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
|
132 |
-
return in_array($this->_getTransactionStatus($transaction), array(
|
133 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_COMPLETED,
|
134 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED
|
135 |
-
));
|
136 |
-
}
|
137 |
-
return false;
|
138 |
-
}
|
139 |
-
|
140 |
-
protected function _updateParentTransaction($transaction) {
|
141 |
-
if ($this->_shouldUpdateParentTransaction($transaction)) {
|
142 |
-
if ($parentTransaction = $transaction->getParentTransaction()) {
|
143 |
-
$transaction->setData('skip_update_parent_transaction', true);
|
144 |
-
$this->_fetchTransactionInfo($parentTransaction);
|
145 |
-
}
|
146 |
-
}
|
147 |
return $this;
|
148 |
}
|
149 |
|
150 |
-
protected function _updateOrderTransaction($transaction, $shouldSave = true) {
|
151 |
-
if ($transaction->getTxnType() == Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE) {
|
152 |
-
if ($this->_getTransactionStatus($transaction) == Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_COMPLETED) {
|
153 |
-
$payment = $transaction->getOrderPaymentObject();
|
154 |
-
if ($payment && !$payment->getOrder()->canInvoice()) {
|
155 |
-
Mage::getModel('amazonpayments/processor_payment')
|
156 |
-
->setPaymentObject($payment)
|
157 |
-
->closeOrderReference();
|
158 |
-
}
|
159 |
-
}
|
160 |
-
}
|
161 |
-
return $this;
|
162 |
-
}
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
// **********************************************************************
|
167 |
-
// Event observers
|
168 |
-
|
169 |
/**
|
170 |
* Inject Authorize button to the admin order view page
|
171 |
*
|
172 |
* @param Varien_Event_Observer $observer
|
173 |
-
* @return
|
174 |
*/
|
175 |
-
public function injectAuthorizeButton($observer)
|
|
|
|
|
176 |
try {
|
177 |
$order = Mage::registry('sales_order');
|
178 |
// check if object instance exists and whether manual authorization is enabled
|
179 |
-
if (
|
180 |
-
&& Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/amazonpayments_authorize')
|
|
|
181 |
$payment = $order->getPayment();
|
182 |
-
if (
|
183 |
// check if payment wasn't authorized already
|
184 |
-
$orderTransaction =
|
185 |
-
|
|
|
|
|
|
|
186 |
// invoke injectAuthorizeButton helper if authorization transaction does not exist or is closed
|
187 |
-
if ($orderTransaction && !$orderTransaction->getIsClosed()
|
|
|
188 |
$block = Mage::getSingleton('core/layout')->getBlock('sales_order_edit');
|
189 |
if ($block) {
|
190 |
-
$url = Mage::getModel('adminhtml/url')->getUrl(
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
'
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
}
|
198 |
}
|
199 |
}
|
@@ -201,6 +188,26 @@ class Creativestyle_AmazonPayments_Model_Observer {
|
|
201 |
} catch (Exception $e) {
|
202 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
203 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
return $this;
|
205 |
}
|
206 |
|
@@ -208,13 +215,15 @@ class Creativestyle_AmazonPayments_Model_Observer {
|
|
208 |
* Capture and log Amazon Payments API call
|
209 |
*
|
210 |
* @param Varien_Event_Observer $observer
|
211 |
-
* @return
|
212 |
*/
|
213 |
-
public function logApiCall($observer)
|
|
|
214 |
$callData = $observer->getEvent()->getCallData();
|
215 |
if (is_array($callData)) {
|
216 |
Creativestyle_AmazonPayments_Model_Logger::logApiCall($callData);
|
217 |
}
|
|
|
218 |
return $this;
|
219 |
}
|
220 |
|
@@ -222,100 +231,81 @@ class Creativestyle_AmazonPayments_Model_Observer {
|
|
222 |
* Capture and log incoming IPN notification
|
223 |
*
|
224 |
* @param Varien_Event_Observer $observer
|
225 |
-
* @return
|
226 |
*/
|
227 |
-
public function logIpnCall($observer)
|
|
|
228 |
$callData = $observer->getEvent()->getCallData();
|
229 |
if (is_array($callData)) {
|
230 |
Creativestyle_AmazonPayments_Model_Logger::logIpnCall($callData);
|
231 |
}
|
232 |
-
return $this;
|
233 |
-
}
|
234 |
|
235 |
-
public function closeTransaction($observer) {
|
236 |
-
try {
|
237 |
-
$transaction = $observer->getEvent()->getOrderPaymentTransaction();
|
238 |
-
if ($transaction->getId() && in_array($transaction->getOrderPaymentObject()->getMethod(), Mage::helper('amazonpayments')->getAvailablePaymentMethods())) {
|
239 |
-
if (in_array($this->_getTransactionStatus($transaction), array(
|
240 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED,
|
241 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_COMPLETED,
|
242 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CANCELED,
|
243 |
-
Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED
|
244 |
-
))) {
|
245 |
-
$transaction->setIsClosed(true);
|
246 |
-
}
|
247 |
-
}
|
248 |
-
} catch (Exception $e) {
|
249 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
250 |
-
}
|
251 |
-
return $this;
|
252 |
-
}
|
253 |
-
|
254 |
-
public function updateParentTransaction($observer) {
|
255 |
-
try {
|
256 |
-
$transaction = $observer->getEvent()->getOrderPaymentTransaction();
|
257 |
-
if ($transaction->getId() && in_array($transaction->getOrderPaymentObject()->getMethod(), Mage::helper('amazonpayments')->getAvailablePaymentMethods())) {
|
258 |
-
$this->_updateOrderTransaction($transaction);
|
259 |
-
$this->_updateParentTransaction($transaction);
|
260 |
-
}
|
261 |
-
} catch (Exception $e) {
|
262 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
263 |
-
}
|
264 |
return $this;
|
265 |
}
|
266 |
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
try {
|
269 |
$secureUrlsConfigNode = Mage::getConfig()->getNode('frontend/secure_url');
|
270 |
-
if ($this->_getConfig()->
|
271 |
-
&& !$this->_getConfig()->isRedirectAuthenticationExperience())
|
272 |
-
{
|
273 |
$secureUrlsConfigNode->addChild('amazonpayments_cart', '/checkout/cart');
|
274 |
}
|
275 |
-
|
|
|
|
|
276 |
unset($secureUrlsConfigNode->amazonpayments_ipn);
|
|
|
|
|
277 |
}
|
278 |
} catch (Exception $e) {
|
279 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
280 |
}
|
|
|
281 |
return $this;
|
282 |
}
|
283 |
|
284 |
-
|
285 |
-
|
286 |
-
// **********************************************************************
|
287 |
-
// Cronjobs
|
288 |
-
|
289 |
/**
|
290 |
-
* Invokes Amazon Payments
|
291 |
*
|
292 |
-
* @return
|
|
|
293 |
*/
|
294 |
-
public function rotateLogfiles()
|
|
|
295 |
try {
|
296 |
Creativestyle_AmazonPayments_Model_Logger::rotateLogfiles();
|
297 |
} catch (Exception $e) {
|
298 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
299 |
throw $e;
|
300 |
}
|
|
|
301 |
return $this;
|
302 |
}
|
303 |
|
304 |
/**
|
305 |
* Invokes data polling from Amazon Payments gateway
|
306 |
*
|
307 |
-
* @return
|
|
|
308 |
*/
|
309 |
-
public function
|
|
|
310 |
try {
|
311 |
if (!$this->_getConfig()->isIpnActive()) {
|
312 |
-
$this->
|
313 |
}
|
314 |
} catch (Exception $e) {
|
315 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
316 |
throw $e;
|
317 |
}
|
|
|
318 |
return $this;
|
319 |
}
|
320 |
-
|
321 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Observer
|
18 |
+
{
|
19 |
|
20 |
const DATA_POLL_TRANSACTION_LIMIT = 36;
|
21 |
const DATA_POLL_SLEEP_BETWEEN_TIME = 300000;
|
22 |
|
23 |
+
/**
|
24 |
+
* Return Amazon Pay config model instance
|
25 |
+
*
|
26 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
27 |
+
*/
|
28 |
+
protected function _getConfig()
|
29 |
+
{
|
30 |
return Mage::getSingleton('amazonpayments/config');
|
31 |
}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
/**
|
34 |
+
* Returns Amazon Pay helper
|
35 |
*
|
36 |
+
* @return Creativestyle_AmazonPayments_Helper_Data
|
37 |
*/
|
38 |
+
protected function _getHelper()
|
39 |
+
{
|
40 |
+
return Mage::helper('amazonpayments');
|
|
|
|
|
41 |
}
|
42 |
|
43 |
+
/**
|
44 |
+
* Returns transaction processor instance
|
45 |
+
*
|
46 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
47 |
+
* @return Creativestyle_AmazonPayments_Model_Processor_Transaction
|
48 |
+
*/
|
49 |
+
protected function _getTransactionProcessor(Mage_Sales_Model_Order_Payment_Transaction $transaction)
|
50 |
+
{
|
51 |
+
return Mage::getModel('amazonpayments/processor_transaction')->setTransaction($transaction);
|
52 |
}
|
53 |
|
54 |
+
/**
|
55 |
+
* @return Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection
|
56 |
+
*/
|
57 |
+
protected function _getPaymentTransactionCollection()
|
58 |
+
{
|
59 |
+
/** @var Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection $collection */
|
60 |
+
$collection = Mage::getModel('sales/order_payment_transaction')->getCollection();
|
61 |
+
$collection->addPaymentInformation(array('method'))
|
62 |
+
->addFieldToFilter('method', array('in' => $this->_getHelper()->getAvailablePaymentMethods()))
|
63 |
->addFieldToFilter('is_closed', 0)
|
64 |
->setOrder('transaction_id', 'asc');
|
65 |
|
66 |
+
if ($recentPolledTransaction = $this->_getConfig()->getRecentPolledTransaction()) {
|
|
|
67 |
$collection->addFieldToFilter('transaction_id', array('gt' => (int)$recentPolledTransaction));
|
68 |
}
|
69 |
|
70 |
+
return $collection;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
75 |
+
* @return bool
|
76 |
+
*/
|
77 |
+
protected function _shouldPollDataForTransaction(Mage_Sales_Model_Order_Payment_Transaction $transaction)
|
78 |
+
{
|
79 |
+
return $this->_getTransactionProcessor($transaction)
|
80 |
+
->shouldPollData();
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param string $method
|
85 |
+
* @return bool
|
86 |
+
*/
|
87 |
+
protected function _isAmazonPaymentsMethod($method)
|
88 |
+
{
|
89 |
+
return in_array($method, $this->_getHelper()->getAvailablePaymentMethods());
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
94 |
+
* @return bool
|
95 |
+
*/
|
96 |
+
protected function _shouldCloseTransaction(Mage_Sales_Model_Order_Payment_Transaction $transaction)
|
97 |
+
{
|
98 |
+
return $this->_isAmazonPaymentsMethod($transaction->getOrder()->getPayment()->getMethod())
|
99 |
+
&& $this->_getTransactionProcessor($transaction)->shouldCloseTransaction();
|
100 |
+
}
|
101 |
|
102 |
+
protected function _pollPaymentTransactionData()
|
103 |
+
{
|
104 |
$recentTransactionId = null;
|
105 |
$count = 0;
|
|
|
106 |
|
107 |
+
/** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
|
108 |
+
foreach ($this->_getPaymentTransactionCollection() as $transaction) {
|
109 |
try {
|
110 |
+
if ($this->_shouldPollDataForTransaction($transaction)) {
|
111 |
+
$transaction->getOrderPaymentObject()
|
112 |
+
->setOrder($transaction->getOrder())
|
113 |
+
->importTransactionInfo($transaction);
|
114 |
+
// @codingStandardsIgnoreStart
|
115 |
+
$transaction->save();
|
116 |
+
// @codingStandardsIgnoreEnd
|
117 |
+
$recentTransactionId = $transaction->getId();
|
118 |
+
if ($count++ >= self::DATA_POLL_TRANSACTION_LIMIT) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
break;
|
120 |
+
}
|
121 |
|
122 |
+
usleep(self::DATA_POLL_SLEEP_BETWEEN_TIME);
|
123 |
}
|
124 |
+
} catch (OffAmazonPaymentsService_Exception $e) {
|
125 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
126 |
+
if ($e->getStatusCode() == 503 && $e->getErrorCode() == 'RequestThrottled') {
|
127 |
+
$count = self::DATA_POLL_TRANSACTION_LIMIT;
|
128 |
break;
|
129 |
}
|
|
|
|
|
130 |
}
|
131 |
}
|
132 |
|
136 |
|
137 |
$this->_getConfig()->setRecentPolledTransaction($recentTransactionId);
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
return $this;
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
/**
|
143 |
* Inject Authorize button to the admin order view page
|
144 |
*
|
145 |
* @param Varien_Event_Observer $observer
|
146 |
+
* @return $this
|
147 |
*/
|
148 |
+
public function injectAuthorizeButton($observer)
|
149 |
+
{
|
150 |
+
$observer->getEvent();
|
151 |
try {
|
152 |
$order = Mage::registry('sales_order');
|
153 |
// check if object instance exists and whether manual authorization is enabled
|
154 |
+
if ($order && $order->getId() && $this->_getConfig()->isManualAuthorizationAllowed()
|
155 |
+
&& Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/amazonpayments_authorize')
|
156 |
+
) {
|
157 |
$payment = $order->getPayment();
|
158 |
+
if ($this->_isAmazonPaymentsMethod($payment->getMethod())) {
|
159 |
// check if payment wasn't authorized already
|
160 |
+
$orderTransaction =
|
161 |
+
$payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
|
162 |
+
$authTransaction =
|
163 |
+
$payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
164 |
+
|
165 |
// invoke injectAuthorizeButton helper if authorization transaction does not exist or is closed
|
166 |
+
if ($orderTransaction && !$orderTransaction->getIsClosed()
|
167 |
+
&& (!$authTransaction || $authTransaction->getIsClosed())) {
|
168 |
$block = Mage::getSingleton('core/layout')->getBlock('sales_order_edit');
|
169 |
if ($block) {
|
170 |
+
$url = Mage::getModel('adminhtml/url')->getUrl(
|
171 |
+
'adminhtml/amazonpayments_order/authorize',
|
172 |
+
array('order_id' => $order->getId())
|
173 |
+
);
|
174 |
+
$message = $this->_getHelper()
|
175 |
+
->__('Are you sure you want to authorize payment for this order?');
|
176 |
+
$block->addButton(
|
177 |
+
'payment_authorize',
|
178 |
+
array(
|
179 |
+
'label' => $this->_getHelper()->__('Authorize payment'),
|
180 |
+
'onclick' => "confirmSetLocation('{$message}', '{$url}')",
|
181 |
+
'class' => 'go'
|
182 |
+
)
|
183 |
+
);
|
184 |
}
|
185 |
}
|
186 |
}
|
188 |
} catch (Exception $e) {
|
189 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
190 |
}
|
191 |
+
|
192 |
+
return $this;
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* @param Varien_Event_Observer $observer
|
197 |
+
* @return $this
|
198 |
+
*/
|
199 |
+
public function saveTransactionBefore($observer)
|
200 |
+
{
|
201 |
+
try {
|
202 |
+
/** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
|
203 |
+
$transaction = $observer->getEvent()->getOrderPaymentTransaction();
|
204 |
+
if ($this->_shouldCloseTransaction($transaction)) {
|
205 |
+
$transaction->setIsClosed(true);
|
206 |
+
}
|
207 |
+
} catch (Exception $e) {
|
208 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
209 |
+
}
|
210 |
+
|
211 |
return $this;
|
212 |
}
|
213 |
|
215 |
* Capture and log Amazon Payments API call
|
216 |
*
|
217 |
* @param Varien_Event_Observer $observer
|
218 |
+
* @return $this
|
219 |
*/
|
220 |
+
public function logApiCall($observer)
|
221 |
+
{
|
222 |
$callData = $observer->getEvent()->getCallData();
|
223 |
if (is_array($callData)) {
|
224 |
Creativestyle_AmazonPayments_Model_Logger::logApiCall($callData);
|
225 |
}
|
226 |
+
|
227 |
return $this;
|
228 |
}
|
229 |
|
231 |
* Capture and log incoming IPN notification
|
232 |
*
|
233 |
* @param Varien_Event_Observer $observer
|
234 |
+
* @return $this
|
235 |
*/
|
236 |
+
public function logIpnCall($observer)
|
237 |
+
{
|
238 |
$callData = $observer->getEvent()->getCallData();
|
239 |
if (is_array($callData)) {
|
240 |
Creativestyle_AmazonPayments_Model_Logger::logIpnCall($callData);
|
241 |
}
|
|
|
|
|
242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
return $this;
|
244 |
}
|
245 |
|
246 |
+
/**
|
247 |
+
* Sets secure URLs in Magento configuration
|
248 |
+
*
|
249 |
+
* @param Varien_Event_Observer $observer
|
250 |
+
* @return $this
|
251 |
+
*/
|
252 |
+
public function setSecureUrls($observer)
|
253 |
+
{
|
254 |
+
$observer->getEvent();
|
255 |
try {
|
256 |
$secureUrlsConfigNode = Mage::getConfig()->getNode('frontend/secure_url');
|
257 |
+
if ($this->_getConfig()->isLoginActive() && !$this->_getConfig()->isRedirectAuthenticationExperience()) {
|
|
|
|
|
258 |
$secureUrlsConfigNode->addChild('amazonpayments_cart', '/checkout/cart');
|
259 |
}
|
260 |
+
|
261 |
+
if ($this->_getConfig()->isSandboxActive()) {
|
262 |
+
// @codingStandardsIgnoreStart
|
263 |
unset($secureUrlsConfigNode->amazonpayments_ipn);
|
264 |
+
unset($secureUrlsConfigNode->amazonpayments_ipn_legacy);
|
265 |
+
// @codingStandardsIgnoreEnd
|
266 |
}
|
267 |
} catch (Exception $e) {
|
268 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
269 |
}
|
270 |
+
|
271 |
return $this;
|
272 |
}
|
273 |
|
|
|
|
|
|
|
|
|
|
|
274 |
/**
|
275 |
+
* Invokes Amazon Payments log files rotating
|
276 |
*
|
277 |
+
* @return $this
|
278 |
+
* @throws Exception
|
279 |
*/
|
280 |
+
public function rotateLogfiles()
|
281 |
+
{
|
282 |
try {
|
283 |
Creativestyle_AmazonPayments_Model_Logger::rotateLogfiles();
|
284 |
} catch (Exception $e) {
|
285 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
286 |
throw $e;
|
287 |
}
|
288 |
+
|
289 |
return $this;
|
290 |
}
|
291 |
|
292 |
/**
|
293 |
* Invokes data polling from Amazon Payments gateway
|
294 |
*
|
295 |
+
* @return $this
|
296 |
+
* @throws Exception
|
297 |
*/
|
298 |
+
public function pollPaymentTransactionData()
|
299 |
+
{
|
300 |
try {
|
301 |
if (!$this->_getConfig()->isIpnActive()) {
|
302 |
+
$this->_pollPaymentTransactionData();
|
303 |
}
|
304 |
} catch (Exception $e) {
|
305 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
306 |
throw $e;
|
307 |
}
|
308 |
+
|
309 |
return $this;
|
310 |
}
|
|
|
311 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Payment/Abstract.php
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract
|
17 |
-
|
18 |
const ACTION_MANUAL = 'manual';
|
19 |
const ACTION_AUTHORIZE = 'authorize';
|
20 |
const ACTION_AUTHORIZE_CAPTURE = 'authorize_capture';
|
@@ -29,11 +30,13 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
|
|
29 |
const CHECK_RECURRING_PROFILES = 64;
|
30 |
const CHECK_ZERO_TOTAL = 128;
|
31 |
|
|
|
|
|
32 |
protected $_code = 'amazonpayments_abstract';
|
33 |
protected $_infoBlockType = 'amazonpayments/payment_info';
|
34 |
|
35 |
/**
|
36 |
-
* Pay
|
37 |
*
|
38 |
* @var bool
|
39 |
*/
|
@@ -56,546 +59,630 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
|
|
56 |
protected $_canManageRecurringProfiles = true;
|
57 |
|
58 |
/**
|
59 |
-
*
|
|
|
|
|
|
|
|
|
|
|
60 |
*
|
61 |
* @return Creativestyle_AmazonPayments_Model_Config
|
62 |
*/
|
63 |
-
protected function _getConfig()
|
|
|
64 |
return Mage::getSingleton('amazonpayments/config');
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
* Return Magento order processor instance
|
69 |
*
|
|
|
70 |
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
71 |
*/
|
72 |
-
protected function _getOrderProcessor()
|
73 |
-
|
|
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
-
*
|
78 |
*
|
|
|
79 |
* @return Creativestyle_AmazonPayments_Model_Processor_Payment
|
80 |
*/
|
81 |
-
protected function _getPaymentProcessor()
|
82 |
-
|
|
|
|
|
|
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
-
*
|
87 |
*
|
88 |
-
* @
|
|
|
89 |
*/
|
90 |
-
protected function
|
91 |
-
|
92 |
-
|
93 |
-
}
|
94 |
-
if ($payment->getOrder() && null === $this->getStore()) {
|
95 |
-
$this->setStore($payment->getOrder()->getStoreId());
|
96 |
-
}
|
97 |
-
return $this;
|
98 |
-
}
|
99 |
-
|
100 |
-
protected function _getPaymentSequenceId() {
|
101 |
-
$sequenceNumber = $this->getInfoInstance()->getAdditionalInformation('amazon_sequence_number');
|
102 |
-
$sequenceNumber = is_null($sequenceNumber) ? 1 : ++$sequenceNumber;
|
103 |
-
$this->getInfoInstance()->setAdditionalInformation('amazon_sequence_number', $sequenceNumber);
|
104 |
-
return sprintf('%s-%s', $this->getInfoInstance()->getOrder()->getExtOrderId(), $sequenceNumber);
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
-
*
|
109 |
-
*
|
110 |
-
* @return bool
|
111 |
*/
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
|
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
-
*
|
|
|
|
|
121 |
*
|
122 |
-
* @
|
|
|
123 |
*/
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
-
*
|
133 |
-
*
|
|
|
134 |
* @return bool
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
-
|
|
|
141 |
}
|
142 |
|
143 |
/**
|
144 |
-
*
|
|
|
145 |
*
|
|
|
|
|
|
|
146 |
* @return bool
|
147 |
*/
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
}
|
154 |
|
155 |
/**
|
156 |
-
*
|
157 |
-
*
|
158 |
-
* @
|
|
|
|
|
159 |
*/
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
|
167 |
/**
|
168 |
-
*
|
169 |
-
*
|
170 |
* @return bool
|
171 |
*/
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
|
|
177 |
}
|
178 |
|
179 |
/**
|
180 |
-
*
|
181 |
*
|
182 |
-
* @param
|
183 |
-
* @
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
-
*
|
195 |
-
*
|
196 |
* @return bool
|
197 |
*/
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
}
|
201 |
|
202 |
/**
|
203 |
-
*
|
204 |
-
*
|
205 |
* @return bool
|
206 |
*/
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
-
*
|
216 |
-
*
|
217 |
-
* @param
|
218 |
-
* @param
|
219 |
-
* @param
|
220 |
-
* @return
|
221 |
* @throws Creativestyle_AmazonPayments_Exception
|
222 |
*/
|
223 |
-
|
224 |
-
$
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
$transactionAdapter->processRelatedObjects($this->getInfoInstance()->getOrder());
|
233 |
-
if ($shouldSave) $this->_getOrderProcessor()->saveOrder();
|
234 |
-
}
|
235 |
-
return $transactionAdapter->getStatusChange();
|
236 |
}
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
}
|
239 |
|
240 |
/**
|
241 |
-
*
|
242 |
-
*
|
243 |
-
* @param string $currencyCode
|
244 |
-
* @return boolean
|
245 |
*/
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
}
|
249 |
|
250 |
/**
|
251 |
-
*
|
252 |
*
|
253 |
-
* @param
|
254 |
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
255 |
-
*
|
|
|
256 |
* @return array|null
|
257 |
*/
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
$
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
}
|
267 |
|
268 |
/**
|
269 |
-
*
|
270 |
-
*
|
271 |
-
* @param float $amount
|
272 |
-
* @param string $parentTransactionId
|
273 |
-
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
274 |
-
* @param bool $captureNow
|
275 |
*
|
276 |
-
* @
|
|
|
277 |
*/
|
278 |
-
|
279 |
-
|
280 |
-
|
|
|
|
|
|
|
281 |
}
|
282 |
-
|
283 |
-
|
284 |
-
$
|
285 |
-
|
286 |
-
|
287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
);
|
289 |
-
|
290 |
-
->setTransactionId($authorizationDetails->getAmazonAuthorizationId())
|
291 |
-
->setParentTransactionId($parentTransactionId)
|
292 |
-
->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
293 |
-
return $this->_getPaymentProcessor()->importTransactionDetails($transaction);
|
294 |
}
|
295 |
|
296 |
/**
|
297 |
-
*
|
298 |
-
*
|
299 |
-
* @param float $amount
|
300 |
-
* @param string $parentTransactionId
|
301 |
-
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
302 |
-
*
|
303 |
-
* @return array|null
|
304 |
*/
|
305 |
-
|
306 |
-
|
307 |
-
|
|
|
|
|
|
|
|
|
308 |
}
|
309 |
-
$captureDetails = $this->_getPaymentProcessor()->capture(
|
310 |
-
$amount,
|
311 |
-
$this->_getPaymentSequenceId(),
|
312 |
-
$parentTransactionId
|
313 |
-
);
|
314 |
-
$transaction = $this->getInfoInstance()->setIsTransactionClosed(false)
|
315 |
-
->setTransactionId($captureDetails->getAmazonCaptureId())
|
316 |
-
->setParentTransactionId($parentTransactionId)
|
317 |
-
->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
318 |
-
return $this->_getPaymentProcessor()->importTransactionDetails($transaction, $captureDetails);
|
319 |
}
|
320 |
|
321 |
/**
|
322 |
-
*
|
323 |
-
*
|
324 |
-
* @param float $amount
|
325 |
-
* @param string $parentTransactionId
|
326 |
-
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
327 |
*
|
328 |
-
* @
|
|
|
|
|
329 |
*/
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
$
|
335 |
-
|
336 |
-
|
337 |
-
$
|
|
|
|
|
338 |
);
|
339 |
-
$transaction = $this->getInfoInstance()->setIsTransactionClosed(false)
|
340 |
-
->setTransactionId($refundDetails->getAmazonRefundId())
|
341 |
-
->setParentTransactionId($parentTransactionId)
|
342 |
-
->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
|
343 |
-
return $this->_getPaymentProcessor()->importTransactionDetails($transaction, $refundDetails);
|
344 |
-
}
|
345 |
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
|
|
|
|
|
|
|
|
352 |
}
|
353 |
-
|
|
|
354 |
}
|
355 |
|
356 |
/**
|
357 |
-
* Public wrapper for payment order
|
358 |
-
*
|
359 |
* @param Varien_Object $payment
|
360 |
* @param float $amount
|
361 |
-
*
|
362 |
-
* @return Creativestyle_AmazonPayments_Model_Payment_Abstract
|
363 |
*/
|
364 |
-
public function order(Varien_Object $payment, $amount)
|
365 |
-
|
366 |
-
$
|
367 |
-
$orderReferenceAdapter = $this->_order($amount, $orderTransaction);
|
368 |
-
$orderReferenceAdapter->validateTransactionStatus();
|
369 |
-
$this->_getOrderProcessor()->importTransactionDetails($orderReferenceAdapter, $stateObject);
|
370 |
return $this;
|
371 |
}
|
372 |
|
373 |
/**
|
374 |
-
* Payment authorization public method
|
375 |
-
*
|
376 |
* @param Varien_Object $payment
|
377 |
* @param float $amount
|
378 |
-
*
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
$
|
383 |
-
|
384 |
-
|
385 |
-
$
|
|
|
386 |
$amount,
|
387 |
-
|
388 |
-
$
|
389 |
-
$
|
|
|
390 |
$this->_getConfig()->isAuthorizationSynchronous($payment->getOrder()->getStoreId())
|
391 |
);
|
392 |
-
$authorizationAdapter->validateTransactionStatus();
|
393 |
-
$this->_getOrderProcessor()->importTransactionDetails($authorizationAdapter, $stateObject);
|
394 |
}
|
|
|
395 |
return $this;
|
396 |
}
|
397 |
|
398 |
/**
|
399 |
-
* Payment capture public method
|
400 |
-
*
|
401 |
* @param Varien_Object $payment
|
402 |
* @param float $amount
|
403 |
-
*
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
$
|
408 |
-
|
409 |
-
|
410 |
-
$
|
|
|
411 |
$amount,
|
412 |
-
|
413 |
-
$
|
|
|
414 |
);
|
415 |
-
$captureAdapter->validateTransactionStatus();
|
416 |
-
$this->_getOrderProcessor()->importTransactionDetails($captureAdapter, $stateObject)->saveOrder();
|
417 |
-
// avoid transaction duplicates
|
418 |
$payment->setSkipTransactionCreation(true);
|
419 |
}
|
420 |
-
return $this;
|
421 |
-
}
|
422 |
|
423 |
-
/**
|
424 |
-
* @todo
|
425 |
-
* Set capture transaction ID to invoice for informational purposes
|
426 |
-
*
|
427 |
-
* @param Mage_Sales_Model_Order_Invoice $invoice
|
428 |
-
* @param Mage_Sales_Model_Order_Payment $payment
|
429 |
-
*
|
430 |
-
* @return Mage_Payment_Model_Method_Abstract
|
431 |
-
*/
|
432 |
-
public function processInvoice($invoice, $payment) {
|
433 |
-
$invoice->setTransactionId($payment->getLastTransId());
|
434 |
return $this;
|
435 |
}
|
436 |
|
437 |
/**
|
438 |
-
* @todo
|
439 |
-
* Refund specified amount for payment
|
440 |
-
*
|
441 |
* @param Varien_Object $payment
|
442 |
* @param float $amount
|
443 |
-
*
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
$
|
448 |
-
|
449 |
-
|
450 |
-
|
|
|
|
|
451 |
$amount,
|
452 |
-
|
453 |
-
$
|
|
|
454 |
);
|
455 |
-
$refundAdapter->validateTransactionStatus();
|
456 |
-
$this->_getOrderProcessor()->importTransactionDetails($refundAdapter, $stateObject)->saveOrder();
|
457 |
-
// avoid transaction duplicates
|
458 |
$payment->setSkipTransactionCreation(true);
|
459 |
}
|
|
|
460 |
return $this;
|
461 |
}
|
462 |
|
463 |
/**
|
464 |
-
* @todo
|
465 |
-
* Set transaction ID into creditmemo for informational purposes
|
466 |
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
|
467 |
* @param Mage_Sales_Model_Order_Payment $payment
|
468 |
-
* @return
|
469 |
-
*/
|
470 |
-
public function processCreditmemo($creditmemo, $payment)
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
* Cancel payment abstract method
|
477 |
-
*
|
478 |
-
* @param Varien_Object $payment
|
479 |
-
*
|
480 |
-
* @return Mage_Payment_Model_Abstract
|
481 |
-
*/
|
482 |
-
public function cancel(Varien_Object $payment) {
|
483 |
-
$this->_initInfoInstance($payment);
|
484 |
-
if ($orderTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER)) {
|
485 |
-
if (!$orderTransaction->getIsClosed()) {
|
486 |
-
$this->_void();
|
487 |
-
}
|
488 |
}
|
489 |
-
// avoid transaction duplicates
|
490 |
-
$payment->setSkipTransactionCreation(true);
|
491 |
-
return $this;
|
492 |
-
}
|
493 |
|
494 |
-
/**
|
495 |
-
* Void payment abstract method
|
496 |
-
*
|
497 |
-
* @param Varien_Object $payment
|
498 |
-
*
|
499 |
-
* @return Mage_Payment_Model_Abstract
|
500 |
-
*/
|
501 |
-
public function void(Varien_Object $payment) {
|
502 |
-
$this->_initInfoInstance($payment);
|
503 |
-
if ($orderTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER)) {
|
504 |
-
if (!$orderTransaction->getIsClosed()) {
|
505 |
-
$this->_void();
|
506 |
-
}
|
507 |
-
}
|
508 |
-
// avoid transaction duplicates
|
509 |
-
$payment->setSkipTransactionCreation(true);
|
510 |
return $this;
|
511 |
}
|
512 |
|
513 |
/**
|
514 |
-
*
|
515 |
*
|
516 |
-
* @param
|
517 |
-
* @param
|
518 |
-
*
|
519 |
-
* @
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
|
|
|
|
|
|
|
|
530 |
}
|
531 |
-
}
|
532 |
|
533 |
-
/**
|
534 |
-
* Method that will be executed instead of authorize or capture
|
535 |
-
* if flag isInitializeNeeded set to true
|
536 |
-
*
|
537 |
-
* @param string $paymentAction
|
538 |
-
* @param object $stateObject
|
539 |
-
*
|
540 |
-
* @return Creativestyle_AmazonPayments_Model_Payment_Abstract
|
541 |
-
*/
|
542 |
-
public function initialize($paymentAction, $stateObject) {
|
543 |
-
$payment = $this->getInfoInstance();
|
544 |
-
$this->setStore($payment->getOrder()->getStoreId());
|
545 |
-
switch ($paymentAction) {
|
546 |
-
case self::ACTION_MANUAL:
|
547 |
-
case self::ACTION_ERP:
|
548 |
-
$orderTransaction = null;
|
549 |
-
$orderReferenceAdapter = $this->_order($this->getInfoInstance()->getOrder()->getBaseTotalDue(), $orderTransaction);
|
550 |
-
$orderReferenceAdapter->validateTransactionStatus();
|
551 |
-
$this->_getOrderProcessor()->importTransactionDetails($orderReferenceAdapter, $stateObject);
|
552 |
-
break;
|
553 |
-
case self::ACTION_AUTHORIZE:
|
554 |
-
case self::ACTION_AUTHORIZE_CAPTURE:
|
555 |
-
// OrderReference first
|
556 |
-
$orderTransaction = null;
|
557 |
-
$orderReferenceAdapter = $this->_order($this->getInfoInstance()->getOrder()->getBaseTotalDue(), $orderTransaction);
|
558 |
-
$orderReferenceAdapter->validateTransactionStatus();
|
559 |
-
$this->_getOrderProcessor()->importTransactionDetails($orderReferenceAdapter, $stateObject);
|
560 |
-
// Authorization next
|
561 |
-
$authorizationTransaction = null;
|
562 |
-
$authorizationAdapter = $this->_authorize(
|
563 |
-
$this->getInfoInstance()->getOrder()->getBaseTotalDue(),
|
564 |
-
$orderTransaction->getTxnId(),
|
565 |
-
$authorizationTransaction,
|
566 |
-
$paymentAction == self::ACTION_AUTHORIZE_CAPTURE,
|
567 |
-
$this->_getConfig()->isAuthorizationSynchronous($payment->getOrder()->getStoreId())
|
568 |
-
);
|
569 |
-
$authorizationAdapter->validateTransactionStatus();
|
570 |
-
$this->_getOrderProcessor()->importTransactionDetails($authorizationAdapter, $stateObject);
|
571 |
-
break;
|
572 |
-
}
|
573 |
return $this;
|
574 |
}
|
575 |
|
576 |
/**
|
577 |
-
*
|
578 |
*
|
579 |
-
* @param
|
580 |
-
* @
|
|
|
581 |
*/
|
582 |
-
public function
|
583 |
-
|
584 |
-
|
585 |
-
if ($
|
586 |
-
$
|
587 |
-
|
588 |
-
|
589 |
-
|
|
|
590 |
}
|
591 |
-
$checkResult->isAvailable = $isActive;
|
592 |
-
$checkResult->isDeniedInConfig = !$isActive;
|
593 |
-
Mage::dispatchEvent('payment_method_is_active', array(
|
594 |
-
'result' => $checkResult,
|
595 |
-
'method_instance' => $this,
|
596 |
-
'quote' => $quote,
|
597 |
-
));
|
598 |
-
return $checkResult->isAvailable;
|
599 |
-
}
|
600 |
|
|
|
|
|
601 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract
|
18 |
+
{
|
19 |
const ACTION_MANUAL = 'manual';
|
20 |
const ACTION_AUTHORIZE = 'authorize';
|
21 |
const ACTION_AUTHORIZE_CAPTURE = 'authorize_capture';
|
30 |
const CHECK_RECURRING_PROFILES = 64;
|
31 |
const CHECK_ZERO_TOTAL = 128;
|
32 |
|
33 |
+
const SEQUENCE_NUMBER_KEY = 'amazon_sequence_number';
|
34 |
+
|
35 |
protected $_code = 'amazonpayments_abstract';
|
36 |
protected $_infoBlockType = 'amazonpayments/payment_info';
|
37 |
|
38 |
/**
|
39 |
+
* Amazon Pay method features
|
40 |
*
|
41 |
* @var bool
|
42 |
*/
|
59 |
protected $_canManageRecurringProfiles = true;
|
60 |
|
61 |
/**
|
62 |
+
* @var Creativestyle_AmazonPayments_Model_Processor_Transaction|null
|
63 |
+
*/
|
64 |
+
protected $_lastTransactionProcessor = null;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Returns Amazon Pay config model instance
|
68 |
*
|
69 |
* @return Creativestyle_AmazonPayments_Model_Config
|
70 |
*/
|
71 |
+
protected function _getConfig()
|
72 |
+
{
|
73 |
return Mage::getSingleton('amazonpayments/config');
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
* Return Magento order processor instance
|
78 |
*
|
79 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
80 |
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
81 |
*/
|
82 |
+
protected function _getOrderProcessor(Mage_Sales_Model_Order_Payment $payment)
|
83 |
+
{
|
84 |
+
return Mage::getModel('amazonpayments/processor_order')->setOrder($payment->getOrder());
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
+
* Returns payment processor instance
|
89 |
*
|
90 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
91 |
* @return Creativestyle_AmazonPayments_Model_Processor_Payment
|
92 |
*/
|
93 |
+
protected function _getPaymentProcessor(Mage_Sales_Model_Order_Payment $payment)
|
94 |
+
{
|
95 |
+
return Mage::getModel('amazonpayments/processor_payment')
|
96 |
+
->setPayment($payment)
|
97 |
+
->setStoreId($payment->getOrder()->getStoreId());
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
+
* Returns transaction processor instance
|
102 |
*
|
103 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
104 |
+
* @return Creativestyle_AmazonPayments_Model_Processor_Transaction
|
105 |
*/
|
106 |
+
protected function _getTransactionProcessor(Mage_Sales_Model_Order_Payment_Transaction $transaction)
|
107 |
+
{
|
108 |
+
return Mage::getModel('amazonpayments/processor_transaction')->setTransaction($transaction);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
+
* @param mixed|null $store
|
113 |
+
* @return Varien_Object
|
|
|
114 |
*/
|
115 |
+
protected function _getCustomStatusList($store = null)
|
116 |
+
{
|
117 |
+
return new Varien_Object(
|
118 |
+
array(
|
119 |
+
'new_order_status' => $this->_getConfig()->getNewOrderStatus($store),
|
120 |
+
'holded_order_status' => $this->_getConfig()->getHoldedOrderStatus($store),
|
121 |
+
'authorized_order_status' => $this->_getConfig()->getAuthorizedOrderStatus($store)
|
122 |
+
)
|
123 |
+
);
|
124 |
}
|
125 |
|
126 |
/**
|
127 |
+
* Returns transaction sequence ID, comprised of order reference ID
|
128 |
+
* and subsequent unique number, it can be used as a transaction
|
129 |
+
* reference ID for requesting new transactions in Amazon Pay API
|
130 |
*
|
131 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
132 |
+
* @return string
|
133 |
*/
|
134 |
+
protected function _getTransactionSequenceId(Mage_Sales_Model_Order_Payment $payment)
|
135 |
+
{
|
136 |
+
$sequenceNumber = $payment->getAdditionalInformation(self::SEQUENCE_NUMBER_KEY);
|
137 |
+
$sequenceNumber = null === $sequenceNumber ? 1 : ++$sequenceNumber;
|
138 |
+
$payment->setAdditionalInformation(self::SEQUENCE_NUMBER_KEY, $sequenceNumber);
|
139 |
+
return sprintf('%s-%s', $payment->getOrder()->getExtOrderId(), $sequenceNumber);
|
140 |
}
|
141 |
|
142 |
/**
|
143 |
+
* @param string $transactionType
|
144 |
+
* @param array|null $transactionInfo
|
145 |
+
* @param array $states
|
146 |
* @return bool
|
147 |
+
* @throws Creativestyle_AmazonPayments_Exception_InvalidTransaction
|
148 |
+
*/
|
149 |
+
protected function _assertTransactionState($transactionType, $transactionInfo = null, $states = array())
|
150 |
+
{
|
151 |
+
if ($transactionInfo) {
|
152 |
+
$transactionInfoObj = new Varien_Object($transactionInfo);
|
153 |
+
$transactionState = $transactionInfoObj->getData(
|
154 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_KEY
|
155 |
+
);
|
156 |
+
if (!in_array($transactionState, $states)) {
|
157 |
+
throw new Creativestyle_AmazonPayments_Exception_InvalidTransaction(
|
158 |
+
$transactionType,
|
159 |
+
$transactionInfo,
|
160 |
+
sprintf('Invalid Amazon Pay %s transaction status', $transactionType)
|
161 |
+
);
|
162 |
+
}
|
163 |
}
|
164 |
+
|
165 |
+
return true;
|
166 |
}
|
167 |
|
168 |
/**
|
169 |
+
* Checks whether payment should be re-authorized asynchronously
|
170 |
+
* after synchronous authorization failed
|
171 |
*
|
172 |
+
* @param bool $isSync
|
173 |
+
* @param string $txnState
|
174 |
+
* @param string|null $txnReasonCode
|
175 |
* @return bool
|
176 |
*/
|
177 |
+
protected function _shouldReauthorizeAsynchronously($isSync, $txnState, $txnReasonCode = null)
|
178 |
+
{
|
179 |
+
return $isSync && $this->_getConfig()->isAuthorizationOmnichronous()
|
180 |
+
&& $txnState == Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED
|
181 |
+
&& $txnReasonCode == Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_REASON_TIMEOUT;
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
186 |
+
* @param float $amount
|
187 |
+
* @param Varien_Object $stateObject
|
188 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction
|
189 |
+
* @throws Creativestyle_AmazonPayments_Exception
|
190 |
*/
|
191 |
+
protected function _order(Mage_Sales_Model_Order_Payment $payment, $amount, Varien_Object $stateObject)
|
192 |
+
{
|
193 |
+
if (!$this->canOrder()) {
|
194 |
+
throw new Creativestyle_AmazonPayments_Exception('Order action is not available');
|
195 |
+
}
|
196 |
+
|
197 |
+
$paymentProcessor = $this->_getPaymentProcessor($payment);
|
198 |
+
|
199 |
+
if (!$payment->getSkipOrderReferenceProcessing()) {
|
200 |
+
$paymentProcessor->setOrderDetails(
|
201 |
+
$amount,
|
202 |
+
$payment->getOrder()->getBaseCurrencyCode(),
|
203 |
+
$payment->getTransactionId(),
|
204 |
+
$payment->getOrder()->getIncrementId(),
|
205 |
+
$this->_getConfig()->getStoreName($payment->getOrder()->getStoreId())
|
206 |
+
);
|
207 |
}
|
208 |
+
|
209 |
+
$paymentProcessor->order($payment->getTransactionId());
|
210 |
+
|
211 |
+
/** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
|
212 |
+
$transaction = $payment->setIsTransactionClosed(false)
|
213 |
+
->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
|
214 |
+
$transactionInfo = $this->_fetchTransactionInfo($payment, $transaction, $stateObject);
|
215 |
+
$this->_validateOrderReferenceState($transactionInfo);
|
216 |
+
if ($transactionInfo) {
|
217 |
+
$transaction->setAdditionalInformation(
|
218 |
+
Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
|
219 |
+
$transactionInfo
|
220 |
+
);
|
221 |
+
}
|
222 |
+
|
223 |
+
return $transaction;
|
224 |
}
|
225 |
|
226 |
/**
|
227 |
+
* @param array|null $transactionInfo
|
|
|
228 |
* @return bool
|
229 |
*/
|
230 |
+
protected function _validateOrderReferenceState($transactionInfo = null)
|
231 |
+
{
|
232 |
+
return $this->_assertTransactionState(
|
233 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_ORDER,
|
234 |
+
$transactionInfo,
|
235 |
+
array(
|
236 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_OPEN
|
237 |
+
)
|
238 |
+
);
|
239 |
}
|
240 |
|
241 |
/**
|
242 |
+
* Authorize payment
|
243 |
*
|
244 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
245 |
+
* @param float $amount
|
246 |
+
* @param Varien_Object $stateObject
|
247 |
+
* @param string $transactionReferenceId
|
248 |
+
* @param string $parentTransactionId
|
249 |
+
* @param bool $isSync
|
250 |
+
* @param bool $captureNow
|
251 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction
|
252 |
+
* @throws Creativestyle_AmazonPayments_Exception
|
253 |
+
* @throws Creativestyle_AmazonPayments_Exception_InvalidTransaction
|
254 |
+
*/
|
255 |
+
protected function _authorize(
|
256 |
+
Mage_Sales_Model_Order_Payment $payment,
|
257 |
+
$amount,
|
258 |
+
Varien_Object $stateObject,
|
259 |
+
$transactionReferenceId,
|
260 |
+
$parentTransactionId,
|
261 |
+
$isSync = true,
|
262 |
+
$captureNow = false
|
263 |
+
) {
|
264 |
+
if (!$this->canAuthorize()) {
|
265 |
+
throw new Creativestyle_AmazonPayments_Exception('Authorize action is not available');
|
266 |
}
|
267 |
+
|
268 |
+
$transactionDetails = $this->_getPaymentProcessor($payment)->authorize(
|
269 |
+
$amount,
|
270 |
+
$payment->getOrder()->getBaseCurrencyCode(),
|
271 |
+
$transactionReferenceId,
|
272 |
+
$parentTransactionId,
|
273 |
+
$isSync,
|
274 |
+
$captureNow
|
275 |
+
);
|
276 |
+
/** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
|
277 |
+
$transaction = $payment->setIsTransactionClosed(false)
|
278 |
+
->setTransactionId($transactionDetails->getAmazonAuthorizationId())
|
279 |
+
->setParentTransactionId($parentTransactionId)
|
280 |
+
->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
281 |
+
$transactionInfo = $this->_fetchTransactionInfo($payment, $transaction, $stateObject);
|
282 |
+
if ($transactionInfo) {
|
283 |
+
$transaction->setAdditionalInformation(
|
284 |
+
Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
|
285 |
+
$transactionInfo
|
286 |
+
);
|
287 |
+
}
|
288 |
+
|
289 |
+
try {
|
290 |
+
$this->_validateAuthorizationState($transactionInfo);
|
291 |
+
} catch (Creativestyle_AmazonPayments_Exception_InvalidTransaction $e) {
|
292 |
+
if ($this->_shouldReauthorizeAsynchronously($isSync, $e->getState(), $e->getReasonCode())) {
|
293 |
+
$transaction->setIsClosed(true);
|
294 |
+
return $this->_authorize(
|
295 |
+
$payment,
|
296 |
+
$amount,
|
297 |
+
$stateObject,
|
298 |
+
$this->_getTransactionSequenceId($payment),
|
299 |
+
$parentTransactionId,
|
300 |
+
false,
|
301 |
+
$captureNow
|
302 |
+
);
|
303 |
+
}
|
304 |
+
|
305 |
+
throw $e;
|
306 |
+
}
|
307 |
+
|
308 |
+
return $transaction;
|
309 |
}
|
310 |
|
311 |
/**
|
312 |
+
* @param array|null $transactionInfo
|
|
|
313 |
* @return bool
|
314 |
*/
|
315 |
+
protected function _validateAuthorizationState($transactionInfo = null)
|
316 |
+
{
|
317 |
+
return $this->_assertTransactionState(
|
318 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_AUTH,
|
319 |
+
$transactionInfo,
|
320 |
+
array(
|
321 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_PENDING,
|
322 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_OPEN,
|
323 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_COMPLETED,
|
324 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_CLOSED
|
325 |
+
)
|
326 |
+
);
|
327 |
+
}
|
328 |
+
|
329 |
+
protected function _capture(
|
330 |
+
Mage_Sales_Model_Order_Payment $payment,
|
331 |
+
$amount,
|
332 |
+
Varien_Object $stateObject,
|
333 |
+
$transactionReferenceId,
|
334 |
+
$parentTransactionId
|
335 |
+
) {
|
336 |
+
if (!$this->canCapture()) {
|
337 |
+
throw new Creativestyle_AmazonPayments_Exception('Capture action is not available');
|
338 |
+
}
|
339 |
+
|
340 |
+
$transactionDetails = $this->_getPaymentProcessor($payment)->capture(
|
341 |
+
$amount,
|
342 |
+
$payment->getOrder()->getBaseCurrencyCode(),
|
343 |
+
$transactionReferenceId,
|
344 |
+
$parentTransactionId
|
345 |
+
);
|
346 |
+
/** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
|
347 |
+
$transaction = $payment->setIsTransactionClosed(false)
|
348 |
+
->setTransactionId($transactionDetails->getAmazonCaptureId())
|
349 |
+
->setParentTransactionId($parentTransactionId)
|
350 |
+
->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
351 |
+
$transactionInfo = $this->_fetchTransactionInfo($payment, $transaction, $stateObject, $transactionDetails);
|
352 |
+
$this->_validateCaptureState($transactionInfo);
|
353 |
+
if ($transactionInfo) {
|
354 |
+
$transaction->setAdditionalInformation(
|
355 |
+
Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
|
356 |
+
$transactionInfo
|
357 |
+
);
|
358 |
+
}
|
359 |
+
|
360 |
+
return $transaction;
|
361 |
}
|
362 |
|
363 |
/**
|
364 |
+
* @param array|null $transactionInfo
|
|
|
365 |
* @return bool
|
366 |
*/
|
367 |
+
protected function _validateCaptureState(array $transactionInfo = null)
|
368 |
+
{
|
369 |
+
return $this->_assertTransactionState(
|
370 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_CAPTURE,
|
371 |
+
$transactionInfo,
|
372 |
+
array(
|
373 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_PENDING,
|
374 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_COMPLETED,
|
375 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_CLOSED
|
376 |
+
)
|
377 |
+
);
|
378 |
}
|
379 |
|
380 |
/**
|
381 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
382 |
+
* @param $amount
|
383 |
+
* @param Varien_Object $stateObject
|
384 |
+
* @param $transactionReferenceId
|
385 |
+
* @param $parentTransactionId
|
386 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction
|
387 |
* @throws Creativestyle_AmazonPayments_Exception
|
388 |
*/
|
389 |
+
protected function _refund(
|
390 |
+
Mage_Sales_Model_Order_Payment $payment,
|
391 |
+
$amount,
|
392 |
+
Varien_Object $stateObject,
|
393 |
+
$transactionReferenceId,
|
394 |
+
$parentTransactionId
|
395 |
+
) {
|
396 |
+
if (!$this->canRefund()) {
|
397 |
+
throw new Creativestyle_AmazonPayments_Exception('Refund action is not available');
|
|
|
|
|
|
|
|
|
398 |
}
|
399 |
+
|
400 |
+
$transactionDetails = $this->_getPaymentProcessor($payment)->refund(
|
401 |
+
$amount,
|
402 |
+
$payment->getOrder()->getBaseCurrencyCode(),
|
403 |
+
$transactionReferenceId,
|
404 |
+
$parentTransactionId
|
405 |
+
);
|
406 |
+
/** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
|
407 |
+
$transaction = $payment->setIsTransactionClosed(false)
|
408 |
+
->setTransactionId($transactionDetails->getAmazonRefundId())
|
409 |
+
->setParentTransactionId($parentTransactionId)
|
410 |
+
->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
|
411 |
+
$transactionInfo = $this->_fetchTransactionInfo($payment, $transaction, $stateObject, $transactionDetails);
|
412 |
+
$this->_validateRefundState($transactionInfo);
|
413 |
+
if ($transactionInfo) {
|
414 |
+
$transaction->setAdditionalInformation(
|
415 |
+
Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
|
416 |
+
$transactionInfo
|
417 |
+
);
|
418 |
+
}
|
419 |
+
|
420 |
+
return $transaction;
|
421 |
}
|
422 |
|
423 |
/**
|
424 |
+
* @param array|null $transactionInfo
|
425 |
+
* @return bool
|
|
|
|
|
426 |
*/
|
427 |
+
protected function _validateRefundState(array $transactionInfo = null)
|
428 |
+
{
|
429 |
+
return $this->_assertTransactionState(
|
430 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_REFUND,
|
431 |
+
$transactionInfo,
|
432 |
+
array(
|
433 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_PENDING,
|
434 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_COMPLETED
|
435 |
+
)
|
436 |
+
);
|
437 |
}
|
438 |
|
439 |
/**
|
440 |
+
* Fetch payment transaction info
|
441 |
*
|
442 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
443 |
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
444 |
+
* @param Varien_Object $stateObject
|
445 |
+
* @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model|null $transactionDetails
|
446 |
* @return array|null
|
447 |
*/
|
448 |
+
public function _fetchTransactionInfo(
|
449 |
+
Mage_Sales_Model_Order_Payment $payment,
|
450 |
+
Mage_Sales_Model_Order_Payment_Transaction $transaction,
|
451 |
+
Varien_Object $stateObject,
|
452 |
+
$transactionDetails = null
|
453 |
+
) {
|
454 |
+
$transactionProcessor = $this->_getTransactionProcessor($transaction)
|
455 |
+
->setTransactionDetails($transactionDetails);
|
456 |
+
$this->_getOrderProcessor($payment)->importTransactionDetails(
|
457 |
+
$transactionProcessor,
|
458 |
+
$stateObject,
|
459 |
+
$this->_getCustomStatusList($transaction->getOrder()->getStoreId())
|
460 |
+
);
|
461 |
+
$this->_lastTransactionProcessor = $transactionProcessor;
|
462 |
+
return $transactionProcessor->getRawDetails();
|
463 |
}
|
464 |
|
465 |
/**
|
466 |
+
* Check whether Pay with Amazon is available
|
|
|
|
|
|
|
|
|
|
|
467 |
*
|
468 |
+
* @param Mage_Sales_Model_Quote|null $quote
|
469 |
+
* @return bool
|
470 |
*/
|
471 |
+
public function isAvailable($quote = null)
|
472 |
+
{
|
473 |
+
$checkResult = new StdClass;
|
474 |
+
$isActive = $this->_getConfig()->isPayActive($quote ? $quote->getStoreId() : null);
|
475 |
+
if ($quote && !$quote->validateMinimumAmount()) {
|
476 |
+
$isActive = false;
|
477 |
}
|
478 |
+
|
479 |
+
if ($quote && Mage::app()->getStore()->roundPrice($quote->getGrandTotal()) == 0) {
|
480 |
+
$isActive = false;
|
481 |
+
}
|
482 |
+
|
483 |
+
$checkResult->isAvailable = $isActive;
|
484 |
+
$checkResult->isDeniedInConfig = !$isActive;
|
485 |
+
Mage::dispatchEvent(
|
486 |
+
'payment_method_is_active',
|
487 |
+
array(
|
488 |
+
'result' => $checkResult,
|
489 |
+
'method_instance' => $this,
|
490 |
+
'quote' => $quote,
|
491 |
+
)
|
492 |
);
|
493 |
+
return $checkResult->isAvailable;
|
|
|
|
|
|
|
|
|
494 |
}
|
495 |
|
496 |
/**
|
497 |
+
* @inheritdoc
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
*/
|
499 |
+
public function getConfigData($field, $storeId = null)
|
500 |
+
{
|
501 |
+
switch ($field) {
|
502 |
+
case 'payment_action':
|
503 |
+
return $this->_getConfig()->getPaymentAction($storeId);
|
504 |
+
default:
|
505 |
+
return parent::getConfigData($field, $storeId);
|
506 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
}
|
508 |
|
509 |
/**
|
510 |
+
* Method that will be executed instead of authorize or capture
|
511 |
+
* if flag isInitializeNeeded set to true
|
|
|
|
|
|
|
512 |
*
|
513 |
+
* @param string $paymentAction
|
514 |
+
* @param Varien_Object $stateObject
|
515 |
+
* @return $this
|
516 |
*/
|
517 |
+
public function initialize($paymentAction, $stateObject)
|
518 |
+
{
|
519 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
520 |
+
$payment = $this->getInfoInstance();
|
521 |
+
$orderReferenceId = $payment->getTransactionId();
|
522 |
+
|
523 |
+
$this->_order(
|
524 |
+
$payment,
|
525 |
+
$payment->getOrder()->getBaseTotalDue(),
|
526 |
+
$stateObject
|
527 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
|
529 |
+
if (in_array($paymentAction, array(self::ACTION_AUTHORIZE, self::ACTION_AUTHORIZE_CAPTURE))) {
|
530 |
+
$this->_authorize(
|
531 |
+
$payment,
|
532 |
+
$payment->getOrder()->getBaseTotalDue(),
|
533 |
+
$stateObject,
|
534 |
+
$this->_getTransactionSequenceId($payment),
|
535 |
+
$orderReferenceId,
|
536 |
+
$this->_getConfig()->isAuthorizationSynchronous($payment->getOrder()->getStoreId()),
|
537 |
+
$this->_getConfig()->captureImmediately($payment->getOrder()->getStoreId())
|
538 |
+
);
|
539 |
}
|
540 |
+
|
541 |
+
return $this;
|
542 |
}
|
543 |
|
544 |
/**
|
|
|
|
|
545 |
* @param Varien_Object $payment
|
546 |
* @param float $amount
|
547 |
+
* @return $this
|
|
|
548 |
*/
|
549 |
+
public function order(Varien_Object $payment, $amount)
|
550 |
+
{
|
551 |
+
$this->_order($payment, $amount, new Varien_Object());
|
|
|
|
|
|
|
552 |
return $this;
|
553 |
}
|
554 |
|
555 |
/**
|
|
|
|
|
556 |
* @param Varien_Object $payment
|
557 |
* @param float $amount
|
558 |
+
* @return $this
|
559 |
+
*/
|
560 |
+
public function authorize(Varien_Object $payment, $amount)
|
561 |
+
{
|
562 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
563 |
+
$parentTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
|
564 |
+
if ($parentTransaction) {
|
565 |
+
$this->_authorize(
|
566 |
+
$payment,
|
567 |
$amount,
|
568 |
+
new Varien_Object(),
|
569 |
+
$this->_getTransactionSequenceId($payment),
|
570 |
+
$parentTransaction->getTxnId(),
|
571 |
+
$this->_getConfig()->captureImmediately($payment->getOrder()->getStoreId()),
|
572 |
$this->_getConfig()->isAuthorizationSynchronous($payment->getOrder()->getStoreId())
|
573 |
);
|
|
|
|
|
574 |
}
|
575 |
+
|
576 |
return $this;
|
577 |
}
|
578 |
|
579 |
/**
|
|
|
|
|
580 |
* @param Varien_Object $payment
|
581 |
* @param float $amount
|
582 |
+
* @return $this
|
583 |
+
*/
|
584 |
+
public function capture(Varien_Object $payment, $amount)
|
585 |
+
{
|
586 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
587 |
+
$parentTransaction = $payment->getAuthorizationTransaction();
|
588 |
+
if ($parentTransaction) {
|
589 |
+
$this->_capture(
|
590 |
+
$payment,
|
591 |
$amount,
|
592 |
+
new Varien_Object(),
|
593 |
+
$this->_getTransactionSequenceId($payment),
|
594 |
+
$parentTransaction->getTxnId()
|
595 |
);
|
|
|
|
|
|
|
596 |
$payment->setSkipTransactionCreation(true);
|
597 |
}
|
|
|
|
|
598 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
599 |
return $this;
|
600 |
}
|
601 |
|
602 |
/**
|
|
|
|
|
|
|
603 |
* @param Varien_Object $payment
|
604 |
* @param float $amount
|
605 |
+
* @return $this
|
606 |
+
*/
|
607 |
+
public function refund(Varien_Object $payment, $amount)
|
608 |
+
{
|
609 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
610 |
+
$parentTransaction = $payment
|
611 |
+
->lookupTransaction(null, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
612 |
+
if ($parentTransaction) {
|
613 |
+
$this->_refund(
|
614 |
+
$payment,
|
615 |
$amount,
|
616 |
+
new Varien_Object(),
|
617 |
+
$this->_getTransactionSequenceId($payment),
|
618 |
+
$parentTransaction->getTxnId()
|
619 |
);
|
|
|
|
|
|
|
620 |
$payment->setSkipTransactionCreation(true);
|
621 |
}
|
622 |
+
|
623 |
return $this;
|
624 |
}
|
625 |
|
626 |
/**
|
|
|
|
|
627 |
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
|
628 |
* @param Mage_Sales_Model_Order_Payment $payment
|
629 |
+
* @return $this
|
630 |
+
*/
|
631 |
+
public function processCreditmemo($creditmemo, $payment)
|
632 |
+
{
|
633 |
+
parent::processCreditmemo($creditmemo, $payment);
|
634 |
+
/** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
|
635 |
+
if ($this->_lastTransactionProcessor) {
|
636 |
+
$creditmemo->setState($this->_lastTransactionProcessor->getCreditmemoState());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
}
|
|
|
|
|
|
|
|
|
638 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
639 |
return $this;
|
640 |
}
|
641 |
|
642 |
/**
|
643 |
+
* Import transaction details
|
644 |
*
|
645 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
646 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
647 |
+
* @param Varien_Object $stateObject
|
648 |
+
* @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model|null $transactionDetails
|
649 |
+
* @return $this
|
650 |
+
*/
|
651 |
+
public function importTransactionDetails(
|
652 |
+
Mage_Sales_Model_Order_Payment $payment,
|
653 |
+
Mage_Sales_Model_Order_Payment_Transaction $transaction,
|
654 |
+
Varien_Object $stateObject,
|
655 |
+
$transactionDetails = null
|
656 |
+
) {
|
657 |
+
$transactionInfo = $this->_fetchTransactionInfo($payment, $transaction, $stateObject, $transactionDetails);
|
658 |
+
if ($transactionInfo) {
|
659 |
+
$transaction->setAdditionalInformation(
|
660 |
+
Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
|
661 |
+
$transactionInfo
|
662 |
+
);
|
663 |
}
|
|
|
664 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
665 |
return $this;
|
666 |
}
|
667 |
|
668 |
/**
|
669 |
+
* Fetch details for transaction with given ID
|
670 |
*
|
671 |
+
* @param Mage_Payment_Model_Info $payment
|
672 |
+
* @param string $transactionId
|
673 |
+
* @return array|null
|
674 |
*/
|
675 |
+
public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
|
676 |
+
{
|
677 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
678 |
+
if ($transaction = $payment->lookupTransaction($transactionId)) {
|
679 |
+
$transactionInfo = $this->_fetchTransactionInfo($payment, $transaction, new Varien_Object());
|
680 |
+
$payment->getOrder()
|
681 |
+
->addRelatedObject($transaction)
|
682 |
+
->save();
|
683 |
+
return $transactionInfo;
|
684 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
685 |
|
686 |
+
return array();
|
687 |
+
}
|
688 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Payment/Advanced.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Payment_Advanced extends Creativestyle_AmazonPayments_Model_Payment_Abstract
|
17 |
-
|
18 |
protected $_code = 'amazonpayments_advanced';
|
19 |
-
|
20 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Payment_Advanced extends Creativestyle_AmazonPayments_Model_Payment_Abstract
|
18 |
+
{
|
19 |
protected $_code = 'amazonpayments_advanced';
|
|
|
20 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Payment/Advanced/Sandbox.php
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Payment_Advanced_Sandbox extends
|
17 |
-
|
|
|
18 |
protected $_code = 'amazonpayments_advanced_sandbox';
|
19 |
-
|
20 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Payment_Advanced_Sandbox extends
|
18 |
+
Creativestyle_AmazonPayments_Model_Payment_Abstract
|
19 |
+
{
|
20 |
protected $_code = 'amazonpayments_advanced_sandbox';
|
|
|
21 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Payment/Legacy.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Payment_Legacy extends Mage_Payment_Model_Method_Abstract
|
|
|
17 |
|
18 |
protected $_code = 'amazonpayments_legacy';
|
19 |
protected $_infoBlockType = 'amazonpayments/payment_legacy_info';
|
@@ -36,12 +38,13 @@ class Creativestyle_AmazonPayments_Model_Payment_Legacy extends Mage_Payment_Mod
|
|
36 |
protected $_canCreateBillingAgreement = false;
|
37 |
protected $_canManageRecurringProfiles = false;
|
38 |
|
39 |
-
public function isAvailable($quote = null)
|
|
|
40 |
return false;
|
41 |
}
|
42 |
|
43 |
-
public function getCode()
|
|
|
44 |
return $this->getId();
|
45 |
}
|
46 |
-
|
47 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2016 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2016 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Payment_Legacy extends Mage_Payment_Model_Method_Abstract
|
18 |
+
{
|
19 |
|
20 |
protected $_code = 'amazonpayments_legacy';
|
21 |
protected $_infoBlockType = 'amazonpayments/payment_legacy_info';
|
38 |
protected $_canCreateBillingAgreement = false;
|
39 |
protected $_canManageRecurringProfiles = false;
|
40 |
|
41 |
+
public function isAvailable($quote = null)
|
42 |
+
{
|
43 |
return false;
|
44 |
}
|
45 |
|
46 |
+
public function getCode()
|
47 |
+
{
|
48 |
return $this->getId();
|
49 |
}
|
|
|
50 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Processor/Ipn.php
DELETED
@@ -1,139 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2015 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Processor_Ipn {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Return Magento order processor instance
|
20 |
-
*
|
21 |
-
* @param Mage_Sales_Model_Order $order
|
22 |
-
*
|
23 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
24 |
-
*/
|
25 |
-
protected function _getOrderProcessor($order) {
|
26 |
-
return Mage::getSingleton('amazonpayments/processor_order')->setOrder($order);
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* TODO: [_getOrderReferenceId description]
|
31 |
-
*
|
32 |
-
* @param string $transactionId
|
33 |
-
* @return string
|
34 |
-
*/
|
35 |
-
protected function _getOrderReferenceId($transactionId) {
|
36 |
-
return substr($transactionId, 0, strrpos($transactionId, '-'));
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Return Amazon Payments processor instance
|
41 |
-
*
|
42 |
-
* @param Mage_Sales_Model_Order_Payment $payment
|
43 |
-
*
|
44 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_Payment
|
45 |
-
*/
|
46 |
-
protected function _getPaymentProcessor($payment) {
|
47 |
-
return Mage::getSingleton('amazonpayments/processor_payment')->setPaymentObject($payment);
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* TODO: [_lookupPayment description]
|
52 |
-
*
|
53 |
-
* @param string $orderReferenceId
|
54 |
-
*
|
55 |
-
* @return Mage_Sales_Model_Order_Payment
|
56 |
-
*
|
57 |
-
* @throws Creativestyle_AmazonPayments_Exception
|
58 |
-
*/
|
59 |
-
protected function _lookupPayment($orderReferenceId) {
|
60 |
-
$order = Mage::getModel('sales/order')->loadByAttribute('ext_order_id', $orderReferenceId);
|
61 |
-
if (!is_object($order) || !$order->getId()) {
|
62 |
-
throw new Creativestyle_AmazonPayments_Exception('Payment transaction with such ID not found');
|
63 |
-
}
|
64 |
-
return $order->getPayment();
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Process a notification message requested via IPN
|
69 |
-
*
|
70 |
-
* @param OffAmazonPaymentNotifications_Notification $notification
|
71 |
-
*
|
72 |
-
* @throws Creativestyle_AmazonPayments_Exception
|
73 |
-
*/
|
74 |
-
public function processNotification($notification) {
|
75 |
-
if (null !== $notification) {
|
76 |
-
$payment = null;
|
77 |
-
$transaction = null;
|
78 |
-
$transactionDetails = null;
|
79 |
-
switch ($notification->getNotificationType()) {
|
80 |
-
case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_ORDER_REFERENCE:
|
81 |
-
if ($notification->isSetOrderReference()) {
|
82 |
-
$payment = $this->_lookupPayment($notification->getOrderReference()->getAmazonOrderReferenceId());
|
83 |
-
$transaction = $payment->lookupTransaction($notification->getOrderReference()->getAmazonOrderReferenceId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
|
84 |
-
$transactionDetails = $notification->getOrderReference();
|
85 |
-
} else {
|
86 |
-
throw new Creativestyle_AmazonPayments_Exception('OrderReference field not found in submitted notification');
|
87 |
-
}
|
88 |
-
break;
|
89 |
-
case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_AUTHORIZATION:
|
90 |
-
if ($notification->isSetAuthorizationDetails()) {
|
91 |
-
$payment = $this->_lookupPayment($this->_getOrderReferenceId($notification->getAuthorizationDetails()->getAuthorizationReferenceId()));
|
92 |
-
$transaction = $payment->lookupTransaction($notification->getAuthorizationDetails()->getAmazonAuthorizationId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
93 |
-
$transactionDetails = $notification->getAuthorizationDetails();
|
94 |
-
} else {
|
95 |
-
throw new Creativestyle_AmazonPayments_Exception('AuthorizationDetails field not found in submitted notification');
|
96 |
-
}
|
97 |
-
break;
|
98 |
-
case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_CAPTURE:
|
99 |
-
if ($notification->isSetCaptureDetails()) {
|
100 |
-
$payment = $this->_lookupPayment($this->_getOrderReferenceId($notification->getCaptureDetails()->getCaptureReferenceId()));
|
101 |
-
$transaction = $payment->lookupTransaction($notification->getCaptureDetails()->getAmazonCaptureId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
102 |
-
$transactionDetails = $notification->getCaptureDetails();
|
103 |
-
} else {
|
104 |
-
throw new Creativestyle_AmazonPayments_Exception('CaptureDetails field not found in submitted notification');
|
105 |
-
}
|
106 |
-
break;
|
107 |
-
case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_REFUND:
|
108 |
-
if ($notification->isSetRefundDetails()) {
|
109 |
-
$payment = $this->_lookupPayment($this->_getOrderReferenceId($notification->getRefundDetails()->getRefundReferenceId()));
|
110 |
-
$transaction = $payment->lookupTransaction($notification->getRefundDetails()->getAmazonRefundId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
|
111 |
-
$transactionDetails = $notification->getRefundDetails();
|
112 |
-
} else {
|
113 |
-
throw new Creativestyle_AmazonPayments_Exception('RefundDetails field not found in submitted notification');
|
114 |
-
}
|
115 |
-
break;
|
116 |
-
default:
|
117 |
-
throw new Creativestyle_AmazonPayments_Exception('Invalid notification type');
|
118 |
-
}
|
119 |
-
if ($payment && $transaction) {
|
120 |
-
$transactionAdapter = $this->_getPaymentProcessor($payment)->importTransactionDetails($transaction);
|
121 |
-
if ($transactionAdapter->getStatusChange()) {
|
122 |
-
$stateObject = new Varien_Object();
|
123 |
-
$transactionAdapter->saveTransaction();
|
124 |
-
$this->_getOrderProcessor($payment->getOrder())
|
125 |
-
->importTransactionDetails($transactionAdapter, $stateObject)
|
126 |
-
->saveOrder();
|
127 |
-
} else {
|
128 |
-
$relatedTransactionAdapter = $transactionAdapter->processRelatedObjects($payment->getOrder());
|
129 |
-
$this->_getOrderProcessor($payment->getOrder())->saveOrder();
|
130 |
-
}
|
131 |
-
} else {
|
132 |
-
throw new Creativestyle_AmazonPayments_Exception('Payment transaction with such ID not found');
|
133 |
-
}
|
134 |
-
} else {
|
135 |
-
throw new Creativestyle_AmazonPayments_Exception('No notification data provided');
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Model/Processor/Order.php
CHANGED
@@ -1,530 +1,506 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Processor_Order
|
|
|
|
|
17 |
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
*
|
25 |
-
* @return
|
26 |
*/
|
27 |
-
protected function
|
28 |
-
|
|
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
-
*
|
33 |
-
*
|
34 |
-
* @param Varien_Object &$stateObject
|
35 |
*
|
|
|
36 |
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
37 |
*/
|
38 |
-
protected function
|
39 |
-
|
40 |
-
|
41 |
-
}
|
42 |
-
$stateObject->setData(array(
|
43 |
-
'state' => $this->getOrder()->getState() ? $this->getOrder()->getState() : Mage_Sales_Model_Order::STATE_NEW,
|
44 |
-
'status' => $this->getOrder()->getStatus() ? $this->getOrder()->getStatus() : $this->_getConfig()->getNewOrderStatus($this->_store),
|
45 |
-
'is_notified' => Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE
|
46 |
-
));
|
47 |
-
return $this;
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
*
|
52 |
*
|
53 |
-
* @param
|
54 |
-
* @
|
55 |
-
*
|
56 |
-
* @return bool
|
57 |
*/
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
-
|
|
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
-
* @
|
|
|
73 |
*/
|
74 |
-
protected function
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
*
|
80 |
-
* indexed with the same keys Magento order address entities
|
81 |
-
*
|
82 |
-
* @param OffAmazonPaymentsService_Model_Address $amazonAddress
|
83 |
*
|
84 |
-
* @
|
|
|
85 |
*/
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
);
|
93 |
-
|
94 |
-
$data['firstname'] = $explodedName->getFirstname();
|
95 |
-
$data['lastname'] = $explodedName->getLastname();
|
96 |
-
$data['country_id'] = $amazonAddress->getCountryCode();
|
97 |
-
$data['city'] = $amazonAddress->getCity();
|
98 |
-
$data['postcode'] = $amazonAddress->getPostalCode();
|
99 |
-
$data['telephone'] = $amazonAddress->getPhone();
|
100 |
-
return new Varien_Object($data);
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
-
* @
|
|
|
105 |
*/
|
106 |
-
protected function
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
}
|
109 |
|
110 |
/**
|
111 |
-
*
|
112 |
-
*
|
113 |
-
*
|
114 |
-
*
|
115 |
-
* @param string $addressLine1
|
116 |
-
* @param string $addressLine2
|
117 |
-
* @param string $addressLine3
|
118 |
-
* @param string $countryId
|
119 |
-
*
|
120 |
-
* @return array
|
121 |
*/
|
122 |
-
|
123 |
-
|
124 |
-
if ($
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
if (self::isPoBox($addressLine1)) {
|
135 |
-
$data['street'][] = $addressLine1;
|
136 |
-
} else {
|
137 |
-
$data['company'] = $addressLine1;
|
138 |
-
}
|
139 |
-
$data['street'][] = $addressLine2;
|
140 |
-
} else {
|
141 |
-
$data['street'][] = $addressLine1;
|
142 |
-
}
|
143 |
-
} else {
|
144 |
-
if ($addressLine1) {
|
145 |
-
$data['street'][] = $addressLine1;
|
146 |
-
}
|
147 |
-
if ($addressLine2) {
|
148 |
-
$data['street'][] = $addressLine2;
|
149 |
-
}
|
150 |
-
if ($addressLine3) {
|
151 |
-
$data['street'][] = $addressLine3;
|
152 |
-
}
|
153 |
}
|
154 |
-
return $data;
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
-
* @
|
159 |
*/
|
160 |
-
protected function
|
161 |
-
|
|
|
162 |
}
|
163 |
|
164 |
/**
|
165 |
-
*
|
166 |
-
* with the same keys as Magento order entity
|
167 |
-
*
|
168 |
-
* @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
|
169 |
-
*
|
170 |
-
* @return Varien_Object
|
171 |
*/
|
172 |
-
protected function
|
173 |
-
|
174 |
-
|
175 |
-
if ($transactionDetails instanceof OffAmazonPaymentsService_Model_OrderReferenceDetails) {
|
176 |
-
if ($transactionDetails->isSetBuyer()) {
|
177 |
-
$data['customer_email'] = $transactionDetails->getBuyer()->getEmail();
|
178 |
-
$customerName = Mage::helper('amazonpayments')->explodeCustomerName($transactionDetails->getBuyer()->getName(), null);
|
179 |
-
$data['customer_firstname'] = $customerName->getFirstname();
|
180 |
-
$data['customer_lastname'] = $customerName->getLastname();
|
181 |
-
}
|
182 |
-
if ($transactionDetails->isSetDestination()) {
|
183 |
-
if ($transactionDetails->getDestination()->isSetPhysicalDestination()) {
|
184 |
-
$data['shipping_address'] = self::mapAmazonAddress($transactionDetails->getDestination()->getPhysicalDestination());
|
185 |
-
}
|
186 |
-
}
|
187 |
-
if ($transactionDetails->isSetBillingAddress()) {
|
188 |
-
if ($transactionDetails->getBillingAddress()->isSetPhysicalAddress()) {
|
189 |
-
$data['billing_address'] = self::mapAmazonAddress($transactionDetails->getBillingAddress()->getPhysicalAddress());
|
190 |
-
$data['customer_firstname'] = $data['billing_address']->getFirstname();
|
191 |
-
$data['customer_lastname'] = $data['billing_address']->getLastname();
|
192 |
-
}
|
193 |
-
} elseif (isset($data['shipping_address'])) {
|
194 |
-
$data['billing_address'] = $data['shipping_address'];
|
195 |
-
}
|
196 |
-
}
|
197 |
-
// AuthorizationDetails from API response
|
198 |
-
elseif ($transactionDetails instanceof OffAmazonPaymentsService_Model_AuthorizationDetails) {
|
199 |
-
if ($transactionDetails->isSetAuthorizationBillingAddress()) {
|
200 |
-
$data['billing_address'] = self::mapAmazonAddress($transactionDetails->getAuthorizationBillingAddress());
|
201 |
-
$data['customer_firstname'] = $data['billing_address']->getFirstname();
|
202 |
-
$data['customer_lastname'] = $data['billing_address']->getLastname();
|
203 |
-
}
|
204 |
-
}
|
205 |
-
return new Varien_Object($data);
|
206 |
}
|
207 |
|
208 |
/**
|
209 |
-
*
|
210 |
-
*
|
211 |
-
* @param Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter $transactionAdapter
|
212 |
-
* @param Varien_Object &$stateObject
|
213 |
-
*
|
214 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
215 |
*/
|
216 |
-
protected function
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
'state' => Mage_Sales_Model_Order::STATE_HOLDED,
|
226 |
-
'status' => $this->_getConfig()->getHoldedOrderStatus($this->_store)
|
227 |
-
));
|
228 |
-
break; // ORDER_SUSPENDED
|
229 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_OPEN:
|
230 |
-
$stateObject->setData(array(
|
231 |
-
'state' => Mage_Sales_Model_Order::STATE_NEW,
|
232 |
-
'status' => $this->_getConfig()->getNewOrderStatus($this->_store),
|
233 |
-
));
|
234 |
-
break; // ORDER_OPEN
|
235 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CANCELED:
|
236 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED:
|
237 |
-
break; // ORDER_CANCELED / ORDER_CLOSED
|
238 |
-
}
|
239 |
-
break;
|
240 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
|
241 |
-
$message = 'An authorization of %s has been processed by Amazon Payments (%s). The new status is %s.';
|
242 |
-
switch ($transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_KEY)) {
|
243 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_PENDING:
|
244 |
-
$stateObject->setData(array(
|
245 |
-
'state' => Mage_Sales_Model_Order::STATE_NEW,
|
246 |
-
'status' => $this->_getConfig()->getNewOrderStatus($this->_store),
|
247 |
-
));
|
248 |
-
break; // AUTH_PENDING
|
249 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_OPEN:
|
250 |
-
$stateObject->setData(array(
|
251 |
-
'state' => Mage_Sales_Model_Order::STATE_PROCESSING,
|
252 |
-
'status' => $this->_getConfig()->getAuthorizedOrderStatus($this->_store)
|
253 |
-
));
|
254 |
-
break; // AUTH_OPEN
|
255 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED:
|
256 |
-
switch ($transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_REASON_CODE_KEY)) {
|
257 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_REASON_EXPIRED_UNUSED:
|
258 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_REASON_AMAZON_CLOSED:
|
259 |
-
$stateObject->setData(array(
|
260 |
-
'hold_before_state' => $stateObject->getState(),
|
261 |
-
'hold_before_status' => $stateObject->getStatus(),
|
262 |
-
'state' => Mage_Sales_Model_Order::STATE_HOLDED,
|
263 |
-
'status' => $this->_getConfig()->getHoldedOrderStatus($this->_store)
|
264 |
-
));
|
265 |
-
break;
|
266 |
-
default:
|
267 |
-
$stateObject->setData(array(
|
268 |
-
'state' => Mage_Sales_Model_Order::STATE_PROCESSING,
|
269 |
-
'status' => $this->_getConfig()->getAuthorizedOrderStatus($this->_store)
|
270 |
-
));
|
271 |
-
break;
|
272 |
-
}
|
273 |
-
break; // AUTH_OPEN
|
274 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED:
|
275 |
-
$stateObject->setData(array(
|
276 |
-
'hold_before_state' => $stateObject->getState(),
|
277 |
-
'hold_before_status' => $stateObject->getStatus(),
|
278 |
-
'state' => Mage_Sales_Model_Order::STATE_HOLDED,
|
279 |
-
'status' => $this->_getConfig()->getHoldedOrderStatus($this->_store)
|
280 |
-
));
|
281 |
-
break; // AUTH_DECLINED
|
282 |
-
}
|
283 |
-
break;
|
284 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
|
285 |
-
$message = 'A capture of %s has been processed by Amazon Payments (%s). The new status is %s.';
|
286 |
-
switch ($transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_KEY)) {
|
287 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED:
|
288 |
-
$stateObject->setData(array(
|
289 |
-
'hold_before_state' => $stateObject->getState(),
|
290 |
-
'hold_before_status' => $stateObject->getStatus(),
|
291 |
-
'state' => Mage_Sales_Model_Order::STATE_HOLDED,
|
292 |
-
'status' => $this->_getConfig()->getHoldedOrderStatus($this->_store)
|
293 |
-
));
|
294 |
-
$this->_cancelInvoice($transactionAdapter);
|
295 |
-
break; // CAPTURE_DECLINED
|
296 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_COMPLETED:
|
297 |
-
$stateObject->setData(array(
|
298 |
-
'state' => Mage_Sales_Model_Order::STATE_PROCESSING,
|
299 |
-
'status' => $this->_getConfig()->getAuthorizedOrderStatus($this->_store)
|
300 |
-
));
|
301 |
-
break; // CAPTURE_COMPLETED
|
302 |
-
}
|
303 |
-
break;
|
304 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
|
305 |
-
$message = 'A refund of %s has been processed by Amazon Payments (%s). The new status is %s.';
|
306 |
-
break;
|
307 |
-
default:
|
308 |
-
return $this;
|
309 |
-
}
|
310 |
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
return $this;
|
322 |
}
|
323 |
|
324 |
/**
|
325 |
-
*
|
326 |
-
*
|
327 |
-
* @param Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter $transactionAdapter
|
328 |
-
* @param Varien_Object &$stateObject
|
329 |
-
*
|
330 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
331 |
*/
|
332 |
-
protected function
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
break;
|
343 |
-
case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED:
|
344 |
-
if ($this->getOrder()
|
345 |
-
&& $transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_REASON_CODE_KEY)
|
346 |
-
== Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_REASON_INVALID_PAYMENT)
|
347 |
-
{
|
348 |
-
Mage::helper('amazonpayments')->sendAuthorizationDeclinedEmail($this->getOrder());
|
349 |
-
$stateObject->setIsNotified(true);
|
350 |
-
}
|
351 |
-
break;
|
352 |
-
}
|
353 |
-
break;
|
354 |
-
default:
|
355 |
-
return $this;
|
356 |
}
|
357 |
|
358 |
return $this;
|
359 |
}
|
360 |
|
361 |
/**
|
362 |
-
*
|
363 |
-
*
|
364 |
-
* @param Mage_Customer_Model_Address_Abstract $addressObject
|
365 |
-
* @param Varien_Object $addressData
|
366 |
*/
|
367 |
-
protected function
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
$addressObject->setCompany($addressData->getCompany());
|
376 |
-
}
|
377 |
-
if ($addressObject->getCity() != $addressData->getCity()) {
|
378 |
-
$addressObject->setCity($addressData->getCity());
|
379 |
-
}
|
380 |
-
if ($addressObject->getPostcode() != $addressData->getPostcode()) {
|
381 |
-
$addressObject->setPostcode($addressData->getPostcode());
|
382 |
-
}
|
383 |
-
if ($addressObject->getCountryId() != $addressData->getCountryId()) {
|
384 |
-
$addressObject->setCountryId($addressData->getCountryId());
|
385 |
-
}
|
386 |
-
if ($addressObject->getTelephone() != $addressData->getTelephone()) {
|
387 |
-
$addressObject->setTelephone($addressData->getTelephone());
|
388 |
-
}
|
389 |
-
$streetDiff = array_diff($addressObject->getStreet(), $addressData->getStreet());
|
390 |
-
if (!empty($streetDiff)) {
|
391 |
-
$addressObject->setStreet($addressData->getStreet());
|
392 |
}
|
|
|
|
|
393 |
}
|
394 |
|
395 |
/**
|
396 |
-
*
|
397 |
-
*
|
398 |
-
* @param Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter $transactionAdapter
|
399 |
-
* @param Varien_Object &$stateObject
|
400 |
-
*
|
401 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
402 |
*/
|
403 |
-
protected function
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
if ($orderData->hasBillingAddress()) {
|
416 |
-
$this->_updateAddress($this->getOrder()->getBillingAddress(), $orderData->getBillingAddress());
|
417 |
-
}
|
418 |
-
if ($orderData->hasShippingAddress()) {
|
419 |
-
$this->_updateAddress($this->getOrder()->getShippingAddress(), $orderData->getShippingAddress());
|
420 |
-
}
|
421 |
}
|
422 |
|
423 |
-
$this
|
|
|
424 |
|
425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
}
|
441 |
|
442 |
return $this;
|
443 |
}
|
444 |
|
445 |
/**
|
446 |
-
*
|
447 |
-
*
|
448 |
-
* @
|
449 |
-
* @return Mage_Sales_Model_Order_Invoice|bool
|
450 |
*/
|
451 |
-
protected function
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
}
|
457 |
}
|
458 |
-
|
|
|
459 |
}
|
460 |
|
461 |
/**
|
462 |
-
*
|
463 |
-
*
|
464 |
-
* @
|
465 |
-
*
|
466 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
467 |
*/
|
468 |
-
protected function
|
469 |
-
|
470 |
-
|
471 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
}
|
|
|
473 |
return $this;
|
474 |
}
|
475 |
|
476 |
/**
|
477 |
-
* TODO: [setOrder description]
|
478 |
-
*
|
479 |
* @param Mage_Sales_Model_Order $order
|
480 |
-
*
|
481 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
482 |
*/
|
483 |
-
public function setOrder($order)
|
|
|
484 |
$this->_order = $order;
|
485 |
-
$this->_store = $order->getStoreId();
|
486 |
return $this;
|
487 |
}
|
488 |
|
489 |
/**
|
490 |
-
*
|
491 |
*
|
492 |
* @return Mage_Sales_Model_Order
|
|
|
493 |
*/
|
494 |
-
public function getOrder()
|
|
|
495 |
if (null === $this->_order) {
|
496 |
throw new Creativestyle_AmazonPayments_Exception('Order object is not set');
|
497 |
}
|
|
|
498 |
return $this->_order;
|
499 |
}
|
500 |
|
501 |
/**
|
502 |
-
*
|
503 |
-
*
|
504 |
-
* @param Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter $transactionAdapter
|
505 |
-
* @param Varien_Object &$stateObject
|
506 |
-
*
|
507 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
508 |
*/
|
509 |
-
public function
|
510 |
-
|
511 |
-
|
512 |
-
if (null !== $relatedTransactionAdapter) {
|
513 |
-
$this->_initStateObject($stateObject)->_updateOrderData($relatedTransactionAdapter, $stateObject);
|
514 |
-
}
|
515 |
-
return $this;
|
516 |
}
|
517 |
|
518 |
/**
|
519 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
*
|
521 |
-
* @return
|
522 |
*/
|
523 |
-
public function
|
524 |
-
|
525 |
-
|
526 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
527 |
return $this;
|
528 |
}
|
529 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2015 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2015 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Processor_Order
|
18 |
+
{
|
19 |
+
const REGISTRY_KEY = 'amazon_pay_order_processor';
|
20 |
|
21 |
+
/**
|
22 |
+
* @var Mage_Sales_Model_Order
|
23 |
+
*/
|
24 |
+
protected $_order;
|
25 |
|
26 |
+
/**
|
27 |
+
* @var array
|
28 |
+
*/
|
29 |
+
protected $_orderAfterSaveCallbacks = array();
|
30 |
|
31 |
/**
|
32 |
+
* Returns Amazon Pay helper
|
33 |
*
|
34 |
+
* @return Creativestyle_AmazonPayments_Helper_Data
|
35 |
*/
|
36 |
+
protected function _getHelper()
|
37 |
+
{
|
38 |
+
return Mage::helper('amazonpayments');
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* Return Magento order processor instance
|
|
|
|
|
43 |
*
|
44 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
45 |
* @return Creativestyle_AmazonPayments_Model_Processor_Order
|
46 |
*/
|
47 |
+
protected function _getOrderProcessor(Mage_Sales_Model_Order_Payment $payment)
|
48 |
+
{
|
49 |
+
return Mage::getModel('amazonpayments/processor_order')->setOrder($payment->getOrder());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Returns transaction processor instance
|
54 |
*
|
55 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
56 |
+
* @return Creativestyle_AmazonPayments_Model_Processor_Transaction
|
|
|
|
|
57 |
*/
|
58 |
+
protected function _getTransactionProcessor(Mage_Sales_Model_Order_Payment_Transaction $transaction)
|
59 |
+
{
|
60 |
+
return Mage::getModel('amazonpayments/processor_transaction')->setTransaction($transaction);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @param string $transactionId
|
65 |
+
* @return Mage_Sales_Model_Order_Invoice|null
|
66 |
+
*/
|
67 |
+
protected function _getInvoiceByTransactionId($transactionId)
|
68 |
+
{
|
69 |
+
$invoiceCollection = $this->getOrder()->getInvoiceCollection();
|
70 |
+
/** @var Mage_Sales_Model_Order_Invoice $invoice */
|
71 |
+
foreach ($invoiceCollection as $invoice) {
|
72 |
+
if ($invoice->getTransactionId() == $transactionId) {
|
73 |
+
return $invoice;
|
74 |
+
}
|
75 |
}
|
76 |
+
|
77 |
+
return null;
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* @param string $transactionId
|
82 |
+
* @return Mage_Sales_Model_Order_Creditmemo|null
|
83 |
*/
|
84 |
+
protected function _getCreditmemoByTransactionId($transactionId)
|
85 |
+
{
|
86 |
+
$creditmemosCollection = $this->getOrder()->getCreditmemosCollection();
|
87 |
+
/** @var Mage_Sales_Model_Order_Creditmemo $creditmemo */
|
88 |
+
foreach ($creditmemosCollection as $creditmemo) {
|
89 |
+
if ($creditmemo->getTransactionId() == $transactionId) {
|
90 |
+
return $creditmemo;
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
return null;
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
+
* Init order state object for further processing
|
|
|
|
|
|
|
99 |
*
|
100 |
+
* @param Varien_Object $stateObject
|
101 |
+
* @return $this
|
102 |
*/
|
103 |
+
protected function _initStateObject(Varien_Object $stateObject)
|
104 |
+
{
|
105 |
+
$stateObject->setData(
|
106 |
+
array(
|
107 |
+
'state' => $this->getOrder()->getState()
|
108 |
+
? $this->getOrder()->getState()
|
109 |
+
: Mage_Sales_Model_Order::STATE_NEW,
|
110 |
+
'status' => $this->getOrder()->getStatus()
|
111 |
+
? $this->getOrder()->getStatus()
|
112 |
+
: Mage::getModel('sales/order_status')
|
113 |
+
->loadDefaultByState(Mage_Sales_Model_Order::STATE_NEW)
|
114 |
+
->getStatus(),
|
115 |
+
'is_notified' => Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE
|
116 |
+
)
|
117 |
);
|
118 |
+
return $this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
+
* @param Mage_Customer_Model_Address_Abstract $address
|
123 |
+
* @param Varien_Object $newAddress
|
124 |
*/
|
125 |
+
protected function _updateAddress($address, $newAddress)
|
126 |
+
{
|
127 |
+
if ($address->getFirstname() != $newAddress->getFirstname()) {
|
128 |
+
$address->setFirstname($newAddress->getFirstname());
|
129 |
+
}
|
130 |
+
|
131 |
+
if ($address->getLastname() != $newAddress->getLastname()) {
|
132 |
+
$address->setLastname($newAddress->getLastname());
|
133 |
+
}
|
134 |
+
|
135 |
+
if ($address->getCompany() != $newAddress->getCompany()) {
|
136 |
+
$address->setCompany($newAddress->getCompany());
|
137 |
+
}
|
138 |
+
|
139 |
+
if ($address->getCity() != $newAddress->getCity()) {
|
140 |
+
$address->setCity($newAddress->getCity());
|
141 |
+
}
|
142 |
+
|
143 |
+
if ($address->getPostcode() != $newAddress->getPostcode()) {
|
144 |
+
$address->setPostcode($newAddress->getPostcode());
|
145 |
+
}
|
146 |
+
|
147 |
+
if ($address->getCountryId() != $newAddress->getCountryId()) {
|
148 |
+
$address->setCountryId($newAddress->getCountryId());
|
149 |
+
}
|
150 |
+
|
151 |
+
if ($address->getTelephone() != $newAddress->getTelephone()) {
|
152 |
+
$address->setTelephone($newAddress->getTelephone());
|
153 |
+
}
|
154 |
+
|
155 |
+
$streetDiff = array_diff($address->getStreet(), $newAddress->getStreet());
|
156 |
+
if (!empty($streetDiff)) {
|
157 |
+
$address->setStreet($newAddress->getStreet());
|
158 |
+
}
|
159 |
}
|
160 |
|
161 |
/**
|
162 |
+
* @param string $email
|
163 |
+
* @param string $firstname
|
164 |
+
* @param string $lastname
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
*/
|
166 |
+
protected function _updateCustomerData($email, $firstname, $lastname)
|
167 |
+
{
|
168 |
+
if ($email && $this->getOrder()->getCustomerEmail() != $email) {
|
169 |
+
$this->getOrder()->setCustomerEmail($email);
|
170 |
+
}
|
171 |
+
|
172 |
+
if ($firstname && $this->getOrder()->getCustomerFirstname() != $firstname) {
|
173 |
+
$this->getOrder()->setCustomerFirstname($firstname);
|
174 |
+
}
|
175 |
+
|
176 |
+
if ($lastname && $this->getOrder()->getCustomerLastname() != $lastname) {
|
177 |
+
$this->getOrder()->setCustomerLastname($lastname);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
|
|
179 |
}
|
180 |
|
181 |
/**
|
182 |
+
* @param array $address
|
183 |
*/
|
184 |
+
protected function _updateBillingAddress(array $address)
|
185 |
+
{
|
186 |
+
$this->_updateAddress($this->getOrder()->getBillingAddress(), new Varien_Object($address));
|
187 |
}
|
188 |
|
189 |
/**
|
190 |
+
* @param array $address
|
|
|
|
|
|
|
|
|
|
|
191 |
*/
|
192 |
+
protected function _updateShippingAddress(array $address)
|
193 |
+
{
|
194 |
+
$this->_updateAddress($this->getOrder()->getShippingAddress(), new Varien_Object($address));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
}
|
196 |
|
197 |
/**
|
198 |
+
* @param Varien_Object $stateObject
|
199 |
+
* @return bool
|
|
|
|
|
|
|
|
|
200 |
*/
|
201 |
+
protected function _shouldUpdateOrderState(Varien_Object $stateObject)
|
202 |
+
{
|
203 |
+
return !$this->getOrder()->isCanceled()
|
204 |
+
&& $this->getOrder()->getState() != Mage_Sales_Model_Order::STATE_CLOSED
|
205 |
+
&& (
|
206 |
+
$stateObject->getState() != $this->getOrder()->getState()
|
207 |
+
|| $stateObject->getStatus() != $this->getOrder()->getStatus()
|
208 |
+
);
|
209 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
+
/**
|
212 |
+
* @param Varien_Object $stateObject
|
213 |
+
* @return $this
|
214 |
+
*/
|
215 |
+
protected function _updateOrderState(Varien_Object $stateObject)
|
216 |
+
{
|
217 |
+
if ($this->_shouldUpdateOrderState($stateObject)) {
|
218 |
+
$this->getOrder()
|
219 |
+
->setHoldBeforeState($stateObject->getHoldBeforeState() ? $stateObject->getHoldBeforeState() : null)
|
220 |
+
->setHoldBeforeStatus($stateObject->getHoldBeforeStatus() ? $stateObject->getHoldBeforeStatus() : null)
|
221 |
+
->setState(
|
222 |
+
$stateObject->getState(),
|
223 |
+
$stateObject->getStatus(),
|
224 |
+
$stateObject->getMessage(),
|
225 |
+
$stateObject->getIsNotified()
|
226 |
+
);
|
227 |
+
} elseif ($stateObject->getMessage()) {
|
228 |
+
/** @var Mage_Sales_Model_Order_Status_History $history */
|
229 |
+
$history = $this->getOrder()
|
230 |
+
->addStatusHistoryComment($stateObject->getMessage());
|
231 |
+
$history->setIsCustomerNotified($stateObject->getIsNotified());
|
232 |
+
}
|
233 |
|
234 |
return $this;
|
235 |
}
|
236 |
|
237 |
/**
|
238 |
+
* @param mixed|null $flags
|
239 |
+
* @return $this
|
|
|
|
|
|
|
|
|
240 |
*/
|
241 |
+
protected function _updatePaymentFlags($flags = null)
|
242 |
+
{
|
243 |
+
if (null !== $flags) {
|
244 |
+
if (!is_array($flags)) {
|
245 |
+
$flags = array($flags);
|
246 |
+
}
|
247 |
+
|
248 |
+
foreach ($flags as $flag) {
|
249 |
+
$this->getPayment()->setData($flag, true);
|
250 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
}
|
252 |
|
253 |
return $this;
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
258 |
+
* @return $this
|
|
|
|
|
259 |
*/
|
260 |
+
protected function _updateTransactionDocuments(
|
261 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
262 |
+
) {
|
263 |
+
switch ($transactionProcessor->getTransactionType()) {
|
264 |
+
case Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_CAPTURE:
|
265 |
+
return $this->_updateInvoice($transactionProcessor);
|
266 |
+
case Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_REFUND:
|
267 |
+
return $this->_updateCreditmemo($transactionProcessor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
+
|
270 |
+
return $this;
|
271 |
}
|
272 |
|
273 |
/**
|
274 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
275 |
+
* @return $this
|
|
|
|
|
|
|
|
|
276 |
*/
|
277 |
+
protected function _updateInvoice(
|
278 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
279 |
+
) {
|
280 |
+
$invoice = $this->_getInvoiceByTransactionId($transactionProcessor->getTransactionId());
|
281 |
+
if ($invoice) {
|
282 |
+
$this->getPayment()
|
283 |
+
->setSkipTransactionCreation(true)
|
284 |
+
->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, false);
|
285 |
+
} else {
|
286 |
+
$this->getPayment()
|
287 |
+
->setSkipTransactionCreation(true)
|
288 |
+
->registerCaptureNotification($transactionProcessor->getTransactionAmount());
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
}
|
290 |
|
291 |
+
return $this;
|
292 |
+
}
|
293 |
|
294 |
+
/**
|
295 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
296 |
+
* @return $this
|
297 |
+
*/
|
298 |
+
protected function _updateCreditmemo(
|
299 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
300 |
+
) {
|
301 |
+
$creditmemo = $this->_getCreditmemoByTransactionId($transactionProcessor->getTransactionId());
|
302 |
+
$state = $transactionProcessor->getCreditmemoState();
|
303 |
+
if ($creditmemo && null !== $state) {
|
304 |
+
$creditmemo->setState((int)$state);
|
305 |
+
$this->getOrder()->addRelatedObject($creditmemo);
|
306 |
+
}
|
307 |
|
308 |
+
return $this;
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
313 |
+
* @param Varien_Object $stateObject
|
314 |
+
* @return $this
|
315 |
+
*/
|
316 |
+
protected function _processChildTransactions(
|
317 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor,
|
318 |
+
Varien_Object $stateObject
|
319 |
+
) {
|
320 |
+
$childrenIds = $transactionProcessor->getChildrenIds();
|
321 |
+
if ($childrenIds) {
|
322 |
+
foreach ($childrenIds as $childTransactionId) {
|
323 |
+
if (!$this->getPayment()->lookupTransaction($childTransactionId)
|
324 |
+
&& $transactionProcessor->getMagentoChildTransactionType()) {
|
325 |
+
$this->addTransaction(
|
326 |
+
$transactionProcessor->getMagentoChildTransactionType(),
|
327 |
+
$childTransactionId,
|
328 |
+
$transactionProcessor->getTransactionId(),
|
329 |
+
$stateObject
|
330 |
+
);
|
331 |
+
}
|
332 |
+
}
|
333 |
}
|
334 |
|
335 |
return $this;
|
336 |
}
|
337 |
|
338 |
/**
|
339 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
340 |
+
* @param Varien_Object $stateObject
|
341 |
+
* @return $this
|
|
|
342 |
*/
|
343 |
+
protected function _processParentTransactions(
|
344 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor,
|
345 |
+
Varien_Object $stateObject
|
346 |
+
) {
|
347 |
+
if ($transactionProcessor->shouldUpdateParentTransaction()) {
|
348 |
+
if ($parentTransaction = $transactionProcessor->getTransaction()->getParentTransaction()) {
|
349 |
+
$this->getPaymentMethodInstance()
|
350 |
+
->importTransactionDetails($this->getPayment(), $parentTransaction, $stateObject);
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
if ($transactionProcessor->getTransactionType()
|
355 |
+
== Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_ORDER
|
356 |
+
&& $transactionProcessor->getTransactionState()
|
357 |
+
== Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_OPEN) {
|
358 |
+
$authTransaction = $this->getPayment()->getAuthorizationTransaction();
|
359 |
+
if ($authTransaction && $authTransaction->getIsClosed() && ($this->getOrder()->getBaseTotalDue() > 0)) {
|
360 |
+
$this->getPaymentMethodInstance()
|
361 |
+
->setStore($this->getStoreId())
|
362 |
+
->authorize($this->getPayment(), $this->getBaseTotalDue());
|
363 |
}
|
364 |
}
|
365 |
+
|
366 |
+
return $this;
|
367 |
}
|
368 |
|
369 |
/**
|
370 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
371 |
+
* @param Varien_Object $stateObject
|
372 |
+
* @return $this
|
|
|
|
|
373 |
*/
|
374 |
+
protected function _sendTransactionalEmails($transactionProcessor, $stateObject)
|
375 |
+
{
|
376 |
+
switch ($transactionProcessor->getTransactionalEmailToSend()) {
|
377 |
+
case Creativestyle_AmazonPayments_Model_Processor_Transaction::EMAIL_TYPE_NEW_ORDER:
|
378 |
+
if (!$this->getOrder()->getEmailSent()) {
|
379 |
+
$this->getOrder()->sendNewOrderEmail();
|
380 |
+
$stateObject->setIsNotified(true);
|
381 |
+
}
|
382 |
+
break;
|
383 |
+
case Creativestyle_AmazonPayments_Model_Processor_Transaction::EMAIL_TYPE_AUTH_DECLINED:
|
384 |
+
$this->_getHelper()->sendAuthorizationDeclinedEmail($this->getOrder());
|
385 |
+
$stateObject->setIsNotified(true);
|
386 |
+
break;
|
387 |
}
|
388 |
+
|
389 |
return $this;
|
390 |
}
|
391 |
|
392 |
/**
|
|
|
|
|
393 |
* @param Mage_Sales_Model_Order $order
|
394 |
+
* @return $this
|
|
|
395 |
*/
|
396 |
+
public function setOrder(Mage_Sales_Model_Order $order)
|
397 |
+
{
|
398 |
$this->_order = $order;
|
|
|
399 |
return $this;
|
400 |
}
|
401 |
|
402 |
/**
|
403 |
+
* Returns order instance
|
404 |
*
|
405 |
* @return Mage_Sales_Model_Order
|
406 |
+
* @throws Creativestyle_AmazonPayments_Exception
|
407 |
*/
|
408 |
+
public function getOrder()
|
409 |
+
{
|
410 |
if (null === $this->_order) {
|
411 |
throw new Creativestyle_AmazonPayments_Exception('Order object is not set');
|
412 |
}
|
413 |
+
|
414 |
return $this->_order;
|
415 |
}
|
416 |
|
417 |
/**
|
418 |
+
* @return Mage_Sales_Model_Order_Payment
|
|
|
|
|
|
|
|
|
|
|
419 |
*/
|
420 |
+
public function getPayment()
|
421 |
+
{
|
422 |
+
return $this->getOrder()->getPayment();
|
|
|
|
|
|
|
|
|
423 |
}
|
424 |
|
425 |
/**
|
426 |
+
* @return Creativestyle_AmazonPayments_Model_Payment_Abstract
|
427 |
+
*/
|
428 |
+
public function getPaymentMethodInstance()
|
429 |
+
{
|
430 |
+
return $this->getOrder()->getPayment()->getMethodInstance();
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Returns order's store ID
|
435 |
*
|
436 |
+
* @return int
|
437 |
*/
|
438 |
+
public function getStoreId()
|
439 |
+
{
|
440 |
+
return $this->getOrder()->getStoreId();
|
441 |
+
}
|
442 |
+
|
443 |
+
|
444 |
+
public function addTransaction(
|
445 |
+
$transactionType,
|
446 |
+
$transactionId,
|
447 |
+
$parentTransactionId,
|
448 |
+
Varien_Object $stateObject
|
449 |
+
) {
|
450 |
+
/** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
|
451 |
+
$transaction = $this->getPayment()->setIsTransactionClosed(false)
|
452 |
+
->setTransactionId($transactionId)
|
453 |
+
->setParentTransactionId($parentTransactionId)
|
454 |
+
->addTransaction($transactionType);
|
455 |
+
|
456 |
+
$this->getPaymentMethodInstance()
|
457 |
+
->importTransactionDetails($this->getPayment(), $transaction, $stateObject);
|
458 |
+
|
459 |
return $this;
|
460 |
}
|
461 |
|
462 |
+
/**
|
463 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
464 |
+
* @param Varien_Object $stateObject
|
465 |
+
* @param Varien_Object $customStatus
|
466 |
+
*/
|
467 |
+
public function importTransactionDetails(
|
468 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor,
|
469 |
+
Varien_Object $stateObject,
|
470 |
+
Varien_Object $customStatus
|
471 |
+
) {
|
472 |
+
if ($transactionProcessor->shouldUpdateTransaction()) {
|
473 |
+
$this->_initStateObject($stateObject);
|
474 |
+
|
475 |
+
if ($transactionProcessor->shouldUpdateOrderData()) {
|
476 |
+
$this->_updateCustomerData(
|
477 |
+
$transactionProcessor->getCustomerEmail(),
|
478 |
+
$transactionProcessor->getCustomerFirstname(),
|
479 |
+
$transactionProcessor->getCustomerLastname()
|
480 |
+
);
|
481 |
+
$shippingAddress = $transactionProcessor->getMagentoShippingAddress();
|
482 |
+
$billingAddress = $transactionProcessor->getMagentoBillingAddress();
|
483 |
+
|
484 |
+
if ($shippingAddress) {
|
485 |
+
$this->_updateShippingAddress($shippingAddress);
|
486 |
+
// use shipping address for billing, if billing address is empty
|
487 |
+
if (!$billingAddress) {
|
488 |
+
$billingAddress = $shippingAddress;
|
489 |
+
}
|
490 |
+
}
|
491 |
+
|
492 |
+
if ($billingAddress) {
|
493 |
+
$this->_updateBillingAddress($billingAddress);
|
494 |
+
}
|
495 |
+
}
|
496 |
+
|
497 |
+
$transactionProcessor->generateMagentoOrderStateObject($stateObject, $customStatus);
|
498 |
+
$this->_updatePaymentFlags($transactionProcessor->getPaymentFlags())
|
499 |
+
->_updateTransactionDocuments($transactionProcessor)
|
500 |
+
->_sendTransactionalEmails($transactionProcessor, $stateObject)
|
501 |
+
->_updateOrderState($stateObject)
|
502 |
+
->_processChildTransactions($transactionProcessor, $stateObject)
|
503 |
+
->_processParentTransactions($transactionProcessor, $stateObject);
|
504 |
+
}
|
505 |
+
}
|
506 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Processor/Payment.php
CHANGED
@@ -1,206 +1,224 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Processor_Payment
|
|
|
17 |
|
18 |
/**
|
19 |
-
*
|
20 |
*
|
21 |
-
* @var null
|
22 |
*/
|
23 |
protected $_payment = null;
|
24 |
|
25 |
/**
|
26 |
-
*
|
27 |
*
|
28 |
-
* @var null
|
29 |
*/
|
30 |
-
protected $
|
31 |
|
32 |
/**
|
33 |
-
*
|
34 |
*
|
35 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
*
|
37 |
-
* @
|
|
|
38 |
*/
|
39 |
-
|
40 |
-
|
41 |
-
$this->
|
42 |
-
return $this;
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
*
|
|
|
47 |
* @return Mage_Sales_Model_Order_Payment
|
48 |
* @throws Creativestyle_AmazonPayments_Exception
|
49 |
*/
|
50 |
-
public function getPayment()
|
|
|
51 |
if (null === $this->_payment) {
|
52 |
-
throw new Creativestyle_AmazonPayments_Exception('Payment object is not set');
|
53 |
}
|
|
|
54 |
return $this->_payment;
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
-
*
|
59 |
*
|
60 |
-
* @
|
|
|
61 |
*/
|
62 |
-
|
63 |
-
|
|
|
|
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
-
*
|
68 |
*
|
69 |
-
* @return
|
70 |
*/
|
71 |
-
|
72 |
-
|
|
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
-
*
|
77 |
*
|
78 |
-
* @param
|
79 |
-
* @
|
80 |
-
*
|
81 |
-
* @return Varien_Object
|
82 |
*/
|
83 |
-
|
84 |
-
|
85 |
-
$
|
86 |
-
|
87 |
-
->setTransactionDetails($transactionDetails);
|
88 |
-
return $transactionAdapter;
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
-
*
|
93 |
-
*
|
94 |
-
* @param
|
95 |
-
* @param
|
|
|
|
|
96 |
*/
|
97 |
-
public function
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
* Authorize order amount on Amazon Payments gateway
|
113 |
*
|
114 |
-
* @param
|
115 |
-
* @param
|
116 |
-
* @param
|
117 |
-
* @param
|
118 |
-
* @param
|
119 |
-
*
|
120 |
* @return OffAmazonPaymentsService_Model_AuthorizationDetails
|
121 |
*/
|
122 |
-
public function authorize(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
return $this->_getApi()->authorize(
|
124 |
-
$parentTransactionId,
|
125 |
-
$transactionSequenceId,
|
126 |
$amount,
|
127 |
-
$
|
128 |
-
|
|
|
|
|
129 |
$captureNow,
|
130 |
-
$
|
131 |
);
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
* Capture order amount on Amazon Payments gateway
|
136 |
*
|
137 |
-
* @param
|
138 |
-
* @param
|
139 |
-
* @param
|
140 |
-
*
|
141 |
-
* @return
|
142 |
*/
|
143 |
-
public function capture($amount, $
|
|
|
144 |
return $this->_getApi()->capture(
|
145 |
-
$parentTransactionId,
|
146 |
-
$transactionSequenceId,
|
147 |
$amount,
|
148 |
-
$
|
149 |
-
|
|
|
|
|
150 |
);
|
151 |
}
|
152 |
|
153 |
/**
|
154 |
* Refund amount on Amazon Payments gateway
|
155 |
*
|
156 |
-
* @param
|
157 |
-
* @param
|
158 |
-
* @param
|
159 |
-
*
|
160 |
-
* @return
|
161 |
*/
|
162 |
-
public function refund($amount, $
|
|
|
163 |
return $this->_getApi()->refund(
|
164 |
-
$parentTransactionId,
|
165 |
-
$transactionSequenceId,
|
166 |
$amount,
|
167 |
-
$
|
168 |
-
|
|
|
|
|
169 |
);
|
170 |
}
|
171 |
|
172 |
-
/**
|
173 |
-
* Public wrapper for _importTransactionDetails() method
|
174 |
-
*
|
175 |
-
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
176 |
-
* @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
|
177 |
-
*
|
178 |
-
* @return Varien_Object
|
179 |
-
*/
|
180 |
-
public function importTransactionDetails($transaction, $transactionDetails = null) {
|
181 |
-
return $this->_importTransactionDetails($transaction, $transactionDetails);
|
182 |
-
}
|
183 |
-
|
184 |
/**
|
185 |
* Cancel order reference on Amazon Payments gateway
|
186 |
*/
|
187 |
-
public function cancelOrderReference()
|
188 |
-
|
|
|
|
|
189 |
if ($orderTransaction && !$orderTransaction->getIsClosed()) {
|
190 |
$this->_getApi()->cancelOrderReference($orderTransaction->getTxnId());
|
191 |
$orderTransaction->setIsClosed(true)->save();
|
192 |
}
|
193 |
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* [closeOrderReference description]
|
197 |
-
*/
|
198 |
-
public function closeOrderReference() {
|
199 |
-
$orderTransaction = $this->getPayment()->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
|
200 |
-
if ($orderTransaction && !$orderTransaction->getIsClosed()) {
|
201 |
-
$this->_getApi()->closeOrderReference($orderTransaction->getTxnId());
|
202 |
-
$orderTransaction->setIsClosed(true)->save();
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2015 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2015 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Processor_Payment
|
18 |
+
{
|
19 |
|
20 |
/**
|
21 |
+
* Payment info instance
|
22 |
*
|
23 |
+
* @var Mage_Sales_Model_Order_Payment|null
|
24 |
*/
|
25 |
protected $_payment = null;
|
26 |
|
27 |
/**
|
28 |
+
* Payment store ID
|
29 |
*
|
30 |
+
* @var int|null
|
31 |
*/
|
32 |
+
protected $_storeId = null;
|
33 |
|
34 |
/**
|
35 |
+
* Returns API adapter instance
|
36 |
*
|
37 |
+
* @return Creativestyle_AmazonPayments_Model_Api_Advanced
|
38 |
+
*/
|
39 |
+
protected function _getApi()
|
40 |
+
{
|
41 |
+
return Mage::getSingleton('amazonpayments/api_advanced')->setStore($this->getStoreId());
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Process transaction simulation request
|
46 |
*
|
47 |
+
* @param string $transactionType
|
48 |
+
* @return string
|
49 |
*/
|
50 |
+
protected function _processTransactionStateSimulation($transactionType)
|
51 |
+
{
|
52 |
+
return Creativestyle_AmazonPayments_Model_Simulator::simulate($this->getPayment(), $transactionType);
|
|
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
+
* Returns payment info instance
|
57 |
+
*
|
58 |
* @return Mage_Sales_Model_Order_Payment
|
59 |
* @throws Creativestyle_AmazonPayments_Exception
|
60 |
*/
|
61 |
+
public function getPayment()
|
62 |
+
{
|
63 |
if (null === $this->_payment) {
|
64 |
+
throw new Creativestyle_AmazonPayments_Exception('Payment info object is not set');
|
65 |
}
|
66 |
+
|
67 |
return $this->_payment;
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* Sets payment info instance for the processing
|
72 |
*
|
73 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
74 |
+
* @return $this
|
75 |
*/
|
76 |
+
public function setPayment(Mage_Sales_Model_Order_Payment $payment)
|
77 |
+
{
|
78 |
+
$this->_payment = $payment;
|
79 |
+
return $this;
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* Returns order's store ID
|
84 |
*
|
85 |
+
* @return int|null
|
86 |
*/
|
87 |
+
public function getStoreId()
|
88 |
+
{
|
89 |
+
return $this->_storeId;
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* Sets store ID for processing payment
|
94 |
*
|
95 |
+
* @param int $storeId
|
96 |
+
* @return $this
|
|
|
|
|
97 |
*/
|
98 |
+
public function setStoreId($storeId)
|
99 |
+
{
|
100 |
+
$this->_storeId = $storeId;
|
101 |
+
return $this;
|
|
|
|
|
102 |
}
|
103 |
|
104 |
/**
|
105 |
+
* @param float $amount
|
106 |
+
* @param string $currency
|
107 |
+
* @param string $transactionReferenceId
|
108 |
+
* @param string $orderId
|
109 |
+
* @param string|null $storeName
|
110 |
+
* @return OffAmazonPaymentsService_Model_OrderReferenceDetails
|
111 |
*/
|
112 |
+
public function setOrderDetails($amount, $currency, $transactionReferenceId, $orderId, $storeName = null)
|
113 |
+
{
|
114 |
+
$transactionDetails = $this->_getApi()->setOrderReferenceDetails(
|
115 |
+
$amount,
|
116 |
+
$currency,
|
117 |
+
$transactionReferenceId,
|
118 |
+
$orderId,
|
119 |
+
$storeName
|
120 |
+
);
|
121 |
+
return $transactionDetails;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @param string $transactionReferenceId
|
126 |
+
*/
|
127 |
+
public function order($transactionReferenceId)
|
128 |
+
{
|
129 |
+
$this->_getApi()->confirmOrderReference($transactionReferenceId);
|
130 |
+
$this->_processTransactionStateSimulation('OrderReference');
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @param string $transactionId
|
135 |
+
* @param string|null $closureReason
|
136 |
+
*/
|
137 |
+
public function closeOrderReference($transactionId, $closureReason = null)
|
138 |
+
{
|
139 |
+
$this->_getApi()->closeOrderReference($transactionId, $closureReason);
|
140 |
}
|
141 |
|
142 |
/**
|
143 |
* Authorize order amount on Amazon Payments gateway
|
144 |
*
|
145 |
+
* @param float $amount
|
146 |
+
* @param string $currency
|
147 |
+
* @param string $transactionReferenceId
|
148 |
+
* @param string $parentTransactionId
|
149 |
+
* @param bool $isSync
|
150 |
+
* @param bool $captureNow
|
151 |
* @return OffAmazonPaymentsService_Model_AuthorizationDetails
|
152 |
*/
|
153 |
+
public function authorize(
|
154 |
+
$amount,
|
155 |
+
$currency,
|
156 |
+
$transactionReferenceId,
|
157 |
+
$parentTransactionId,
|
158 |
+
$isSync = true,
|
159 |
+
$captureNow = false
|
160 |
+
) {
|
161 |
return $this->_getApi()->authorize(
|
|
|
|
|
162 |
$amount,
|
163 |
+
$currency,
|
164 |
+
$transactionReferenceId,
|
165 |
+
$parentTransactionId,
|
166 |
+
$isSync ? 0 : null,
|
167 |
$captureNow,
|
168 |
+
$this->_processTransactionStateSimulation('Authorization')
|
169 |
);
|
170 |
}
|
171 |
|
172 |
/**
|
173 |
* Capture order amount on Amazon Payments gateway
|
174 |
*
|
175 |
+
* @param float $amount
|
176 |
+
* @param string $currency
|
177 |
+
* @param string $transactionReferenceId
|
178 |
+
* @param string $parentTransactionId
|
179 |
+
* @return OffAmazonPaymentsService_Model_CaptureDetails
|
180 |
*/
|
181 |
+
public function capture($amount, $currency, $transactionReferenceId, $parentTransactionId)
|
182 |
+
{
|
183 |
return $this->_getApi()->capture(
|
|
|
|
|
184 |
$amount,
|
185 |
+
$currency,
|
186 |
+
$transactionReferenceId,
|
187 |
+
$parentTransactionId,
|
188 |
+
$this->_processTransactionStateSimulation('Capture')
|
189 |
);
|
190 |
}
|
191 |
|
192 |
/**
|
193 |
* Refund amount on Amazon Payments gateway
|
194 |
*
|
195 |
+
* @param float $amount
|
196 |
+
* @param string $currency
|
197 |
+
* @param string $transactionReferenceId
|
198 |
+
* @param string $parentTransactionId
|
199 |
+
* @return OffAmazonPaymentsService_Model_RefundDetails
|
200 |
*/
|
201 |
+
public function refund($amount, $currency, $transactionReferenceId, $parentTransactionId)
|
202 |
+
{
|
203 |
return $this->_getApi()->refund(
|
|
|
|
|
204 |
$amount,
|
205 |
+
$currency,
|
206 |
+
$transactionReferenceId,
|
207 |
+
$parentTransactionId,
|
208 |
+
$this->_processTransactionStateSimulation('Refund')
|
209 |
);
|
210 |
}
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
/**
|
213 |
* Cancel order reference on Amazon Payments gateway
|
214 |
*/
|
215 |
+
public function cancelOrderReference()
|
216 |
+
{
|
217 |
+
$orderTransaction = $this->getPayment()
|
218 |
+
->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
|
219 |
if ($orderTransaction && !$orderTransaction->getIsClosed()) {
|
220 |
$this->_getApi()->cancelOrderReference($orderTransaction->getTxnId());
|
221 |
$orderTransaction->setIsClosed(true)->save();
|
222 |
}
|
223 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Processor/Transaction.php
ADDED
@@ -0,0 +1,922 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Processor_Transaction
|
18 |
+
{
|
19 |
+
const TRANSACTION_TYPE_ORDER = 'OrderReference';
|
20 |
+
const TRANSACTION_TYPE_AUTH = 'Authorization';
|
21 |
+
const TRANSACTION_TYPE_CAPTURE = 'Capture';
|
22 |
+
const TRANSACTION_TYPE_REFUND = 'Refund';
|
23 |
+
|
24 |
+
const TRANSACTION_STATE_KEY = 'State';
|
25 |
+
const TRANSACTION_REASON_CODE_KEY = 'ReasonCode';
|
26 |
+
const TRANSACTION_REASON_DESCRIPTION_KEY = 'ReasonDescription';
|
27 |
+
const TRANSACTION_ORDER_LANGUAGE_KEY = 'Language';
|
28 |
+
|
29 |
+
const TRANSACTION_STATE_DRAFT = 'Draft';
|
30 |
+
const TRANSACTION_STATE_PENDING = 'Pending';
|
31 |
+
const TRANSACTION_STATE_OPEN = 'Open';
|
32 |
+
const TRANSACTION_STATE_SUSPENDED = 'Suspended';
|
33 |
+
const TRANSACTION_STATE_DECLINED = 'Declined';
|
34 |
+
const TRANSACTION_STATE_COMPLETED = 'Completed';
|
35 |
+
const TRANSACTION_STATE_CANCELED = 'Canceled';
|
36 |
+
const TRANSACTION_STATE_CLOSED = 'Closed';
|
37 |
+
|
38 |
+
const TRANSACTION_REASON_INVALID_PAYMENT = 'InvalidPaymentMethod';
|
39 |
+
const TRANSACTION_REASON_TIMEOUT = 'TransactionTimedOut';
|
40 |
+
const TRANSACTION_REASON_AMAZON_REJECTED = 'AmazonRejected';
|
41 |
+
const TRANSACTION_REASON_AMAZON_CLOSED = 'AmazonClosed';
|
42 |
+
const TRANSACTION_REASON_EXPIRED_UNUSED = 'ExpiredUnused';
|
43 |
+
const TRANSACTION_REASON_PROCESSING_FAILURE = 'ProcessingFailure';
|
44 |
+
const TRANSACTION_REASON_MAX_CAPTURES = 'MaxCapturesProcessed';
|
45 |
+
|
46 |
+
const EMAIL_TYPE_NEW_ORDER = 'new_order';
|
47 |
+
const EMAIL_TYPE_AUTH_DECLINED = 'auth_declined';
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @var Mage_Sales_Model_Order_Payment_Transaction|null
|
51 |
+
*/
|
52 |
+
protected $_transaction = null;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @var OffAmazonPaymentsService_Model|OffAmazonPayments_Model|null
|
56 |
+
*/
|
57 |
+
protected $_transactionDetails = null;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Returns Amazon Pay API adapter instance
|
61 |
+
*
|
62 |
+
* @return Creativestyle_AmazonPayments_Model_Api_Advanced
|
63 |
+
*/
|
64 |
+
protected function _getApi()
|
65 |
+
{
|
66 |
+
return Mage::getSingleton('amazonpayments/api_advanced')->setStore($this->_getStoreId());
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Returns Amazon Pay helper
|
71 |
+
*
|
72 |
+
* @return Creativestyle_AmazonPayments_Helper_Data
|
73 |
+
*/
|
74 |
+
protected function _getHelper()
|
75 |
+
{
|
76 |
+
return Mage::helper('amazonpayments');
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @param string $amount
|
81 |
+
* @return string|null
|
82 |
+
*/
|
83 |
+
protected function _formatAmount($amount = null)
|
84 |
+
{
|
85 |
+
return $amount ? $this->getTransaction()->getOrder()->getBaseCurrency()->formatTxt($amount) : null;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Returns order's store ID
|
90 |
+
*
|
91 |
+
* @return int
|
92 |
+
*/
|
93 |
+
protected function _getStoreId()
|
94 |
+
{
|
95 |
+
return $this->getTransaction()->getOrder()->getStoreId();
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Returns Magento transaction type
|
100 |
+
*
|
101 |
+
* @return string
|
102 |
+
*/
|
103 |
+
protected function _getMagentoTransactionType()
|
104 |
+
{
|
105 |
+
return $this->getTransaction()->getTxnType();
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @return int
|
110 |
+
*/
|
111 |
+
protected function _getTransactionAgeInDays()
|
112 |
+
{
|
113 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
114 |
+
$dateModel = Mage::getModel('core/date');
|
115 |
+
$txnAge = ($dateModel->timestamp() - $dateModel->timestamp($this->getTransaction()->getCreatedAt()))
|
116 |
+
/ (60 * 60 * 24);
|
117 |
+
return (int)floor($txnAge);
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Returns Magento transaction additional information
|
122 |
+
*
|
123 |
+
* @param string|null $key
|
124 |
+
* @return array|null|string
|
125 |
+
*/
|
126 |
+
protected function _getMagentoTransactionAdditionalInformation($key = null)
|
127 |
+
{
|
128 |
+
$additionalInformation = $this->getTransaction()
|
129 |
+
->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
|
130 |
+
if (null !== $key) {
|
131 |
+
if (is_array($additionalInformation) && array_key_exists($key, $additionalInformation)) {
|
132 |
+
return $additionalInformation[$key];
|
133 |
+
}
|
134 |
+
|
135 |
+
return null;
|
136 |
+
}
|
137 |
+
|
138 |
+
return $additionalInformation;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Returns transaction details
|
143 |
+
*
|
144 |
+
* Returns details for the transaction, if not set then retrieves
|
145 |
+
* the details from Amazon Payments API.
|
146 |
+
*
|
147 |
+
* @return OffAmazonPayments_Model|OffAmazonPaymentsService_Model|null
|
148 |
+
*/
|
149 |
+
protected function _getAmazonTransactionDetails()
|
150 |
+
{
|
151 |
+
if (null == $this->_transactionDetails) {
|
152 |
+
$this->setTransactionDetails($this->_fetchTransactionDetails());
|
153 |
+
}
|
154 |
+
|
155 |
+
return $this->_transactionDetails;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* @return OffAmazonPaymentsService_Model_Status|null
|
160 |
+
*/
|
161 |
+
protected function _getAmazonTransactionStatus()
|
162 |
+
{
|
163 |
+
// @codingStandardsIgnoreStart
|
164 |
+
return call_user_func(
|
165 |
+
array(
|
166 |
+
$this->_getAmazonTransactionDetails(),
|
167 |
+
'isSet' . $this->getTransactionType() . 'Status')
|
168 |
+
)
|
169 |
+
? call_user_func(
|
170 |
+
array(
|
171 |
+
$this->_getAmazonTransactionDetails(),
|
172 |
+
'get' . $this->getTransactionType() . 'Status')
|
173 |
+
)
|
174 |
+
: null;
|
175 |
+
// @codingStandardsIgnoreEnd
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* @return OffAmazonPaymentsService_Model_Buyer|null
|
180 |
+
*/
|
181 |
+
protected function _getAmazonBuyer()
|
182 |
+
{
|
183 |
+
return is_callable(array($this->_getAmazonTransactionDetails(), 'isSetBuyer'))
|
184 |
+
&& $this->_getAmazonTransactionDetails()->isSetBuyer()
|
185 |
+
? $this->_getAmazonTransactionDetails()->getBuyer()
|
186 |
+
: null;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* @return OffAmazonPaymentsService_Model_Address|null
|
191 |
+
*/
|
192 |
+
protected function _getAmazonBillingAddress()
|
193 |
+
{
|
194 |
+
$transactionDetails = $this->_getAmazonTransactionDetails();
|
195 |
+
if (is_callable(array($transactionDetails, 'isSetBillingAddress'))) {
|
196 |
+
/** @var OffAmazonPaymentsService_Model_OrderReferenceDetails $transactionDetails */
|
197 |
+
if ($transactionDetails->isSetBillingAddress()) {
|
198 |
+
/** @var OffAmazonPaymentsService_Model_BillingAddress $billingAddress */
|
199 |
+
$billingAddress = $transactionDetails->getBillingAddress();
|
200 |
+
if (is_callable(array($billingAddress, 'isSetPhysicalAddress'))) {
|
201 |
+
if ($billingAddress->isSetPhysicalAddress()) {
|
202 |
+
return $billingAddress->getPhysicalAddress();
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
206 |
+
} elseif (is_callable(array($transactionDetails, 'isSetAuthorizationBillingAddress'))) {
|
207 |
+
/** @var OffAmazonPaymentsService_Model_AuthorizationDetails $transactionDetails */
|
208 |
+
if ($transactionDetails->isSetAuthorizationBillingAddress()) {
|
209 |
+
return $transactionDetails->getAuthorizationBillingAddress();
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
return null;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* @return OffAmazonPaymentsService_Model_Address|null
|
218 |
+
*/
|
219 |
+
protected function _getAmazonShippingAddress()
|
220 |
+
{
|
221 |
+
$transactionDetails = $this->_getAmazonTransactionDetails();
|
222 |
+
if (is_callable(array($transactionDetails, 'isSetDestination'))) {
|
223 |
+
/** @var OffAmazonPaymentsService_Model_OrderReferenceDetails $transactionDetails */
|
224 |
+
if ($transactionDetails->isSetDestination()) {
|
225 |
+
/** @var OffAmazonPaymentsService_Model_Destination $destination */
|
226 |
+
$destination = $transactionDetails->getDestination();
|
227 |
+
if (is_callable(array($destination, 'isSetPhysicalDestination'))) {
|
228 |
+
if ($destination->isSetPhysicalDestination()) {
|
229 |
+
return $destination->getPhysicalDestination();
|
230 |
+
}
|
231 |
+
}
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
return null;
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* @return array|null
|
240 |
+
*/
|
241 |
+
protected function _getAmazonIdList()
|
242 |
+
{
|
243 |
+
$transactionDetails = $this->_getAmazonTransactionDetails();
|
244 |
+
if (is_callable(array($transactionDetails, 'isSetIdList'))) {
|
245 |
+
if ($transactionDetails->isSetIdList()) {
|
246 |
+
/** @var OffAmazonPaymentsService_Model_IdList $idList */
|
247 |
+
$idList = $transactionDetails->getIdList();
|
248 |
+
if (is_callable(array($idList, 'isSetmember'))) {
|
249 |
+
if ($idList->isSetmember()) {
|
250 |
+
return $idList->getmember();
|
251 |
+
}
|
252 |
+
} elseif (is_callable(array($idList, 'isSetId'))) {
|
253 |
+
if ($idList->isSetId()) {
|
254 |
+
return $idList->getId();
|
255 |
+
}
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
return null;
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Extracts city name from given Amazon Pay address object
|
265 |
+
*
|
266 |
+
* @param OffAmazonPaymentsService_Model_Address|null $address
|
267 |
+
* @return string|null
|
268 |
+
*/
|
269 |
+
protected function _extractCityFromAmazonAddress($address = null)
|
270 |
+
{
|
271 |
+
return $address && $address->isSetCity()
|
272 |
+
? $address->getCity() : null;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Extracts country code from given Amazon Pay address object
|
277 |
+
*
|
278 |
+
* @param OffAmazonPaymentsService_Model_Address|null $address
|
279 |
+
* @return string|null
|
280 |
+
*/
|
281 |
+
protected function _extractCountryCodeFromAmazonAddress($address = null)
|
282 |
+
{
|
283 |
+
return $address && $address->isSetCountryCode()
|
284 |
+
? $address->getCountryCode() : null;
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Extracts customer name from given Amazon Pay address object
|
289 |
+
*
|
290 |
+
* @param OffAmazonPaymentsService_Model_Address|null $address
|
291 |
+
* @return Varien_Object
|
292 |
+
*/
|
293 |
+
protected function _extractCustomerNameFromAmazonAddress($address = null)
|
294 |
+
{
|
295 |
+
return $address && $address->isSetName()
|
296 |
+
? $this->_getHelper()->explodeCustomerName($address->getName(), null) : null;
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Extracts address lines from given Amazon Pay address object
|
301 |
+
*
|
302 |
+
* @param OffAmazonPaymentsService_Model_Address|null $address
|
303 |
+
* @return array|null
|
304 |
+
*/
|
305 |
+
protected function _extractLinesFromAmazonAddress($address = null)
|
306 |
+
{
|
307 |
+
if ($address) {
|
308 |
+
return array(
|
309 |
+
$address->isSetAddressLine1() ? $address->getAddressLine1() : null,
|
310 |
+
$address->isSetAddressLine2() ? $address->getAddressLine2() : null,
|
311 |
+
$address->isSetAddressLine3() ? $address->getAddressLine3() : null,
|
312 |
+
);
|
313 |
+
}
|
314 |
+
|
315 |
+
return null;
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Extracts phone from given Amazon Pay address object
|
320 |
+
*
|
321 |
+
* @param OffAmazonPaymentsService_Model_Address|null $address
|
322 |
+
* @return string|null
|
323 |
+
*/
|
324 |
+
protected function _extractPhoneFromAmazonAddress($address = null)
|
325 |
+
{
|
326 |
+
return $address && $address->isSetPhone()
|
327 |
+
? $address->getPhone() : null;
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Extracts postal code from given Amazon Pay address object
|
332 |
+
*
|
333 |
+
* @param OffAmazonPaymentsService_Model_Address|null $address
|
334 |
+
* @return string|null
|
335 |
+
*/
|
336 |
+
protected function _extractPostalCodeFromAmazonAddress($address = null)
|
337 |
+
{
|
338 |
+
return $address && $address->isSetPostalCode()
|
339 |
+
? $address->getPostalCode() : null;
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Retrieve transaction details from Amazon Payments API
|
344 |
+
*
|
345 |
+
* Retrieves details for provided Magento transaction object using
|
346 |
+
* Amazon Payments API client. Before making a call, identifies the
|
347 |
+
* type of provided transaction type by using appropriate function.
|
348 |
+
*
|
349 |
+
* @return OffAmazonPayments_Model|null
|
350 |
+
*/
|
351 |
+
protected function _fetchTransactionDetails()
|
352 |
+
{
|
353 |
+
// @codingStandardsIgnoreStart
|
354 |
+
return call_user_func(
|
355 |
+
array($this->_getApi(), 'get' . $this->getTransactionType() . 'Details'),
|
356 |
+
$this->getTransactionId()
|
357 |
+
);
|
358 |
+
// @codingStandardsIgnoreEnd
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Returns Amazon to Magento transaction data mapper
|
363 |
+
*
|
364 |
+
* @return Creativestyle_AmazonPayments_Model_Processor_Transaction_DataMapper
|
365 |
+
*/
|
366 |
+
public function getDataMapper()
|
367 |
+
{
|
368 |
+
return Mage::getSingleton('amazonpayments/processor_transaction_dataMapper');
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Sets previously fetched transaction details
|
373 |
+
*
|
374 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
375 |
+
* @return $this
|
376 |
+
*/
|
377 |
+
public function setTransaction($transaction)
|
378 |
+
{
|
379 |
+
$this->_transaction = $transaction;
|
380 |
+
return $this;
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Returns transaction instance
|
385 |
+
*
|
386 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction
|
387 |
+
* @throws Creativestyle_AmazonPayments_Exception
|
388 |
+
*/
|
389 |
+
public function getTransaction()
|
390 |
+
{
|
391 |
+
if (null === $this->_transaction) {
|
392 |
+
throw new Creativestyle_AmazonPayments_Exception('Transaction object is not set');
|
393 |
+
}
|
394 |
+
|
395 |
+
return $this->_transaction;
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Sets previously fetched transaction details
|
400 |
+
*
|
401 |
+
* @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
|
402 |
+
* @return $this
|
403 |
+
*/
|
404 |
+
public function setTransactionDetails($transactionDetails)
|
405 |
+
{
|
406 |
+
$this->_transactionDetails = $transactionDetails;
|
407 |
+
return $this;
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Returns transaction ID
|
412 |
+
*
|
413 |
+
* @return string
|
414 |
+
*/
|
415 |
+
public function getTransactionId()
|
416 |
+
{
|
417 |
+
return $this->getTransaction()->getTxnId();
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* Returns Amazon Pay-specific name for Magento transaction type
|
422 |
+
*
|
423 |
+
* Checks the type of provided payment transaction object and
|
424 |
+
* returns its corresponding Amazon transaction name. Returns
|
425 |
+
* null if type of provided transaction object is neither
|
426 |
+
* recognized nor has an Amazon Pay equivalent.
|
427 |
+
*
|
428 |
+
* @return string|null
|
429 |
+
*/
|
430 |
+
public function getTransactionType()
|
431 |
+
{
|
432 |
+
return $this->getDataMapper()->getAmazonTransactionType($this->_getMagentoTransactionType());
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* @return string|null
|
437 |
+
*/
|
438 |
+
public function getTransactionState()
|
439 |
+
{
|
440 |
+
$transactionStatus = $this->_getAmazonTransactionStatus();
|
441 |
+
return $transactionStatus ? $transactionStatus->getState() : null;
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* @return string|null
|
446 |
+
*/
|
447 |
+
public function getTransactionReasonCode()
|
448 |
+
{
|
449 |
+
$transactionStatus = $this->_getAmazonTransactionStatus();
|
450 |
+
return $transactionStatus && $transactionStatus->isSetReasonCode()
|
451 |
+
? $transactionStatus->getReasonCode() : null;
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* @return string|null
|
456 |
+
*/
|
457 |
+
public function getTransactionReasonDescription()
|
458 |
+
{
|
459 |
+
$transactionStatus = $this->_getAmazonTransactionStatus();
|
460 |
+
return $transactionStatus && $transactionStatus->isSetReasonDescription()
|
461 |
+
? $transactionStatus->getReasonDescription() : null;
|
462 |
+
}
|
463 |
+
|
464 |
+
/**
|
465 |
+
* @return string|null
|
466 |
+
*/
|
467 |
+
public function getTransactionOrderLanguage()
|
468 |
+
{
|
469 |
+
$transactionDetails = $this->_getAmazonTransactionDetails();
|
470 |
+
return $transactionDetails
|
471 |
+
&& is_callable(array($transactionDetails, 'isSetOrderLanguage'))
|
472 |
+
&& $transactionDetails->isSetOrderLanguage()
|
473 |
+
? $transactionDetails->getOrderLanguage() : null;
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Returns transaction amount
|
478 |
+
*
|
479 |
+
* @return string|null
|
480 |
+
*/
|
481 |
+
public function getTransactionAmount()
|
482 |
+
{
|
483 |
+
$transactionDetails = $this->_getAmazonTransactionDetails();
|
484 |
+
if (is_callable(array($transactionDetails, 'get' . $this->getTransactionType() . 'Amount'))) {
|
485 |
+
// @codingStandardsIgnoreStart
|
486 |
+
/** @var OffAmazonPaymentsService_Model_Price $transactionAmount */
|
487 |
+
$transactionAmount = call_user_func(
|
488 |
+
array(
|
489 |
+
$transactionDetails,
|
490 |
+
'get' . $this->getTransactionType() . 'Amount'
|
491 |
+
)
|
492 |
+
);
|
493 |
+
// @codingStandardsIgnoreEnd
|
494 |
+
return $transactionAmount->getAmount();
|
495 |
+
}
|
496 |
+
|
497 |
+
if (is_callable(array($transactionDetails, 'getOrderTotal'))) {
|
498 |
+
/** @var OffAmazonPaymentsService_Model_OrderTotal $transactionAmount */
|
499 |
+
$transactionAmount = $transactionDetails->getOrderTotal();
|
500 |
+
return $transactionAmount->getAmount();
|
501 |
+
}
|
502 |
+
|
503 |
+
return null;
|
504 |
+
}
|
505 |
+
|
506 |
+
/**
|
507 |
+
* Returns transaction amount
|
508 |
+
*
|
509 |
+
* @return string|null
|
510 |
+
*/
|
511 |
+
public function getFormattedTransactionAmount()
|
512 |
+
{
|
513 |
+
return $this->_formatAmount($this->getTransactionAmount());
|
514 |
+
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* @return array|null
|
518 |
+
*/
|
519 |
+
public function getChildrenIds()
|
520 |
+
{
|
521 |
+
return $this->_getAmazonIdList();
|
522 |
+
}
|
523 |
+
|
524 |
+
/**
|
525 |
+
* @return string|null
|
526 |
+
*/
|
527 |
+
public function getCustomerEmail()
|
528 |
+
{
|
529 |
+
$buyer = $this->_getAmazonBuyer();
|
530 |
+
return $buyer && $buyer->isSetEmail()
|
531 |
+
? $buyer->getEmail() : null;
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* @return Varien_Object|null
|
536 |
+
*/
|
537 |
+
public function getCustomerName()
|
538 |
+
{
|
539 |
+
if ($customerName = $this->_extractCustomerNameFromAmazonAddress($this->_getAmazonBillingAddress())) {
|
540 |
+
return $customerName;
|
541 |
+
}
|
542 |
+
|
543 |
+
$buyer = $this->_getAmazonBuyer();
|
544 |
+
return $buyer && $buyer->isSetName()
|
545 |
+
? $this->_getHelper()->explodeCustomerName($buyer->getName(), null) : null;
|
546 |
+
}
|
547 |
+
|
548 |
+
/**
|
549 |
+
* @return string|null
|
550 |
+
*/
|
551 |
+
public function getCustomerFirstname()
|
552 |
+
{
|
553 |
+
$customerName = $this->getCustomerName();
|
554 |
+
return $customerName ? $customerName->getFirstname() : null;
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* @return string|null
|
559 |
+
*/
|
560 |
+
public function getCustomerLastname()
|
561 |
+
{
|
562 |
+
$customerName = $this->getCustomerName();
|
563 |
+
return $customerName ? $customerName->getLastname() : null;
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* Returns customer first name for billing address
|
568 |
+
*
|
569 |
+
* @return string|null
|
570 |
+
*/
|
571 |
+
public function getBillingAddressFirstname()
|
572 |
+
{
|
573 |
+
$customerName = $this->_extractCustomerNameFromAmazonAddress($this->_getAmazonBillingAddress());
|
574 |
+
return $customerName ? $customerName->getFirstname() : null;
|
575 |
+
}
|
576 |
+
|
577 |
+
/**
|
578 |
+
* Returns customer last name for billing address
|
579 |
+
*
|
580 |
+
* @return string|null
|
581 |
+
*/
|
582 |
+
public function getBillingAddressLastname()
|
583 |
+
{
|
584 |
+
$customerName = $this->_extractCustomerNameFromAmazonAddress($this->_getAmazonBillingAddress());
|
585 |
+
return $customerName ? $customerName->getLastname() : null;
|
586 |
+
}
|
587 |
+
|
588 |
+
/**
|
589 |
+
* Returns billing address street lines
|
590 |
+
*
|
591 |
+
* @return array|null
|
592 |
+
*/
|
593 |
+
public function getBillingAddressLines()
|
594 |
+
{
|
595 |
+
return $this->_extractLinesFromAmazonAddress($this->_getAmazonBillingAddress());
|
596 |
+
}
|
597 |
+
|
598 |
+
/**
|
599 |
+
* Returns billing address city
|
600 |
+
*
|
601 |
+
* @return string|null
|
602 |
+
*/
|
603 |
+
public function getBillingAddressCity()
|
604 |
+
{
|
605 |
+
return $this->_extractCityFromAmazonAddress($this->_getAmazonBillingAddress());
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* Returns billing address postal code
|
610 |
+
*
|
611 |
+
* @return string|null
|
612 |
+
*/
|
613 |
+
public function getBillingAddressPostalCode()
|
614 |
+
{
|
615 |
+
return $this->_extractPostalCodeFromAmazonAddress($this->_getAmazonBillingAddress());
|
616 |
+
}
|
617 |
+
|
618 |
+
/**
|
619 |
+
* Returns billing address country code
|
620 |
+
*
|
621 |
+
* @return string|null
|
622 |
+
*/
|
623 |
+
public function getBillingAddressCountryCode()
|
624 |
+
{
|
625 |
+
return $this->_extractCountryCodeFromAmazonAddress($this->_getAmazonBillingAddress());
|
626 |
+
}
|
627 |
+
|
628 |
+
/**
|
629 |
+
* Returns customer phone for billing address
|
630 |
+
*
|
631 |
+
* @return string|null
|
632 |
+
*/
|
633 |
+
public function getBillingAddressPhone()
|
634 |
+
{
|
635 |
+
return $this->_extractPhoneFromAmazonAddress($this->_getAmazonBillingAddress());
|
636 |
+
}
|
637 |
+
|
638 |
+
/**
|
639 |
+
* Returns customer first name for shipping address
|
640 |
+
*
|
641 |
+
* @return string|null
|
642 |
+
*/
|
643 |
+
public function getShippingAddressFirstname()
|
644 |
+
{
|
645 |
+
$customerName = $this->_extractCustomerNameFromAmazonAddress($this->_getAmazonShippingAddress());
|
646 |
+
return $customerName ? $customerName->getData('firstname') : null;
|
647 |
+
}
|
648 |
+
|
649 |
+
/**
|
650 |
+
* Returns customer last name for shipping address
|
651 |
+
*
|
652 |
+
* @return string|null
|
653 |
+
*/
|
654 |
+
public function getShippingAddressLastname()
|
655 |
+
{
|
656 |
+
$customerName = $this->_extractCustomerNameFromAmazonAddress($this->_getAmazonShippingAddress());
|
657 |
+
return $customerName ? $customerName->getData('lastname') : null;
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Returns shipping address street lines
|
662 |
+
*
|
663 |
+
* @return array|null
|
664 |
+
*/
|
665 |
+
public function getShippingAddressLines()
|
666 |
+
{
|
667 |
+
return $this->_extractLinesFromAmazonAddress($this->_getAmazonShippingAddress());
|
668 |
+
}
|
669 |
+
|
670 |
+
/**
|
671 |
+
* Returns shipping address city
|
672 |
+
*
|
673 |
+
* @return string|null
|
674 |
+
*/
|
675 |
+
public function getShippingAddressCity()
|
676 |
+
{
|
677 |
+
return $this->_extractCityFromAmazonAddress($this->_getAmazonShippingAddress());
|
678 |
+
}
|
679 |
+
|
680 |
+
/**
|
681 |
+
* Returns shipping address postal code
|
682 |
+
*
|
683 |
+
* @return string|null
|
684 |
+
*/
|
685 |
+
public function getShippingAddressPostalCode()
|
686 |
+
{
|
687 |
+
return $this->_extractPostalCodeFromAmazonAddress($this->_getAmazonShippingAddress());
|
688 |
+
}
|
689 |
+
|
690 |
+
/**
|
691 |
+
* Returns shipping address country code
|
692 |
+
*
|
693 |
+
* @return string|null
|
694 |
+
*/
|
695 |
+
public function getShippingAddressCountryCode()
|
696 |
+
{
|
697 |
+
return $this->_extractCountryCodeFromAmazonAddress($this->_getAmazonShippingAddress());
|
698 |
+
}
|
699 |
+
|
700 |
+
/**
|
701 |
+
* Returns customer phone for shipping address
|
702 |
+
*
|
703 |
+
* @return string|null
|
704 |
+
*/
|
705 |
+
public function getShippingAddressPhone()
|
706 |
+
{
|
707 |
+
return $this->_extractPhoneFromAmazonAddress($this->_getAmazonShippingAddress());
|
708 |
+
}
|
709 |
+
|
710 |
+
/**
|
711 |
+
* @return string|null
|
712 |
+
*/
|
713 |
+
public function getMagentoTransactionState()
|
714 |
+
{
|
715 |
+
return $this->_getMagentoTransactionAdditionalInformation(self::TRANSACTION_STATE_KEY);
|
716 |
+
}
|
717 |
+
|
718 |
+
/**
|
719 |
+
* @return string|null
|
720 |
+
*/
|
721 |
+
public function getMagentoTransactionReasonCode()
|
722 |
+
{
|
723 |
+
return $this->_getMagentoTransactionAdditionalInformation(self::TRANSACTION_REASON_CODE_KEY);
|
724 |
+
}
|
725 |
+
|
726 |
+
/**
|
727 |
+
* @return string|null
|
728 |
+
*/
|
729 |
+
public function getMagentoTransactionOrderLanguage()
|
730 |
+
{
|
731 |
+
return $this->_getMagentoTransactionAdditionalInformation(self::TRANSACTION_ORDER_LANGUAGE_KEY);
|
732 |
+
}
|
733 |
+
|
734 |
+
/**
|
735 |
+
* @return null|string
|
736 |
+
*/
|
737 |
+
public function getMagentoChildTransactionType()
|
738 |
+
{
|
739 |
+
return $this->getDataMapper()->getMagentoChildTransactionType($this->getTransactionType());
|
740 |
+
}
|
741 |
+
|
742 |
+
/**
|
743 |
+
* @return array|null
|
744 |
+
*/
|
745 |
+
public function getMagentoBillingAddress()
|
746 |
+
{
|
747 |
+
return $this->getDataMapper()->getBillingAddress($this);
|
748 |
+
}
|
749 |
+
|
750 |
+
/**
|
751 |
+
* @return array|null
|
752 |
+
*/
|
753 |
+
public function getMagentoShippingAddress()
|
754 |
+
{
|
755 |
+
return $this->getDataMapper()->getShippingAddress($this);
|
756 |
+
}
|
757 |
+
|
758 |
+
/**
|
759 |
+
* @param Varien_Object|null $stateObject
|
760 |
+
* @param Varien_Object|null $customStatus
|
761 |
+
* @return Varien_Object
|
762 |
+
*/
|
763 |
+
public function generateMagentoOrderStateObject($stateObject = null, $customStatus = null)
|
764 |
+
{
|
765 |
+
return $this->getDataMapper()->generateMagentoOrderStateObject($this, $stateObject, $customStatus);
|
766 |
+
}
|
767 |
+
|
768 |
+
/**
|
769 |
+
* @return string|null
|
770 |
+
*/
|
771 |
+
public function getCreditmemoState()
|
772 |
+
{
|
773 |
+
return $this->getDataMapper()->getCreditmemoState(
|
774 |
+
$this->getTransactionType(),
|
775 |
+
$this->getTransactionState(),
|
776 |
+
$this->getTransactionReasonCode()
|
777 |
+
);
|
778 |
+
}
|
779 |
+
|
780 |
+
/**
|
781 |
+
* @return string|null
|
782 |
+
*/
|
783 |
+
public function getInvoiceState()
|
784 |
+
{
|
785 |
+
return $this->getDataMapper()->getInvoiceState(
|
786 |
+
$this->getTransactionType(),
|
787 |
+
$this->getTransactionState(),
|
788 |
+
$this->getTransactionReasonCode()
|
789 |
+
);
|
790 |
+
}
|
791 |
+
|
792 |
+
/**
|
793 |
+
* @return array|null
|
794 |
+
*/
|
795 |
+
public function getPaymentFlags()
|
796 |
+
{
|
797 |
+
return $this->getDataMapper()->getPaymentFlags(
|
798 |
+
$this->getTransactionType(),
|
799 |
+
$this->getTransactionState(),
|
800 |
+
$this->getTransactionReasonCode()
|
801 |
+
);
|
802 |
+
}
|
803 |
+
|
804 |
+
/**
|
805 |
+
* @return null|string
|
806 |
+
*/
|
807 |
+
public function getTransactionalEmailToSend()
|
808 |
+
{
|
809 |
+
$email = $this->getDataMapper()->getTransactionalEmailToSend(
|
810 |
+
$this->getTransactionType(),
|
811 |
+
$this->getTransactionState(),
|
812 |
+
$this->getTransactionReasonCode()
|
813 |
+
);
|
814 |
+
if (null === $email && null !== $this->getMagentoBillingAddress()) {
|
815 |
+
return self::EMAIL_TYPE_NEW_ORDER;
|
816 |
+
}
|
817 |
+
|
818 |
+
return $email;
|
819 |
+
}
|
820 |
+
|
821 |
+
/**
|
822 |
+
* Checks whether Magento order data should be updated
|
823 |
+
*
|
824 |
+
* @return bool
|
825 |
+
*/
|
826 |
+
public function shouldUpdateOrderData()
|
827 |
+
{
|
828 |
+
return $this->getDataMapper()->shouldUpdateOrderData(
|
829 |
+
$this->getTransactionType(),
|
830 |
+
$this->getTransactionState()
|
831 |
+
);
|
832 |
+
}
|
833 |
+
|
834 |
+
/**
|
835 |
+
* Checks whether Magento payment transaction should be updated
|
836 |
+
*
|
837 |
+
* @return bool
|
838 |
+
*/
|
839 |
+
public function shouldUpdateTransaction()
|
840 |
+
{
|
841 |
+
return $this->getMagentoTransactionState() != $this->getTransactionState()
|
842 |
+
|| $this->getMagentoTransactionReasonCode() != $this->getTransactionReasonCode()
|
843 |
+
|| $this->getMagentoTransactionOrderLanguage() != $this->getTransactionOrderLanguage();
|
844 |
+
}
|
845 |
+
|
846 |
+
/**
|
847 |
+
* Checks whether Magento payment transaction should be closed
|
848 |
+
*
|
849 |
+
* @return bool
|
850 |
+
*/
|
851 |
+
public function shouldCloseTransaction()
|
852 |
+
{
|
853 |
+
return $this->getDataMapper()->shouldCloseTransaction($this->getMagentoTransactionState());
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Checks whether parent transaction should be updated
|
858 |
+
*
|
859 |
+
* @return bool
|
860 |
+
*/
|
861 |
+
public function shouldUpdateParentTransaction()
|
862 |
+
{
|
863 |
+
return $this->getTransaction()->getId()
|
864 |
+
&& $this->getDataMapper()->shouldUpdateParentTransaction(
|
865 |
+
$this->getTransactionType(),
|
866 |
+
$this->getTransactionState(),
|
867 |
+
$this->getTransactionReasonCode()
|
868 |
+
);
|
869 |
+
}
|
870 |
+
|
871 |
+
/**
|
872 |
+
* Checks whether transaction is eligible for data polling
|
873 |
+
*
|
874 |
+
* @return bool
|
875 |
+
*/
|
876 |
+
public function shouldPollData()
|
877 |
+
{
|
878 |
+
switch ($this->getMagentoTransactionState()) {
|
879 |
+
case self::TRANSACTION_STATE_PENDING:
|
880 |
+
case self::TRANSACTION_STATE_SUSPENDED:
|
881 |
+
case null:
|
882 |
+
return true;
|
883 |
+
case self::TRANSACTION_STATE_OPEN:
|
884 |
+
$txnAge = $this->_getTransactionAgeInDays();
|
885 |
+
if (($this->getTransactionType() == self::TRANSACTION_TYPE_ORDER && $txnAge > 180)
|
886 |
+
|| ($this->getTransactionType() == self::TRANSACTION_TYPE_AUTH && $txnAge > 30)) {
|
887 |
+
return true;
|
888 |
+
}
|
889 |
+
break;
|
890 |
+
}
|
891 |
+
|
892 |
+
return false;
|
893 |
+
}
|
894 |
+
|
895 |
+
/**
|
896 |
+
* Returns transaction status and details to save in 'additional_data'
|
897 |
+
* field of the payment transaction entity in Magento
|
898 |
+
*
|
899 |
+
* @return array|null
|
900 |
+
*/
|
901 |
+
public function getRawDetails()
|
902 |
+
{
|
903 |
+
$rawDetails = array();
|
904 |
+
if ($state = $this->getTransactionState()) {
|
905 |
+
$rawDetails[self::TRANSACTION_STATE_KEY] = $state;
|
906 |
+
}
|
907 |
+
|
908 |
+
if ($reasonCode = $this->getTransactionReasonCode()) {
|
909 |
+
$rawDetails[self::TRANSACTION_REASON_CODE_KEY] = $reasonCode;
|
910 |
+
}
|
911 |
+
|
912 |
+
if ($reasonDescription = $this->getTransactionReasonDescription()) {
|
913 |
+
$rawDetails[self::TRANSACTION_REASON_DESCRIPTION_KEY] = $reasonDescription;
|
914 |
+
}
|
915 |
+
|
916 |
+
if ($orderLanguage = $this->getTransactionOrderLanguage()) {
|
917 |
+
$rawDetails[self::TRANSACTION_ORDER_LANGUAGE_KEY] = $orderLanguage;
|
918 |
+
}
|
919 |
+
|
920 |
+
return !empty($rawDetails) ? $rawDetails : null;
|
921 |
+
}
|
922 |
+
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Processor/Transaction/DataMapper.php
ADDED
@@ -0,0 +1,574 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Processor_Transaction_DataMapper
|
18 |
+
{
|
19 |
+
protected $_transactionTypeMap = array(
|
20 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_ORDER
|
21 |
+
=> Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER,
|
22 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_AUTH
|
23 |
+
=> Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
|
24 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_CAPTURE
|
25 |
+
=> Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE,
|
26 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_REFUND
|
27 |
+
=> Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND
|
28 |
+
);
|
29 |
+
|
30 |
+
protected $_magentoChildTransactionTypeMap = array(
|
31 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_ORDER
|
32 |
+
=> Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
|
33 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_AUTH
|
34 |
+
=> Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE,
|
35 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_CAPTURE
|
36 |
+
=> Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND
|
37 |
+
);
|
38 |
+
|
39 |
+
protected $_shouldUpdateOrderDataMap = array(
|
40 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_ORDER => array(
|
41 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_OPEN,
|
42 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_SUSPENDED,
|
43 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_CANCELED
|
44 |
+
),
|
45 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_AUTH => true
|
46 |
+
);
|
47 |
+
|
48 |
+
protected $_orderStateMap = array(
|
49 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_ORDER => array(
|
50 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_OPEN
|
51 |
+
=> Mage_Sales_Model_Order::STATE_NEW
|
52 |
+
),
|
53 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_AUTH => array(
|
54 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_PENDING
|
55 |
+
=> Mage_Sales_Model_Order::STATE_NEW,
|
56 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_OPEN
|
57 |
+
=> Mage_Sales_Model_Order::STATE_PROCESSING,
|
58 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED
|
59 |
+
=> Mage_Sales_Model_Order::STATE_HOLDED,
|
60 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_CLOSED => array(
|
61 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_REASON_MAX_CAPTURES
|
62 |
+
=> Mage_Sales_Model_Order::STATE_PROCESSING
|
63 |
+
)
|
64 |
+
),
|
65 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_CAPTURE => array(
|
66 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED
|
67 |
+
=> Mage_Sales_Model_Order::STATE_HOLDED,
|
68 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_COMPLETED
|
69 |
+
=> Mage_Sales_Model_Order::STATE_PROCESSING,
|
70 |
+
),
|
71 |
+
);
|
72 |
+
|
73 |
+
protected $_emailToSendMap = array(
|
74 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_AUTH => array(
|
75 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_OPEN
|
76 |
+
=> Creativestyle_AmazonPayments_Model_Processor_Transaction::EMAIL_TYPE_NEW_ORDER,
|
77 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_CLOSED
|
78 |
+
=> Creativestyle_AmazonPayments_Model_Processor_Transaction::EMAIL_TYPE_NEW_ORDER,
|
79 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED => array(
|
80 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_REASON_INVALID_PAYMENT
|
81 |
+
=> Creativestyle_AmazonPayments_Model_Processor_Transaction::EMAIL_TYPE_AUTH_DECLINED
|
82 |
+
)
|
83 |
+
)
|
84 |
+
);
|
85 |
+
|
86 |
+
protected $_paymentFlagsMap = array(
|
87 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_CAPTURE => array(
|
88 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_PENDING
|
89 |
+
=> 'is_transaction_pending',
|
90 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED => array(
|
91 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_REASON_AMAZON_REJECTED
|
92 |
+
=> 'is_transaction_pending,is_transaction_denied',
|
93 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_REASON_PROCESSING_FAILURE
|
94 |
+
=> 'is_transaction_pending'
|
95 |
+
),
|
96 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_COMPLETED
|
97 |
+
=> 'is_transaction_accepted'
|
98 |
+
)
|
99 |
+
);
|
100 |
+
|
101 |
+
protected $_invoiceStateMap = array(
|
102 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_CAPTURE => array(
|
103 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_PENDING
|
104 |
+
=> Mage_Sales_Model_Order_Invoice::STATE_OPEN,
|
105 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED => array(
|
106 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_REASON_AMAZON_REJECTED
|
107 |
+
=> Mage_Sales_Model_Order_Invoice::STATE_CANCELED,
|
108 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_REASON_PROCESSING_FAILURE
|
109 |
+
=> Mage_Sales_Model_Order_Invoice::STATE_OPEN
|
110 |
+
),
|
111 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_COMPLETED
|
112 |
+
=> Mage_Sales_Model_Order_Invoice::STATE_PAID
|
113 |
+
),
|
114 |
+
);
|
115 |
+
|
116 |
+
protected $_creditmemoStateMap = array(
|
117 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_REFUND => array(
|
118 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED
|
119 |
+
=> Mage_Sales_Model_Order_Creditmemo::STATE_CANCELED,
|
120 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_PENDING
|
121 |
+
=> Mage_Sales_Model_Order_Creditmemo::STATE_OPEN,
|
122 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_COMPLETED
|
123 |
+
=> Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED
|
124 |
+
),
|
125 |
+
);
|
126 |
+
|
127 |
+
protected $_shouldCloseTransactionMap = array(
|
128 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED,
|
129 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_CANCELED,
|
130 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_CLOSED,
|
131 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_COMPLETED
|
132 |
+
);
|
133 |
+
|
134 |
+
protected $_shouldUpdateParentTransactionMap = array(
|
135 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_AUTH => array(
|
136 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED => true
|
137 |
+
)
|
138 |
+
);
|
139 |
+
|
140 |
+
/**
|
141 |
+
* @param array $map
|
142 |
+
* @param string $transactionType
|
143 |
+
* @param string $transactionState
|
144 |
+
* @param string|null $transactionReasonCode
|
145 |
+
* @return null|mixed
|
146 |
+
*/
|
147 |
+
protected function _getMapTarget(
|
148 |
+
array $map,
|
149 |
+
$transactionType,
|
150 |
+
$transactionState,
|
151 |
+
$transactionReasonCode = null
|
152 |
+
) {
|
153 |
+
if (array_key_exists($transactionType, $map)) {
|
154 |
+
$transactionTypeTargets = $map[$transactionType];
|
155 |
+
if (array_key_exists($transactionState, $transactionTypeTargets)) {
|
156 |
+
$transactionStateTargets = $transactionTypeTargets[$transactionState];
|
157 |
+
if (is_array($transactionStateTargets)) {
|
158 |
+
if ($transactionReasonCode && array_key_exists($transactionReasonCode, $transactionStateTargets)) {
|
159 |
+
return $transactionStateTargets[$transactionReasonCode];
|
160 |
+
}
|
161 |
+
|
162 |
+
return null;
|
163 |
+
}
|
164 |
+
|
165 |
+
return $transactionStateTargets;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
return null;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Check whether given address lines contain PO Box data
|
174 |
+
*
|
175 |
+
* @param string $firstAddressLine
|
176 |
+
* @param string|null $secondAddressLine
|
177 |
+
*
|
178 |
+
* @return bool
|
179 |
+
*/
|
180 |
+
protected function _isPoBox($firstAddressLine, $secondAddressLine = null)
|
181 |
+
{
|
182 |
+
if (is_numeric($firstAddressLine)) {
|
183 |
+
return true;
|
184 |
+
}
|
185 |
+
|
186 |
+
if (strpos(strtolower($firstAddressLine), 'packstation') !== false) {
|
187 |
+
return true;
|
188 |
+
}
|
189 |
+
|
190 |
+
if (strpos(strtolower($secondAddressLine), 'packstation') !== false) {
|
191 |
+
return true;
|
192 |
+
}
|
193 |
+
|
194 |
+
return false;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* @param string $transactionType
|
199 |
+
* @param string|null $transactionState
|
200 |
+
* @param string|null $transactionReasonCode
|
201 |
+
* @return string|null
|
202 |
+
*/
|
203 |
+
protected function _getOrderStateByTransaction(
|
204 |
+
$transactionType,
|
205 |
+
$transactionState,
|
206 |
+
$transactionReasonCode = null
|
207 |
+
) {
|
208 |
+
return $this->_getMapTarget($this->_orderStateMap, $transactionType, $transactionState, $transactionReasonCode);
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* @param string $state
|
213 |
+
* @param Varien_Object|null $customStatus
|
214 |
+
* @return string
|
215 |
+
*/
|
216 |
+
protected function _getStatusByState($state, $customStatus = null)
|
217 |
+
{
|
218 |
+
$defaultStatus = Mage::getModel('sales/order_status')->loadDefaultByState($state)->getStatus();
|
219 |
+
if ($customStatus) {
|
220 |
+
switch ($state) {
|
221 |
+
case Mage_Sales_Model_Order::STATE_NEW:
|
222 |
+
return $customStatus->getNewOrderStatus() ? $customStatus->getNewOrderStatus() : $defaultStatus;
|
223 |
+
case Mage_Sales_Model_Order::STATE_PROCESSING:
|
224 |
+
return $customStatus->getAuthorizedOrderStatus()
|
225 |
+
? $customStatus->getAuthorizedOrderStatus() : $defaultStatus;
|
226 |
+
case Mage_Sales_Model_Order::STATE_HOLDED:
|
227 |
+
return $customStatus->getHoldedOrderStatus()
|
228 |
+
? $customStatus->getHoldedOrderStatus() : $defaultStatus;
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
return $defaultStatus;
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* @param $message
|
237 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
238 |
+
* @return string
|
239 |
+
*/
|
240 |
+
protected function _formatTransactionUpdateMessage(
|
241 |
+
$message,
|
242 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
243 |
+
) {
|
244 |
+
return Mage::helper('amazonpayments')->__(
|
245 |
+
$message,
|
246 |
+
$transactionProcessor->getFormattedTransactionAmount(),
|
247 |
+
$transactionProcessor->getTransactionId(),
|
248 |
+
sprintf(
|
249 |
+
'<strong>%s</strong>%s',
|
250 |
+
$transactionProcessor->getTransactionState(),
|
251 |
+
$transactionProcessor->getTransactionReasonCode()
|
252 |
+
? ' (' . $transactionProcessor->getTransactionReasonCode() . ')' : ''
|
253 |
+
)
|
254 |
+
);
|
255 |
+
}
|
256 |
+
|
257 |
+
// @codingStandardsIgnoreStart
|
258 |
+
/**
|
259 |
+
* @param array $addressLines
|
260 |
+
* @param string|null $countryId
|
261 |
+
* @return array
|
262 |
+
*/
|
263 |
+
protected function _mapAmazonAddressLines(array $addressLines = array(), $countryId = null)
|
264 |
+
{
|
265 |
+
$address = array('street' => array());
|
266 |
+
switch ($countryId) {
|
267 |
+
case 'DE':
|
268 |
+
case 'AT':
|
269 |
+
if (isset($addressLines[2]) && $addressLines[2]) {
|
270 |
+
if ($this->_isPoBox($addressLines[0], $addressLines[1])) {
|
271 |
+
$address['street'][] = $addressLines[0];
|
272 |
+
$address['street'][] = $addressLines[1];
|
273 |
+
} else {
|
274 |
+
$address['company'] = trim($addressLines[0] . ' ' . $addressLines[1]);
|
275 |
+
}
|
276 |
+
$address['street'][] = $addressLines[2];
|
277 |
+
} elseif (isset($addressLines[1]) && $addressLines[1]) {
|
278 |
+
if ($this->_isPoBox($addressLines[0])) {
|
279 |
+
$address['street'][] = $addressLines[0];
|
280 |
+
} else {
|
281 |
+
$address['company'] = $addressLines[0];
|
282 |
+
}
|
283 |
+
$address['street'][] = $addressLines[1];
|
284 |
+
} elseif (isset($addressLines[0]) && $addressLines[0]) {
|
285 |
+
$address['street'][] = $addressLines[0];
|
286 |
+
}
|
287 |
+
break;
|
288 |
+
default:
|
289 |
+
if (isset($addressLines[0]) && $addressLines[0]) {
|
290 |
+
$address['street'][] = $addressLines[0];
|
291 |
+
}
|
292 |
+
if (isset($addressLines[1]) && $addressLines[1]) {
|
293 |
+
$address['street'][] = $addressLines[1];
|
294 |
+
}
|
295 |
+
if (isset($addressLines[2]) && $addressLines[2]) {
|
296 |
+
$address['street'][] = $addressLines[2];
|
297 |
+
}
|
298 |
+
break;
|
299 |
+
}
|
300 |
+
return $address;
|
301 |
+
}
|
302 |
+
// @codingStandardsIgnoreEnd
|
303 |
+
|
304 |
+
/**
|
305 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
306 |
+
* @param Varien_Object|null $stateObject
|
307 |
+
* @param Varien_Object|null $customStatus
|
308 |
+
* @return Varien_Object
|
309 |
+
*/
|
310 |
+
public function generateMagentoOrderStateObject(
|
311 |
+
Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor,
|
312 |
+
$stateObject = null,
|
313 |
+
$customStatus = null
|
314 |
+
) {
|
315 |
+
if (null === $stateObject) {
|
316 |
+
$stateObject = new Varien_Object();
|
317 |
+
}
|
318 |
+
|
319 |
+
$orderState = $this->_getOrderStateByTransaction(
|
320 |
+
$transactionProcessor->getTransactionType(),
|
321 |
+
$transactionProcessor->getTransactionState(),
|
322 |
+
$transactionProcessor->getTransactionReasonCode()
|
323 |
+
);
|
324 |
+
|
325 |
+
if ($orderState) {
|
326 |
+
$stateObjectData = array(
|
327 |
+
'state' => $orderState,
|
328 |
+
'status' => $this->_getStatusByState($orderState, $customStatus),
|
329 |
+
);
|
330 |
+
if ($orderState == Mage_Sales_Model_Order::STATE_HOLDED) {
|
331 |
+
$stateObjectData['hold_before_state'] = $stateObject->getState();
|
332 |
+
$stateObjectData['hold_before_status'] = $stateObject->getStatus();
|
333 |
+
}
|
334 |
+
|
335 |
+
$stateObject->setData($stateObjectData);
|
336 |
+
}
|
337 |
+
|
338 |
+
$message = null;
|
339 |
+
switch ($transactionProcessor->getTransactionType()) {
|
340 |
+
case Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_ORDER:
|
341 |
+
$message = 'An order of %s has been processed by Amazon Payments (%s). The new status is %s.';
|
342 |
+
break;
|
343 |
+
case Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_AUTH:
|
344 |
+
$message = 'An authorization of %s has been processed by Amazon Payments (%s). The new status is %s.';
|
345 |
+
break;
|
346 |
+
case Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_CAPTURE:
|
347 |
+
$message = 'A capture of %s has been processed by Amazon Payments (%s). The new status is %s.';
|
348 |
+
break;
|
349 |
+
case Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_REFUND:
|
350 |
+
$message = 'A refund of %s has been processed by Amazon Payments (%s). The new status is %s.';
|
351 |
+
break;
|
352 |
+
}
|
353 |
+
|
354 |
+
if ($message) {
|
355 |
+
$stateObject->setMessage($this->_formatTransactionUpdateMessage($message, $transactionProcessor));
|
356 |
+
}
|
357 |
+
|
358 |
+
return $stateObject;
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* @param string $transactionType
|
363 |
+
* @param string|null $transactionState
|
364 |
+
* @param string|null $transactionReasonCode
|
365 |
+
* @return string|null
|
366 |
+
*/
|
367 |
+
public function getCreditmemoState(
|
368 |
+
$transactionType,
|
369 |
+
$transactionState,
|
370 |
+
$transactionReasonCode = null
|
371 |
+
) {
|
372 |
+
return $this->_getMapTarget(
|
373 |
+
$this->_creditmemoStateMap,
|
374 |
+
$transactionType,
|
375 |
+
$transactionState,
|
376 |
+
$transactionReasonCode
|
377 |
+
);
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* @param string $transactionType
|
382 |
+
* @param string|null $transactionState
|
383 |
+
* @param string|null $transactionReasonCode
|
384 |
+
* @return string|null
|
385 |
+
*/
|
386 |
+
public function getInvoiceState(
|
387 |
+
$transactionType,
|
388 |
+
$transactionState,
|
389 |
+
$transactionReasonCode = null
|
390 |
+
) {
|
391 |
+
return $this->_getMapTarget(
|
392 |
+
$this->_invoiceStateMap,
|
393 |
+
$transactionType,
|
394 |
+
$transactionState,
|
395 |
+
$transactionReasonCode
|
396 |
+
);
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* @param string $transactionType
|
401 |
+
* @param string|null $transactionState
|
402 |
+
* @param string|null $transactionReasonCode
|
403 |
+
* @return array|null
|
404 |
+
*/
|
405 |
+
public function getPaymentFlags(
|
406 |
+
$transactionType,
|
407 |
+
$transactionState,
|
408 |
+
$transactionReasonCode = null
|
409 |
+
) {
|
410 |
+
$flags = $this->_getMapTarget(
|
411 |
+
$this->_paymentFlagsMap,
|
412 |
+
$transactionType,
|
413 |
+
$transactionState,
|
414 |
+
$transactionReasonCode
|
415 |
+
);
|
416 |
+
return $flags ? explode(',', $flags) : $flags;
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Returns Amazon transaction type for corresponding Magento transaction type
|
421 |
+
*
|
422 |
+
* @param string $transactionType
|
423 |
+
* @return string|null
|
424 |
+
*/
|
425 |
+
public function getAmazonTransactionType($transactionType)
|
426 |
+
{
|
427 |
+
$transactionTypes = array_flip($this->_transactionTypeMap);
|
428 |
+
if (array_key_exists($transactionType, $transactionTypes)) {
|
429 |
+
return $transactionTypes[$transactionType];
|
430 |
+
}
|
431 |
+
|
432 |
+
return null;
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* @param string $transactionType
|
437 |
+
* @param string|null $transactionState
|
438 |
+
* @param string|null $transactionReasonCode
|
439 |
+
* @return string|null
|
440 |
+
*/
|
441 |
+
public function getTransactionalEmailToSend(
|
442 |
+
$transactionType,
|
443 |
+
$transactionState,
|
444 |
+
$transactionReasonCode = null
|
445 |
+
) {
|
446 |
+
return $this->_getMapTarget(
|
447 |
+
$this->_emailToSendMap,
|
448 |
+
$transactionType,
|
449 |
+
$transactionState,
|
450 |
+
$transactionReasonCode
|
451 |
+
);
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* @param string $transactionType
|
456 |
+
* @param string $transactionState
|
457 |
+
* @return bool
|
458 |
+
*/
|
459 |
+
public function shouldUpdateOrderData($transactionType, $transactionState)
|
460 |
+
{
|
461 |
+
if (array_key_exists($transactionType, $this->_shouldUpdateOrderDataMap)) {
|
462 |
+
if (is_array($this->_shouldUpdateOrderDataMap[$transactionType])) {
|
463 |
+
if (in_array($transactionState, $this->_shouldUpdateOrderDataMap[$transactionType])) {
|
464 |
+
return true;
|
465 |
+
}
|
466 |
+
|
467 |
+
return false;
|
468 |
+
}
|
469 |
+
|
470 |
+
return (bool)$this->_shouldUpdateOrderDataMap[$transactionType];
|
471 |
+
}
|
472 |
+
|
473 |
+
return false;
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* @param string $transactionState
|
478 |
+
* @return bool
|
479 |
+
*/
|
480 |
+
public function shouldCloseTransaction($transactionState)
|
481 |
+
{
|
482 |
+
return in_array($transactionState, $this->_shouldCloseTransactionMap);
|
483 |
+
}
|
484 |
+
|
485 |
+
/**
|
486 |
+
* @param string $transactionType
|
487 |
+
* @param string|null $transactionState
|
488 |
+
* @param string|null $transactionReasonCode
|
489 |
+
* @return bool
|
490 |
+
*/
|
491 |
+
public function shouldUpdateParentTransaction(
|
492 |
+
$transactionType,
|
493 |
+
$transactionState,
|
494 |
+
$transactionReasonCode = null
|
495 |
+
) {
|
496 |
+
return (bool)$this->_getMapTarget(
|
497 |
+
$this->_shouldUpdateParentTransactionMap,
|
498 |
+
$transactionType,
|
499 |
+
$transactionState,
|
500 |
+
$transactionReasonCode
|
501 |
+
);
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Maps transaction details to Magento billing address array
|
506 |
+
*
|
507 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
508 |
+
* @return array|null
|
509 |
+
*/
|
510 |
+
public function getBillingAddress(Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor)
|
511 |
+
{
|
512 |
+
$addressLines = $transactionProcessor->getBillingAddressLines();
|
513 |
+
$countryCode = $transactionProcessor->getBillingAddressCountryCode();
|
514 |
+
if ($addressLines && $countryCode) {
|
515 |
+
return array_merge(
|
516 |
+
array(
|
517 |
+
'firstname' => $transactionProcessor->getBillingAddressFirstname(),
|
518 |
+
'lastname' => $transactionProcessor->getBillingAddressLastname(),
|
519 |
+
),
|
520 |
+
$this->_mapAmazonAddressLines($addressLines, $countryCode),
|
521 |
+
array(
|
522 |
+
'country_id' => $countryCode,
|
523 |
+
'city' => $transactionProcessor->getBillingAddressCity(),
|
524 |
+
'postcode' => $transactionProcessor->getBillingAddressPostalCode(),
|
525 |
+
'telephone' => $transactionProcessor->getBillingAddressPhone()
|
526 |
+
)
|
527 |
+
);
|
528 |
+
}
|
529 |
+
|
530 |
+
return null;
|
531 |
+
}
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Maps transaction details to Magento shipping address array
|
535 |
+
*
|
536 |
+
* @param Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor
|
537 |
+
* @return array|null
|
538 |
+
*/
|
539 |
+
public function getShippingAddress(Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor)
|
540 |
+
{
|
541 |
+
$addressLines = $transactionProcessor->getShippingAddressLines();
|
542 |
+
$countryCode = $transactionProcessor->getShippingAddressCountryCode();
|
543 |
+
if ($addressLines && $countryCode) {
|
544 |
+
return array_merge(
|
545 |
+
array(
|
546 |
+
'firstname' => $transactionProcessor->getShippingAddressFirstname(),
|
547 |
+
'lastname' => $transactionProcessor->getShippingAddressLastname(),
|
548 |
+
),
|
549 |
+
$this->_mapAmazonAddressLines($addressLines, $countryCode),
|
550 |
+
array(
|
551 |
+
'country_id' => $countryCode,
|
552 |
+
'city' => $transactionProcessor->getShippingAddressCity(),
|
553 |
+
'postcode' => $transactionProcessor->getShippingAddressPostalCode(),
|
554 |
+
'telephone' => $transactionProcessor->getShippingAddressPhone()
|
555 |
+
)
|
556 |
+
);
|
557 |
+
}
|
558 |
+
|
559 |
+
return null;
|
560 |
+
}
|
561 |
+
|
562 |
+
/**
|
563 |
+
* @param string $transactionType
|
564 |
+
* @return string|null
|
565 |
+
*/
|
566 |
+
public function getMagentoChildTransactionType($transactionType)
|
567 |
+
{
|
568 |
+
if (array_key_exists($transactionType, $this->_magentoChildTransactionTypeMap)) {
|
569 |
+
return $this->_magentoChildTransactionTypeMap[$transactionType];
|
570 |
+
}
|
571 |
+
|
572 |
+
return null;
|
573 |
+
}
|
574 |
+
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Processor/TransactionAdapter.php
DELETED
@@ -1,485 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2015 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter {
|
17 |
-
|
18 |
-
const TRANSACTION_STATE_KEY = 'State';
|
19 |
-
const TRANSACTION_REASON_CODE_KEY = 'ReasonCode';
|
20 |
-
const TRANSACTION_REASON_DESCRIPTION_KEY = 'ReasonDescription';
|
21 |
-
const TRANSACTION_LANGUAGE_KEY = 'Language';
|
22 |
-
|
23 |
-
const TRANSACTION_STATE_DRAFT = 'Draft';
|
24 |
-
const TRANSACTION_STATE_PENDING = 'Pending';
|
25 |
-
const TRANSACTION_STATE_OPEN = 'Open';
|
26 |
-
const TRANSACTION_STATE_SUSPENDED = 'Suspended';
|
27 |
-
const TRANSACTION_STATE_DECLINED = 'Declined';
|
28 |
-
const TRANSACTION_STATE_COMPLETED = 'Completed';
|
29 |
-
const TRANSACTION_STATE_CANCELED = 'Canceled';
|
30 |
-
const TRANSACTION_STATE_CLOSED = 'Closed';
|
31 |
-
|
32 |
-
const TRANSACTION_REASON_INVALID_PAYMENT = 'InvalidPaymentMethod';
|
33 |
-
const TRANSACTION_REASON_TIMEOUT = 'TransactionTimedOut';
|
34 |
-
const TRANSACTION_REASON_AMAZON_REJECTED = 'AmazonRejected';
|
35 |
-
const TRANSACTION_REASON_AMAZON_CLOSED = 'AmazonClosed';
|
36 |
-
const TRANSACTION_REASON_EXPIRED_UNUSED = 'ExpiredUnused';
|
37 |
-
|
38 |
-
/**
|
39 |
-
* TODO: [$_store description]
|
40 |
-
*
|
41 |
-
* @var null
|
42 |
-
*/
|
43 |
-
protected $_store = null;
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Magento payment transaction instance
|
47 |
-
*
|
48 |
-
* @var Mage_Sales_Model_Order_Payment_Transaction|null
|
49 |
-
*/
|
50 |
-
protected $_transaction = null;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Transaction details object retrieved from Amazon Payments API
|
54 |
-
*
|
55 |
-
* @var OffAmazonPaymentsService_Model|OffAmazonPayments_Model|null
|
56 |
-
*/
|
57 |
-
protected $_transactionDetails = null;
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Transaction amount extracted from transaction details
|
61 |
-
*
|
62 |
-
* @var float|null
|
63 |
-
*/
|
64 |
-
protected $_transactionAmount = null;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* An array reflecting transaction status change in the recently
|
68 |
-
* got Amazon Payments API call response in comparison to
|
69 |
-
* corresponding Magento transaction saved in database
|
70 |
-
*
|
71 |
-
* @var array|false|null
|
72 |
-
*/
|
73 |
-
protected $_statusChange = null;
|
74 |
-
|
75 |
-
/**
|
76 |
-
* TODO: [_getApi description]
|
77 |
-
*
|
78 |
-
* @return Creativestyle_AmazonPayments_Model_Api_Advanced
|
79 |
-
*/
|
80 |
-
protected function _getApi() {
|
81 |
-
return Mage::getSingleton('amazonpayments/api_advanced')->setStore($this->_store);
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Extract transaction status from the transaction details
|
86 |
-
*
|
87 |
-
* Extract and return transaction status array (state, reason code)
|
88 |
-
* from the transaction details.
|
89 |
-
*
|
90 |
-
* @param string $key
|
91 |
-
*
|
92 |
-
* @return array|null
|
93 |
-
*/
|
94 |
-
protected function _extractTransactionStatus($key = null) {
|
95 |
-
if (null !== $this->_transaction && $this->getTransactionDetails()) {
|
96 |
-
if (call_user_func(array($this->getTransactionDetails(), 'isSet' . $this->_getAmazonTransactionType() . 'Status'))) {
|
97 |
-
$transactionStatus = call_user_func(array($this->getTransactionDetails(), 'get' . $this->_getAmazonTransactionType() . 'Status'));
|
98 |
-
$status = array(self::TRANSACTION_STATE_KEY => $transactionStatus->getState());
|
99 |
-
if ($transactionStatus->isSetReasonCode()) {
|
100 |
-
$status[self::TRANSACTION_REASON_CODE_KEY] = $transactionStatus->getReasonCode();
|
101 |
-
}
|
102 |
-
if ($transactionStatus->isSetReasonDescription()) {
|
103 |
-
$status[self::TRANSACTION_REASON_DESCRIPTION_KEY] = $transactionStatus->getReasonDescription();
|
104 |
-
}
|
105 |
-
if (is_callable(array($this->getTransactionDetails(), 'isSetOrderLanguage'))) {
|
106 |
-
if ($this->getTransactionDetails()->isSetOrderLanguage()) {
|
107 |
-
$status[self::TRANSACTION_LANGUAGE_KEY] = $this->getTransactionDetails()->getOrderLanguage();
|
108 |
-
}
|
109 |
-
}
|
110 |
-
if (null !== $key) {
|
111 |
-
if (array_key_exists($key, $status)) {
|
112 |
-
return $status[$key];
|
113 |
-
}
|
114 |
-
return null;
|
115 |
-
}
|
116 |
-
return $status;
|
117 |
-
}
|
118 |
-
}
|
119 |
-
return null;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Check if transaction status has changed
|
124 |
-
*
|
125 |
-
* Extract transaction status from the transaction details. If the
|
126 |
-
* status in assigned transaction details is the same as in
|
127 |
-
* corresponding transaction saved in Magento then return false to
|
128 |
-
* distinguish in the further processes that there's no need to
|
129 |
-
* update payment or order data.
|
130 |
-
*
|
131 |
-
* @return array|false
|
132 |
-
*/
|
133 |
-
protected function _checkStatusChange() {
|
134 |
-
$transactionStatus = $this->_extractTransactionStatus();
|
135 |
-
if (null !== $transactionStatus && Mage::helper('amazonpayments')->getTransactionInformation($this->_transaction, self::TRANSACTION_STATE_KEY) != $transactionStatus[self::TRANSACTION_STATE_KEY]) {
|
136 |
-
return $transactionStatus;
|
137 |
-
}
|
138 |
-
return false;
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* TODO: [_extractIdList description]
|
143 |
-
*
|
144 |
-
* @return array|null
|
145 |
-
*/
|
146 |
-
protected function _extractIdList() {
|
147 |
-
$transactionDetails = $this->getTransactionDetails();
|
148 |
-
if (is_callable(array($transactionDetails, 'isSetIdList'))) {
|
149 |
-
if ($transactionDetails->isSetIdList()) {
|
150 |
-
$idList = $transactionDetails->getIdList();
|
151 |
-
if (is_callable(array($idList, 'isSetmember'))) {
|
152 |
-
if ($idList->isSetmember()) {
|
153 |
-
return $idList->getmember();
|
154 |
-
}
|
155 |
-
} else if (is_callable(array($idList, 'isSetId'))) {
|
156 |
-
if ($idList->isSetId()) {
|
157 |
-
return $idList->getId();
|
158 |
-
}
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
162 |
-
return null;
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Retrieve transaction details from Amazon Payments API
|
167 |
-
*
|
168 |
-
* Retrieves details for provided Magento transaction object using
|
169 |
-
* Amazon Payments API client. Before making a call, identifies the
|
170 |
-
* type of provided transaction type by using appropriate function.
|
171 |
-
*
|
172 |
-
* @return OffAmazonPayments_Model|null
|
173 |
-
*/
|
174 |
-
protected function _fetchTransactionDetails() {
|
175 |
-
if (null !== $this->_transaction) {
|
176 |
-
return call_user_func(array($this->_getApi(), 'get' . $this->_getAmazonTransactionType() . 'Details'), $this->getTransactionId());
|
177 |
-
}
|
178 |
-
return null;
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Returns Amazon Payments-specific name for transaction type
|
183 |
-
*
|
184 |
-
* Checks the type of provided payment transaction object and
|
185 |
-
* returns its corresponding Amazon transaction name. Returns
|
186 |
-
* null if type of provided transaction object is neither
|
187 |
-
* recognized nor has an Amazon Payments equivalent.
|
188 |
-
*
|
189 |
-
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
190 |
-
*
|
191 |
-
* @return string|null
|
192 |
-
*/
|
193 |
-
protected function _getAmazonTransactionType() {
|
194 |
-
switch ($this->getTransactionType()) {
|
195 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
|
196 |
-
return 'OrderReference';
|
197 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
|
198 |
-
return 'Authorization';
|
199 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
|
200 |
-
return 'Capture';
|
201 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
|
202 |
-
return 'Refund';
|
203 |
-
}
|
204 |
-
return null;
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Update status of Magento payment transaction object
|
209 |
-
*
|
210 |
-
* @param array $transactionStatus
|
211 |
-
*
|
212 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
|
213 |
-
*/
|
214 |
-
protected function _updateTransactionStatus($transactionStatus) {
|
215 |
-
$this->_transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
|
216 |
-
if (is_array($transactionStatus) && array_key_exists(self::TRANSACTION_STATE_KEY, $transactionStatus)) {
|
217 |
-
switch ($transactionStatus[self::TRANSACTION_STATE_KEY]) {
|
218 |
-
case self::TRANSACTION_STATE_DECLINED:
|
219 |
-
case self::TRANSACTION_STATE_CANCELED:
|
220 |
-
case self::TRANSACTION_STATE_CLOSED:
|
221 |
-
case self::TRANSACTION_STATE_COMPLETED:
|
222 |
-
$this->_transaction->setIsClosed(true);
|
223 |
-
break;
|
224 |
-
default:
|
225 |
-
break;
|
226 |
-
}
|
227 |
-
}
|
228 |
-
return $this;
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* TODO: [setStore description]
|
233 |
-
*
|
234 |
-
* @param [type] $store
|
235 |
-
*
|
236 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
|
237 |
-
*/
|
238 |
-
public function setStore($store) {
|
239 |
-
$this->_store = $store;
|
240 |
-
return $this;
|
241 |
-
}
|
242 |
-
|
243 |
-
/**
|
244 |
-
* TODO: [setTransaction description]
|
245 |
-
*
|
246 |
-
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction [description]
|
247 |
-
*
|
248 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
|
249 |
-
*/
|
250 |
-
public function setTransaction($transaction) {
|
251 |
-
$this->_transaction = $transaction;
|
252 |
-
return $this;
|
253 |
-
}
|
254 |
-
|
255 |
-
/**
|
256 |
-
* TODO: [setTransactionDetails description]
|
257 |
-
*
|
258 |
-
* @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
|
259 |
-
*
|
260 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
|
261 |
-
*/
|
262 |
-
public function setTransactionDetails($transactionDetails) {
|
263 |
-
$this->_transactionDetails = $transactionDetails;
|
264 |
-
return $this;
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* TODO: [getTransaction description]
|
269 |
-
*
|
270 |
-
* @return Mage_Sales_Model_Order_Payment_Transaction|null
|
271 |
-
*/
|
272 |
-
public function getTransaction() {
|
273 |
-
return $this->_transaction;
|
274 |
-
}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* TODO: [getTransactionType description]
|
278 |
-
*
|
279 |
-
* @return string|null
|
280 |
-
*/
|
281 |
-
public function getTransactionType() {
|
282 |
-
if (null !== $this->_transaction) {
|
283 |
-
return $this->_transaction->getTxnType();
|
284 |
-
}
|
285 |
-
return null;
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* TODO: [getTransactionId description]
|
290 |
-
*
|
291 |
-
* @return string
|
292 |
-
*/
|
293 |
-
public function getTransactionId() {
|
294 |
-
if (null !== $this->_transaction) {
|
295 |
-
return $this->_transaction->getTxnId();
|
296 |
-
}
|
297 |
-
return null;
|
298 |
-
}
|
299 |
-
|
300 |
-
/**
|
301 |
-
* TODO: [getTransactionDetails description]
|
302 |
-
*
|
303 |
-
* @return OffAmazonPaymentsService_Model|OffAmazonPayments_Model|null
|
304 |
-
*/
|
305 |
-
public function getTransactionDetails() {
|
306 |
-
if (null === $this->_transactionDetails) {
|
307 |
-
$this->_transactionDetails = $this->_fetchTransactionDetails();
|
308 |
-
}
|
309 |
-
return $this->_transactionDetails;
|
310 |
-
}
|
311 |
-
|
312 |
-
/**
|
313 |
-
* TODO: [getTransactionAmount description]
|
314 |
-
*
|
315 |
-
* @return float
|
316 |
-
*/
|
317 |
-
public function getTransactionAmount() {
|
318 |
-
if (null === $this->_transactionAmount) {
|
319 |
-
$transactionAmountObject = call_user_func(array($this->getTransactionDetails(), $this->getTransactionType() == Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER ? 'getOrderTotal' : 'get' . $this->_getAmazonTransactionType() . 'Amount'));
|
320 |
-
$this->_transactionAmount = $transactionAmountObject->getAmount();
|
321 |
-
}
|
322 |
-
return $this->_transactionAmount;
|
323 |
-
}
|
324 |
-
|
325 |
-
/**
|
326 |
-
* TODO: [getStatusChange description]
|
327 |
-
*
|
328 |
-
* @param string $key
|
329 |
-
*
|
330 |
-
* @return array|string|false|null
|
331 |
-
*/
|
332 |
-
public function getStatusChange($key = null) {
|
333 |
-
if (null === $this->_statusChange) {
|
334 |
-
$this->_statusChange = $this->_checkStatusChange();
|
335 |
-
if ($this->_statusChange) {
|
336 |
-
$this->_updateTransactionStatus($this->_statusChange);
|
337 |
-
}
|
338 |
-
}
|
339 |
-
if (null !== $key) {
|
340 |
-
if (is_array($this->_statusChange) && array_key_exists($key, $this->_statusChange)) {
|
341 |
-
return $this->_statusChange[$key];
|
342 |
-
}
|
343 |
-
return null;
|
344 |
-
}
|
345 |
-
return $this->_statusChange;
|
346 |
-
}
|
347 |
-
|
348 |
-
/**
|
349 |
-
* TODO: [processRelatedObjects description]
|
350 |
-
*
|
351 |
-
* @param Mage_Sales_Model_Order $order
|
352 |
-
*
|
353 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter|null
|
354 |
-
*/
|
355 |
-
public function processRelatedObjects($order) {
|
356 |
-
switch ($this->getTransactionType()) {
|
357 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
|
358 |
-
if ($this->_extractTransactionStatus(self::TRANSACTION_STATE_KEY) == self::TRANSACTION_STATE_OPEN) {
|
359 |
-
$authTransaction = $order->getPayment()->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
360 |
-
if ($authTransaction && $authTransaction->getIsClosed() && ($order->getBaseTotalDue() > 0)) {
|
361 |
-
$order->getPayment()->getMethodInstance()->setStore($order->getStoreId())->authorize($order->getPayment(), $order->getBaseTotalDue());
|
362 |
-
}
|
363 |
-
}
|
364 |
-
break;
|
365 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
|
366 |
-
$childrenIds = $this->_extractIdList();
|
367 |
-
if (is_array($childrenIds)) {
|
368 |
-
foreach ($childrenIds as $childTransactionId) {
|
369 |
-
if (!$order->getPayment()->lookupTransaction($childTransactionId)) {
|
370 |
-
$childTransaction = $order->getPayment()->setIsTransactionClosed(false)
|
371 |
-
->setTransactionId($childTransactionId)
|
372 |
-
->setParentTransactionId($this->getTransactionId())
|
373 |
-
->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
374 |
-
$captureAdapter = Mage::getSingleton('amazonpayments/processor_payment')
|
375 |
-
->setPaymentObject($order->getPayment())
|
376 |
-
->importTransactionDetails($childTransaction);
|
377 |
-
$captureAdapter->validateTransactionStatus();
|
378 |
-
$invoice = $order->prepareInvoice()
|
379 |
-
->setTransactionId($childTransactionId)
|
380 |
-
->register()
|
381 |
-
->pay();
|
382 |
-
$order->addRelatedObject($invoice);
|
383 |
-
return $captureAdapter;
|
384 |
-
}
|
385 |
-
}
|
386 |
-
}
|
387 |
-
if ($this->_extractTransactionStatus(self::TRANSACTION_STATE_KEY) == self::TRANSACTION_STATE_CLOSED
|
388 |
-
&& $this->_extractTransactionStatus(self::TRANSACTION_REASON_CODE_KEY) == self::TRANSACTION_REASON_EXPIRED_UNUSED) {
|
389 |
-
$order->getPayment()->getMethodInstance()->authorize($order->getPayment(), $this->getTransactionAmount());
|
390 |
-
}
|
391 |
-
break;
|
392 |
-
}
|
393 |
-
return null;
|
394 |
-
}
|
395 |
-
|
396 |
-
/**
|
397 |
-
* TODO: [saveTransaction description]
|
398 |
-
*
|
399 |
-
* @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
|
400 |
-
*/
|
401 |
-
public function saveTransaction() {
|
402 |
-
$this->_transaction->save();
|
403 |
-
return $this;
|
404 |
-
}
|
405 |
-
|
406 |
-
/**
|
407 |
-
* TODO: [validateTransactionStatus description]
|
408 |
-
*
|
409 |
-
* @return bool
|
410 |
-
*
|
411 |
-
* @throws Creativestyle_AmazonPayments_Exception_InvalidStatus_Unrecoverable
|
412 |
-
* @throws Creativestyle_AmazonPayments_Exception_InvalidStatus_Recoverable
|
413 |
-
* @throws Creativestyle_AmazonPayments_Exception_InvalidStatus
|
414 |
-
* @throws Creativestyle_AmazonPayments_Exception
|
415 |
-
*/
|
416 |
-
public function validateTransactionStatus() {
|
417 |
-
$transactionStatus = $this->getStatusChange();
|
418 |
-
if (is_array($transactionStatus)) {
|
419 |
-
$state = array_key_exists(self::TRANSACTION_STATE_KEY, $transactionStatus) ? $transactionStatus[self::TRANSACTION_STATE_KEY] : null;
|
420 |
-
$reason = array_key_exists(self::TRANSACTION_REASON_CODE_KEY, $transactionStatus) ? $transactionStatus[self::TRANSACTION_REASON_CODE_KEY] : null;
|
421 |
-
switch ($this->getTransactionType()) {
|
422 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
|
423 |
-
switch ($state) {
|
424 |
-
case self::TRANSACTION_STATE_OPEN:
|
425 |
-
return true;
|
426 |
-
default:
|
427 |
-
throw new Creativestyle_AmazonPayments_Exception('Invalid Order Reference status');
|
428 |
-
}
|
429 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
|
430 |
-
switch ($state) {
|
431 |
-
case self::TRANSACTION_STATE_PENDING:
|
432 |
-
case self::TRANSACTION_STATE_OPEN:
|
433 |
-
case self::TRANSACTION_STATE_CLOSED:
|
434 |
-
return true;
|
435 |
-
case self::TRANSACTION_STATE_DECLINED:
|
436 |
-
switch ($reason) {
|
437 |
-
case self::TRANSACTION_REASON_INVALID_PAYMENT:
|
438 |
-
throw new Creativestyle_AmazonPayments_Exception_InvalidStatus_Recoverable('Invalid Authorization status');
|
439 |
-
case self::TRANSACTION_REASON_TIMEOUT:
|
440 |
-
throw new Creativestyle_AmazonPayments_Exception_InvalidStatus('Invalid Authorization status');
|
441 |
-
case self::TRANSACTION_REASON_AMAZON_REJECTED:
|
442 |
-
throw new Creativestyle_AmazonPayments_Exception_InvalidStatus_Unrecoverable('Invalid Authorization status');
|
443 |
-
}
|
444 |
-
default:
|
445 |
-
throw new Creativestyle_AmazonPayments_Exception('Invalid Authorization status');
|
446 |
-
}
|
447 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
|
448 |
-
switch ($state) {
|
449 |
-
case self::TRANSACTION_STATE_PENDING:
|
450 |
-
case self::TRANSACTION_STATE_COMPLETED:
|
451 |
-
return true;
|
452 |
-
default:
|
453 |
-
throw new Creativestyle_AmazonPayments_Exception('Invalid Capture status');
|
454 |
-
}
|
455 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
|
456 |
-
return true;
|
457 |
-
default:
|
458 |
-
throw new Creativestyle_AmazonPayments_Exception('Invalid transaction type');
|
459 |
-
}
|
460 |
-
}
|
461 |
-
throw new Creativestyle_AmazonPayments_Exception('Invalid transaction status');
|
462 |
-
}
|
463 |
-
|
464 |
-
public function shouldUpdateOrderData() {
|
465 |
-
$transactionStatus = $this->getStatusChange();
|
466 |
-
if (is_array($transactionStatus)) {
|
467 |
-
$state = array_key_exists(self::TRANSACTION_STATE_KEY, $transactionStatus) ? $transactionStatus[self::TRANSACTION_STATE_KEY] : null;
|
468 |
-
switch ($this->getTransactionType()) {
|
469 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
|
470 |
-
switch ($state) {
|
471 |
-
case self::TRANSACTION_STATE_CLOSED:
|
472 |
-
return false;
|
473 |
-
default:
|
474 |
-
return true;
|
475 |
-
}
|
476 |
-
return true;
|
477 |
-
case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
|
478 |
-
return true;
|
479 |
-
default:
|
480 |
-
return false;
|
481 |
-
}
|
482 |
-
}
|
483 |
-
return false;
|
484 |
-
}
|
485 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/Model/{Setup.php → Resource/Setup.php}
RENAMED
@@ -1,37 +1,48 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class
|
|
|
17 |
|
18 |
-
protected function _getVersion()
|
|
|
19 |
return (string)$this->_moduleConfig->version;
|
20 |
}
|
21 |
|
22 |
-
protected function _copyConfigData(array $data)
|
|
|
23 |
foreach ($data as $oldConfigPath => $newConfigPath) {
|
24 |
$query = $this->getConnection()->select()
|
25 |
->from($this->getTable('core/config_data'), '*')
|
26 |
->where('path = ?', $oldConfigPath);
|
|
|
27 |
$oldConfig = $this->getConnection()->fetchAll($query);
|
28 |
-
|
|
|
29 |
$newConfig = array();
|
30 |
foreach ($oldConfig as $row) {
|
31 |
// check if config entry with given path, scope and scope_id exists
|
32 |
$query = $this->getConnection()->select()
|
33 |
->from($this->getTable('core/config_data'), 'COUNT(*)')
|
34 |
-
->where(
|
|
|
|
|
|
|
|
|
|
|
35 |
$count = $this->getConnection()->fetchOne($query);
|
36 |
if (!$count) {
|
37 |
$newConfig[] = array(
|
@@ -42,6 +53,7 @@ class Creativestyle_AmazonPayments_Model_Setup extends Mage_Eav_Model_Entity_Set
|
|
42 |
);
|
43 |
}
|
44 |
}
|
|
|
45 |
if (!empty($newConfig)) {
|
46 |
try {
|
47 |
$this->getConnection()->beginTransaction();
|
@@ -56,7 +68,8 @@ class Creativestyle_AmazonPayments_Model_Setup extends Mage_Eav_Model_Entity_Set
|
|
56 |
}
|
57 |
}
|
58 |
|
59 |
-
protected function _updateConfigData(array $data)
|
|
|
60 |
foreach ($data as $configPath => $updates) {
|
61 |
if (is_array($updates) && !empty($updates)) {
|
62 |
try {
|
@@ -69,6 +82,7 @@ class Creativestyle_AmazonPayments_Model_Setup extends Mage_Eav_Model_Entity_Set
|
|
69 |
. $this->getConnection()->quoteInto('value = ?', $oldValue)
|
70 |
);
|
71 |
}
|
|
|
72 |
$this->getConnection()->commit();
|
73 |
} catch (Exception $e) {
|
74 |
$this->getConnection()->rollback();
|
@@ -78,21 +92,26 @@ class Creativestyle_AmazonPayments_Model_Setup extends Mage_Eav_Model_Entity_Set
|
|
78 |
}
|
79 |
}
|
80 |
|
81 |
-
public function updateConfigData()
|
|
|
82 |
switch ($this->_getVersion()) {
|
83 |
case '1.8.2':
|
84 |
-
$this->_copyConfigData(
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
94 |
)
|
95 |
-
)
|
96 |
break;
|
97 |
default:
|
98 |
break;
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2016 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2016 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
18 |
+
{
|
19 |
|
20 |
+
protected function _getVersion()
|
21 |
+
{
|
22 |
return (string)$this->_moduleConfig->version;
|
23 |
}
|
24 |
|
25 |
+
protected function _copyConfigData(array $data)
|
26 |
+
{
|
27 |
foreach ($data as $oldConfigPath => $newConfigPath) {
|
28 |
$query = $this->getConnection()->select()
|
29 |
->from($this->getTable('core/config_data'), '*')
|
30 |
->where('path = ?', $oldConfigPath);
|
31 |
+
// @codingStandardsIgnoreStart
|
32 |
$oldConfig = $this->getConnection()->fetchAll($query);
|
33 |
+
// @codingStandardsIgnoreEnd
|
34 |
+
if (!empty($oldConfig)) {
|
35 |
$newConfig = array();
|
36 |
foreach ($oldConfig as $row) {
|
37 |
// check if config entry with given path, scope and scope_id exists
|
38 |
$query = $this->getConnection()->select()
|
39 |
->from($this->getTable('core/config_data'), 'COUNT(*)')
|
40 |
+
->where(
|
41 |
+
'scope = ? AND scope_id = ? AND path = ?',
|
42 |
+
$row['scope'],
|
43 |
+
$row['scope_id'],
|
44 |
+
$newConfigPath
|
45 |
+
);
|
46 |
$count = $this->getConnection()->fetchOne($query);
|
47 |
if (!$count) {
|
48 |
$newConfig[] = array(
|
53 |
);
|
54 |
}
|
55 |
}
|
56 |
+
|
57 |
if (!empty($newConfig)) {
|
58 |
try {
|
59 |
$this->getConnection()->beginTransaction();
|
68 |
}
|
69 |
}
|
70 |
|
71 |
+
protected function _updateConfigData(array $data)
|
72 |
+
{
|
73 |
foreach ($data as $configPath => $updates) {
|
74 |
if (is_array($updates) && !empty($updates)) {
|
75 |
try {
|
82 |
. $this->getConnection()->quoteInto('value = ?', $oldValue)
|
83 |
);
|
84 |
}
|
85 |
+
|
86 |
$this->getConnection()->commit();
|
87 |
} catch (Exception $e) {
|
88 |
$this->getConnection()->rollback();
|
92 |
}
|
93 |
}
|
94 |
|
95 |
+
public function updateConfigData()
|
96 |
+
{
|
97 |
switch ($this->_getVersion()) {
|
98 |
case '1.8.2':
|
99 |
+
$this->_copyConfigData(
|
100 |
+
array(
|
101 |
+
'amazonpayments/login/active' => 'amazonpayments/general/login_active',
|
102 |
+
'amazonpayments/login/client_id' => 'amazonpayments/account/client_id',
|
103 |
+
'amazonpayments/login/language' => 'amazonpayments/general/language',
|
104 |
+
'amazonpayments/login/authentication' => 'amazonpayments/general/authentication'
|
105 |
+
)
|
106 |
+
);
|
107 |
+
$this->_updateConfigData(
|
108 |
+
array(
|
109 |
+
'amazonpayments/account/region' => array(
|
110 |
+
'de' => 'EUR',
|
111 |
+
'uk' => 'GBP'
|
112 |
+
)
|
113 |
)
|
114 |
+
);
|
115 |
break;
|
116 |
default:
|
117 |
break;
|
app/code/community/Creativestyle/AmazonPayments/Model/Service/Login.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Service_Login
|
|
|
17 |
|
18 |
const ACCOUNT_STATUS_OK = 1;
|
19 |
const ACCOUNT_STATUS_CONFIRM = 2;
|
@@ -26,39 +28,55 @@ class Creativestyle_AmazonPayments_Model_Service_Login {
|
|
26 |
|
27 |
protected $_websiteId = null;
|
28 |
|
29 |
-
public function __construct($amazonUserData)
|
|
|
30 |
if (!$this->_validateAmazonUserData($amazonUserData)) {
|
31 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-service] Provided user profile is invalid');
|
32 |
}
|
|
|
33 |
$this->_amazonUserData = $amazonUserData;
|
34 |
}
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
return Mage::getSingleton('amazonpayments/config');
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
* @return Mage_Customer_Model_Session
|
42 |
*/
|
43 |
-
protected function _getCustomerSession()
|
|
|
44 |
return Mage::getSingleton('customer/session');
|
45 |
}
|
46 |
|
47 |
-
protected function _getWebsiteId()
|
|
|
48 |
if (null === $this->_websiteId) {
|
49 |
$this->_websiteId = Mage::app()->getStore()->getWebsiteId();
|
50 |
}
|
|
|
51 |
return $this->_websiteId;
|
52 |
}
|
53 |
|
54 |
-
protected function _validateAmazonUserData($amazonUserData)
|
55 |
-
|
|
|
|
|
56 |
}
|
57 |
|
58 |
-
protected function _getCustomer()
|
|
|
59 |
$amazonUserIdAttr = Mage::getResourceModel('catalog/eav_attribute')->loadByCode('customer', 'amazon_user_id');
|
60 |
if (!$amazonUserIdAttr->getId()) {
|
61 |
-
throw new Creativestyle_AmazonPayments_Exception(
|
|
|
|
|
62 |
}
|
63 |
|
64 |
if (null === $this->_customer) {
|
@@ -69,45 +87,58 @@ class Creativestyle_AmazonPayments_Model_Service_Login {
|
|
69 |
if ($customer->getSharingConfig()->isWebsiteScope()) {
|
70 |
$collection->addAttributeToFilter('website_id', $this->_getWebsiteId());
|
71 |
}
|
72 |
-
|
|
|
|
|
73 |
$this->_customer = $collection->getFirstItem();
|
|
|
74 |
}
|
75 |
}
|
|
|
76 |
return $this->_customer;
|
77 |
}
|
78 |
|
79 |
-
protected function _getCustomerByEmail()
|
|
|
80 |
if (null === $this->_customer) {
|
81 |
-
$this->_customer = Mage::getModel('customer/customer')
|
|
|
|
|
82 |
if (!$this->_customer->getId()) {
|
83 |
$this->_customer = null;
|
84 |
}
|
85 |
}
|
|
|
86 |
return $this->_customer;
|
87 |
}
|
88 |
|
89 |
-
protected function _getEmptyCustomer()
|
|
|
90 |
if (null === $this->_customer) {
|
91 |
$this->_customer = Mage::getModel('customer/customer');
|
92 |
}
|
|
|
93 |
return $this->_customer;
|
94 |
}
|
95 |
|
96 |
-
protected function _getCustomerRequiredData()
|
|
|
97 |
$requiredData = array();
|
98 |
-
$
|
99 |
-
foreach ($this->_getConfig()->
|
100 |
-
$attributeModel = $
|
101 |
if ($attributeModel instanceof Varien_Object) {
|
102 |
if ($attributeModel->getIsRequired()) {
|
103 |
$requiredData[] = $attributeCode;
|
104 |
}
|
105 |
}
|
106 |
}
|
|
|
107 |
return $requiredData;
|
108 |
}
|
109 |
|
110 |
-
protected function _createCustomer($accountData = array())
|
|
|
111 |
if ($customer = $this->_getEmptyCustomer()) {
|
112 |
$password = $customer->generatePassword(8);
|
113 |
$customerName = Mage::helper('amazonpayments')->explodeCustomerName($this->_amazonUserData->getName());
|
@@ -130,56 +161,73 @@ class Creativestyle_AmazonPayments_Model_Service_Login {
|
|
130 |
$validation = $customer->validate();
|
131 |
if ($validation !== true && !empty($validation)) {
|
132 |
$validation = implode(", ", $validation);
|
133 |
-
throw new Creativestyle_AmazonPayments_Exception(
|
|
|
|
|
134 |
}
|
135 |
|
136 |
$customer->save();
|
137 |
return $customer;
|
138 |
}
|
|
|
139 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-service] unable to create new customer account');
|
140 |
}
|
141 |
|
142 |
-
public function connect($accountData = array())
|
|
|
143 |
if (null !== $this->_getCustomer()) {
|
144 |
-
return new Varien_Object(
|
|
|
145 |
'status' => self::ACCOUNT_STATUS_OK,
|
146 |
'customer' => $this->_getCustomer()
|
147 |
-
|
|
|
148 |
} elseif (null !== $this->_getCustomerByEmail()) {
|
149 |
if ($this->_getCustomerSession()->isLoggedIn()) {
|
150 |
$this->_getCustomerByEmail()->setAmazonUserId($this->_amazonUserData->getUserId())->save();
|
151 |
-
return new Varien_Object(
|
|
|
152 |
'status' => self::ACCOUNT_STATUS_OK,
|
153 |
'customer' => $this->_getCustomerByEmail()
|
154 |
-
|
|
|
155 |
}
|
156 |
-
|
|
|
|
|
157 |
'status' => self::ACCOUNT_STATUS_CONFIRM,
|
158 |
'customer' => $this->_getCustomerByEmail()
|
159 |
-
|
|
|
160 |
} else {
|
161 |
$requiredData = $this->_getCustomerRequiredData();
|
162 |
$postedData = array_keys($accountData);
|
163 |
$dataDiff = array_diff($requiredData, $postedData);
|
164 |
if (!(empty($requiredData) || empty($dataDiff))) {
|
165 |
-
return new Varien_Object(
|
|
|
166 |
'status' => self::ACCOUNT_STATUS_DATA_MISSING,
|
167 |
'required_data' => $requiredData
|
168 |
-
|
|
|
169 |
} else {
|
170 |
$customer = $this->_createCustomer($accountData);
|
171 |
if (null !== $customer) {
|
172 |
-
return new Varien_Object(
|
|
|
173 |
'status' => self::ACCOUNT_STATUS_OK,
|
174 |
'customer' => $customer
|
175 |
-
|
|
|
176 |
}
|
177 |
}
|
178 |
}
|
|
|
179 |
return new Varien_Object(array('status' => self::ACCOUNT_STATUS_ERROR));
|
180 |
}
|
181 |
|
182 |
-
public function setWebsiteId($websiteId)
|
|
|
183 |
$this->_websiteId = $websiteId;
|
184 |
return $this;
|
185 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Service_Login
|
18 |
+
{
|
19 |
|
20 |
const ACCOUNT_STATUS_OK = 1;
|
21 |
const ACCOUNT_STATUS_CONFIRM = 2;
|
28 |
|
29 |
protected $_websiteId = null;
|
30 |
|
31 |
+
public function __construct($amazonUserData)
|
32 |
+
{
|
33 |
if (!$this->_validateAmazonUserData($amazonUserData)) {
|
34 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-service] Provided user profile is invalid');
|
35 |
}
|
36 |
+
|
37 |
$this->_amazonUserData = $amazonUserData;
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
+
* Returns instance of Amazon Payments config object
|
42 |
+
*
|
43 |
+
* @return Creativestyle_AmazonPayments_Model_Config
|
44 |
+
*/
|
45 |
+
protected function _getConfig()
|
46 |
+
{
|
47 |
return Mage::getSingleton('amazonpayments/config');
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
* @return Mage_Customer_Model_Session
|
52 |
*/
|
53 |
+
protected function _getCustomerSession()
|
54 |
+
{
|
55 |
return Mage::getSingleton('customer/session');
|
56 |
}
|
57 |
|
58 |
+
protected function _getWebsiteId()
|
59 |
+
{
|
60 |
if (null === $this->_websiteId) {
|
61 |
$this->_websiteId = Mage::app()->getStore()->getWebsiteId();
|
62 |
}
|
63 |
+
|
64 |
return $this->_websiteId;
|
65 |
}
|
66 |
|
67 |
+
protected function _validateAmazonUserData($amazonUserData)
|
68 |
+
{
|
69 |
+
return $amazonUserData instanceof Varien_Object
|
70 |
+
&& $amazonUserData->getEmail() && $amazonUserData->getName() && $amazonUserData->getUserId();
|
71 |
}
|
72 |
|
73 |
+
protected function _getCustomer()
|
74 |
+
{
|
75 |
$amazonUserIdAttr = Mage::getResourceModel('catalog/eav_attribute')->loadByCode('customer', 'amazon_user_id');
|
76 |
if (!$amazonUserIdAttr->getId()) {
|
77 |
+
throw new Creativestyle_AmazonPayments_Exception(
|
78 |
+
'[LWA-service] amazon_user_id customer attribute does not exist'
|
79 |
+
);
|
80 |
}
|
81 |
|
82 |
if (null === $this->_customer) {
|
87 |
if ($customer->getSharingConfig()->isWebsiteScope()) {
|
88 |
$collection->addAttributeToFilter('website_id', $this->_getWebsiteId());
|
89 |
}
|
90 |
+
|
91 |
+
if (!empty($collection)) {
|
92 |
+
// @codingStandardsIgnoreStart
|
93 |
$this->_customer = $collection->getFirstItem();
|
94 |
+
// @codingStandardsIgnoreEnd
|
95 |
}
|
96 |
}
|
97 |
+
|
98 |
return $this->_customer;
|
99 |
}
|
100 |
|
101 |
+
protected function _getCustomerByEmail()
|
102 |
+
{
|
103 |
if (null === $this->_customer) {
|
104 |
+
$this->_customer = Mage::getModel('customer/customer')
|
105 |
+
->setWebsiteId($this->_getWebsiteId())
|
106 |
+
->loadByEmail($this->_amazonUserData->getEmail());
|
107 |
if (!$this->_customer->getId()) {
|
108 |
$this->_customer = null;
|
109 |
}
|
110 |
}
|
111 |
+
|
112 |
return $this->_customer;
|
113 |
}
|
114 |
|
115 |
+
protected function _getEmptyCustomer()
|
116 |
+
{
|
117 |
if (null === $this->_customer) {
|
118 |
$this->_customer = Mage::getModel('customer/customer');
|
119 |
}
|
120 |
+
|
121 |
return $this->_customer;
|
122 |
}
|
123 |
|
124 |
+
protected function _getCustomerRequiredData()
|
125 |
+
{
|
126 |
$requiredData = array();
|
127 |
+
$eavConfig = Mage::getSingleton('eav/config');
|
128 |
+
foreach ($this->_getConfig()->getGlobalConfigData('customer_attributes') as $attributeCode => $attributeData) {
|
129 |
+
$attributeModel = $eavConfig->getAttribute('customer', $attributeCode);
|
130 |
if ($attributeModel instanceof Varien_Object) {
|
131 |
if ($attributeModel->getIsRequired()) {
|
132 |
$requiredData[] = $attributeCode;
|
133 |
}
|
134 |
}
|
135 |
}
|
136 |
+
|
137 |
return $requiredData;
|
138 |
}
|
139 |
|
140 |
+
protected function _createCustomer($accountData = array())
|
141 |
+
{
|
142 |
if ($customer = $this->_getEmptyCustomer()) {
|
143 |
$password = $customer->generatePassword(8);
|
144 |
$customerName = Mage::helper('amazonpayments')->explodeCustomerName($this->_amazonUserData->getName());
|
161 |
$validation = $customer->validate();
|
162 |
if ($validation !== true && !empty($validation)) {
|
163 |
$validation = implode(", ", $validation);
|
164 |
+
throw new Creativestyle_AmazonPayments_Exception(
|
165 |
+
'[LWA-service] error while creating customer account: ' . $validation
|
166 |
+
);
|
167 |
}
|
168 |
|
169 |
$customer->save();
|
170 |
return $customer;
|
171 |
}
|
172 |
+
|
173 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-service] unable to create new customer account');
|
174 |
}
|
175 |
|
176 |
+
public function connect($accountData = array())
|
177 |
+
{
|
178 |
if (null !== $this->_getCustomer()) {
|
179 |
+
return new Varien_Object(
|
180 |
+
array(
|
181 |
'status' => self::ACCOUNT_STATUS_OK,
|
182 |
'customer' => $this->_getCustomer()
|
183 |
+
)
|
184 |
+
);
|
185 |
} elseif (null !== $this->_getCustomerByEmail()) {
|
186 |
if ($this->_getCustomerSession()->isLoggedIn()) {
|
187 |
$this->_getCustomerByEmail()->setAmazonUserId($this->_amazonUserData->getUserId())->save();
|
188 |
+
return new Varien_Object(
|
189 |
+
array(
|
190 |
'status' => self::ACCOUNT_STATUS_OK,
|
191 |
'customer' => $this->_getCustomerByEmail()
|
192 |
+
)
|
193 |
+
);
|
194 |
}
|
195 |
+
|
196 |
+
return new Varien_Object(
|
197 |
+
array(
|
198 |
'status' => self::ACCOUNT_STATUS_CONFIRM,
|
199 |
'customer' => $this->_getCustomerByEmail()
|
200 |
+
)
|
201 |
+
);
|
202 |
} else {
|
203 |
$requiredData = $this->_getCustomerRequiredData();
|
204 |
$postedData = array_keys($accountData);
|
205 |
$dataDiff = array_diff($requiredData, $postedData);
|
206 |
if (!(empty($requiredData) || empty($dataDiff))) {
|
207 |
+
return new Varien_Object(
|
208 |
+
array(
|
209 |
'status' => self::ACCOUNT_STATUS_DATA_MISSING,
|
210 |
'required_data' => $requiredData
|
211 |
+
)
|
212 |
+
);
|
213 |
} else {
|
214 |
$customer = $this->_createCustomer($accountData);
|
215 |
if (null !== $customer) {
|
216 |
+
return new Varien_Object(
|
217 |
+
array(
|
218 |
'status' => self::ACCOUNT_STATUS_OK,
|
219 |
'customer' => $customer
|
220 |
+
)
|
221 |
+
);
|
222 |
}
|
223 |
}
|
224 |
}
|
225 |
+
|
226 |
return new Varien_Object(array('status' => self::ACCOUNT_STATUS_ERROR));
|
227 |
}
|
228 |
|
229 |
+
public function setWebsiteId($websiteId)
|
230 |
+
{
|
231 |
$this->_websiteId = $websiteId;
|
232 |
return $this;
|
233 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Service/Quote.php
CHANGED
@@ -1,26 +1,29 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Service_Quote extends Mage_Sales_Model_Service_Quote
|
|
|
17 |
|
18 |
/**
|
19 |
* Validate quote data before converting to order
|
20 |
*
|
21 |
* @return Mage_Sales_Model_Service_Quote
|
22 |
*/
|
23 |
-
protected function _validate()
|
|
|
24 |
if (!$this->getQuote()->isVirtual()) {
|
25 |
$address = $this->getQuote()->getShippingAddress();
|
26 |
$method= $address->getShippingMethod();
|
@@ -37,12 +40,14 @@ class Creativestyle_AmazonPayments_Model_Service_Quote extends Mage_Sales_Model_
|
|
37 |
return $this;
|
38 |
}
|
39 |
|
|
|
40 |
/**
|
41 |
* Submit the quote. Quote submit process will create the order based on quote data
|
42 |
-
*
|
43 |
* @return Mage_Sales_Model_Order
|
|
|
44 |
*/
|
45 |
-
public function submitOrder()
|
|
|
46 |
$this->_deleteNominalItems();
|
47 |
$this->_validate();
|
48 |
$quote = $this->_quote;
|
@@ -52,6 +57,7 @@ class Creativestyle_AmazonPayments_Model_Service_Quote extends Mage_Sales_Model_
|
|
52 |
if ($quote->getCustomerId()) {
|
53 |
$transaction->addObject($quote->getCustomer());
|
54 |
}
|
|
|
55 |
$transaction->addObject($quote);
|
56 |
|
57 |
$quote->reserveOrderId();
|
@@ -60,25 +66,39 @@ class Creativestyle_AmazonPayments_Model_Service_Quote extends Mage_Sales_Model_
|
|
60 |
} else {
|
61 |
$order = $this->_convertor->addressToOrder($quote->getShippingAddress());
|
62 |
}
|
|
|
63 |
$order->setBillingAddress($this->_convertor->addressToOrderAddress($quote->getBillingAddress()));
|
64 |
if ($quote->getBillingAddress()->getCustomerAddress()) {
|
65 |
$order->getBillingAddress()->setCustomerAddress($quote->getBillingAddress()->getCustomerAddress());
|
66 |
}
|
|
|
67 |
if (!$isVirtual) {
|
68 |
$order->setShippingAddress($this->_convertor->addressToOrderAddress($quote->getShippingAddress()));
|
69 |
if ($quote->getShippingAddress()->getCustomerAddress()) {
|
70 |
$order->getShippingAddress()->setCustomerAddress($quote->getShippingAddress()->getCustomerAddress());
|
71 |
}
|
72 |
}
|
|
|
73 |
$order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment()));
|
74 |
$order->getPayment()->setTransactionId($quote->getPayment()->getTransactionId());
|
75 |
-
$order->getPayment()->setAdditionalInformation(
|
|
|
|
|
|
|
76 |
if ($quote->getPayment()->getSimulationData()) {
|
77 |
-
$order->getPayment()->setAdditionalInformation(
|
|
|
|
|
|
|
78 |
}
|
|
|
79 |
if ($quote->getPayment()->getAmazonSequenceNumber()) {
|
80 |
-
$order->getPayment()->setAdditionalInformation(
|
|
|
|
|
|
|
81 |
}
|
|
|
82 |
if ($quote->getPayment()->getSkipOrderReferenceProcessing()) {
|
83 |
$order->getPayment()->setSkipOrderReferenceProcessing(true);
|
84 |
}
|
@@ -92,6 +112,7 @@ class Creativestyle_AmazonPayments_Model_Service_Quote extends Mage_Sales_Model_
|
|
92 |
if ($item->getParentItem()) {
|
93 |
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
94 |
}
|
|
|
95 |
$order->addItem($orderItem);
|
96 |
}
|
97 |
|
@@ -113,7 +134,6 @@ class Creativestyle_AmazonPayments_Model_Service_Quote extends Mage_Sales_Model_
|
|
113 |
$this->_inactivateQuote();
|
114 |
Mage::dispatchEvent('sales_model_service_quote_submit_success', array('order'=>$order, 'quote'=>$quote));
|
115 |
} catch (Exception $e) {
|
116 |
-
|
117 |
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
118 |
// reset customer ID's on exception, because customer not saved
|
119 |
$quote->getCustomer()->setId(null);
|
@@ -130,9 +150,10 @@ class Creativestyle_AmazonPayments_Model_Service_Quote extends Mage_Sales_Model_
|
|
130 |
Mage::dispatchEvent('sales_model_service_quote_submit_failure', array('order'=>$order, 'quote'=>$quote));
|
131 |
throw $e;
|
132 |
}
|
|
|
133 |
Mage::dispatchEvent('sales_model_service_quote_submit_after', array('order'=>$order, 'quote'=>$quote));
|
134 |
$this->_order = $order;
|
135 |
return $order;
|
136 |
}
|
137 |
-
|
138 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Service_Quote extends Mage_Sales_Model_Service_Quote
|
18 |
+
{
|
19 |
|
20 |
/**
|
21 |
* Validate quote data before converting to order
|
22 |
*
|
23 |
* @return Mage_Sales_Model_Service_Quote
|
24 |
*/
|
25 |
+
protected function _validate()
|
26 |
+
{
|
27 |
if (!$this->getQuote()->isVirtual()) {
|
28 |
$address = $this->getQuote()->getShippingAddress();
|
29 |
$method= $address->getShippingMethod();
|
40 |
return $this;
|
41 |
}
|
42 |
|
43 |
+
// @codingStandardsIgnoreStart
|
44 |
/**
|
45 |
* Submit the quote. Quote submit process will create the order based on quote data
|
|
|
46 |
* @return Mage_Sales_Model_Order
|
47 |
+
* @throws Exception
|
48 |
*/
|
49 |
+
public function submitOrder()
|
50 |
+
{
|
51 |
$this->_deleteNominalItems();
|
52 |
$this->_validate();
|
53 |
$quote = $this->_quote;
|
57 |
if ($quote->getCustomerId()) {
|
58 |
$transaction->addObject($quote->getCustomer());
|
59 |
}
|
60 |
+
|
61 |
$transaction->addObject($quote);
|
62 |
|
63 |
$quote->reserveOrderId();
|
66 |
} else {
|
67 |
$order = $this->_convertor->addressToOrder($quote->getShippingAddress());
|
68 |
}
|
69 |
+
|
70 |
$order->setBillingAddress($this->_convertor->addressToOrderAddress($quote->getBillingAddress()));
|
71 |
if ($quote->getBillingAddress()->getCustomerAddress()) {
|
72 |
$order->getBillingAddress()->setCustomerAddress($quote->getBillingAddress()->getCustomerAddress());
|
73 |
}
|
74 |
+
|
75 |
if (!$isVirtual) {
|
76 |
$order->setShippingAddress($this->_convertor->addressToOrderAddress($quote->getShippingAddress()));
|
77 |
if ($quote->getShippingAddress()->getCustomerAddress()) {
|
78 |
$order->getShippingAddress()->setCustomerAddress($quote->getShippingAddress()->getCustomerAddress());
|
79 |
}
|
80 |
}
|
81 |
+
|
82 |
$order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment()));
|
83 |
$order->getPayment()->setTransactionId($quote->getPayment()->getTransactionId());
|
84 |
+
$order->getPayment()->setAdditionalInformation(
|
85 |
+
'amazon_order_reference_id',
|
86 |
+
$quote->getPayment()->getTransactionId()
|
87 |
+
);
|
88 |
if ($quote->getPayment()->getSimulationData()) {
|
89 |
+
$order->getPayment()->setAdditionalInformation(
|
90 |
+
'_simulation_data',
|
91 |
+
$quote->getPayment()->getSimulationData()
|
92 |
+
);
|
93 |
}
|
94 |
+
|
95 |
if ($quote->getPayment()->getAmazonSequenceNumber()) {
|
96 |
+
$order->getPayment()->setAdditionalInformation(
|
97 |
+
'amazon_sequence_number',
|
98 |
+
$quote->getPayment()->getAmazonSequenceNumber()
|
99 |
+
);
|
100 |
}
|
101 |
+
|
102 |
if ($quote->getPayment()->getSkipOrderReferenceProcessing()) {
|
103 |
$order->getPayment()->setSkipOrderReferenceProcessing(true);
|
104 |
}
|
112 |
if ($item->getParentItem()) {
|
113 |
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
114 |
}
|
115 |
+
|
116 |
$order->addItem($orderItem);
|
117 |
}
|
118 |
|
134 |
$this->_inactivateQuote();
|
135 |
Mage::dispatchEvent('sales_model_service_quote_submit_success', array('order'=>$order, 'quote'=>$quote));
|
136 |
} catch (Exception $e) {
|
|
|
137 |
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
138 |
// reset customer ID's on exception, because customer not saved
|
139 |
$quote->getCustomer()->setId(null);
|
150 |
Mage::dispatchEvent('sales_model_service_quote_submit_failure', array('order'=>$order, 'quote'=>$quote));
|
151 |
throw $e;
|
152 |
}
|
153 |
+
|
154 |
Mage::dispatchEvent('sales_model_service_quote_submit_after', array('order'=>$order, 'quote'=>$quote));
|
155 |
$this->_order = $order;
|
156 |
return $order;
|
157 |
}
|
158 |
+
// @codingStandardsIgnoreEnd
|
159 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/Simulator.php
CHANGED
@@ -1,30 +1,37 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Model_Simulator
|
17 |
-
|
|
|
|
|
|
|
18 |
protected static $_availableSimulations = null;
|
19 |
|
20 |
-
protected static function _getConfig()
|
|
|
21 |
return Mage::getSingleton('amazonpayments/config');
|
22 |
}
|
23 |
|
24 |
-
|
|
|
|
|
25 |
if (null === self::$_availableSimulations) {
|
26 |
self::$_availableSimulations = array();
|
27 |
-
$objects = self::_getConfig()->
|
28 |
if (is_array($objects) && !empty($objects)) {
|
29 |
foreach ($objects as $objectKey => &$object) {
|
30 |
if (isset($object['states']) && is_array($object['states']) && !empty($object['states'])) {
|
@@ -37,6 +44,7 @@ class Creativestyle_AmazonPayments_Model_Simulator {
|
|
37 |
unset($state['reasons'][$reasonKey]);
|
38 |
}
|
39 |
}
|
|
|
40 |
if (empty($state['reasons'])) {
|
41 |
unset($object['states'][$stateKey]);
|
42 |
}
|
@@ -48,13 +56,17 @@ class Creativestyle_AmazonPayments_Model_Simulator {
|
|
48 |
}
|
49 |
}
|
50 |
}
|
|
|
51 |
self::$_availableSimulations = $objects;
|
52 |
}
|
53 |
}
|
|
|
54 |
return self::$_availableSimulations;
|
55 |
}
|
|
|
56 |
|
57 |
-
public static function getSimulationOptions($object, $state, $reason = null)
|
|
|
58 |
$availableSimulations = self::getAvailableSimulations();
|
59 |
if (isset($availableSimulations[$object])) {
|
60 |
if (isset($availableSimulations[$object]['states'][$state])) {
|
@@ -63,15 +75,20 @@ class Creativestyle_AmazonPayments_Model_Simulator {
|
|
63 |
return $availableSimulations[$object]['states'][$state]['simulation_options'];
|
64 |
}
|
65 |
} else {
|
66 |
-
if (isset(
|
67 |
-
|
|
|
|
|
|
|
68 |
}
|
69 |
}
|
70 |
}
|
71 |
}
|
|
|
72 |
return null;
|
73 |
}
|
74 |
|
|
|
75 |
/**
|
76 |
* Get simulation string for use in API calls
|
77 |
*
|
@@ -79,16 +96,18 @@ class Creativestyle_AmazonPayments_Model_Simulator {
|
|
79 |
* @param string $transactionType
|
80 |
* @return string
|
81 |
*/
|
82 |
-
public static function simulate(Varien_Object $payment, $transactionType = null)
|
|
|
83 |
// object state simulations are available only in the sandbox mode
|
84 |
-
if (null !== $transactionType && self::_getConfig()->
|
85 |
$availableSimulations = self::getAvailableSimulations();
|
86 |
// check if the requested transaction type is on the list of allowed simulations
|
87 |
if (array_key_exists($transactionType, $availableSimulations)) {
|
88 |
try {
|
89 |
$simulationData = $payment->getAdditionalInformation('_simulation_data');
|
90 |
// check if payment contains any simulation and for which transaction type
|
91 |
-
if (!empty($simulationData) && array_key_exists('object', $simulationData)
|
|
|
92 |
$simulation = array(
|
93 |
'SandboxSimulation' => array(
|
94 |
'State' => $simulationData['state']
|
@@ -97,6 +116,7 @@ class Creativestyle_AmazonPayments_Model_Simulator {
|
|
97 |
if (array_key_exists('reason_code', $simulationData)) {
|
98 |
$simulation['SandboxSimulation']['ReasonCode'] = $simulationData['reason_code'];
|
99 |
}
|
|
|
100 |
if (array_key_exists('options', $simulationData) && is_array($simulationData['options'])) {
|
101 |
foreach ($simulationData['options'] as $option => $value) {
|
102 |
if (is_array($value) && isset($value['@']['type']) && isset($value[0])) {
|
@@ -113,11 +133,14 @@ class Creativestyle_AmazonPayments_Model_Simulator {
|
|
113 |
}
|
114 |
}
|
115 |
}
|
|
|
116 |
$simulationString = Mage::helper('core')->jsonEncode($simulation);
|
117 |
if ($transactionType == 'OrderReference' && $simulationData['state'] == 'Closed') {
|
118 |
$amazonOrderReferenceId = $payment->getAdditionalInformation('amazon_order_reference_id');
|
119 |
-
Mage::getSingleton('amazonpayments/api_advanced')
|
|
|
120 |
}
|
|
|
121 |
$payment->setAdditionalInformation('_simulation_data', null);
|
122 |
return $simulationString;
|
123 |
}
|
@@ -126,7 +149,8 @@ class Creativestyle_AmazonPayments_Model_Simulator {
|
|
126 |
}
|
127 |
}
|
128 |
}
|
|
|
129 |
return null;
|
130 |
}
|
131 |
-
|
132 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_Simulator
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @var array|null
|
21 |
+
*/
|
22 |
protected static $_availableSimulations = null;
|
23 |
|
24 |
+
protected static function _getConfig()
|
25 |
+
{
|
26 |
return Mage::getSingleton('amazonpayments/config');
|
27 |
}
|
28 |
|
29 |
+
// @codingStandardsIgnoreStart
|
30 |
+
public static function getAvailableSimulations()
|
31 |
+
{
|
32 |
if (null === self::$_availableSimulations) {
|
33 |
self::$_availableSimulations = array();
|
34 |
+
$objects = self::_getConfig()->getGlobalConfigData('objects');
|
35 |
if (is_array($objects) && !empty($objects)) {
|
36 |
foreach ($objects as $objectKey => &$object) {
|
37 |
if (isset($object['states']) && is_array($object['states']) && !empty($object['states'])) {
|
44 |
unset($state['reasons'][$reasonKey]);
|
45 |
}
|
46 |
}
|
47 |
+
|
48 |
if (empty($state['reasons'])) {
|
49 |
unset($object['states'][$stateKey]);
|
50 |
}
|
56 |
}
|
57 |
}
|
58 |
}
|
59 |
+
|
60 |
self::$_availableSimulations = $objects;
|
61 |
}
|
62 |
}
|
63 |
+
|
64 |
return self::$_availableSimulations;
|
65 |
}
|
66 |
+
// @codingStandardsIgnoreEnd
|
67 |
|
68 |
+
public static function getSimulationOptions($object, $state, $reason = null)
|
69 |
+
{
|
70 |
$availableSimulations = self::getAvailableSimulations();
|
71 |
if (isset($availableSimulations[$object])) {
|
72 |
if (isset($availableSimulations[$object]['states'][$state])) {
|
75 |
return $availableSimulations[$object]['states'][$state]['simulation_options'];
|
76 |
}
|
77 |
} else {
|
78 |
+
if (isset(
|
79 |
+
$availableSimulations[$object]['states'][$state]['reasons'][$reason]['simulation_options']
|
80 |
+
)) {
|
81 |
+
return
|
82 |
+
$availableSimulations[$object]['states'][$state]['reasons'][$reason]['simulation_options'];
|
83 |
}
|
84 |
}
|
85 |
}
|
86 |
}
|
87 |
+
|
88 |
return null;
|
89 |
}
|
90 |
|
91 |
+
// @codingStandardsIgnoreStart
|
92 |
/**
|
93 |
* Get simulation string for use in API calls
|
94 |
*
|
96 |
* @param string $transactionType
|
97 |
* @return string
|
98 |
*/
|
99 |
+
public static function simulate(Varien_Object $payment, $transactionType = null)
|
100 |
+
{
|
101 |
// object state simulations are available only in the sandbox mode
|
102 |
+
if (null !== $transactionType && self::_getConfig()->isSandboxActive()) {
|
103 |
$availableSimulations = self::getAvailableSimulations();
|
104 |
// check if the requested transaction type is on the list of allowed simulations
|
105 |
if (array_key_exists($transactionType, $availableSimulations)) {
|
106 |
try {
|
107 |
$simulationData = $payment->getAdditionalInformation('_simulation_data');
|
108 |
// check if payment contains any simulation and for which transaction type
|
109 |
+
if (!empty($simulationData) && array_key_exists('object', $simulationData)
|
110 |
+
&& $simulationData['object'] == $transactionType) {
|
111 |
$simulation = array(
|
112 |
'SandboxSimulation' => array(
|
113 |
'State' => $simulationData['state']
|
116 |
if (array_key_exists('reason_code', $simulationData)) {
|
117 |
$simulation['SandboxSimulation']['ReasonCode'] = $simulationData['reason_code'];
|
118 |
}
|
119 |
+
|
120 |
if (array_key_exists('options', $simulationData) && is_array($simulationData['options'])) {
|
121 |
foreach ($simulationData['options'] as $option => $value) {
|
122 |
if (is_array($value) && isset($value['@']['type']) && isset($value[0])) {
|
133 |
}
|
134 |
}
|
135 |
}
|
136 |
+
|
137 |
$simulationString = Mage::helper('core')->jsonEncode($simulation);
|
138 |
if ($transactionType == 'OrderReference' && $simulationData['state'] == 'Closed') {
|
139 |
$amazonOrderReferenceId = $payment->getAdditionalInformation('amazon_order_reference_id');
|
140 |
+
Mage::getSingleton('amazonpayments/api_advanced')
|
141 |
+
->closeOrderReference($amazonOrderReferenceId, $simulationString);
|
142 |
}
|
143 |
+
|
144 |
$payment->setAdditionalInformation('_simulation_data', null);
|
145 |
return $simulationString;
|
146 |
}
|
149 |
}
|
150 |
}
|
151 |
}
|
152 |
+
|
153 |
return null;
|
154 |
}
|
155 |
+
// @codingStandardsIgnoreEnd
|
156 |
}
|
app/code/community/Creativestyle/AmazonPayments/Model/System/Config/Backend/DataPolling/Cron.php
CHANGED
@@ -1,22 +1,26 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
-
class Creativestyle_AmazonPayments_Model_System_Config_Backend_DataPolling_Cron extends Mage_Core_Model_Config_Data
|
|
|
16 |
|
17 |
const XML_PATH_DATA_POLLING_CRON_EXPR = 'crontab/jobs/amazonpayments_advanced_data_poll/schedule/cron_expr';
|
18 |
|
19 |
-
protected function _afterSave()
|
|
|
20 |
$cronExprModel = Mage::getModel('core/config_data')->load(self::XML_PATH_DATA_POLLING_CRON_EXPR, 'path');
|
21 |
if (!$this->getData('groups/general/fields/ipn_active/value')) {
|
22 |
$frequency = $this->getData('groups/general/fields/polling_frequency/value');
|
@@ -36,20 +40,20 @@ class Creativestyle_AmazonPayments_Model_System_Config_Backend_DataPolling_Cron
|
|
36 |
} else if ($minutes) {
|
37 |
$cronExpr = sprintf('*/%s * * * *', $minutes);
|
38 |
}
|
|
|
39 |
try {
|
40 |
$cronExprModel->setValue($cronExpr)
|
41 |
->setPath(self::XML_PATH_DATA_POLLING_CRON_EXPR)
|
42 |
->save();
|
43 |
} catch (Exception $e) {
|
44 |
-
|
45 |
}
|
46 |
} elseif ($cronExprModel->getId()) {
|
47 |
try {
|
48 |
$cronExprModel->delete();
|
49 |
} catch (Exception $e) {
|
50 |
-
|
51 |
}
|
52 |
}
|
53 |
}
|
54 |
-
|
55 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Model_System_Config_Backend_DataPolling_Cron extends Mage_Core_Model_Config_Data
|
18 |
+
{
|
19 |
|
20 |
const XML_PATH_DATA_POLLING_CRON_EXPR = 'crontab/jobs/amazonpayments_advanced_data_poll/schedule/cron_expr';
|
21 |
|
22 |
+
protected function _afterSave()
|
23 |
+
{
|
24 |
$cronExprModel = Mage::getModel('core/config_data')->load(self::XML_PATH_DATA_POLLING_CRON_EXPR, 'path');
|
25 |
if (!$this->getData('groups/general/fields/ipn_active/value')) {
|
26 |
$frequency = $this->getData('groups/general/fields/polling_frequency/value');
|
40 |
} else if ($minutes) {
|
41 |
$cronExpr = sprintf('*/%s * * * *', $minutes);
|
42 |
}
|
43 |
+
|
44 |
try {
|
45 |
$cronExprModel->setValue($cronExpr)
|
46 |
->setPath(self::XML_PATH_DATA_POLLING_CRON_EXPR)
|
47 |
->save();
|
48 |
} catch (Exception $e) {
|
49 |
+
Mage::throwException('Unable to save cron expression.');
|
50 |
}
|
51 |
} elseif ($cronExprModel->getId()) {
|
52 |
try {
|
53 |
$cronExprModel->delete();
|
54 |
} catch (Exception $e) {
|
55 |
+
Mage::throwException('Unable to delete cron expression.');
|
56 |
}
|
57 |
}
|
58 |
}
|
|
|
59 |
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/DebugController.php
CHANGED
@@ -1,47 +1,63 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_DebugController extends Mage_Adminhtml_Controller_Action
|
17 |
-
|
18 |
-
protected function _initAction($actionMenuItem, $actionBreadcrumbs)
|
|
|
19 |
$this->_setActiveMenu('creativestyle/amazonpayments/' . $actionMenuItem);
|
20 |
foreach ($actionBreadcrumbs as $breadcrumb) {
|
21 |
$this->_addBreadcrumb($this->__($breadcrumb), $this->__($breadcrumb))
|
22 |
->_title($breadcrumb);
|
23 |
}
|
|
|
24 |
return $this;
|
25 |
}
|
26 |
|
27 |
-
public function indexAction()
|
|
|
28 |
$this->loadLayout()
|
29 |
->_initAction('debug', array('Amazon Pay and Login with Amazon', 'Debug data'))
|
30 |
->renderLayout();
|
31 |
}
|
32 |
|
33 |
-
public function downloadAction()
|
|
|
34 |
$debugData = Mage::helper('amazonpayments/debug')->getDebugData();
|
35 |
-
$filename = str_replace(
|
36 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
$debugData = base64_encode(serialize($debugData));
|
38 |
Mage::app()->getResponse()->setHeader('Content-type', 'application/base64');
|
39 |
Mage::app()->getResponse()->setHeader('Content-disposition', 'attachment;filename=' . $filename);
|
40 |
Mage::app()->getResponse()->setBody($debugData);
|
41 |
}
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
return Mage::getSingleton('admin/session')->isAllowed('admin/creativestyle/amazonpayments/debug');
|
45 |
}
|
46 |
-
|
47 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_DebugController extends Mage_Adminhtml_Controller_Action
|
18 |
+
{
|
19 |
+
protected function _initAction($actionMenuItem, $actionBreadcrumbs)
|
20 |
+
{
|
21 |
$this->_setActiveMenu('creativestyle/amazonpayments/' . $actionMenuItem);
|
22 |
foreach ($actionBreadcrumbs as $breadcrumb) {
|
23 |
$this->_addBreadcrumb($this->__($breadcrumb), $this->__($breadcrumb))
|
24 |
->_title($breadcrumb);
|
25 |
}
|
26 |
+
|
27 |
return $this;
|
28 |
}
|
29 |
|
30 |
+
public function indexAction()
|
31 |
+
{
|
32 |
$this->loadLayout()
|
33 |
->_initAction('debug', array('Amazon Pay and Login with Amazon', 'Debug data'))
|
34 |
->renderLayout();
|
35 |
}
|
36 |
|
37 |
+
public function downloadAction()
|
38 |
+
{
|
39 |
$debugData = Mage::helper('amazonpayments/debug')->getDebugData();
|
40 |
+
$filename = str_replace(
|
41 |
+
array('.', '/', '\\'),
|
42 |
+
array('_'),
|
43 |
+
// @codingStandardsIgnoreStart
|
44 |
+
parse_url(
|
45 |
+
Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL),
|
46 |
+
PHP_URL_HOST
|
47 |
+
)
|
48 |
+
// @codingStandardsIgnoreEnd
|
49 |
+
) . '_apa_debug_' . Mage::getModel('core/date')->gmtTimestamp() . '.dmp';
|
50 |
$debugData = base64_encode(serialize($debugData));
|
51 |
Mage::app()->getResponse()->setHeader('Content-type', 'application/base64');
|
52 |
Mage::app()->getResponse()->setHeader('Content-disposition', 'attachment;filename=' . $filename);
|
53 |
Mage::app()->getResponse()->setBody($debugData);
|
54 |
}
|
55 |
|
56 |
+
/**
|
57 |
+
* @inheritdoc
|
58 |
+
*/
|
59 |
+
protected function _isAllowed()
|
60 |
+
{
|
61 |
return Mage::getSingleton('admin/session')->isAllowed('admin/creativestyle/amazonpayments/debug');
|
62 |
}
|
|
|
63 |
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/Log/ApiController.php
CHANGED
@@ -1,73 +1,38 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_Log_ApiController extends
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
->_setActiveMenu('creativestyle/amazonpayments/log/api')
|
29 |
-
->_addBreadcrumb($this->__('Amazon Pay'), $this->__('Amazon Pay'))
|
30 |
-
->_addBreadcrumb($this->__('Log preview'), $this->__('Log preview'))
|
31 |
-
->_addBreadcrumb($this->__('API calls'), $this->__('API calls'));
|
32 |
-
return $this;
|
33 |
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
39 |
}
|
40 |
-
|
41 |
-
public function viewAction() {
|
42 |
-
$id = $this->getRequest()->getParam('id');
|
43 |
-
$log = $this->_getCollection()->getItemById($id);
|
44 |
-
if (is_object($log) && $log->getId()) {
|
45 |
-
$this->_title($this->__('Amazon Pay'))->_title($this->__('Log preview'))->_title($this->__('API calls'))->_title($this->__('Preview'));
|
46 |
-
$this->_initAction();
|
47 |
-
$this->_addContent($this->getLayout()->createBlock('amazonpayments/adminhtml_log_api_view')->setLog($log));
|
48 |
-
$this->renderLayout();
|
49 |
-
} else {
|
50 |
-
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amazonpayments')->__('Log does not exist'));
|
51 |
-
$this->_redirect('*/*/');
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
public function downloadAction() {
|
56 |
-
$logFilePath = Creativestyle_AmazonPayments_Model_Logger::getAbsoluteLogFilePath('api');
|
57 |
-
if (file_exists($logFilePath)) {
|
58 |
-
$output = implode($this->_getConfig()->getLogDelimiter(), Creativestyle_AmazonPayments_Model_Logger::getColumnMapping('api')) . "\n";
|
59 |
-
$output .= file_get_contents($logFilePath);
|
60 |
-
Mage::app()->getResponse()->setHeader('Content-type', 'text/csv');
|
61 |
-
Mage::app()->getResponse()->setHeader('Content-disposition', 'attachment;filename=' . basename($logFilePath) . '.csv');
|
62 |
-
Mage::app()->getResponse()->setHeader('Content-Length', filesize($logFilePath));
|
63 |
-
Mage::app()->getResponse()->setBody($output);
|
64 |
-
} else {
|
65 |
-
$this->_redirect('*/*/');
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
protected function _isAllowed() {
|
70 |
-
return Mage::getSingleton('admin/session')->isAllowed('admin/creativestyle/amazonpayments/log/api');
|
71 |
-
}
|
72 |
-
|
73 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_Log_ApiController extends
|
18 |
+
Creativestyle_AmazonPayments_Controller_Adminhtml_Log_Action
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'api';
|
21 |
+
const LOG_TITLE = 'API calls';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @inheritdoc
|
25 |
+
*/
|
26 |
+
public function getLogType()
|
27 |
+
{
|
28 |
+
return self::LOG_TYPE;
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
+
/**
|
32 |
+
* @inheritdoc
|
33 |
+
*/
|
34 |
+
public function getTitle()
|
35 |
+
{
|
36 |
+
return self::LOG_TITLE;
|
37 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/Log/ExceptionController.php
CHANGED
@@ -1,73 +1,38 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_Log_ExceptionController extends
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
->_setActiveMenu('creativestyle/amazonpayments/log/exception')
|
29 |
-
->_addBreadcrumb($this->__('Amazon Pay'), $this->__('Amazon Pay'))
|
30 |
-
->_addBreadcrumb($this->__('Log preview'), $this->__('Log preview'))
|
31 |
-
->_addBreadcrumb($this->__('Exceptions'), $this->__('Exceptions'));
|
32 |
-
return $this;
|
33 |
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
39 |
}
|
40 |
-
|
41 |
-
public function viewAction() {
|
42 |
-
$id = $this->getRequest()->getParam('id');
|
43 |
-
$log = $this->_getCollection()->getItemById($id);
|
44 |
-
if (is_object($log) && $log->getId()) {
|
45 |
-
$this->_title($this->__('Amazon Pay'))->_title($this->__('Log preview'))->_title($this->__('Exceptions'))->_title($this->__('Preview'));
|
46 |
-
$this->_initAction();
|
47 |
-
$this->_addContent($this->getLayout()->createBlock('amazonpayments/adminhtml_log_exception_view')->setLog($log));
|
48 |
-
$this->renderLayout();
|
49 |
-
} else {
|
50 |
-
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amazonpayments')->__('Log does not exist'));
|
51 |
-
$this->_redirect('*/*/');
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
public function downloadAction() {
|
56 |
-
$logFilePath = Creativestyle_AmazonPayments_Model_Logger::getAbsoluteLogFilePath('exception');
|
57 |
-
if (file_exists($logFilePath)) {
|
58 |
-
$output = implode($this->_getConfig()->getLogDelimiter(), Creativestyle_AmazonPayments_Model_Logger::getColumnMapping('exception')) . "\n";
|
59 |
-
$output .= file_get_contents($logFilePath);
|
60 |
-
Mage::app()->getResponse()->setHeader('Content-type', 'text/csv');
|
61 |
-
Mage::app()->getResponse()->setHeader('Content-disposition', 'attachment;filename=' . basename($logFilePath) . '.csv');
|
62 |
-
Mage::app()->getResponse()->setHeader('Content-Length', filesize($logFilePath));
|
63 |
-
Mage::app()->getResponse()->setBody($output);
|
64 |
-
} else {
|
65 |
-
$this->_redirect('*/*/');
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
protected function _isAllowed() {
|
70 |
-
return Mage::getSingleton('admin/session')->isAllowed('admin/creativestyle/amazonpayments/log/exception');
|
71 |
-
}
|
72 |
-
|
73 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_Log_ExceptionController extends
|
18 |
+
Creativestyle_AmazonPayments_Controller_Adminhtml_Log_Action
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'exception';
|
21 |
+
const LOG_TITLE = 'Exceptions';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @inheritdoc
|
25 |
+
*/
|
26 |
+
public function getLogType()
|
27 |
+
{
|
28 |
+
return self::LOG_TYPE;
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
+
/**
|
32 |
+
* @inheritdoc
|
33 |
+
*/
|
34 |
+
public function getTitle()
|
35 |
+
{
|
36 |
+
return self::LOG_TITLE;
|
37 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/Log/IpnController.php
CHANGED
@@ -1,73 +1,38 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_Log_IpnController extends
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
->_setActiveMenu('creativestyle/amazonpayments/log/ipn')
|
29 |
-
->_addBreadcrumb($this->__('Amazon Pay'), $this->__('Amazon Pay'))
|
30 |
-
->_addBreadcrumb($this->__('Log preview'), $this->__('Log preview'))
|
31 |
-
->_addBreadcrumb($this->__('Notifications'), $this->__('Notifications'));
|
32 |
-
return $this;
|
33 |
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
39 |
}
|
40 |
-
|
41 |
-
public function viewAction() {
|
42 |
-
$id = $this->getRequest()->getParam('id');
|
43 |
-
$log = $this->_getCollection()->getItemById($id);
|
44 |
-
if (is_object($log) && $log->getId()) {
|
45 |
-
$this->_title($this->__('Amazon Pay'))->_title($this->__('Log preview'))->_title($this->__('Notifications'))->_title($this->__('Preview'));
|
46 |
-
$this->_initAction();
|
47 |
-
$this->_addContent($this->getLayout()->createBlock('amazonpayments/adminhtml_log_ipn_view')->setLog($log));
|
48 |
-
$this->renderLayout();
|
49 |
-
} else {
|
50 |
-
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amazonpayments')->__('Log does not exist'));
|
51 |
-
$this->_redirect('*/*/');
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
public function downloadAction() {
|
56 |
-
$logFilePath = Creativestyle_AmazonPayments_Model_Logger::getAbsoluteLogFilePath('ipn');
|
57 |
-
if (file_exists($logFilePath)) {
|
58 |
-
$output = implode($this->_getConfig()->getLogDelimiter(), Creativestyle_AmazonPayments_Model_Logger::getColumnMapping('ipn')) . "\n";
|
59 |
-
$output .= file_get_contents($logFilePath);
|
60 |
-
Mage::app()->getResponse()->setHeader('Content-type', 'text/csv');
|
61 |
-
Mage::app()->getResponse()->setHeader('Content-disposition', 'attachment;filename=' . basename($logFilePath) . '.csv');
|
62 |
-
Mage::app()->getResponse()->setHeader('Content-Length', filesize($logFilePath));
|
63 |
-
Mage::app()->getResponse()->setBody($output);
|
64 |
-
} else {
|
65 |
-
$this->_redirect('*/*/');
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
protected function _isAllowed() {
|
70 |
-
return Mage::getSingleton('admin/session')->isAllowed('admin/creativestyle/amazonpayments/log/ipn');
|
71 |
-
}
|
72 |
-
|
73 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_Log_IpnController extends
|
18 |
+
Creativestyle_AmazonPayments_Controller_Adminhtml_Log_Action
|
19 |
+
{
|
20 |
+
const LOG_TYPE = 'ipn';
|
21 |
+
const LOG_TITLE = 'Notifications';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @inheritdoc
|
25 |
+
*/
|
26 |
+
public function getLogType()
|
27 |
+
{
|
28 |
+
return self::LOG_TYPE;
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
+
/**
|
32 |
+
* @inheritdoc
|
33 |
+
*/
|
34 |
+
public function getTitle()
|
35 |
+
{
|
36 |
+
return self::LOG_TITLE;
|
37 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/OrderController.php
CHANGED
@@ -1,31 +1,48 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_OrderController extends Mage_Adminhtml_Controller_Action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
$orderId = $this->getRequest()->getParam('order_id', null);
|
20 |
if (null !== $orderId) {
|
21 |
try {
|
|
|
22 |
$order = Mage::getModel('sales/order')->load($orderId);
|
23 |
if ($order->getId()) {
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
->setBaseAmountAuthorized($order->getBaseTotalDue())
|
28 |
-
->getMethodInstance()->authorize($
|
29 |
$order->save();
|
30 |
}
|
31 |
}
|
@@ -36,13 +53,20 @@ class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_OrderController exte
|
|
36 |
$this->_getSession()->addError($this->__('Failed to authorize the payment.'));
|
37 |
Mage::logException($e);
|
38 |
}
|
|
|
39 |
$this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
|
40 |
return;
|
41 |
}
|
|
|
42 |
$this->_redirect('adminhtml/sales_order');
|
43 |
}
|
44 |
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_OrderController extends Mage_Adminhtml_Controller_Action
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Returns Amazon Pay helper
|
21 |
+
*
|
22 |
+
* @return Creativestyle_AmazonPayments_Helper_Data
|
23 |
+
*/
|
24 |
+
protected function _getHelper()
|
25 |
+
{
|
26 |
+
return Mage::helper('amazonpayments');
|
27 |
+
}
|
28 |
|
29 |
+
/**
|
30 |
+
* Order manual authorization action
|
31 |
+
*/
|
32 |
+
public function authorizeAction()
|
33 |
+
{
|
34 |
$orderId = $this->getRequest()->getParam('order_id', null);
|
35 |
if (null !== $orderId) {
|
36 |
try {
|
37 |
+
/** @var Mage_Sales_Model_Order $order */
|
38 |
$order = Mage::getModel('sales/order')->load($orderId);
|
39 |
if ($order->getId()) {
|
40 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
41 |
+
$payment = $order->getPayment();
|
42 |
+
if (in_array($payment->getMethod(), $this->_getHelper()->getAvailablePaymentMethods())) {
|
43 |
+
$payment->setAmountAuthorized($order->getTotalDue())
|
44 |
->setBaseAmountAuthorized($order->getBaseTotalDue())
|
45 |
+
->getMethodInstance()->authorize($payment, $order->getBaseTotalDue());
|
46 |
$order->save();
|
47 |
}
|
48 |
}
|
53 |
$this->_getSession()->addError($this->__('Failed to authorize the payment.'));
|
54 |
Mage::logException($e);
|
55 |
}
|
56 |
+
|
57 |
$this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
|
58 |
return;
|
59 |
}
|
60 |
+
|
61 |
$this->_redirect('adminhtml/sales_order');
|
62 |
}
|
63 |
|
64 |
+
/**
|
65 |
+
* @inheritdoc
|
66 |
+
*/
|
67 |
+
protected function _isAllowed()
|
68 |
+
{
|
69 |
+
return Mage::getSingleton('admin/session')
|
70 |
+
->isAllowed('sales/order/actions/amazonpayments_authorize');
|
71 |
}
|
72 |
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/Amazonpayments/SystemController.php
CHANGED
@@ -1,21 +1,23 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_SystemController extends Mage_Adminhtml_Controller_Action
|
17 |
-
|
18 |
-
protected function _mapRegion($region)
|
|
|
19 |
switch ($region) {
|
20 |
case 'EUR':
|
21 |
return 'de';
|
@@ -26,56 +28,72 @@ class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_SystemController ext
|
|
26 |
}
|
27 |
}
|
28 |
|
29 |
-
protected function _getRegionLabel($code)
|
30 |
-
|
|
|
|
|
31 |
}
|
32 |
|
33 |
-
|
|
|
|
|
34 |
$result = array('valid' => true, 'messages' => array());
|
|
|
35 |
if (!$merchantId) {
|
36 |
$result['valid'] = false;
|
37 |
$result['messages'][] = $this->__('Merchant ID is missing.');
|
38 |
}
|
|
|
39 |
if (!$accessKey) {
|
40 |
$result['valid'] = false;
|
41 |
$result['messages'][] = $this->__('Access Key ID is missing.');
|
42 |
}
|
|
|
43 |
if (!$secretKey) {
|
44 |
$result['valid'] = false;
|
45 |
$result['messages'][] = $this->__('Secret Key is missing.');
|
46 |
}
|
|
|
47 |
if (!$clientId) {
|
48 |
$result['valid'] = false;
|
49 |
$result['messages'][] = $this->__('Client ID is missing.');
|
50 |
}
|
|
|
51 |
if (!$result['valid']) {
|
52 |
return $result;
|
53 |
}
|
54 |
|
55 |
try {
|
56 |
-
$api = new OffAmazonPaymentsService_Client(
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
74 |
$api->getOrderReferenceDetails($apiRequest);
|
75 |
} catch (OffAmazonPaymentsService_Exception $e) {
|
76 |
switch ($e->getErrorCode()) {
|
77 |
case 'InvalidOrderReferenceId':
|
78 |
-
$result['messages'][] = $this->__(
|
|
|
|
|
79 |
break;
|
80 |
case 'InvalidParameterValue':
|
81 |
$result['valid'] = false;
|
@@ -99,10 +117,13 @@ class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_SystemController ext
|
|
99 |
$result['valid'] = false;
|
100 |
$result['messages'][] = $this->__('Whoops! Something went wrong while validating your account.');
|
101 |
}
|
|
|
102 |
return $result;
|
103 |
}
|
|
|
104 |
|
105 |
-
public function validateAction()
|
|
|
106 |
$merchantId = $this->getRequest()->getPost('merchant_id', null);
|
107 |
$accessKey = $this->getRequest()->getPost('access_key', null);
|
108 |
$secretKey = $this->getRequest()->getPost('secret_key', null);
|
@@ -122,8 +143,11 @@ class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_SystemController ext
|
|
122 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
123 |
}
|
124 |
|
125 |
-
|
|
|
|
|
|
|
|
|
126 |
return Mage::getSingleton('admin/session')->isAllowed('admin/system/config/amazonpayments');
|
127 |
}
|
128 |
-
|
129 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2015 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2015 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Adminhtml_Amazonpayments_SystemController extends Mage_Adminhtml_Controller_Action
|
18 |
+
{
|
19 |
+
protected function _mapRegion($region)
|
20 |
+
{
|
21 |
switch ($region) {
|
22 |
case 'EUR':
|
23 |
return 'de';
|
28 |
}
|
29 |
}
|
30 |
|
31 |
+
protected function _getRegionLabel($code)
|
32 |
+
{
|
33 |
+
return Mage::getSingleton('amazonpayments/lookup_accountRegion')
|
34 |
+
->getRegionLabelByCode($code);
|
35 |
}
|
36 |
|
37 |
+
// @codingStandardsIgnoreStart
|
38 |
+
protected function _checkCredentials($merchantId, $accessKey, $secretKey, $clientId, $region)
|
39 |
+
{
|
40 |
$result = array('valid' => true, 'messages' => array());
|
41 |
+
|
42 |
if (!$merchantId) {
|
43 |
$result['valid'] = false;
|
44 |
$result['messages'][] = $this->__('Merchant ID is missing.');
|
45 |
}
|
46 |
+
|
47 |
if (!$accessKey) {
|
48 |
$result['valid'] = false;
|
49 |
$result['messages'][] = $this->__('Access Key ID is missing.');
|
50 |
}
|
51 |
+
|
52 |
if (!$secretKey) {
|
53 |
$result['valid'] = false;
|
54 |
$result['messages'][] = $this->__('Secret Key is missing.');
|
55 |
}
|
56 |
+
|
57 |
if (!$clientId) {
|
58 |
$result['valid'] = false;
|
59 |
$result['messages'][] = $this->__('Client ID is missing.');
|
60 |
}
|
61 |
+
|
62 |
if (!$result['valid']) {
|
63 |
return $result;
|
64 |
}
|
65 |
|
66 |
try {
|
67 |
+
$api = new OffAmazonPaymentsService_Client(
|
68 |
+
array(
|
69 |
+
'merchantId' => trim($merchantId),
|
70 |
+
'accessKey' => trim($accessKey),
|
71 |
+
'secretKey' => trim($secretKey),
|
72 |
+
'applicationName' => 'Creativestyle Amazon Payments Advanced Magento Extension',
|
73 |
+
'applicationVersion'
|
74 |
+
=> Mage::getConfig()->getNode('modules/Creativestyle_AmazonPayments/version'),
|
75 |
+
'region' => $this->_mapRegion($region),
|
76 |
+
'environment' => 'sandbox',
|
77 |
+
'serviceURL' => '',
|
78 |
+
'widgetURL' => '',
|
79 |
+
'caBundleFile' => '',
|
80 |
+
'clientId' => '',
|
81 |
+
'cnName' => 'sns.amazonaws.com'
|
82 |
+
)
|
83 |
+
);
|
84 |
+
$apiRequest = new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest(
|
85 |
+
array(
|
86 |
+
'SellerId' => trim($merchantId),
|
87 |
+
'AmazonOrderReferenceId' => 'P00-0000000-0000000'
|
88 |
+
)
|
89 |
+
);
|
90 |
$api->getOrderReferenceDetails($apiRequest);
|
91 |
} catch (OffAmazonPaymentsService_Exception $e) {
|
92 |
switch ($e->getErrorCode()) {
|
93 |
case 'InvalidOrderReferenceId':
|
94 |
+
$result['messages'][] = $this->__(
|
95 |
+
'Congratulations! Your Amazon Payments account settings seem to be OK.'
|
96 |
+
);
|
97 |
break;
|
98 |
case 'InvalidParameterValue':
|
99 |
$result['valid'] = false;
|
117 |
$result['valid'] = false;
|
118 |
$result['messages'][] = $this->__('Whoops! Something went wrong while validating your account.');
|
119 |
}
|
120 |
+
|
121 |
return $result;
|
122 |
}
|
123 |
+
// @codingStandardsIgnoreEnd
|
124 |
|
125 |
+
public function validateAction()
|
126 |
+
{
|
127 |
$merchantId = $this->getRequest()->getPost('merchant_id', null);
|
128 |
$accessKey = $this->getRequest()->getPost('access_key', null);
|
129 |
$secretKey = $this->getRequest()->getPost('secret_key', null);
|
143 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
144 |
}
|
145 |
|
146 |
+
/**
|
147 |
+
* @inheritdoc
|
148 |
+
*/
|
149 |
+
protected function _isAllowed()
|
150 |
+
{
|
151 |
return Mage::getSingleton('admin/session')->isAllowed('admin/system/config/amazonpayments');
|
152 |
}
|
|
|
153 |
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/CheckoutController.php
DELETED
@@ -1,407 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file is part of the official Amazon Payments Advanced extension
|
5 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
6 |
-
* All rights reserved
|
7 |
-
*
|
8 |
-
* Reuse or modification of this source code is not allowed
|
9 |
-
* without written permission from creativestyle GmbH
|
10 |
-
*
|
11 |
-
* @category Creativestyle
|
12 |
-
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
14 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
15 |
-
*/
|
16 |
-
class Creativestyle_AmazonPayments_Advanced_CheckoutController extends Mage_Core_Controller_Front_Action {
|
17 |
-
|
18 |
-
protected $_orderReferenceId = null;
|
19 |
-
|
20 |
-
protected $_accessToken = null;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @return Creativestyle_AmazonPayments_Model_Checkout
|
24 |
-
*/
|
25 |
-
protected function _getCheckout() {
|
26 |
-
return Mage::getSingleton('amazonpayments/checkout');
|
27 |
-
}
|
28 |
-
|
29 |
-
protected function _getCheckoutSession() {
|
30 |
-
return Mage::getSingleton('checkout/session');
|
31 |
-
}
|
32 |
-
|
33 |
-
protected function _getOrderReferenceId() {
|
34 |
-
return $this->_orderReferenceId;
|
35 |
-
}
|
36 |
-
|
37 |
-
protected function _getAccessToken() {
|
38 |
-
return $this->_accessToken;
|
39 |
-
}
|
40 |
-
|
41 |
-
protected function _getApi() {
|
42 |
-
return Mage::getModel('amazonpayments/api_advanced');
|
43 |
-
}
|
44 |
-
|
45 |
-
protected function _getQuote() {
|
46 |
-
return $this->_getCheckout()->getQuote();
|
47 |
-
}
|
48 |
-
|
49 |
-
protected function _getShippingMethodsHtml() {
|
50 |
-
$layout = $this->getLayout();
|
51 |
-
$update = $layout->getUpdate();
|
52 |
-
$update->load('amazonpayments_advanced_shippingmethod');
|
53 |
-
$layout->generateXml();
|
54 |
-
$layout->generateBlocks();
|
55 |
-
$output = $layout->getOutput();
|
56 |
-
return $output;
|
57 |
-
}
|
58 |
-
|
59 |
-
protected function _getReviewHtml() {
|
60 |
-
$layout = $this->getLayout();
|
61 |
-
$update = $layout->getUpdate();
|
62 |
-
$update->load('amazonpayments_advanced_review');
|
63 |
-
$layout->generateXml();
|
64 |
-
$layout->generateBlocks();
|
65 |
-
$output = $layout->getOutput();
|
66 |
-
return $output;
|
67 |
-
}
|
68 |
-
|
69 |
-
protected function _isSubmitAllowed() {
|
70 |
-
if (!$this->_getQuote()->isVirtual()) {
|
71 |
-
$address = $this->_getQuote()->getShippingAddress();
|
72 |
-
$method = $address->getShippingMethod();
|
73 |
-
$rate = $address->getShippingRateByCode($method);
|
74 |
-
if (!$this->_getQuote()->isVirtual() && (!$method || !$rate)) {
|
75 |
-
return false;
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
// TODO add checking if customer selected payment method in the Amazon Wallet widget
|
80 |
-
|
81 |
-
return true;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Clear Order Reference ID in controller properties
|
86 |
-
* and in session data and return its value
|
87 |
-
*
|
88 |
-
* @return string
|
89 |
-
*/
|
90 |
-
protected function _clearOrderReferenceId() {
|
91 |
-
$orderReferenceId = $this->_orderReferenceId;
|
92 |
-
$this->_orderReferenceId = null;
|
93 |
-
$this->_getCheckoutSession()->setOrderReferenceId($this->_orderReferenceId);
|
94 |
-
return $orderReferenceId;
|
95 |
-
}
|
96 |
-
|
97 |
-
protected function _voidOrderReferenceId() {
|
98 |
-
$orderReferenceId = $this->_clearOrderReferenceId();
|
99 |
-
if ($orderReferenceId) {
|
100 |
-
return $this->_getApi()->cancelOrderReference($orderReferenceId);
|
101 |
-
}
|
102 |
-
return null;
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Send Ajax redirect response
|
107 |
-
*
|
108 |
-
* @return Creativestyle_AmazonPayments_Advanced_CheckoutController
|
109 |
-
*/
|
110 |
-
protected function _ajaxRedirectResponse() {
|
111 |
-
$this->getResponse()
|
112 |
-
->setHeader('HTTP/1.1', '403 Session Expired')
|
113 |
-
->setHeader('Login-Required', 'true')
|
114 |
-
->sendResponse();
|
115 |
-
return $this;
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Validate ajax request and redirect on failure
|
120 |
-
*
|
121 |
-
* @return bool
|
122 |
-
*/
|
123 |
-
protected function _expireAjax() {
|
124 |
-
if (!$this->_getQuote()->hasItems() || $this->_getQuote()->getHasError()) {
|
125 |
-
$this->_ajaxRedirectResponse();
|
126 |
-
return true;
|
127 |
-
}
|
128 |
-
if ($this->_getCheckoutSession()->getCartWasUpdated(true)) {
|
129 |
-
$this->_ajaxRedirectResponse();
|
130 |
-
return true;
|
131 |
-
}
|
132 |
-
if (null === $this->_getOrderReferenceId()) {
|
133 |
-
$this->_ajaxRedirectResponse();
|
134 |
-
return true;
|
135 |
-
}
|
136 |
-
return false;
|
137 |
-
}
|
138 |
-
|
139 |
-
public function preDispatch() {
|
140 |
-
parent::preDispatch();
|
141 |
-
$this->_orderReferenceId = $this->getRequest()->getParam('orderReferenceId', $this->_getCheckoutSession()->getOrderReferenceId());
|
142 |
-
$this->_accessToken = $this->getRequest()->getParam('accessToken', $this->_getCheckoutSession()->getAccessToken());
|
143 |
-
$this->_getCheckoutSession()->setOrderReferenceId($this->_orderReferenceId);
|
144 |
-
$this->_getCheckoutSession()->setAccessToken($this->_accessToken);
|
145 |
-
}
|
146 |
-
|
147 |
-
public function indexAction() {
|
148 |
-
try {
|
149 |
-
if (!$this->_getQuote()->hasItems() || $this->_getQuote()->getHasError()) {
|
150 |
-
$this->_redirect('checkout/cart');
|
151 |
-
return;
|
152 |
-
}
|
153 |
-
|
154 |
-
if (!$this->_getQuote()->validateMinimumAmount()) {
|
155 |
-
$error = Mage::getStoreConfig('sales/minimum_order/error_message') ?
|
156 |
-
Mage::getStoreConfig('sales/minimum_order/error_message') :
|
157 |
-
Mage::helper('checkout')->__('Subtotal must exceed minimum order amount');
|
158 |
-
$this->_getCheckoutSession()->addError($error);
|
159 |
-
$this->_redirect('checkout/cart');
|
160 |
-
return;
|
161 |
-
}
|
162 |
-
|
163 |
-
if (null === $this->_getOrderReferenceId() && null === $this->_getAccessToken()) {
|
164 |
-
$this->_redirect('checkout/cart');
|
165 |
-
return;
|
166 |
-
}
|
167 |
-
|
168 |
-
$this->_getCheckoutSession()->setCartWasUpdated(false);
|
169 |
-
$this->_getCheckout()->savePayment(null);
|
170 |
-
|
171 |
-
$this->loadLayout();
|
172 |
-
$this->getLayout()->getBlock('head')->setTitle($this->__('Amazon Pay'));
|
173 |
-
$this->renderLayout();
|
174 |
-
} catch (Exception $e) {
|
175 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
176 |
-
$this->_getCheckoutSession()->addError($this->__('There was an error processing your order. Please contact us or try again later.'));
|
177 |
-
$this->_redirect('checkout/cart');
|
178 |
-
return;
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
public function saveShippingAction() {
|
183 |
-
if ($this->getRequest()->isPost()) {
|
184 |
-
try {
|
185 |
-
if ($this->_expireAjax()) {
|
186 |
-
return;
|
187 |
-
}
|
188 |
-
|
189 |
-
// submit draft data of order reference to Amazon gateway
|
190 |
-
$this->_getApi()->setOrderReferenceDetails($this->_getOrderReferenceId(), $this->_getQuote()->getBaseGrandTotal(), $this->_getQuote()->getBaseCurrencyCode());
|
191 |
-
|
192 |
-
// fetch address data from Amazon gateway and save it as a billing address
|
193 |
-
$orderReference = $this->_getApi()->getOrderReferenceDetails($this->_getOrderReferenceId(), $this->_getAccessToken());
|
194 |
-
$shippingAddress = Creativestyle_AmazonPayments_Model_Processor_Order::mapAmazonAddress($orderReference->getDestination()->getPhysicalDestination());
|
195 |
-
$result = $this->_getCheckout()->saveShipping(array_merge(
|
196 |
-
$shippingAddress->toArray(),
|
197 |
-
array('use_for_shipping' => true)
|
198 |
-
), false);
|
199 |
-
} catch (Exception $e) {
|
200 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
201 |
-
$result = array(
|
202 |
-
'error' => -1,
|
203 |
-
'error_messages' => $e->getMessage()
|
204 |
-
);
|
205 |
-
}
|
206 |
-
|
207 |
-
if (!isset($result['error'])) {
|
208 |
-
$result = array(
|
209 |
-
'render_widget' => array(
|
210 |
-
'shipping-method' => $this->_getShippingMethodsHtml()
|
211 |
-
),
|
212 |
-
'allow_submit' => $this->_isSubmitAllowed()
|
213 |
-
);
|
214 |
-
};
|
215 |
-
} else {
|
216 |
-
$this->_forward('noRoute');
|
217 |
-
}
|
218 |
-
|
219 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
220 |
-
}
|
221 |
-
|
222 |
-
public function saveShippingMethodAction() {
|
223 |
-
if ($this->getRequest()->isPost()) {
|
224 |
-
try {
|
225 |
-
if ($this->_expireAjax()) {
|
226 |
-
return;
|
227 |
-
}
|
228 |
-
|
229 |
-
$data = $this->getRequest()->getPost('shipping_method', '');
|
230 |
-
$result = $this->_getCheckout()->saveShippingMethod($data);
|
231 |
-
|
232 |
-
if (!empty($data) && !isset($result['error'])) {
|
233 |
-
Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method',
|
234 |
-
array(
|
235 |
-
'request' => $this->getRequest(),
|
236 |
-
'quote' => $this->_getQuote()
|
237 |
-
)
|
238 |
-
);
|
239 |
-
}
|
240 |
-
} catch (Exception $e) {
|
241 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
242 |
-
$result = array(
|
243 |
-
'error' => -1,
|
244 |
-
'error_messages' => $e->getMessage()
|
245 |
-
);
|
246 |
-
}
|
247 |
-
|
248 |
-
if (!isset($result['error'])) {
|
249 |
-
$this->_getQuote()->collectTotals()->save();
|
250 |
-
$result = array(
|
251 |
-
'render_widget' => array(
|
252 |
-
'review' => $this->_getReviewHtml()
|
253 |
-
),
|
254 |
-
'allow_submit' => $this->_isSubmitAllowed()
|
255 |
-
);
|
256 |
-
}
|
257 |
-
} else {
|
258 |
-
$this->_forward('noRoute');
|
259 |
-
}
|
260 |
-
|
261 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
262 |
-
}
|
263 |
-
|
264 |
-
public function saveOrderAction() {
|
265 |
-
$result = array();
|
266 |
-
try {
|
267 |
-
$requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
|
268 |
-
if ($requiredAgreements) {
|
269 |
-
$postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
|
270 |
-
$diff = array_diff($requiredAgreements, $postedAgreements);
|
271 |
-
if ($diff) {
|
272 |
-
$result['success'] = false;
|
273 |
-
$result['error'] = true;
|
274 |
-
$result['error_messages'] = $this->__('Please agree to all the terms and conditions before placing the order.');
|
275 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
276 |
-
return;
|
277 |
-
}
|
278 |
-
}
|
279 |
-
|
280 |
-
$giftMessages = $this->getRequest()->getPost('giftmessage');
|
281 |
-
if (is_array($giftMessages)) {
|
282 |
-
Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method',
|
283 |
-
array(
|
284 |
-
'request' => $this->getRequest(),
|
285 |
-
'quote' => $this->_getQuote()
|
286 |
-
)
|
287 |
-
);
|
288 |
-
}
|
289 |
-
|
290 |
-
$this->_getQuote()->getPayment()->setTransactionId($this->_getOrderReferenceId());
|
291 |
-
|
292 |
-
if ($this->getRequest()->getPost('reloaded', false)) {
|
293 |
-
$sequenceNumber = (int)$this->_getCheckoutSession()->getAmazonSequenceNumber();
|
294 |
-
$this->_getQuote()->getPayment()
|
295 |
-
->setAmazonSequenceNumber(++$sequenceNumber)
|
296 |
-
->setSkipOrderReferenceProcessing(true);
|
297 |
-
$this->_getCheckoutSession()->setAmazonSequenceNumber($sequenceNumber);
|
298 |
-
} else {
|
299 |
-
$this->_getQuote()->getPayment()
|
300 |
-
->setAmazonSequenceNumber(null)
|
301 |
-
->setSkipOrderReferenceProcessing(false);
|
302 |
-
$this->_getCheckoutSession()->setAmazonSequenceNumber(null);
|
303 |
-
}
|
304 |
-
|
305 |
-
$simulation = $this->getRequest()->getPost('simulation', array());
|
306 |
-
if (!empty($simulation)) {
|
307 |
-
$simulationData = array(
|
308 |
-
'object' => isset($simulation['object']) ? $simulation['object'] : null,
|
309 |
-
'state' => isset($simulation['state']) ? $simulation['state'] : null,
|
310 |
-
'reason_code' => isset($simulation['reason']) ? $simulation['reason'] : null
|
311 |
-
);
|
312 |
-
$simulationData['options'] = Creativestyle_AmazonPayments_Model_Simulator::getSimulationOptions($simulationData['object'], $simulationData['state'], $simulationData['reason_code']);
|
313 |
-
$this->_getQuote()->getPayment()->setSimulationData($simulationData);
|
314 |
-
}
|
315 |
-
|
316 |
-
$this->_getCheckout()->saveOrder();
|
317 |
-
$this->_getQuote()->save();
|
318 |
-
$result['success'] = true;
|
319 |
-
$result['error'] = false;
|
320 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
321 |
-
} catch (Creativestyle_AmazonPayments_Exception_InvalidStatus_Recoverable $e) {
|
322 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array(
|
323 |
-
'success' => false,
|
324 |
-
'error' => true,
|
325 |
-
'error_messages' => $this->__('There has been a problem with the selected payment method from your Amazon account, please update the payment method or choose another one.'),
|
326 |
-
'reload_wallet' => true
|
327 |
-
)));
|
328 |
-
} catch (Creativestyle_AmazonPayments_Exception_InvalidStatus_Unrecoverable $e) {
|
329 |
-
$this->_clearOrderReferenceId();
|
330 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array(
|
331 |
-
'success' => false,
|
332 |
-
'error' => true,
|
333 |
-
'error_messages' => $this->__('There has been a problem with the selected payment method from your Amazon account, please choose another payment method from you Amazon account or return to the cart to choose another checkout method.'),
|
334 |
-
'logout' => true,
|
335 |
-
'redirect' => Mage::getUrl('checkout/cart')
|
336 |
-
)));
|
337 |
-
} catch (Creativestyle_AmazonPayments_Exception_InvalidStatus $e) {
|
338 |
-
$this->_voidOrderReferenceId();
|
339 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array(
|
340 |
-
'success' => false,
|
341 |
-
'error' => true,
|
342 |
-
'error_messages' => $this->__('There has been a problem with the selected payment method from your Amazon account, please choose another payment method from you Amazon account or return to the cart to choose another checkout method.'),
|
343 |
-
'reload' => true
|
344 |
-
)));
|
345 |
-
} catch (Exception $e) {
|
346 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
347 |
-
Mage::helper('checkout')->sendPaymentFailedEmail($this->_getQuote(), $e->getMessage());
|
348 |
-
$this->_voidOrderReferenceId();
|
349 |
-
$this->_getCheckoutSession()->addError($this->__('There was an error processing your order. Please contact us or try again later.'));
|
350 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array(
|
351 |
-
'success' => false,
|
352 |
-
'redirect' => Mage::getUrl('checkout/cart')
|
353 |
-
)));
|
354 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
public function clearOrderReferenceAction() {
|
358 |
-
$this->_clearOrderReferenceId();
|
359 |
-
$this->_redirect('checkout/cart');
|
360 |
-
return;
|
361 |
-
}
|
362 |
-
|
363 |
-
public function voidOrderReferenceAction() {
|
364 |
-
$this->_voidOrderReferenceId();
|
365 |
-
$this->_redirect('checkout/cart');
|
366 |
-
return;
|
367 |
-
}
|
368 |
-
|
369 |
-
public function couponPostAction() {
|
370 |
-
if ($this->getRequest()->isPost()) {
|
371 |
-
try {
|
372 |
-
if ($this->_expireAjax()) {
|
373 |
-
return;
|
374 |
-
}
|
375 |
-
$couponCode = (string) $this->getRequest()->getParam('coupon_code');
|
376 |
-
if ($this->getRequest()->getParam('remove') == 1) {
|
377 |
-
$couponCode = '';
|
378 |
-
}
|
379 |
-
|
380 |
-
$this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
|
381 |
-
$result = $this->_getQuote()->setCouponCode($couponCode)
|
382 |
-
->collectTotals()
|
383 |
-
->save();
|
384 |
-
|
385 |
-
} catch (Exception $e) {
|
386 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
387 |
-
$result = array(
|
388 |
-
'error' => -1,
|
389 |
-
'error_messages' => $e->getMessage()
|
390 |
-
);
|
391 |
-
}
|
392 |
-
|
393 |
-
if (!isset($result['error'])) {
|
394 |
-
$result = array(
|
395 |
-
'render_widget' => array(
|
396 |
-
'review' => $this->_getReviewHtml()
|
397 |
-
),
|
398 |
-
'allow_submit' => $this->_isSubmitAllowed()
|
399 |
-
);
|
400 |
-
};
|
401 |
-
} else {
|
402 |
-
$this->_forward('noRoute');
|
403 |
-
}
|
404 |
-
|
405 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
406 |
-
}
|
407 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/IpnController.php
CHANGED
@@ -1,82 +1,23 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Advanced_IpnController extends Mage_Core_Controller_Front_Action
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
return Mage::getSingleton('amazonpayments/config');
|
22 |
-
}
|
23 |
-
|
24 |
-
protected function _sendResponse($code = 500, $message = null) {
|
25 |
-
$response = $this->getResponse();
|
26 |
-
switch ($code) {
|
27 |
-
case 200:
|
28 |
-
$responseCode = '200 OK';
|
29 |
-
break;
|
30 |
-
case 403:
|
31 |
-
$responseCode = '403 Forbidden';
|
32 |
-
break;
|
33 |
-
case 404:
|
34 |
-
$responseCode = '404 Not Found';
|
35 |
-
break;
|
36 |
-
case 503:
|
37 |
-
$responseCode = '503 Service Unavailable';
|
38 |
-
break;
|
39 |
-
default:
|
40 |
-
$responseCode = '500 Internal Server Error';
|
41 |
-
break;
|
42 |
-
}
|
43 |
-
$response->setHeader('HTTP/1.1', $responseCode);
|
44 |
-
if ($message) $response->setBody($message);
|
45 |
-
$response->sendResponse();
|
46 |
-
}
|
47 |
-
|
48 |
-
public function indexAction() {
|
49 |
-
if ($this->_getConfig()->isPaymentProcessingAllowed() && $this->_getConfig()->isIpnActive()) {
|
50 |
-
try {
|
51 |
-
$headers = array();
|
52 |
-
$requestHeaders = array();
|
53 |
-
foreach ($this->_headers as $headerId) {
|
54 |
-
if (Mage::app()->getRequest()->getHeader($headerId)) {
|
55 |
-
$headers[$headerId] = Mage::app()->getRequest()->getHeader($headerId);
|
56 |
-
$requestHeaders[] = $headerId . ': ' . Mage::app()->getRequest()->getHeader($headerId);
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
$notification = Mage::getSingleton('amazonpayments/api_ipn')->parseMessage($headers, Mage::app()->getRequest()->getRawBody());
|
61 |
-
Mage::dispatchEvent('amazonpayments_advanced_ipn_request', array(
|
62 |
-
'call_data' => array(
|
63 |
-
'notification_type' => $notification->getNotificationType(),
|
64 |
-
'response_code' => 200,
|
65 |
-
'response_error' => null,
|
66 |
-
'request_headers' => implode("\n", $requestHeaders),
|
67 |
-
'request_body' => Mage::app()->getRequest()->getRawBody()
|
68 |
-
)
|
69 |
-
));
|
70 |
-
Mage::getSingleton('amazonpayments/processor_ipn')->processNotification($notification);
|
71 |
-
$this->_sendResponse(200);
|
72 |
-
} catch (Exception $e) {
|
73 |
-
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
74 |
-
$this->_sendResponse(503, $e->getMessage());
|
75 |
-
}
|
76 |
-
return;
|
77 |
-
} else {
|
78 |
-
$this->_forward('noRoute');
|
79 |
-
}
|
80 |
}
|
81 |
-
|
82 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Advanced_IpnController extends Mage_Core_Controller_Front_Action
|
18 |
+
{
|
19 |
+
public function indexAction()
|
20 |
+
{
|
21 |
+
$this->_forward('index', 'ipn');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
|
|
23 |
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/LoginController.php
CHANGED
@@ -1,81 +1,114 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-
class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Controller_Front_Action
|
|
|
17 |
|
18 |
const ACCESS_TOKEN_PARAM_NAME = 'access_token';
|
19 |
|
20 |
-
|
|
|
21 |
$accessToken = $this->getRequest()->getParam(self::ACCESS_TOKEN_PARAM_NAME, null);
|
22 |
$accessToken = str_replace('|', '%7C', $accessToken);
|
23 |
return $accessToken;
|
24 |
}
|
25 |
|
26 |
-
|
|
|
27 |
return Mage::getModel('amazonpayments/api_login');
|
28 |
}
|
29 |
|
30 |
-
|
|
|
31 |
return Mage::getSingleton('amazonpayments/config');
|
32 |
}
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
return Mage::getSingleton('checkout/session');
|
36 |
}
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
return Mage::getSingleton('customer/session');
|
40 |
}
|
41 |
|
42 |
-
protected function _getRedirectUrl()
|
43 |
-
|
44 |
-
|
45 |
-
'
|
46 |
-
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
-
protected function _getRedirectFailureUrl()
|
|
|
50 |
if (strtolower($this->getRequest()->getParam('target', null)) == 'checkout') {
|
51 |
return Mage::getUrl('checkout/cart');
|
52 |
}
|
|
|
53 |
return Mage::getUrl('customer/account/login');
|
54 |
}
|
55 |
-
|
|
|
|
|
56 |
if (strtolower($this->getRequest()->getParam('target', null)) == 'checkout') {
|
57 |
$accessToken = $this->_extractAccessTokenFromUrl();
|
58 |
-
return Mage::getUrl('amazonpayments/
|
59 |
}
|
|
|
60 |
return Mage::getUrl('customer/account/');
|
61 |
}
|
62 |
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
-
|
|
|
68 |
return $authToken instanceof Varien_Object && $authToken->getAud() != '';
|
69 |
}
|
70 |
|
71 |
-
public function preDispatch()
|
|
|
72 |
parent::preDispatch();
|
73 |
-
if (
|
74 |
$this->_forward('noRoute');
|
75 |
}
|
76 |
}
|
77 |
|
78 |
-
|
|
|
|
|
79 |
$accessToken = $this->_extractAccessTokenFromUrl();
|
80 |
if (null !== $accessToken) {
|
81 |
$accessToken = urldecode($accessToken);
|
@@ -95,14 +128,17 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
|
|
95 |
$loginPost = $this->getRequest()->getPost('login', array());
|
96 |
if (!empty($loginPost) && array_key_exists('password', $loginPost)) {
|
97 |
if ($connectStatus->getCustomer()->validatePassword($loginPost['password'])) {
|
98 |
-
$connectStatus->getCustomer()->setAmazonUserId($userProfile->getUserId())
|
99 |
-
|
|
|
|
|
100 |
$this->_redirectUrl($this->_getTargetUrl());
|
101 |
return;
|
102 |
} else {
|
103 |
$this->_getCustomerSession()->addError($this->__('Invalid password'));
|
104 |
}
|
105 |
}
|
|
|
106 |
$update = $this->getLayout()->getUpdate();
|
107 |
$update->addHandle('default');
|
108 |
$this->addActionLayoutHandles();
|
@@ -115,6 +151,7 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
|
|
115 |
$formBlock->setData('back_url', $this->_getRefererUrl());
|
116 |
$formBlock->setUsername($connectStatus->getCustomer()->getEmail());
|
117 |
}
|
|
|
118 |
$this->renderLayout();
|
119 |
return;
|
120 |
case Creativestyle_AmazonPayments_Model_Service_Login::ACCOUNT_STATUS_DATA_MISSING:
|
@@ -127,6 +164,7 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
|
|
127 |
$postedData[] = $attribute;
|
128 |
}
|
129 |
}
|
|
|
130 |
$dataDiff = array_diff($requiredData, $postedData);
|
131 |
if (empty($dataDiff)) {
|
132 |
$connectStatus = $loginService->connect($accountPost);
|
@@ -141,6 +179,7 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
|
|
141 |
$this->_getCustomerSession()->addError($this->__('Please provide all required data.'));
|
142 |
}
|
143 |
}
|
|
|
144 |
$update = $this->getLayout()->getUpdate();
|
145 |
$update->addHandle('default');
|
146 |
$this->addActionLayoutHandles();
|
@@ -158,20 +197,25 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
|
|
158 |
if (!$formData->getFirstname()) {
|
159 |
$formData->setData('firstname', $customerName->getFirstname());
|
160 |
}
|
|
|
161 |
if (!$formData->getLastname()) {
|
162 |
$formData->setData('lastname', $customerName->getLastname());
|
163 |
}
|
164 |
}
|
|
|
165 |
$formBlock->setFormData($formData);
|
166 |
}
|
|
|
167 |
$this->renderLayout();
|
168 |
return;
|
169 |
case Creativestyle_AmazonPayments_Model_Service_Login::ACCOUNT_STATUS_ERROR:
|
170 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-controller] Error when connecting accounts');
|
171 |
}
|
172 |
}
|
|
|
173 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-controller] Retrieved user profile is invalid');
|
174 |
}
|
|
|
175 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-controller] Provided access_token is invalid');
|
176 |
} catch (Exception $e) {
|
177 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
@@ -180,6 +224,7 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
|
|
180 |
} else {
|
181 |
$this->_getCustomerSession()->addError($this->__('There was an error connecting your Amazon account. Please contact us or try again later.'));
|
182 |
}
|
|
|
183 |
$this->_redirectReferer();
|
184 |
return;
|
185 |
}
|
@@ -189,13 +234,17 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
|
|
189 |
} else {
|
190 |
$this->_getCustomerSession()->addError($this->__('You have aborted the login with Amazon. Please contact us or try again.'));
|
191 |
}
|
|
|
192 |
$this->_redirectUrl($this->_getRedirectFailureUrl());
|
193 |
return;
|
194 |
}
|
|
|
195 |
$this->_forward('noRoute');
|
196 |
}
|
|
|
197 |
|
198 |
-
public function redirectAction()
|
|
|
199 |
$this->loadLayout();
|
200 |
$this->getLayout()->getBlock('head')->setTitle($this->__('Login with Amazon'));
|
201 |
$this->getLayout()->getBlock('amazonpayments_login_redirect')
|
@@ -205,12 +254,14 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
|
|
205 |
$this->renderLayout();
|
206 |
}
|
207 |
|
208 |
-
public function disconnectAction()
|
|
|
209 |
if ($customer = $this->_getCustomerSession()->getCustomer()) {
|
210 |
if ($customer->getAmazonUserId()) {
|
211 |
$customer->setAmazonUserId(null)->save();
|
212 |
}
|
213 |
}
|
|
|
214 |
$this->_redirect('customer/account');
|
215 |
}
|
216 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
+
class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Controller_Front_Action
|
18 |
+
{
|
19 |
|
20 |
const ACCESS_TOKEN_PARAM_NAME = 'access_token';
|
21 |
|
22 |
+
protected function _extractAccessTokenFromUrl()
|
23 |
+
{
|
24 |
$accessToken = $this->getRequest()->getParam(self::ACCESS_TOKEN_PARAM_NAME, null);
|
25 |
$accessToken = str_replace('|', '%7C', $accessToken);
|
26 |
return $accessToken;
|
27 |
}
|
28 |
|
29 |
+
protected function _getApi()
|
30 |
+
{
|
31 |
return Mage::getModel('amazonpayments/api_login');
|
32 |
}
|
33 |
|
34 |
+
protected function _getConfig()
|
35 |
+
{
|
36 |
return Mage::getSingleton('amazonpayments/config');
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* Returns checkout session instance
|
41 |
+
*
|
42 |
+
* @return Mage_Checkout_Model_Session
|
43 |
+
*/
|
44 |
+
protected function _getCheckoutSession()
|
45 |
+
{
|
46 |
return Mage::getSingleton('checkout/session');
|
47 |
}
|
48 |
|
49 |
+
/**
|
50 |
+
* Returns customer session instance
|
51 |
+
*
|
52 |
+
* @return Mage_Customer_Model_Session
|
53 |
+
*/
|
54 |
+
protected function _getCustomerSession()
|
55 |
+
{
|
56 |
return Mage::getSingleton('customer/session');
|
57 |
}
|
58 |
|
59 |
+
protected function _getRedirectUrl()
|
60 |
+
{
|
61 |
+
return Mage::getUrl(
|
62 |
+
'*/*/index', array(
|
63 |
+
self::ACCESS_TOKEN_PARAM_NAME => '%s',
|
64 |
+
'target' => $this->getRequest()->getParam('target', null)
|
65 |
+
)
|
66 |
+
);
|
67 |
}
|
68 |
|
69 |
+
protected function _getRedirectFailureUrl()
|
70 |
+
{
|
71 |
if (strtolower($this->getRequest()->getParam('target', null)) == 'checkout') {
|
72 |
return Mage::getUrl('checkout/cart');
|
73 |
}
|
74 |
+
|
75 |
return Mage::getUrl('customer/account/login');
|
76 |
}
|
77 |
+
|
78 |
+
protected function _getTargetUrl()
|
79 |
+
{
|
80 |
if (strtolower($this->getRequest()->getParam('target', null)) == 'checkout') {
|
81 |
$accessToken = $this->_extractAccessTokenFromUrl();
|
82 |
+
return Mage::getUrl('amazonpayments/checkout/', array('accessToken' => $accessToken));
|
83 |
}
|
84 |
+
|
85 |
return Mage::getUrl('customer/account/');
|
86 |
}
|
87 |
|
88 |
+
protected function _validateUserProfile($userProfile)
|
89 |
+
{
|
90 |
+
return $userProfile instanceof Varien_Object
|
91 |
+
&& $userProfile->getEmail()
|
92 |
+
&& $userProfile->getName()
|
93 |
+
&& $userProfile->getUserId();
|
94 |
}
|
95 |
|
96 |
+
protected function _validateAuthToken($authToken)
|
97 |
+
{
|
98 |
return $authToken instanceof Varien_Object && $authToken->getAud() != '';
|
99 |
}
|
100 |
|
101 |
+
public function preDispatch()
|
102 |
+
{
|
103 |
parent::preDispatch();
|
104 |
+
if (!$this->_getConfig()->isLoginActive()) {
|
105 |
$this->_forward('noRoute');
|
106 |
}
|
107 |
}
|
108 |
|
109 |
+
// @codingStandardsIgnoreStart
|
110 |
+
public function indexAction()
|
111 |
+
{
|
112 |
$accessToken = $this->_extractAccessTokenFromUrl();
|
113 |
if (null !== $accessToken) {
|
114 |
$accessToken = urldecode($accessToken);
|
128 |
$loginPost = $this->getRequest()->getPost('login', array());
|
129 |
if (!empty($loginPost) && array_key_exists('password', $loginPost)) {
|
130 |
if ($connectStatus->getCustomer()->validatePassword($loginPost['password'])) {
|
131 |
+
$connectStatus->getCustomer()->setAmazonUserId($userProfile->getUserId())
|
132 |
+
->save();
|
133 |
+
$this->_getCustomerSession()
|
134 |
+
->setCustomerAsLoggedIn($connectStatus->getCustomer());
|
135 |
$this->_redirectUrl($this->_getTargetUrl());
|
136 |
return;
|
137 |
} else {
|
138 |
$this->_getCustomerSession()->addError($this->__('Invalid password'));
|
139 |
}
|
140 |
}
|
141 |
+
|
142 |
$update = $this->getLayout()->getUpdate();
|
143 |
$update->addHandle('default');
|
144 |
$this->addActionLayoutHandles();
|
151 |
$formBlock->setData('back_url', $this->_getRefererUrl());
|
152 |
$formBlock->setUsername($connectStatus->getCustomer()->getEmail());
|
153 |
}
|
154 |
+
|
155 |
$this->renderLayout();
|
156 |
return;
|
157 |
case Creativestyle_AmazonPayments_Model_Service_Login::ACCOUNT_STATUS_DATA_MISSING:
|
164 |
$postedData[] = $attribute;
|
165 |
}
|
166 |
}
|
167 |
+
|
168 |
$dataDiff = array_diff($requiredData, $postedData);
|
169 |
if (empty($dataDiff)) {
|
170 |
$connectStatus = $loginService->connect($accountPost);
|
179 |
$this->_getCustomerSession()->addError($this->__('Please provide all required data.'));
|
180 |
}
|
181 |
}
|
182 |
+
|
183 |
$update = $this->getLayout()->getUpdate();
|
184 |
$update->addHandle('default');
|
185 |
$this->addActionLayoutHandles();
|
197 |
if (!$formData->getFirstname()) {
|
198 |
$formData->setData('firstname', $customerName->getFirstname());
|
199 |
}
|
200 |
+
|
201 |
if (!$formData->getLastname()) {
|
202 |
$formData->setData('lastname', $customerName->getLastname());
|
203 |
}
|
204 |
}
|
205 |
+
|
206 |
$formBlock->setFormData($formData);
|
207 |
}
|
208 |
+
|
209 |
$this->renderLayout();
|
210 |
return;
|
211 |
case Creativestyle_AmazonPayments_Model_Service_Login::ACCOUNT_STATUS_ERROR:
|
212 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-controller] Error when connecting accounts');
|
213 |
}
|
214 |
}
|
215 |
+
|
216 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-controller] Retrieved user profile is invalid');
|
217 |
}
|
218 |
+
|
219 |
throw new Creativestyle_AmazonPayments_Exception('[LWA-controller] Provided access_token is invalid');
|
220 |
} catch (Exception $e) {
|
221 |
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
224 |
} else {
|
225 |
$this->_getCustomerSession()->addError($this->__('There was an error connecting your Amazon account. Please contact us or try again later.'));
|
226 |
}
|
227 |
+
|
228 |
$this->_redirectReferer();
|
229 |
return;
|
230 |
}
|
234 |
} else {
|
235 |
$this->_getCustomerSession()->addError($this->__('You have aborted the login with Amazon. Please contact us or try again.'));
|
236 |
}
|
237 |
+
|
238 |
$this->_redirectUrl($this->_getRedirectFailureUrl());
|
239 |
return;
|
240 |
}
|
241 |
+
|
242 |
$this->_forward('noRoute');
|
243 |
}
|
244 |
+
// @codingStandardsIgnoreEnd
|
245 |
|
246 |
+
public function redirectAction()
|
247 |
+
{
|
248 |
$this->loadLayout();
|
249 |
$this->getLayout()->getBlock('head')->setTitle($this->__('Login with Amazon'));
|
250 |
$this->getLayout()->getBlock('amazonpayments_login_redirect')
|
254 |
$this->renderLayout();
|
255 |
}
|
256 |
|
257 |
+
public function disconnectAction()
|
258 |
+
{
|
259 |
if ($customer = $this->_getCustomerSession()->getCustomer()) {
|
260 |
if ($customer->getAmazonUserId()) {
|
261 |
$customer->setAmazonUserId(null)->save();
|
262 |
}
|
263 |
}
|
264 |
+
|
265 |
$this->_redirect('customer/account');
|
266 |
}
|
267 |
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/CheckoutController.php
ADDED
@@ -0,0 +1,575 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
class Creativestyle_AmazonPayments_CheckoutController extends Mage_Core_Controller_Front_Action
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Current order reference ID
|
21 |
+
*
|
22 |
+
* @var string|null
|
23 |
+
*/
|
24 |
+
protected $_orderReferenceId = null;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Current access token value
|
28 |
+
*
|
29 |
+
* @var string|null
|
30 |
+
*/
|
31 |
+
protected $_accessToken = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Returns Amazon checkout instance
|
35 |
+
*
|
36 |
+
* @return Creativestyle_AmazonPayments_Model_Checkout
|
37 |
+
*/
|
38 |
+
protected function _getCheckout()
|
39 |
+
{
|
40 |
+
return Mage::getSingleton('amazonpayments/checkout');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns checkout session instance
|
45 |
+
*
|
46 |
+
* @return Mage_Checkout_Model_Session
|
47 |
+
*/
|
48 |
+
protected function _getCheckoutSession()
|
49 |
+
{
|
50 |
+
return Mage::getSingleton('checkout/session');
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Returns saved order reference ID
|
55 |
+
*
|
56 |
+
* @return string|null
|
57 |
+
*/
|
58 |
+
protected function _getOrderReferenceId()
|
59 |
+
{
|
60 |
+
return $this->_orderReferenceId;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Returns saved access token
|
65 |
+
*
|
66 |
+
* @return string|null
|
67 |
+
*/
|
68 |
+
protected function _getAccessToken()
|
69 |
+
{
|
70 |
+
return $this->_accessToken;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Returns Amazon Pay API adapter instance
|
75 |
+
*
|
76 |
+
* @return Creativestyle_AmazonPayments_Model_Api_Advanced
|
77 |
+
*/
|
78 |
+
protected function _getApi()
|
79 |
+
{
|
80 |
+
return Mage::getModel('amazonpayments/api_advanced');
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Returns current quote entity
|
85 |
+
*
|
86 |
+
* @return Mage_Sales_Model_Quote
|
87 |
+
*/
|
88 |
+
protected function _getQuote()
|
89 |
+
{
|
90 |
+
return $this->_getCheckout()->getQuote();
|
91 |
+
}
|
92 |
+
|
93 |
+
protected function _getShippingMethodsHtml()
|
94 |
+
{
|
95 |
+
$layout = $this->getLayout();
|
96 |
+
$update = $layout->getUpdate();
|
97 |
+
$update->load('amazonpayments_checkout_shippingmethod');
|
98 |
+
$layout->generateXml();
|
99 |
+
$layout->generateBlocks();
|
100 |
+
$output = $layout->getOutput();
|
101 |
+
return $output;
|
102 |
+
}
|
103 |
+
|
104 |
+
protected function _getReviewHtml()
|
105 |
+
{
|
106 |
+
$layout = $this->getLayout();
|
107 |
+
$update = $layout->getUpdate();
|
108 |
+
$update->load('amazonpayments_checkout_review');
|
109 |
+
$layout->generateXml();
|
110 |
+
$layout->generateBlocks();
|
111 |
+
$output = $layout->getOutput();
|
112 |
+
return $output;
|
113 |
+
}
|
114 |
+
|
115 |
+
protected function _isSubmitAllowed()
|
116 |
+
{
|
117 |
+
if (!$this->_getQuote()->isVirtual()) {
|
118 |
+
$address = $this->_getQuote()->getShippingAddress();
|
119 |
+
$method = $address->getShippingMethod();
|
120 |
+
$rate = $address->getShippingRateByCode($method);
|
121 |
+
if (!$this->_getQuote()->isVirtual() && (!$method || !$rate)) {
|
122 |
+
return false;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
return true;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Clear Order Reference ID in controller properties
|
131 |
+
* and in session data and return its value
|
132 |
+
*/
|
133 |
+
protected function _clearOrderReferenceId()
|
134 |
+
{
|
135 |
+
$this->_orderReferenceId = null;
|
136 |
+
$this->_getCheckoutSession()->setAmazonOrderReferenceId(null);
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Cancels order reference at Amazon Payments gateway
|
141 |
+
* and clears corresponding session data
|
142 |
+
*/
|
143 |
+
protected function _cancelOrderReferenceId()
|
144 |
+
{
|
145 |
+
if ($this->_orderReferenceId) {
|
146 |
+
$this->_getApi()->cancelOrderReference($this->_orderReferenceId);
|
147 |
+
$this->_clearOrderReferenceId();
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Send Ajax redirect response
|
153 |
+
*
|
154 |
+
* @return $this
|
155 |
+
*/
|
156 |
+
protected function _ajaxRedirectResponse()
|
157 |
+
{
|
158 |
+
$this->getResponse()
|
159 |
+
->setHeader('HTTP/1.1', '403 Session Expired')
|
160 |
+
->setHeader('Login-Required', 'true')
|
161 |
+
->sendResponse();
|
162 |
+
return $this;
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Validate ajax request and redirect on failure
|
167 |
+
*
|
168 |
+
* @return bool
|
169 |
+
*/
|
170 |
+
protected function _expireAjax()
|
171 |
+
{
|
172 |
+
if (!$this->_getQuote()->hasItems() || $this->_getQuote()->getHasError()) {
|
173 |
+
$this->_ajaxRedirectResponse();
|
174 |
+
return true;
|
175 |
+
}
|
176 |
+
|
177 |
+
if ($this->_getCheckoutSession()->getCartWasUpdated(true)) {
|
178 |
+
$this->_ajaxRedirectResponse();
|
179 |
+
return true;
|
180 |
+
}
|
181 |
+
|
182 |
+
if (null === $this->_getOrderReferenceId()) {
|
183 |
+
$this->_ajaxRedirectResponse();
|
184 |
+
return true;
|
185 |
+
}
|
186 |
+
|
187 |
+
return false;
|
188 |
+
}
|
189 |
+
|
190 |
+
public function preDispatch()
|
191 |
+
{
|
192 |
+
parent::preDispatch();
|
193 |
+
$this->_orderReferenceId = $this->getRequest()->getParam(
|
194 |
+
'orderReferenceId',
|
195 |
+
$this->_getCheckoutSession()->getAmazonOrderReferenceId()
|
196 |
+
);
|
197 |
+
$this->_accessToken = $this->getRequest()->getParam(
|
198 |
+
'accessToken',
|
199 |
+
$this->_getCheckoutSession()->getAmazonAccessToken()
|
200 |
+
);
|
201 |
+
$this->_getCheckoutSession()->setAmazonOrderReferenceId($this->_orderReferenceId);
|
202 |
+
$this->_getCheckoutSession()->setAmazonAccessToken($this->_accessToken);
|
203 |
+
}
|
204 |
+
|
205 |
+
public function indexAction()
|
206 |
+
{
|
207 |
+
try {
|
208 |
+
if (!$this->_getQuote()->hasItems() || $this->_getQuote()->getHasError()) {
|
209 |
+
$this->_redirect('checkout/cart');
|
210 |
+
return;
|
211 |
+
}
|
212 |
+
|
213 |
+
if (!$this->_getQuote()->validateMinimumAmount()) {
|
214 |
+
$error = Mage::getStoreConfig('sales/minimum_order/error_message') ?
|
215 |
+
Mage::getStoreConfig('sales/minimum_order/error_message') :
|
216 |
+
Mage::helper('checkout')->__('Subtotal must exceed minimum order amount');
|
217 |
+
$this->_getCheckoutSession()->addError($error);
|
218 |
+
$this->_redirect('checkout/cart');
|
219 |
+
return;
|
220 |
+
}
|
221 |
+
|
222 |
+
if (null === $this->_getOrderReferenceId() && null === $this->_getAccessToken()) {
|
223 |
+
$this->_redirect('checkout/cart');
|
224 |
+
return;
|
225 |
+
}
|
226 |
+
|
227 |
+
$this->_getCheckoutSession()->setCartWasUpdated(false);
|
228 |
+
$this->_getCheckout()->savePayment(null);
|
229 |
+
|
230 |
+
$this->loadLayout();
|
231 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('Amazon Pay'));
|
232 |
+
$this->renderLayout();
|
233 |
+
} catch (Exception $e) {
|
234 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
235 |
+
$this->_getCheckoutSession()->addError(
|
236 |
+
$this->__('There was an error processing your order. Please contact us or try again later.')
|
237 |
+
);
|
238 |
+
$this->_redirect('checkout/cart');
|
239 |
+
return;
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
public function saveShippingAction()
|
244 |
+
{
|
245 |
+
if ($this->getRequest()->isPost()) {
|
246 |
+
try {
|
247 |
+
if ($this->_expireAjax()) {
|
248 |
+
return;
|
249 |
+
}
|
250 |
+
|
251 |
+
// submit draft data of order reference to Amazon gateway
|
252 |
+
$orderReferenceDetails = $this->_getApi()->setOrderReferenceDetails(
|
253 |
+
$this->_getQuote()->getBaseGrandTotal(),
|
254 |
+
$this->_getQuote()->getBaseCurrencyCode(),
|
255 |
+
$this->_getOrderReferenceId()
|
256 |
+
);
|
257 |
+
|
258 |
+
/** @var Creativestyle_AmazonPayments_Model_Processor_Transaction $transactionProcessor */
|
259 |
+
$transactionProcessor = Mage::getModel('amazonpayments/processor_transaction');
|
260 |
+
$transactionProcessor->setTransactionDetails($orderReferenceDetails);
|
261 |
+
$shippingAddress = $transactionProcessor->getMagentoShippingAddress();
|
262 |
+
$result = $this->_getCheckout()->saveShipping(
|
263 |
+
array_merge(
|
264 |
+
$shippingAddress,
|
265 |
+
array('use_for_shipping' => true)
|
266 |
+
),
|
267 |
+
false
|
268 |
+
);
|
269 |
+
} catch (Exception $e) {
|
270 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
271 |
+
$result = array(
|
272 |
+
'error' => -1,
|
273 |
+
'error_messages' => $e->getMessage(),
|
274 |
+
'allow_submit' => false
|
275 |
+
);
|
276 |
+
}
|
277 |
+
|
278 |
+
if (!isset($result['error'])) {
|
279 |
+
$result = array(
|
280 |
+
'render_widget' => array(
|
281 |
+
'shipping-method' => $this->_getShippingMethodsHtml()
|
282 |
+
),
|
283 |
+
'allow_submit' => false
|
284 |
+
);
|
285 |
+
};
|
286 |
+
} else {
|
287 |
+
$this->_forward('noRoute');
|
288 |
+
return;
|
289 |
+
}
|
290 |
+
|
291 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
292 |
+
}
|
293 |
+
|
294 |
+
public function saveShippingMethodAction()
|
295 |
+
{
|
296 |
+
if ($this->getRequest()->isPost()) {
|
297 |
+
try {
|
298 |
+
if ($this->_expireAjax()) {
|
299 |
+
return;
|
300 |
+
}
|
301 |
+
|
302 |
+
$data = $this->getRequest()->getPost('shipping_method', '');
|
303 |
+
$this->_getCheckout()->saveShippingMethod($data);
|
304 |
+
} catch (Exception $e) {
|
305 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
306 |
+
$result = array(
|
307 |
+
'error' => true,
|
308 |
+
'error_messages' => $e->getMessage(),
|
309 |
+
'allow_submit' => false
|
310 |
+
);
|
311 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
312 |
+
return;
|
313 |
+
}
|
314 |
+
|
315 |
+
Mage::dispatchEvent(
|
316 |
+
'checkout_controller_onepage_save_shipping_method',
|
317 |
+
array('request' => $this->getRequest(), 'quote' => $this->_getQuote())
|
318 |
+
);
|
319 |
+
$this->_getQuote()->collectTotals()->save();
|
320 |
+
$result = array(
|
321 |
+
'render_widget' => array('review' => $this->_getReviewHtml()),
|
322 |
+
'allow_submit' => $this->_isSubmitAllowed()
|
323 |
+
);
|
324 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
325 |
+
} else {
|
326 |
+
$this->_forward('noRoute');
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* @param OffAmazonPaymentsService_Model_OrderReferenceDetails $orderReference
|
332 |
+
* @return array|null
|
333 |
+
*/
|
334 |
+
protected function _validateOrderReference($orderReference)
|
335 |
+
{
|
336 |
+
/** @var OffAmazonPaymentsService_Model_Constraints $constraints */
|
337 |
+
if ($constraints = $orderReference->getConstraints()) {
|
338 |
+
/** @var OffAmazonPaymentsService_Model_Constraint $constraint */
|
339 |
+
foreach ($constraints->getConstraint() as $constraint) {
|
340 |
+
switch ($constraint->getConstraintID()) {
|
341 |
+
case 'ShippingAddressNotSet':
|
342 |
+
return array(
|
343 |
+
'success' => false,
|
344 |
+
'error' => true,
|
345 |
+
'error_messages' => $this->__(
|
346 |
+
'There has been a problem with the selected payment method from your Amazon account, '
|
347 |
+
. 'please update the payment method or choose another one.'
|
348 |
+
),
|
349 |
+
'allow_submit' => false
|
350 |
+
);
|
351 |
+
case 'PaymentMethodNotAllowed':
|
352 |
+
case 'PaymentPlanNotSet':
|
353 |
+
return array(
|
354 |
+
'success' => false,
|
355 |
+
'error' => true,
|
356 |
+
'error_messages' => $this->__(
|
357 |
+
'There has been a problem with the selected payment method from your Amazon account, '
|
358 |
+
. 'please update the payment method or choose another one.'
|
359 |
+
),
|
360 |
+
'allow_submit' => $this->_isSubmitAllowed(),
|
361 |
+
'deselect_payment' => true,
|
362 |
+
'render_widget' => array(
|
363 |
+
'wallet' => true
|
364 |
+
)
|
365 |
+
);
|
366 |
+
}
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
return null;
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* @param array $postedAgreements
|
375 |
+
* @param array $requiredAgreements
|
376 |
+
* @return array|null
|
377 |
+
*/
|
378 |
+
protected function _validateCheckoutAgreements($postedAgreements, $requiredAgreements)
|
379 |
+
{
|
380 |
+
if ($requiredAgreements) {
|
381 |
+
$diff = array_diff($requiredAgreements, $postedAgreements);
|
382 |
+
if ($diff) {
|
383 |
+
return array(
|
384 |
+
'success' => false,
|
385 |
+
'error' => true,
|
386 |
+
'error_messages' => $this->__(
|
387 |
+
'Please agree to all the terms and conditions before placing the order.'
|
388 |
+
),
|
389 |
+
'allow_submit' => $this->_isSubmitAllowed()
|
390 |
+
);
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
return null;
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* @param Creativestyle_AmazonPayments_Exception_InvalidTransaction $e
|
399 |
+
* @return array|null
|
400 |
+
*/
|
401 |
+
protected function _handleInvalidTransactionException(Creativestyle_AmazonPayments_Exception_InvalidTransaction $e)
|
402 |
+
{
|
403 |
+
if ($e->getType() == Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_TYPE_AUTH) {
|
404 |
+
if ($e->getState()
|
405 |
+
== Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DECLINED) {
|
406 |
+
if ($e->getReasonCode()
|
407 |
+
== Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_REASON_INVALID_PAYMENT) {
|
408 |
+
return array(
|
409 |
+
'success' => false,
|
410 |
+
'error' => true,
|
411 |
+
'error_messages' => $this->__(
|
412 |
+
'There has been a problem with the selected payment method from your Amazon account, '
|
413 |
+
. 'please update the payment method or choose another one.'
|
414 |
+
),
|
415 |
+
'allow_submit' => $this->_isSubmitAllowed(),
|
416 |
+
'deselect_payment' => true,
|
417 |
+
'render_widget' => array(
|
418 |
+
'wallet' => true
|
419 |
+
),
|
420 |
+
'disable_widget' => array(
|
421 |
+
'address-book' => true,
|
422 |
+
'shipping-method' => true,
|
423 |
+
'review' => true
|
424 |
+
)
|
425 |
+
);
|
426 |
+
}
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
431 |
+
|
432 |
+
$this->_getCheckoutSession()->addError(
|
433 |
+
$this->__('There was an error processing your order. Please contact us or try again later.')
|
434 |
+
);
|
435 |
+
|
436 |
+
return array(
|
437 |
+
'success' => false,
|
438 |
+
'error' => true,
|
439 |
+
'redirect' => Mage::getUrl('checkout/cart')
|
440 |
+
);
|
441 |
+
}
|
442 |
+
|
443 |
+
public function saveOrderAction()
|
444 |
+
{
|
445 |
+
try {
|
446 |
+
// validate checkout agreements
|
447 |
+
$result = $this->_validateCheckoutAgreements(
|
448 |
+
array_keys($this->getRequest()->getPost('agreement', array())),
|
449 |
+
Mage::helper('checkout')->getRequiredAgreementIds()
|
450 |
+
);
|
451 |
+
if ($result) {
|
452 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
453 |
+
return;
|
454 |
+
}
|
455 |
+
|
456 |
+
// validate order reference
|
457 |
+
$orderReferenceDetails = $this->_getApi()->getOrderReferenceDetails(
|
458 |
+
$this->_getOrderReferenceId(),
|
459 |
+
$this->_getAccessToken()
|
460 |
+
);
|
461 |
+
$result = $this->_validateOrderReference($orderReferenceDetails);
|
462 |
+
if ($result) {
|
463 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
464 |
+
return;
|
465 |
+
}
|
466 |
+
|
467 |
+
$skipOrderReferenceProcessing = $orderReferenceDetails->getOrderReferenceStatus()->getState()
|
468 |
+
!= Creativestyle_AmazonPayments_Model_Processor_Transaction::TRANSACTION_STATE_DRAFT;
|
469 |
+
|
470 |
+
$sequenceNumber = (int)$this->_getCheckoutSession()->getAmazonSequenceNumber();
|
471 |
+
$this->_getQuote()->getPayment()
|
472 |
+
->setTransactionId($this->_getOrderReferenceId())
|
473 |
+
->setSkipOrderReferenceProcessing($skipOrderReferenceProcessing)
|
474 |
+
->setAmazonSequenceNumber($sequenceNumber ? $sequenceNumber : null);
|
475 |
+
$this->_getCheckoutSession()->setAmazonSequenceNumber($sequenceNumber ? $sequenceNumber + 1 : 1);
|
476 |
+
|
477 |
+
|
478 |
+
|
479 |
+
$simulation = $this->getRequest()->getPost('simulation', array());
|
480 |
+
if (!empty($simulation) && isset($simulation['object'])) {
|
481 |
+
$simulationData = array(
|
482 |
+
'object' => isset($simulation['object']) ? $simulation['object'] : null,
|
483 |
+
'state' => isset($simulation['state']) ? $simulation['state'] : null,
|
484 |
+
'reason_code' => isset($simulation['reason']) ? $simulation['reason'] : null
|
485 |
+
);
|
486 |
+
$simulationData['options'] = Creativestyle_AmazonPayments_Model_Simulator::getSimulationOptions(
|
487 |
+
$simulationData['object'],
|
488 |
+
$simulationData['state'],
|
489 |
+
$simulationData['reason_code']
|
490 |
+
);
|
491 |
+
$this->_getQuote()->getPayment()->setSimulationData($simulationData);
|
492 |
+
}
|
493 |
+
|
494 |
+
$this->_getCheckout()->saveOrder();
|
495 |
+
$this->_getQuote()->save();
|
496 |
+
$result = array(
|
497 |
+
'success' => true,
|
498 |
+
'error' => false,
|
499 |
+
'redirect' => Mage::getUrl('checkout/onepage/success')
|
500 |
+
);
|
501 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
502 |
+
} catch (Creativestyle_AmazonPayments_Exception_InvalidTransaction $e) {
|
503 |
+
$result = $this->_handleInvalidTransactionException($e);
|
504 |
+
if (is_array($result)) {
|
505 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
506 |
+
return;
|
507 |
+
}
|
508 |
+
} catch (Exception $e) {
|
509 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
510 |
+
Mage::helper('checkout')->sendPaymentFailedEmail($this->_getQuote(), $e->getMessage());
|
511 |
+
$this->_getCheckoutSession()->addError(
|
512 |
+
$this->__('There was an error processing your order. Please contact us or try again later.')
|
513 |
+
);
|
514 |
+
$result = array(
|
515 |
+
'success' => false,
|
516 |
+
'error' => true,
|
517 |
+
'redirect' => Mage::getUrl('checkout/cart')
|
518 |
+
);
|
519 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
520 |
+
}
|
521 |
+
}
|
522 |
+
|
523 |
+
public function clearOrderReferenceAction()
|
524 |
+
{
|
525 |
+
$this->_clearOrderReferenceId();
|
526 |
+
$this->_redirect('checkout/cart');
|
527 |
+
}
|
528 |
+
|
529 |
+
public function cancelOrderReferenceAction()
|
530 |
+
{
|
531 |
+
$this->_cancelOrderReferenceId();
|
532 |
+
$this->_redirect('checkout/cart');
|
533 |
+
}
|
534 |
+
|
535 |
+
public function couponPostAction()
|
536 |
+
{
|
537 |
+
if ($this->getRequest()->isPost()) {
|
538 |
+
try {
|
539 |
+
if ($this->_expireAjax()) {
|
540 |
+
return;
|
541 |
+
}
|
542 |
+
|
543 |
+
$couponCode = (string) $this->getRequest()->getParam('coupon_code');
|
544 |
+
if ($this->getRequest()->getParam('remove') == 1) {
|
545 |
+
$couponCode = '';
|
546 |
+
}
|
547 |
+
|
548 |
+
$this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
|
549 |
+
$result = $this->_getQuote()->setCouponCode($couponCode)
|
550 |
+
->collectTotals()
|
551 |
+
->save();
|
552 |
+
} catch (Exception $e) {
|
553 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
554 |
+
$result = array(
|
555 |
+
'error' => -1,
|
556 |
+
'error_messages' => $e->getMessage()
|
557 |
+
);
|
558 |
+
}
|
559 |
+
|
560 |
+
if (!isset($result['error'])) {
|
561 |
+
$result = array(
|
562 |
+
'render_widget' => array(
|
563 |
+
'review' => $this->_getReviewHtml()
|
564 |
+
),
|
565 |
+
'allow_submit' => $this->_isSubmitAllowed()
|
566 |
+
);
|
567 |
+
};
|
568 |
+
} else {
|
569 |
+
$this->_forward('noRoute');
|
570 |
+
return;
|
571 |
+
}
|
572 |
+
|
573 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
574 |
+
}
|
575 |
+
}
|
app/code/community/Creativestyle/AmazonPayments/controllers/IpnController.php
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
class Creativestyle_AmazonPayments_IpnController extends Creativestyle_AmazonPayments_Controller_Action
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
protected $_headers = array(
|
23 |
+
'x-amz-sns-message-type',
|
24 |
+
'x-amz-sns-message-id',
|
25 |
+
'x-amz-sns-topic-arn',
|
26 |
+
'x-amz-sns-subscription-arn'
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
protected $_responseCodes = array(
|
33 |
+
200 => '200 OK',
|
34 |
+
400 => '400 Bad Request',
|
35 |
+
403 => '403 Forbidden',
|
36 |
+
404 => '404 Not Found',
|
37 |
+
500 => '500 Internal Server Error',
|
38 |
+
503 => '503 Service Unavailable'
|
39 |
+
);
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Returns Amazon Pay IPN endpoint instance
|
43 |
+
*
|
44 |
+
* @return Creativestyle_AmazonPayments_Model_Api_Ipn
|
45 |
+
*/
|
46 |
+
protected function _getApi()
|
47 |
+
{
|
48 |
+
return Mage::getModel('amazonpayments/api_ipn');
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Returns value of request header with given ID
|
53 |
+
*
|
54 |
+
* @param string $headerId
|
55 |
+
* @return false|string
|
56 |
+
*/
|
57 |
+
protected function _getRequestHeaderById($headerId)
|
58 |
+
{
|
59 |
+
return $this->getRequest()->getHeader($headerId);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Returns values of the defined request headers in array
|
64 |
+
*
|
65 |
+
* @return array
|
66 |
+
*/
|
67 |
+
protected function _getRequestHeaders()
|
68 |
+
{
|
69 |
+
return array_filter(
|
70 |
+
array_combine($this->_headers, array_map(array($this, '_getRequestHeaderById'), $this->_headers)),
|
71 |
+
function ($header) {
|
72 |
+
return (bool)$header;
|
73 |
+
}
|
74 |
+
);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Returns request headers formatted for log
|
79 |
+
*
|
80 |
+
* @return string
|
81 |
+
*/
|
82 |
+
protected function _getFormattedRequestHeaders()
|
83 |
+
{
|
84 |
+
$formattedHeaders = array();
|
85 |
+
foreach ($this->_getRequestHeaders() as $headerId => $header) {
|
86 |
+
$formattedHeaders[] = sprintf('%s: %s', $headerId, $header);
|
87 |
+
}
|
88 |
+
|
89 |
+
return implode("\n", $formattedHeaders);
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Prepare response for sending
|
94 |
+
*
|
95 |
+
* @param int $code
|
96 |
+
* @param null $message
|
97 |
+
* @return int
|
98 |
+
*/
|
99 |
+
protected function _prepareIpnResponse($code, $message = null)
|
100 |
+
{
|
101 |
+
if (!array_key_exists($code, $this->_responseCodes)) {
|
102 |
+
$code = 500;
|
103 |
+
}
|
104 |
+
|
105 |
+
$this->getResponse()->setHeader('HTTP/1.1', $this->_responseCodes[$code]);
|
106 |
+
|
107 |
+
if ($message) {
|
108 |
+
$this->getResponse()->setBody($message);
|
109 |
+
}
|
110 |
+
|
111 |
+
return $code;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* @inheritdoc
|
116 |
+
*/
|
117 |
+
public function preDispatch()
|
118 |
+
{
|
119 |
+
parent::preDispatch();
|
120 |
+
if (!$this->_getConfig()->isPaymentProcessingAllowed()
|
121 |
+
|| !$this->_getConfig()->isIpnActive()
|
122 |
+
|| !$this->getRequest()->isPost()) {
|
123 |
+
if ($this->getRequest()->getActionName() != 'noRoute') {
|
124 |
+
$this->_forward('noRoute');
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* IPN entry point action
|
131 |
+
*/
|
132 |
+
public function indexAction()
|
133 |
+
{
|
134 |
+
try {
|
135 |
+
$transactionId = null;
|
136 |
+
|
137 |
+
/** @var OffAmazonPaymentsNotifications_Model_NotificationImpl $notification */
|
138 |
+
$notification = $this->_getApi()->parseMessage(
|
139 |
+
$this->_getRequestHeaders(),
|
140 |
+
$this->getRequest()->getRawBody()
|
141 |
+
);
|
142 |
+
|
143 |
+
$transactionId = $this->_getApi()->processNotification($notification);
|
144 |
+
$responseError = null;
|
145 |
+
$responseCode = $this->_prepareIpnResponse(200);
|
146 |
+
} catch (OffAmazonPaymentsNotifications_InvalidMessageException $e) {
|
147 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
148 |
+
$responseError = $e->getMessage();
|
149 |
+
$responseCode = $this->_prepareIpnResponse(400, $responseError);
|
150 |
+
} catch (Exception $e) {
|
151 |
+
Creativestyle_AmazonPayments_Model_Logger::logException($e);
|
152 |
+
$responseError = $e->getMessage();
|
153 |
+
$responseCode = $this->_prepareIpnResponse($e->getCode(), $responseError);
|
154 |
+
}
|
155 |
+
|
156 |
+
if ($notification) {
|
157 |
+
Mage::dispatchEvent(
|
158 |
+
'amazonpayments_ipn_request',
|
159 |
+
array('call_data' => array(
|
160 |
+
'notification_type' => $notification->getNotificationType(),
|
161 |
+
'transaction_id' => $transactionId,
|
162 |
+
'response_code' => $responseCode,
|
163 |
+
'response_error' => $responseError,
|
164 |
+
'request_headers' => $this->_getFormattedRequestHeaders(),
|
165 |
+
'request_body' => $this->getRequest()->getRawBody()
|
166 |
+
))
|
167 |
+
);
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
app/code/community/Creativestyle/AmazonPayments/etc/config.xml
CHANGED
@@ -1,23 +1,25 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-->
|
17 |
<config>
|
18 |
<modules>
|
19 |
<Creativestyle_AmazonPayments>
|
20 |
-
<version>
|
21 |
</Creativestyle_AmazonPayments>
|
22 |
</modules>
|
23 |
<global>
|
@@ -40,7 +42,7 @@
|
|
40 |
<amazonpayments_setup>
|
41 |
<setup>
|
42 |
<module>Creativestyle_AmazonPayments</module>
|
43 |
-
<class>
|
44 |
</setup>
|
45 |
<connection>
|
46 |
<use>core_setup</use>
|
@@ -67,7 +69,7 @@
|
|
67 |
</amazonpayments_advanced_observer>
|
68 |
</observers>
|
69 |
</amazonpayments_advanced_api_post_call>
|
70 |
-
<
|
71 |
<observers>
|
72 |
<amazonpayments_advanced_observer>
|
73 |
<type>singleton</type>
|
@@ -75,7 +77,7 @@
|
|
75 |
<method>logIpnCall</method>
|
76 |
</amazonpayments_advanced_observer>
|
77 |
</observers>
|
78 |
-
</
|
79 |
<controller_action_layout_render_before_adminhtml_sales_order_view>
|
80 |
<observers>
|
81 |
<amazonpayments_advanced_observer>
|
@@ -85,33 +87,24 @@
|
|
85 |
</amazonpayments_advanced_observer>
|
86 |
</observers>
|
87 |
</controller_action_layout_render_before_adminhtml_sales_order_view>
|
88 |
-
<
|
89 |
-
<observers>
|
90 |
-
<amazonpayments_advanced_observer>
|
91 |
-
<type>singleton</type>
|
92 |
-
<class>Creativestyle_AmazonPayments_Model_Observer</class>
|
93 |
-
<method>closeTransaction</method>
|
94 |
-
</amazonpayments_advanced_observer>
|
95 |
-
</observers>
|
96 |
-
</sales_order_payment_transaction_save_before>
|
97 |
-
<sales_order_payment_transaction_save_after>
|
98 |
<observers>
|
99 |
<amazonpayments_advanced_observer>
|
100 |
<type>singleton</type>
|
101 |
<class>Creativestyle_AmazonPayments_Model_Observer</class>
|
102 |
-
<method>
|
103 |
</amazonpayments_advanced_observer>
|
104 |
</observers>
|
105 |
-
</
|
106 |
-
<
|
107 |
<observers>
|
108 |
<amazonpayments_advanced_observer>
|
109 |
<type>singleton</type>
|
110 |
<class>Creativestyle_AmazonPayments_Model_Observer</class>
|
111 |
-
<method>
|
112 |
</amazonpayments_advanced_observer>
|
113 |
</observers>
|
114 |
-
</
|
115 |
</events>
|
116 |
<payment>
|
117 |
<groups>
|
@@ -361,9 +354,10 @@
|
|
361 |
</modules>
|
362 |
</translate>
|
363 |
<secure_url>
|
364 |
-
<amazonpayments_checkout>/amazonpayments/
|
365 |
<amazonpayments_login>/amazonpayments/advanced_login</amazonpayments_login>
|
366 |
-
<amazonpayments_ipn>/amazonpayments/
|
|
|
367 |
</secure_url>
|
368 |
</frontend>
|
369 |
<admin>
|
@@ -402,7 +396,7 @@
|
|
402 |
<run><model>amazonpayments/observer::rotateLogfiles</model></run>
|
403 |
</amazonpayments_advanced_log_rotate>
|
404 |
<amazonpayments_advanced_data_poll>
|
405 |
-
<run><model>amazonpayments/observer::
|
406 |
</amazonpayments_advanced_data_poll>
|
407 |
</jobs>
|
408 |
</crontab>
|
@@ -448,14 +442,13 @@
|
|
448 |
<sandbox_toolbox>0</sandbox_toolbox>
|
449 |
<ipn_active>1</ipn_active>
|
450 |
<payment_action>authorize</payment_action>
|
451 |
-
<authorization_mode>
|
452 |
<new_order_status>pending</new_order_status>
|
453 |
<authorized_order_status>processing</authorized_order_status>
|
454 |
<language></language>
|
455 |
<authentication>auto</authentication>
|
456 |
</general>
|
457 |
<email>
|
458 |
-
<order_confirmation>1</order_confirmation>
|
459 |
<authorization_declined_template>amazonpayments_advanced_authorization_declined</authorization_declined_template>
|
460 |
<authorization_declined_identity>sales</authorization_declined_identity>
|
461 |
</email>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
5 |
+
* for Magento 1.x
|
|
|
6 |
*
|
7 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
8 |
+
*
|
9 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
10 |
+
* this software, is not allowed without explicit written permission granted
|
11 |
+
* by creativestyle GmbH
|
12 |
*
|
13 |
* @category Creativestyle
|
14 |
* @package Creativestyle_AmazonPayments
|
15 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
16 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
17 |
*/
|
18 |
-->
|
19 |
<config>
|
20 |
<modules>
|
21 |
<Creativestyle_AmazonPayments>
|
22 |
+
<version>2.0.0</version>
|
23 |
</Creativestyle_AmazonPayments>
|
24 |
</modules>
|
25 |
<global>
|
42 |
<amazonpayments_setup>
|
43 |
<setup>
|
44 |
<module>Creativestyle_AmazonPayments</module>
|
45 |
+
<class>Creativestyle_AmazonPayments_Model_Resource_Setup</class>
|
46 |
</setup>
|
47 |
<connection>
|
48 |
<use>core_setup</use>
|
69 |
</amazonpayments_advanced_observer>
|
70 |
</observers>
|
71 |
</amazonpayments_advanced_api_post_call>
|
72 |
+
<amazonpayments_ipn_request>
|
73 |
<observers>
|
74 |
<amazonpayments_advanced_observer>
|
75 |
<type>singleton</type>
|
77 |
<method>logIpnCall</method>
|
78 |
</amazonpayments_advanced_observer>
|
79 |
</observers>
|
80 |
+
</amazonpayments_ipn_request>
|
81 |
<controller_action_layout_render_before_adminhtml_sales_order_view>
|
82 |
<observers>
|
83 |
<amazonpayments_advanced_observer>
|
87 |
</amazonpayments_advanced_observer>
|
88 |
</observers>
|
89 |
</controller_action_layout_render_before_adminhtml_sales_order_view>
|
90 |
+
<controller_front_init_before>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
<observers>
|
92 |
<amazonpayments_advanced_observer>
|
93 |
<type>singleton</type>
|
94 |
<class>Creativestyle_AmazonPayments_Model_Observer</class>
|
95 |
+
<method>setSecureUrls</method>
|
96 |
</amazonpayments_advanced_observer>
|
97 |
</observers>
|
98 |
+
</controller_front_init_before>
|
99 |
+
<sales_order_payment_transaction_save_before>
|
100 |
<observers>
|
101 |
<amazonpayments_advanced_observer>
|
102 |
<type>singleton</type>
|
103 |
<class>Creativestyle_AmazonPayments_Model_Observer</class>
|
104 |
+
<method>saveTransactionBefore</method>
|
105 |
</amazonpayments_advanced_observer>
|
106 |
</observers>
|
107 |
+
</sales_order_payment_transaction_save_before>
|
108 |
</events>
|
109 |
<payment>
|
110 |
<groups>
|
354 |
</modules>
|
355 |
</translate>
|
356 |
<secure_url>
|
357 |
+
<amazonpayments_checkout>/amazonpayments/checkout</amazonpayments_checkout>
|
358 |
<amazonpayments_login>/amazonpayments/advanced_login</amazonpayments_login>
|
359 |
+
<amazonpayments_ipn>/amazonpayments/ipn</amazonpayments_ipn>
|
360 |
+
<amazonpayments_ipn_legacy>/amazonpayments/advanced_ipn</amazonpayments_ipn_legacy>
|
361 |
</secure_url>
|
362 |
</frontend>
|
363 |
<admin>
|
396 |
<run><model>amazonpayments/observer::rotateLogfiles</model></run>
|
397 |
</amazonpayments_advanced_log_rotate>
|
398 |
<amazonpayments_advanced_data_poll>
|
399 |
+
<run><model>amazonpayments/observer::pollPaymentTransactionData</model></run>
|
400 |
</amazonpayments_advanced_data_poll>
|
401 |
</jobs>
|
402 |
</crontab>
|
442 |
<sandbox_toolbox>0</sandbox_toolbox>
|
443 |
<ipn_active>1</ipn_active>
|
444 |
<payment_action>authorize</payment_action>
|
445 |
+
<authorization_mode>auto</authorization_mode>
|
446 |
<new_order_status>pending</new_order_status>
|
447 |
<authorized_order_status>processing</authorized_order_status>
|
448 |
<language></language>
|
449 |
<authentication>auto</authentication>
|
450 |
</general>
|
451 |
<email>
|
|
|
452 |
<authorization_declined_template>amazonpayments_advanced_authorization_declined</authorization_declined_template>
|
453 |
<authorization_declined_identity>sales</authorization_declined_identity>
|
454 |
</email>
|
app/code/community/Creativestyle/AmazonPayments/etc/system.xml
CHANGED
@@ -128,7 +128,6 @@
|
|
128 |
<show_in_default>1</show_in_default>
|
129 |
<show_in_website>1</show_in_website>
|
130 |
<show_in_store>1</show_in_store>
|
131 |
-
<depends><active>1</active></depends>
|
132 |
</sandbox>
|
133 |
<sandbox_toolbox translate="label">
|
134 |
<label>Show Sandbox Toolbox</label>
|
@@ -226,6 +225,7 @@
|
|
226 |
<show_in_default>1</show_in_default>
|
227 |
<show_in_website>1</show_in_website>
|
228 |
<show_in_store>1</show_in_store>
|
|
|
229 |
</language>
|
230 |
<authentication>
|
231 |
<label>Authentication Experience</label>
|
@@ -235,71 +235,23 @@
|
|
235 |
<show_in_default>1</show_in_default>
|
236 |
<show_in_website>1</show_in_website>
|
237 |
<show_in_store>1</show_in_store>
|
238 |
-
<depends><
|
239 |
</authentication>
|
240 |
</fields>
|
241 |
</general>
|
242 |
-
<login translate="label">
|
243 |
-
<label>Login with Amazon</label>
|
244 |
-
<sort_order>250</sort_order>
|
245 |
-
<show_in_default>0</show_in_default>
|
246 |
-
<show_in_website>0</show_in_website>
|
247 |
-
<show_in_store>0</show_in_store>
|
248 |
-
<fields>
|
249 |
-
<active translate="label">
|
250 |
-
<label>Enable Login with Amazon</label>
|
251 |
-
<frontend_type>select</frontend_type>
|
252 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
253 |
-
<sort_order>10</sort_order>
|
254 |
-
<show_in_default>1</show_in_default>
|
255 |
-
<show_in_website>1</show_in_website>
|
256 |
-
<show_in_store>1</show_in_store>
|
257 |
-
</active>
|
258 |
-
<client_id translate="label comment">
|
259 |
-
<label>Client ID</label>
|
260 |
-
<comment><![CDATA[Account information can be found <a target="_blank" href="https://sellercentral-europe.amazon.com/hz/me/integration/details">here</a>]]></comment>
|
261 |
-
<frontend_type>text</frontend_type>
|
262 |
-
<sort_order>20</sort_order>
|
263 |
-
<show_in_default>1</show_in_default>
|
264 |
-
<show_in_website>1</show_in_website>
|
265 |
-
<show_in_store>1</show_in_store>
|
266 |
-
<depends><active>1</active></depends>
|
267 |
-
</client_id>
|
268 |
-
<language>
|
269 |
-
<label>Display Language</label>
|
270 |
-
<frontend_type>select</frontend_type>
|
271 |
-
<source_model>amazonpayments/lookup_language</source_model>
|
272 |
-
<sort_order>25</sort_order>
|
273 |
-
<show_in_default>1</show_in_default>
|
274 |
-
<show_in_website>1</show_in_website>
|
275 |
-
<show_in_store>1</show_in_store>
|
276 |
-
<depends><active>1</active></depends>
|
277 |
-
</language>
|
278 |
-
<authentication>
|
279 |
-
<label>Authentication Experience</label>
|
280 |
-
<frontend_type>select</frontend_type>
|
281 |
-
<source_model>amazonpayments/lookup_authentication</source_model>
|
282 |
-
<sort_order>30</sort_order>
|
283 |
-
<show_in_default>1</show_in_default>
|
284 |
-
<show_in_website>1</show_in_website>
|
285 |
-
<show_in_store>1</show_in_store>
|
286 |
-
<depends><active>1</active></depends>
|
287 |
-
</authentication>
|
288 |
-
</fields>
|
289 |
-
</login>
|
290 |
<store translate="label">
|
291 |
<label>Store Options</label>
|
292 |
<sort_order>250</sort_order>
|
293 |
-
<show_in_default>
|
294 |
-
<show_in_website>
|
295 |
<show_in_store>1</show_in_store>
|
296 |
<fields>
|
297 |
<name translate="label">
|
298 |
<label>Store name</label>
|
299 |
<frontend_type>text</frontend_type>
|
300 |
<sort_order>10</sort_order>
|
301 |
-
<show_in_default>
|
302 |
-
<show_in_website>
|
303 |
<show_in_store>1</show_in_store>
|
304 |
</name>
|
305 |
</fields>
|
@@ -311,16 +263,6 @@
|
|
311 |
<show_in_website>1</show_in_website>
|
312 |
<show_in_store>1</show_in_store>
|
313 |
<fields>
|
314 |
-
<order_confirmation translate="label">
|
315 |
-
<label>Send order confirmation</label>
|
316 |
-
<comment>Select whether an email confirmation for newly placed orders shall be sent by the shop</comment>
|
317 |
-
<frontend_type>select</frontend_type>
|
318 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
319 |
-
<sort_order>10</sort_order>
|
320 |
-
<show_in_default>1</show_in_default>
|
321 |
-
<show_in_website>1</show_in_website>
|
322 |
-
<show_in_store>1</show_in_store>
|
323 |
-
</order_confirmation>
|
324 |
<authorization_declined_template translate="label">
|
325 |
<label>Declined Payment Email Template</label>
|
326 |
<frontend_type>select</frontend_type>
|
128 |
<show_in_default>1</show_in_default>
|
129 |
<show_in_website>1</show_in_website>
|
130 |
<show_in_store>1</show_in_store>
|
|
|
131 |
</sandbox>
|
132 |
<sandbox_toolbox translate="label">
|
133 |
<label>Show Sandbox Toolbox</label>
|
225 |
<show_in_default>1</show_in_default>
|
226 |
<show_in_website>1</show_in_website>
|
227 |
<show_in_store>1</show_in_store>
|
228 |
+
<depends><login_active>1</login_active></depends>
|
229 |
</language>
|
230 |
<authentication>
|
231 |
<label>Authentication Experience</label>
|
235 |
<show_in_default>1</show_in_default>
|
236 |
<show_in_website>1</show_in_website>
|
237 |
<show_in_store>1</show_in_store>
|
238 |
+
<depends><login_active>1</login_active></depends>
|
239 |
</authentication>
|
240 |
</fields>
|
241 |
</general>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
<store translate="label">
|
243 |
<label>Store Options</label>
|
244 |
<sort_order>250</sort_order>
|
245 |
+
<show_in_default>1</show_in_default>
|
246 |
+
<show_in_website>1</show_in_website>
|
247 |
<show_in_store>1</show_in_store>
|
248 |
<fields>
|
249 |
<name translate="label">
|
250 |
<label>Store name</label>
|
251 |
<frontend_type>text</frontend_type>
|
252 |
<sort_order>10</sort_order>
|
253 |
+
<show_in_default>1</show_in_default>
|
254 |
+
<show_in_website>1</show_in_website>
|
255 |
<show_in_store>1</show_in_store>
|
256 |
</name>
|
257 |
</fields>
|
263 |
<show_in_website>1</show_in_website>
|
264 |
<show_in_store>1</show_in_store>
|
265 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
<authorization_declined_template translate="label">
|
267 |
<label>Declined Payment Email Template</label>
|
268 |
<frontend_type>select</frontend_type>
|
app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-install-1.0.0.php
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
|
17 |
$installer = $this;
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
|
18 |
$installer = $this;
|
app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-install-1.6.2.php
CHANGED
@@ -1,28 +1,31 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
|
17 |
$installer = $this;
|
18 |
$installer->startSetup();
|
19 |
|
20 |
-
$installer->addAttribute(
|
21 |
-
'
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
27 |
|
28 |
-
$installer->endSetup();
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2015 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2015 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
|
18 |
$installer = $this;
|
19 |
$installer->startSetup();
|
20 |
|
21 |
+
$installer->addAttribute(
|
22 |
+
'customer', 'amazon_user_id', array(
|
23 |
+
'type' => 'varchar',
|
24 |
+
'label' => 'Amazon UID',
|
25 |
+
'visible' => false,
|
26 |
+
'required' => false,
|
27 |
+
'unique' => true
|
28 |
+
)
|
29 |
+
);
|
30 |
|
31 |
+
$installer->endSetup();
|
app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-install-2.0.0.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
|
18 |
+
/** @var Creativestyle_AmazonPayments_Model_Resource_Setup $installer */
|
19 |
+
$installer = $this;
|
20 |
+
$installer->startSetup();
|
21 |
+
|
22 |
+
$installer->addAttribute(
|
23 |
+
'customer',
|
24 |
+
'amazon_user_id',
|
25 |
+
array(
|
26 |
+
'type' => 'varchar',
|
27 |
+
'label' => 'Amazon UID',
|
28 |
+
'visible' => false,
|
29 |
+
'required' => false,
|
30 |
+
'unique' => true
|
31 |
+
)
|
32 |
+
);
|
33 |
+
|
34 |
+
$installer->endSetup();
|
app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-1.1.6-1.2.0.php
CHANGED
@@ -1,28 +1,31 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
|
17 |
$installer = $this;
|
18 |
$installer->startSetup();
|
19 |
|
20 |
-
$installer->addAttribute(
|
21 |
-
'
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
27 |
|
28 |
$installer->endSetup();
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
|
18 |
$installer = $this;
|
19 |
$installer->startSetup();
|
20 |
|
21 |
+
$installer->addAttribute(
|
22 |
+
'customer', 'amazon_user_id', array(
|
23 |
+
'type' => 'varchar',
|
24 |
+
'label' => 'Amazon UID',
|
25 |
+
'visible' => false,
|
26 |
+
'required' => false,
|
27 |
+
'unique' => true
|
28 |
+
)
|
29 |
+
);
|
30 |
|
31 |
$installer->endSetup();
|
app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-1.7.4-1.7.6.php
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
|
17 |
$installer = $this;
|
@@ -20,13 +21,15 @@ $installer->startSetup();
|
|
20 |
$amazonUserIdAttr = Mage::getResourceModel('catalog/eav_attribute')->loadByCode('customer', 'amazon_user_id');
|
21 |
|
22 |
if (!$amazonUserIdAttr->getId()) {
|
23 |
-
$installer->addAttribute(
|
24 |
-
'
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
30 |
}
|
31 |
|
32 |
$installer->endSetup();
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2016 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2016 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
|
18 |
$installer = $this;
|
21 |
$amazonUserIdAttr = Mage::getResourceModel('catalog/eav_attribute')->loadByCode('customer', 'amazon_user_id');
|
22 |
|
23 |
if (!$amazonUserIdAttr->getId()) {
|
24 |
+
$installer->addAttribute(
|
25 |
+
'customer', 'amazon_user_id', array(
|
26 |
+
'type' => 'varchar',
|
27 |
+
'label' => 'Amazon UID',
|
28 |
+
'visible' => false,
|
29 |
+
'required' => false,
|
30 |
+
'unique' => true
|
31 |
+
)
|
32 |
+
);
|
33 |
}
|
34 |
|
35 |
$installer->endSetup();
|
app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-1.7.8-1.8.2.php
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
*
|
|
|
7 |
*
|
8 |
-
*
|
9 |
-
* without written permission
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
|
17 |
$installer = $this;
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2016 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2016 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
|
18 |
$installer = $this;
|
app/design/adminhtml/default/default/template/creativestyle/amazonpayments/advanced/log/{notification → ipn}/view.phtml
RENAMED
@@ -1,3 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<div class="content-header">
|
2 |
<table cellspacing="0">
|
3 |
<tr>
|
@@ -23,11 +40,23 @@
|
|
23 |
<td class="label"><label><?php echo $this->__('Notification type'); ?></label></td>
|
24 |
<td class="value"><?php echo $this->escapeHtml($this->getNotificationType()); ?></td>
|
25 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
<tr>
|
27 |
<td class="label"><label><?php echo $this->__('Response code'); ?></label></td>
|
28 |
<td class="value"><?php echo $this->escapeHtml($this->getResponseCode()); ?></td>
|
29 |
</tr>
|
30 |
-
<?php if ($this->getResponseError()): ?>
|
31 |
<tr>
|
32 |
<td class="label"><label><?php echo $this->__('Response error'); ?></label></td>
|
33 |
<td class="value"><?php echo $this->escapeHtml($this->getResponseError()); ?></td>
|
@@ -36,7 +65,7 @@
|
|
36 |
</tbody>
|
37 |
</table>
|
38 |
</div>
|
39 |
-
<?php if ($this->getMessageXml()): ?>
|
40 |
<div class="entry-edit-head">
|
41 |
<h4><?php echo $this->__('Extracted XML message'); ?></h4>
|
42 |
</div>
|
@@ -44,15 +73,16 @@
|
|
44 |
<pre><code class="language-markup"><?php echo $this->escapeHtml($this->getMessageXml()); ?></code></pre>
|
45 |
</div>
|
46 |
<?php endif; ?>
|
47 |
-
<?php if ($this->getRequestBody()): ?>
|
48 |
<div class="entry-edit-head">
|
49 |
<h4><?php echo $this->__('Request Body'); ?></h4>
|
50 |
</div>
|
51 |
<div class="box box-code">
|
52 |
-
<pre><code class="language-javascript"><?php
|
|
|
53 |
</div>
|
54 |
<?php endif; ?>
|
55 |
-
<?php if ($this->getRequestHeaders()): ?>
|
56 |
<div class="entry-edit-head">
|
57 |
<h4><?php echo $this->__('Request Headers'); ?></h4>
|
58 |
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
5 |
+
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
+
*
|
12 |
+
* @category Creativestyle
|
13 |
+
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
+
*/
|
17 |
+
?>
|
18 |
<div class="content-header">
|
19 |
<table cellspacing="0">
|
20 |
<tr>
|
40 |
<td class="label"><label><?php echo $this->__('Notification type'); ?></label></td>
|
41 |
<td class="value"><?php echo $this->escapeHtml($this->getNotificationType()); ?></td>
|
42 |
</tr>
|
43 |
+
<?php if ($txnId = $this->escapeHtml($this->getTransactionId())) : ?>
|
44 |
+
<tr>
|
45 |
+
<td class="label"><label><?php echo $this->__('Transaction ID'); ?></label></td>
|
46 |
+
<td class="value">
|
47 |
+
<?php if ($txnLink = $this->getTransactionLink()) : ?>
|
48 |
+
<?php echo sprintf('<a href="%s">%s</a>', $txnLink, $txnId); ?>
|
49 |
+
<?php else : ?>
|
50 |
+
<?php echo $txnId; ?>
|
51 |
+
<?php endif; ?>
|
52 |
+
</td>
|
53 |
+
</tr>
|
54 |
+
<?php endif; ?>
|
55 |
<tr>
|
56 |
<td class="label"><label><?php echo $this->__('Response code'); ?></label></td>
|
57 |
<td class="value"><?php echo $this->escapeHtml($this->getResponseCode()); ?></td>
|
58 |
</tr>
|
59 |
+
<?php if ($this->getResponseError()) : ?>
|
60 |
<tr>
|
61 |
<td class="label"><label><?php echo $this->__('Response error'); ?></label></td>
|
62 |
<td class="value"><?php echo $this->escapeHtml($this->getResponseError()); ?></td>
|
65 |
</tbody>
|
66 |
</table>
|
67 |
</div>
|
68 |
+
<?php if ($this->getMessageXml()) : ?>
|
69 |
<div class="entry-edit-head">
|
70 |
<h4><?php echo $this->__('Extracted XML message'); ?></h4>
|
71 |
</div>
|
73 |
<pre><code class="language-markup"><?php echo $this->escapeHtml($this->getMessageXml()); ?></code></pre>
|
74 |
</div>
|
75 |
<?php endif; ?>
|
76 |
+
<?php if ($this->getRequestBody()) : ?>
|
77 |
<div class="entry-edit-head">
|
78 |
<h4><?php echo $this->__('Request Body'); ?></h4>
|
79 |
</div>
|
80 |
<div class="box box-code">
|
81 |
+
<pre><code class="language-javascript"><?php
|
82 |
+
echo $this->escapeHtml($this->getRequestBody()); ?></code></pre>
|
83 |
</div>
|
84 |
<?php endif; ?>
|
85 |
+
<?php if ($this->getRequestHeaders()) : ?>
|
86 |
<div class="entry-edit-head">
|
87 |
<h4><?php echo $this->__('Request Headers'); ?></h4>
|
88 |
</div>
|
app/design/frontend/base/default/layout/amazonpayments.xml
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
-->
|
17 |
<layout version="1.2.0">
|
@@ -19,8 +21,6 @@
|
|
19 |
<reference name="head">
|
20 |
<action method="addCss"><stylesheet helper="amazonpayments/getHeadCss"/></action>
|
21 |
<action method="addCss"><stylesheet helper="amazonpayments/getWidgetsCss"/></action>
|
22 |
-
<action method="addJs"><script helper="amazonpayments/getHeadTooltipJs"/></action>
|
23 |
-
<action method="addJs"><script helper="amazonpayments/getHeadJs"/></action>
|
24 |
</reference>
|
25 |
<reference name="cart_sidebar.extra_actions">
|
26 |
<block type="amazonpayments/pay_button" name="top_cart.amazonpayments.pay_button" before="-">
|
@@ -29,16 +29,13 @@
|
|
29 |
</block>
|
30 |
</reference>
|
31 |
<reference name="before_body_end">
|
32 |
-
<block type="amazonpayments/js" name="amazonpayments.js"
|
33 |
-
<block type="amazonpayments/login_js" name="amazonpayments.js.login" as="amazonpayments_login_js" template="creativestyle/amazonpayments/login/js.phtml"/>
|
34 |
-
<block type="amazonpayments/button_js" name="amazonpayments.js.button" template="creativestyle/amazonpayments/button/js.phtml"/>
|
35 |
-
</block>
|
36 |
</reference>
|
37 |
</default>
|
38 |
<checkout_cart_index>
|
39 |
<reference name="checkout.cart.methods">
|
40 |
<block type="amazonpayments/pay_button" name="checkout.cart.methods.amazonpayments_pay.bottom" before="-">
|
41 |
-
<action method="setIdSuffix"><value>
|
42 |
<action method="setEnableOr"><value>1</value></action>
|
43 |
</block>
|
44 |
</reference>
|
@@ -52,17 +49,14 @@
|
|
52 |
<checkout_onepage_index>
|
53 |
<reference name="checkout.onepage.login.before">
|
54 |
<block type="amazonpayments/onepage_button" name="onepage.amazonpayments.button">
|
55 |
-
<block type="amazonpayments/pay_button" name="onepage.amazonpayments.button.pay"
|
56 |
-
<action method="setIdSuffix"><value>onepage</value></action>
|
57 |
-
</block>
|
58 |
-
<block type="amazonpayments/login_button" name="onepage.amazonpayments.button.login" template="creativestyle/amazonpayments/onepage/button.phtml">
|
59 |
<action method="setIdSuffix"><value>onepage</value></action>
|
60 |
</block>
|
61 |
</block>
|
62 |
</reference>
|
63 |
</checkout_onepage_index>
|
64 |
-
<
|
65 |
-
<label>
|
66 |
<remove name="left"/>
|
67 |
<remove name="right"/>
|
68 |
<reference name="root">
|
@@ -74,7 +68,7 @@
|
|
74 |
<block type="checkout/onepage_shipping_method" name="amazonpayments.checkout.shipping_method" as="shipping_method" template="creativestyle/amazonpayments/checkout/shipping_method.phtml"/>
|
75 |
<block type="checkout/onepage_shipping_method_additional" name="amazonpayments.checkout.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
|
76 |
<block type="amazonpayments/checkout_sandboxToolbox" name="amazonpayments.checkout.sandbox_toolbox" as="sandbox_toolbox" template="creativestyle/amazonpayments/checkout/sandbox_toolbox.phtml"/>
|
77 |
-
<block type="checkout/onepage_review_info" name="
|
78 |
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
|
79 |
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
|
80 |
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
|
@@ -84,6 +78,7 @@
|
|
84 |
</block>
|
85 |
<block type="core/text_list" name="checkout.onepage.review.info.items.after" as="items_after" translate="label">
|
86 |
<label>Items After</label>
|
|
|
87 |
</block>
|
88 |
<block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
|
89 |
<block type="core/template" name="checkout.onepage.review.button" as="button" template="creativestyle/amazonpayments/checkout/review/button.phtml"/>
|
@@ -91,15 +86,15 @@
|
|
91 |
</block>
|
92 |
</reference>
|
93 |
<reference name="amazonpayments.js">
|
94 |
-
<
|
95 |
</reference>
|
96 |
-
</
|
97 |
-
<
|
98 |
<remove name="right"/>
|
99 |
<remove name="left"/>
|
100 |
<block type="checkout/onepage_shipping_method_available" name="root" output="toHtml" template="checkout/onepage/shipping_method/available.phtml"/>
|
101 |
-
</
|
102 |
-
<
|
103 |
<remove name="right"/>
|
104 |
<remove name="left"/>
|
105 |
<block type="checkout/onepage_review_info" name="root" output="toHtml" template="checkout/onepage/review/info.phtml">
|
@@ -117,7 +112,7 @@
|
|
117 |
<block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
|
118 |
<block type="core/template" name="checkout.onepage.review.button" as="button" template="creativestyle/amazonpayments/checkout/review/button.phtml"/>
|
119 |
</block>
|
120 |
-
</
|
121 |
<customer_account_login>
|
122 |
<reference name="content">
|
123 |
<block type="amazonpayments/login_button" name="amazonpayments_login" template="creativestyle/amazonpayments/login/button/account_login.phtml">
|
@@ -136,7 +131,7 @@
|
|
136 |
</customer_account_create>
|
137 |
<customer_account_logoutsuccess translate="label">
|
138 |
<reference name="amazonpayments.js">
|
139 |
-
<
|
140 |
</reference>
|
141 |
</customer_account_logoutsuccess>
|
142 |
<amazonpayments_advanced_login_index>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
5 |
+
* for Magento 1.x
|
|
|
6 |
*
|
7 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
8 |
+
*
|
9 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
10 |
+
* this software, is not allowed without explicit written permission granted
|
11 |
+
* by creativestyle GmbH
|
12 |
*
|
13 |
* @category Creativestyle
|
14 |
* @package Creativestyle_AmazonPayments
|
15 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
16 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
17 |
*/
|
18 |
-->
|
19 |
<layout version="1.2.0">
|
21 |
<reference name="head">
|
22 |
<action method="addCss"><stylesheet helper="amazonpayments/getHeadCss"/></action>
|
23 |
<action method="addCss"><stylesheet helper="amazonpayments/getWidgetsCss"/></action>
|
|
|
|
|
24 |
</reference>
|
25 |
<reference name="cart_sidebar.extra_actions">
|
26 |
<block type="amazonpayments/pay_button" name="top_cart.amazonpayments.pay_button" before="-">
|
29 |
</block>
|
30 |
</reference>
|
31 |
<reference name="before_body_end">
|
32 |
+
<block type="amazonpayments/js" name="amazonpayments.js"/>
|
|
|
|
|
|
|
33 |
</reference>
|
34 |
</default>
|
35 |
<checkout_cart_index>
|
36 |
<reference name="checkout.cart.methods">
|
37 |
<block type="amazonpayments/pay_button" name="checkout.cart.methods.amazonpayments_pay.bottom" before="-">
|
38 |
+
<action method="setIdSuffix"><value>bottom</value></action>
|
39 |
<action method="setEnableOr"><value>1</value></action>
|
40 |
</block>
|
41 |
</reference>
|
49 |
<checkout_onepage_index>
|
50 |
<reference name="checkout.onepage.login.before">
|
51 |
<block type="amazonpayments/onepage_button" name="onepage.amazonpayments.button">
|
52 |
+
<block type="amazonpayments/pay_button" name="onepage.amazonpayments.button.pay" as="amazonpayments_button_pay" before="-">
|
|
|
|
|
|
|
53 |
<action method="setIdSuffix"><value>onepage</value></action>
|
54 |
</block>
|
55 |
</block>
|
56 |
</reference>
|
57 |
</checkout_onepage_index>
|
58 |
+
<amazonpayments_checkout_index>
|
59 |
+
<label>Amazon Pay checkout</label>
|
60 |
<remove name="left"/>
|
61 |
<remove name="right"/>
|
62 |
<reference name="root">
|
68 |
<block type="checkout/onepage_shipping_method" name="amazonpayments.checkout.shipping_method" as="shipping_method" template="creativestyle/amazonpayments/checkout/shipping_method.phtml"/>
|
69 |
<block type="checkout/onepage_shipping_method_additional" name="amazonpayments.checkout.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
|
70 |
<block type="amazonpayments/checkout_sandboxToolbox" name="amazonpayments.checkout.sandbox_toolbox" as="sandbox_toolbox" template="creativestyle/amazonpayments/checkout/sandbox_toolbox.phtml"/>
|
71 |
+
<block type="checkout/onepage_review_info" name="amazonpayments.checkout.review" as="review" template="checkout/onepage/review/info.phtml">
|
72 |
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
|
73 |
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
|
74 |
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
|
78 |
</block>
|
79 |
<block type="core/text_list" name="checkout.onepage.review.info.items.after" as="items_after" translate="label">
|
80 |
<label>Items After</label>
|
81 |
+
<block type="checkout/cart_coupon" name="checkout.onepage.review.coupon" as="coupon" template="creativestyle/amazonpayments/checkout/review/coupon.phtml"/>
|
82 |
</block>
|
83 |
<block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
|
84 |
<block type="core/template" name="checkout.onepage.review.button" as="button" template="creativestyle/amazonpayments/checkout/review/button.phtml"/>
|
86 |
</block>
|
87 |
</reference>
|
88 |
<reference name="amazonpayments.js">
|
89 |
+
<action method="setIsCheckout"><value>1</value></action>
|
90 |
</reference>
|
91 |
+
</amazonpayments_checkout_index>
|
92 |
+
<amazonpayments_checkout_shippingmethod>
|
93 |
<remove name="right"/>
|
94 |
<remove name="left"/>
|
95 |
<block type="checkout/onepage_shipping_method_available" name="root" output="toHtml" template="checkout/onepage/shipping_method/available.phtml"/>
|
96 |
+
</amazonpayments_checkout_shippingmethod>
|
97 |
+
<amazonpayments_checkout_review>
|
98 |
<remove name="right"/>
|
99 |
<remove name="left"/>
|
100 |
<block type="checkout/onepage_review_info" name="root" output="toHtml" template="checkout/onepage/review/info.phtml">
|
112 |
<block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
|
113 |
<block type="core/template" name="checkout.onepage.review.button" as="button" template="creativestyle/amazonpayments/checkout/review/button.phtml"/>
|
114 |
</block>
|
115 |
+
</amazonpayments_checkout_review>
|
116 |
<customer_account_login>
|
117 |
<reference name="content">
|
118 |
<block type="amazonpayments/login_button" name="amazonpayments_login" template="creativestyle/amazonpayments/login/button/account_login.phtml">
|
131 |
</customer_account_create>
|
132 |
<customer_account_logoutsuccess translate="label">
|
133 |
<reference name="amazonpayments.js">
|
134 |
+
<action method="setIsLogout"><value>1</value></action>
|
135 |
</reference>
|
136 |
</customer_account_logoutsuccess>
|
137 |
<amazonpayments_advanced_login_index>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/button/js.phtml
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This file is part of the official Amazon Payments Advanced extension
|
4 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
5 |
-
* All rights reserved
|
6 |
-
*
|
7 |
-
* Reuse or modification of this source code is not allowed
|
8 |
-
* without written permission from creativestyle GmbH
|
9 |
-
*
|
10 |
-
* @category Creativestyle
|
11 |
-
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
13 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
14 |
-
*/
|
15 |
-
?>
|
16 |
-
<?php if ($this->isVirtual()): ?>
|
17 |
-
var amazonButtonTooltip = '<img src="<?php echo $this->getSkinUrl('creativestyle/images/logo_a-glyph_1x.png'); ?>" alt="<?php echo $this->__('Amazon Pay'); ?>"/><?php echo $this->__('<strong>Amazon Pay</strong> helps you shop quickly, safely and securely. You can pay on our website without re-entering your payment and address details.'); ?>';
|
18 |
-
<?php else: ?>
|
19 |
-
var amazonButtonTooltip = '<img src="<?php echo $this->getSkinUrl('creativestyle/images/logo_a-glyph_1x.png'); ?>" alt="<?php echo $this->__('Amazon Pay'); ?>"/><?php echo $this->__('<strong>Amazon Pay</strong> helps you shop quickly, safely and securely. You can pay on our website without re-entering your payment and address details. All Amazon transactions are protected by Amazon's A-to-z Guarantee.'); ?>';
|
20 |
-
<?php endif; ?>
|
21 |
-
|
22 |
-
APA.setup('<?php echo $this->getMerchantId(); ?>', {
|
23 |
-
live: <?php echo ($this->isLive() ? 'true' : 'false'); ?>,
|
24 |
-
popup: <?php echo ($this->isPopup() ? 'true' : 'false'); ?>,
|
25 |
-
virtual: <?php echo ($this->isVirtual() ? 'true' : 'false'); ?>,
|
26 |
-
<?php if ($this->getDisplayLanguage()): ?>
|
27 |
-
language: '<?php echo $this->getDisplayLanguage(); ?>',
|
28 |
-
|
29 |
-
<?php endif; ?>
|
30 |
-
layers: {
|
31 |
-
payButtons: '.payButtonWidget',
|
32 |
-
loginButtons: '.loginButtonWidget',
|
33 |
-
},
|
34 |
-
urls: <?php echo $this->getUrlParams(); ?>,
|
35 |
-
design: <?php echo $this->getDesignParams(); ?>
|
36 |
-
|
37 |
-
}).renderButtonWidget(amazonButtonTooltip);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout.phtml
CHANGED
@@ -1,23 +1,30 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
|
|
|
|
|
|
|
|
|
|
16 |
<div class="page-title">
|
17 |
<h1><?php echo $this->__('Amazon Pay'); ?></h1>
|
18 |
</div>
|
19 |
<?php echo $this->getChildHtml('capture_notice'); ?>
|
20 |
-
<ol class="
|
21 |
<?php if ($this->showSandboxToolbox()): ?>
|
22 |
<li class="section store-widget">
|
23 |
<div class="step-title">
|
@@ -26,7 +33,7 @@
|
|
26 |
<div class="section-content"><?php echo $this->getChildHtml('sandbox_toolbox'); ?></div>
|
27 |
</li>
|
28 |
<?php endif; ?>
|
29 |
-
<?php if (!$this->
|
30 |
<li id="apa-shipping" class="section amazon-widget">
|
31 |
<div id="addressBookWidgetDiv"></div>
|
32 |
</li>
|
@@ -34,7 +41,7 @@
|
|
34 |
<li id="apa-payment" class="section amazon-widget">
|
35 |
<div id="walletWidgetDiv"></div>
|
36 |
</li>
|
37 |
-
<?php if (!$this->
|
38 |
<form id="co-shipping-method-form" action="">
|
39 |
<li id="apa-shipping_method" class="section narrow-section store-widget">
|
40 |
<div class="step-title">
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
+
<?php /** @var Creativestyle_AmazonPayments_Block_Checkout $this */ ?>
|
19 |
+
<script type="text/javascript">
|
20 |
+
if (!window.Review)
|
21 |
+
var Review = function() {};
|
22 |
+
</script>
|
23 |
<div class="page-title">
|
24 |
<h1><?php echo $this->__('Amazon Pay'); ?></h1>
|
25 |
</div>
|
26 |
<?php echo $this->getChildHtml('capture_notice'); ?>
|
27 |
+
<ol class="<?php echo $this->getContainerClass(); ?>" id="checkoutSteps">
|
28 |
<?php if ($this->showSandboxToolbox()): ?>
|
29 |
<li class="section store-widget">
|
30 |
<div class="step-title">
|
33 |
<div class="section-content"><?php echo $this->getChildHtml('sandbox_toolbox'); ?></div>
|
34 |
</li>
|
35 |
<?php endif; ?>
|
36 |
+
<?php if (!$this->isQuoteVirtual()): ?>
|
37 |
<li id="apa-shipping" class="section amazon-widget">
|
38 |
<div id="addressBookWidgetDiv"></div>
|
39 |
</li>
|
41 |
<li id="apa-payment" class="section amazon-widget">
|
42 |
<div id="walletWidgetDiv"></div>
|
43 |
</li>
|
44 |
+
<?php if (!$this->isQuoteVirtual()): ?>
|
45 |
<form id="co-shipping-method-form" action="">
|
46 |
<li id="apa-shipping_method" class="section narrow-section store-widget">
|
47 |
<div class="step-title">
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/capture_notice.phtml
CHANGED
@@ -1,26 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
-
|
17 |
-
<
|
18 |
-
<
|
19 |
-
<
|
20 |
-
<
|
21 |
-
|
22 |
-
|
23 |
-
</
|
24 |
-
</
|
25 |
-
</
|
26 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
+
<ul class="messages">
|
19 |
+
<li class="notice-msg">
|
20 |
+
<ul>
|
21 |
+
<li>
|
22 |
+
<span><?php echo $this->__(
|
23 |
+
'Please note that the total amount of the order will be charged at order placement.'
|
24 |
+
); ?></span>
|
25 |
+
</li>
|
26 |
+
</ul>
|
27 |
+
</li>
|
28 |
+
</ul>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/js.phtml
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This file is part of the official Amazon Payments Advanced extension
|
4 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
5 |
-
* All rights reserved
|
6 |
-
*
|
7 |
-
* Reuse or modification of this source code is not allowed
|
8 |
-
* without written permission from creativestyle GmbH
|
9 |
-
*
|
10 |
-
* @category Creativestyle
|
11 |
-
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
13 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
14 |
-
*/
|
15 |
-
?>
|
16 |
-
<?php $orderReferenceId = $this->getOrderReferenceId(); ?>
|
17 |
-
|
18 |
-
var quoteBaseGrandTotal = <?php echo (float)$this->getQuoteBaseGrandTotal(); ?>;
|
19 |
-
var checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
|
20 |
-
var lastPrice;
|
21 |
-
if (typeof Translator != 'undefined') {
|
22 |
-
Translator.add('There was an error processing your order. Please contact us or try again later.', '<?php echo $this->jsQuoteEscape($this->__('There was an error processing your order. Please contact us or try again later.')); ?>');
|
23 |
-
}
|
24 |
-
|
25 |
-
APA.setup('<?php echo $this->getMerchantId(); ?>', {
|
26 |
-
orderReferenceId: <?php echo $orderReferenceId ? '\'' . $orderReferenceId . '\'' : 'null'; ?>,
|
27 |
-
live: <?php echo ($this->isLive() ? 'true' : 'false'); ?>,
|
28 |
-
popup: <?php echo ($this->isPopup() ? 'true' : 'false'); ?>,
|
29 |
-
virtual: <?php echo ($this->isVirtual() ? 'true' : 'false'); ?>,
|
30 |
-
urls: {
|
31 |
-
saveShipping: '<?php echo $this->getUrl('amazonpayments/advanced_checkout/saveShipping'); ?>',
|
32 |
-
saveShippingMethod: '<?php echo $this->getUrl('amazonpayments/advanced_checkout/saveShippingMethod'); ?>',
|
33 |
-
saveOrder: '<?php echo $this->getUrl('amazonpayments/advanced_checkout/saveOrder'); ?>',
|
34 |
-
coupon: '<?php echo $this->getUrl('amazonpayments/advanced_checkout/couponPost'); ?>',
|
35 |
-
clear: '<?php echo $this->getUrl('amazonpayments/advanced_checkout/clearOrderReference'); ?>',
|
36 |
-
void: '<?php echo $this->getUrl('amazonpayments/advanced_checkout/voidOrderReference'); ?>',
|
37 |
-
success: '<?php echo $this->getUrl('checkout/onepage/success'); ?>',
|
38 |
-
failure: '<?php echo $this->getUrl('checkout/cart') ?>'
|
39 |
-
},
|
40 |
-
layers: {
|
41 |
-
addressBook: 'addressBookWidgetDiv',
|
42 |
-
wallet: 'walletWidgetDiv',
|
43 |
-
shippingMethod: 'shippingMethodWidgetDiv',
|
44 |
-
review: 'reviewWidgetDiv'
|
45 |
-
},
|
46 |
-
design: {
|
47 |
-
responsive: <?php echo ($this->isResponsive() ? 'true' : 'false'); ?>,
|
48 |
-
<?php if (!$this->isResponsive()): ?>
|
49 |
-
addressBook: {
|
50 |
-
size: {width: '<?php echo $this->getAddressBookWidgetSize()->getWidth(); ?>', height: '<?php echo $this->getAddressBookWidgetSize()->getHeight(); ?>'}
|
51 |
-
},
|
52 |
-
wallet: {
|
53 |
-
size: {width: '<?php echo $this->getWalletWidgetSize()->getWidth(); ?>', height: '<?php echo $this->getWalletWidgetSize()->getHeight(); ?>'}
|
54 |
-
}
|
55 |
-
<?php endif; ?>
|
56 |
-
|
57 |
-
}
|
58 |
-
}).initCheckout();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/review/button.phtml
CHANGED
@@ -1,16 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
-
<button id="amazonpayments-checkout-place-order-button"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
+
<button id="amazonpayments-checkout-place-order-button"
|
19 |
+
type="submit"
|
20 |
+
title="<?php echo $this->helper('checkout')->__('Place Order') ?>"
|
21 |
+
class="button btn-checkout"
|
22 |
+
disabled="disabled"
|
23 |
+
onclick="AmazonPayments.saveOrder();">
|
24 |
+
<span><span><?php echo $this->helper('checkout')->__('Place Order') ?></span></span>
|
25 |
+
</button>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/review/coupon.phtml
CHANGED
@@ -13,17 +13,35 @@
|
|
13 |
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
14 |
*/
|
15 |
?>
|
|
|
|
|
|
|
16 |
<form id="discount-coupon-form" method="post" onsubmit="return false;">
|
17 |
<div class="discount">
|
18 |
<div class="discount-form">
|
19 |
-
<label for="coupon_code"><?php echo $
|
20 |
-
<input type="hidden" name="remove" id="remove-coupone" value="0" />
|
21 |
<div class="field-wrapper">
|
22 |
-
<input
|
|
|
|
|
|
|
|
|
23 |
<div class="button-wrapper">
|
24 |
-
<button type="button"
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
</button>
|
28 |
<?php endif;?>
|
29 |
</div>
|
@@ -32,19 +50,17 @@
|
|
32 |
</div>
|
33 |
</form>
|
34 |
<script type="text/javascript">
|
35 |
-
//<![CDATA[
|
36 |
document.getElementById('coupon_code').addEventListener('keyup', function(event) {
|
37 |
event.preventDefault();
|
38 |
-
if (event.keyCode
|
39 |
document.getElementById('coupon_code_apply_button').click();
|
40 |
}
|
41 |
});
|
42 |
document.getElementById('coupon_code').addEventListener('change', function(event) {
|
43 |
event.preventDefault();
|
44 |
var couponCode = document.getElementById('coupon_code').value;
|
45 |
-
if (couponCode && couponCode
|
46 |
document.getElementById('coupon_code_apply_button').click();
|
47 |
}
|
48 |
});
|
49 |
-
//]]>
|
50 |
</script>
|
13 |
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
14 |
*/
|
15 |
?>
|
16 |
+
<?php /** @var Mage_Checkout_Block_Cart_Coupon $this */ ?>
|
17 |
+
<?php $coreHelper = $this->helper('core'); ?>
|
18 |
+
<?php $checkoutHelper = $this->helper('checkout'); ?>
|
19 |
<form id="discount-coupon-form" method="post" onsubmit="return false;">
|
20 |
<div class="discount">
|
21 |
<div class="discount-form">
|
22 |
+
<label for="coupon_code"><?php echo $checkoutHelper->__('Discount Codes') ?></label>
|
|
|
23 |
<div class="field-wrapper">
|
24 |
+
<input type="text"
|
25 |
+
id="coupon_code"
|
26 |
+
name="coupon_code"
|
27 |
+
class="input-text required-entry"
|
28 |
+
value="<?php echo $this->escapeHtml($this->getCouponCode()) ?>" />
|
29 |
<div class="button-wrapper">
|
30 |
+
<button type="button"
|
31 |
+
id="coupon_code_apply_button"
|
32 |
+
class="button2"
|
33 |
+
title="<?php echo $coreHelper->quoteEscape($checkoutHelper->__('Apply')) ?>"
|
34 |
+
value="<?php echo $checkoutHelper->__('Apply') ?>"
|
35 |
+
onclick="AmazonPayments.submitCoupon(false)">
|
36 |
+
<span><span><?php echo $checkoutHelper->__('Apply') ?></span></span>
|
37 |
+
</button>
|
38 |
+
<?php if (strlen($this->getCouponCode())) : ?>
|
39 |
+
<button type="button"
|
40 |
+
class="button2 cancel-coupon"
|
41 |
+
title="<?php echo $coreHelper->quoteEscape($checkoutHelper->__('Cancel')) ?>"
|
42 |
+
value="<?php echo $checkoutHelper->__('Cancel') ?>"
|
43 |
+
onclick="AmazonPayments.submitCoupon(true)">
|
44 |
+
<span><span><?php echo $checkoutHelper->__('Cancel') ?></span></span>
|
45 |
</button>
|
46 |
<?php endif;?>
|
47 |
</div>
|
50 |
</div>
|
51 |
</form>
|
52 |
<script type="text/javascript">
|
|
|
53 |
document.getElementById('coupon_code').addEventListener('keyup', function(event) {
|
54 |
event.preventDefault();
|
55 |
+
if (event.keyCode === 13) {
|
56 |
document.getElementById('coupon_code_apply_button').click();
|
57 |
}
|
58 |
});
|
59 |
document.getElementById('coupon_code').addEventListener('change', function(event) {
|
60 |
event.preventDefault();
|
61 |
var couponCode = document.getElementById('coupon_code').value;
|
62 |
+
if (couponCode && couponCode !== '<?php echo $this->getCouponCode(); ?>' && couponCode.length > 1) {
|
63 |
document.getElementById('coupon_code_apply_button').click();
|
64 |
}
|
65 |
});
|
|
|
66 |
</script>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/sandbox_toolbox.phtml
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
<form id="sandbox-simulation">
|
@@ -21,11 +23,22 @@
|
|
21 |
<select id="simulation_reason" name="simulation[reason]" style="display:none;"></select>
|
22 |
</fieldset>
|
23 |
</form>
|
24 |
-
<script type="text/javascript"
|
|
|
25 |
<script type="text/javascript">
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
</script>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<form id="sandbox-simulation">
|
23 |
<select id="simulation_reason" name="simulation[reason]" style="display:none;"></select>
|
24 |
</fieldset>
|
25 |
</form>
|
26 |
+
<script type="text/javascript"
|
27 |
+
src="<?php echo $this->getJsUrl('creativestyle/amazonpayments.toolbox.min.js'); ?>"></script>
|
28 |
<script type="text/javascript">
|
29 |
+
document.observe('dom:loaded', function() {
|
30 |
+
AmazonPaymentsToolbox.setup(
|
31 |
+
<?php echo $this->getSimulationOptions(); ?>,
|
32 |
+
{
|
33 |
+
object: $('simulation_object'),
|
34 |
+
state: $('simulation_state'),
|
35 |
+
reason: $('simulation_reason')
|
36 |
+
},
|
37 |
+
{
|
38 |
+
object: '<?php echo $this->jsQuoteEscape($this->__('--- Select object ---')); ?>',
|
39 |
+
state: '<?php echo $this->jsQuoteEscape($this->__('--- Select state to simulate ---')); ?>',
|
40 |
+
reason: '<?php echo $this->jsQuoteEscape($this->__('--- Select reason code ---')); ?>'
|
41 |
+
}
|
42 |
+
);
|
43 |
+
});
|
44 |
</script>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/checkout/shipping_method.phtml
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
<div id="shippingMethodWidgetDiv">
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<div id="shippingMethodWidgetDiv">
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/customer/account/dashboard/login.phtml
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
<div class="dashboard">
|
@@ -18,11 +20,14 @@
|
|
18 |
<div class="box-head">
|
19 |
<h2><?php echo $this->helper('amazonpayments')->__('Login with Amazon'); ?></h2>
|
20 |
<?php if ($this->isCustomerConnectedWithAmazon()): ?>
|
21 |
-
<a href="<?php echo $this->getUrl('amazonpayments/advanced_login/disconnect'); ?>"
|
|
|
|
|
22 |
<?php endif; ?>
|
23 |
</div>
|
24 |
<div class="box">
|
25 |
<div class="box-content">
|
|
|
26 |
<?php if ($this->isCustomerConnectedWithAmazon()): ?>
|
27 |
<p><?php echo $this->helper('amazonpayments')->__('Currently, you can use your Amazon account to log into your shop account. In order to remove the connection to your Amazon account click on "Disconnect".'); ?></p>
|
28 |
<?php else: ?>
|
@@ -31,6 +36,7 @@
|
|
31 |
<?php echo $this->helper('amazonpayments')->__('By selecting Login with Amazon, you will be asked to sign-in securely to your Amazon account without leaving the shop.'); ?>
|
32 |
</p>
|
33 |
<?php endif; ?>
|
|
|
34 |
</div>
|
35 |
<?php if (!$this->isCustomerConnectedWithAmazon()): ?>
|
36 |
<div class="buttons">
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<div class="dashboard">
|
20 |
<div class="box-head">
|
21 |
<h2><?php echo $this->helper('amazonpayments')->__('Login with Amazon'); ?></h2>
|
22 |
<?php if ($this->isCustomerConnectedWithAmazon()): ?>
|
23 |
+
<a href="<?php echo $this->getUrl('amazonpayments/advanced_login/disconnect'); ?>">
|
24 |
+
<?php echo $this->helper('amazonpayments')->__('Disconnect'); ?>
|
25 |
+
</a>
|
26 |
<?php endif; ?>
|
27 |
</div>
|
28 |
<div class="box">
|
29 |
<div class="box-content">
|
30 |
+
<?php // @codingStandardsIgnoreStart ?>
|
31 |
<?php if ($this->isCustomerConnectedWithAmazon()): ?>
|
32 |
<p><?php echo $this->helper('amazonpayments')->__('Currently, you can use your Amazon account to log into your shop account. In order to remove the connection to your Amazon account click on "Disconnect".'); ?></p>
|
33 |
<?php else: ?>
|
36 |
<?php echo $this->helper('amazonpayments')->__('By selecting Login with Amazon, you will be asked to sign-in securely to your Amazon account without leaving the shop.'); ?>
|
37 |
</p>
|
38 |
<?php endif; ?>
|
39 |
+
<?php // @codingStandardsIgnoreEnd ?>
|
40 |
</div>
|
41 |
<?php if (!$this->isCustomerConnectedWithAmazon()): ?>
|
42 |
<div class="buttons">
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/js.phtml
CHANGED
@@ -1,21 +1,51 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
-
<?php
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
<?php endif; ?>
|
21 |
-
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
+
<?php /** @var Creativestyle_AmazonPayments_Block_Js $this */ ?>
|
19 |
+
<script type="text/javascript" src="<?php echo $this->getJsUrl('creativestyle/amazonpayments.min.js'); ?>"></script>
|
20 |
+
<script type="text/javascript">
|
21 |
+
AmazonPayments.setup(<?php echo $this->getJsConfig(); ?>);
|
22 |
+
|
23 |
+
window.onAmazonPaymentsReady = function() {
|
24 |
+
AmazonPayments
|
25 |
+
.renderButtons()
|
26 |
+
<?php if ($this->getIsCheckout()) : ?>
|
27 |
+
<?php $orderReferenceId = $this->getOrderReferenceId(); ?>
|
28 |
+
<?php if ($orderReferenceId) : ?>
|
29 |
+
.setOrderReferenceId('<?php echo $orderReferenceId; ?>')
|
30 |
+
<?php endif; ?>
|
31 |
+
.initCheckout({
|
32 |
+
responsive: true,
|
33 |
+
urls: <?php echo $this->getCheckoutUrls(); ?>
|
34 |
+
|
35 |
+
})
|
36 |
+
<?php endif; ?>
|
37 |
+
;
|
38 |
+
};
|
39 |
+
|
40 |
+
<?php if ($this->isLoginActive()) : ?>
|
41 |
+
window.onAmazonLoginReady = function() {
|
42 |
+
AmazonPayments
|
43 |
+
.initLogin()
|
44 |
+
<?php if ($this->getIsLogout()) : ?>
|
45 |
+
.logout()
|
46 |
+
<?php endif; ?>
|
47 |
+
;
|
48 |
+
};
|
49 |
<?php endif; ?>
|
50 |
+
</script>
|
51 |
+
<script async type="text/javascript" src="<?php echo $this->getWidgetJsUrl(); ?>"></script>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/login/button.phtml
CHANGED
@@ -1,22 +1,24 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
-
<div id="<?php echo $this->
|
17 |
<?php if ($this->isCustomDesignSet()): ?>
|
18 |
-
<script type="text/javascript"
|
19 |
-
var buttonDiv = $('<?php echo $this->
|
20 |
<?php if ($buttonType = $this->getButtonType()): ?>
|
21 |
buttonDiv.buttonType = '<?php echo $buttonType; ?>';
|
22 |
<?php endif; ?>
|
@@ -26,5 +28,5 @@
|
|
26 |
<?php if ($buttonColor = $this->getButtonColor()): ?>
|
27 |
buttonDiv.buttonColor = '<?php echo $buttonColor; ?>';
|
28 |
<?php endif; ?>
|
29 |
-
|
30 |
<?php endif; ?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
+
<div id="<?php echo $this->getContainerId(); ?>" class="<?php echo $this->getContainerClass(); ?>"></div>
|
19 |
<?php if ($this->isCustomDesignSet()): ?>
|
20 |
+
<script type="text/javascript">
|
21 |
+
var buttonDiv = $('<?php echo $this->getContainerId(); ?>');
|
22 |
<?php if ($buttonType = $this->getButtonType()): ?>
|
23 |
buttonDiv.buttonType = '<?php echo $buttonType; ?>';
|
24 |
<?php endif; ?>
|
28 |
<?php if ($buttonColor = $this->getButtonColor()): ?>
|
29 |
buttonDiv.buttonColor = '<?php echo $buttonColor; ?>';
|
30 |
<?php endif; ?>
|
31 |
+
</script>
|
32 |
<?php endif; ?>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/login/button/account_login.phtml
CHANGED
@@ -1,52 +1,58 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
|
|
16 |
<div class="account-login amazon-login">
|
17 |
<div class="new-users">
|
18 |
<div class="content">
|
19 |
<h2><?php echo $this->helper('amazonpayments')->__('Use your Amazon Account') ?></h2>
|
|
|
20 |
<p>
|
21 |
<?php echo $this->helper('amazonpayments')->__('With Amazon Pay, you can use the shipping and payment information stored in your Amazon account to place an order on this website. It\'s a convenient and trusted way to pay that\'s enjoyed by millions of people.'); ?>
|
22 |
<?php echo $this->helper('amazonpayments')->__('By selecting Login with Amazon, you will be asked to sign-in securely to your Amazon account without leaving the shop.'); ?>
|
23 |
</p>
|
|
|
24 |
</div>
|
25 |
</div>
|
26 |
<div class="buttons-set">
|
27 |
-
<div id="<?php echo $this->
|
28 |
-
<?php if ($this->isCustomDesignSet()): ?>
|
29 |
-
<script type="text/javascript">//<![CDATA[
|
30 |
-
var buttonDiv = $('<?php echo $this->getWidgetHtmlId(); ?>');
|
31 |
-
<?php if ($buttonType = $this->getButtonType()): ?>
|
32 |
-
buttonDiv.buttonType = '<?php echo $buttonType; ?>';
|
33 |
-
<?php endif; ?>
|
34 |
-
<?php if ($buttonSize = $this->getButtonSize()): ?>
|
35 |
-
buttonDiv.buttonSize = '<?php echo $buttonSize; ?>';
|
36 |
-
<?php endif; ?>
|
37 |
-
<?php if ($buttonColor = $this->getButtonColor()): ?>
|
38 |
-
buttonDiv.buttonColor = '<?php echo $buttonColor; ?>';
|
39 |
-
<?php endif; ?>
|
40 |
-
//]]></script>
|
41 |
-
<?php endif; ?>
|
42 |
</div>
|
43 |
</div>
|
44 |
-
<?php if ($this->getMoveBefore()): ?>
|
45 |
-
<script type="text/javascript"
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
<?php endif; ?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
+
<?php /** @var Creativestyle_AmazonPayments_Block_Login_Button $this */ ?>
|
19 |
<div class="account-login amazon-login">
|
20 |
<div class="new-users">
|
21 |
<div class="content">
|
22 |
<h2><?php echo $this->helper('amazonpayments')->__('Use your Amazon Account') ?></h2>
|
23 |
+
<?php // @codingStandardsIgnoreStart ?>
|
24 |
<p>
|
25 |
<?php echo $this->helper('amazonpayments')->__('With Amazon Pay, you can use the shipping and payment information stored in your Amazon account to place an order on this website. It\'s a convenient and trusted way to pay that\'s enjoyed by millions of people.'); ?>
|
26 |
<?php echo $this->helper('amazonpayments')->__('By selecting Login with Amazon, you will be asked to sign-in securely to your Amazon account without leaving the shop.'); ?>
|
27 |
</p>
|
28 |
+
<?php // @codingStandardsIgnoreEnd ?>
|
29 |
</div>
|
30 |
</div>
|
31 |
<div class="buttons-set">
|
32 |
+
<div id="<?php echo $this->getContainerId(); ?>" class="<?php echo $this->getContainerClass(); ?>"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
</div>
|
34 |
</div>
|
35 |
+
<?php if ($this->getMoveBefore() || $this->isCustomDesignSet()): ?>
|
36 |
+
<script type="text/javascript">
|
37 |
+
<?php if ($this->isCustomDesignSet()): ?>
|
38 |
+
var buttonDiv = $('<?php echo $this->getContainerId(); ?>');
|
39 |
+
<?php if ($buttonType = $this->getButtonType()): ?>
|
40 |
+
buttonDiv.buttonType = '<?php echo $buttonType; ?>';
|
41 |
+
<?php endif; ?>
|
42 |
+
<?php if ($buttonSize = $this->getButtonSize()): ?>
|
43 |
+
buttonDiv.buttonSize = '<?php echo $buttonSize; ?>';
|
44 |
+
<?php endif; ?>
|
45 |
+
<?php if ($buttonColor = $this->getButtonColor()): ?>
|
46 |
+
buttonDiv.buttonColor = '<?php echo $buttonColor; ?>';
|
47 |
+
<?php endif; ?>
|
48 |
+
<?php endif; ?>
|
49 |
+
<?php if ($this->getMoveBefore()): ?>
|
50 |
+
if ($('<?php echo $this->getMoveBefore(); ?>')) {
|
51 |
+
$$('div.amazon-login').each(function(element) {
|
52 |
+
$('<?php echo $this->getMoveBefore(); ?>')
|
53 |
+
.insert({before: element.addClassName('position-before')});
|
54 |
+
});
|
55 |
+
}
|
56 |
+
<?php endif; ?>
|
57 |
+
</script>
|
58 |
<?php endif; ?>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/login/form/account_confirm.phtml
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
<div class="account-login">
|
@@ -23,18 +25,30 @@
|
|
23 |
<input name="action" type="hidden" value="account_confirm">
|
24 |
<div class="account-login">
|
25 |
<div class="content">
|
|
|
26 |
<p><?php echo $this->__('Dear buyer, it looks like you already have an account in this shop. Please enter the password for your shop account here for once to make sure you are the authorized user of this account. We will not ask you for this anymore afterwards.') ?></p>
|
|
|
27 |
<ul class="form-list">
|
28 |
<li>
|
29 |
<label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
30 |
<div class="input-box">
|
31 |
-
<input type="text"
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
</div>
|
33 |
</li>
|
34 |
<li>
|
35 |
<label for="pass" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
|
36 |
<div class="input-box">
|
37 |
-
<input type="password"
|
|
|
|
|
|
|
|
|
38 |
</div>
|
39 |
</li>
|
40 |
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
@@ -42,16 +56,22 @@
|
|
42 |
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
43 |
</div>
|
44 |
<div class="buttons-set">
|
45 |
-
<a href="<?php echo $this->getForgotPasswordUrl() ?>" class="f-left"
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
</div>
|
49 |
</div>
|
50 |
</form>
|
51 |
-
<script type="text/javascript"
|
52 |
function cancelMatching() {
|
53 |
-
|
54 |
setLocation('<?php echo $this->escapeUrl($this->getBackUrl()); ?>');
|
55 |
}
|
56 |
-
|
57 |
-
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<div class="account-login">
|
25 |
<input name="action" type="hidden" value="account_confirm">
|
26 |
<div class="account-login">
|
27 |
<div class="content">
|
28 |
+
<?php // @codingStandardsIgnoreStart ?>
|
29 |
<p><?php echo $this->__('Dear buyer, it looks like you already have an account in this shop. Please enter the password for your shop account here for once to make sure you are the authorized user of this account. We will not ask you for this anymore afterwards.') ?></p>
|
30 |
+
<?php // @codingStandardsIgnoreEnd ?>
|
31 |
<ul class="form-list">
|
32 |
<li>
|
33 |
<label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
34 |
<div class="input-box">
|
35 |
+
<input type="text"
|
36 |
+
name="login[username]"
|
37 |
+
disabled="disabled"
|
38 |
+
value="<?php echo $this->escapeHtml($this->getUsername()) ?>"
|
39 |
+
id="email"
|
40 |
+
class="input-text required-entry validate-email"
|
41 |
+
title="<?php echo $this->__('Email Address') ?>" />
|
42 |
</div>
|
43 |
</li>
|
44 |
<li>
|
45 |
<label for="pass" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
|
46 |
<div class="input-box">
|
47 |
+
<input type="password"
|
48 |
+
name="login[password]"
|
49 |
+
class="input-text required-entry validate-password"
|
50 |
+
id="pass"
|
51 |
+
title="<?php echo $this->__('Password') ?>" />
|
52 |
</div>
|
53 |
</li>
|
54 |
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
56 |
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
57 |
</div>
|
58 |
<div class="buttons-set">
|
59 |
+
<a href="<?php echo $this->getForgotPasswordUrl() ?>" class="f-left">
|
60 |
+
<?php echo $this->__('Forgot Your Password?') ?>
|
61 |
+
</a>
|
62 |
+
<button type="submit" class="button" title="<?php echo $this->__('Login') ?>" name="send" id="send2">
|
63 |
+
<span><span><?php echo $this->__('Login') ?></span></span>
|
64 |
+
</button>
|
65 |
+
<button type="button" class="button cancel" onclick="cancelMatching();">
|
66 |
+
<span><span><?php echo $this->__('Cancel') ?></span></span>
|
67 |
+
</button>
|
68 |
</div>
|
69 |
</div>
|
70 |
</form>
|
71 |
+
<script type="text/javascript">
|
72 |
function cancelMatching() {
|
73 |
+
AmazonPayments.logout();
|
74 |
setLocation('<?php echo $this->escapeUrl($this->getBackUrl()); ?>');
|
75 |
}
|
76 |
+
</script>
|
77 |
+
</div>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/login/form/account_update.phtml
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
<div class="account-create">
|
@@ -22,7 +24,9 @@
|
|
22 |
<?php echo $this->getChildHtml('customer.form.register.extra')?>
|
23 |
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
|
24 |
<div class="content">
|
|
|
25 |
<p><?php echo $this->__('Please fill in required data that cannot be retrieved from your Amazon account.') ?></p>
|
|
|
26 |
</div>
|
27 |
<div class="fieldset">
|
28 |
<h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
|
@@ -35,7 +39,15 @@
|
|
35 |
<?php if ($this->isNewsletterEnabled()): ?>
|
36 |
<li class="control">
|
37 |
<div class="input-box">
|
38 |
-
<input type="checkbox"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
</div>
|
40 |
<label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
|
41 |
<?php /* Extensions placeholder */ ?>
|
@@ -44,31 +56,44 @@
|
|
44 |
<?php endif ?>
|
45 |
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
46 |
<?php if ($_dob->isEnabled()): ?>
|
47 |
-
<li><?php echo $_dob->setFieldNameFormat($this->getFieldNameFormat())
|
|
|
48 |
<?php endif ?>
|
49 |
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
50 |
<?php if ($_taxvat->isEnabled()): ?>
|
51 |
-
<li><?php echo $_taxvat->setFieldNameFormat($this->getFieldNameFormat())
|
|
|
52 |
<?php endif ?>
|
53 |
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
|
54 |
<?php if ($_gender->isEnabled()): ?>
|
55 |
-
<li><?php echo $_gender->setFieldNameFormat($this->getFieldNameFormat())
|
|
|
56 |
<?php endif ?>
|
57 |
</ul>
|
58 |
</div>
|
59 |
<div class="buttons-set">
|
60 |
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
61 |
-
<p class="back-link"
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
</div>
|
65 |
</form>
|
66 |
-
<script type="text/javascript"
|
67 |
function cancelMatching() {
|
68 |
-
|
69 |
setLocation('<?php echo $this->escapeUrl($this->getBackUrl()); ?>');
|
70 |
}
|
71 |
|
72 |
var dataForm = new VarienForm('form-validate', true);
|
73 |
-
|
74 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<div class="account-create">
|
24 |
<?php echo $this->getChildHtml('customer.form.register.extra')?>
|
25 |
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
|
26 |
<div class="content">
|
27 |
+
<?php // @codingStandardsIgnoreStart ?>
|
28 |
<p><?php echo $this->__('Please fill in required data that cannot be retrieved from your Amazon account.') ?></p>
|
29 |
+
<?php // @codingStandardsIgnoreEnd ?>
|
30 |
</div>
|
31 |
<div class="fieldset">
|
32 |
<h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
|
39 |
<?php if ($this->isNewsletterEnabled()): ?>
|
40 |
<li class="control">
|
41 |
<div class="input-box">
|
42 |
+
<input type="checkbox"
|
43 |
+
name="account[is_subscribed]"
|
44 |
+
title="<?php echo $this->__('Sign Up for Newsletter') ?>"
|
45 |
+
value="1"
|
46 |
+
id="is_subscribed"
|
47 |
+
<?php if($this->getFormData()->getIsSubscribed()): ?>
|
48 |
+
checked="checked"
|
49 |
+
<?php endif; ?>
|
50 |
+
class="checkbox" />
|
51 |
</div>
|
52 |
<label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
|
53 |
<?php /* Extensions placeholder */ ?>
|
56 |
<?php endif ?>
|
57 |
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
58 |
<?php if ($_dob->isEnabled()): ?>
|
59 |
+
<li><?php echo $_dob->setFieldNameFormat($this->getFieldNameFormat())
|
60 |
+
->setDate($this->getFormData()->getDob())->toHtml() ?></li>
|
61 |
<?php endif ?>
|
62 |
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
63 |
<?php if ($_taxvat->isEnabled()): ?>
|
64 |
+
<li><?php echo $_taxvat->setFieldNameFormat($this->getFieldNameFormat())
|
65 |
+
->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
|
66 |
<?php endif ?>
|
67 |
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
|
68 |
<?php if ($_gender->isEnabled()): ?>
|
69 |
+
<li><?php echo $_gender->setFieldNameFormat($this->getFieldNameFormat())
|
70 |
+
->setGender($this->getFormData()->getGender())->toHtml() ?></li>
|
71 |
<?php endif ?>
|
72 |
</ul>
|
73 |
</div>
|
74 |
<div class="buttons-set">
|
75 |
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
76 |
+
<p class="back-link">
|
77 |
+
<a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"
|
78 |
+
onclick="cancelMatching();"
|
79 |
+
class="back-link">
|
80 |
+
<small>« </small><?php echo $this->__('Back') ?>
|
81 |
+
</a>
|
82 |
+
</p>
|
83 |
+
<button type="submit" title="<?php echo $this->__('Submit') ?>" class="button">
|
84 |
+
<span><span><?php echo $this->__('Submit') ?></span></span>
|
85 |
+
</button>
|
86 |
+
<button type="button" class="button cancel" onclick="cancelMatching();">
|
87 |
+
<span><span><?php echo $this->__('Cancel') ?></span></span>
|
88 |
+
</button>
|
89 |
</div>
|
90 |
</form>
|
91 |
+
<script type="text/javascript">
|
92 |
function cancelMatching() {
|
93 |
+
AmazonPayments.logout();
|
94 |
setLocation('<?php echo $this->escapeUrl($this->getBackUrl()); ?>');
|
95 |
}
|
96 |
|
97 |
var dataForm = new VarienForm('form-validate', true);
|
98 |
+
</script>
|
99 |
</div>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/login/js.phtml
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This file is part of the official Amazon Payments Advanced extension
|
4 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
5 |
-
* All rights reserved
|
6 |
-
*
|
7 |
-
* Reuse or modification of this source code is not allowed
|
8 |
-
* without written permission from creativestyle GmbH
|
9 |
-
*
|
10 |
-
* @category Creativestyle
|
11 |
-
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
13 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
14 |
-
*/
|
15 |
-
?>
|
16 |
-
amazon.Login.setClientId('<?php echo $this->getClientId(); ?>');
|
17 |
-
amazon.Login.setUseCookie(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/login/logout.phtml
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This file is part of the official Amazon Payments Advanced extension
|
4 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
5 |
-
* All rights reserved
|
6 |
-
*
|
7 |
-
* Reuse or modification of this source code is not allowed
|
8 |
-
* without written permission from creativestyle GmbH
|
9 |
-
*
|
10 |
-
* @category Creativestyle
|
11 |
-
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
13 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
14 |
-
*/
|
15 |
-
?>
|
16 |
-
amazon.Login.logout();
|
17 |
-
Mage.Cookies.clear('amazon_Login_accessToken');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/login/redirect.phtml
CHANGED
@@ -1,21 +1,24 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
<h1><?php echo $this->__('Redirecting, please wait...'); ?></h1>
|
17 |
<script type="text/javascript">//<![CDATA[
|
18 |
-
var accessToken = (new RegExp('[?|&|#]<?php echo $this->getAccessTokenParamName(); ?>=([^&;]+?)(&|#|;|$)')
|
|
|
19 |
if (typeof accessToken === 'string' && accessToken.match(/^Atza/)) {
|
20 |
Mage.Cookies.set('amazon_Login_accessToken', decodeURIComponent(accessToken), null, '/', null, true);
|
21 |
setLocation('<?php echo $this->getRedirectUrl(); ?>'.replace(/%s/, accessToken));
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2015 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2015 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<h1><?php echo $this->__('Redirecting, please wait...'); ?></h1>
|
19 |
<script type="text/javascript">//<![CDATA[
|
20 |
+
var accessToken = (new RegExp('[?|&|#]<?php echo $this->getAccessTokenParamName(); ?>=([^&;]+?)(&|#|;|$)')
|
21 |
+
.exec(location.hash) || [,""])[1].replace(/\+/g,'%20') || null;
|
22 |
if (typeof accessToken === 'string' && accessToken.match(/^Atza/)) {
|
23 |
Mage.Cookies.set('amazon_Login_accessToken', decodeURIComponent(accessToken), null, '/', null, true);
|
24 |
setLocation('<?php echo $this->getRedirectUrl(); ?>'.replace(/%s/, accessToken));
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/onepage/button.phtml
CHANGED
@@ -1,42 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
|
|
16 |
<div class="pay-with-amazon-onepage-shortcut">
|
17 |
<h3><?php echo $this->__('Amazon Pay'); ?></h3>
|
18 |
-
<?php
|
|
|
19 |
<p><?php echo $this->__('<strong>Amazon Pay</strong> helps you shop quickly, safely and securely. You can pay on our website without re-entering your payment and address details.'); ?></p>
|
20 |
<?php else: ?>
|
21 |
<p><?php echo $this->__('<strong>Amazon Pay</strong> helps you shop quickly, safely and securely. You can pay on our website without re-entering your payment and address details. All Amazon transactions are protected by Amazon's A-to-z Guarantee.'); ?></p>
|
22 |
<?php endif; ?>
|
23 |
-
|
24 |
-
|
25 |
-
<img src="<?php echo $buttonImgUrl; ?>"/>
|
26 |
-
<?php endif; ?>
|
27 |
-
</div>
|
28 |
-
<?php if ($this->isCustomDesignSet()): ?>
|
29 |
-
<script type="text/javascript">//<![CDATA[
|
30 |
-
var buttonDiv = $('<?php echo $this->getWidgetHtmlId(); ?>');
|
31 |
-
<?php if ($buttonType = $this->getButtonType()): ?>
|
32 |
-
buttonDiv.buttonType = '<?php echo $buttonType; ?>';
|
33 |
-
<?php endif; ?>
|
34 |
-
<?php if ($buttonSize = $this->getButtonSize()): ?>
|
35 |
-
buttonDiv.buttonSize = '<?php echo $buttonSize; ?>';
|
36 |
-
<?php endif; ?>
|
37 |
-
<?php if ($buttonColor = $this->getButtonColor()): ?>
|
38 |
-
buttonDiv.buttonColor = '<?php echo $buttonColor; ?>';
|
39 |
-
<?php endif; ?>
|
40 |
-
//]]></script>
|
41 |
-
<?php endif; ?>
|
42 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
+
<?php /** @var Creativestyle_AmazonPayments_Block_Onepage_Button $this */ ?>
|
19 |
<div class="pay-with-amazon-onepage-shortcut">
|
20 |
<h3><?php echo $this->__('Amazon Pay'); ?></h3>
|
21 |
+
<?php // @codingStandardsIgnoreStart ?>
|
22 |
+
<?php if ($this->isQuoteVirtual()): ?>
|
23 |
<p><?php echo $this->__('<strong>Amazon Pay</strong> helps you shop quickly, safely and securely. You can pay on our website without re-entering your payment and address details.'); ?></p>
|
24 |
<?php else: ?>
|
25 |
<p><?php echo $this->__('<strong>Amazon Pay</strong> helps you shop quickly, safely and securely. You can pay on our website without re-entering your payment and address details. All Amazon transactions are protected by Amazon's A-to-z Guarantee.'); ?></p>
|
26 |
<?php endif; ?>
|
27 |
+
<?php // @codingStandardsIgnoreEnd ?>
|
28 |
+
<?php echo $this->getChildHtml('amazonpayments_button_pay'); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
</div>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/pay/button.phtml
CHANGED
@@ -1,37 +1,46 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
<?php endif; ?>
|
20 |
-
|
21 |
-
<?php
|
22 |
-
|
23 |
-
<?php
|
24 |
-
<?php if ($this->isCustomDesignSet()): ?>
|
25 |
-
<script type="text/javascript">//<![CDATA[
|
26 |
-
var buttonDiv = $('<?php echo $this->getWidgetHtmlId(); ?>');
|
27 |
-
<?php if ($buttonType = $this->getButtonType()): ?>
|
28 |
-
buttonDiv.buttonType = '<?php echo $buttonType; ?>';
|
29 |
-
<?php endif; ?>
|
30 |
-
<?php if ($buttonSize = $this->getButtonSize()): ?>
|
31 |
-
buttonDiv.buttonSize = '<?php echo $buttonSize; ?>';
|
32 |
<?php endif; ?>
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
<?php endif; ?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
+
<?php /** @var Creativestyle_AmazonPayments_Block_Pay_Button $this */ ?>
|
19 |
+
<?php if ($this->isLoginActive()) : ?>
|
20 |
+
<div id="<?php echo $this->getContainerId(); ?>"
|
21 |
+
class="<?php echo $this->getContainerClass(); ?> with-tooltip">
|
22 |
+
</div>
|
23 |
+
<?php if ($this->isCustomDesignSet()) : ?>
|
24 |
+
<script type="text/javascript">
|
25 |
+
var buttonDiv = $('<?php echo $this->getContainerId(); ?>');
|
26 |
+
<?php if ($buttonType = $this->getButtonType()) : ?>
|
27 |
+
buttonDiv.buttonType = '<?php echo $buttonType; ?>';
|
28 |
+
<?php endif; ?>
|
29 |
+
<?php if ($buttonSize = $this->getButtonSize()) : ?>
|
30 |
+
buttonDiv.buttonSize = '<?php echo $buttonSize; ?>';
|
31 |
+
<?php endif; ?>
|
32 |
+
<?php if ($buttonColor = $this->getButtonColor()) : ?>
|
33 |
+
buttonDiv.buttonColor = '<?php echo $buttonColor; ?>';
|
34 |
+
<?php endif; ?>
|
35 |
+
</script>
|
36 |
<?php endif; ?>
|
37 |
+
<?php else : ?>
|
38 |
+
<div id="<?php echo $this->getContainerId(); ?>" class="<?php echo $this->getContainerClass(); ?> with-tooltip">
|
39 |
+
<?php if ($buttonImgUrl = $this->getButtonWidgetUrl()) : ?>
|
40 |
+
<img src="<?php echo $buttonImgUrl; ?>"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
<?php endif; ?>
|
42 |
+
</div>
|
43 |
+
<?php endif; ?>
|
44 |
+
<?php if ($this->getEnableOr()) : ?>
|
45 |
+
<span class="amazonpayments-or"><?php echo $this->__('-OR-'); ?></span>
|
46 |
<?php endif; ?>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/payment/info.phtml
CHANGED
@@ -1,19 +1,24 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
<?php echo $this->__($this->getMethod()->getTitle()); ?><br />
|
17 |
<?php if ($this->getInfo()->getAdditionalInformation('amazon_order_reference_id')): ?>
|
18 |
-
<?php echo $this->__('Amazon Order Reference ID: %s', $this->htmlEscape(
|
|
|
|
|
19 |
<?php endif; ?>
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<?php echo $this->__($this->getMethod()->getTitle()); ?><br />
|
19 |
<?php if ($this->getInfo()->getAdditionalInformation('amazon_order_reference_id')): ?>
|
20 |
+
<?php echo $this->__('Amazon Order Reference ID: %s', $this->htmlEscape(
|
21 |
+
$this->getInfo()->getAdditionalInformation('amazon_order_reference_id')
|
22 |
+
)); ?><br/>
|
23 |
<?php endif; ?>
|
24 |
+
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/payment/legacy/info.phtml
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* This file is part of the official Amazon
|
5 |
-
* for Magento
|
6 |
-
* All rights reserved
|
7 |
*
|
8 |
-
*
|
9 |
-
*
|
|
|
|
|
|
|
10 |
*
|
11 |
* @category Creativestyle
|
12 |
* @package Creativestyle_AmazonPayments
|
13 |
-
* @copyright
|
14 |
-
* @author Marek Zabrowarny
|
15 |
*/
|
16 |
?>
|
17 |
<?php echo $this->__($this->getMethod()->getTitle()); ?><br />
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2016 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2016 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<?php echo $this->__($this->getMethod()->getTitle()); ?><br />
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/payment/legacy/pdf/info.phtml
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
<?php echo $this->__($this->getMethod()->getTitle()); ?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2016 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2016 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<?php echo $this->__($this->getMethod()->getTitle()); ?>
|
app/design/frontend/base/default/template/creativestyle/amazonpayments/payment/pdf/info.phtml
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This file is part of the official Amazon
|
4 |
-
* for Magento
|
5 |
-
* All rights reserved
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
9 |
*
|
10 |
* @category Creativestyle
|
11 |
* @package Creativestyle_AmazonPayments
|
12 |
-
* @copyright
|
13 |
-
* @author Marek Zabrowarny
|
14 |
*/
|
15 |
?>
|
16 |
<?php echo $this->__($this->getMethod()->getTitle()); ?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This file is part of the official Amazon Pay and Login with Amazon extension
|
4 |
+
* for Magento 1.x
|
|
|
5 |
*
|
6 |
+
* (c) 2014 - 2017 creativestyle GmbH. All Rights reserved
|
7 |
+
*
|
8 |
+
* Distribution of the derivatives reusing, transforming or being built upon
|
9 |
+
* this software, is not allowed without explicit written permission granted
|
10 |
+
* by creativestyle GmbH
|
11 |
*
|
12 |
* @category Creativestyle
|
13 |
* @package Creativestyle_AmazonPayments
|
14 |
+
* @copyright 2014 - 2017 creativestyle GmbH
|
15 |
+
* @author Marek Zabrowarny <ticket@creativestyle.de>
|
16 |
*/
|
17 |
?>
|
18 |
<?php echo $this->__($this->getMethod()->getTitle()); ?>
|
js/creativestyle/adminhtml/amazonpayments.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var AmazonPaymentsAdmin=Class.create();AmazonPaymentsAdmin.prototype={setupConfig:function(i){i&&(this.unique_id=i.unique_id||null,this.fields=i.fields||{},this.merchant_id=$F(this.fields.merchant_id)||null,this.client_id=$F(this.fields.client_id)||null,this.layers=i.layers||{},this.messages=i.messages||{},this.urls=i.urls||{})},setupRegistration:function(i){i&&($(i.submit)&&Event.observe($(i.submit),"click",this.startSimplePathRegistration.bindAsEventListener(this,$(i.region),$(i.language))),this.registration=i)},setupValidation:function(i,e){i&&($(i.submit)&&Event.observe($(i.submit),"click",this.startSimplePathValidation.bindAsEventListener(this,$(i.json_field),$(e.region))),$(i.use_button)&&Event.observe($(i.use_button),"click",this.useNewOptions.bindAsEventListener(this)),$(i.save_button)&&Event.observe($(i.save_button),"click",this.useNewOptionsAndSave.bindAsEventListener(this)),$(i.cancel_button)&&Event.observe($(i.cancel_button),"click",this.cancelValidation.bindAsEventListener(this)),$(i.json_field)&&i.placeholder&&$(i.json_field).setAttribute("placeholder",i.placeholder),this.validation=i)},cancelValidation:function(
|
1 |
+
var AmazonPaymentsAdmin=Class.create();AmazonPaymentsAdmin.prototype={setupConfig:function(i){i&&(this.unique_id=i.unique_id||null,this.fields=i.fields||{},this.merchant_id=$F(this.fields.merchant_id)||null,this.client_id=$F(this.fields.client_id)||null,this.layers=i.layers||{},this.messages=i.messages||{},this.urls=i.urls||{})},setupRegistration:function(i){i&&($(i.submit)&&Event.observe($(i.submit),"click",this.startSimplePathRegistration.bindAsEventListener(this,$(i.region),$(i.language))),this.registration=i)},setupValidation:function(i,e){i&&($(i.submit)&&Event.observe($(i.submit),"click",this.startSimplePathValidation.bindAsEventListener(this,$(i.json_field),$(e.region))),$(i.use_button)&&Event.observe($(i.use_button),"click",this.useNewOptions.bindAsEventListener(this)),$(i.save_button)&&Event.observe($(i.save_button),"click",this.useNewOptionsAndSave.bindAsEventListener(this)),$(i.cancel_button)&&Event.observe($(i.cancel_button),"click",this.cancelValidation.bindAsEventListener(this)),$(i.json_field)&&i.placeholder&&$(i.json_field).setAttribute("placeholder",i.placeholder),this.validation=i)},cancelValidation:function(){this.showSimplePathValidationJson(!0),this.showSimplePathValidationSubmit(!0),this.enableSimplePathRegistrationRegion(!0)},useNewOptions:function(){this.populateNewOptions()},useNewOptionsAndSave:function(){this.populateNewOptions(),configForm.submit()},populateNewOptions:function(){if(region=$F(this.registration.region),options=$F(this.validation.json_field),options)try{options=options.evalJSON(!0),$F(this.fields.merchant_id)!==options.merchant_id&&($(this.fields.merchant_id).disabled&&$(this.fields.merchant_id.identify()+"_inherit").click(),this.fields.merchant_id.setValue(options.merchant_id)),$F(this.fields.client_id)!==options.client_id&&($(this.fields.client_id).disabled&&$(this.fields.client_id.identify()+"_inherit").click(),this.fields.client_id.setValue(options.client_id)),$F(this.fields.access_key)!==options.access_key&&($(this.fields.access_key).disabled&&$(this.fields.access_key.identify()+"_inherit").click(),this.fields.access_key.setValue(options.access_key)),$F(this.fields.secret_key)!==options.secret_key&&($(this.fields.secret_key).disabled&&$(this.fields.secret_key.identify()+"_inherit").click(),this.fields.secret_key.setValue(options.secret_key)),region&&$F(this.fields.region)!==region&&($(this.fields.region).disabled&&$(this.fields.region.identify()+"_inherit").click(),this.fields.region.setValue(region))}catch(i){console.error(i)}},setupView:function(){this.isConfigured()?(this.disableRegionSynchronization(),this.showSellerCentralConfiguration(!0),this.showSimplePathRegistration(!1)):(this.enableRegionSynchronization(),this.showSellerCentralConfiguration(!1),this.showSimplePathRegistration(!0))},showSellerCentralConfiguration:function(i){i?($(this.layers.seller_central+"-state").setValue(1),Fieldset.applyCollapse(this.layers.seller_central)):($(this.layers.seller_central+"-state").setValue(0),Fieldset.applyCollapse(this.layers.seller_central))},showSimplePathRegistration:function(i){i?($(this.registration.id+"-state").setValue(1),Fieldset.applyCollapse(this.registration.id)):($(this.registration.id+"-state").setValue(0),Fieldset.applyCollapse(this.registration.id))},showSimplePathValidationSubmit:function(i){i?$(this.validation.submit).show():$(this.validation.submit).hide()},showSimplePathValidationJson:function(i){i?($(this.validation.result).hide(),$(this.validation.result_buttons).hide(),$(this.validation.json_field.up("tr").show())):($(this.validation.result).show(),$(this.validation.result_buttons).show(),$(this.validation.json_field.up("tr").hide()))},enableSimplePathRegistrationRegion:function(i){i?($(this.registration.region).enable(),$(this.registration.region).removeClassName("disabled"),$(this.registration.submit).enable(),$(this.registration.submit).removeClassName("disabled")):($(this.registration.region).disable(),$(this.registration.region).addClassName("disabled"),$(this.registration.submit).disable(),$(this.registration.submit).addClassName("disabled"))},enableRegionSynchronization:function(){this.fields.region.setValue($F(this.registration.region)),Event.observe($(this.registration.region),"change",this.synchronizeRegions.bindAsEventListener(this))},disableRegionSynchronization:function(){Event.stopObserving($(this.registration.region),"change")},synchronizeRegions:function(i){this.fields.region.setValue($F(Event.findElement(i)))},startSimplePathRegistration:function(i,e,t){var s=new Element("form",{method:"post",action:this.simplePathRegistrationUrl[$F(e)],target:"_blank"});s.insert(new Element("input",{name:"source",value:"SPPW",type:"hidden"})),s.insert(new Element("input",{name:"spId",value:this.spIds[$F(e)],type:"hidden"})),s.insert(new Element("input",{name:"locale",value:$F(e),type:"hidden"})),s.insert(new Element("input",{name:"language",value:$F(t),type:"hidden"})),this.unique_id&&s.insert(new Element("input",{name:"uniqueId",value:this.unique_id,type:"hidden"})),this.urls.sandbox_ipn&&s.insert(new Element("input",{name:"sandboxMerchantIPNURL",value:this.urls.sandbox_ipn,type:"hidden"})),this.urls.production_ipn&&s.insert(new Element("input",{name:"productionMerchantIPNURL",value:this.urls.production_ipn,type:"hidden"})),this.urls.js_origins&&this.urls.js_origins.each(function(i){s.insert(new Element("input",{name:"allowedLoginDomains[]",value:i,type:"hidden"}))}),this.urls.return_urls&&this.urls.return_urls.each(function(i){s.insert(new Element("input",{name:"loginRedirectURLs[]",value:i,type:"hidden"}))}),$(document.body).insert(s),s.submit()},startSimplePathValidation:function(i,e,t){if(options=$F(e),options)try{options=options.evalJSON(!0),options.region=$F(t),options&&new Ajax.Request(this.validation.url,{method:"post",parameters:options,onSuccess:this.validationCallback.bind(this,options)})}catch(s){this.displayValidationFailureMsg([this.messages.invalid_json])}},validationCallback:function(i,e){if(e.responseText)try{result=e.responseText.evalJSON(!0),result.valid?this.displayValidationSuccessMsg(result.messages,result.data):this.displayValidationFailureMsg(result.messages)}catch(t){this.displayValidationFailureMsg([this.messages.invalid_json])}},displayValidationSuccessMsg:function(i,e){msg='<ul class="messages"><li class="success-msg"><ul>',i.each(function(i){msg=msg+"<li>"+i+"</li>"}),e&&(msg+='<li><table style="width:100%;"><tbody>',$H(e).each(function(i){msg=msg+'<tr><th style="text-align:right;">'+i.key+':</th><td style="font-weight:normal;">'+i.value+"</td></tr>"}),msg+="</tbody></table></li>"),msg+="</ul></li></ul>",$(this.validation.result).update(msg),this.showSimplePathValidationJson(!1),this.showSimplePathValidationSubmit(!1),this.enableSimplePathRegistrationRegion(!1)},displayValidationFailureMsg:function(i){msg='<ul class="messages"><li class="error-msg"><ul>',i.each(function(i){msg=msg+"<li>"+i+"</li>"}),msg+="</ul></li></ul>",$(this.validation.result).update(msg).show()},isConfigured:function(){return this.merchant_id},spIds:{EUR:"AIOVPYYF70KB5",GBP:"ASGN9CNMS5AA3"},simplePathRegistrationUrl:{EUR:"https://sellercentral-europe.amazon.com/hz/me/sp/redirect?ld=SPEXDEAPA-MagentoPL",GBP:"https://sellercentral-europe.amazon.com/hz/me/sp/redirect?ld=SPEXUKAPA-MagentoPL"},initialize:function(i){this.setupConfig(i.config),this.setupRegistration(i.registration),this.setupValidation(i.validation,i.registration),this.setupView()}};
|
js/creativestyle/amazonpayments.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
var AmazonPayments=function(selectorFn,serializer){var _extendObj=function(e,t){for(var r in t)e[r]=t[r];return this},_xhrCall=function(e,t,r,n,o,a){var i=new XMLHttpRequest;i.onreadystatechange=function(){switch(i.readyState){case XMLHttpRequest.OPENED:o&&o();break;case XMLHttpRequest.DONE:200===i.status?r&&r(i.responseText):n&&n(i.statusText),a&&a()}},i.open("post",e,!0),i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.send(t)},_getElementsBySelector=function(e){return selectorFn(e)},_getElementById=function(e){var t=_getElementsBySelector("#"+e);return t.length?t[0]:null},_getElementByName=function(e){var t=_getElementsBySelector(e);return t.length?t[0]:null},_evalJsScripts=function(html){for(var scripts=html.getElementsByTagName("script"),i=0;i<scripts.length;i++)eval(scripts[i].innerHTML)},_serializeForm=function(){var e=[];checkoutOrderReferenceId&&e.push("orderReferenceId="+checkoutOrderReferenceId);for(var t=0;t<arguments.length;t++){var r=_getElementById(arguments[t]);r&&e.push(serializer(r))}return e.join("&")},_setLoadWaiting=function(){for(var e=0;e<arguments.length;e++){var t=_getElementById(arguments[e]);if(t){var r=t.up("li");r&&r.addClassName("loading")}}},_unsetLoadWaiting=function(){for(var e=0;e<arguments.length;e++){var t=_getElementById(arguments[e]);if(t){var r=t.up("li");r&&r.removeClassName("loading")}}},_setFormLoadWaiting=function(){var e=_getElementById(config.pleaseWaitId);e&&e.show(),_showOverlay()},_unsetFormLoadWaiting=function(){var e=_getElementById(config.pleaseWaitId);e&&e.hide(),_hideOverlay()},_showOverlay=function(){var e=_getElementByName("body");e.insert('<div class="amazon-widget-overlay" id="'+config.amazonPleaseWaitOverlayId+'"></div>')},_hideOverlay=function(){var e=_getElementById(config.amazonPleaseWaitOverlayId);e&&e.remove()},config={live:!0,popup:!0,virtual:!1,pay:{selector:null,callbackUrl:null,design:null},login:{selector:null,callbackUrl:null,design:null},checkoutUrl:null,currency:null,debug:!1,scope:"profile payments:widget payments:shipping_address payments:billing_address",shippingMethodFormId:"co-shipping-method-form",discountCouponFormId:"discount-coupon-form",checkoutAgreementsFormId:"checkout-agreements",checkoutSubmitButtonId:"amazonpayments-checkout-place-order-button",simulationFormId:"sandbox-simulation",pleaseWaitId:"review-please-wait",amazonPleaseWaitOverlayId:"amazon-please-wait-overlay"},checkoutParams={responsive:!0,addressBook:"addressBookWidgetDiv",wallet:"walletWidgetDiv",shippingMethod:"shippingMethodWidgetDiv",review:"reviewWidgetDiv",urls:{}},checkoutOrderReferenceId=null,checkoutSubmitAllowed=!1,checkoutPaymentSelected=!1,addressBookWidget=null,walletWidget=null,errorCodes={clearOrderReference:["InvalidOrderReferenceId"],cancelOrderReference:["AddressNotModifiable","PaymentMethodNotModifiable"],redirect:["BuyerNotAssociated","BuyerSessionExpired","StaleOrderReference"]},_addressSelectCallback=function(){_setCheckoutPaymentSelected(!1),_xhrCall(checkoutParams.urls.saveShipping,_serializeForm(),callbacks.onXhrSuccess,callbacks.onXhrError,function(){_setLoadWaiting(checkoutParams.shippingMethod,checkoutParams.review)},function(){_unsetLoadWaiting(checkoutParams.shippingMethod,checkoutParams.review)})},_orderReferenceCreateCallback=function(e){checkoutOrderReferenceId||(setOrderReferenceId(e.getAmazonOrderReferenceId()),config.virtual||_renderWalletWidget())},_paymentSelectCallback=function(){_setCheckoutPaymentSelected(!0)},_shippingMethodSelectCallback=function(){_xhrCall(checkoutParams.urls.saveShippingMethod,_serializeForm(config.shippingMethodFormId),callbacks.onXhrSuccess,callbacks.onXhrError,function(){_setLoadWaiting(checkoutParams.review)},function(){_unsetLoadWaiting(checkoutParams.review)})},_signInCallback=function(e){var t=document.createElement("input");t.setAttribute("type","hidden"),t.setAttribute("name","orderReferenceId"),t.setAttribute("value",e.getAmazonOrderReferenceId());var r=document.createElement("form");r.setAttribute("method","post"),r.setAttribute("action",config.checkoutUrl),r.appendChild(t),document.body.appendChild(r),r.submit()},_widgetErrorCallback=function(e){config.debug&&alert("["+e.getErrorCode()+"]: "+e.getErrorMessage()),errorCodes.clearOrderReference.some(function(t){return t===e.getErrorCode()})&&(window.location.href=checkoutParams.urls.clearOrderReference||checkoutParams.urls.failure),errorCodes.cancelOrderReference.some(function(t){return t===e.getErrorCode()})&&(window.location.href=checkoutParams.urls.cancelOrderReference||checkoutParams.urls.failure),errorCodes.redirect.some(function(t){return t===e.getErrorCode()})&&(window.location.href=checkoutParams.urls.failure)},_xhrErrorCallback=function(e){config.debug&&alert(e.statusText),e.getResponseHeader("Login-Required")&&checkoutParams.urls.failure&&(window.location=checkoutParams.urls.failure)},_xhrSuccessCallback=function(e){_handleXhrResponse(e)},callbacks={onAddressSelect:_addressSelectCallback,onButtonError:_widgetErrorCallback,onOrderReferenceCreate:_orderReferenceCreateCallback,onPaymentSelect:_paymentSelectCallback,onShippingMethodSelect:_shippingMethodSelectCallback,onSignIn:_signInCallback,onWidgetError:_widgetErrorCallback,onXhrError:_xhrErrorCallback,onXhrSuccess:_xhrSuccessCallback},_setCheckoutSubmitAllowed=function(e){checkoutSubmitAllowed=e,_updateCheckoutSubmitButtonState()},_setCheckoutPaymentSelected=function(e){checkoutPaymentSelected=e,_updateCheckoutSubmitButtonState()},_updateCheckoutSubmitButtonState=function(){var e=document.getElementById(config.checkoutSubmitButtonId);e&&(e.disabled=!checkoutSubmitAllowed||!checkoutPaymentSelected)},_handleXhrResponse=function(e){e=JSON.parse(e),e.error&&_handleXhrErrorResponse(e),e.redirect&&(window.location=e.redirect),e.render_widget&&(e.render_widget["shipping-method"]&&_renderShippingMethod(e.render_widget["shipping-method"]),e.render_widget.review&&_renderReview(e.render_widget.review)),e.disable_widget&&e.disable_widget["address-book"]&&_renderAddressBookWidget("Read"),_setCheckoutSubmitAllowed(e.allow_submit),e.deselect_payment&&_setCheckoutPaymentSelected(!1)},_handleXhrErrorResponse=function(e){e.error_messages&&("object"!=typeof e.error_messages?alert(e.error_messages):alert(e.error_messages.join("\n")))},_getDisplayMode=function(e){return e?e:"Edit"},_renderAddressBookWidget=function(e){return e=_getDisplayMode(e),addressBookWidget=new OffAmazonPayments.Widgets.AddressBook({sellerId:config.merchantId,displayMode:e,onOrderReferenceCreate:"Edit"===e?callbacks.onOrderReferenceCreate:null,amazonOrderReferenceId:checkoutOrderReferenceId,design:checkoutParams.responsive?{designMode:"responsive"}:checkoutParams.addressBook,onAddressSelect:"Edit"===e?callbacks.onAddressSelect:null,onError:callbacks.onWidgetError}),addressBookWidget.bind(checkoutParams.addressBook),this},_renderWalletWidget=function(){return walletWidget=new OffAmazonPayments.Widgets.Wallet({sellerId:config.merchantId,onOrderReferenceCreate:callbacks.onOrderReferenceCreate,amazonOrderReferenceId:checkoutOrderReferenceId,design:checkoutParams.responsive?{designMode:"responsive"}:checkoutParams.wallet,onPaymentSelect:callbacks.onPaymentSelect,onError:callbacks.onWidgetError}),walletWidget.bind(checkoutParams.wallet),this},_renderShippingMethod=function(e){var t=_getElementById(checkoutParams.shippingMethod);if(t){if(t.onchange=callbacks.onShippingMethodSelect,t.innerHTML=e,_evalJsScripts(t),!t.down("input[type=radio]:checked")){var r=t.down("input[type=radio]");r&&(r.checked=!0)}callbacks.onShippingMethodSelect()}return this},_renderReview=function(e){var t=_getElementById(checkoutParams.review);return t&&(t.innerHTML=e,_evalJsScripts(t)),this},saveOrder=function(){_setCheckoutSubmitAllowed(!1),_xhrCall(checkoutParams.urls.saveOrder,_serializeForm(config.checkoutAgreementsFormId,config.shippingMethodFormId,config.simulationFormId),callbacks.onXhrSuccess,callbacks.onXhrError,_setFormLoadWaiting,_unsetFormLoadWaiting)},submitCoupon=function(e){_setCheckoutSubmitAllowed(!1),_xhrCall(checkoutParams.urls.saveCoupon,e?_serializeForm(config.discountCouponFormId)+"&remove=1":_serializeForm(config.discountCouponFormId),callbacks.onXhrSuccess,callbacks.onXhrError,function(){_showOverlay(),_setLoadWaiting(checkoutParams.review)},function(){_hideOverlay(),_unsetLoadWaiting(checkoutParams.review)})},initCheckout=function(e){_extendObj(checkoutParams,e),_setCheckoutSubmitAllowed(!1),config.virtual?(_renderWalletWidget(),_setCheckoutSubmitAllowed(!0)):(_renderAddressBookWidget(),checkoutOrderReferenceId&&_renderWalletWidget())},logout=function(){amazon.Login.logout(),Mage.Cookies.clear("amazon_Login_accessToken")},initLogin=function(){return amazon.Login.setClientId(config.clientId),amazon.Login.setUseCookie(!0),this},renderButtons=function(){var e=null;if(config.pay.selector){var t=_getElementsBySelector(config.pay.selector);if(config.pay&&config.pay.callbackUrl)for(var r=0;r<t.length;r++)e=t[r],e&&new OffAmazonPayments.Button(e.id,config.merchantId,{type:e.buttonType||config.pay.design&&config.pay.design.type||"PwA",size:e.buttonSize||config.pay.design&&config.pay.design.size||"small",color:e.buttonColor||config.pay.design&&config.pay.design.color||"Gold",language:config.language,onError:callbacks.onButtonError,authorization:function(){amazon.Login.authorize({scope:config.scope,popup:config.popup},config.pay.callbackUrl)}});else for(var r=0;r<t.length;r++)e=t[r],e&&new OffAmazonPayments.Widgets.Button({sellerId:config.merchantId,useAmazonAddressBook:!config.virtual,onSignIn:callbacks.onSignIn,onError:callbacks.onButtonError}).bind(e.id)}if(config.login&&config.login.selector)for(var n=_getElementsBySelector(config.login.selector),r=0;r<n.length;r++)e=n[r],e&&new OffAmazonPayments.Button(e.id,config.merchantId,{type:e.buttonType||config.login.design&&config.login.design.type||"LwA",size:e.buttonSize||config.login.design&&config.login.design.size||"small",color:e.buttonColor||config.login.design&&config.login.design.color||"Gold",language:config.language,onError:callbacks.onButtonError,authorization:function(){amazon.Login.authorize({scope:config.scope,popup:config.popup},config.login.callbackUrl)}});return this},setOrderReferenceId=function(e){return checkoutOrderReferenceId=e,this},setup=function(e){return _extendObj(config,e),this};return{setup:setup,setOrderReferenceId:setOrderReferenceId,renderButtons:renderButtons,initLogin:initLogin,logout:logout,initCheckout:initCheckout,submitCoupon:submitCoupon,saveOrder:saveOrder}}($$,Form.serialize);
|
js/creativestyle/amazonpayments.toolbox.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
var AmazonPaymentsToolbox=function(){var t={},e={object:null,state:null,reason:null},n={object:null,state:null,reason:null},o=function(){c()&&s()&&a();for(var n in t){var o=document.createElement("option");o.text=n,e.object.add(o)}return e.object.addEventListener("change",function(t){r(t.target.value)}),e.object.enable().show(),this},a=function(){if(e.object){for(var t=e.object.options.length;t>0;t--)e.object.remove(t-1);var o=document.createElement("option");o.text=n.object,e.object.add(o),e.object.hide().disable()}return this},r=function(n){if(c()&&s(),t[n]&&t[n].states){for(var o in t[n].states){var a=document.createElement("option");a.text=o,e.state.add(a)}e.state.addEventListener("change",function(t){i(n,t.target.value)}),e.state.enable().show()}return this},s=function(){if(e.state){for(var t=e.state.options.length;t>0;t--)e.state.remove(t-1);var o=document.createElement("option");o.text=n.state,e.state.add(o),e.state.hide().disable()}return this},i=function(n,o){if(c(),t[n]&&t[n].states&&t[n].states[o]&&t[n].states[o].reasons){for(var a in t[n].states[o].reasons){var r=document.createElement("option");r.text=a,e.reason.add(r)}e.reason.enable().show()}return this},c=function(){if(e.reason){for(var t=e.reason.options.length;t>0;t--)e.reason.remove(t-1);var o=document.createElement("option");o.text=n.reason,e.reason.add(o),e.reason.hide().disable()}return this},u=function(a,r,s){t=a,e=r,n=s,o()};return{setup:u}}();
|
js/creativestyle/apa_checkout.js
DELETED
@@ -1,635 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* This file is part of the official Amazon Payments Advanced extension
|
3 |
-
* for Magento (c) creativestyle GmbH <amazon@creativestyle.de>
|
4 |
-
* All rights reserved
|
5 |
-
*
|
6 |
-
* Reuse or modification of this source code is not allowed
|
7 |
-
* without written permission from creativestyle GmbH
|
8 |
-
*
|
9 |
-
* @category Creativestyle
|
10 |
-
* @package Creativestyle_AmazonPayments
|
11 |
-
* @copyright Copyright (c) 2014 creativestyle GmbH
|
12 |
-
* @author Marek Zabrowarny / creativestyle GmbH <amazon@creativestyle.de>
|
13 |
-
*/
|
14 |
-
|
15 |
-
if (!window.Review)
|
16 |
-
var Review = function() {};
|
17 |
-
|
18 |
-
var APA = {
|
19 |
-
|
20 |
-
submitAllowed: false,
|
21 |
-
paymentSelected: false,
|
22 |
-
reloaded: false,
|
23 |
-
|
24 |
-
Widgets: {
|
25 |
-
ShippingMethod: Class.create({
|
26 |
-
initialize: function(options) {
|
27 |
-
this.layer = $(APA.layers.shippingMethod);
|
28 |
-
Object.extend(this, options);
|
29 |
-
Event.stopObserving(this.layer, 'widget:update').observe('widget:update', this.onUpdate.bindAsEventListener(this));
|
30 |
-
},
|
31 |
-
update: function(html) {
|
32 |
-
try {
|
33 |
-
Element.update(this.layer, html);
|
34 |
-
if (!this.layer.down('input[type=radio]:checked')) {
|
35 |
-
var firstShippingMethod = this.layer.down('input[type=radio]');
|
36 |
-
if (firstShippingMethod) {
|
37 |
-
firstShippingMethod.checked = true;
|
38 |
-
}
|
39 |
-
}
|
40 |
-
Event.stopObserving(this.layer, 'change').observe('change', this.onShippingMethodSelect.bindAsEventListener(this));
|
41 |
-
Event.stopObserving(this.layer, 'widget:checked').observe('widget:checked', this.onShippingMethodSelect.bindAsEventListener(this));
|
42 |
-
Event.fire(this.layer, 'widget:update');
|
43 |
-
} catch(err) {
|
44 |
-
this.onError(err);
|
45 |
-
}
|
46 |
-
}
|
47 |
-
}),
|
48 |
-
Review: Class.create({
|
49 |
-
initialize: function(options) {
|
50 |
-
this.layer = $(APA.layers.review);
|
51 |
-
Object.extend(this, options);
|
52 |
-
},
|
53 |
-
update: function(html) {
|
54 |
-
try {
|
55 |
-
Element.update(this.layer, html);
|
56 |
-
} catch(err) {
|
57 |
-
this.onError(err);
|
58 |
-
}
|
59 |
-
}
|
60 |
-
})
|
61 |
-
},
|
62 |
-
|
63 |
-
setLoadWaiting: function() {
|
64 |
-
for (var i = 0; i < arguments.length; i++) {
|
65 |
-
if ($(arguments[i])) {
|
66 |
-
var container = $(arguments[i]).up('li');
|
67 |
-
container.addClassName('loading');
|
68 |
-
}
|
69 |
-
}
|
70 |
-
return this;
|
71 |
-
},
|
72 |
-
|
73 |
-
unsetLoadWaiting: function() {
|
74 |
-
for (var i = 0; i < arguments.length; i++) {
|
75 |
-
if ($(arguments[i])) {
|
76 |
-
var container = $(arguments[i]).up('li');
|
77 |
-
container.removeClassName('loading');
|
78 |
-
}
|
79 |
-
}
|
80 |
-
return this;
|
81 |
-
},
|
82 |
-
|
83 |
-
setOrderSaveWaiting: function() {
|
84 |
-
if ($(APA.layers.review)) {
|
85 |
-
var loader = $(APA.layers.review).down('.please-wait');
|
86 |
-
if (loader) {
|
87 |
-
Element.show(loader);
|
88 |
-
}
|
89 |
-
}
|
90 |
-
this.showOverlay();
|
91 |
-
this.disableSubmit();
|
92 |
-
return this;
|
93 |
-
},
|
94 |
-
|
95 |
-
unsetOrderSaveWaiting: function() {
|
96 |
-
if ($(APA.layers.review)) {
|
97 |
-
var loader = $(APA.layers.review).down('.please-wait');
|
98 |
-
if (loader) {
|
99 |
-
Element.hide(loader);
|
100 |
-
}
|
101 |
-
}
|
102 |
-
this.hideOverlay();
|
103 |
-
return this;
|
104 |
-
},
|
105 |
-
|
106 |
-
showOverlay: function() {
|
107 |
-
if ($('checkoutSteps')) {
|
108 |
-
$('checkoutSteps').insert({
|
109 |
-
top: new Element('div', {'class': 'amazon-widget-overlay'})
|
110 |
-
});
|
111 |
-
}
|
112 |
-
return this;
|
113 |
-
},
|
114 |
-
|
115 |
-
hideOverlay: function() {
|
116 |
-
if ($('checkoutSteps') && $('checkoutSteps').down('.amazon-widget-overlay')) {
|
117 |
-
$('checkoutSteps').down('.amazon-widget-overlay').remove();
|
118 |
-
}
|
119 |
-
this.toggleSubmit();
|
120 |
-
return this;
|
121 |
-
},
|
122 |
-
|
123 |
-
initCheckout: function() {
|
124 |
-
this.disableSubmit().scaffoldPaymentWidget();
|
125 |
-
if (this.virtual) {
|
126 |
-
return this.setLoadWaiting(APA.layers.wallet).renderWalletWidget().allowSubmit(true);
|
127 |
-
}
|
128 |
-
if (!this.orderReferenceId) {
|
129 |
-
return this.setLoadWaiting(APA.layers.shippingMethod, APA.layers.wallet, APA.layers.review).renderAddressBookWidget();
|
130 |
-
}
|
131 |
-
return this.setLoadWaiting(APA.layers.shippingMethod, APA.layers.wallet, APA.layers.review).renderAddressBookWidget().renderWalletWidget();
|
132 |
-
},
|
133 |
-
|
134 |
-
scaffoldPaymentWidget: function() {
|
135 |
-
if (typeof APA.design.wallet.size != 'undefined' && !APA.design.responsive) {
|
136 |
-
if (APA.design.wallet.size.width) {
|
137 |
-
$(APA.layers.wallet).up().setStyle({width: APA.design.wallet.size.width});
|
138 |
-
}
|
139 |
-
if (APA.design.wallet.size.height) {
|
140 |
-
$(APA.layers.wallet).up().setStyle({height: APA.design.wallet.size.height});
|
141 |
-
}
|
142 |
-
}
|
143 |
-
return this;
|
144 |
-
},
|
145 |
-
|
146 |
-
renderButtonWidget: function(tooltipContent) {
|
147 |
-
if (APA.urls.login !== null) {
|
148 |
-
$$(APA.layers.payButtons).each(function(button) {
|
149 |
-
var buttonParams = {
|
150 |
-
type: button.buttonType || APA.design.payButton.type || 'PwA',
|
151 |
-
size: button.buttonSize || APA.design.payButton.size,
|
152 |
-
color: button.buttonColor || APA.design.payButton.color,
|
153 |
-
authorization: function() {
|
154 |
-
amazon.Login.authorize({
|
155 |
-
scope: 'profile payments:widget payments:shipping_address payments:billing_address',
|
156 |
-
popup: APA.popup
|
157 |
-
}, APA.urls.pay);
|
158 |
-
},
|
159 |
-
onError: APA.buttonErrorCallback
|
160 |
-
};
|
161 |
-
if (APA.language) {
|
162 |
-
buttonParams.language = APA.language;
|
163 |
-
}
|
164 |
-
new OffAmazonPayments.Button(button.identify(), APA.sellerId, buttonParams);
|
165 |
-
});
|
166 |
-
$$(APA.layers.loginButtons).each(function(button) {
|
167 |
-
var buttonParams = {
|
168 |
-
type: button.buttonType || APA.design.loginButton.type || 'LwA',
|
169 |
-
size: button.buttonSize || APA.design.loginButton.size,
|
170 |
-
color: button.buttonColor || APA.design.loginButton.color,
|
171 |
-
authorization: function() {
|
172 |
-
amazon.Login.authorize({
|
173 |
-
scope: 'profile payments:widget payments:shipping_address payments:billing_address',
|
174 |
-
popup: APA.popup
|
175 |
-
}, APA.urls.login);
|
176 |
-
},
|
177 |
-
onError: APA.buttonErrorCallback
|
178 |
-
};
|
179 |
-
if (APA.language) {
|
180 |
-
buttonParams.language = APA.language;
|
181 |
-
}
|
182 |
-
new OffAmazonPayments.Button(button.identify(), APA.sellerId, buttonParams);
|
183 |
-
});
|
184 |
-
} else {
|
185 |
-
$$(APA.layers.payButtons).each(function(button) {
|
186 |
-
new OffAmazonPayments.Widgets.Button({
|
187 |
-
sellerId: APA.sellerId,
|
188 |
-
useAmazonAddressBook: !APA.virtual,
|
189 |
-
onSignIn: APA.signInCallback,
|
190 |
-
onError: APA.buttonErrorCallback
|
191 |
-
}).bind(button.identify());
|
192 |
-
});
|
193 |
-
}
|
194 |
-
|
195 |
-
// add tooltips
|
196 |
-
if (tooltipContent && typeof Tooltip != 'undefined' && !APA.isMobileDevice()) {
|
197 |
-
var tooltipButtons = $$(APA.layers.payButtons + ',' + APA.layers.loginButtons).findAll(function(button) {
|
198 |
-
return button.hasClassName('with-tooltip');
|
199 |
-
});
|
200 |
-
if (tooltipButtons.length) {
|
201 |
-
var tooltip = document.createElement('div');
|
202 |
-
tooltip.setAttribute('id', 'pay-with-amazon-tooltip');
|
203 |
-
tooltip.addClassName('pay-with-amazon-tooltip');
|
204 |
-
tooltip.setStyle({display: 'none'});
|
205 |
-
tooltip.update(tooltipContent);
|
206 |
-
document.body.appendChild(tooltip);
|
207 |
-
tooltipButtons.each(function(button) {
|
208 |
-
var buttonImg = button.down('img');
|
209 |
-
if (buttonImg) {
|
210 |
-
new Tooltip(buttonImg, tooltip);
|
211 |
-
}
|
212 |
-
});
|
213 |
-
}
|
214 |
-
}
|
215 |
-
},
|
216 |
-
|
217 |
-
signInCallback: function(orderReference) {
|
218 |
-
var id = document.createElement('input');
|
219 |
-
id.setAttribute('type', 'hidden');
|
220 |
-
id.setAttribute('name', 'orderReferenceId');
|
221 |
-
id.setAttribute('value', orderReference.getAmazonOrderReferenceId());
|
222 |
-
var form = document.createElement('form');
|
223 |
-
form.setAttribute('method', 'post');
|
224 |
-
form.setAttribute('action', APA.urls.checkout);
|
225 |
-
form.appendChild(id);
|
226 |
-
document.body.appendChild(form);
|
227 |
-
form.submit();
|
228 |
-
return;
|
229 |
-
},
|
230 |
-
|
231 |
-
renderAddressBookWidget: function() {
|
232 |
-
APA.setLoadWaiting(APA.layers.shippingMethod, APA.layers.review);
|
233 |
-
new OffAmazonPayments.Widgets.AddressBook({
|
234 |
-
sellerId: APA.sellerId,
|
235 |
-
onOrderReferenceCreate: APA.orderReferenceCreateCallback,
|
236 |
-
amazonOrderReferenceId: APA.orderReferenceId,
|
237 |
-
design: (APA.design.responsive ? {designMode: 'responsive'} : APA.design.addressBook),
|
238 |
-
onAddressSelect: APA.addressSelectCallback,
|
239 |
-
onError: APA.amazonErrorCallback,
|
240 |
-
}).bind(APA.layers.addressBook);
|
241 |
-
return this;
|
242 |
-
},
|
243 |
-
|
244 |
-
renderReadOnlyAddressBookWidget: function() {
|
245 |
-
new OffAmazonPayments.Widgets.AddressBook({
|
246 |
-
sellerId: APA.sellerId,
|
247 |
-
amazonOrderReferenceId: APA.orderReferenceId,
|
248 |
-
design: (APA.design.responsive ? {designMode: 'responsive'} : APA.design.addressBook),
|
249 |
-
onError: APA.amazonErrorCallback,
|
250 |
-
displayMode: 'Read'
|
251 |
-
}).bind(APA.layers.addressBook);
|
252 |
-
return this;
|
253 |
-
},
|
254 |
-
|
255 |
-
orderReferenceCreateCallback: function(orderReference) {
|
256 |
-
if (!APA.orderReferenceId) {
|
257 |
-
APA.orderReferenceId = orderReference.getAmazonOrderReferenceId();
|
258 |
-
if (!APA.virtual) {
|
259 |
-
APA.renderWalletWidget();
|
260 |
-
}
|
261 |
-
}
|
262 |
-
},
|
263 |
-
|
264 |
-
addressSelectCallback: function() {
|
265 |
-
APA.selectPayment(false);
|
266 |
-
APA.setLoadWaiting(APA.layers.shippingMethod, APA.layers.review);
|
267 |
-
new Ajax.Request(APA.urls.saveShipping, {
|
268 |
-
method: 'post',
|
269 |
-
parameters: {orderReferenceId: APA.orderReferenceId},
|
270 |
-
evalScripts: true,
|
271 |
-
onSuccess: APA.successCallback,
|
272 |
-
onFailure: APA.ajaxFailureCallback
|
273 |
-
});
|
274 |
-
},
|
275 |
-
|
276 |
-
renderShippingMethodWidget: function(html) {
|
277 |
-
APA.setLoadWaiting(APA.layers.review);
|
278 |
-
new APA.Widgets.ShippingMethod({
|
279 |
-
onShippingMethodSelect: APA.shippingMethodSelectCallback,
|
280 |
-
onUpdate: APA.shippingMethodUpdateCallback,
|
281 |
-
onError: APA.magentoErrorCallback
|
282 |
-
}).update(html);
|
283 |
-
return this;
|
284 |
-
},
|
285 |
-
|
286 |
-
shippingMethodSelectCallback: function(event) {
|
287 |
-
APA.setLoadWaiting(APA.layers.review);
|
288 |
-
new Ajax.Request(APA.urls.saveShippingMethod, {
|
289 |
-
method: 'post',
|
290 |
-
parameters: Form.serialize($('co-shipping-method-form')),
|
291 |
-
evalScripts: true,
|
292 |
-
onSuccess: APA.successCallback,
|
293 |
-
onFailure: APA.ajaxFailureCallback
|
294 |
-
});
|
295 |
-
},
|
296 |
-
|
297 |
-
shippingMethodUpdateCallback: function(event) {
|
298 |
-
var element = Event.element(event);
|
299 |
-
Event.fire(element, 'widget:checked');
|
300 |
-
},
|
301 |
-
|
302 |
-
renderWalletWidget: function() {
|
303 |
-
new OffAmazonPayments.Widgets.Wallet({
|
304 |
-
sellerId: APA.sellerId,
|
305 |
-
onOrderReferenceCreate: APA.orderReferenceCreateCallback,
|
306 |
-
amazonOrderReferenceId: APA.orderReferenceId,
|
307 |
-
design: (APA.design.responsive ? {designMode: 'responsive'} : APA.design.wallet),
|
308 |
-
onPaymentSelect: APA.paymentSelectCallback,
|
309 |
-
onError: APA.amazonErrorCallback
|
310 |
-
}).bind(APA.layers.wallet);
|
311 |
-
return this;
|
312 |
-
},
|
313 |
-
|
314 |
-
paymentSelectCallback: function() {
|
315 |
-
APA.selectPayment(true);
|
316 |
-
},
|
317 |
-
|
318 |
-
reloadWallet: function() {
|
319 |
-
this.renderReadOnlyAddressBookWidget().renderWalletWidget();
|
320 |
-
return this;
|
321 |
-
},
|
322 |
-
|
323 |
-
renderReviewWidget: function(html) {
|
324 |
-
new APA.Widgets.Review({
|
325 |
-
onError: APA.magentoErrorCallback
|
326 |
-
}).update(html);
|
327 |
-
this.toggleSubmit();
|
328 |
-
return this;
|
329 |
-
},
|
330 |
-
|
331 |
-
successCallback: function(transport) {
|
332 |
-
response = eval('(' + transport.responseText + ')');
|
333 |
-
if (response.error) {
|
334 |
-
APA.magentoErrorCallback(response.error_messages);
|
335 |
-
}
|
336 |
-
|
337 |
-
if (response.render_widget) {
|
338 |
-
$H(response.render_widget).each(function(pair) {
|
339 |
-
APA['render' + pair.key.capitalize().camelize() + 'Widget'](pair.value);
|
340 |
-
if (pair.value) {
|
341 |
-
APA.unsetLoadWaiting(APA.layers[pair.key.camelize()]);
|
342 |
-
}
|
343 |
-
});
|
344 |
-
}
|
345 |
-
|
346 |
-
if (response.allow_submit) {
|
347 |
-
APA.allowSubmit(true);
|
348 |
-
} else {
|
349 |
-
APA.allowSubmit(false);
|
350 |
-
}
|
351 |
-
},
|
352 |
-
|
353 |
-
saveOrderCallback: function(transport) {
|
354 |
-
response = eval('(' + transport.responseText + ')');
|
355 |
-
if (response.success) {
|
356 |
-
window.location = APA.urls.success;
|
357 |
-
}
|
358 |
-
if (response.logout && typeof amazon != 'undefined') {
|
359 |
-
amazon.Login.logout();
|
360 |
-
}
|
361 |
-
if (response.error) {
|
362 |
-
APA.unsetOrderSaveWaiting();
|
363 |
-
APA.magentoErrorCallback(response.error_messages);
|
364 |
-
if (response.reload) {
|
365 |
-
APA.reloaded = false;
|
366 |
-
APA.orderReferenceId = null;
|
367 |
-
APA.initCheckout();
|
368 |
-
}
|
369 |
-
if (response.reload_wallet) {
|
370 |
-
APA.reloaded = true;
|
371 |
-
APA.disableSubmit().reloadWallet();
|
372 |
-
}
|
373 |
-
}
|
374 |
-
if (response.redirect) {
|
375 |
-
window.location = response.redirect;
|
376 |
-
}
|
377 |
-
},
|
378 |
-
|
379 |
-
ajaxFailureCallback: function() {
|
380 |
-
window.location.href = APA.urls.failure;
|
381 |
-
},
|
382 |
-
|
383 |
-
confirmErrorRedirect: function(error, redirect_url) {
|
384 |
-
return confirm('An error occured. Redirect to failure URL?' +
|
385 |
-
'\n\nERROR DETAILS:' +
|
386 |
-
'\n==============' +
|
387 |
-
'\n[' + error.getErrorCode() + ']: ' + error.getErrorMessage() +
|
388 |
-
'\n\nDEBUG DATA:' +
|
389 |
-
'\n==============' +
|
390 |
-
'\nREDIRECT URL = ' + redirect_url +
|
391 |
-
(APA.sellerId ? '\nMERCHANT ID = ' + APA.sellerId : '') +
|
392 |
-
(APA.orderReferenceId ? '\nORDER REFERENCE ID = ' + APA.orderReferenceId : '') +
|
393 |
-
(APA.language ? '\nLANGUAGE = ' + APA.language : '') +
|
394 |
-
'\nPOPUP EXPERIENCE = ' + (APA.popup ? 'yes' : 'no') +
|
395 |
-
'\nVIRTUAL ORDER = ' + (APA.virtual ? 'yes' : 'no') +
|
396 |
-
'\n\nSTACK TRACE:' +
|
397 |
-
'\n==============' +
|
398 |
-
'\n' + (new Error()).stack +
|
399 |
-
'');
|
400 |
-
},
|
401 |
-
|
402 |
-
buttonErrorCallback: function(error) {
|
403 |
-
if (!APA.live) {
|
404 |
-
console.error('BUTTON ERROR [' + error.getErrorCode() + ']: ' + error.getErrorMessage());
|
405 |
-
console.trace();
|
406 |
-
}
|
407 |
-
},
|
408 |
-
|
409 |
-
amazonErrorCallback: function(error) {
|
410 |
-
var debug_data = {'Order Reference ID': APA.orderReferenceId};
|
411 |
-
var clearOrderReferenceErrors = ['InvalidOrderReferenceId'];
|
412 |
-
if (clearOrderReferenceErrors.any(function(errorCode) { return errorCode == error.getErrorCode(); })) {
|
413 |
-
if (APA.live || APA.confirmErrorRedirect(error, APA.urls.clear || APA.urls.failure)) {
|
414 |
-
window.location.href = APA.urls.clear || APA.urls.failure;
|
415 |
-
}
|
416 |
-
return;
|
417 |
-
}
|
418 |
-
var voidOrderReferenceErrors = ['AddressNotModifiable', 'PaymentMethodNotModifiable'];
|
419 |
-
if (voidOrderReferenceErrors.any(function(errorCode) { return errorCode == error.getErrorCode(); })) {
|
420 |
-
if (APA.live || APA.confirmErrorRedirect(error, APA.urls.void || APA.urls.failure)) {
|
421 |
-
window.location.href = APA.urls.void || APA.urls.failure;
|
422 |
-
}
|
423 |
-
return;
|
424 |
-
}
|
425 |
-
var redirectErrors = ['BuyerNotAssociated', 'BuyerSessionExpired', 'StaleOrderReference'];
|
426 |
-
if (redirectErrors.any(function(errorCode) { return errorCode == error.getErrorCode(); })) {
|
427 |
-
if (APA.live || APA.confirmErrorRedirect(error, APA.urls.failure)) {
|
428 |
-
window.location.href = APA.urls.failure;
|
429 |
-
}
|
430 |
-
return;
|
431 |
-
}
|
432 |
-
if (!APA.live) {
|
433 |
-
console.error('AMAZON ERROR [' + error.getErrorCode() + ']: ' + error.getErrorMessage());
|
434 |
-
console.trace();
|
435 |
-
}
|
436 |
-
},
|
437 |
-
|
438 |
-
magentoErrorCallback: function(error) {
|
439 |
-
if (!APA.live) {
|
440 |
-
console.trace();
|
441 |
-
}
|
442 |
-
if (typeof(error) == 'object') {
|
443 |
-
error = error.join("\n");
|
444 |
-
}
|
445 |
-
if (error) {
|
446 |
-
alert(error);
|
447 |
-
}
|
448 |
-
},
|
449 |
-
|
450 |
-
allowSubmit: function(allowed) {
|
451 |
-
this.submitAllowed = allowed;
|
452 |
-
return this.toggleSubmit();
|
453 |
-
},
|
454 |
-
|
455 |
-
selectPayment: function(selected) {
|
456 |
-
this.paymentSelected = selected;
|
457 |
-
return this.toggleSubmit();
|
458 |
-
},
|
459 |
-
|
460 |
-
toggleSubmit: function() {
|
461 |
-
if (this.submitAllowed && this.paymentSelected) {
|
462 |
-
return this.enableSubmit();
|
463 |
-
}
|
464 |
-
return this.disableSubmit();
|
465 |
-
},
|
466 |
-
|
467 |
-
disableSubmit: function() {
|
468 |
-
var button = $('amazonpayments-checkout-place-order-button');
|
469 |
-
if (button) {
|
470 |
-
button.disabled = true;
|
471 |
-
var buttonContainer = button.up('div.buttons-set');
|
472 |
-
if (buttonContainer) {
|
473 |
-
buttonContainer.addClassName('disabled');
|
474 |
-
}
|
475 |
-
}
|
476 |
-
return this;
|
477 |
-
},
|
478 |
-
|
479 |
-
enableSubmit: function() {
|
480 |
-
if (this.submitAllowed && this.paymentSelected) {
|
481 |
-
var button = $('amazonpayments-checkout-place-order-button');
|
482 |
-
if (button) {
|
483 |
-
button.disabled = false;
|
484 |
-
var buttonContainer = button.up('div.buttons-set');
|
485 |
-
if (buttonContainer) {
|
486 |
-
buttonContainer.removeClassName('disabled');
|
487 |
-
}
|
488 |
-
}
|
489 |
-
}
|
490 |
-
return this;
|
491 |
-
},
|
492 |
-
|
493 |
-
saveOrder: function() {
|
494 |
-
APA.setOrderSaveWaiting();
|
495 |
-
new Ajax.Request(APA.urls.saveOrder, {
|
496 |
-
method: 'post',
|
497 |
-
parameters: APA.getSaveOrderParams(),
|
498 |
-
onSuccess: APA.saveOrderCallback,
|
499 |
-
onFailure: APA.ajaxFailureCallback
|
500 |
-
});
|
501 |
-
},
|
502 |
-
|
503 |
-
submitCoupon: function() {
|
504 |
-
APA.setLoadWaiting(APA.layers.review);
|
505 |
-
new Ajax.Request(APA.urls.coupon, {
|
506 |
-
method: 'post',
|
507 |
-
parameters: Form.serialize($('discount-coupon-form')),
|
508 |
-
evalScripts: true,
|
509 |
-
onSuccess: APA.successCallback,
|
510 |
-
onFailure: APA.ajaxFailureCallback
|
511 |
-
});
|
512 |
-
},
|
513 |
-
|
514 |
-
cancelCoupon: function() {
|
515 |
-
APA.setLoadWaiting(APA.layers.review);
|
516 |
-
new Ajax.Request(APA.urls.coupon, {
|
517 |
-
method: 'post',
|
518 |
-
parameters: {remove: 1},
|
519 |
-
evalScripts: true,
|
520 |
-
onSuccess: APA.successCallback,
|
521 |
-
onFailure: APA.ajaxFailureCallback
|
522 |
-
});
|
523 |
-
},
|
524 |
-
|
525 |
-
getSaveOrderParams: function() {
|
526 |
-
var params = '';
|
527 |
-
if (APA.virtual) {
|
528 |
-
params += Object.toQueryString({orderReferenceId: APA.orderReferenceId});
|
529 |
-
if ($('checkout-agreements')) {
|
530 |
-
params += '&' + Form.serialize($('checkout-agreements'));
|
531 |
-
}
|
532 |
-
} else {
|
533 |
-
params = Form.serialize($('co-shipping-method-form'));
|
534 |
-
if ($('checkout-agreements')) {
|
535 |
-
params += '&' + Form.serialize($('checkout-agreements'));
|
536 |
-
}
|
537 |
-
}
|
538 |
-
if (APA.reloaded) {
|
539 |
-
params += '&' + Object.toQueryString({reloaded: 1});
|
540 |
-
}
|
541 |
-
params.save = true;
|
542 |
-
return params;
|
543 |
-
},
|
544 |
-
|
545 |
-
isMobileDevice: function() {
|
546 |
-
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(navigator.userAgent || navigator.vendor || window.opera) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test((navigator.userAgent || navigator.vendor || window.opera).substr(0,4));
|
547 |
-
},
|
548 |
-
|
549 |
-
initialize: function(sellerId, orderReferenceId, live, virtual, urls, layers, design) {
|
550 |
-
return Object.extend(APA, {
|
551 |
-
sellerId: sellerId,
|
552 |
-
orderReferenceId: orderReferenceId,
|
553 |
-
live: live,
|
554 |
-
virtual: virtual,
|
555 |
-
urls: Object.extend({
|
556 |
-
login: null,
|
557 |
-
pay: null,
|
558 |
-
checkout: null,
|
559 |
-
saveShipping: null,
|
560 |
-
saveShippingMethod: null,
|
561 |
-
saveOrder: null,
|
562 |
-
success: null,
|
563 |
-
failure: null
|
564 |
-
}, urls),
|
565 |
-
layers: Object.extend({
|
566 |
-
payButtons: '.payButtonWidget',
|
567 |
-
loginButtons: '.loginButtonWidget',
|
568 |
-
addressBook: 'addressBookWidgetDiv',
|
569 |
-
wallet: 'walletWidgetDiv',
|
570 |
-
shippingMethod: 'shippingMethodWidgetDiv',
|
571 |
-
review: 'reviewWidgetDiv'
|
572 |
-
}, layers),
|
573 |
-
design: Object.extend({
|
574 |
-
addressBook: {
|
575 |
-
size: {
|
576 |
-
width: '440px',
|
577 |
-
height: '260px'
|
578 |
-
}
|
579 |
-
},
|
580 |
-
wallet: {
|
581 |
-
size: {
|
582 |
-
width: '440px',
|
583 |
-
height: '260px'
|
584 |
-
}
|
585 |
-
},
|
586 |
-
payButton: {
|
587 |
-
type: 'PwA'
|
588 |
-
},
|
589 |
-
loginButton: {
|
590 |
-
type: 'LwA'
|
591 |
-
}
|
592 |
-
}, design)
|
593 |
-
});
|
594 |
-
},
|
595 |
-
|
596 |
-
setup: function(sellerId, options) {
|
597 |
-
return Object.extend(APA, {
|
598 |
-
sellerId: sellerId,
|
599 |
-
orderReferenceId: typeof options.orderReferenceId == 'undefined' ? null : options.orderReferenceId,
|
600 |
-
language: typeof options.language == 'undefined' ? null : options.language,
|
601 |
-
live: typeof options.live == 'undefined' ? true : options.live,
|
602 |
-
popup: typeof options.popup == 'undefined' ? true : options.popup,
|
603 |
-
virtual: typeof options.virtual == 'undefined' ? false : options.virtual,
|
604 |
-
layers: Object.extend({
|
605 |
-
payButtons: '.payButtonWidget',
|
606 |
-
loginButtons: '.loginButtonWidget',
|
607 |
-
addressBook: 'addressBookWidgetDiv',
|
608 |
-
wallet: 'walletWidgetDiv',
|
609 |
-
shippingMethod: 'shippingMethodWidgetDiv',
|
610 |
-
review: 'reviewWidgetDiv'
|
611 |
-
}, options.layers),
|
612 |
-
urls: Object.extend({
|
613 |
-
login: null,
|
614 |
-
pay: null,
|
615 |
-
checkout: null,
|
616 |
-
saveShipping: null,
|
617 |
-
saveShippingMethod: null,
|
618 |
-
saveOrder: null,
|
619 |
-
coupon: null,
|
620 |
-
clear: null,
|
621 |
-
void: null,
|
622 |
-
success: null,
|
623 |
-
failure: null
|
624 |
-
}, options.urls),
|
625 |
-
design: Object.extend({
|
626 |
-
responsive: true,
|
627 |
-
addressBook: {size: {width: '440px', height: '260px'}},
|
628 |
-
wallet: {size: {width: '440px', height: '260px'}},
|
629 |
-
payButton: {type: 'PwA'},
|
630 |
-
loginButton: {type: 'LwA'}
|
631 |
-
}, options.design)
|
632 |
-
});
|
633 |
-
}
|
634 |
-
|
635 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/creativestyle/apa_checkout.min.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
if(!window.Review)var Review=function(){};var APA={submitAllowed:!1,paymentSelected:!1,reloaded:!1,Widgets:{ShippingMethod:Class.create({initialize:function(e){this.layer=$(APA.layers.shippingMethod),Object.extend(this,e),Event.stopObserving(this.layer,"widget:update").observe("widget:update",this.onUpdate.bindAsEventListener(this))},update:function(e){try{if(Element.update(this.layer,e),!this.layer.down("input[type=radio]:checked")){var t=this.layer.down("input[type=radio]");t&&(t.checked=!0)}Event.stopObserving(this.layer,"change").observe("change",this.onShippingMethodSelect.bindAsEventListener(this)),Event.stopObserving(this.layer,"widget:checked").observe("widget:checked",this.onShippingMethodSelect.bindAsEventListener(this)),Event.fire(this.layer,"widget:update")}catch(r){this.onError(r)}}}),Review:Class.create({initialize:function(e){this.layer=$(APA.layers.review),Object.extend(this,e)},update:function(e){try{Element.update(this.layer,e)}catch(t){this.onError(t)}}})},setLoadWaiting:function(){for(var e=0;e<arguments.length;e++)if($(arguments[e])){var t=$(arguments[e]).up("li");t.addClassName("loading")}return this},unsetLoadWaiting:function(){for(var e=0;e<arguments.length;e++)if($(arguments[e])){var t=$(arguments[e]).up("li");t.removeClassName("loading")}return this},setOrderSaveWaiting:function(){if($(APA.layers.review)){var e=$(APA.layers.review).down(".please-wait");e&&Element.show(e)}return this.showOverlay(),this.disableSubmit(),this},unsetOrderSaveWaiting:function(){if($(APA.layers.review)){var e=$(APA.layers.review).down(".please-wait");e&&Element.hide(e)}return this.hideOverlay(),this},showOverlay:function(){return $("checkoutSteps")&&$("checkoutSteps").insert({top:new Element("div",{"class":"amazon-widget-overlay"})}),this},hideOverlay:function(){return $("checkoutSteps")&&$("checkoutSteps").down(".amazon-widget-overlay")&&$("checkoutSteps").down(".amazon-widget-overlay").remove(),this.toggleSubmit(),this},initCheckout:function(){return this.disableSubmit().scaffoldPaymentWidget(),this.virtual?this.setLoadWaiting(APA.layers.wallet).renderWalletWidget().allowSubmit(!0):this.orderReferenceId?this.setLoadWaiting(APA.layers.shippingMethod,APA.layers.wallet,APA.layers.review).renderAddressBookWidget().renderWalletWidget():this.setLoadWaiting(APA.layers.shippingMethod,APA.layers.wallet,APA.layers.review).renderAddressBookWidget()},scaffoldPaymentWidget:function(){return"undefined"==typeof APA.design.wallet.size||APA.design.responsive||(APA.design.wallet.size.width&&$(APA.layers.wallet).up().setStyle({width:APA.design.wallet.size.width}),APA.design.wallet.size.height&&$(APA.layers.wallet).up().setStyle({height:APA.design.wallet.size.height})),this},renderButtonWidget:function(e){if(null!==APA.urls.login?($$(APA.layers.payButtons).each(function(e){var t={type:e.buttonType||APA.design.payButton.type||"PwA",size:e.buttonSize||APA.design.payButton.size,color:e.buttonColor||APA.design.payButton.color,authorization:function(){amazon.Login.authorize({scope:"profile payments:widget payments:shipping_address payments:billing_address",popup:APA.popup},APA.urls.pay)},onError:APA.buttonErrorCallback};APA.language&&(t.language=APA.language),new OffAmazonPayments.Button(e.identify(),APA.sellerId,t)}),$$(APA.layers.loginButtons).each(function(e){var t={type:e.buttonType||APA.design.loginButton.type||"LwA",size:e.buttonSize||APA.design.loginButton.size,color:e.buttonColor||APA.design.loginButton.color,authorization:function(){amazon.Login.authorize({scope:"profile payments:widget payments:shipping_address payments:billing_address",popup:APA.popup},APA.urls.login)},onError:APA.buttonErrorCallback};APA.language&&(t.language=APA.language),new OffAmazonPayments.Button(e.identify(),APA.sellerId,t)})):$$(APA.layers.payButtons).each(function(e){new OffAmazonPayments.Widgets.Button({sellerId:APA.sellerId,useAmazonAddressBook:!APA.virtual,onSignIn:APA.signInCallback,onError:APA.buttonErrorCallback}).bind(e.identify())}),e&&"undefined"!=typeof Tooltip&&!APA.isMobileDevice()){var t=$$(APA.layers.payButtons+","+APA.layers.loginButtons).findAll(function(e){return e.hasClassName("with-tooltip")});if(t.length){var r=document.createElement("div");r.setAttribute("id","pay-with-amazon-tooltip"),r.addClassName("pay-with-amazon-tooltip"),r.setStyle({display:"none"}),r.update(e),document.body.appendChild(r),t.each(function(e){var t=e.down("img");t&&new Tooltip(t,r)})}}},signInCallback:function(e){var t=document.createElement("input");t.setAttribute("type","hidden"),t.setAttribute("name","orderReferenceId"),t.setAttribute("value",e.getAmazonOrderReferenceId());var r=document.createElement("form");r.setAttribute("method","post"),r.setAttribute("action",APA.urls.checkout),r.appendChild(t),document.body.appendChild(r),r.submit()},renderAddressBookWidget:function(){return APA.setLoadWaiting(APA.layers.shippingMethod,APA.layers.review),new OffAmazonPayments.Widgets.AddressBook({sellerId:APA.sellerId,onOrderReferenceCreate:APA.orderReferenceCreateCallback,amazonOrderReferenceId:APA.orderReferenceId,design:APA.design.responsive?{designMode:"responsive"}:APA.design.addressBook,onAddressSelect:APA.addressSelectCallback,onError:APA.amazonErrorCallback}).bind(APA.layers.addressBook),this},renderReadOnlyAddressBookWidget:function(){return new OffAmazonPayments.Widgets.AddressBook({sellerId:APA.sellerId,amazonOrderReferenceId:APA.orderReferenceId,design:APA.design.responsive?{designMode:"responsive"}:APA.design.addressBook,onError:APA.amazonErrorCallback,displayMode:"Read"}).bind(APA.layers.addressBook),this},orderReferenceCreateCallback:function(e){APA.orderReferenceId||(APA.orderReferenceId=e.getAmazonOrderReferenceId(),APA.virtual||APA.renderWalletWidget())},addressSelectCallback:function(){APA.selectPayment(!1),APA.setLoadWaiting(APA.layers.shippingMethod,APA.layers.review),new Ajax.Request(APA.urls.saveShipping,{method:"post",parameters:{orderReferenceId:APA.orderReferenceId},evalScripts:!0,onSuccess:APA.successCallback,onFailure:APA.ajaxFailureCallback})},renderShippingMethodWidget:function(e){return APA.setLoadWaiting(APA.layers.review),new APA.Widgets.ShippingMethod({onShippingMethodSelect:APA.shippingMethodSelectCallback,onUpdate:APA.shippingMethodUpdateCallback,onError:APA.magentoErrorCallback}).update(e),this},shippingMethodSelectCallback:function(e){APA.setLoadWaiting(APA.layers.review),new Ajax.Request(APA.urls.saveShippingMethod,{method:"post",parameters:Form.serialize($("co-shipping-method-form")),evalScripts:!0,onSuccess:APA.successCallback,onFailure:APA.ajaxFailureCallback})},shippingMethodUpdateCallback:function(e){var t=Event.element(e);Event.fire(t,"widget:checked")},renderWalletWidget:function(){return new OffAmazonPayments.Widgets.Wallet({sellerId:APA.sellerId,onOrderReferenceCreate:APA.orderReferenceCreateCallback,amazonOrderReferenceId:APA.orderReferenceId,design:APA.design.responsive?{designMode:"responsive"}:APA.design.wallet,onPaymentSelect:APA.paymentSelectCallback,onError:APA.amazonErrorCallback}).bind(APA.layers.wallet),this},paymentSelectCallback:function(){APA.selectPayment(!0)},reloadWallet:function(){return this.renderReadOnlyAddressBookWidget().renderWalletWidget(),this},renderReviewWidget:function(e){return new APA.Widgets.Review({onError:APA.magentoErrorCallback}).update(e),this.toggleSubmit(),this},successCallback:function(transport){response=eval("("+transport.responseText+")"),response.error&&APA.magentoErrorCallback(response.error_messages),response.render_widget&&$H(response.render_widget).each(function(e){APA["render"+e.key.capitalize().camelize()+"Widget"](e.value),e.value&&APA.unsetLoadWaiting(APA.layers[e.key.camelize()])}),response.allow_submit?APA.allowSubmit(!0):APA.allowSubmit(!1)},saveOrderCallback:function(transport){response=eval("("+transport.responseText+")"),response.success&&(window.location=APA.urls.success),response.logout&&"undefined"!=typeof amazon&&amazon.Login.logout(),response.error&&(APA.unsetOrderSaveWaiting(),APA.magentoErrorCallback(response.error_messages),response.reload&&(APA.reloaded=!1,APA.orderReferenceId=null,APA.initCheckout()),response.reload_wallet&&(APA.reloaded=!0,APA.disableSubmit().reloadWallet())),response.redirect&&(window.location=response.redirect)},ajaxFailureCallback:function(){window.location.href=APA.urls.failure},confirmErrorRedirect:function(e,t){return confirm("An error occured. Redirect to failure URL?\n\nERROR DETAILS:\n==============\n["+e.getErrorCode()+"]: "+e.getErrorMessage()+"\n\nDEBUG DATA:\n==============\nREDIRECT URL = "+t+(APA.sellerId?"\nMERCHANT ID = "+APA.sellerId:"")+(APA.orderReferenceId?"\nORDER REFERENCE ID = "+APA.orderReferenceId:"")+(APA.language?"\nLANGUAGE = "+APA.language:"")+"\nPOPUP EXPERIENCE = "+(APA.popup?"yes":"no")+"\nVIRTUAL ORDER = "+(APA.virtual?"yes":"no")+"\n\nSTACK TRACE:\n==============\n"+(new Error).stack)},buttonErrorCallback:function(e){APA.live||(console.error("BUTTON ERROR ["+e.getErrorCode()+"]: "+e.getErrorMessage()),console.trace())},amazonErrorCallback:function(e){var t=({"Order Reference ID":APA.orderReferenceId},["InvalidOrderReferenceId"]);if(t.any(function(t){return t==e.getErrorCode()}))return void((APA.live||APA.confirmErrorRedirect(e,APA.urls.clear||APA.urls.failure))&&(window.location.href=APA.urls.clear||APA.urls.failure));var r=["AddressNotModifiable","PaymentMethodNotModifiable"];if(r.any(function(t){return t==e.getErrorCode()}))return void((APA.live||APA.confirmErrorRedirect(e,APA.urls["void"]||APA.urls.failure))&&(window.location.href=APA.urls["void"]||APA.urls.failure));var n=["BuyerNotAssociated","BuyerSessionExpired","StaleOrderReference"];return n.any(function(t){return t==e.getErrorCode()})?void((APA.live||APA.confirmErrorRedirect(e,APA.urls.failure))&&(window.location.href=APA.urls.failure)):void(APA.live||(console.error("AMAZON ERROR ["+e.getErrorCode()+"]: "+e.getErrorMessage()),console.trace()))},magentoErrorCallback:function(e){APA.live||console.trace(),"object"==typeof e&&(e=e.join("\n")),e&&alert(e)},allowSubmit:function(e){return this.submitAllowed=e,this.toggleSubmit()},selectPayment:function(e){return this.paymentSelected=e,this.toggleSubmit()},toggleSubmit:function(){return this.submitAllowed&&this.paymentSelected?this.enableSubmit():this.disableSubmit()},disableSubmit:function(){var e=$("amazonpayments-checkout-place-order-button");if(e){e.disabled=!0;var t=e.up("div.buttons-set");t&&t.addClassName("disabled")}return this},enableSubmit:function(){if(this.submitAllowed&&this.paymentSelected){var e=$("amazonpayments-checkout-place-order-button");if(e){e.disabled=!1;var t=e.up("div.buttons-set");t&&t.removeClassName("disabled")}}return this},saveOrder:function(){APA.setOrderSaveWaiting(),new Ajax.Request(APA.urls.saveOrder,{method:"post",parameters:APA.getSaveOrderParams(),onSuccess:APA.saveOrderCallback,onFailure:APA.ajaxFailureCallback})},submitCoupon:function(){APA.setLoadWaiting(APA.layers.review),new Ajax.Request(APA.urls.coupon,{method:"post",parameters:Form.serialize($("discount-coupon-form")),evalScripts:!0,onSuccess:APA.successCallback,onFailure:APA.ajaxFailureCallback})},cancelCoupon:function(){APA.setLoadWaiting(APA.layers.review),new Ajax.Request(APA.urls.coupon,{method:"post",parameters:{remove:1},evalScripts:!0,onSuccess:APA.successCallback,onFailure:APA.ajaxFailureCallback})},getSaveOrderParams:function(){var e="";return APA.virtual?(e+=Object.toQueryString({orderReferenceId:APA.orderReferenceId}),$("checkout-agreements")&&(e+="&"+Form.serialize($("checkout-agreements")))):(e=Form.serialize($("co-shipping-method-form")),$("checkout-agreements")&&(e+="&"+Form.serialize($("checkout-agreements")))),APA.reloaded&&(e+="&"+Object.toQueryString({reloaded:1})),e.save=!0,e},isMobileDevice:function(){return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(navigator.userAgent||navigator.vendor||window.opera)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test((navigator.userAgent||navigator.vendor||window.opera).substr(0,4))},initialize:function(e,t,r,n,i,a,o){return Object.extend(APA,{sellerId:e,orderReferenceId:t,live:r,virtual:n,urls:Object.extend({login:null,pay:null,checkout:null,saveShipping:null,saveShippingMethod:null,saveOrder:null,success:null,failure:null},i),layers:Object.extend({payButtons:".payButtonWidget",loginButtons:".loginButtonWidget",addressBook:"addressBookWidgetDiv",wallet:"walletWidgetDiv",shippingMethod:"shippingMethodWidgetDiv",review:"reviewWidgetDiv"},a),design:Object.extend({addressBook:{size:{width:"440px",height:"260px"}},wallet:{size:{width:"440px",height:"260px"}},payButton:{type:"PwA"},loginButton:{type:"LwA"}},o)})},setup:function(e,t){return Object.extend(APA,{sellerId:e,orderReferenceId:"undefined"==typeof t.orderReferenceId?null:t.orderReferenceId,language:"undefined"==typeof t.language?null:t.language,live:"undefined"==typeof t.live||t.live,popup:"undefined"==typeof t.popup||t.popup,virtual:"undefined"!=typeof t.virtual&&t.virtual,layers:Object.extend({payButtons:".payButtonWidget",loginButtons:".loginButtonWidget",addressBook:"addressBookWidgetDiv",wallet:"walletWidgetDiv",shippingMethod:"shippingMethodWidgetDiv",review:"reviewWidgetDiv"},t.layers),urls:Object.extend({login:null,pay:null,checkout:null,saveShipping:null,saveShippingMethod:null,saveOrder:null,coupon:null,clear:null,"void":null,success:null,failure:null},t.urls),design:Object.extend({responsive:!0,addressBook:{size:{width:"440px",height:"260px"}},wallet:{size:{width:"440px",height:"260px"}},payButton:{type:"PwA"},loginButton:{type:"LwA"}},t.design)})}};
|
|
js/creativestyle/apa_sandbox_toolbox.min.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
if("undefined"==typeof APA)var APA={};APA.Toolbox={clearSimulationObjects:function(){APA.Toolbox.objectSelect.descendants().each(Element.remove),APA.Toolbox.objectSelect.hide().disable().insert(new Element("option",{value:""}).update(APA.Toolbox.labels.object))},clearSimulationStates:function(){APA.Toolbox.stateSelect.descendants().each(Element.remove),APA.Toolbox.stateSelect.hide().disable().insert(new Element("option",{value:""}).update(APA.Toolbox.labels.state))},clearSimulationReasons:function(){APA.Toolbox.reasonSelect.descendants().each(Element.remove),APA.Toolbox.reasonSelect.hide().disable().insert(new Element("option",{value:""}).update(APA.Toolbox.labels.reason))},fillSimulationObjects:function(){APA.Toolbox.clearSimulationReasons(),APA.Toolbox.clearSimulationStates(),APA.Toolbox.clearSimulationObjects(),$H(APA.Toolbox.availableSimulations).each(function(e){APA.Toolbox.objectSelect.insert(new Element("option",{value:e.key}).update(e.key))}),APA.Toolbox.objectSelect.enable().show(),APA.Toolbox.objectSelect.observe("change",function(e){var o=APA.Toolbox.objectSelect.getValue();o&&"undefined"!=typeof APA.Toolbox.availableSimulations[o]&&"undefined"!=typeof APA.Toolbox.availableSimulations[o].states?APA.Toolbox.fillSimulationStates(APA.Toolbox.availableSimulations[o].states):(APA.Toolbox.clearSimulationReasons(),APA.Toolbox.clearSimulationStates())})},fillSimulationStates:function(e){APA.Toolbox.clearSimulationReasons(),APA.Toolbox.clearSimulationStates(),$H(e).each(function(e){APA.Toolbox.stateSelect.insert(new Element("option",{value:e.key}).update(e.key))}),APA.Toolbox.stateSelect.enable().show(),APA.Toolbox.stateSelect.observe("change",function(o){var t=APA.Toolbox.stateSelect.getValue();t&&"undefined"!=typeof e[t]&&"undefined"!=typeof e[t].reasons?APA.Toolbox.fillSimulationReasons(e[t].reasons):APA.Toolbox.clearSimulationReasons()})},fillSimulationReasons:function(e){APA.Toolbox.clearSimulationReasons(),$H(e).each(function(e){APA.Toolbox.reasonSelect.insert(new Element("option",{value:e.key}).update(e.key))}),APA.Toolbox.reasonSelect.enable().show()},initialize:function(e,o,t){document.observe("dom:loaded",Object.extend(APA.Toolbox,{availableSimulations:e,objectSelect:$(o.object),stateSelect:$(o.state),reasonSelect:$(o.reason),labels:t}).fillSimulationObjects)}},APA.getSaveOrderParams=function(){var e="";return APA.virtual?(e+=Object.toQueryString({orderReferenceId:APA.orderReferenceId}),$("checkout-agreements")&&(e+="&"+Form.serialize($("checkout-agreements")))):(e=Form.serialize($("co-shipping-method-form")),$("checkout-agreements")&&(e+="&"+Form.serialize($("checkout-agreements")))),APA.reloaded&&(e+="&"+Object.toQueryString({reloaded:1})),$("sandbox-simulation")&&$("simulation_object").getValue()&&(e+="&"+Form.serialize($("sandbox-simulation"))),e.save=!0,e};
|
|
package.xml
CHANGED
@@ -1,26 +1,25 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Creativestyle_AmazonPayments</name>
|
4 |
-
<version>
|
5 |
<stability>stable</stability>
|
6 |
<license>Creative Commons Attribution-NoDerivatives 4.0 International</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Integration of your Magento shop with Login and Pay with Amazon service</summary>
|
10 |
<description>This extension provides an official integration of your Magento store with Login and Pay with Amazon service. It helps your customers shop quickly, safely and securely. Your customers can pay on your website without re-entering their payment and address details. All Amazon transactions are protected by Amazon's A-to-z Guarantee.</description>
|
11 |
-
<notes>#
|
12 |
-
-
|
13 |
-
- Added possibility to disconnect customer account from Amazon account
|
14 |
# Changes
|
15 |
-
-
|
16 |
-
-
|
17 |
-
|
18 |
-
-
|
19 |
</notes>
|
20 |
<authors><author><name>creativestyle GmbH</name><user>creativestyle</user><email>amazon@creativestyle.de</email></author></authors>
|
21 |
-
<date>2017-
|
22 |
-
<time>
|
23 |
-
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="amazonpayments.xml" hash="08f9c3c3cdd9536c28746bb3be7eeb0c"/></dir><dir name="template"><dir name="creativestyle"><dir name="amazonpayments"><dir name="advanced"><file name="documentation.phtml" hash="af3ae6ebce4712dd8fb972bef508ca55"/><dir name="log"><dir name="api"><file name="view.phtml" hash="2c2fcd6122b4481ad2cf8b7657f3f187"/></dir><dir name="exception"><file name="view.phtml" hash="c5d01f6de86e47d4da5dfabd60b1b382"/></dir><file name="js.phtml" hash="eb1d2098440a0bac2a6f5b959afa3693"/><dir name="notification"><file name="view.phtml" hash="31d893106f7c7c7f94f05d5cafa36440"/></dir></dir></dir><dir name="debug"><dir name="section"><file name="table.phtml" hash="f4bb8e35b3608cf0639407a3461c3717"/></dir><file name="section.phtml" hash="1472da0e9f07b5583a02e327483d4d75"/></dir><file name="debug.phtml" hash="9748d4fe92986f36ad47ae5b61fc4883"/><file name="info.phtml" hash="c3748d44ad12514e379393e3722c7b82"/><file name="init.phtml" hash="ba9d53045077e63b4e6c25c6b7bb685c"/><file name="notifications.phtml" hash="2bdcecbebc9b0df6d00ad5c49c464e2d"/><dir name="payment"><file name="info.phtml" hash="1604a1ca8c640748023859dee07f1182"/><dir name="legacy"><file name="info.phtml" hash="7d35f0a93900f40fb4433f576734595a"/><dir name="pdf"><file name="info.phtml" hash="73e54dbec4a659063a6e6c3b35565159"/></dir></dir><dir name="pdf"><file name="info.phtml" hash="1fb213f3fcc3aeecaa6305c07cff3b73"/></dir></dir><file name="register.phtml" hash="0a232ba7493098b49da82c88c646cc87"/><file name="seller_central.phtml" hash="fa3012b0191ac7175bc6bb68188f654c"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="amazonpayments.xml" hash="5b41cce3d289b987f05e09433c7ffb85"/></dir><dir name="template"><dir name="creativestyle"><dir name="amazonpayments"><dir name="button"><file name="js.phtml" hash="a108a88af0112fd43123a1b37cfc106b"/></dir><dir name="checkout"><file name="capture_notice.phtml" hash="f9c75cd05a596d0a16c55f0169b4ee6c"/><file name="js.phtml" hash="a47a9b7f24f1f0a2f1f91b802801b194"/><dir name="review"><file name="button.phtml" hash="5fa9b038cc1e91a8203b163411b8bf20"/><file name="coupon.phtml" hash="e7b47c2fdd6a1d38a39fa8c292ad793b"/></dir><file name="sandbox_toolbox.phtml" hash="b1a346f095d83223914e65024f56d19f"/><file name="shipping_method.phtml" hash="852008f89fc32c7af6c250cafdde5f51"/></dir><file name="checkout.phtml" hash="93574891397c9d3cd95272f918f512bd"/><dir name="customer"><dir name="account"><dir name="dashboard"><file name="login.phtml" hash="0eafc3c58b54c194c07a779afcde403e"/></dir></dir></dir><file name="js.phtml" hash="13581f0bcdf7c39da46be530892e8183"/><dir name="login"><dir name="button"><file name="account_login.phtml" hash="d7dc275051ab1973b74cd4b5c4b589d8"/></dir><file name="button.phtml" hash="b5d66280337ecc895ae9a2bc48c469e4"/><dir name="form"><file name="account_confirm.phtml" hash="35adec8936cc612b865bca61e2316a8b"/><file name="account_update.phtml" hash="64fdc50df3b3c49384d5d50a1da82d4d"/></dir><file name="js.phtml" hash="9d542e726fe51739b72fc2e509edadd8"/><file name="logout.phtml" hash="e8b6f4d39047903e4ee8d481ba59543b"/><file name="redirect.phtml" hash="8d395ab25504c0cdb928cf93e684b868"/></dir><dir name="onepage"><file name="button.phtml" hash="199ae967a31b7d92b0a2279e339bb938"/></dir><dir name="pay"><file name="button.phtml" hash="dfcccab45794c81d2d3ca52f709019d4"/></dir><dir name="payment"><file name="info.phtml" hash="3631896707e596d9675f526a7d021617"/><dir name="legacy"><file name="info.phtml" hash="7d35f0a93900f40fb4433f576734595a"/><dir name="pdf"><file name="info.phtml" hash="738d0b82322b1df3c315daf5253e001e"/></dir></dir><dir name="pdf"><file name="info.phtml" hash="69549bf3340c19d62f42a556f13e8a1e"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Creativestyle_AmazonPayments.xml" hash="3d30f68b24829494a2a66164eba0e5f7"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Creativestyle_AmazonPayments.csv" hash="c296f98874a5ff2f38a4d6f96359a015"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="863d241bc23599124715c1e797a3cae6"/></dir></dir></dir><dir name="en_GB"><file name="Creativestyle_AmazonPayments.csv" hash="3afdd699a914e9a99317edf97addb18d"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="f858886b12b6f3e16cab85f5ce57b975"/></dir></dir></dir><dir name="en_US"><file name="Creativestyle_AmazonPayments.csv" hash="1ab4e3faab0979a910408f66c0ca95c2"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="702e0a9ada30a5bb5776b28fe63eda93"/></dir></dir></dir><dir name="es_ES"><file name="Creativestyle_AmazonPayments.csv" hash="00213f40cd3a3d46f8e643e14d0322ef"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="e1705a091d04cd4da4d0b0cc49bd283f"/></dir></dir></dir><dir name="fr_FR"><file name="Creativestyle_AmazonPayments.csv" hash="a2ccef1fbee52c1dbb2c0e8f174bcd02"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="e593f24125ecb3ffacbe467d8f39f2de"/></dir></dir></dir><dir name="it_IT"><file name="Creativestyle_AmazonPayments.csv" hash="2ab40220504d9113445a57b5c3ba5b8a"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="5c3857cb5465c91415940689eec8dc75"/></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="creativestyle"><file name="apa_checkout.js" hash="090d3f9984ec92992c950fb65b0d7953"/><file name="apa_checkout.min.js" hash="1b1887cfa66cda473f1e2600cb1d2c42"/><file name="apa_sandbox_toolbox.min.js" hash="caaeb27b79fb6a26561d5e4bd6a4d851"/><dir name="vendors"><file name="prism.js" hash="c700de3d980f7ef1e056dc5400acfd44"/></dir><dir name="adminhtml"><file name="amazonpayments.min.js" hash="417f5ac42d57cdd42ed3d7005dcbd6a2"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="creativestyle"><dir name="css"><file name="amazonpayments.css" hash="db97912a183d743b89a5bdfc16a66e71"/><file name="amazonpayments-highlight.css" hash="f6daf03c989ac56ad436300b5520f0df"/></dir><dir name="images"><file name="amazon-payments-advanced-creativestyle-header-logo.png" hash="8591e03aeaa7cbc71a509443de35bfce"/><file name="amazon-payments-advanced-creativestyle-header-logo-white.png" hash="9552112bc27581249cb8e8de1bb91887"/><file name="amazon-payments-advanced-creativestyle-logo.png" hash="abc54550ae7d7a3e5c8a5cd0896d310d"/><file name="amazon-payments-advanced-header.png" hash="a94ab7de3238be5949eec5139e401615"/><file name="amazon-payments-advanced-section.png" hash="8c137a5960eb6938358644259bf23646"/><file name="logo_a-glyph_16.png" hash="44a3f5f0013cab34d26653eb48b989fc"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="creativestyle"><dir name="css"><file name="amazonpayments.css" hash="a6aa4506d316e7303eb33fb4d65bd471"/><file name="amazonpayments-responsive-widgets.css" hash="ffca5cdc8a4e0585946c78258044c471"/><file name="amazonpayments-widgets.css" hash="35704192aaeb204e407e8b853c118d16"/></dir><dir name="images"><file name="amazon-loading-large.gif" hash="5f6d83bf2b69ab73c7e48ec9b66d54db"/><file name="logo_a-glyph_1x.png" hash="5d44ca86985afbb2a47b9265053a456e"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="creativestyle"><dir name="css"><file name="amazonpayments-responsive-widgets.css" hash="389d23ee96bb5305f7ba5b616d930846"/><file name="amazonpayments.css" hash="ac8dee6f92fb5ebafaea7f53b730ca57"/></dir><dir name="images"><file name="amazon-loading-large.gif" hash="5f6d83bf2b69ab73c7e48ec9b66d54db"/><file name="logo_a-glyph_1x.png" hash="5d44ca86985afbb2a47b9265053a456e"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Creativestyle"><dir name="AmazonPayments"><dir name="Block"><file name="Abstract.php" hash="1518541acdae0c74473a2f57088165d2"/><dir name="Adminhtml"><dir name="Debug"><dir name="Section"><file name="Table.php" hash="f6947e99e982164a220e3d82fa0f988f"/></dir><file name="Section.php" hash="a249d2fedeaa5e485e40ffaeeb0335c6"/></dir><file name="Debug.php" hash="51fdd651a5a672c75e645fc5974fae95"/><file name="Info.php" hash="5e948aaea093307b3a2d9483e116934f"/><dir name="Log"><file name="Abstract.php" hash="183114e38269e6ad666840127cfe0311"/><dir name="Api"><file name="Grid.php" hash="1f3ab2ee3c884a080babe33d092c97e4"/><file name="View.php" hash="6cfb2d5ac1777a146e9bca3b09e31fc8"/></dir><file name="Api.php" hash="6725b51b926550d4731835245095f9ec"/><dir name="Exception"><file name="Grid.php" hash="e12982b34793ad34c3eb0b24bac9dc1d"/><file name="View.php" hash="f24fa8a264a13ab1f29ada77624bfc09"/></dir><file name="Exception.php" hash="d3ea2ff8dac95796fdb01b0284ccc90a"/><dir name="Grid"><file name="Abstract.php" hash="11ccd78d87834bd73398358f190ef9bd"/></dir><dir name="Ipn"><file name="Grid.php" hash="8efa9f6b1adcac9a3562979ac97bc0c5"/><file name="View.php" hash="6ab63414642658e95258a73a143e6955"/></dir><file name="Ipn.php" hash="a2225b081ccb354bfe94b4a646b0d521"/><dir name="View"><file name="Abstract.php" hash="1b9423b817bc1c0765601d73b78d0d8e"/></dir></dir><file name="Notifications.php" hash="de983b6f26e73bc5ac71b6a979d1125e"/><file name="Register.php" hash="18f5eeb19dee4926183f17e3dc5b6b88"/><dir name="Renderer"><file name="Timestamp.php" hash="190325613c20e2cf97adc28950658e99"/></dir><dir name="Sales"><file name="Order.php" hash="45a5ee919501a2bf26160d38dafccd44"/></dir><file name="SellerCentral.php" hash="2a70da712e0010b76d7f166a010f511d"/></dir><dir name="Button"><file name="Js.php" hash="6081c66a769b6db8a7f607e6f60365af"/></dir><dir name="Checkout"><file name="Abstract.php" hash="db5cf0b3d9dd37ad4552987b9df5e09c"/><file name="Js.php" hash="0e5ba9b3f4ae06139a084816c04a05a3"/><file name="Notice.php" hash="3bd2869322fac80a80436f8e2daa8d70"/><file name="SandboxToolbox.php" hash="047b1bfde3f5469195b9a7ccfee3f16d"/></dir><file name="Checkout.php" hash="6620fc17c1c86deac47709664d6a93f7"/><dir name="Customer"><dir name="Account"><dir name="Dashboard"><file name="Login.php" hash="0a8a23d61e5ea2029cc3c504e8f65d7d"/></dir></dir></dir><dir name="Js"><file name="Interface.php" hash="11827746ff821b4cbda1ad041e30321e"/></dir><file name="Js.php" hash="f5c8f0cf7d13387387ad4b2656e8d9a9"/><dir name="Login"><file name="Abstract.php" hash="d260896597dc717bd82bf2d76374a9e4"/><dir name="Account"><file name="Confirm.php" hash="ae8123a65a717a0046aaf1d9dc21f878"/><file name="Update.php" hash="8fdadae9294b17fbb0989f8d0e2016a4"/></dir><file name="Button.php" hash="bad55de20f480d53a15ddedd551ff6dd"/><file name="Js.php" hash="2d144b27681c48f2adfa8cd0fdd5d31e"/><file name="Redirect.php" hash="8634cf4f6bf792006e4ab7674b758e5c"/></dir><dir name="Onepage"><file name="Button.php" hash="9b75d05f91d17a507544fdda247eb1a7"/></dir><dir name="Pay"><file name="Abstract.php" hash="7df3aa69d74f5d11b47e9508c628ca5d"/><file name="Button.php" hash="b76cbc47c91b88ceb9fc1fde609fa2dc"/></dir><dir name="Payment"><file name="Info.php" hash="c6285a5688834b456765317d3471bf2a"/><dir name="Legacy"><file name="Info.php" hash="6d4b1d32a19c80c42bf3acccd1963ba5"/></dir></dir></dir><dir name="Exception"><dir name="InvalidStatus"><file name="Recoverable.php" hash="dc4d8857cf1841bb56f6da11cf92e99e"/><file name="Unrecoverable.php" hash="53a377c09d7c41368adf597e0173e513"/></dir><file name="InvalidStatus.php" hash="614d45747601dea035ff2a3faadd7e18"/></dir><file name="Exception.php" hash="ca655a29842b38dd2ebf438208a6c70c"/><dir name="Helper"><file name="Data.php" hash="a0282202539953a047cb17316def6b28"/><file name="Debug.php" hash="3c9fead1b33537ae7d5a4d15fb799dff"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="1814fcd0d61599f15d808d9c2990ebe4"/><file name="Advanced.php" hash="0f5a3f480da20a2f8253f9b78c78f9dd"/><file name="Ipn.php" hash="e672342ca8b1f1f7493e42b9656aeabe"/><file name="Login.php" hash="d9297e66749c6930a1010a5babdfde14"/></dir><file name="Checkout.php" hash="8b80a8ae2a4b2cf595cabded2f5c3c2a"/><file name="Config.php" hash="e242b57817426a77c0f146657ab5374e"/><dir name="Log"><file name="Collection.php" hash="13d71847c4e164af18636a3fe5bf975b"/></dir><file name="Logger.php" hash="181e90628ee324547ed79cd4fb71b58c"/><dir name="Lookup"><file name="Abstract.php" hash="443bbef12f4e7c896e54cf0b7463e04e"/><file name="AccountRegion.php" hash="7be22d7cab69151e409ea7ec7df7fadc"/><file name="Authentication.php" hash="af62e3961a5b00319aa32487c6cc20d6"/><file name="AuthorizationMode.php" hash="b26806dc71de6b55bc37b20a1b804364"/><dir name="Design"><dir name="Button"><dir name="Color"><file name="LoginPay.php" hash="e9a469e82c7805782cf7694c4d50af7a"/></dir><file name="Color.php" hash="81a33471dfefb27897f7b1ff19749671"/><dir name="Size"><file name="LoginPay.php" hash="6cdf3d3633617994783a38f30add86fe"/></dir><file name="Size.php" hash="7c73a97a0fa3f4c6a73b838c0594ad5c"/><dir name="Type"><file name="Login.php" hash="44e852189b0305bbe4cc38848316d4e6"/><file name="Pay.php" hash="8e85dde5088b02f966a35c9b0a053de5"/></dir></dir></dir><file name="Frequency.php" hash="5115fb39b48781e5e97f9b62414a72cc"/><file name="IpnActive.php" hash="b73000f5bfc1e26b80911e125e9eec46"/><file name="Language.php" hash="4a9b8e24251cb3e80e9e22395b947cac"/><file name="PaymentAction.php" hash="6d0c15996ec3caf112d88e07ea703bb4"/><file name="Region.php" hash="8f5cc8ab970aa165e16085368b320f89"/></dir><file name="Observer.php" hash="0316aeff3e7c6bb028d35b6b76a6c494"/><dir name="Payment"><file name="Abstract.php" hash="3c4487ec8b65ce94a7b81b7f6079c60d"/><dir name="Advanced"><file name="Sandbox.php" hash="10e80bd587f2d27fc97bb6e595936b82"/></dir><file name="Advanced.php" hash="15c5dde1d3a82a9bdf01e1681c47ec3b"/><file name="Legacy.php" hash="654ba0aa8692416ca2721f2ebb59a883"/></dir><dir name="Processor"><file name="Ipn.php" hash="e7d757a60ea7e3481cfe3ba3466af1cc"/><file name="Order.php" hash="bea0a609138e58614fe8fdb11426bf40"/><file name="Payment.php" hash="05d099c2b8bf6dcc67ef6ea037c6594c"/><file name="TransactionAdapter.php" hash="8566292e6e7ac85471ac12f2bd155ab8"/></dir><dir name="Service"><file name="Login.php" hash="668216c8e815a4490d0c2d7ba0c6a3dc"/><file name="Quote.php" hash="d566370281e690ca31f3ddd47c21ef1d"/></dir><file name="Setup.php" hash="41f37f025dc543f63d2dccd28f41e255"/><file name="Simulator.php" hash="553bb0c0ca3c74202083b366f4c33e9a"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="DataPolling"><file name="Cron.php" hash="8beaac61d4ebfb4ac74335f5ff121ce0"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Amazonpayments"><file name="DebugController.php" hash="aedfdbe70c652afe31439b991f912e2c"/><dir name="Log"><file name="ApiController.php" hash="9a8e3361c754eec9d78d3aa62411a47b"/><file name="ExceptionController.php" hash="c5bd239ce59de35dc064cc1474d5a005"/><file name="IpnController.php" hash="6e67da69a85eba85f3c44470fab6c5b9"/></dir><file name="OrderController.php" hash="83ffbf0de858765c0c9c7c594e9b2b66"/><file name="SystemController.php" hash="516e0ec1c7cc978a087ec4b7e3d91e44"/></dir></dir><dir name="Advanced"><file name="CheckoutController.php" hash="58172a934438d67d402b6f6fb3cb7662"/><file name="IpnController.php" hash="918297ba173a73e7be05aae9a4fef0c9"/><file name="LoginController.php" hash="9d0004a3684163feeefbc9f3672300d2"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="cd249bbc1deefba11366dba61ed2386c"/><file name="config.xml" hash="0490c0c377061012f3f10b10204ccdc2"/><file name="system.xml" hash="5eed5c0724b7c889676e62fb639fde12"/></dir><dir name="sql"><dir name="amazonpayments_setup"><file name="mysql4-install-1.0.0.php" hash="d4681b9a39905cc9e9dcc660688dea85"/><file name="mysql4-install-1.6.2.php" hash="6bb2b8656a3c6b2b517b88ca98ff84de"/><file name="mysql4-upgrade-1.1.6-1.2.0.php" hash="27f8e108bac4268d3c17e812b413dbbc"/><file name="mysql4-upgrade-1.7.4-1.7.6.php" hash="cbe499399eac3dcf607dd42e9be239a1"/><file name="mysql4-upgrade-1.7.8-1.8.2.php" hash="7f858b1140aff7a4bf36545c72d0c0fe"/></dir></dir></dir></dir></target><target name="magelib"><dir name="OffAmazonPayments"><dir name="HttpRequest"><file name="HttpException.php" hash="d2feba35467baa6ff61503bb15d5f016"/><file name="IHttpRequest.php" hash="7c7d44deffb15b2db161d8dfc585c4d2"/><file name="IHttpRequestFactory.php" hash="02c9cfe067cd0ae40f14704d58fa2098"/><dir name="Impl"><file name="HttpRequestCurlImpl.php" hash="815a03cc4b5fc1222e0bc9b9f85f3428"/><file name="HttpRequestFactoryCurlImpl.php" hash="09140d0c9518e0e7c1bffb8bd0c98310"/></dir></dir><file name="Model.php" hash="778dfe809587f010352d9ccd2bed8106"/><file name="OffAmazonPaymentsServiceUtils.php" hash="827a9e9f2b04652736406b1cd9672a2c"/></dir><dir name="OffAmazonPaymentsNotifications"><file name="Client.php" hash="a8bfa462188eb5193985e984ff503b04"/><dir name="Impl"><file name="Certificate.php" hash="33aec53879fff368b0f6f52ce7f79f13"/><file name="IpnNotificationParser.php" hash="3f4e203c89d23c2971214a7e0713f6a9"/><file name="Message.php" hash="6cffc2f4b4c09a8411572cdb7ddcc83a"/><file name="OpenSslVerifySignature.php" hash="45449e157fa55ab5c2c16a9207616357"/><file name="SnsMessageParser.php" hash="c6d1b0bfa852441b4ddfdc25cf624c9d"/><file name="SnsMessageValidator.php" hash="7291f2b91f0dc9ace62752c37b69d15f"/><file name="VerifySignature.php" hash="b7c3089f35fba596e16f6f39f7029908"/><file name="XmlNotificationParser.php" hash="a6b6ff48de5cee20db383a2a6c953092"/></dir><file name="Interface.php" hash="3930f956058657059e2ea705fc43333d"/><file name="InvalidCertificateException.php" hash="4711c0ea7b574a8ab3fb04623b2f7453"/><file name="InvalidMessageException.php" hash="c9608c6ecfafeae2db9db9e8786f2a15"/><dir name="Model"><file name="AuthorizationDetails.php" hash="c5e85494dd4b21c49c1d786bf38879da"/><file name="AuthorizationNotification.php" hash="490fd1da11270f9af20a6ca0d87b8149"/><file name="BillingAgreement.php" hash="00f24d00547ddb3320a20f77132feb0e"/><file name="BillingAgreementLimits.php" hash="e972154534547bde777133c2de1e835f"/><file name="BillingAgreementNotification.php" hash="c5ee60508326e840ce02765b175897aa"/><file name="BillingAgreementStatus.php" hash="68da18941f6cc8b17a9157c83e550c0c"/><file name="CaptureDetails.php" hash="f8702f3d5d5afd595814182f847367c5"/><file name="CaptureNotification.php" hash="8d4da47b23888f3cfd94fe9d217c46da"/><file name="IdList.php" hash="4d77007c611ba2a990179ecf506d4ac7"/><file name="IpnNotificationMetadata.php" hash="802e724b1cc35eae31e4aa9288446b8f"/><file name="MerchantRegistrationDetails.php" hash="d4de7689d8e216567abd710dde7ef4ed"/><file name="NotificationImpl.php" hash="17205cb366af769c0563d80ee82de067"/><file name="NotificationMetadataImpl.php" hash="27bdabd2ae04ab753e60b0ab3042859c"/><file name="OrderItemCategories.php" hash="ac5edd66a87e28f1e0a4be758e3d7b8c"/><file name="OrderReference.php" hash="3ff8f8729cc3e398823061b73d8d2789"/><file name="OrderReferenceNotification.php" hash="4b6a0e68f77ff7b710fe00916d5b0546"/><file name="OrderReferenceStatus.php" hash="e09fc390fb5c21afd4764c41dd7418c0"/><file name="OrderTotal.php" hash="ce3157db8b593588c9405030968176a5"/><file name="Price.php" hash="cff064218bbb2d56f463ab489dc907cd"/><file name="ProviderCreditDetails.php" hash="d355185842eb0816de151fb535b14edc"/><file name="ProviderCreditNotification.php" hash="7ddc5d80dee797893171237ecabf10e2"/><file name="ProviderCreditReversalDetails.php" hash="a789bbf3c7074bc800053967e64286c7"/><file name="ProviderCreditReversalNotification.php" hash="56479587ee330013bdffe17719d0edec"/><file name="ProviderCreditReversalSummary.php" hash="577971d363b95fd7a73e8cd4995a240c"/><file name="ProviderCreditReversalSummaryList.php" hash="05ae0f9769e4c46e5c3ba3f9907ae576"/><file name="ProviderCreditSummary.php" hash="4403e12b73867b58021655df3fcf6720"/><file name="ProviderCreditSummaryList.php" hash="667167ed6a427d71086aa4ef8dabc5f5"/><file name="RefundDetails.php" hash="ae08c0447ec12996a465772d55f2c28f"/><file name="RefundNotification.php" hash="fb29285214205fd09c4f9ac7964c1a07"/><file name="SellerBillingAgreementAttributes.php" hash="691b120995ac30f3f542c3ec9cd6c0d6"/><file name="SellerOrderAttributes.php" hash="896cf700231529f39e903d4614579a85"/><file name="SnsNotificationMetadata.php" hash="df453726f714f7ea50cc04b6093123eb"/><file name="SolutionProviderMerchantNotification.php" hash="77e4152a922f1a26582e46546387943d"/><file name="SolutionProviderOption.php" hash="df8fbbb1ad2fef1796e3b42a9a417a64"/><file name="SolutionProviderOptions.php" hash="624d2f4efd3a32eab8baf8628efda4ef"/><file name="Status.php" hash="8726fde00e0f97595115866c1a8000dd"/></dir><file name="Notification.php" hash="562b2a4eb6e292b6df4db3112391ab55"/><file name="NotificationMetadata.php" hash="07f94bf3a41ed0c72f387e900260c48a"/></dir><dir name="OffAmazonPaymentsService"><file name="Client.php" hash="26dd6a2d2c407427c5ea0933e2159351"/><file name="Environments.php" hash="1a9ff744e131c19f5bd0d58c5aa578ab"/><file name="Exception.php" hash="eee23053020a397cf082a28f41001284"/><file name="Interface.php" hash="b681a546f2a5e3690e5e04f9c75ca8a5"/><file name="MerchantValues.php" hash="2cca67c2b1b0557e5a63d4ef35950172"/><file name="MerchantValuesBuilder.php" hash="a6328566f8f5ee48a8b054d8f02897e1"/><dir name="Model"><file name="Address.php" hash="6840237ae7035912f95020ff6d580033"/><file name="AuthorizationDetails.php" hash="159edfb213e12b7ecb847c103c70c5de"/><file name="AuthorizeOnBillingAgreementRequest.php" hash="8b0e8d6ffa94b1f18546b7554ec042ed"/><file name="AuthorizeOnBillingAgreementResponse.php" hash="8770715da01743adeafc25d54bb0c1d9"/><file name="AuthorizeOnBillingAgreementResult.php" hash="a73c77f8fce673257e2dca072ad6fab6"/><file name="AuthorizeRequest.php" hash="08bdab4fe2896f4a2b808c6e8abfeeba"/><file name="AuthorizeResponse.php" hash="0ae054040c36e7362683146b537f551b"/><file name="AuthorizeResult.php" hash="e7dfd388200467e736ff3b7d11c8d2bf"/><file name="BillingAddress.php" hash="93f82f074b62e8b1abf25ae8ae44b676"/><file name="BillingAgreementAttributes.php" hash="e52a2c92f92f7081ac742e24f70385df"/><file name="BillingAgreementDetails.php" hash="359f9bd686d21242f2e27feb8b3379b2"/><file name="BillingAgreementLimits.php" hash="66f84e67052b91092867496d11a28763"/><file name="BillingAgreementStatus.php" hash="adcf9379fb2f6fa88a1d8e230d8cf101"/><file name="Buyer.php" hash="cb691abf757d54025ac43964849dd5fd"/><file name="CancelOrderReferenceRequest.php" hash="ef06ecd8f05a4c032aa28f5b5a132d05"/><file name="CancelOrderReferenceResponse.php" hash="004c4e3a21ea1dc8e11bbba3d733b3ca"/><file name="CancelOrderReferenceResult.php" hash="74b7ad1facdf31263e9bb55544303180"/><file name="CaptureDetails.php" hash="4f360221d888d50d92e7f2ea20b5b54f"/><file name="CaptureRequest.php" hash="5b976a76214f870964d49cf104a50b30"/><file name="CaptureResponse.php" hash="7ece74f93f362d31bc16f9fb7bf2b270"/><file name="CaptureResult.php" hash="e0fccf0fe27efd36d822ddcdaefe97ac"/><file name="CloseAuthorizationRequest.php" hash="cb0e2113e9e36b7b133b539e5ff99c50"/><file name="CloseAuthorizationResponse.php" hash="99be7612c9effdac53fb0bc225a13eb1"/><file name="CloseAuthorizationResult.php" hash="6d77eea8924d2ef6a3acd0dabb3f9f76"/><file name="CloseBillingAgreementRequest.php" hash="89f82b30dd0902faa6feb3a57dfe24cb"/><file name="CloseBillingAgreementResponse.php" hash="1bda191dc9a8b2b1a14b6e11772f05cf"/><file name="CloseBillingAgreementResult.php" hash="f926f5d65d95323647129605a26037ae"/><file name="CloseOrderReferenceRequest.php" hash="b8b592bdc71a4046efead52196f8073c"/><file name="CloseOrderReferenceResponse.php" hash="137da00395052b25099de3a0d152887d"/><file name="CloseOrderReferenceResult.php" hash="81e21f75ae477f07a9b913e1ac2bd89d"/><file name="ConfirmBillingAgreementRequest.php" hash="ab524aa1cc6e51a8b483e4f96b7e1e02"/><file name="ConfirmBillingAgreementResponse.php" hash="0639de39ba58e6c2b806a84b43dc31d3"/><file name="ConfirmBillingAgreementResult.php" hash="42456915a3efa4ccd774a1d5d3a05307"/><file name="ConfirmOrderReferenceRequest.php" hash="632a4b8414aac550fc0ec59a83737be7"/><file name="ConfirmOrderReferenceResponse.php" hash="fb0c329ffa1a54e4c15c531b58561f6f"/><file name="Constraint.php" hash="e46dc3d18486b6639ea5b8f52a92cfdc"/><file name="Constraints.php" hash="cb983d71bda42bdda767ffc9f4feeafc"/><file name="CreateOrderReferenceForIdRequest.php" hash="b1f4e96f1392c427228f5799edc5dc64"/><file name="CreateOrderReferenceForIdResponse.php" hash="630cb4812997fa7c067f393dfb5e2f48"/><file name="CreateOrderReferenceForIdResult.php" hash="4abf7af5eb56058c17996406a877f427"/><file name="Destination.php" hash="737777909588915788398ab86f0de1de"/><file name="Error.php" hash="bb8b6bb6d3c778fc4e1d0a346b5fa03a"/><file name="ErrorResponse.php" hash="8804c6f39d9a0bdcbd76260eba9d261d"/><file name="GetAuthorizationDetailsRequest.php" hash="67d5a478c01fbbfba420dff3cf2098dc"/><file name="GetAuthorizationDetailsResponse.php" hash="0c9fe935bcb953cc9cd9e11bab32b5b2"/><file name="GetAuthorizationDetailsResult.php" hash="02ac4fa6533ccfd705c543160165c31d"/><file name="GetBillingAgreementDetailsRequest.php" hash="761cbdc44a4ac1e28b22d01f7a484b76"/><file name="GetBillingAgreementDetailsResponse.php" hash="061084469683253d1d76d5c881e5062d"/><file name="GetBillingAgreementDetailsResult.php" hash="5a585ad373b11b806ba320bcd988f71b"/><file name="GetCaptureDetailsRequest.php" hash="69252be80c32d911f2ff664904375e7d"/><file name="GetCaptureDetailsResponse.php" hash="5323ed86174064bb1122187457440861"/><file name="GetCaptureDetailsResult.php" hash="962ef27de2778c9ccde55d848b8fa649"/><file name="GetOrderReferenceDetailsRequest.php" hash="edfea06a629f298ab134229d35fef319"/><file name="GetOrderReferenceDetailsResponse.php" hash="4955733fe736a9f51e0bd6823b8bf74b"/><file name="GetOrderReferenceDetailsResult.php" hash="f9ee3738bddff51c6bd545028d275348"/><file name="GetProviderCreditDetailsRequest.php" hash="e51201c7d39935c4fa8da96e822b7075"/><file name="GetProviderCreditDetailsResponse.php" hash="e312b54192343e16230b7436b101766a"/><file name="GetProviderCreditDetailsResult.php" hash="9f0af601e8a716e4e5af3802d8952fe4"/><file name="GetProviderCreditReversalDetailsRequest.php" hash="cf74576ef8dc02e34244aca962d854b3"/><file name="GetProviderCreditReversalDetailsResponse.php" hash="a869c2695416514834c83890d3b080f9"/><file name="GetProviderCreditReversalDetailsResult.php" hash="33f1980d1632034eee8396c6286b5320"/><file name="GetRefundDetailsRequest.php" hash="7ab0f7d756a59a284ffd0ffc361fee42"/><file name="GetRefundDetailsResponse.php" hash="4847a7513f69d3f81c306d26ad7c5291"/><file name="GetRefundDetailsResult.php" hash="0c24e3c8e95f4ee10f5c4e9dd07518bf"/><file name="IdList.php" hash="25fd15394669b4721bdd0e4d367d534f"/><file name="OrderItemCategories.php" hash="995db32a92601555ee9a7550d1daae7e"/><file name="OrderReferenceAttributes.php" hash="78e1735d8fc99c5676d894564d6b88c7"/><file name="OrderReferenceDetails.php" hash="4e9365808e09fe1b1407348c9d05ca41"/><file name="OrderReferenceStatus.php" hash="5c21e44d991a24ab2527e491c435d54c"/><file name="OrderTotal.php" hash="2ff8e8ccc9c7266d72f534485ccd01bf"/><file name="ParentDetails.php" hash="99f7062b4764166637dfc44b4fe4788c"/><file name="Price.php" hash="4ac8de3791146a17a237a914c9f762a6"/><file name="ProviderCredit.php" hash="8f2f21ac5c0dba73e64a35cc7a61fbbe"/><file name="ProviderCreditDetails.php" hash="d9057efbe528a1571eda4252b8ad1813"/><file name="ProviderCreditList.php" hash="4a3eeae90b5a1ed09a528f5254b968a5"/><file name="ProviderCreditReversal.php" hash="07c1d7959a7cfb94164846c276b43ce7"/><file name="ProviderCreditReversalDetails.php" hash="ebfbf919b4a399213c7e312e59873e43"/><file name="ProviderCreditReversalList.php" hash="8eb64497a6a233535c8b0ca55591d06b"/><file name="ProviderCreditReversalSummary.php" hash="7646c582ea5fb3a46dcb09637f7daf01"/><file name="ProviderCreditReversalSummaryList.php" hash="cae281ddee9f766d1d5bf350e238037a"/><file name="ProviderCreditSummary.php" hash="69bc18eefe644e6b851a6daf7e6dfa8a"/><file name="ProviderCreditSummaryList.php" hash="751812d8903ba883036d1bc381c37667"/><file name="RefundDetails.php" hash="b53e480fe8e8e5d96a4b6a0df431e5ac"/><file name="RefundRequest.php" hash="665585551aba39532fe3352abb4859b3"/><file name="RefundResponse.php" hash="fadbc4ad5313395a48e38b1c0502c85a"/><file name="RefundResult.php" hash="9ddad34dd53edfd156651b021bc5137a"/><file name="ResponseHeaderMetadata.php" hash="382fe7bd666eea293b729c5d6c79348f"/><file name="ResponseMetadata.php" hash="073748a20ecd8bddc240dd4c0a4a56b9"/><file name="ReverseProviderCreditRequest.php" hash="802a3709149add8fa192ce389b93c2ea"/><file name="ReverseProviderCreditResponse.php" hash="ff702a7def546f0c6216094f93095bd7"/><file name="ReverseProviderCreditResult.php" hash="84f3e78e1b8b1b47e6f8b92abee7704b"/><file name="SellerBillingAgreementAttributes.php" hash="308899b9e48a95f0b5d48d74a510c915"/><file name="SellerOrderAttributes.php" hash="35b62fe0e130207dfaa2caefa1dfe7ba"/><file name="SetBillingAgreementDetailsRequest.php" hash="347a6c85c5cc8394255efcb9c4b57d52"/><file name="SetBillingAgreementDetailsResponse.php" hash="92299b3338dc7435149f17d8126f7518"/><file name="SetBillingAgreementDetailsResult.php" hash="7cb3e84e58fe2bbf163f8ac34de5eccf"/><file name="SetOrderReferenceDetailsRequest.php" hash="4cf2605f5188116a1526d463638aa768"/><file name="SetOrderReferenceDetailsResponse.php" hash="41720bdf965dcd759cc3278e01610530"/><file name="SetOrderReferenceDetailsResult.php" hash="4281a97da7865e47157c1d22c2094bfd"/><file name="Status.php" hash="28bd007e6c9747417a063e9941cc0dba"/><file name="ValidateBillingAgreementRequest.php" hash="d77beda441fd1688903e96a02fa4e643"/><file name="ValidateBillingAgreementResponse.php" hash="89658fd2a78d7dbb2997dae6ba169f7e"/><file name="ValidateBillingAgreementResult.php" hash="b9244d0496b0bbcfbf7628c775c17ca3"/></dir><file name="Model.php" hash="fafcb3a4318eb7bd9be5b69225187352"/><file name="RegionSpecificProperties.php" hash="f4e77cc63766b42fbef6ef1e07ec4402"/><file name="Regions.php" hash="4676d77db7dde345118e2a6fc021ce3f"/></dir></target></contents>
|
24 |
<compatible/>
|
25 |
<dependencies><required><php><min>5.2.0</min><max>8.0.0</max></php></required></dependencies>
|
26 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Creativestyle_AmazonPayments</name>
|
4 |
+
<version>2.0.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>Creative Commons Attribution-NoDerivatives 4.0 International</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Integration of your Magento shop with Login and Pay with Amazon service</summary>
|
10 |
<description>This extension provides an official integration of your Magento store with Login and Pay with Amazon service. It helps your customers shop quickly, safely and securely. Your customers can pay on your website without re-entering their payment and address details. All Amazon transactions are protected by Amazon's A-to-z Guarantee.</description>
|
11 |
+
<notes># Major Highlights
|
12 |
+
- Implemented omni-chronous authorization
|
|
|
13 |
# Changes
|
14 |
+
- Refactored order post-processing
|
15 |
+
- Changed IPN endpoint URL
|
16 |
+
- Changed frontend layout and templates (no backward compatibility)
|
17 |
+
- Simplified frontend JS application
|
18 |
</notes>
|
19 |
<authors><author><name>creativestyle GmbH</name><user>creativestyle</user><email>amazon@creativestyle.de</email></author></authors>
|
20 |
+
<date>2017-09-12</date>
|
21 |
+
<time>11:53:56</time>
|
22 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="amazonpayments.xml" hash="08f9c3c3cdd9536c28746bb3be7eeb0c"/></dir><dir name="template"><dir name="creativestyle"><dir name="amazonpayments"><dir name="advanced"><file name="documentation.phtml" hash="af3ae6ebce4712dd8fb972bef508ca55"/><dir name="log"><dir name="api"><file name="view.phtml" hash="2c2fcd6122b4481ad2cf8b7657f3f187"/></dir><dir name="exception"><file name="view.phtml" hash="c5d01f6de86e47d4da5dfabd60b1b382"/></dir><dir name="ipn"><file name="view.phtml" hash="d1ee2da648f50b1d793748065646df67"/></dir><file name="js.phtml" hash="eb1d2098440a0bac2a6f5b959afa3693"/></dir></dir><dir name="debug"><dir name="section"><file name="table.phtml" hash="f4bb8e35b3608cf0639407a3461c3717"/></dir><file name="section.phtml" hash="1472da0e9f07b5583a02e327483d4d75"/></dir><file name="debug.phtml" hash="9748d4fe92986f36ad47ae5b61fc4883"/><file name="info.phtml" hash="c3748d44ad12514e379393e3722c7b82"/><file name="init.phtml" hash="ba9d53045077e63b4e6c25c6b7bb685c"/><file name="notifications.phtml" hash="2bdcecbebc9b0df6d00ad5c49c464e2d"/><dir name="payment"><file name="info.phtml" hash="1604a1ca8c640748023859dee07f1182"/><dir name="legacy"><file name="info.phtml" hash="7d35f0a93900f40fb4433f576734595a"/><dir name="pdf"><file name="info.phtml" hash="73e54dbec4a659063a6e6c3b35565159"/></dir></dir><dir name="pdf"><file name="info.phtml" hash="1fb213f3fcc3aeecaa6305c07cff3b73"/></dir></dir><file name="register.phtml" hash="0a232ba7493098b49da82c88c646cc87"/><file name="seller_central.phtml" hash="fa3012b0191ac7175bc6bb68188f654c"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="amazonpayments.xml" hash="c1697a0e0a3f3ccbae47ad70013fa79a"/></dir><dir name="template"><dir name="creativestyle"><dir name="amazonpayments"><dir name="checkout"><file name="capture_notice.phtml" hash="c26167453dd620f4cc40c4d2edce9357"/><dir name="review"><file name="button.phtml" hash="a431ed7de5f3aa866e53c2059aeda84f"/><file name="coupon.phtml" hash="79e144d77baefeec48e3a6e2715f0e18"/></dir><file name="sandbox_toolbox.phtml" hash="ce976dbb5ac0bc5eda70412178feb1d6"/><file name="shipping_method.phtml" hash="5a3f6d62a844b9752a128754da3a3407"/></dir><file name="checkout.phtml" hash="c4227d5ddf0f5b236801e7fcb18e8a2d"/><dir name="customer"><dir name="account"><dir name="dashboard"><file name="login.phtml" hash="f0bf615e649e69a5ff7068db05a2be11"/></dir></dir></dir><file name="js.phtml" hash="501906b9ba691064897e8427761fc641"/><dir name="login"><dir name="button"><file name="account_login.phtml" hash="0d264d082837df0595eaaf974ed621f4"/></dir><file name="button.phtml" hash="009e63a277ee4b85be2e740391a6e895"/><dir name="form"><file name="account_confirm.phtml" hash="92aa2251d75610c4222fdda0b687a2f7"/><file name="account_update.phtml" hash="899c19823ebf6085399a46230d90f830"/></dir><file name="redirect.phtml" hash="0c6e072d82cda10f045b37df7ba4117f"/></dir><dir name="onepage"><file name="button.phtml" hash="d367eb51c74b612ce75579e5a9d07ea5"/></dir><dir name="pay"><file name="button.phtml" hash="69b7b88794a5800d1f82e188d36d1490"/></dir><dir name="payment"><file name="info.phtml" hash="d858c87b3f5d70fbaecd8df77bc9692a"/><dir name="legacy"><file name="info.phtml" hash="8f4821334af01742456d57002e451ce7"/><dir name="pdf"><file name="info.phtml" hash="978c1c5a9716726e2757f4ccb8c03958"/></dir></dir><dir name="pdf"><file name="info.phtml" hash="91eb0a66035259f5cbbd3424ec09d523"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Creativestyle_AmazonPayments.xml" hash="3d30f68b24829494a2a66164eba0e5f7"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Creativestyle_AmazonPayments.csv" hash="c296f98874a5ff2f38a4d6f96359a015"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="863d241bc23599124715c1e797a3cae6"/></dir></dir></dir><dir name="en_GB"><file name="Creativestyle_AmazonPayments.csv" hash="3afdd699a914e9a99317edf97addb18d"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="f858886b12b6f3e16cab85f5ce57b975"/></dir></dir></dir><dir name="en_US"><file name="Creativestyle_AmazonPayments.csv" hash="1ab4e3faab0979a910408f66c0ca95c2"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="702e0a9ada30a5bb5776b28fe63eda93"/></dir></dir></dir><dir name="es_ES"><file name="Creativestyle_AmazonPayments.csv" hash="00213f40cd3a3d46f8e643e14d0322ef"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="e1705a091d04cd4da4d0b0cc49bd283f"/></dir></dir></dir><dir name="fr_FR"><file name="Creativestyle_AmazonPayments.csv" hash="a2ccef1fbee52c1dbb2c0e8f174bcd02"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="e593f24125ecb3ffacbe467d8f39f2de"/></dir></dir></dir><dir name="it_IT"><file name="Creativestyle_AmazonPayments.csv" hash="2ab40220504d9113445a57b5c3ba5b8a"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="5c3857cb5465c91415940689eec8dc75"/></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="creativestyle"><file name="amazonpayments.min.js" hash="42c2fda817e568d5886655d2f6a11ab8"/><file name="amazonpayments.toolbox.min.js" hash="54885eddf2eda8589bc2f4cb8a14d2b2"/><dir name="adminhtml"><file name="amazonpayments.min.js" hash="f59a1371a48770211622b6d337ba8b8b"/></dir><dir name="vendors"><file name="prism.js" hash="c700de3d980f7ef1e056dc5400acfd44"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="creativestyle"><dir name="css"><file name="amazonpayments.css" hash="db97912a183d743b89a5bdfc16a66e71"/><file name="amazonpayments-highlight.css" hash="f6daf03c989ac56ad436300b5520f0df"/></dir><dir name="images"><file name="amazon-payments-advanced-creativestyle-header-logo.png" hash="8591e03aeaa7cbc71a509443de35bfce"/><file name="amazon-payments-advanced-creativestyle-header-logo-white.png" hash="9552112bc27581249cb8e8de1bb91887"/><file name="amazon-payments-advanced-creativestyle-logo.png" hash="abc54550ae7d7a3e5c8a5cd0896d310d"/><file name="amazon-payments-advanced-header.png" hash="a94ab7de3238be5949eec5139e401615"/><file name="amazon-payments-advanced-section.png" hash="8c137a5960eb6938358644259bf23646"/><file name="logo_a-glyph_16.png" hash="44a3f5f0013cab34d26653eb48b989fc"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="creativestyle"><dir name="css"><file name="amazonpayments.css" hash="a6aa4506d316e7303eb33fb4d65bd471"/><file name="amazonpayments-responsive-widgets.css" hash="ffca5cdc8a4e0585946c78258044c471"/><file name="amazonpayments-widgets.css" hash="35704192aaeb204e407e8b853c118d16"/></dir><dir name="images"><file name="amazon-loading-large.gif" hash="5f6d83bf2b69ab73c7e48ec9b66d54db"/><file name="logo_a-glyph_1x.png" hash="5d44ca86985afbb2a47b9265053a456e"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="creativestyle"><dir name="css"><file name="amazonpayments-responsive-widgets.css" hash="389d23ee96bb5305f7ba5b616d930846"/><file name="amazonpayments.css" hash="ac8dee6f92fb5ebafaea7f53b730ca57"/></dir><dir name="images"><file name="amazon-loading-large.gif" hash="5f6d83bf2b69ab73c7e48ec9b66d54db"/><file name="logo_a-glyph_1x.png" hash="5d44ca86985afbb2a47b9265053a456e"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Creativestyle"><dir name="AmazonPayments"><dir name="Block"><file name="Abstract.php" hash="95b7795e67abf7498a0c36ca07012026"/><dir name="Adminhtml"><dir name="Debug"><dir name="Section"><file name="Table.php" hash="741357e99c501e9f4253f77d89f4f9c0"/></dir><file name="Section.php" hash="8101640f29860cc52b8f110fbe60f7fd"/></dir><file name="Debug.php" hash="9e14deca3786ef12a6f4f6a44d76f61e"/><file name="Info.php" hash="cff2abb404250f66a83c0a7ebe5f76d2"/><dir name="Log"><file name="Abstract.php" hash="4700c15d9fdfa7b73feea33f9a18d197"/><dir name="Api"><file name="Grid.php" hash="144446321e70be61e9ded5100fcf393a"/><file name="View.php" hash="c3c71c47b9b9383b68dc28be67ef9eaa"/></dir><file name="Api.php" hash="25ad5ccf87e4e6f03fcee6b10750c77b"/><dir name="Exception"><file name="Grid.php" hash="666a47f6ca80c4d12f2ebef33f52b23b"/><file name="View.php" hash="fcaaabc7f1cb63151d2afec616538915"/></dir><file name="Exception.php" hash="0d3cba3d67af79a980a5e2878753825e"/><dir name="Grid"><file name="Abstract.php" hash="40ef2684a3334c5b182db2ff8d24ebdc"/></dir><dir name="Ipn"><file name="Grid.php" hash="2bdc150636a03e49b528494e30a33fc8"/><file name="View.php" hash="031b1dcf6d9ff344930cf604de3f39f8"/></dir><file name="Ipn.php" hash="1c52eaa03f6f6764034bd259bd433d32"/><dir name="View"><file name="Abstract.php" hash="792ac354ccd345fb5e093e29b493283f"/></dir></dir><file name="Notifications.php" hash="a6f8ded1c0eed0db62bd1c029d22aab4"/><file name="Register.php" hash="95aa85b56271e459edff0600c71ab3c9"/><dir name="Renderer"><file name="Timestamp.php" hash="6fdf831eead3d7300ac070f50887de27"/></dir><file name="SellerCentral.php" hash="bb84af984b60c17971d006acd71c0acf"/></dir><dir name="Checkout"><file name="Abstract.php" hash="2a2cc209f8e1b7585add4820f4cd9a5a"/><file name="Notice.php" hash="3ab8141c2923a57cea3882f69f4e1718"/><file name="SandboxToolbox.php" hash="351c974159285fffff5ef641049cdd30"/></dir><file name="Checkout.php" hash="308bd9ab5c3eea30c38d4fba65fe4424"/><dir name="Customer"><dir name="Account"><dir name="Dashboard"><file name="Login.php" hash="8b746815a86dc6f586ac79aec8f91cea"/></dir></dir></dir><file name="Js.php" hash="f7eed377eb5cbadf0daaa9e47a043864"/><dir name="Login"><file name="Abstract.php" hash="f815118bd94ff30b1e0bd1529ae3efec"/><dir name="Account"><file name="Confirm.php" hash="e76d9fefcf20826e4044773896ee0bef"/><file name="Update.php" hash="3b47702ee8e19168e665faea4b149aca"/></dir><file name="Button.php" hash="79b31962e9e96d3a856c7acb3c262bc5"/><file name="Redirect.php" hash="d680e2dab1cc49d73f313b16f3c5c2eb"/></dir><dir name="Onepage"><file name="Button.php" hash="038f37db916ddd99b5da33406563c2a5"/></dir><dir name="Pay"><file name="Abstract.php" hash="beb5ea19b6fa9e28ee5cf2671fe2217e"/><file name="Button.php" hash="4921a97c88451b216490bbd8497ed0ff"/></dir><dir name="Payment"><file name="Info.php" hash="e73c303f049fbf417f5cbaaa0a9a0a81"/><dir name="Legacy"><file name="Info.php" hash="47a3b994f2cfe436d1b4d8111fa29f45"/></dir></dir></dir><dir name="Controller"><file name="Action.php" hash="11fc97e61d1465b32a4cf3f355fb74a0"/><dir name="Adminhtml"><dir name="Log"><file name="Action.php" hash="29101d0a9ca55bacaeca10f81de74baa"/></dir></dir></dir><dir name="Exception"><file name="InvalidTransaction.php" hash="5ce75c03623fafbb84d23e224b267cca"/><file name="TransactionNotFound.php" hash="a77b6a2f5ff1551ce5db762c2c3ec553"/></dir><file name="Exception.php" hash="869dcadbfd445f947649e96703fe018a"/><dir name="Helper"><file name="Data.php" hash="a45c3a6eb458ceaaf2ac242a480496bd"/><file name="Debug.php" hash="a8bc799cf341e85f33c3417e1c7a3cb5"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="01460ddef0688317a6c6d4c09fcd481f"/><file name="Advanced.php" hash="aeb32cae7ac1fc3111df0528bd6afdaf"/><file name="Ipn.php" hash="63ca90d256276829d056ff7c454b9fe7"/><file name="Login.php" hash="22475a1bdfba0d0161d9a6efdcc36d09"/></dir><file name="Checkout.php" hash="8b2c1d7ead65181500aefe45804a7b87"/><file name="Config.php" hash="be4341ccdad0d5dcb50d91c1cd4aba1c"/><dir name="Log"><file name="Collection.php" hash="9d2fd24dc0073a74ea5f79965c814b24"/></dir><file name="Logger.php" hash="fd313968f89c96733df6cdc4df44b791"/><dir name="Lookup"><file name="Abstract.php" hash="ab89522f0678953cfc661a7db3581b3e"/><file name="AccountRegion.php" hash="8120ea8a8f39c4b49f6a2bcbfcbce9f3"/><file name="Authentication.php" hash="fe736b679b7a24169f13361ae0ace6cf"/><file name="AuthorizationMode.php" hash="4b126b47b01783c777afd61a6c9b4c4f"/><dir name="Design"><dir name="Button"><dir name="Color"><file name="LoginPay.php" hash="d1ab7427cebf36f2a24675d96ef14427"/></dir><file name="Color.php" hash="536b6138fff50203f478eb43a0976a1d"/><dir name="Size"><file name="LoginPay.php" hash="47ae32fd834c7b10b6811af91297850b"/></dir><file name="Size.php" hash="1a294580523abcd8e30f69b667ba947f"/><dir name="Type"><file name="Login.php" hash="1f618e2e5d55c4265e8bcf91d6d18229"/><file name="Pay.php" hash="e95acb3c83e1f8625eaf27e6cfa0ce0b"/></dir></dir></dir><file name="Frequency.php" hash="70d38b195850207fc10fb40a3b298cfd"/><file name="IpnActive.php" hash="6cb130e3bf98df033c17583eb78ba262"/><file name="Language.php" hash="ae1075e3ea2e54c32e38fa17a48f6f8f"/><file name="PaymentAction.php" hash="967090edaa071c5cd168d00d1ac1fc7f"/></dir><file name="Observer.php" hash="3731b83612d094f22bc5c8b69bf309ed"/><dir name="Payment"><file name="Abstract.php" hash="0c8126e2175ac9d9db526c683664aad7"/><dir name="Advanced"><file name="Sandbox.php" hash="38cf735eacf2459f0474f005bfdff1ee"/></dir><file name="Advanced.php" hash="09f541d7a2fe9cbe96add5435c808f67"/><file name="Legacy.php" hash="35ff67bf4069b2b1e9e30c2f4370e86f"/></dir><dir name="Processor"><file name="Order.php" hash="8b9e67d75264af2f3fba17bd51ced9d1"/><file name="Payment.php" hash="9daaaa49e21eac3f5673d0d731f99c28"/><dir name="Transaction"><file name="DataMapper.php" hash="c940149895f643b5a677a2cda6103952"/></dir><file name="Transaction.php" hash="3873d854efbd8d6f3428a13d12befe18"/></dir><dir name="Resource"><file name="Setup.php" hash="75c3c950c3ce37b46d7dcaedc0202f55"/></dir><dir name="Service"><file name="Login.php" hash="d5c67de1bb5b2446cb7b60e36efefc5b"/><file name="Quote.php" hash="5e6820d89ba77a382c1fa8b6b2608883"/></dir><file name="Simulator.php" hash="3ff1243577f1ab1d4ae412e815a6a065"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="DataPolling"><file name="Cron.php" hash="c5b9627dd8e283819606e31051249e4c"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Amazonpayments"><file name="DebugController.php" hash="f7d1ea06deaacbccd9f2f4e5d667d2c9"/><dir name="Log"><file name="ApiController.php" hash="d3119572df028650b29f0d19b46795b8"/><file name="ExceptionController.php" hash="ccf94ebe8591ad08a7b5baa17036a695"/><file name="IpnController.php" hash="9b2e5b215e8d1a83e11218e35a3d0a19"/></dir><file name="OrderController.php" hash="1e128bde8296604a95f50adac0727830"/><file name="SystemController.php" hash="6ad76601e1d5fb4a0565c53606ecbf18"/></dir></dir><dir name="Advanced"><file name="IpnController.php" hash="7556a783d14a32dcdd2c3bbcaa770cfd"/><file name="LoginController.php" hash="8546c6c1832c8a1fd9ff263d453d3b88"/></dir><file name="CheckoutController.php" hash="3e893ec46eeb9ef3a1ea6a17ec549ff0"/><file name="IpnController.php" hash="c700e6fdaa34665d355b333b17634edc"/></dir><dir name="etc"><file name="adminhtml.xml" hash="cd249bbc1deefba11366dba61ed2386c"/><file name="config.xml" hash="4efcf53b4dae5380f9e6c3521fe798d3"/><file name="system.xml" hash="030b3f6b4811902eaab9212647f140cc"/></dir><dir name="sql"><dir name="amazonpayments_setup"><file name="mysql4-install-1.0.0.php" hash="460b9ea8b5319cb86716f4f0b17f9af4"/><file name="mysql4-install-1.6.2.php" hash="127155cdef28f720663d6f7a3fff6cca"/><file name="mysql4-install-2.0.0.php" hash="361497138da518c8fdbd87b6e19c4f32"/><file name="mysql4-upgrade-1.1.6-1.2.0.php" hash="d8fa73e3e74cd58298747a5adcce9bf8"/><file name="mysql4-upgrade-1.7.4-1.7.6.php" hash="b6d706dc250b7fb6ca1a1b1314b19493"/><file name="mysql4-upgrade-1.7.8-1.8.2.php" hash="fcbb92f775e6ae530eb0cd2fd16d3b4d"/></dir></dir></dir></dir></target><target name="magelib"><dir name="OffAmazonPayments"><dir name="HttpRequest"><file name="HttpException.php" hash="d2feba35467baa6ff61503bb15d5f016"/><file name="IHttpRequest.php" hash="7c7d44deffb15b2db161d8dfc585c4d2"/><file name="IHttpRequestFactory.php" hash="02c9cfe067cd0ae40f14704d58fa2098"/><dir name="Impl"><file name="HttpRequestCurlImpl.php" hash="815a03cc4b5fc1222e0bc9b9f85f3428"/><file name="HttpRequestFactoryCurlImpl.php" hash="09140d0c9518e0e7c1bffb8bd0c98310"/></dir></dir><file name="Model.php" hash="778dfe809587f010352d9ccd2bed8106"/><file name="OffAmazonPaymentsServiceUtils.php" hash="827a9e9f2b04652736406b1cd9672a2c"/></dir><dir name="OffAmazonPaymentsNotifications"><file name="Client.php" hash="a8bfa462188eb5193985e984ff503b04"/><dir name="Impl"><file name="Certificate.php" hash="33aec53879fff368b0f6f52ce7f79f13"/><file name="IpnNotificationParser.php" hash="3f4e203c89d23c2971214a7e0713f6a9"/><file name="Message.php" hash="6cffc2f4b4c09a8411572cdb7ddcc83a"/><file name="OpenSslVerifySignature.php" hash="45449e157fa55ab5c2c16a9207616357"/><file name="SnsMessageParser.php" hash="c6d1b0bfa852441b4ddfdc25cf624c9d"/><file name="SnsMessageValidator.php" hash="7291f2b91f0dc9ace62752c37b69d15f"/><file name="VerifySignature.php" hash="b7c3089f35fba596e16f6f39f7029908"/><file name="XmlNotificationParser.php" hash="a6b6ff48de5cee20db383a2a6c953092"/></dir><file name="Interface.php" hash="3930f956058657059e2ea705fc43333d"/><file name="InvalidCertificateException.php" hash="4711c0ea7b574a8ab3fb04623b2f7453"/><file name="InvalidMessageException.php" hash="c9608c6ecfafeae2db9db9e8786f2a15"/><dir name="Model"><file name="AuthorizationDetails.php" hash="c5e85494dd4b21c49c1d786bf38879da"/><file name="AuthorizationNotification.php" hash="490fd1da11270f9af20a6ca0d87b8149"/><file name="BillingAgreement.php" hash="00f24d00547ddb3320a20f77132feb0e"/><file name="BillingAgreementLimits.php" hash="e972154534547bde777133c2de1e835f"/><file name="BillingAgreementNotification.php" hash="c5ee60508326e840ce02765b175897aa"/><file name="BillingAgreementStatus.php" hash="68da18941f6cc8b17a9157c83e550c0c"/><file name="CaptureDetails.php" hash="f8702f3d5d5afd595814182f847367c5"/><file name="CaptureNotification.php" hash="8d4da47b23888f3cfd94fe9d217c46da"/><file name="IdList.php" hash="4d77007c611ba2a990179ecf506d4ac7"/><file name="IpnNotificationMetadata.php" hash="802e724b1cc35eae31e4aa9288446b8f"/><file name="MerchantRegistrationDetails.php" hash="d4de7689d8e216567abd710dde7ef4ed"/><file name="NotificationImpl.php" hash="17205cb366af769c0563d80ee82de067"/><file name="NotificationMetadataImpl.php" hash="27bdabd2ae04ab753e60b0ab3042859c"/><file name="OrderItemCategories.php" hash="ac5edd66a87e28f1e0a4be758e3d7b8c"/><file name="OrderReference.php" hash="3ff8f8729cc3e398823061b73d8d2789"/><file name="OrderReferenceNotification.php" hash="4b6a0e68f77ff7b710fe00916d5b0546"/><file name="OrderReferenceStatus.php" hash="e09fc390fb5c21afd4764c41dd7418c0"/><file name="OrderTotal.php" hash="ce3157db8b593588c9405030968176a5"/><file name="Price.php" hash="cff064218bbb2d56f463ab489dc907cd"/><file name="ProviderCreditDetails.php" hash="d355185842eb0816de151fb535b14edc"/><file name="ProviderCreditNotification.php" hash="7ddc5d80dee797893171237ecabf10e2"/><file name="ProviderCreditReversalDetails.php" hash="a789bbf3c7074bc800053967e64286c7"/><file name="ProviderCreditReversalNotification.php" hash="56479587ee330013bdffe17719d0edec"/><file name="ProviderCreditReversalSummary.php" hash="577971d363b95fd7a73e8cd4995a240c"/><file name="ProviderCreditReversalSummaryList.php" hash="05ae0f9769e4c46e5c3ba3f9907ae576"/><file name="ProviderCreditSummary.php" hash="4403e12b73867b58021655df3fcf6720"/><file name="ProviderCreditSummaryList.php" hash="667167ed6a427d71086aa4ef8dabc5f5"/><file name="RefundDetails.php" hash="ae08c0447ec12996a465772d55f2c28f"/><file name="RefundNotification.php" hash="fb29285214205fd09c4f9ac7964c1a07"/><file name="SellerBillingAgreementAttributes.php" hash="691b120995ac30f3f542c3ec9cd6c0d6"/><file name="SellerOrderAttributes.php" hash="896cf700231529f39e903d4614579a85"/><file name="SnsNotificationMetadata.php" hash="df453726f714f7ea50cc04b6093123eb"/><file name="SolutionProviderMerchantNotification.php" hash="77e4152a922f1a26582e46546387943d"/><file name="SolutionProviderOption.php" hash="df8fbbb1ad2fef1796e3b42a9a417a64"/><file name="SolutionProviderOptions.php" hash="624d2f4efd3a32eab8baf8628efda4ef"/><file name="Status.php" hash="8726fde00e0f97595115866c1a8000dd"/></dir><file name="Notification.php" hash="562b2a4eb6e292b6df4db3112391ab55"/><file name="NotificationMetadata.php" hash="07f94bf3a41ed0c72f387e900260c48a"/></dir><dir name="OffAmazonPaymentsService"><file name="Client.php" hash="26dd6a2d2c407427c5ea0933e2159351"/><file name="Environments.php" hash="1a9ff744e131c19f5bd0d58c5aa578ab"/><file name="Exception.php" hash="eee23053020a397cf082a28f41001284"/><file name="Interface.php" hash="b681a546f2a5e3690e5e04f9c75ca8a5"/><file name="MerchantValues.php" hash="2cca67c2b1b0557e5a63d4ef35950172"/><file name="MerchantValuesBuilder.php" hash="a6328566f8f5ee48a8b054d8f02897e1"/><dir name="Model"><file name="Address.php" hash="6840237ae7035912f95020ff6d580033"/><file name="AuthorizationDetails.php" hash="159edfb213e12b7ecb847c103c70c5de"/><file name="AuthorizeOnBillingAgreementRequest.php" hash="8b0e8d6ffa94b1f18546b7554ec042ed"/><file name="AuthorizeOnBillingAgreementResponse.php" hash="8770715da01743adeafc25d54bb0c1d9"/><file name="AuthorizeOnBillingAgreementResult.php" hash="a73c77f8fce673257e2dca072ad6fab6"/><file name="AuthorizeRequest.php" hash="08bdab4fe2896f4a2b808c6e8abfeeba"/><file name="AuthorizeResponse.php" hash="0ae054040c36e7362683146b537f551b"/><file name="AuthorizeResult.php" hash="e7dfd388200467e736ff3b7d11c8d2bf"/><file name="BillingAddress.php" hash="93f82f074b62e8b1abf25ae8ae44b676"/><file name="BillingAgreementAttributes.php" hash="e52a2c92f92f7081ac742e24f70385df"/><file name="BillingAgreementDetails.php" hash="359f9bd686d21242f2e27feb8b3379b2"/><file name="BillingAgreementLimits.php" hash="66f84e67052b91092867496d11a28763"/><file name="BillingAgreementStatus.php" hash="adcf9379fb2f6fa88a1d8e230d8cf101"/><file name="Buyer.php" hash="cb691abf757d54025ac43964849dd5fd"/><file name="CancelOrderReferenceRequest.php" hash="ef06ecd8f05a4c032aa28f5b5a132d05"/><file name="CancelOrderReferenceResponse.php" hash="004c4e3a21ea1dc8e11bbba3d733b3ca"/><file name="CancelOrderReferenceResult.php" hash="74b7ad1facdf31263e9bb55544303180"/><file name="CaptureDetails.php" hash="4f360221d888d50d92e7f2ea20b5b54f"/><file name="CaptureRequest.php" hash="5b976a76214f870964d49cf104a50b30"/><file name="CaptureResponse.php" hash="7ece74f93f362d31bc16f9fb7bf2b270"/><file name="CaptureResult.php" hash="e0fccf0fe27efd36d822ddcdaefe97ac"/><file name="CloseAuthorizationRequest.php" hash="cb0e2113e9e36b7b133b539e5ff99c50"/><file name="CloseAuthorizationResponse.php" hash="99be7612c9effdac53fb0bc225a13eb1"/><file name="CloseAuthorizationResult.php" hash="6d77eea8924d2ef6a3acd0dabb3f9f76"/><file name="CloseBillingAgreementRequest.php" hash="89f82b30dd0902faa6feb3a57dfe24cb"/><file name="CloseBillingAgreementResponse.php" hash="1bda191dc9a8b2b1a14b6e11772f05cf"/><file name="CloseBillingAgreementResult.php" hash="f926f5d65d95323647129605a26037ae"/><file name="CloseOrderReferenceRequest.php" hash="b8b592bdc71a4046efead52196f8073c"/><file name="CloseOrderReferenceResponse.php" hash="137da00395052b25099de3a0d152887d"/><file name="CloseOrderReferenceResult.php" hash="81e21f75ae477f07a9b913e1ac2bd89d"/><file name="ConfirmBillingAgreementRequest.php" hash="ab524aa1cc6e51a8b483e4f96b7e1e02"/><file name="ConfirmBillingAgreementResponse.php" hash="0639de39ba58e6c2b806a84b43dc31d3"/><file name="ConfirmBillingAgreementResult.php" hash="42456915a3efa4ccd774a1d5d3a05307"/><file name="ConfirmOrderReferenceRequest.php" hash="632a4b8414aac550fc0ec59a83737be7"/><file name="ConfirmOrderReferenceResponse.php" hash="fb0c329ffa1a54e4c15c531b58561f6f"/><file name="Constraint.php" hash="e46dc3d18486b6639ea5b8f52a92cfdc"/><file name="Constraints.php" hash="cb983d71bda42bdda767ffc9f4feeafc"/><file name="CreateOrderReferenceForIdRequest.php" hash="b1f4e96f1392c427228f5799edc5dc64"/><file name="CreateOrderReferenceForIdResponse.php" hash="630cb4812997fa7c067f393dfb5e2f48"/><file name="CreateOrderReferenceForIdResult.php" hash="4abf7af5eb56058c17996406a877f427"/><file name="Destination.php" hash="737777909588915788398ab86f0de1de"/><file name="Error.php" hash="bb8b6bb6d3c778fc4e1d0a346b5fa03a"/><file name="ErrorResponse.php" hash="8804c6f39d9a0bdcbd76260eba9d261d"/><file name="GetAuthorizationDetailsRequest.php" hash="67d5a478c01fbbfba420dff3cf2098dc"/><file name="GetAuthorizationDetailsResponse.php" hash="0c9fe935bcb953cc9cd9e11bab32b5b2"/><file name="GetAuthorizationDetailsResult.php" hash="02ac4fa6533ccfd705c543160165c31d"/><file name="GetBillingAgreementDetailsRequest.php" hash="761cbdc44a4ac1e28b22d01f7a484b76"/><file name="GetBillingAgreementDetailsResponse.php" hash="061084469683253d1d76d5c881e5062d"/><file name="GetBillingAgreementDetailsResult.php" hash="5a585ad373b11b806ba320bcd988f71b"/><file name="GetCaptureDetailsRequest.php" hash="69252be80c32d911f2ff664904375e7d"/><file name="GetCaptureDetailsResponse.php" hash="5323ed86174064bb1122187457440861"/><file name="GetCaptureDetailsResult.php" hash="962ef27de2778c9ccde55d848b8fa649"/><file name="GetOrderReferenceDetailsRequest.php" hash="edfea06a629f298ab134229d35fef319"/><file name="GetOrderReferenceDetailsResponse.php" hash="4955733fe736a9f51e0bd6823b8bf74b"/><file name="GetOrderReferenceDetailsResult.php" hash="f9ee3738bddff51c6bd545028d275348"/><file name="GetProviderCreditDetailsRequest.php" hash="e51201c7d39935c4fa8da96e822b7075"/><file name="GetProviderCreditDetailsResponse.php" hash="e312b54192343e16230b7436b101766a"/><file name="GetProviderCreditDetailsResult.php" hash="9f0af601e8a716e4e5af3802d8952fe4"/><file name="GetProviderCreditReversalDetailsRequest.php" hash="cf74576ef8dc02e34244aca962d854b3"/><file name="GetProviderCreditReversalDetailsResponse.php" hash="a869c2695416514834c83890d3b080f9"/><file name="GetProviderCreditReversalDetailsResult.php" hash="33f1980d1632034eee8396c6286b5320"/><file name="GetRefundDetailsRequest.php" hash="7ab0f7d756a59a284ffd0ffc361fee42"/><file name="GetRefundDetailsResponse.php" hash="4847a7513f69d3f81c306d26ad7c5291"/><file name="GetRefundDetailsResult.php" hash="0c24e3c8e95f4ee10f5c4e9dd07518bf"/><file name="IdList.php" hash="25fd15394669b4721bdd0e4d367d534f"/><file name="OrderItemCategories.php" hash="995db32a92601555ee9a7550d1daae7e"/><file name="OrderReferenceAttributes.php" hash="78e1735d8fc99c5676d894564d6b88c7"/><file name="OrderReferenceDetails.php" hash="4e9365808e09fe1b1407348c9d05ca41"/><file name="OrderReferenceStatus.php" hash="5c21e44d991a24ab2527e491c435d54c"/><file name="OrderTotal.php" hash="2ff8e8ccc9c7266d72f534485ccd01bf"/><file name="ParentDetails.php" hash="99f7062b4764166637dfc44b4fe4788c"/><file name="Price.php" hash="4ac8de3791146a17a237a914c9f762a6"/><file name="ProviderCredit.php" hash="8f2f21ac5c0dba73e64a35cc7a61fbbe"/><file name="ProviderCreditDetails.php" hash="d9057efbe528a1571eda4252b8ad1813"/><file name="ProviderCreditList.php" hash="4a3eeae90b5a1ed09a528f5254b968a5"/><file name="ProviderCreditReversal.php" hash="07c1d7959a7cfb94164846c276b43ce7"/><file name="ProviderCreditReversalDetails.php" hash="ebfbf919b4a399213c7e312e59873e43"/><file name="ProviderCreditReversalList.php" hash="8eb64497a6a233535c8b0ca55591d06b"/><file name="ProviderCreditReversalSummary.php" hash="7646c582ea5fb3a46dcb09637f7daf01"/><file name="ProviderCreditReversalSummaryList.php" hash="cae281ddee9f766d1d5bf350e238037a"/><file name="ProviderCreditSummary.php" hash="69bc18eefe644e6b851a6daf7e6dfa8a"/><file name="ProviderCreditSummaryList.php" hash="751812d8903ba883036d1bc381c37667"/><file name="RefundDetails.php" hash="b53e480fe8e8e5d96a4b6a0df431e5ac"/><file name="RefundRequest.php" hash="665585551aba39532fe3352abb4859b3"/><file name="RefundResponse.php" hash="fadbc4ad5313395a48e38b1c0502c85a"/><file name="RefundResult.php" hash="9ddad34dd53edfd156651b021bc5137a"/><file name="ResponseHeaderMetadata.php" hash="382fe7bd666eea293b729c5d6c79348f"/><file name="ResponseMetadata.php" hash="073748a20ecd8bddc240dd4c0a4a56b9"/><file name="ReverseProviderCreditRequest.php" hash="802a3709149add8fa192ce389b93c2ea"/><file name="ReverseProviderCreditResponse.php" hash="ff702a7def546f0c6216094f93095bd7"/><file name="ReverseProviderCreditResult.php" hash="84f3e78e1b8b1b47e6f8b92abee7704b"/><file name="SellerBillingAgreementAttributes.php" hash="308899b9e48a95f0b5d48d74a510c915"/><file name="SellerOrderAttributes.php" hash="35b62fe0e130207dfaa2caefa1dfe7ba"/><file name="SetBillingAgreementDetailsRequest.php" hash="347a6c85c5cc8394255efcb9c4b57d52"/><file name="SetBillingAgreementDetailsResponse.php" hash="92299b3338dc7435149f17d8126f7518"/><file name="SetBillingAgreementDetailsResult.php" hash="7cb3e84e58fe2bbf163f8ac34de5eccf"/><file name="SetOrderReferenceDetailsRequest.php" hash="4cf2605f5188116a1526d463638aa768"/><file name="SetOrderReferenceDetailsResponse.php" hash="41720bdf965dcd759cc3278e01610530"/><file name="SetOrderReferenceDetailsResult.php" hash="4281a97da7865e47157c1d22c2094bfd"/><file name="Status.php" hash="28bd007e6c9747417a063e9941cc0dba"/><file name="ValidateBillingAgreementRequest.php" hash="d77beda441fd1688903e96a02fa4e643"/><file name="ValidateBillingAgreementResponse.php" hash="89658fd2a78d7dbb2997dae6ba169f7e"/><file name="ValidateBillingAgreementResult.php" hash="b9244d0496b0bbcfbf7628c775c17ca3"/></dir><file name="Model.php" hash="fafcb3a4318eb7bd9be5b69225187352"/><file name="RegionSpecificProperties.php" hash="f4e77cc63766b42fbef6ef1e07ec4402"/><file name="Regions.php" hash="4676d77db7dde345118e2a6fc021ce3f"/></dir></target></contents>
|
23 |
<compatible/>
|
24 |
<dependencies><required><php><min>5.2.0</min><max>8.0.0</max></php></required></dependencies>
|
25 |
</package>
|