Creativestyle_AmazonPayments - Version 1.6.2

Version Notes

FIXED: bugs in refactored payment model
FIXED: IPN processing bugs in v.1.6.0
FIXED: 404 error when customer press "Cancel" on Amazon login form

Download this release

Release Info

Developer creativestyle GmbH
Extension Creativestyle_AmazonPayments
Version 1.6.2
Comparing to
See all releases


Code changes from version 1.6.0 to 1.6.2

Files changed (20) hide show
  1. app/code/community/Creativestyle/AmazonPayments/Helper/Data.php +32 -12
  2. app/code/community/Creativestyle/AmazonPayments/Model/Manager.php +0 -1027
  3. app/code/community/Creativestyle/AmazonPayments/Model/Mapper.php +0 -162
  4. app/code/community/Creativestyle/AmazonPayments/Model/Observer.php +16 -15
  5. app/code/community/Creativestyle/AmazonPayments/Model/Payment/Abstract.php +106 -331
  6. app/code/community/Creativestyle/AmazonPayments/Model/Payment/Advanced/Abstract.php +0 -393
  7. app/code/community/Creativestyle/AmazonPayments/Model/Processor.php +0 -297
  8. app/code/community/Creativestyle/AmazonPayments/Model/Processor/Ipn.php +133 -0
  9. app/code/community/Creativestyle/AmazonPayments/Model/Processor/Order.php +452 -0
  10. app/code/community/Creativestyle/AmazonPayments/Model/Processor/Payment.php +174 -0
  11. app/code/community/Creativestyle/AmazonPayments/Model/Processor/TransactionAdapter.php +452 -0
  12. app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/OrderController.php +2 -1
  13. app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/IpnController.php +2 -2
  14. app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/LoginController.php +17 -1
  15. app/code/community/Creativestyle/AmazonPayments/etc/config.xml +1 -1
  16. app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-install-1.6.2.php +28 -0
  17. app/locale/de_DE/Creativestyle_AmazonPayments.csv +1 -0
  18. app/locale/en_GB/Creativestyle_AmazonPayments.csv +1 -0
  19. app/locale/en_US/Creativestyle_AmazonPayments.csv +1 -0
  20. package.xml +7 -6
app/code/community/Creativestyle/AmazonPayments/Helper/Data.php CHANGED
@@ -27,26 +27,21 @@ class Creativestyle_AmazonPayments_Helper_Data extends Mage_Core_Helper_Abstract
27
  }
28
 
29
  /**
30
- * Send email id payment was failed
31
  *
32
- * @param Mage_Sales_Model_Order_Payment $payment
33
- * @param OffAmazonPaymentsService_Model_AuthorizationDetails|OffAmazonPaymentsNotifications_Model_AuthorizationDetails $authorizationDetails
 
34
  */
35
- public function sendAuthorizationDeclinedEmail($payment, $authorizationDetails = null) {
36
  $translate = Mage::getSingleton('core/translate');
37
- /* @var $translate Mage_Core_Model_Translate */
38
  $translate->setTranslateInline(false);
39
-
40
  $mailTemplate = Mage::getModel('core/email_template');
41
- /* @var $mailTemplate Mage_Core_Model_Email_Template */
42
 
43
- $template = $this->_getConfig()->getAuthorizationDeclinedEmailTemplate();
44
-
45
- $order = $payment->getOrder();
46
  $mailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $order->getStore()->getId()))
47
  ->sendTransactional(
48
- $template,
49
- $this->_getConfig()->getAuthorizationDeclinedEmailIdentity(),
50
  $order->getCustomerEmail(),
51
  null,
52
  array(
@@ -86,6 +81,9 @@ class Creativestyle_AmazonPayments_Helper_Data extends Mage_Core_Helper_Abstract
86
  return preg_match('/iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini/', $userAgent);
87
  }
88
 
 
 
 
89
  public function getTransactionStatus($transaction) {
90
  $statusArray = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
91
  if (is_array($statusArray) && array_key_exists('State', $statusArray)) {
@@ -94,6 +92,28 @@ class Creativestyle_AmazonPayments_Helper_Data extends Mage_Core_Helper_Abstract
94
  return null;
95
  }
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  public function getTransactionReasonCode($transaction) {
98
  $statusArray = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
99
  if (is_array($statusArray) && array_key_exists('ReasonCode', $statusArray)) {
27
  }
28
 
29
  /**
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()),
44
+ $this->_getConfig()->getAuthorizationDeclinedEmailIdentity($order->getStore()->getId()),
45
  $order->getCustomerEmail(),
46
  null,
47
  array(
81
  return preg_match('/iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini/', $userAgent);
82
  }
83
 
84
+ /**
85
+ * @deprecated deprecated since 1.6.2
86
+ */
87
  public function getTransactionStatus($transaction) {
88
  $statusArray = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
89
  if (is_array($statusArray) && array_key_exists('State', $statusArray)) {
92
  return null;
93
  }
94
 
95
+ /**
96
+ * TODO: [getTransactionInformation description]
97
+ *
98
+ * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
99
+ * @param string $key
100
+ *
101
+ * @return array|string|null
102
+ */
103
+ public function getTransactionInformation($transaction, $key = null) {
104
+ $additionalInformation = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
105
+ if (is_array($additionalInformation)) {
106
+ if (null !== $key) {
107
+ if (array_key_exists($key, $additionalInformation)) {
108
+ return $additionalInformation[$key];
109
+ }
110
+ } else {
111
+ return $additionalInformation;
112
+ }
113
+ }
114
+ return null;
115
+ }
116
+
117
  public function getTransactionReasonCode($transaction) {
118
  $statusArray = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
119
  if (is_array($statusArray) && array_key_exists('ReasonCode', $statusArray)) {
app/code/community/Creativestyle/AmazonPayments/Model/Manager.php DELETED
@@ -1,1027 +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_Manager {
17
-
18
-
19
- // **********************************************************************
20
- // Object instances geters
21
-
22
- protected function _getApi() {
23
- return Mage::getSingleton('amazonpayments/api_advanced');
24
- }
25
-
26
- protected function _getConfig() {
27
- return Mage::getSingleton('amazonpayments/config');
28
- }
29
-
30
-
31
-
32
- // **********************************************************************
33
- // General helpers
34
-
35
- protected function _sanitizeReferenceId($referenceId) {
36
- return substr($referenceId, 0, strrpos($referenceId, '-'));
37
- }
38
-
39
- protected function _lookupPayment($referenceId) {
40
- $order = Mage::getModel('sales/order')->loadByAttribute('ext_order_id', $referenceId);
41
- if (is_object($order) && $order->getId()) return $order->getPayment();
42
- return null;
43
- }
44
-
45
- /**
46
- * Check if addresses differ, return false otherwise
47
- *
48
- * @param Mage_Customer_Model_Address_Abstract $address1st
49
- * @param array $address2nd
50
- * @return bool
51
- */
52
- protected function _compareAddresses($address1st, $address2nd) {
53
- // compare both addresses, but streets due their array nature in a separate call
54
- $streetDiff = array_diff($address2nd['street'], $address1st->getStreet());
55
- return ((isset($address2nd['firstname']) && $address1st->getFirstname() != $address2nd['firstname'])
56
- || (isset($address2nd['lastname']) && $address1st->getLastname() != $address2nd['lastname'])
57
- || (isset($address2nd['company']) && $address1st->getCompany() != $address2nd['company'])
58
- || (isset($address2nd['city']) && $address1st->getCity() != $address2nd['city'])
59
- || (isset($address2nd['postcode']) && $address1st->getPostcode() != $address2nd['postcode'])
60
- || (isset($address2nd['country_id']) && $address1st->getCountryId() != $address2nd['country_id'])
61
- || (!empty($streetDiff)));
62
- }
63
-
64
- /**
65
- * @param Mage_Customer_Model_Address_Abstract $address
66
- * @param array $newAddress
67
- * @return bool
68
- */
69
- protected function _updateOrderAddress(Mage_Customer_Model_Address_Abstract $address, $newAddress) {
70
- if ($this->_compareAddresses($address, $newAddress)) {
71
- if (isset($newAddress['firstname'])) {
72
- $address->setFirstname($newAddress['firstname']);
73
- }
74
- if (isset($newAddress['lastname'])) {
75
- $address->setLastname($newAddress['lastname']);
76
- }
77
- if (isset($newAddress['company'])) {
78
- $address->setCompany($newAddress['company']);
79
- }
80
- if (isset($newAddress['street'])) {
81
- $address->setStreet($newAddress['street']);
82
- }
83
- if (isset($newAddress['city'])) {
84
- $address->setCity($newAddress['city']);
85
- }
86
- if (isset($newAddress['postcode'])) {
87
- $address->setPostcode($newAddress['postcode']);
88
- }
89
- if (isset($newAddress['country_id'])) {
90
- $address->setCountryId($newAddress['country_id']);
91
- }
92
- if (isset($newAddress['telephone'])) {
93
- $address->setTelephone($newAddress['telephone']);
94
- }
95
- return true;
96
- }
97
- return false;
98
- }
99
-
100
- /**
101
- * Check if emails differ, return false otherwise
102
- *
103
- * @param string $email1st
104
- * @param string $email2nd
105
- * @return bool
106
- */
107
- protected function _compareEmails($email1st, $email2nd) {
108
- return trim($email1st) != trim($email2nd);
109
- }
110
-
111
- /**
112
- * @param Mage_Sales_Model_Order $order
113
- * @param string $newEmail
114
- * @return bool
115
- */
116
- protected function _updateCustomerEmail(Mage_Sales_Model_Order $order, $newEmail) {
117
- if ($this->_compareEmails($order->getCustomerEmail(), $newEmail)) {
118
- $order->setCustomerEmail(trim($newEmail));
119
- return true;
120
- }
121
- return false;
122
- }
123
-
124
-
125
- /**
126
- * Check if names differ, return false otherwise
127
- *
128
- * @param string $name1st
129
- * @param string $name2nd
130
- * @return bool
131
- */
132
- protected function _compareNames($name1st, $name2nd) {
133
- return trim($name1st) != trim($name2nd);
134
- }
135
-
136
- /**
137
- * @param Mage_Sales_Model_Order $order
138
- * @param array $newEmail
139
- * @return bool
140
- */
141
- protected function _updateCustomerName(Mage_Sales_Model_Order $order, $newName) {
142
- $customerNameUpdated = false;
143
- if (isset($newName['firstname']) && isset($newName['lastname'])) {
144
- if ($this->_compareNames($order->getCustomerFirstname(), $newName['firstname'])) {
145
- $order->setCustomerFirstname($newName['firstname']);
146
- $customerNameUpdated = true;
147
- }
148
- if ($this->_compareNames($order->getCustomerLastname(), $newName['lastname'])) {
149
- $order->setCustomerLastname($newName['lastname']);
150
- $customerNameUpdated = true;
151
- }
152
- }
153
- return $customerNameUpdated;
154
- }
155
-
156
- /**
157
- * Check whether provided address lines contain PO Box data
158
- */
159
- protected function _isPoBox($addressLine1, $addressLine2 = null) {
160
- if (is_numeric($addressLine1)) {
161
- return true;
162
- }
163
- if (strpos(strtolower($addressLine1), 'packstation') !== false) {
164
- return true;
165
- }
166
- if (strpos(strtolower($addressLine2), 'packstation') !== false) {
167
- return true;
168
- }
169
- return false;
170
- }
171
-
172
- /**
173
- * Convert Amazon AddressLine fields to the array
174
- * Try to guess if address lines contain company name or PO Box
175
- *
176
- * @param string $addressLine1
177
- * @param string $addressLine2
178
- * @param string $addressLine3
179
- * @param string $countryId
180
- *
181
- * @return array
182
- */
183
- protected function _convertAmazonAddressLinesToArray($addressLine1, $addressLine2 = null, $addressLine3 = null, $countryId = null) {
184
- $data = array('street' => array());
185
- if ($countryId && in_array($countryId, array('DE', 'AT'))) {
186
- if ($addressLine3) {
187
- if ($this->_isPoBox($addressLine1, $addressLine2)) {
188
- $data['street'][] = $addressLine1;
189
- $data['street'][] = $addressLine2;
190
- } else {
191
- $data['company'] = trim($addressLine1 . ' ' . $addressLine2);
192
- }
193
- $data['street'][] = $addressLine3;
194
- } else if ($addressLine2) {
195
- if ($this->_isPoBox($addressLine1)) {
196
- $data['street'][] = $addressLine1;
197
- } else {
198
- $data['company'] = $addressLine1;
199
- }
200
- $data['street'][] = $addressLine2;
201
- } else {
202
- $data['street'][] = $addressLine1;
203
- }
204
- } else {
205
- if ($addressLine1) {
206
- $data['street'][] = $addressLine1;
207
- }
208
- if ($addressLine2) {
209
- $data['street'][] = $addressLine2;
210
- }
211
- if ($addressLine3) {
212
- $data['street'][] = $addressLine3;
213
- }
214
- }
215
- return $data;
216
- }
217
-
218
- /**
219
- * Converts Amazon address object to the array
220
- *
221
- * @return OffAmazonPaymentsService_Model_Address $amazonAddress
222
- * @return array
223
- */
224
- protected function _convertAmazonAddressToArray($amazonAddress) {
225
- $address = $this->_convertAmazonAddressLinesToArray(
226
- $amazonAddress->getAddressLine1(),
227
- $amazonAddress->getAddressLine2(),
228
- $amazonAddress->getAddressLine3(),
229
- $amazonAddress->getCountryCode()
230
- );
231
- if ($amazonAddress->isSetName()) {
232
- $customerName = Mage::helper('amazonpayments')->explodeCustomerName($amazonAddress->getName());
233
- $address['firstname'] = $customerName->getFirstname();
234
- $address['lastname'] = $customerName->getLastname();
235
- }
236
- if ($amazonAddress->isSetCity()) {
237
- $address['city'] = $amazonAddress->getCity();
238
- }
239
- if ($amazonAddress->isSetPostalCode()) {
240
- $address['postcode'] = $amazonAddress->getPostalCode();
241
- }
242
- if ($amazonAddress->isSetCountryCode()) {
243
- $address['country_id'] = $amazonAddress->getCountryCode();
244
- }
245
- if ($amazonAddress->isSetPhone()) {
246
- $address['telephone'] = $amazonAddress->getPhone();
247
- }
248
- return $address;
249
- }
250
-
251
-
252
-
253
- // **********************************************************************
254
- // General handling routines
255
-
256
- /**
257
- * Update state of Magento transaction object
258
- *
259
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
260
- * @param OffAmazonPaymentsService_Model_Status|OffAmazonPaymentsNotifications_Model_Status $transactionStatus
261
- * @return Mage_Sales_Model_Order_Payment_Transaction
262
- */
263
- protected function _updateTransactionStatus($transaction, $transactionStatus) {
264
- if ($transactionStatus->isSetState()) {
265
- if (Mage::helper('amazonpayments')->getTransactionStatus($transaction) != $transactionStatus->getState()) {
266
- $statusArray = array('State' => $transactionStatus->getState());
267
- if ($transactionStatus->isSetReasonCode()) {
268
- $statusArray['ReasonCode'] = $transactionStatus->getReasonCode();
269
- }
270
- if ($transactionStatus->isSetReasonDescription()) {
271
- $statusArray['ReasonDescription'] = $transactionStatus->getReasonDescription();
272
- }
273
- return $statusArray;
274
- }
275
- }
276
- return null;
277
- }
278
-
279
- /*
280
- protected function _updateTransactionStatus($transaction, $transactionStatus) {
281
- if ($transactionStatus->isSetState()) {
282
- $statusArray = array('State' => $transactionStatus->getState());
283
- if ($transactionStatus->isSetReasonCode()) {
284
- $statusArray['ReasonCode'] = $transactionStatus->getReasonCode();
285
- }
286
- if ($transactionStatus->isSetReasonDescription()) {
287
- $statusArray['ReasonDescription'] = $transactionStatus->getReasonDescription();
288
- }
289
- $transaction->setAdditionalInformation('state', strtolower($transactionStatus->getState()))
290
- ->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $statusArray);
291
- }
292
- return $transaction;
293
- }
294
- */
295
-
296
- /**
297
- *
298
- */
299
- protected function _addHistoryComment($order, $transaction, $amount, $state) {
300
- switch ($transaction->getTxnType()) {
301
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
302
- $message = 'An order of %s has been processed by Amazon Payments (%s). The new status is %s.';
303
- break;
304
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
305
- $message = 'An authorization of %s has been processed by Amazon Payments (%s). The new status is %s.';
306
- break;
307
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
308
- $message = 'A capture of %s has been processed by Amazon Payments (%s). The new status is %s.';
309
- break;
310
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
311
- $message = 'A refund of %s has been processed by Amazon Payments (%s). The new status is %s.';
312
- break;
313
- default:
314
- throw new Creativestyle_AmazonPayments_Exception('Cannot add a history comment for unsupported transaction type.');
315
- }
316
-
317
- return $order->addStatusHistoryComment(Mage::helper('amazonpayments')->__(
318
- $message,
319
- $order->getStore()->convertPrice($amount, true, false),
320
- $transaction->getTxnId(),
321
- strtoupper($state)
322
- ), true
323
- )->setIsCustomerNotified(Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE);
324
- }
325
-
326
-
327
-
328
-
329
- // **********************************************************************
330
- // Order Reference handling routines
331
-
332
- /**
333
- * Handle & process open Amazon's Order Reference object
334
- *
335
- * @todo $orderUpdated variable obsolete, remove it and add coments when order data changes
336
- * @param Mage_Sales_Model_Order_Payment $payment
337
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
338
- * @param OffAmazonPaymentsService_Model_OrderReferenceDetails|OffAmazonPaymentsNotifications_Model_OrderReference $orderReferenceDetails
339
- */
340
- protected function _handleOpenOrderReference($payment, $transaction, $orderReferenceDetails) {
341
- if ($transaction && $orderReferenceDetails->isSetOrderReferenceStatus()) {
342
- $newStatus = $this->_updateTransactionStatus($transaction, $orderReferenceDetails->getOrderReferenceStatus());
343
- if (null !== $newStatus) {
344
- $order = $payment->getOrder();
345
- $orderUpdated = false;
346
-
347
- // depending on the data source, some fields may be not available, process below section
348
- // only for responses to GetOrderReferenceDetails calls, skip for OrderReference notifications
349
- if ($orderReferenceDetails instanceof OffAmazonPaymentsService_Model_OrderReferenceDetails) {
350
- if ($orderReferenceDetails->isSetBuyer()) {
351
- if ($orderReferenceDetails->getBuyer()->isSetEmail()) {
352
- $orderUpdated = $this->_updateCustomerEmail($order, $orderReferenceDetails->getBuyer()->getEmail()) || $orderUpdated;
353
- }
354
- }
355
-
356
- if ($orderReferenceDetails->isSetDestination()) {
357
- if ($orderReferenceDetails->getDestination()->isSetPhysicalDestination()) {
358
- $shippingAddress = $this->_convertAmazonAddressToArray($orderReferenceDetails->getDestination()->getPhysicalDestination());
359
- if (isset($shippingAddress['firstname']) && isset($shippingAddress['lastname'])) {
360
- $customerName = array(
361
- 'firstname' => $shippingAddress['firstname'],
362
- 'lastname' => $shippingAddress['lastname']
363
- );
364
- $orderUpdated = $this->_updateCustomerName($order, $customerName) || $orderUpdated;
365
- }
366
- $orderUpdated = $this->_updateOrderAddress($order->getBillingAddress(), $shippingAddress) || $orderUpdated;
367
- $orderUpdated = $this->_updateOrderAddress($order->getShippingAddress(), $shippingAddress) || $orderUpdated;
368
- }
369
- }
370
- }
371
-
372
- $this->_addHistoryComment($order, $transaction, $orderReferenceDetails->getOrderTotal()->getAmount(), $orderReferenceDetails->getOrderReferenceStatus()->getState());
373
-
374
- $transactionSave = Mage::getModel('core/resource_transaction');
375
- if ($orderUpdated) {
376
- $transactionSave->addObject($order);
377
- $transactionSave->addCommitCallback(array($order, 'save'));
378
- }
379
-
380
- // check if authorization should be re-submitted
381
- $authTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
382
- if ($authTransaction && $authTransaction->getIsClosed() && ($order->getBaseTotalDue() > 0)) {
383
- $payment->authorize(true, $order->getBaseTotalDue());
384
- $transactionSave->addObject($payment);
385
- $orderUpdated = true;
386
- }
387
-
388
- if ($orderUpdated) {
389
- $transactionSave->save();
390
- }
391
-
392
- }
393
- return $newStatus;
394
- }
395
- return null;
396
- }
397
-
398
- /**
399
- * Handle & process suspended Amazon's Order Reference object
400
- *
401
- * @param Mage_Sales_Model_Order_Payment $payment
402
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
403
- * @param OffAmazonPaymentsService_Model_OrderReferenceDetails|OffAmazonPaymentsNotifications_Model_OrderReference $orderReferenceDetails
404
- */
405
- protected function _handleSuspendedOrderReference($payment, $transaction, $orderReferenceDetails) {
406
- if ($orderReferenceDetails->isSetOrderReferenceStatus()) {
407
- $newStatus = $this->_updateTransactionStatus($transaction, $orderReferenceDetails->getOrderReferenceStatus());
408
- if (null !== $newStatus) {
409
- $this->_addHistoryComment($payment->getOrder(), $transaction, $orderReferenceDetails->getOrderTotal()->getAmount(), $orderReferenceDetails->getOrderReferenceStatus()->getState())->save();
410
- }
411
- return $newStatus;
412
- }
413
- return null;
414
- }
415
-
416
- /**
417
- * Handle & process canceled Amazon's Order Reference object
418
- *
419
- * @param Mage_Sales_Model_Order_Payment $payment
420
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
421
- * @param OffAmazonPaymentsService_Model_OrderReferenceDetails|OffAmazonPaymentsNotifications_Model_OrderReference $orderReferenceDetails
422
- */
423
- protected function _handleCanceledOrderReference($payment, $transaction, $orderReferenceDetails) {
424
- if ($orderReferenceDetails->isSetOrderReferenceStatus()) {
425
- $newStatus = $this->_updateTransactionStatus($transaction, $orderReferenceDetails->getOrderReferenceStatus());
426
- if (null !== $newStatus) {
427
- $this->_addHistoryComment($payment->getOrder(), $transaction, $orderReferenceDetails->getOrderTotal()->getAmount(), $orderReferenceDetails->getOrderReferenceStatus()->getState())->save();
428
- }
429
- return $newStatus;
430
- }
431
- return null;
432
- }
433
-
434
- /**
435
- * Handle & process closed Amazon's Order Reference object
436
- *
437
- * @param Mage_Sales_Model_Order_Payment $payment
438
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
439
- * @param OffAmazonPaymentsService_Model_OrderReferenceDetails|OffAmazonPaymentsNotifications_Model_OrderReference $orderReferenceDetails
440
- */
441
- protected function _handleClosedOrderReference($payment, $transaction, $orderReferenceDetails) {
442
- if ($orderReferenceDetails->isSetOrderReferenceStatus()) {
443
- $newStatus = $this->_updateTransactionStatus($transaction, $orderReferenceDetails->getOrderReferenceStatus());
444
- if (null !== $newStatus) {
445
- $this->_addHistoryComment($payment->getOrder(), $transaction, $orderReferenceDetails->getOrderTotal()->getAmount(), $orderReferenceDetails->getOrderReferenceStatus()->getState())->save();
446
- }
447
- return $newStatus;
448
- }
449
- return null;
450
- }
451
-
452
-
453
-
454
- // **********************************************************************
455
- // Authorization handling routines
456
-
457
- /**
458
- * Handle & process pending Amazon's Authorization object
459
- *
460
- * @param Mage_Sales_Model_Order_Payment $payment
461
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
462
- * @param OffAmazonPaymentsService_Model_AuthorizationDetails|OffAmazonPaymentsNotifications_Model_AuthorizationDetails $authorizationDetails
463
- */
464
- protected function _handlePendingAuthorization($payment, $transaction, $authorizationDetails) {
465
- if ($authorizationDetails->isSetAuthorizationStatus()) {
466
- $newStatus = $this->_updateTransactionStatus($transaction, $authorizationDetails->getAuthorizationStatus());
467
- if (null !== $newStatus) {
468
- $this->_addHistoryComment($payment->getOrder(), $transaction, $authorizationDetails->getAuthorizationAmount()->getAmount(), $authorizationDetails->getAuthorizationStatus()->getState())->save();
469
- }
470
- return $newStatus;
471
- }
472
- return null;
473
- }
474
-
475
- /**
476
- * Handle & process open Amazon's Authorization object
477
- *
478
- * @param Mage_Sales_Model_Order_Payment $payment
479
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
480
- * @param OffAmazonPaymentsService_Model_AuthorizationDetails|OffAmazonPaymentsNotifications_Model_AuthorizationDetails $authorizationDetails
481
- */
482
- protected function _handleOpenAuthorization($payment, $transaction, $authorizationDetails) {
483
- if ($authorizationDetails->isSetAuthorizationStatus()) {
484
- $newStatus = $this->_updateTransactionStatus($transaction, $authorizationDetails->getAuthorizationStatus());
485
- if (null !== $newStatus) {
486
- $order = $payment->getOrder();
487
- $orderUpdated = false;
488
-
489
- if ($authorizationDetails->isSetAuthorizationBillingAddress()) {
490
- $billingAddress = $this->_convertAmazonAddressToArray($authorizationDetails->getAuthorizationBillingAddress());
491
- if (isset($billingAddress['firstname']) && isset($billingAddress['lastname'])) {
492
- $customerName = array(
493
- 'firstname' => $billingAddress['firstname'],
494
- 'lastname' => $billingAddress['lastname']
495
- );
496
- $orderUpdated = $this->_updateCustomerName($order, $customerName) || $orderUpdated;
497
- }
498
- $orderUpdated = $this->_updateCustomerName($order, $customerName) || $orderUpdated;
499
- $orderUpdated = $this->_updateOrderAddress($order->getBillingAddress(), $billingAddress) || $orderUpdated;
500
- }
501
-
502
- if ($order->getStatus() != $this->_getConfig()->getAuthorizedOrderStatus()) {
503
- $order->setState(
504
- Mage_Sales_Model_Order::STATE_PROCESSING,
505
- $this->_getConfig()->getAuthorizedOrderStatus(),
506
- Mage::helper('amazonpayments')->__('An authorization of %s has been processed by Amazon Payments (%s). The new status is %s.',
507
- $order->getStore()->convertPrice($authorizationDetails->getAuthorizationAmount()->getAmount(), true, false),
508
- $authorizationDetails->getAmazonAuthorizationId(),
509
- strtoupper($authorizationDetails->getAuthorizationStatus()->getState())
510
- ),
511
- Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE
512
- );
513
- $orderUpdated = true;
514
- }
515
-
516
- $transactionSave = Mage::getModel('core/resource_transaction');
517
- if ($orderUpdated) {
518
- $transactionSave->addObject($order);
519
- $transactionSave->addCommitCallback(array($order, 'save'));
520
- }
521
-
522
- if ($this->_getConfig()->captureImmediately() && $order->canInvoice()) {
523
- $invoice = $order->prepareInvoice()
524
- ->register()
525
- ->capture();
526
- $invoice->setTransactionId($authorizationDetails->getAmazonAuthorizationId());
527
- $transactionSave->addObject($invoice);
528
- $orderUpdated = true;
529
- }
530
-
531
- if ($orderUpdated) {
532
- $transactionSave->save();
533
- }
534
-
535
- if (!$order->getEmailSent() && $this->_getConfig()->sendEmailConfirmation()) {
536
- $order->sendNewOrderEmail();
537
- }
538
-
539
- }
540
- return $newStatus;
541
- }
542
- return null;
543
- }
544
-
545
- /**
546
- * Handle & process declined Amazon's Authorization object
547
- *
548
- * @param Mage_Sales_Model_Order_Payment $payment
549
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
550
- * @param OffAmazonPaymentsService_Model_AuthorizationDetails|OffAmazonPaymentsNotifications_Model_AuthorizationDetails $authorizationDetails
551
- */
552
- protected function _handleDeclinedAuthorization($payment, $transaction, $authorizationDetails) {
553
- if ($authorizationDetails->isSetAuthorizationStatus()) {
554
- $newStatus = $this->_updateTransactionStatus($transaction, $authorizationDetails->getAuthorizationStatus());
555
- if (null !== $newStatus) {
556
- if ($authorizationDetails->getAuthorizationStatus()->getReasonCode() == 'InvalidPaymentMethod') {
557
- Mage::helper('amazonpayments')->sendAuthorizationDeclinedEmail($payment, $authorizationDetails);
558
- }
559
- $this->_addHistoryComment($payment->getOrder(), $transaction, $authorizationDetails->getAuthorizationAmount()->getAmount(), $authorizationDetails->getAuthorizationStatus()->getState())->setIsCustomerNotified(true)->save();
560
- }
561
- return $newStatus;
562
- }
563
- return null;
564
- }
565
-
566
- /**
567
- * Handle & process closed Amazon's Authorization object
568
- *
569
- * @param Mage_Sales_Model_Order_Payment $payment
570
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
571
- * @param OffAmazonPaymentsService_Model_AuthorizationDetails|OffAmazonPaymentsNotifications_Model_AuthorizationDetails $authorizationDetails
572
- */
573
- protected function _handleClosedAuthorization($payment, $transaction, $authorizationDetails) {
574
- if ($authorizationDetails->isSetAuthorizationStatus()) {
575
- $newStatus = $this->_updateTransactionStatus($transaction, $authorizationDetails->getAuthorizationStatus());
576
- if (null !== $newStatus) {
577
- $this->_addHistoryComment($payment->getOrder(), $transaction, $authorizationDetails->getAuthorizationAmount()->getAmount(), $authorizationDetails->getAuthorizationStatus()->getState())->save();
578
- }
579
- return $newStatus;
580
- }
581
- return null;
582
- }
583
-
584
-
585
-
586
- // **********************************************************************
587
- // Capture handling routines
588
-
589
- /**
590
- * Handle & process pending Amazon's Capture object
591
- *
592
- * @param Mage_Sales_Model_Order_Payment $payment
593
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
594
- * @param OffAmazonPaymentsService_Model_CaptureDetails|OffAmazonPaymentsNotifications_Model_CaptureDetails $captureDetails
595
- */
596
- protected function _handlePendingCapture($payment, $transaction, $captureDetails) {
597
- if ($captureDetails->isSetCaptureStatus()) {
598
- $newStatus = $this->_updateTransactionStatus($transaction, $captureDetails->getCaptureStatus());
599
- if (null !== $newStatus) {
600
- $this->_addHistoryComment($payment->getOrder(), $transaction, $captureDetails->getCaptureAmount()->getAmount(), $captureDetails->getCaptureStatus()->getState())->save();
601
- }
602
- return $newStatus;
603
- }
604
- return null;
605
- }
606
-
607
- /**
608
- * Handle & process declined Amazon's Capture object
609
- *
610
- * @param Mage_Sales_Model_Order_Payment $payment
611
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
612
- * @param OffAmazonPaymentsService_Model_CaptureDetails|OffAmazonPaymentsNotifications_Model_CaptureDetails $captureDetails
613
- */
614
- protected function _handleDeclinedCapture($payment, $transaction, $captureDetails) {
615
- if ($captureDetails->isSetCaptureStatus()) {
616
- $newStatus = $this->_updateTransactionStatus($transaction, $captureDetails->getCaptureStatus());
617
- if (null !== $newStatus) {
618
- $this->_addHistoryComment($payment->getOrder(), $transaction, $captureDetails->getCaptureAmount()->getAmount(), $captureDetails->getCaptureStatus()->getState())->save();
619
- }
620
- return $newStatus;
621
- }
622
- return null;
623
- }
624
-
625
- /**
626
- * Handle & process completed Amazon's Capture object
627
- *
628
- * @param Mage_Sales_Model_Order_Payment $payment
629
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
630
- * @param OffAmazonPaymentsService_Model_CaptureDetails|OffAmazonPaymentsNotifications_Model_CaptureDetails $captureDetails
631
- */
632
- protected function _handleCompletedCapture($payment, $transaction, $captureDetails) {
633
- if ($captureDetails->isSetCaptureStatus()) {
634
- $newStatus = $this->_updateTransactionStatus($transaction, $captureDetails->getCaptureStatus());
635
- if (null !== $newStatus) {
636
- $this->_addHistoryComment($payment->getOrder(), $transaction, $captureDetails->getCaptureAmount()->getAmount(), $captureDetails->getCaptureStatus()->getState())->save();
637
- }
638
- return $newStatus;
639
- }
640
- return null;
641
- }
642
-
643
- /**
644
- * Handle & process closed Amazon's Capture object
645
- *
646
- * @param Mage_Sales_Model_Order_Payment $payment
647
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
648
- * @param OffAmazonPaymentsService_Model_CaptureDetails|OffAmazonPaymentsNotifications_Model_CaptureDetails $captureDetails
649
- */
650
- protected function _handleClosedCapture($payment, $transaction, $captureDetails) {
651
- if ($captureDetails->isSetCaptureStatus()) {
652
- $newStatus = $this->_updateTransactionStatus($transaction, $captureDetails->getCaptureStatus());
653
- if (null !== $newStatus) {
654
- $this->_addHistoryComment($payment->getOrder(), $transaction, $captureDetails->getCaptureAmount()->getAmount(), $captureDetails->getCaptureStatus()->getState())->save();
655
- }
656
- return $newStatus;
657
- }
658
- return null;
659
- }
660
-
661
-
662
-
663
- // **********************************************************************
664
- // Refund handling routines
665
-
666
- /**
667
- * Handle & process pending Amazon's Refund object
668
- *
669
- * @param Mage_Sales_Model_Order_Payment $payment
670
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
671
- * @param OffAmazonPaymentsService_Model_RefundDetails|OffAmazonPaymentsNotifications_Model_RefundDetails $refundDetails
672
- */
673
- protected function _handlePendingRefund($payment, $transaction, $refundDetails) {
674
- if ($refundDetails->isSetRefundStatus()) {
675
- $newStatus = $this->_updateTransactionStatus($transaction, $refundDetails->getRefundStatus());
676
- if (null !== $newStatus) {
677
- $this->_addHistoryComment($payment->getOrder(), $transaction, $refundDetails->getRefundAmount()->getAmount(), $refundDetails->getRefundStatus()->getState())->save();
678
- }
679
- return $newStatus;
680
- }
681
- return null;
682
- }
683
-
684
- /**
685
- * Handle & process declined Amazon's Refund object
686
- *
687
- * @param Mage_Sales_Model_Order_Payment $payment
688
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
689
- * @param OffAmazonPaymentsService_Model_RefundDetails|OffAmazonPaymentsNotifications_Model_RefundDetails $refundDetails
690
- */
691
- protected function _handleDeclinedRefund($payment, $transaction, $refundDetails) {
692
- if ($refundDetails->isSetRefundStatus()) {
693
- $newStatus = $this->_updateTransactionStatus($transaction, $refundDetails->getRefundStatus());
694
- if (null !== $newStatus) {
695
- $this->_addHistoryComment($payment->getOrder(), $transaction, $refundDetails->getRefundAmount()->getAmount(), $refundDetails->getRefundStatus()->getState())->save();
696
- }
697
- return $newStatus;
698
- }
699
- return null;
700
- }
701
-
702
- /**
703
- * Handle & process completed Amazon's Refund object
704
- *
705
- * @param Mage_Sales_Model_Order_Payment $payment
706
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
707
- * @param OffAmazonPaymentsService_Model_RefundDetails|OffAmazonPaymentsNotifications_Model_RefundDetails $refundDetails
708
- */
709
- protected function _handleCompletedRefund($payment, $transaction, $refundDetails) {
710
- if ($refundDetails->isSetRefundStatus()) {
711
- $newStatus = $this->_updateTransactionStatus($transaction, $refundDetails->getRefundStatus());
712
- if (null !== $newStatus) {
713
- $this->_addHistoryComment($payment->getOrder(), $transaction, $refundDetails->getRefundAmount()->getAmount(), $refundDetails->getRefundStatus()->getState())->save();
714
- }
715
- return $newStatus;
716
- }
717
- return null;
718
- }
719
-
720
-
721
-
722
- // **********************************************************************
723
- // Public interface
724
-
725
- /**
726
- * Imports payment transaction details
727
- *
728
- * @param Mage_Sales_Model_Order_Payment $payment
729
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
730
- * @return null
731
- */
732
- public function importTransactionDetails($payment, $transaction) {
733
- switch ($transaction->getTxnType()) {
734
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
735
- return $this->importOrderReferenceDetails(
736
- $this->_getApi()->setStore($payment->getOrder()->getStoreId())->getOrderReferenceDetails($transaction->getTxnId()),
737
- $payment,
738
- $transaction
739
- );
740
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
741
- return $this->importAuthorizationDetails(
742
- $this->_getApi()->setStore($payment->getOrder()->getStoreId())->getAuthorizationDetails($transaction->getTxnId()),
743
- $payment,
744
- $transaction,
745
- false
746
- );
747
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
748
- return $this->importCaptureDetails(
749
- $this->_getApi()->setStore($payment->getOrder()->getStoreId())->getCaptureDetails($transaction->getTxnId()),
750
- $payment,
751
- $transaction
752
- );
753
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
754
- return $this->importRefundDetails(
755
- $this->_getApi()->setStore($payment->getOrder()->getStoreId())->getRefundDetails($transaction->getTxnId()),
756
- $payment,
757
- $transaction
758
- );
759
- }
760
- return null;
761
- }
762
-
763
- /**
764
- * Import Amazon's Order Reference object data to Magento entities
765
- *
766
- * @param OffAmazonPaymentsService_Model_OrderReferenceDetails|OffAmazonPaymentsNotifications_Model_OrderReference $orderReferenceDetails
767
- * @param Mage_Sales_Model_Order_Payment $payment
768
- */
769
- public function importOrderReferenceDetails($orderReferenceDetails, $payment = null, $transaction = null) {
770
-
771
- // lookup for the payment if not provided explicitly
772
- if (null === $payment && $orderReferenceDetails->isSetAmazonOrderReferenceId()) {
773
- $payment = $this->_lookupPayment($orderReferenceDetails->getAmazonOrderReferenceId());
774
- }
775
-
776
- // do nothing if payment couldn't be found
777
- if (null !== $payment) {
778
- // lookup for the transaction if not provided explicitly
779
- if (null === $transaction) {
780
- $transaction = $payment->lookupTransaction(
781
- $orderReferenceDetails->getAmazonOrderReferenceId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
782
- );
783
- }
784
- if ($transaction && $orderReferenceDetails->isSetOrderReferenceStatus()) {
785
- $orderReferenceStatus = $orderReferenceDetails->getOrderReferenceStatus();
786
- if ($orderReferenceStatus->isSetState()) {
787
- switch (strtolower($orderReferenceStatus->getState())) {
788
- case 'open':
789
- return $this->_handleOpenOrderReference($payment, $transaction, $orderReferenceDetails);
790
- case 'suspended':
791
- return $this->_handleSuspendedOrderReference($payment, $transaction, $orderReferenceDetails);
792
- case 'canceled':
793
- return $this->_handleCanceledOrderReference($payment, $transaction, $orderReferenceDetails);
794
- case 'closed':
795
- return $this->_handleClosedOrderReference($payment, $transaction, $orderReferenceDetails);
796
- }
797
- }
798
- }
799
- }
800
- return null;
801
- }
802
-
803
- /**
804
- * Import Amazon's Authorization object data to Magento entities
805
- *
806
- * @param OffAmazonPaymentsService_Model_AuthorizationDetails|OffAmazonPaymentsNotifications_Model_AuthorizationDetails $authorizationDetails
807
- * @param Mage_Sales_Model_Order_Payment $payment
808
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
809
- * @param bool $refetchDetails
810
- */
811
- public function importAuthorizationDetails($authorizationDetails, $payment = null, $transaction = null, $refetchDetails = true) {
812
-
813
- // lookup for the payment if not provided explicitly
814
- if (null === $payment && $authorizationDetails->isSetAuthorizationReferenceId()) {
815
- $referenceId = $this->_sanitizeReferenceId($authorizationDetails->getAuthorizationReferenceId());
816
- $payment = $this->_lookupPayment($referenceId);
817
- }
818
-
819
- if (null !== $payment) {
820
- // lookup for the transaction if not provided explicitly
821
- if (null === $transaction) {
822
- $transaction = $payment->lookupTransaction(
823
- $authorizationDetails->getAmazonAuthorizationId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH
824
- );
825
- }
826
- if ($transaction && $authorizationDetails->isSetAuthorizationStatus()) {
827
- $authorizationStatus = $authorizationDetails->getAuthorizationStatus();
828
- if ($authorizationStatus->isSetState()) {
829
- switch (strtolower($authorizationStatus->getState())) {
830
- case 'pending':
831
- return $this->_handlePendingAuthorization($payment, $transaction, $authorizationDetails);
832
- case 'open':
833
- if ($refetchDetails) {
834
- $authorizationDetails = $this->_getApi()->getAuthorizationDetails($authorizationDetails->getAmazonAuthorizationId());
835
- }
836
- return $this->_handleOpenAuthorization($payment, $transaction, $authorizationDetails);
837
- case 'declined':
838
- return $this->_handleDeclinedAuthorization($payment, $transaction, $authorizationDetails);
839
- case 'closed':
840
- return $this->_handleClosedAuthorization($payment, $transaction, $authorizationDetails);
841
- }
842
- }
843
- }
844
- }
845
- return null;
846
- }
847
-
848
- /**
849
- * Import Amazon's Capture object data to Magento entities
850
- *
851
- * @param OffAmazonPaymentsService_Model_CaptureDetails|OffAmazonPaymentsNotifications_Model_CaptureDetails $captureDetails
852
- * @param Mage_Sales_Model_Order_Payment $payment
853
- */
854
- public function importCaptureDetails($captureDetails, $payment = null, $transaction = null) {
855
-
856
- // lookup for the payment if not provided explicitly
857
- if (null === $payment && $captureDetails->isSetCaptureReferenceId()) {
858
- $referenceId = $this->_sanitizeReferenceId($captureDetails->getCaptureReferenceId());
859
- $payment = $this->_lookupPayment($referenceId);
860
- }
861
-
862
- // do nothing if payment couldn't be found
863
- if (null !== $payment) {
864
- // lookup for the transaction if not provided explicitly
865
- if (null === $transaction) {
866
- $transaction = $payment->lookupTransaction(
867
- $captureDetails->getAmazonCaptureId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
868
- );
869
- }
870
- if ($transaction && $captureDetails->isSetCaptureStatus()) {
871
- $captureStatus = $captureDetails->getCaptureStatus();
872
- if ($captureStatus->isSetState()) {
873
- switch (strtolower($captureStatus->getState())) {
874
- case 'pending':
875
- return $this->_handlePendingCapture($payment, $transaction, $captureDetails);
876
- case 'declined':
877
- return $this->_handleDeclinedCapture($payment, $transaction, $captureDetails);
878
- case 'completed':
879
- return $this->_handleCompletedCapture($payment, $transaction, $captureDetails);
880
- case 'closed':
881
- return $this->_handleClosedCapture($payment, $transaction, $captureDetails);
882
- }
883
- }
884
- }
885
- }
886
- return null;
887
- }
888
-
889
- /**
890
- * Import Amazon's Refund object data to Magento entities
891
- *
892
- * @param OffAmazonPaymentsService_Model_RefundDetails|OffAmazonPaymentsNotifications_Model_RefundDetails $refundDetails
893
- * @param Mage_Sales_Model_Order_Payment $payment
894
- */
895
- public function importRefundDetails($refundDetails, $payment = null, $transaction = null) {
896
-
897
- // lookup for the payment if not provided explicitly
898
- if (null === $payment && $refundDetails->isSetRefundReferenceId()) {
899
- $referenceId = $this->_sanitizeReferenceId($refundDetails->getRefundReferenceId());
900
- $payment = $this->_lookupPayment($referenceId);
901
- }
902
-
903
- // do nothing if payment couldn't be found
904
- if (null !== $payment) {
905
- // lookup for the transaction if not provided explicitly
906
- if (null === $transaction) {
907
- $transaction = $payment->lookupTransaction(
908
- $refundDetails->getAmazonRefundId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND
909
- );
910
- }
911
- if ($transaction && $refundDetails->isSetRefundStatus()) {
912
- $refundStatus = $refundDetails->getRefundStatus();
913
- if ($refundStatus->isSetState()) {
914
- switch (strtolower($refundStatus->getState())) {
915
- case 'pending':
916
- return $this->_handlePendingRefund($payment, $transaction, $refundDetails);
917
- case 'declined':
918
- return $this->_handleDeclinedRefund($payment, $transaction, $refundDetails);
919
- case 'completed':
920
- return $this->_handleCompletedRefund($payment, $transaction, $refundDetails);
921
- }
922
- }
923
- }
924
- }
925
- return null;
926
- }
927
-
928
- /**
929
- * Process a notification message requested via IPN
930
- *
931
- * @param OffAmazonPaymentNotifications_Notification $notification
932
- */
933
- public function processNotification($notification = null) {
934
- if (null !== $notification) {
935
- switch ($notification->getNotificationType()) {
936
- case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_ORDER_REFERENCE:
937
- if ($notification->isSetOrderReference()) {
938
- $transactionStatus = $this->importOrderReferenceDetails($notification->getOrderReference());
939
- if (null !== $transactionStatus) {
940
- $payment = $this->_lookupPayment($notification->getOrderReference()->getAmazonOrderReferenceId());
941
- if ($payment) {
942
- $transaction = $payment->lookupTransaction(
943
- $notification->getOrderReference()->getAmazonOrderReferenceId(),
944
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
945
- );
946
- if ($transaction) {
947
- $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
948
- $transaction->save();
949
- }
950
- }
951
- }
952
- } else {
953
- throw new Creativestyle_AmazonPayments_Exception('OrderReference field not found in submitted notification');
954
- }
955
- break;
956
- case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_AUTHORIZATION:
957
- if ($notification->isSetAuthorizationDetails()) {
958
- $transactionStatus = $this->importAuthorizationDetails($notification->getAuthorizationDetails());
959
- if (null !== $transactionStatus) {
960
- $referenceId = $this->_sanitizeReferenceId($notification->getAuthorizationDetails()->getAuthorizationReferenceId());
961
- $payment = $this->_lookupPayment($referenceId);
962
- if ($payment) {
963
- $transaction = $payment->lookupTransaction(
964
- $notification->getAuthorizationDetails()->getAmazonAuthorizationId(),
965
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH
966
- );
967
- if ($transaction) {
968
- $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
969
- $transaction->save();
970
- }
971
- }
972
- }
973
- } else {
974
- throw new Creativestyle_AmazonPayments_Exception('AuthorizationDetails field not found in submitted notification');
975
- }
976
- break;
977
- case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_CAPTURE:
978
- if ($notification->isSetCaptureDetails()) {
979
- $transactionStatus = $this->importCaptureDetails($notification->getCaptureDetails());
980
- if (null !== $transactionStatus) {
981
- $referenceId = $this->_sanitizeReferenceId($notification->getCaptureDetails()->getCaptureReferenceId());
982
- $payment = $this->_lookupPayment($referenceId);
983
- if ($payment) {
984
- $transaction = $payment->lookupTransaction(
985
- $notification->getCaptureDetails()->getAmazonCaptureId(),
986
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
987
- );
988
- if ($transaction) {
989
- $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
990
- $transaction->save();
991
- }
992
- }
993
- }
994
- } else {
995
- throw new Creativestyle_AmazonPayments_Exception('CaptureDetails field not found in submitted notification');
996
- }
997
- break;
998
- case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_REFUND:
999
- if ($notification->isSetRefundDetails()) {
1000
- $transactionStatus = $this->importRefundDetails($notification->getRefundDetails());
1001
- if (null !== $transactionStatus) {
1002
- $referenceId = $this->_sanitizeReferenceId($notification->getRefundDetails()->getRefundReferenceId());
1003
- $payment = $this->_lookupPayment($referenceId);
1004
- if ($payment) {
1005
- $transaction = $payment->lookupTransaction(
1006
- $notification->getRefundDetails()->getAmazonRefundId(),
1007
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND
1008
- );
1009
- if ($transaction) {
1010
- $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
1011
- $transaction->save();
1012
- }
1013
- }
1014
- }
1015
- } else {
1016
- throw new Creativestyle_AmazonPayments_Exception('RefundDetails field not found in submitted notification');
1017
- }
1018
- break;
1019
- default:
1020
- throw new Creativestyle_AmazonPayments_Exception('Wrong Notification type');
1021
- }
1022
- } else {
1023
- throw new Creativestyle_AmazonPayments_Exception('No notification data provided');
1024
- }
1025
- }
1026
-
1027
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Creativestyle/AmazonPayments/Model/Mapper.php DELETED
@@ -1,162 +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_Mapper {
17
-
18
- /**
19
- * Check whether provided address lines contain PO Box data
20
- */
21
- protected function _isPoBox($addressLine1, $addressLine2 = null) {
22
- if (is_numeric($addressLine1)) {
23
- return true;
24
- }
25
- if (strpos(strtolower($addressLine1), 'packstation') !== false) {
26
- return true;
27
- }
28
- if (strpos(strtolower($addressLine2), 'packstation') !== false) {
29
- return true;
30
- }
31
- return false;
32
- }
33
-
34
- /**
35
- * Convert Amazon AddressLine fields to the array indexed with the same
36
- * keys Magento order address entities are using. Try to guess if address
37
- * lines contain company name or PO Box
38
- *
39
- * @param string $addressLine1
40
- * @param string $addressLine2
41
- * @param string $addressLine3
42
- * @param string $countryId
43
- *
44
- * @return array
45
- */
46
- protected function _mapAmazonAddressLines($addressLine1, $addressLine2 = null, $addressLine3 = null, $countryId = null) {
47
- $data = array('street' => array());
48
- if ($countryId && in_array($countryId, array('DE', 'AT'))) {
49
- if ($addressLine3) {
50
- if ($this->_isPoBox($addressLine1, $addressLine2)) {
51
- $data['street'][] = $addressLine1;
52
- $data['street'][] = $addressLine2;
53
- } else {
54
- $data['company'] = trim($addressLine1 . ' ' . $addressLine2);
55
- }
56
- $data['street'][] = $addressLine3;
57
- } else if ($addressLine2) {
58
- if ($this->_isPoBox($addressLine1)) {
59
- $data['street'][] = $addressLine1;
60
- } else {
61
- $data['company'] = $addressLine1;
62
- }
63
- $data['street'][] = $addressLine2;
64
- } else {
65
- $data['street'][] = $addressLine1;
66
- }
67
- } else {
68
- if ($addressLine1) {
69
- $data['street'][] = $addressLine1;
70
- }
71
- if ($addressLine2) {
72
- $data['street'][] = $addressLine2;
73
- }
74
- if ($addressLine3) {
75
- $data['street'][] = $addressLine3;
76
- }
77
- }
78
- return $data;
79
- }
80
-
81
- /**
82
- * Convert address object from Amazon Payments API response to Varien_Object
83
- * indexed with the same keys Magento order address entities are using
84
- *
85
- * @param OffAmazonPaymentsService_Model_Address $amazonAddress
86
- *
87
- * @return Varien_Object
88
- */
89
- public function mapAmazonAddress($amazonAddress) {
90
- $data = $this->_mapAmazonAddressLines(
91
- $amazonAddress->getAddressLine1(),
92
- $amazonAddress->getAddressLine2(),
93
- $amazonAddress->getAddressLine3(),
94
- $amazonAddress->getCountryCode()
95
- );
96
- $explodedName = Mage::helper('amazonpayments')->explodeCustomerName($amazonAddress->getName());
97
- $data['firstname'] = $explodedName->getFirstname();
98
- $data['lastname'] = $explodedName->getLastname();
99
- $data['country_id'] = $amazonAddress->getCountryCode();
100
- $data['city'] = $amazonAddress->getCity();
101
- $data['postcode'] = $amazonAddress->getPostalCode();
102
- $data['telephone'] = $amazonAddress->getPhone();
103
- return new Varien_Object($data);
104
- }
105
-
106
- /**
107
- * Convert transaction info object to Varien_Object indexed with
108
- * the same keys as Magento order entity is
109
- *
110
- * @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionInfo
111
- *
112
- * @return Varien_Object
113
- */
114
- public function mapTransactionInfo($transactionInfo) {
115
- $data = array();
116
- // OrderReferenceDetails from API response
117
- if ($transactionInfo instanceof OffAmazonPaymentsService_Model_OrderReferenceDetails) {
118
- if ($transactionInfo->isSetBuyer()) {
119
- $data['customer_email'] = $transactionInfo->getBuyer()->getEmail();
120
- $customerName = Mage::helper('amazonpayments')->explodeCustomerName($transactionInfo->getBuyer()->getName(), null);
121
- $data['customer_firstname'] = $customerName->getFirstname();
122
- $data['customer_lastname'] = $customerName->getLastname();
123
- }
124
- if ($transactionInfo->isSetDestination()) {
125
- if ($transactionInfo->getDestination()->isSetPhysicalDestination()) {
126
- $data['shipping_address'] = $this->mapAmazonAddress($transactionInfo->getDestination()->getPhysicalDestination());
127
- }
128
- }
129
- if ($transactionInfo->isSetBillingAddress()) {
130
- if ($transactionInfo->getBillingAddress()->isSetPhysicalAddress()) {
131
- $data['billing_address'] = $this->mapAmazonAddress($transactionInfo->getBillingAddress()->getPhysicalAddress());
132
- $data['customer_firstname'] = $data['billing_address']->getFirstname();
133
- $data['customer_lastname'] = $data['billing_address']->getLastname();
134
- }
135
- } elseif (isset($data['shipping_address'])) {
136
- $data['billing_address'] = $data['shipping_address'];
137
- }
138
- }
139
- // OrderReference from OrderReferenceNotification
140
- elseif ($transactionInfo instanceof OffAmazonPaymentsNotifications_Model_OrderReference) {}
141
- // AuthorizationDetails from API response
142
- elseif ($transactionInfo instanceof OffAmazonPaymentsService_Model_AuthorizationDetails) {
143
- if ($transactionInfo->isSetAuthorizationBillingAddress()) {
144
- $data['billing_address'] = $this->mapAmazonAddress($transactionInfo->getAuthorizationBillingAddress());
145
- $data['customer_firstname'] = $data['billing_address']->getFirstname();
146
- $data['customer_lastname'] = $data['billing_address']->getLastname();
147
- }
148
- }
149
- // AuthorizationDetails from AuthorizationNotification
150
- elseif ($transactionInfo instanceof OffAmazonPaymentsNotifications_Model_AuthorizationDetails) {}
151
- // CaptureDetails from API response
152
- elseif ($transactionInfo instanceof OffAmazonPaymentsService_Model_CaptureDetails) {}
153
- // CaptureDetails from CaptureNotification
154
- elseif ($transactionInfo instanceof OffAmazonPaymentsNotifications_Model_CaptureDetails) {}
155
- // RefundDetails from API response
156
- elseif ($transactionInfo instanceof OffAmazonPaymentsService_Model_RefundDetails) {}
157
- // RefundDetails from RefundNotification
158
- elseif ($transactionInfo instanceof OffAmazonPaymentsNotifications_Model_RefundDetails) {}
159
- return new Varien_Object($data);
160
- }
161
-
162
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Creativestyle/AmazonPayments/Model/Observer.php CHANGED
@@ -66,19 +66,19 @@ class Creativestyle_AmazonPayments_Model_Observer {
66
  try {
67
  $txnType = $transaction->getTxnType();
68
  switch (Mage::helper('amazonpayments')->getTransactionStatus($transaction)) {
69
- case Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_PENDING:
70
  $recentTransactionId = $this->_fetchTransactionInfo($transaction)->getId();
71
  $count++;
72
  usleep(self::DATA_POLL_SLEEP_BETWEEN_TIME);
73
  break;
74
- case Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_SUSPENDED:
75
  if ($txnType == Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER) {
76
  $recentTransactionId = $this->_fetchTransactionInfo($transaction)->getId();
77
  $count++;
78
  usleep(self::DATA_POLL_SLEEP_BETWEEN_TIME);
79
  }
80
  break;
81
- case Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_OPEN:
82
  $txnAge = floor(($dateModel->timestamp() - $dateModel->timestamp($transaction->getCreatedAt())) / (60 * 60 * 24));
83
  if (($txnType == Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER && $txnAge > 180) ||
84
  ($txnType == Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH && $txnAge > 30)) {
@@ -111,22 +111,22 @@ class Creativestyle_AmazonPayments_Model_Observer {
111
  }
112
 
113
  protected function _shouldUpdateParentTransaction($transaction) {
114
- switch ($transaction->getTxnType()) {
115
  case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
116
  return in_array(Mage::helper('amazonpayments')->getTransactionStatus($transaction), array(
117
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_DECLINED,
118
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_CLOSED
119
  ));
120
  case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
121
  return in_array(Mage::helper('amazonpayments')->getTransactionStatus($transaction), array(
122
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_COMPLETED,
123
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_DECLINED,
124
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_CLOSED
125
  ));
126
  case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
127
  return in_array(Mage::helper('amazonpayments')->getTransactionStatus($transaction), array(
128
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_COMPLETED,
129
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_DECLINED
130
  ));
131
  }
132
  return false;
@@ -135,6 +135,7 @@ class Creativestyle_AmazonPayments_Model_Observer {
135
  protected function _updateParentTransaction($transaction) {
136
  if ($this->_shouldUpdateParentTransaction($transaction)) {
137
  if ($parentTransaction = $transaction->getParentTransaction()) {
 
138
  $this->_fetchTransactionInfo($parentTransaction);
139
  }
140
  }
@@ -231,10 +232,10 @@ class Creativestyle_AmazonPayments_Model_Observer {
231
  $transaction = $observer->getEvent()->getOrderPaymentTransaction();
232
  if ($transaction->getId() && in_array($transaction->getOrderPaymentObject()->getMethod(), Mage::helper('amazonpayments')->getAvailablePaymentMethods())) {
233
  if (in_array(Mage::helper('amazonpayments')->getTransactionStatus($transaction), array(
234
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_DECLINED,
235
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_COMPLETED,
236
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_CANCELED,
237
- Creativestyle_AmazonPayments_Model_Payment_Abstract::TRANSACTION_STATE_CLOSED
238
  ))) {
239
  $transaction->setIsClosed(true);
240
  }
66
  try {
67
  $txnType = $transaction->getTxnType();
68
  switch (Mage::helper('amazonpayments')->getTransactionStatus($transaction)) {
69
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_PENDING:
70
  $recentTransactionId = $this->_fetchTransactionInfo($transaction)->getId();
71
  $count++;
72
  usleep(self::DATA_POLL_SLEEP_BETWEEN_TIME);
73
  break;
74
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_SUSPENDED:
75
  if ($txnType == Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER) {
76
  $recentTransactionId = $this->_fetchTransactionInfo($transaction)->getId();
77
  $count++;
78
  usleep(self::DATA_POLL_SLEEP_BETWEEN_TIME);
79
  }
80
  break;
81
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_OPEN:
82
  $txnAge = floor(($dateModel->timestamp() - $dateModel->timestamp($transaction->getCreatedAt())) / (60 * 60 * 24));
83
  if (($txnType == Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER && $txnAge > 180) ||
84
  ($txnType == Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH && $txnAge > 30)) {
111
  }
112
 
113
  protected function _shouldUpdateParentTransaction($transaction) {
114
+ switch ($transaction->getTxnType() && !$transaction->getData('skip_update_parent_transaction')) {
115
  case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
116
  return in_array(Mage::helper('amazonpayments')->getTransactionStatus($transaction), array(
117
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED,
118
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED
119
  ));
120
  case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
121
  return in_array(Mage::helper('amazonpayments')->getTransactionStatus($transaction), array(
122
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_COMPLETED,
123
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED,
124
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED
125
  ));
126
  case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
127
  return in_array(Mage::helper('amazonpayments')->getTransactionStatus($transaction), array(
128
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_COMPLETED,
129
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED
130
  ));
131
  }
132
  return false;
135
  protected function _updateParentTransaction($transaction) {
136
  if ($this->_shouldUpdateParentTransaction($transaction)) {
137
  if ($parentTransaction = $transaction->getParentTransaction()) {
138
+ $transaction->setData('skip_update_parent_transaction', true);
139
  $this->_fetchTransactionInfo($parentTransaction);
140
  }
141
  }
232
  $transaction = $observer->getEvent()->getOrderPaymentTransaction();
233
  if ($transaction->getId() && in_array($transaction->getOrderPaymentObject()->getMethod(), Mage::helper('amazonpayments')->getAvailablePaymentMethods())) {
234
  if (in_array(Mage::helper('amazonpayments')->getTransactionStatus($transaction), array(
235
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED,
236
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_COMPLETED,
237
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CANCELED,
238
+ Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED
239
  ))) {
240
  $transaction->setIsClosed(true);
241
  }
app/code/community/Creativestyle/AmazonPayments/Model/Payment/Abstract.php CHANGED
@@ -20,22 +20,6 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
20
  const ACTION_AUTHORIZE_CAPTURE = 'authorize_capture';
21
  const ACTION_ERP = 'erp';
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
-
36
- const TRANSACTION_STATE_KEY = 'State';
37
- const TRANSACTION_REASON_KEY = 'ReasonCode';
38
-
39
  const CHECK_USE_FOR_COUNTRY = 1;
40
  const CHECK_USE_FOR_CURRENCY = 2;
41
  const CHECK_USE_CHECKOUT = 4;
@@ -80,13 +64,22 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
80
  return Mage::getSingleton('amazonpayments/config');
81
  }
82
 
 
 
 
 
 
 
 
 
 
83
  /**
84
  * Return Amazon Payments processor instance
85
  *
86
- * @return Creativestyle_AmazonPayments_Model_Processor
87
  */
88
  protected function _getPaymentProcessor() {
89
- return Mage::getSingleton('amazonpayments/processor');
90
  }
91
 
92
  /**
@@ -104,24 +97,6 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
104
  return $this;
105
  }
106
 
107
- /**
108
- * @param Varien_Object $stateObject
109
- * @param Varien_Object $order
110
- *
111
- * @return Creativestyle_AmazonPayments_Model_Payment_Abstract
112
- */
113
- protected function _initStateObject(&$stateObject = null, $order = null) {
114
- if (null === $stateObject) {
115
- $stateObject = new Varien_Object();
116
- }
117
- $stateObject->setData(array(
118
- 'state' => $order ? $order->getState() : Mage_Sales_Model_Order::STATE_NEW,
119
- 'status' => $order ? $order->getStatus() : $this->_getConfig()->getNewOrderStatus($this->getStore()),
120
- 'is_notified' => Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE
121
- ));
122
- return $this;
123
- }
124
-
125
  protected function _getPaymentSequenceId() {
126
  $sequenceNumber = $this->getInfoInstance()->getAdditionalInformation('amazon_sequence_number');
127
  $sequenceNumber = is_null($sequenceNumber) ? 1 : ++$sequenceNumber;
@@ -129,167 +104,6 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
129
  return sprintf('%s-%s', $this->getInfoInstance()->getOrder()->getExtOrderId(), $sequenceNumber);
130
  }
131
 
132
- /**
133
- * @param array $transactionStatus
134
- * @param array $allowedTransactionStates
135
- *
136
- * @return bool|array
137
- */
138
- protected function _validateTransactionStatus($transactionStatus, $allowedTransactionStates) {
139
- if (!is_array($transactionStatus)) return false;
140
- if (!array_key_exists(self::TRANSACTION_STATE_KEY, $transactionStatus)) return false;
141
- if (!in_array($transactionStatus[self::TRANSACTION_STATE_KEY], $allowedTransactionStates)) {
142
- return false;
143
- }
144
- return $transactionStatus;
145
- }
146
-
147
- /**
148
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
149
- * @param array $transactionStatus
150
- * @param Varien_Object $stateObject
151
- * @param float $amount
152
- * @param bool $initialRequest
153
- *
154
- * @return Creativestyle_AmazonPayments_Model_Payment_Abstract
155
- */
156
- protected function _mapTransactionStatus($transaction, $transactionStatus, $stateObject, $amount, $initialRequest = false) {
157
- switch ($transaction->getTxnType()) {
158
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
159
- switch ($transactionStatus[self::TRANSACTION_STATE_KEY]) {
160
- case self::TRANSACTION_STATE_OPEN:
161
- $this->_initStateObject($stateObject);
162
- break; // self::TRANSACTION_STATE_OPEN
163
-
164
- case self::TRANSACTION_STATE_CANCELED:
165
- case self::TRANSACTION_STATE_CLOSED:
166
- $this->getInfoInstance()->getOrder()->addRelatedObject($transaction->setIsClosed(true));
167
- break; // self::TRANSACTION_STATE_CANCELED / self::TRANSACTION_STATE_CLOSED
168
- }
169
- $message = $initialRequest ?
170
- 'An order of %s has been sent to Amazon Payments (%s). The current status is %s.' :
171
- 'An order of %s has been processed by Amazon Payments (%s). The new status is %s.';
172
- break; // Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
173
-
174
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
175
- switch ($transactionStatus[self::TRANSACTION_STATE_KEY]) {
176
- case self::TRANSACTION_STATE_OPEN:
177
- $stateObject->setData(array(
178
- 'state' => Mage_Sales_Model_Order::STATE_PROCESSING,
179
- 'status' => $this->_getConfig()->getAuthorizedOrderStatus($this->getStore())
180
- ));
181
- break; // self::TRANSACTION_STATE_OPEN
182
-
183
- case self::TRANSACTION_STATE_DECLINED:
184
- $stateObject->setData(array(
185
- 'hold_before_state' => $stateObject->getState(),
186
- 'hold_before_status' => $stateObject->getStatus(),
187
- 'state' => Mage_Sales_Model_Order::STATE_HOLDED,
188
- 'status' => $this->_getConfig()->getHoldedOrderStatus($this->getStore())
189
- ));
190
- break; // self::TRANSACTION_STATE_DECLINED
191
- }
192
- $message = $initialRequest ?
193
- 'An authorize request for %s has been submitted to Amazon Payments (%s). The current status is %s.' :
194
- 'An authorization of %s has been processed by Amazon Payments (%s). The new status is %s.';
195
- break; // Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH
196
-
197
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
198
- switch ($transactionStatus[self::TRANSACTION_STATE_KEY]) {
199
- case self::TRANSACTION_STATE_DECLINED:
200
- $stateObject->setData(array(
201
- 'hold_before_state' => $stateObject->getState(),
202
- 'hold_before_status' => $stateObject->getStatus(),
203
- 'state' => Mage_Sales_Model_Order::STATE_HOLDED,
204
- 'status' => $this->_getConfig()->getHoldedOrderStatus($this->getStore())
205
- ));
206
- break; // self::TRANSACTION_STATE_DECLINED
207
- case self::TRANSACTION_STATE_COMPLETED:
208
- $this->getInfoInstance()->getOrder()->addRelatedObject($transaction->setIsClosed(true));
209
- break; // self::TRANSACTION_STATE_COMPLETED
210
- }
211
- $message = $initialRequest ?
212
- 'A capture request for %s has been submitted to Amazon Payments (%s). The current status is %s.' :
213
- 'A capture of %s has been processed by Amazon Payments (%s). The new status is %s.';
214
- break; // Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
215
-
216
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
217
- $message = $initialRequest ?
218
- 'A refund request for %s has been submitted to Amazon Payments (%s). The current status is %s.' :
219
- 'A refund of %s has been processed by Amazon Payments (%s). The new status is %s.';
220
- break; // Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND
221
-
222
- default:
223
- return $this;
224
- }
225
-
226
- $stateObject->setMessage(Mage::helper('amazonpayments')->__($message,
227
- $this->getInfoInstance()->getOrder()->getBaseCurrency()->formatTxt($amount),
228
- $transaction->getTxnId(),
229
- sprintf('<strong>%s</strong>', strtoupper($transactionStatus[self::TRANSACTION_STATE_KEY]))
230
- ));
231
-
232
- return $this;
233
- }
234
-
235
- /**
236
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
237
- * @param array $transactionStatus
238
- * @param Varien_Object $stateObject
239
- *
240
- * @return Creativestyle_AmazonPayments_Model_Payment_Abstract
241
- */
242
- protected function _sendTransactionEmails($transaction, $transactionStatus, $stateObject) {
243
- switch ($transaction->getTxnType()) {
244
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
245
- switch ($transactionStatus[self::TRANSACTION_STATE_KEY]) {
246
- case self::TRANSACTION_STATE_OPEN:
247
- if ($this->getInfoInstance()->getOrder() && !$this->getInfoInstance()->getOrder()->getEmailSent() && $this->_getConfig()->sendEmailConfirmation($this->getStore())) {
248
- $this->getInfoInstance()->getOrder()->sendNewOrderEmail();
249
- $stateObject->setIsNotified(true);
250
- }
251
- break;
252
- case self::TRANSACTION_STATE_DECLINED:
253
- if ($this->getInfoInstance()->getOrder() && $transactionStatus[self::TRANSACTION_REASON_KEY] == 'InvalidPaymentMethod') {
254
- Mage::helper('amazonpayments')->sendAuthorizationDeclinedEmail($this->getInfoInstance());
255
- $stateObject->setIsNotified(true);
256
- }
257
- break;
258
- }
259
- break; // Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH
260
-
261
- default:
262
- return $this;
263
- }
264
-
265
- return $this;
266
- }
267
-
268
- /**
269
- * @param Varien_Object $stateObject
270
- *
271
- * @return Creativestyle_AmazonPayments_Model_Payment_Abstract
272
- */
273
- protected function _updateOrderStatus($stateObject) {
274
- $this->getInfoInstance()->getOrder()
275
- ->setHoldBeforeState($stateObject->getHoldBeforeState() ? $stateObject->getHoldBeforeState() : null)
276
- ->setHoldBeforeStatus($stateObject->getHoldBeforeStatus() ? $stateObject->getHoldBeforeStatus() : null)
277
- ->setState(
278
- $stateObject->getState(),
279
- $stateObject->getStatus(),
280
- $stateObject->getMessage(),
281
- $stateObject->getIsNotified()
282
- );
283
- return $this;
284
- }
285
-
286
- public function saveOrder($order) {
287
- if ($order->hasDataChanges()) {
288
- $order->save();
289
- }
290
- return $this;
291
- }
292
-
293
  /**
294
  * Check authorise availability
295
  *
@@ -402,22 +216,22 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
402
  *
403
  * @param Mage_Payment_Model_Info $payment
404
  * @param string $transactionId
405
- * @param bool $saveOrder
406
  *
407
- * @return array
408
  */
409
  public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId, $shouldSave = true) {
410
  $this->_initInfoInstance($payment);
411
  if ($transaction = $payment->lookupTransaction($transactionId)) {
412
- $transactionInfo = $this->_getPaymentProcessor()->importTransactionDetails($payment, $transaction);
413
- if ($transactionInfo) {
414
- $this->_initStateObject($stateObject, $payment->getOrder())
415
- ->_mapTransactionStatus($transaction, $transactionInfo, $stateObject, $payment->getOrder()->getBaseTotalDue())
416
- ->_sendTransactionEmails($transaction, $transactionInfo, $stateObject)
417
- ->_updateOrderStatus($stateObject);
418
- if ($shouldSave) $this->saveOrder($payment->getOrder());
419
  }
420
- return $transactionInfo;
421
  }
422
  throw new Creativestyle_AmazonPayments_Exception('Transaction not found');
423
  }
@@ -444,14 +258,10 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
444
  if (!$this->canOrder()) {
445
  throw new Creativestyle_AmazonPayments_Exception('Order action is not available');
446
  }
447
- if ($this->getInfoInstance()->getSkipOrderReferenceProcessing()) {
448
- $this->_getPaymentProcessor()->orderConfirm($this->getInfoInstance(), $this->getInfoInstance()->getTransactionId());
449
- } else {
450
- $this->_getPaymentProcessor()->order($this->getInfoInstance(), $amount, $this->getInfoInstance()->getTransactionId());
451
- }
452
  $transaction = $this->getInfoInstance()->setIsTransactionClosed(false)
453
  ->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
454
- return $this->_getPaymentProcessor()->importTransactionDetails($this->getInfoInstance(), $transaction);
455
  }
456
 
457
  /**
@@ -464,22 +274,22 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
464
  *
465
  * @return array|null
466
  */
467
- protected function _authorize($amount, $parentTransactionId, &$transaction = null, $captureNow = false) {
468
  if (!$this->canAuthorize()) {
469
  throw new Creativestyle_AmazonPayments_Exception('Authorize action is not available');
470
  }
471
  $authorizationDetails = $this->_getPaymentProcessor()->authorize(
472
- $this->getInfoInstance(),
473
  $amount,
474
  $this->_getPaymentSequenceId(),
475
  $parentTransactionId,
476
- $captureNow
 
477
  );
478
  $transaction = $this->getInfoInstance()->setIsTransactionClosed(false)
479
  ->setTransactionId($authorizationDetails->getAmazonAuthorizationId())
480
  ->setParentTransactionId($parentTransactionId)
481
  ->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
482
- return $this->_getPaymentProcessor()->importTransactionDetails($this->getInfoInstance(), $transaction);
483
  }
484
 
485
  /**
@@ -496,7 +306,6 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
496
  throw new Creativestyle_AmazonPayments_Exception('Capture action is not available');
497
  }
498
  $captureDetails = $this->_getPaymentProcessor()->capture(
499
- $this->getInfoInstance(),
500
  $amount,
501
  $this->_getPaymentSequenceId(),
502
  $parentTransactionId
@@ -505,7 +314,32 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
505
  ->setTransactionId($captureDetails->getAmazonCaptureId())
506
  ->setParentTransactionId($parentTransactionId)
507
  ->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
508
- return $this->_getPaymentProcessor()->importTransactionDetails($this->getInfoInstance(), $transaction, $captureDetails);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
509
  }
510
 
511
  /**
@@ -518,20 +352,10 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
518
  */
519
  public function order(Varien_Object $payment, $amount) {
520
  $this->_initInfoInstance($payment);
521
-
522
- $orderReferenceStatus = $this->_validateTransactionStatus(
523
- $this->_order($amount, $orderReferenceTransaction),
524
- array(self::TRANSACTION_STATE_OPEN)
525
- );
526
- if (!$orderReferenceStatus) {
527
- throw new Creativestyle_AmazonPayments_Exception('Invalid OrderReference status returned by Amazon Payments API.');
528
- }
529
-
530
- $this->_initStateObject($stateObject)
531
- ->_mapTransactionStatus($orderReferenceTransaction, $orderReferenceStatus, $stateObject, $amount, true)
532
- ->_sendTransactionEmails($orderReferenceTransaction, $orderReferenceStatus, $stateObject)
533
- ->_updateOrderStatus($stateObject);
534
-
535
  return $this;
536
  }
537
 
@@ -545,32 +369,18 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
545
  */
546
  public function authorize(Varien_Object $payment, $amount) {
547
  $this->_initInfoInstance($payment);
548
-
549
- if ($orderReferenceTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER)) {
550
- $authorizationStatus = $this->_authorize($amount, $orderReferenceTransaction->getTxnId(), $authorizationTransaction, $this->getConfigData('payment_action') == self::ACTION_AUTHORIZE_CAPTURE);
551
- if (!$this->_validateTransactionStatus($authorizationStatus, array(self::TRANSACTION_STATE_PENDING, self::TRANSACTION_STATE_OPEN))) {
552
- if (is_array($authorizationStatus) && array_key_exists(self::TRANSACTION_STATE_KEY, $authorizationStatus)
553
- && $authorizationStatus[self::TRANSACTION_STATE_KEY] == self::TRANSACTION_STATE_DECLINED
554
- && array_key_exists(self::TRANSACTION_REASON_KEY, $authorizationStatus))
555
- {
556
- switch ($authorizationStatus[self::TRANSACTION_REASON_KEY]) {
557
- case self::TRANSACTION_REASON_INVALID_PAYMENT:
558
- throw new Creativestyle_AmazonPayments_Exception_InvalidStatus_Recoverable('Invalid Authorization status returned by Amazon Payments API.');
559
- case self::TRANSACTION_REASON_AMAZON_REJECTED:
560
- case self::TRANSACTION_REASON_TIMEOUT:
561
- throw new Creativestyle_AmazonPayments_Exception_InvalidStatus('Invalid Authorization status returned by Amazon Payments API.');
562
- }
563
-
564
- }
565
- throw new Creativestyle_AmazonPayments_Exception('Invalid Authorization status returned by Amazon Payments API.');
566
- }
567
-
568
- $this->_initStateObject($stateObject, $payment->getOrder())
569
- ->_mapTransactionStatus($authorizationTransaction, $authorizationStatus, $stateObject, $amount, true)
570
- ->_sendTransactionEmails($authorizationTransaction, $authorizationStatus, $stateObject)
571
- ->_updateOrderStatus($stateObject);
572
  }
573
-
574
  return $this;
575
  }
576
 
@@ -584,33 +394,28 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
584
  */
585
  public function capture(Varien_Object $payment, $amount) {
586
  $this->_initInfoInstance($payment);
587
-
588
  if ($authorizationTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)) {
589
- $captureStatus = $this->_validateTransactionStatus(
590
- $this->_capture($amount, $authorizationTransaction->getTxnId(), $captureTransaction),
591
- array(self::TRANSACTION_STATE_COMPLETED)
 
 
592
  );
593
- if (!$captureStatus) {
594
- throw new Creativestyle_AmazonPayments_Exception('Amazon Payments API returned such a Capture status that further payment processing is not allowed.');
595
- }
596
- $this->_initStateObject($stateObject, $payment->getOrder())
597
- ->_mapTransactionStatus($captureTransaction, $captureStatus, $stateObject, $amount, true)
598
- ->_sendTransactionEmails($captureTransaction, $captureStatus, $stateObject)
599
- ->_updateOrderStatus($stateObject)
600
- ->saveOrder($payment->getOrder());
601
-
602
  // avoid transaction duplicates
603
  $payment->setSkipTransactionCreation(true);
604
  }
605
-
606
  return $this;
607
  }
608
 
609
  /**
610
  * @todo
611
  * Set capture transaction ID to invoice for informational purposes
 
612
  * @param Mage_Sales_Model_Order_Invoice $invoice
613
  * @param Mage_Sales_Model_Order_Payment $payment
 
614
  * @return Mage_Payment_Model_Method_Abstract
615
  */
616
  public function processInvoice($invoice, $payment) {
@@ -629,8 +434,16 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
629
  */
630
  public function refund(Varien_Object $payment, $amount) {
631
  $this->_initInfoInstance($payment);
632
- if (!$this->canRefund()) {
633
- throw new Creativestyle_AmazonPayments_Exception('Refund action is not available');
 
 
 
 
 
 
 
 
634
  }
635
  return $this;
636
  }
@@ -708,70 +521,32 @@ abstract class Creativestyle_AmazonPayments_Model_Payment_Abstract extends Mage_
708
  public function initialize($paymentAction, $stateObject) {
709
  $payment = $this->getInfoInstance();
710
  $this->setStore($payment->getOrder()->getStoreId());
711
- $this->_initStateObject($stateObject);
712
  switch ($paymentAction) {
713
  case self::ACTION_MANUAL:
714
-
715
- // OrderReference confirm, throw an exception for invalid statuses
716
- $orderReferenceStatus = $this->_validateTransactionStatus(
717
- $this->_order($this->getInfoInstance()->getOrder()->getBaseTotalDue(), $orderReferenceTransaction),
718
- array(self::TRANSACTION_STATE_OPEN)
719
- );
720
- if (!$orderReferenceStatus) {
721
- throw new Creativestyle_AmazonPayments_Exception('Invalid Order Reference status returned by Amazon Payments API.');
722
- }
723
-
724
- $this->_mapTransactionStatus($orderReferenceTransaction, $orderReferenceStatus, $stateObject, $this->getInfoInstance()->getOrder()->getBaseTotalDue(), true)
725
- ->_sendTransactionEmails($orderReferenceTransaction, $orderReferenceStatus, $stateObject)
726
- ->_updateOrderStatus($stateObject);
727
-
728
  break;
729
-
730
  case self::ACTION_AUTHORIZE:
731
  case self::ACTION_AUTHORIZE_CAPTURE:
732
-
733
- // OrderReference confirm, throw an exception if invalid status is returned
734
- $orderReferenceStatus = $this->_validateTransactionStatus(
735
- $this->_order($this->getInfoInstance()->getOrder()->getBaseTotalDue(), $orderReferenceTransaction),
736
- array(self::TRANSACTION_STATE_OPEN)
 
 
 
 
 
 
 
 
737
  );
738
- if (!$orderReferenceStatus) {
739
- throw new Creativestyle_AmazonPayments_Exception('Invalid Order Reference status returned by Amazon Payments API.');
740
- }
741
-
742
- $this->_mapTransactionStatus($orderReferenceTransaction, $orderReferenceStatus, $stateObject, $this->getInfoInstance()->getOrder()->getBaseTotalDue(), true)
743
- ->_sendTransactionEmails($orderReferenceTransaction, $orderReferenceStatus, $stateObject)
744
- ->_updateOrderStatus($stateObject);
745
-
746
- // Authorization request, throw an exception if invalid status is returned
747
- $authorizationStatus = $this->_authorize($this->getInfoInstance()->getOrder()->getBaseTotalDue(), $orderReferenceTransaction->getTxnId(), $authorizationTransaction, $paymentAction == self::ACTION_AUTHORIZE_CAPTURE);
748
- if (!$this->_validateTransactionStatus($authorizationStatus, array(self::TRANSACTION_STATE_PENDING, self::TRANSACTION_STATE_OPEN))) {
749
- if (is_array($authorizationStatus) && array_key_exists(self::TRANSACTION_STATE_KEY, $authorizationStatus)
750
- && $authorizationStatus[self::TRANSACTION_STATE_KEY] == self::TRANSACTION_STATE_DECLINED
751
- && array_key_exists(self::TRANSACTION_REASON_KEY, $authorizationStatus))
752
- {
753
- switch ($authorizationStatus[self::TRANSACTION_REASON_KEY]) {
754
- case self::TRANSACTION_REASON_INVALID_PAYMENT:
755
- throw new Creativestyle_AmazonPayments_Exception_InvalidStatus_Recoverable('1. Invalid Authorization status returned by Amazon Payments API.');
756
- case self::TRANSACTION_REASON_AMAZON_REJECTED:
757
- case self::TRANSACTION_REASON_TIMEOUT:
758
- throw new Creativestyle_AmazonPayments_Exception_InvalidStatus('2. Invalid Authorization status returned by Amazon Payments API.');
759
- }
760
- }
761
- throw new Creativestyle_AmazonPayments_Exception('3. Invalid Authorization status returned by Amazon Payments API.');
762
- }
763
-
764
- $this->getInfoInstance()->setAmountAuthorized($this->getInfoInstance()->getOrder()->getTotalDue())
765
- ->setBaseAmountAuthorized($this->getInfoInstance()->getOrder()->getBaseTotalDue());
766
-
767
- $this->_mapTransactionStatus($authorizationTransaction, $authorizationStatus, $stateObject, $this->getInfoInstance()->getOrder()->getBaseTotalDue(), true)
768
- ->_sendTransactionEmails($authorizationTransaction, $authorizationStatus, $stateObject)
769
- ->_updateOrderStatus($stateObject);
770
-
771
- // TODO: next steps depending on the transaction status
772
-
773
  break;
774
-
775
  }
776
  return $this;
777
  }
20
  const ACTION_AUTHORIZE_CAPTURE = 'authorize_capture';
21
  const ACTION_ERP = 'erp';
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  const CHECK_USE_FOR_COUNTRY = 1;
24
  const CHECK_USE_FOR_CURRENCY = 2;
25
  const CHECK_USE_CHECKOUT = 4;
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
+ return Mage::getSingleton('amazonpayments/processor_order')->setOrder($this->getInfoInstance()->getOrder());
74
+ }
75
+
76
  /**
77
  * Return Amazon Payments processor instance
78
  *
79
+ * @return Creativestyle_AmazonPayments_Model_Processor_Payment
80
  */
81
  protected function _getPaymentProcessor() {
82
+ return Mage::getSingleton('amazonpayments/processor_payment')->setPaymentObject($this->getInfoInstance());
83
  }
84
 
85
  /**
97
  return $this;
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  protected function _getPaymentSequenceId() {
101
  $sequenceNumber = $this->getInfoInstance()->getAdditionalInformation('amazon_sequence_number');
102
  $sequenceNumber = is_null($sequenceNumber) ? 1 : ++$sequenceNumber;
104
  return sprintf('%s-%s', $this->getInfoInstance()->getOrder()->getExtOrderId(), $sequenceNumber);
105
  }
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  /**
108
  * Check authorise availability
109
  *
216
  *
217
  * @param Mage_Payment_Model_Info $payment
218
  * @param string $transactionId
219
+ * @param bool $shouldSave
220
  *
221
+ * @return array|bool
222
  */
223
  public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId, $shouldSave = true) {
224
  $this->_initInfoInstance($payment);
225
  if ($transaction = $payment->lookupTransaction($transactionId)) {
226
+ $transactionAdapter = $this->_getPaymentProcessor()->importTransactionDetails($transaction);
227
+ if ($transactionAdapter->getStatusChange()) {
228
+ $this->_getOrderProcessor()->importTransactionDetails($transactionAdapter, new Varien_Object());
229
+ if ($shouldSave) $this->_getOrderProcessor()->saveOrder();
230
+ } else {
231
+ $transactionAdapter->processRelatedObjects($this->getInfoInstance()->getOrder());
232
+ if ($shouldSave) $this->_getOrderProcessor()->saveOrder();
233
  }
234
+ return $transactionAdapter->getStatusChange();
235
  }
236
  throw new Creativestyle_AmazonPayments_Exception('Transaction not found');
237
  }
258
  if (!$this->canOrder()) {
259
  throw new Creativestyle_AmazonPayments_Exception('Order action is not available');
260
  }
261
+ $this->_getPaymentProcessor()->order($amount, $this->getInfoInstance()->getTransactionId());
 
 
 
 
262
  $transaction = $this->getInfoInstance()->setIsTransactionClosed(false)
263
  ->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
264
+ return $this->_getPaymentProcessor()->importTransactionDetails($transaction);
265
  }
266
 
267
  /**
274
  *
275
  * @return array|null
276
  */
277
+ protected function _authorize($amount, $parentTransactionId, &$transaction = null, $captureNow = false, $synchronous = false) {
278
  if (!$this->canAuthorize()) {
279
  throw new Creativestyle_AmazonPayments_Exception('Authorize action is not available');
280
  }
281
  $authorizationDetails = $this->_getPaymentProcessor()->authorize(
 
282
  $amount,
283
  $this->_getPaymentSequenceId(),
284
  $parentTransactionId,
285
+ $captureNow,
286
+ $synchronous
287
  );
288
  $transaction = $this->getInfoInstance()->setIsTransactionClosed(false)
289
  ->setTransactionId($authorizationDetails->getAmazonAuthorizationId())
290
  ->setParentTransactionId($parentTransactionId)
291
  ->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
292
+ return $this->_getPaymentProcessor()->importTransactionDetails($transaction);
293
  }
294
 
295
  /**
306
  throw new Creativestyle_AmazonPayments_Exception('Capture action is not available');
307
  }
308
  $captureDetails = $this->_getPaymentProcessor()->capture(
 
309
  $amount,
310
  $this->_getPaymentSequenceId(),
311
  $parentTransactionId
314
  ->setTransactionId($captureDetails->getAmazonCaptureId())
315
  ->setParentTransactionId($parentTransactionId)
316
  ->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
317
+ return $this->_getPaymentProcessor()->importTransactionDetails($transaction, $captureDetails);
318
+ }
319
+
320
+ /**
321
+ * Payment refund
322
+ *
323
+ * @param float $amount
324
+ * @param string $parentTransactionId
325
+ * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
326
+ *
327
+ * @return array|null
328
+ */
329
+ protected function _refund($amount, $parentTransactionId, &$transaction = null) {
330
+ if (!$this->canRefund()) {
331
+ throw new Creativestyle_AmazonPayments_Exception('Capture action is not available');
332
+ }
333
+ $refundDetails = $this->_getPaymentProcessor()->refund(
334
+ $amount,
335
+ $this->_getPaymentSequenceId(),
336
+ $parentTransactionId
337
+ );
338
+ $transaction = $this->getInfoInstance()->setIsTransactionClosed(false)
339
+ ->setTransactionId($refundDetails->getAmazonRefundId())
340
+ ->setParentTransactionId($parentTransactionId)
341
+ ->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
342
+ return $this->_getPaymentProcessor()->importTransactionDetails($transaction, $refundDetails);
343
  }
344
 
345
  /**
352
  */
353
  public function order(Varien_Object $payment, $amount) {
354
  $this->_initInfoInstance($payment);
355
+ $orderTransaction = null;
356
+ $orderReferenceAdapter = $this->_order($amount, $orderTransaction);
357
+ $orderReferenceAdapter->validateTransactionStatus();
358
+ $this->_getOrderProcessor()->importTransactionDetails($orderReferenceAdapter, $stateObject);
 
 
 
 
 
 
 
 
 
 
359
  return $this;
360
  }
361
 
369
  */
370
  public function authorize(Varien_Object $payment, $amount) {
371
  $this->_initInfoInstance($payment);
372
+ if ($orderTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER)) {
373
+ $authorizationTransaction = null;
374
+ $authorizationAdapter = $this->_authorize(
375
+ $amount,
376
+ $orderTransaction->getTxnId(),
377
+ $authorizationTransaction,
378
+ $this->_getConfig()->getPaymentAction($payment->getOrder()->getStoreId()) == self::ACTION_AUTHORIZE_CAPTURE,
379
+ $this->_getConfig()->isAuthorizationSynchronous($payment->getOrder()->getStoreId())
380
+ );
381
+ $authorizationAdapter->validateTransactionStatus();
382
+ $this->_getOrderProcessor()->importTransactionDetails($authorizationAdapter, $stateObject);
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  }
 
384
  return $this;
385
  }
386
 
394
  */
395
  public function capture(Varien_Object $payment, $amount) {
396
  $this->_initInfoInstance($payment);
 
397
  if ($authorizationTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)) {
398
+ $captureTransaction = null;
399
+ $captureAdapter = $this->_capture(
400
+ $amount,
401
+ $authorizationTransaction->getTxnId(),
402
+ $captureTransaction
403
  );
404
+ $captureAdapter->validateTransactionStatus();
405
+ $this->_getOrderProcessor()->importTransactionDetails($captureAdapter, $stateObject)->saveOrder();
 
 
 
 
 
 
 
406
  // avoid transaction duplicates
407
  $payment->setSkipTransactionCreation(true);
408
  }
 
409
  return $this;
410
  }
411
 
412
  /**
413
  * @todo
414
  * Set capture transaction ID to invoice for informational purposes
415
+ *
416
  * @param Mage_Sales_Model_Order_Invoice $invoice
417
  * @param Mage_Sales_Model_Order_Payment $payment
418
+ *
419
  * @return Mage_Payment_Model_Method_Abstract
420
  */
421
  public function processInvoice($invoice, $payment) {
434
  */
435
  public function refund(Varien_Object $payment, $amount) {
436
  $this->_initInfoInstance($payment);
437
+ if ($captureTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE)) {
438
+ $refundTransaction = null;
439
+ $refundAdapter = $this->_refund(
440
+ $amount,
441
+ $captureTransaction->getTxnId(),
442
+ $refundTransaction
443
+ );
444
+ $refundAdapter->validateTransactionStatus();
445
+ // avoid transaction duplicates
446
+ $payment->setSkipTransactionCreation(true);
447
  }
448
  return $this;
449
  }
521
  public function initialize($paymentAction, $stateObject) {
522
  $payment = $this->getInfoInstance();
523
  $this->setStore($payment->getOrder()->getStoreId());
 
524
  switch ($paymentAction) {
525
  case self::ACTION_MANUAL:
526
+ $orderTransaction = null;
527
+ $orderReferenceAdapter = $this->_order($this->getInfoInstance()->getOrder()->getBaseTotalDue(), $orderTransaction);
528
+ $orderReferenceAdapter->validateTransactionStatus();
529
+ $this->_getOrderProcessor()->importTransactionDetails($orderReferenceAdapter, $stateObject);
 
 
 
 
 
 
 
 
 
 
530
  break;
 
531
  case self::ACTION_AUTHORIZE:
532
  case self::ACTION_AUTHORIZE_CAPTURE:
533
+ // OrderReference first
534
+ $orderTransaction = null;
535
+ $orderReferenceAdapter = $this->_order($this->getInfoInstance()->getOrder()->getBaseTotalDue(), $orderTransaction);
536
+ $orderReferenceAdapter->validateTransactionStatus();
537
+ $this->_getOrderProcessor()->importTransactionDetails($orderReferenceAdapter, $stateObject);
538
+ // Authorization next
539
+ $authorizationTransaction = null;
540
+ $authorizationAdapter = $this->_authorize(
541
+ $this->getInfoInstance()->getOrder()->getBaseTotalDue(),
542
+ $orderTransaction->getTxnId(),
543
+ $authorizationTransaction,
544
+ $paymentAction == self::ACTION_AUTHORIZE_CAPTURE,
545
+ $this->_getConfig()->isAuthorizationSynchronous($payment->getOrder()->getStoreId())
546
  );
547
+ $authorizationAdapter->validateTransactionStatus();
548
+ $this->_getOrderProcessor()->importTransactionDetails($authorizationAdapter, $stateObject);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
549
  break;
 
550
  }
551
  return $this;
552
  }
app/code/community/Creativestyle/AmazonPayments/Model/Payment/Advanced/Abstract.php DELETED
@@ -1,393 +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
- abstract class Creativestyle_AmazonPayments_Model_Payment_Advanced_Abstract extends Creativestyle_AmazonPayments_Model_Payment_Abstract {
17
-
18
- protected $_code = 'amazonpayments_advanced_abstract';
19
- protected $_infoBlockType = 'amazonpayments/payment_info';
20
-
21
- /**
22
- * Pay with Amazon method features
23
- * @var bool
24
- */
25
- protected $_canAuthorize = true;
26
- protected $_canCapture = true;
27
- protected $_canCapturePartial = false;
28
- protected $_canRefund = true;
29
- protected $_canRefundInvoicePartial = true;
30
- protected $_canVoid = true;
31
- protected $_canUseInternal = false;
32
- protected $_canUseCheckout = false;
33
- protected $_canUseForMultishipping = false;
34
- protected $_isInitializeNeeded = true;
35
- protected $_canFetchTransactionInfo = true;
36
- protected $_canReviewPayment = false;
37
-
38
- protected function _getApi() {
39
- return Mage::getSingleton('amazonpayments/api_advanced');
40
- }
41
-
42
- protected function _getManager() {
43
- return Mage::getSingleton('amazonpayments/manager');
44
- }
45
-
46
- protected function _getConfig() {
47
- return Mage::getSingleton('amazonpayments/config');
48
- }
49
-
50
- protected function _increaseSequenceNumber(Varien_Object $payment) {
51
- $sequenceNumber = $payment->getAdditionalInformation('amazon_sequence_number');
52
- $sequenceNumber = is_null($sequenceNumber) ? 1 : ++$sequenceNumber;
53
- $payment->setAdditionalInformation('amazon_sequence_number', $sequenceNumber);
54
- return $sequenceNumber;
55
- }
56
-
57
- protected function _authorize(Varien_Object $payment, $amount) {
58
- $order = $payment->getOrder();
59
-
60
- $authorizationDetails = $this->_getApi()->setStore($order->getStoreId())->authorize(
61
- $order->getExtOrderId(),
62
- $order->getExtOrderId() . '-' . $this->_increaseSequenceNumber($payment),
63
- $amount,
64
- $order->getBaseCurrencyCode(),
65
- Creativestyle_AmazonPayments_Model_Simulator::simulate($payment, 'Authorization')
66
- );
67
-
68
- $payment->setTransactionId($authorizationDetails->getAmazonAuthorizationId());
69
- $payment->setParentTransactionId($order->getExtOrderId());
70
- $payment->setIsTransactionClosed(false);
71
-
72
- $message = Mage::helper('amazonpayments')->__('An authorize request for %s has been submitted to Amazon Payments.', $order->getStore()->convertPrice($amount, true, false));
73
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, false, $message);
74
- $transactionStatus = $this->_getManager()->importAuthorizationDetails(
75
- $authorizationDetails,
76
- $payment,
77
- $transaction
78
- );
79
-
80
- if (null !== $transactionStatus) {
81
- $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
82
- $transaction->save();
83
- }
84
-
85
- return $this;
86
- }
87
-
88
- protected function _capture(Varien_Object $payment, $amount) {
89
- $order = $payment->getOrder();
90
-
91
- $authTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
92
- $authTransactionId = $authTransaction->getTxnId();
93
-
94
- $captureDetails = $this->_getApi()->setStore($order->getStoreId())->capture(
95
- $authTransactionId,
96
- $order->getExtOrderId() . '-' . $this->_increaseSequenceNumber($payment),
97
- $amount,
98
- $order->getBaseCurrencyCode(),
99
- Creativestyle_AmazonPayments_Model_Simulator::simulate($payment, 'Capture')
100
- );
101
-
102
- $payment->setTransactionId($captureDetails->getAmazonCaptureId());
103
- $payment->setParentTransactionId($authTransactionId);
104
- $payment->setIsTransactionClosed(false);
105
-
106
- $message = Mage::helper('amazonpayments')->__('A capture request for %s has been submitted to Amazon Payments.', $order->getStore()->convertPrice($amount, true, false));
107
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, false, $message);
108
- $transactionStatus = $this->_getManager()->importCaptureDetails(
109
- $captureDetails,
110
- $payment,
111
- $transaction
112
- );
113
-
114
- if (null !== $transactionStatus) {
115
- $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
116
- $transaction->save();
117
- }
118
-
119
- return $this;
120
- }
121
-
122
- protected function _refund(Varien_Object $payment, $amount) {
123
- $order = $payment->getOrder();
124
-
125
- $captureTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
126
- $captureTransactionId = $captureTransaction->getTxnId();
127
-
128
- $refundDetails = $this->_getApi()->setStore($order->getStoreId())->refund(
129
- $captureTransactionId,
130
- $order->getExtOrderId() . '-' . $this->_increaseSequenceNumber($payment),
131
- $amount,
132
- $order->getBaseCurrencyCode(),
133
- Creativestyle_AmazonPayments_Model_Simulator::simulate($payment, 'Refund')
134
- );
135
-
136
- $payment->setTransactionId($refundDetails->getAmazonRefundId());
137
- $payment->setParentTransactionId($captureTransactionId);
138
- $payment->setIsTransactionClosed(false);
139
-
140
- $message = Mage::helper('amazonpayments')->__('A refund request for %s has been submitted to Amazon Payments.', $order->getStore()->convertPrice($amount, true, false));
141
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND, null, false, $message);
142
- $transactionStatus = $this->_getManager()->importRefundDetails(
143
- $refundDetails,
144
- $payment,
145
- $transaction
146
- );
147
-
148
- if (null !== $transactionStatus) {
149
- $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
150
- $transaction->save();
151
- }
152
-
153
- return $this;
154
- }
155
-
156
- protected function _void(Varien_Object $payment) {
157
- $order = $payment->getOrder();
158
-
159
- $orderTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
160
- $orderTransactionId = $orderTransaction->getTxnId();
161
-
162
- $cancelDetails = $this->_getApi()->setStore($order->getStoreId())->cancelOrderReference($orderTransactionId);
163
- $orderTransaction->close(true);
164
-
165
- return $this;
166
- }
167
-
168
- /**
169
- * Check whether Amazon Payments Advanced is enabled
170
- *
171
- * @param Mage_Sales_Model_Quote
172
- * @return bool
173
- */
174
- public function isAvailable($quote = null) {
175
- $checkResult = new StdClass;
176
- $isActive = $this->_getConfig()->isActive();
177
- if ($quote && !$quote->validateMinimumAmount()) {
178
- $isActive = false;
179
- }
180
- $checkResult->isAvailable = $isActive;
181
- $checkResult->isDeniedInConfig = !$isActive;
182
- Mage::dispatchEvent('payment_method_is_active', array(
183
- 'result' => $checkResult,
184
- 'method_instance' => $this,
185
- 'quote' => $quote,
186
- ));
187
- return $checkResult->isAvailable;
188
- }
189
-
190
- /**
191
- * Payment initialization routines
192
- *
193
- * @param string $paymentAction
194
- * @param object $stateObject
195
- *
196
- * @return Mage_Payment_Model_Abstract
197
- */
198
- public function initialize($paymentAction, $stateObject) {
199
- $payment = $this->getInfoInstance();
200
- if ($payment) {
201
- $order = $payment->getOrder();
202
- $this->setStore($order->getStoreId())->order($payment, $order->getBaseTotalDue());
203
- $stateObject = new Varien_Object(array(
204
- 'state' => Mage_Sales_Model_Order::STATE_NEW,
205
- 'status' => true,
206
- 'is_notified' => Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE
207
- ));
208
- }
209
- return $this;
210
- }
211
-
212
- /**
213
- * Check authorise availability
214
- *
215
- * @return bool
216
- */
217
- public function canAuthorize() {
218
- if ($this->_getConfig()->isPaymentProcessingAllowed()) {
219
- $payment = $this->getInfoInstance();
220
- if ($payment) {
221
- $orderTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
222
- if (!$orderTransaction || $orderTransaction->getIsClosed()) {
223
- return false;
224
- }
225
- }
226
- }
227
- return parent::canAuthorize();
228
- }
229
-
230
- /**
231
- * Check fetch transaction info availability
232
- *
233
- * @return bool
234
- */
235
- public function canFetchTransactionInfo() {
236
- if (!$this->_getConfig()->isPaymentProcessingAllowed()) {
237
- return false;
238
- }
239
- return parent::canFetchTransactionInfo();
240
- }
241
-
242
- /**
243
- * Check invoice creating availability
244
- *
245
- * @return bool
246
- */
247
- public function canInvoice() {
248
- if ($this->_getConfig()->isPaymentProcessingAllowed()) {
249
- $payment = $this->getInfoInstance();
250
- if ($payment) {
251
- $authTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
252
- if (!$authTransaction || $authTransaction->getIsClosed()) {
253
- return false;
254
- }
255
- }
256
- }
257
- return parent::canInvoice();
258
- }
259
-
260
- /**
261
- * Check capture availability
262
- *
263
- * @return bool
264
- */
265
- public function canCapture() {
266
- if ($this->_getConfig()->isPaymentProcessingAllowed()) {
267
- $payment = $this->getInfoInstance();
268
- if ($payment) {
269
- $authTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
270
- if (!$authTransaction || $authTransaction->getIsClosed()) {
271
- return false;
272
- }
273
- }
274
- }
275
- return parent::canCapture();
276
- }
277
-
278
- /**
279
- * Transfer an order to Amazon Payments gateway
280
- *
281
- * @param Varien_Object $payment
282
- * @param float $amount
283
- * @return Creativestyle_AmazonPayments_Model_Payment_Advanced_Abstract
284
- */
285
- public function order(Varien_Object $payment, $amount) {
286
- $order = $payment->getOrder();
287
-
288
- $this->_getApi()->setOrderReferenceDetails($order->getExtOrderId(), $amount, $order->getBaseCurrencyCode(), $order->getIncrementId());
289
- $this->_getApi()->confirmOrderReference($order->getExtOrderId());
290
-
291
- $payment->setIsTransactionClosed(false);
292
- $payment->setSkipOrderProcessing(true);
293
-
294
- $message = Mage::helper('amazonpayments')->__('An order of %s has been sent to Amazon Payments.', $order->getStore()->convertPrice($amount, true, false));
295
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $message);
296
- $transactionStatus = $this->_getManager()->importOrderReferenceDetails(
297
- $this->_getApi()->getOrderReferenceDetails($order->getExtOrderId()),
298
- $payment,
299
- $transaction
300
- );
301
-
302
- if (null !== $transactionStatus) {
303
- $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
304
- $transaction->save();
305
- }
306
-
307
- Creativestyle_AmazonPayments_Model_Simulator::simulate($payment, 'OrderReference');
308
-
309
- if ($this->_getConfig()->authorizeImmediately()) {
310
- $auth = $this->_authorize($payment, $amount);
311
- }
312
-
313
- return $this;
314
- }
315
-
316
- /**
317
- * Authorize
318
- *
319
- * @param Varien_Object $payment
320
- * @param float $amount
321
- * @return Creativestyle_AmazonPayments_Model_Payment_Advanced_Abstract
322
- */
323
- public function authorize(Varien_Object $payment, $amount) {
324
- if ($this->_getConfig()->isPaymentProcessingAllowed()) {
325
- if (!$this->canAuthorize()) {
326
- throw new Creativestyle_AmazonPayments_Exception('Authorize action is not available');
327
- }
328
- $this->_authorize($payment, $amount);
329
- }
330
- return $this;
331
- }
332
-
333
- /**
334
- * Capture
335
- *
336
- * @param Varien_Object $payment
337
- * @param float $amount
338
- * @return Creativestyle_AmazonPayments_Model_Payment_Advanced_Abstract
339
- */
340
- public function capture(Varien_Object $payment, $amount) {
341
- if ($this->_getConfig()->isPaymentProcessingAllowed()) {
342
- if (!$this->canCapture()) {
343
- throw new Creativestyle_AmazonPayments_Exception('Capture action is not available');
344
- }
345
- $this->_capture($payment, $amount);
346
- }
347
- return $this;
348
- }
349
-
350
- public function refund(Varien_Object $payment, $amount) {
351
- if ($this->_getConfig()->isPaymentProcessingAllowed()) {
352
- if (!$this->canRefund()) {
353
- throw new Creativestyle_AmazonPayments_Exception('Refund action is not available');
354
- }
355
- $this->_refund($payment, $amount);
356
- }
357
- return $this;
358
- }
359
-
360
- public function cancel(Varien_Object $payment) {
361
- if ($this->_getConfig()->isPaymentProcessingAllowed()) {
362
- return $this->_void($payment);
363
- }
364
- return $this;
365
- }
366
-
367
- public function void(Varien_Object $payment) {
368
- if ($this->_getConfig()->isPaymentProcessingAllowed()) {
369
- return $this->_void($payment);
370
- }
371
- return $this;
372
- }
373
-
374
- public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId) {
375
- $transaction = $payment->lookupTransaction($transactionId);
376
- if ($transaction) {
377
- if ($transaction->getIsClosed()) {
378
- throw new Creativestyle_AmazonPayments_Exception('Cannot fetch information for closed transaction.');
379
- }
380
- return $this->_getManager()->importTransactionDetails($payment, $transaction);
381
- }
382
- throw new Creativestyle_AmazonPayments_Exception('Transaction not found.');
383
- }
384
-
385
- public function closeOrderReference(Mage_Payment_Model_Info $payment) {
386
- $orderTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
387
- if ($orderTransaction && !$orderTransaction->getIsClosed()) {
388
- $this->_getApi()->setStore($payment->getOrder()->getStoreId())->closeOrderReference($orderTransaction->getTxnId());
389
- $orderTransaction->close(true);
390
- }
391
- }
392
-
393
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Creativestyle/AmazonPayments/Model/Processor.php DELETED
@@ -1,297 +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 {
17
-
18
- protected function _getApi($store = null) {
19
- return Mage::getSingleton('amazonpayments/api_advanced')->setStore($store);
20
- }
21
-
22
- protected function _getConfig() {
23
- return Mage::getSingleton('amazonpayments/config');
24
- }
25
-
26
- protected function _getDataMapper() {
27
- return Mage::getSingleton('amazonpayments/mapper');
28
- }
29
-
30
- /**
31
- * Return Amazon transaction name for provided Magento transaction object
32
- *
33
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
34
- *
35
- * @return string|null
36
- */
37
- protected function _getAmazonTransactionType($transaction) {
38
- switch ($transaction->getTxnType()) {
39
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
40
- return 'OrderReference';
41
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
42
- return 'Authorization';
43
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
44
- return 'Capture';
45
- case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
46
- return 'Refund';
47
- }
48
- return null;
49
- }
50
-
51
- /**
52
- * Get transaction details from Amazon Payments API
53
- *
54
- * @param string $transactionId
55
- * @param string $transactionType
56
- * @param int $store
57
- *
58
- * @return OffAmazonPaymentsService_Model
59
- */
60
- protected function _getTransactionDetails($transactionId, $transactionType, $store = null) {
61
- return call_user_func(array($this->_getApi($store), 'get' . $transactionType . 'Details'), $transactionId);
62
- }
63
-
64
- /**
65
- * Extract transaction status from the transaction details,
66
- * fetch transaction details if not provided in the arguments
67
- *
68
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
69
- * @param int $store
70
- * @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
71
- *
72
- * @return array|null
73
- */
74
- protected function _fetchTransactionStatus($transaction, $store = null, $transactionDetails = null) {
75
- $transactionType = $this->_getAmazonTransactionType($transaction);
76
- if (null === $transactionDetails) {
77
- $transactionDetails = $this->_getTransactionDetails($transaction->getTxnId(), $transactionType, $store);
78
- }
79
- if (call_user_func(array($transactionDetails, 'isSet' . $transactionType . 'Status'))) {
80
- return $this->_getTransactionNewStatus(
81
- $transaction,
82
- call_user_func(array($transactionDetails, 'get' . $transactionType . 'Status'))
83
- );
84
- }
85
- return null;
86
- }
87
-
88
- /**
89
- * Import transaction details to the Magento order and its related objects
90
- *
91
- * @param Mage_Sales_Model_Order_Payment $payment
92
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
93
- * @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
94
- *
95
- * @return array|null
96
- */
97
- protected function _importTransactionDetails($payment, $transaction, $transactionDetails = null) {
98
- $transactionType = $this->_getAmazonTransactionType($transaction);
99
- if (null === $transactionDetails) {
100
- $transactionDetails = $this->_getTransactionDetails($transaction->getTxnId(), $transactionType, $payment->getOrder()->getStoreId());
101
- }
102
- $newStatus = $this->_fetchTransactionStatus($transaction, $payment->getOrder()->getStoreId(), $transactionDetails);
103
- if ($newStatus) {
104
- // $transactionAmountObject = call_user_func(array($transactionDetails, $transactionType == 'OrderReference' ? 'getOrderTotal' : 'get' . $transactionType . 'Amount'));
105
- // $transactionAmountObject->getAmount()
106
- $this->updateTransactionStatus($transaction, $newStatus);
107
- $this->updateOrderData($payment->getOrder(), $transactionDetails);
108
- }
109
- return $newStatus;
110
- }
111
-
112
- /**
113
- * Check if the transaction status changed, if so return new status array,
114
- * null otherwise
115
- *
116
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
117
- * @param OffAmazonPaymentsService_Model_Status|OffAmazonPaymentsNotifications_Model_Status $recentTransactionStatus
118
- *
119
- * @return array|null
120
- */
121
- protected function _getTransactionNewStatus($transaction, $recentTransactionStatus) {
122
- if ($recentTransactionStatus->isSetState()) {
123
- if (Mage::helper('amazonpayments')->getTransactionStatus($transaction) != $recentTransactionStatus->getState()) {
124
- $status = array('State' => $recentTransactionStatus->getState());
125
- if ($recentTransactionStatus->isSetReasonCode()) {
126
- $status['ReasonCode'] = $recentTransactionStatus->getReasonCode();
127
- }
128
- if ($recentTransactionStatus->isSetReasonDescription()) {
129
- $status['ReasonDescription'] = $recentTransactionStatus->getReasonDescription();
130
- }
131
- return $status;
132
- }
133
- }
134
- return null;
135
- }
136
-
137
- /**
138
- * @param Mage_Customer_Model_Address_Abstract $addressObject
139
- * @param Varien_Object $addressData
140
- */
141
- protected function _updateAddress($addressObject, $addressData) {
142
- if ($addressObject->getFirstname() != $addressData->getFirstname()) {
143
- $addressObject->setFirstname($addressData->getFirstname());
144
- }
145
- if ($addressObject->getLastname() != $addressData->getLastname()) {
146
- $addressObject->setLastname($addressData->getLastname());
147
- }
148
- if ($addressObject->getCompany() != $addressData->getCompany()) {
149
- $addressObject->setCompany($addressData->getCompany());
150
- }
151
- if ($addressObject->getCity() != $addressData->getCity()) {
152
- $addressObject->setCity($addressData->getCity());
153
- }
154
- if ($addressObject->getPostcode() != $addressData->getPostcode()) {
155
- $addressObject->setPostcode($addressData->getPostcode());
156
- }
157
- if ($addressObject->getCountryId() != $addressData->getCountryId()) {
158
- $addressObject->setCountryId($addressData->getCountryId());
159
- }
160
- if ($addressObject->getTelephone() != $addressData->getTelephone()) {
161
- $addressObject->setTelephone($addressData->getTelephone());
162
- }
163
- $streetDiff = array_diff($addressObject->getStreet(), $addressData->getStreet());
164
- if (!empty($streetDiff)) {
165
- $addressObject->setStreet($addressData->getStreet());
166
- }
167
- }
168
-
169
- /**
170
- * Transfer order to Amazon Payments gateway
171
- *
172
- * @param Varien_Object $payment
173
- * @param float $amount
174
- * @param string $transactionSequenceId
175
- */
176
- public function order(Varien_Object $payment, $amount, $transactionSequenceId) {
177
- $this->_getApi($payment->getOrder()->getStoreId())->setOrderReferenceDetails(
178
- $transactionSequenceId,
179
- $amount,
180
- $payment->getOrder()->getBaseCurrencyCode(),
181
- $payment->getOrder()->getIncrementId()
182
- );
183
- $this->orderConfirm($payment, $transactionSequenceId);
184
- }
185
-
186
- public function orderConfirm(Varien_Object $payment, $transactionSequenceId) {
187
- $this->_getApi($payment->getOrder()->getStoreId())->confirmOrderReference($transactionSequenceId);
188
- Creativestyle_AmazonPayments_Model_Simulator::simulate($payment, 'OrderReference');
189
- }
190
-
191
- /**
192
- * Authorize order amount on Amazon Payments gateway
193
- *
194
- * @param Varien_Object $payment
195
- * @param float $amount
196
- * @param string $transactionSequenceId
197
- * @param string $parentTransactionId
198
- * @param bool $captureNow
199
- *
200
- * @return OffAmazonPaymentsService_Model_AuthorizationDetails
201
- */
202
- public function authorize(Varien_Object $payment, $amount, $transactionSequenceId, $parentTransactionId, $captureNow = false) {
203
- return $this->_getApi($payment->getOrder()->getStoreId())->authorize(
204
- $parentTransactionId,
205
- $transactionSequenceId,
206
- $amount,
207
- $payment->getOrder()->getBaseCurrencyCode(),
208
- Creativestyle_AmazonPayments_Model_Simulator::simulate($payment, 'Authorization'),
209
- $captureNow,
210
- $this->_getConfig()->isAuthorizationSynchronous($payment->getOrder()->getStoreId()) ? 0 : null
211
- );
212
- }
213
-
214
- /**
215
- * Capture order amount on Amazon Payments gateway
216
- *
217
- * @param Varien_Object $payment
218
- * @param float $amount
219
- * @param string $transactionSequenceId
220
- * @param string $parentTransactionId
221
- *
222
- * @return OffAmazonPaymentsService_Model_AuthorizationDetails
223
- */
224
- public function capture(Varien_Object $payment, $amount, $transactionSequenceId, $parentTransactionId) {
225
- return $this->_getApi($payment->getOrder()->getStoreId())->capture(
226
- $parentTransactionId,
227
- $transactionSequenceId,
228
- $amount,
229
- $payment->getOrder()->getBaseCurrencyCode(),
230
- Creativestyle_AmazonPayments_Model_Simulator::simulate($payment, 'Capture')
231
- );
232
- }
233
-
234
- /**
235
- * Return payment transaction status info array
236
- *
237
- * @param Mage_Sales_Model_Order_Payment $payment
238
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
239
- *
240
- * @return array|null
241
- */
242
- public function fetchTransactionDetails($payment, $transaction) {
243
- return $this->_fetchTransactionStatus($transaction, $payment->getOrder()->getStoreId());
244
- }
245
-
246
- /**
247
- * Import payment transaction info and return transaction status info array
248
- *
249
- * @param Mage_Sales_Model_Order_Payment $payment
250
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
251
- * @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
252
- *
253
- * @return array|null
254
- */
255
- public function importTransactionDetails($payment, $transaction, $transactionDetails = null) {
256
- return $this->_importTransactionDetails($payment, $transaction, $transactionDetails);
257
- }
258
-
259
- /**
260
- * Update order data based using payment transaction details
261
- *
262
- * @param Mage_Sales_Model_Order $order
263
- * @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
264
- */
265
- public function updateOrderData($order, $transactionDetails) {
266
- $orderData = $this->_getDataMapper()->mapTransactionInfo($transactionDetails);
267
- // check which order data should be updated
268
- if ($orderData->hasCustomerEmail() && $order->getCustomerEmail() != $orderData->getCustomerEmail()) {
269
- $order->setCustomerEmail($orderData->getCustomerEmail());
270
- }
271
- if ($orderData->hasCustomerFirstname() && $order->getCustomerFirstname() != $orderData->getCustomerFirstname()) {
272
- $order->setCustomerFirstname($orderData->getCustomerFirstname());
273
- }
274
- if ($orderData->hasCustomerLastname() && $order->getCustomerLastname() != $orderData->getCustomerLastname()) {
275
- $order->setCustomerLastname($orderData->getCustomerLastname());
276
- }
277
- if ($orderData->hasBillingAddress()) {
278
- $this->_updateAddress($order->getBillingAddress(), $orderData->getBillingAddress());
279
- }
280
- if ($orderData->hasShippingAddress()) {
281
- $this->_updateAddress($order->getShippingAddress(), $orderData->getShippingAddress());
282
- }
283
- }
284
-
285
- /**
286
- * Update payment transaction status stored in additional_information field
287
- *
288
- * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
289
- * @param array $transactionStatus
290
- *
291
- * @return Mage_Sales_Model_Order_Payment_Transaction
292
- */
293
- public function updateTransactionStatus($transaction, $transactionStatus) {
294
- return $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
295
- }
296
-
297
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Creativestyle/AmazonPayments/Model/Processor/Ipn.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @return Mage_Sales_Model_Order_Payment|null
55
+ */
56
+ protected function _lookupPayment($orderReferenceId) {
57
+ $order = Mage::getModel('sales/order')->loadByAttribute('ext_order_id', $orderReferenceId);
58
+ if (is_object($order) && $order->getId()) return $order->getPayment();
59
+ return null;
60
+ }
61
+
62
+ /**
63
+ * Process a notification message requested via IPN
64
+ *
65
+ * @param OffAmazonPaymentNotifications_Notification $notification
66
+ *
67
+ * @throws Creativestyle_AmazonPayments_Exception
68
+ */
69
+ public function processNotification($notification) {
70
+ if (null !== $notification) {
71
+ $payment = null;
72
+ $transaction = null;
73
+ $transactionDetails = null;
74
+ switch ($notification->getNotificationType()) {
75
+ case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_ORDER_REFERENCE:
76
+ if ($notification->isSetOrderReference()) {
77
+ $payment = $this->_lookupPayment($notification->getOrderReference()->getAmazonOrderReferenceId());
78
+ $transaction = $payment->lookupTransaction($notification->getOrderReference()->getAmazonOrderReferenceId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
79
+ $transactionDetails = $notification->getOrderReference();
80
+ } else {
81
+ throw new Creativestyle_AmazonPayments_Exception('OrderReference field not found in submitted notification');
82
+ }
83
+ break;
84
+ case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_AUTHORIZATION:
85
+ if ($notification->isSetAuthorizationDetails()) {
86
+ $payment = $this->_lookupPayment($this->_getOrderReferenceId($notification->getAuthorizationDetails()->getAuthorizationReferenceId()));
87
+ $transaction = $payment->lookupTransaction($notification->getAuthorizationDetails()->getAmazonAuthorizationId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
88
+ $transactionDetails = $notification->getAuthorizationDetails();
89
+ } else {
90
+ throw new Creativestyle_AmazonPayments_Exception('AuthorizationDetails field not found in submitted notification');
91
+ }
92
+ break;
93
+ case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_CAPTURE:
94
+ if ($notification->isSetCaptureDetails()) {
95
+ $payment = $this->_lookupPayment($this->_getOrderReferenceId($notification->getCaptureDetails()->getCaptureReferenceId()));
96
+ $transaction = $payment->lookupTransaction($notification->getCaptureDetails()->getAmazonCaptureId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
97
+ $transactionDetails = $notification->getCaptureDetails();
98
+ } else {
99
+ throw new Creativestyle_AmazonPayments_Exception('CaptureDetails field not found in submitted notification');
100
+ }
101
+ break;
102
+ case Creativestyle_AmazonPayments_Model_Api_Ipn::NOTIFICATION_TYPE_REFUND:
103
+ if ($notification->isSetRefundDetails()) {
104
+ $payment = $this->_lookupPayment($this->_getOrderReferenceId($notification->getRefundDetails()->getRefundReferenceId()));
105
+ $transaction = $payment->lookupTransaction($notification->getRefundDetails()->getAmazonRefundId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
106
+ $transactionDetails = $notification->getRefundDetails();
107
+ } else {
108
+ throw new Creativestyle_AmazonPayments_Exception('RefundDetails field not found in submitted notification');
109
+ }
110
+ break;
111
+ default:
112
+ throw new Creativestyle_AmazonPayments_Exception('Invalid notification type');
113
+ }
114
+ if ($payment && $transaction) {
115
+ $transactionAdapter = $this->_getPaymentProcessor($payment)->importTransactionDetails($transaction);
116
+ if ($transactionAdapter->getStatusChange()) {
117
+ $transactionAdapter->saveTransaction();
118
+ $this->_getOrderProcessor($payment->getOrder())
119
+ ->importTransactionDetails($transactionAdapter, new Varien_Object())
120
+ ->saveOrder();
121
+ } else {
122
+ $relatedTransactionAdapter = $transactionAdapter->processRelatedObjects($payment->getOrder());
123
+ $this->_getOrderProcessor($payment->getOrder())->saveOrder();
124
+ }
125
+ } else {
126
+ throw new Creativestyle_AmazonPayments_Exception('Payment transaction with such ID not found');
127
+ }
128
+ } else {
129
+ throw new Creativestyle_AmazonPayments_Exception('No notification data provided');
130
+ }
131
+ }
132
+
133
+ }
app/code/community/Creativestyle/AmazonPayments/Model/Processor/Order.php ADDED
@@ -0,0 +1,452 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Order {
17
+
18
+ protected $_order = null;
19
+
20
+ protected $_store = null;
21
+
22
+ /**
23
+ * Return Amazon Payments config model instance
24
+ *
25
+ * @return Creativestyle_AmazonPayments_Model_Config
26
+ */
27
+ protected function _getConfig() {
28
+ return Mage::getSingleton('amazonpayments/config');
29
+ }
30
+
31
+ /**
32
+ * TODO: [_initStateObject description]
33
+ *
34
+ * @param Varien_Object &$stateObject
35
+ *
36
+ * @return Creativestyle_AmazonPayments_Model_Processor_Order
37
+ */
38
+ protected function _initStateObject(&$stateObject = null) {
39
+ if (null === $stateObject) {
40
+ $stateObject = new Varien_Object();
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
+ * Check whether provided address lines contain PO Box data
52
+ *
53
+ * @param string $addressLine1
54
+ * @param string|null $addressLine2
55
+ *
56
+ * @return bool
57
+ */
58
+ protected function _isPoBox($addressLine1, $addressLine2 = null) {
59
+ if (is_numeric($addressLine1)) {
60
+ return true;
61
+ }
62
+ if (strpos(strtolower($addressLine1), 'packstation') !== false) {
63
+ return true;
64
+ }
65
+ if (strpos(strtolower($addressLine2), 'packstation') !== false) {
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+
71
+ /**
72
+ * Convert address object from Amazon Payments API response to Varien_Object
73
+ * indexed with the same keys Magento order address entities
74
+ *
75
+ * @param OffAmazonPaymentsService_Model_Address $amazonAddress
76
+ *
77
+ * @return Varien_Object
78
+ */
79
+ protected function _mapAmazonAddress($amazonAddress) {
80
+ $data = $this->_mapAmazonAddressLines(
81
+ $amazonAddress->getAddressLine1(),
82
+ $amazonAddress->getAddressLine2(),
83
+ $amazonAddress->getAddressLine3(),
84
+ $amazonAddress->getCountryCode()
85
+ );
86
+ $explodedName = Mage::helper('amazonpayments')->explodeCustomerName($amazonAddress->getName());
87
+ $data['firstname'] = $explodedName->getFirstname();
88
+ $data['lastname'] = $explodedName->getLastname();
89
+ $data['country_id'] = $amazonAddress->getCountryCode();
90
+ $data['city'] = $amazonAddress->getCity();
91
+ $data['postcode'] = $amazonAddress->getPostalCode();
92
+ $data['telephone'] = $amazonAddress->getPhone();
93
+ return new Varien_Object($data);
94
+ }
95
+
96
+ /**
97
+ * Convert Amazon AddressLine fields to the array indexed with the same
98
+ * keys Magento order address entities are using. Try to guess if address
99
+ * lines contain company name or PO Box
100
+ *
101
+ * @param string $addressLine1
102
+ * @param string $addressLine2
103
+ * @param string $addressLine3
104
+ * @param string $countryId
105
+ *
106
+ * @return array
107
+ */
108
+ protected function _mapAmazonAddressLines($addressLine1, $addressLine2 = null, $addressLine3 = null, $countryId = null) {
109
+ $data = array('street' => array());
110
+ if ($countryId && in_array($countryId, array('DE', 'AT'))) {
111
+ if ($addressLine3) {
112
+ if ($this->_isPoBox($addressLine1, $addressLine2)) {
113
+ $data['street'][] = $addressLine1;
114
+ $data['street'][] = $addressLine2;
115
+ } else {
116
+ $data['company'] = trim($addressLine1 . ' ' . $addressLine2);
117
+ }
118
+ $data['street'][] = $addressLine3;
119
+ } else if ($addressLine2) {
120
+ if ($this->_isPoBox($addressLine1)) {
121
+ $data['street'][] = $addressLine1;
122
+ } else {
123
+ $data['company'] = $addressLine1;
124
+ }
125
+ $data['street'][] = $addressLine2;
126
+ } else {
127
+ $data['street'][] = $addressLine1;
128
+ }
129
+ } else {
130
+ if ($addressLine1) {
131
+ $data['street'][] = $addressLine1;
132
+ }
133
+ if ($addressLine2) {
134
+ $data['street'][] = $addressLine2;
135
+ }
136
+ if ($addressLine3) {
137
+ $data['street'][] = $addressLine3;
138
+ }
139
+ }
140
+ return $data;
141
+ }
142
+
143
+ /**
144
+ * Convert transaction details object to Varien_Object indexed
145
+ * with the same keys as Magento order entity
146
+ *
147
+ * @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
148
+ *
149
+ * @return Varien_Object
150
+ */
151
+ protected function _mapTransactionDetails($transactionDetails) {
152
+ $data = array();
153
+ // OrderReferenceDetails from API response
154
+ if ($transactionDetails instanceof OffAmazonPaymentsService_Model_OrderReferenceDetails) {
155
+ if ($transactionDetails->isSetBuyer()) {
156
+ $data['customer_email'] = $transactionDetails->getBuyer()->getEmail();
157
+ $customerName = Mage::helper('amazonpayments')->explodeCustomerName($transactionDetails->getBuyer()->getName(), null);
158
+ $data['customer_firstname'] = $customerName->getFirstname();
159
+ $data['customer_lastname'] = $customerName->getLastname();
160
+ }
161
+ if ($transactionDetails->isSetDestination()) {
162
+ if ($transactionDetails->getDestination()->isSetPhysicalDestination()) {
163
+ $data['shipping_address'] = $this->_mapAmazonAddress($transactionDetails->getDestination()->getPhysicalDestination());
164
+ }
165
+ }
166
+ if ($transactionDetails->isSetBillingAddress()) {
167
+ if ($transactionDetails->getBillingAddress()->isSetPhysicalAddress()) {
168
+ $data['billing_address'] = $this->_mapAmazonAddress($transactionDetails->getBillingAddress()->getPhysicalAddress());
169
+ $data['customer_firstname'] = $data['billing_address']->getFirstname();
170
+ $data['customer_lastname'] = $data['billing_address']->getLastname();
171
+ }
172
+ } elseif (isset($data['shipping_address'])) {
173
+ $data['billing_address'] = $data['shipping_address'];
174
+ }
175
+ }
176
+ // AuthorizationDetails from API response
177
+ elseif ($transactionDetails instanceof OffAmazonPaymentsService_Model_AuthorizationDetails) {
178
+ if ($transactionDetails->isSetAuthorizationBillingAddress()) {
179
+ $data['billing_address'] = $this->_mapAmazonAddress($transactionDetails->getAuthorizationBillingAddress());
180
+ $data['customer_firstname'] = $data['billing_address']->getFirstname();
181
+ $data['customer_lastname'] = $data['billing_address']->getLastname();
182
+ }
183
+ }
184
+ return new Varien_Object($data);
185
+ }
186
+
187
+ /**
188
+ * TODO: [_mapTransactionStatus description]
189
+ *
190
+ * @param Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter $transactionAdapter
191
+ * @param Varien_Object &$stateObject
192
+ *
193
+ * @return Creativestyle_AmazonPayments_Model_Processor_Order
194
+ */
195
+ protected function _mapTransactionStatus($transactionAdapter, &$stateObject) {
196
+ switch ($transactionAdapter->getTransactionType()) {
197
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
198
+ $message = 'An order of %s has been processed by Amazon Payments (%s). The new status is %s.';
199
+ switch ($transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_KEY)) {
200
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_SUSPENDED:
201
+ $stateObject->setData(array(
202
+ 'hold_before_state' => $stateObject->getState(),
203
+ 'hold_before_status' => $stateObject->getStatus(),
204
+ 'state' => Mage_Sales_Model_Order::STATE_HOLDED,
205
+ 'status' => $this->_getConfig()->getHoldedOrderStatus($this->_store)
206
+ ));
207
+ break; // ORDER_SUSPENDED
208
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_OPEN:
209
+ $stateObject->setData(array(
210
+ 'state' => Mage_Sales_Model_Order::STATE_NEW,
211
+ 'status' => $this->_getConfig()->getNewOrderStatus($this->_store),
212
+ ));
213
+ break; // ORDER_OPEN
214
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CANCELED:
215
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED:
216
+ break; // ORDER_CANCELED / ORDER_CLOSED
217
+ }
218
+ break;
219
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
220
+ $message = 'An authorization of %s has been processed by Amazon Payments (%s). The new status is %s.';
221
+ switch ($transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_KEY)) {
222
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_PENDING:
223
+ $stateObject->setData(array(
224
+ 'state' => Mage_Sales_Model_Order::STATE_NEW,
225
+ 'status' => $this->_getConfig()->getNewOrderStatus($this->_store),
226
+ ));
227
+ break; // AUTH_PENDING
228
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_OPEN:
229
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED:
230
+ $stateObject->setData(array(
231
+ 'state' => Mage_Sales_Model_Order::STATE_PROCESSING,
232
+ 'status' => $this->_getConfig()->getAuthorizedOrderStatus($this->_store)
233
+ ));
234
+ break; // AUTH_OPEN
235
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED:
236
+ $stateObject->setData(array(
237
+ 'hold_before_state' => $stateObject->getState(),
238
+ 'hold_before_status' => $stateObject->getStatus(),
239
+ 'state' => Mage_Sales_Model_Order::STATE_HOLDED,
240
+ 'status' => $this->_getConfig()->getHoldedOrderStatus($this->_store)
241
+ ));
242
+ break; // AUTH_DECLINED
243
+ }
244
+ break;
245
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
246
+ $message = 'A capture of %s has been processed by Amazon Payments (%s). The new status is %s.';
247
+ switch ($transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_KEY)) {
248
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED:
249
+ $stateObject->setData(array(
250
+ 'hold_before_state' => $stateObject->getState(),
251
+ 'hold_before_status' => $stateObject->getStatus(),
252
+ 'state' => Mage_Sales_Model_Order::STATE_HOLDED,
253
+ 'status' => $this->_getConfig()->getHoldedOrderStatus($this->_store)
254
+ ));
255
+ break; // CAPTURE_DECLINED
256
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_COMPLETED:
257
+ $stateObject->setData(array(
258
+ 'state' => Mage_Sales_Model_Order::STATE_PROCESSING,
259
+ 'status' => $this->_getConfig()->getAuthorizedOrderStatus($this->_store)
260
+ ));
261
+ break; // CAPTURE_COMPLETED
262
+ }
263
+ break;
264
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
265
+ $message = 'A refund of %s has been processed by Amazon Payments (%s). The new status is %s.';
266
+ break;
267
+ default:
268
+ return $this;
269
+ }
270
+
271
+ $stateObject->setMessage(Mage::helper('amazonpayments')->__($message,
272
+ $this->getOrder()->getBaseCurrency()->formatTxt($transactionAdapter->getTransactionAmount()),
273
+ $transactionAdapter->getTransactionId(),
274
+ sprintf('<strong>%s</strong>', strtoupper($transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_KEY)))
275
+ ));
276
+
277
+ return $this;
278
+ }
279
+
280
+ /**
281
+ * TODO: [_sendTransactionEmails description]
282
+ *
283
+ * @param Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter $transactionAdapter
284
+ * @param Varien_Object &$stateObject
285
+ *
286
+ * @return Creativestyle_AmazonPayments_Model_Processor_Order
287
+ */
288
+ protected function _sendTransactionEmails($transactionAdapter, &$stateObject) {
289
+ switch ($transactionAdapter->getTransactionType()) {
290
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
291
+ switch ($transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_KEY)) {
292
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_OPEN:
293
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_CLOSED:
294
+ if ($this->getOrder() && !$this->getOrder()->getEmailSent() && $this->_getConfig()->sendEmailConfirmation($this->_store)) {
295
+ $this->getOrder()->sendNewOrderEmail();
296
+ $stateObject->setIsNotified(true);
297
+ }
298
+ break;
299
+ case Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_STATE_DECLINED:
300
+ if ($this->getOrder()
301
+ && $transactionAdapter->getStatusChange(Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_REASON_CODE_KEY)
302
+ == Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter::TRANSACTION_REASON_INVALID_PAYMENT)
303
+ {
304
+ Mage::helper('amazonpayments')->sendAuthorizationDeclinedEmail($this->getOrder());
305
+ $stateObject->setIsNotified(true);
306
+ }
307
+ break;
308
+ }
309
+ break;
310
+ default:
311
+ return $this;
312
+ }
313
+
314
+ return $this;
315
+ }
316
+
317
+ /**
318
+ * TODO: [_updateAddress description]
319
+ *
320
+ * @param Mage_Customer_Model_Address_Abstract $addressObject
321
+ * @param Varien_Object $addressData
322
+ */
323
+ protected function _updateAddress($addressObject, $addressData) {
324
+ if ($addressObject->getFirstname() != $addressData->getFirstname()) {
325
+ $addressObject->setFirstname($addressData->getFirstname());
326
+ }
327
+ if ($addressObject->getLastname() != $addressData->getLastname()) {
328
+ $addressObject->setLastname($addressData->getLastname());
329
+ }
330
+ if ($addressObject->getCompany() != $addressData->getCompany()) {
331
+ $addressObject->setCompany($addressData->getCompany());
332
+ }
333
+ if ($addressObject->getCity() != $addressData->getCity()) {
334
+ $addressObject->setCity($addressData->getCity());
335
+ }
336
+ if ($addressObject->getPostcode() != $addressData->getPostcode()) {
337
+ $addressObject->setPostcode($addressData->getPostcode());
338
+ }
339
+ if ($addressObject->getCountryId() != $addressData->getCountryId()) {
340
+ $addressObject->setCountryId($addressData->getCountryId());
341
+ }
342
+ if ($addressObject->getTelephone() != $addressData->getTelephone()) {
343
+ $addressObject->setTelephone($addressData->getTelephone());
344
+ }
345
+ $streetDiff = array_diff($addressObject->getStreet(), $addressData->getStreet());
346
+ if (!empty($streetDiff)) {
347
+ $addressObject->setStreet($addressData->getStreet());
348
+ }
349
+ }
350
+
351
+ /**
352
+ * TODO: [_updateOrderData description]
353
+ *
354
+ * @param Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter $transactionAdapter
355
+ * @param Varien_Object &$stateObject
356
+ *
357
+ * @return Creativestyle_AmazonPayments_Model_Processor_Order
358
+ */
359
+ protected function _updateOrderData($transactionAdapter, &$stateObject) {
360
+ $orderData = $this->_mapTransactionDetails($transactionAdapter->getTransactionDetails());
361
+ if ($orderData->hasCustomerEmail() && $this->getOrder()->getCustomerEmail() != $orderData->getCustomerEmail()) {
362
+ $this->getOrder()->setCustomerEmail($orderData->getCustomerEmail());
363
+ }
364
+ if ($orderData->hasCustomerFirstname() && $this->getOrder()->getCustomerFirstname() != $orderData->getCustomerFirstname()) {
365
+ $this->getOrder()->setCustomerFirstname($orderData->getCustomerFirstname());
366
+ }
367
+ if ($orderData->hasCustomerLastname() && $this->getOrder()->getCustomerLastname() != $orderData->getCustomerLastname()) {
368
+ $this->getOrder()->setCustomerLastname($orderData->getCustomerLastname());
369
+ }
370
+ if ($orderData->hasBillingAddress()) {
371
+ $this->_updateAddress($this->getOrder()->getBillingAddress(), $orderData->getBillingAddress());
372
+ }
373
+ if ($orderData->hasShippingAddress()) {
374
+ $this->_updateAddress($this->getOrder()->getShippingAddress(), $orderData->getShippingAddress());
375
+ }
376
+
377
+ $this->_mapTransactionStatus($transactionAdapter, $stateObject);
378
+
379
+ $this->_sendTransactionEmails($transactionAdapter, $stateObject);
380
+
381
+ if ($stateObject->getState() != $this->getOrder()->getState() || $stateObject->getStatus() != $this->getOrder()->getStatus()) {
382
+ $this->getOrder()
383
+ ->setHoldBeforeState($stateObject->getHoldBeforeState() ? $stateObject->getHoldBeforeState() : null)
384
+ ->setHoldBeforeStatus($stateObject->getHoldBeforeStatus() ? $stateObject->getHoldBeforeStatus() : null)
385
+ ->setState(
386
+ $stateObject->getState(),
387
+ $stateObject->getStatus(),
388
+ $stateObject->getMessage(),
389
+ $stateObject->getIsNotified()
390
+ );
391
+ } else if ($stateObject->getMessage()) {
392
+ $this->getOrder()->addStatusHistoryComment($stateObject->getMessage());
393
+ }
394
+
395
+ return $this;
396
+ }
397
+
398
+ /**
399
+ * TODO: [setOrder description]
400
+ *
401
+ * @param Mage_Sales_Model_Order $order
402
+ *
403
+ * @return Creativestyle_AmazonPayments_Model_Processor_Order
404
+ */
405
+ public function setOrder($order) {
406
+ $this->_order = $order;
407
+ $this->_store = $order->getStoreId();
408
+ return $this;
409
+ }
410
+
411
+ /**
412
+ * TODO: [getOrder description]
413
+ *
414
+ * @return Mage_Sales_Model_Order
415
+ */
416
+ public function getOrder() {
417
+ if (null === $this->_order) {
418
+ throw new Creativestyle_AmazonPayments_Exception('Order object is not set');
419
+ }
420
+ return $this->_order;
421
+ }
422
+
423
+ /**
424
+ * TODO: [importTransactionDetails description]
425
+ *
426
+ * @param Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter $transactionAdapter
427
+ * @param Varien_Object &$stateObject
428
+ *
429
+ * @return Creativestyle_AmazonPayments_Model_Processor_Order
430
+ */
431
+ public function importTransactionDetails($transactionAdapter, &$stateObject) {
432
+ $this->_initStateObject($stateObject)->_updateOrderData($transactionAdapter, $stateObject);
433
+ $relatedTransactionAdapter = $transactionAdapter->processRelatedObjects($this->getOrder());
434
+ if (null !== $relatedTransactionAdapter) {
435
+ $this->_initStateObject($stateObject)->_updateOrderData($relatedTransactionAdapter, $stateObject);
436
+ }
437
+ return $this;
438
+ }
439
+
440
+ /**
441
+ * TODO: [saveOrder description]
442
+ *
443
+ * @return Creativestyle_AmazonPayments_Model_Processor_Order
444
+ */
445
+ public function saveOrder() {
446
+ if ($this->getOrder()->hasDataChanges()) {
447
+ $this->getOrder()->save();
448
+ }
449
+ return $this;
450
+ }
451
+
452
+ }
app/code/community/Creativestyle/AmazonPayments/Model/Processor/Payment.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Payment {
17
+
18
+ /**
19
+ * TODO: Payment info instance
20
+ *
21
+ * @var null
22
+ */
23
+ protected $_payment = null;
24
+
25
+ /**
26
+ * TODO: [$_store description]
27
+ *
28
+ * @var null
29
+ */
30
+ protected $_store = null;
31
+
32
+ /**
33
+ * TODO: [setPaymentObject description]
34
+ *
35
+ * @param Mage_Sales_Model_Order_Payment $payment
36
+ *
37
+ * @return Creativestyle_AmazonPayments_Model_Processor_Payment
38
+ */
39
+ public function setPaymentObject($payment) {
40
+ $this->_payment = $payment;
41
+ $this->_store = $payment->getOrder()->getStoreId();
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * TODO: [getPayment description]
47
+ *
48
+ * @return Mage_Sales_Model_Order_Payment
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
+ * TODO: [_getApi description]
59
+ *
60
+ * @return [type] [description]
61
+ */
62
+ protected function _getApi() {
63
+ return Mage::getSingleton('amazonpayments/api_advanced')->setStore($this->_store);
64
+ }
65
+
66
+ /**
67
+ * Import transaction details to the Magento order and its related objects
68
+ *
69
+ * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
70
+ * @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
71
+ *
72
+ * @return Varien_Object
73
+ */
74
+ protected function _importTransactionDetails($transaction, $transactionDetails = null) {
75
+ $transactionAdapter = Mage::getModel('amazonpayments/processor_transactionAdapter');
76
+ $transactionAdapter->setStore($this->_store)
77
+ ->setTransaction($transaction)
78
+ ->setTransactionDetails($transactionDetails);
79
+ return $transactionAdapter;
80
+ }
81
+
82
+ /**
83
+ * Transfer order to Amazon Payments gateway
84
+ *
85
+ * @param float $amount
86
+ * @param string $transactionSequenceId
87
+ */
88
+ public function order($amount, $transactionSequenceId) {
89
+ if (!$this->getPayment()->getSkipOrderReferenceProcessing()) {
90
+ $this->_getApi()->setOrderReferenceDetails(
91
+ $transactionSequenceId,
92
+ $amount,
93
+ $this->getPayment()->getOrder()->getBaseCurrencyCode(),
94
+ $this->getPayment()->getOrder()->getIncrementId()
95
+ );
96
+ }
97
+ $this->_getApi()->confirmOrderReference($transactionSequenceId);
98
+ Creativestyle_AmazonPayments_Model_Simulator::simulate($this->getPayment(), 'OrderReference');
99
+ }
100
+
101
+ /**
102
+ * Authorize order amount on Amazon Payments gateway
103
+ *
104
+ * @param float $amount
105
+ * @param string $transactionSequenceId
106
+ * @param string $parentTransactionId
107
+ * @param bool $captureNow
108
+ * @param bool $synchronous
109
+ *
110
+ * @return OffAmazonPaymentsService_Model_AuthorizationDetails
111
+ */
112
+ public function authorize($amount, $transactionSequenceId, $parentTransactionId, $captureNow = false, $synchronous = false) {
113
+ return $this->_getApi()->authorize(
114
+ $parentTransactionId,
115
+ $transactionSequenceId,
116
+ $amount,
117
+ $this->getPayment()->getOrder()->getBaseCurrencyCode(),
118
+ Creativestyle_AmazonPayments_Model_Simulator::simulate($this->getPayment(), 'Authorization'),
119
+ $captureNow,
120
+ $synchronous ? 0 : null
121
+ );
122
+ }
123
+
124
+ /**
125
+ * Capture order amount on Amazon Payments gateway
126
+ *
127
+ * @param float $amount
128
+ * @param string $transactionSequenceId
129
+ * @param string $parentTransactionId
130
+ *
131
+ * @return OffAmazonPaymentsService_Model_AuthorizationDetails
132
+ */
133
+ public function capture($amount, $transactionSequenceId, $parentTransactionId) {
134
+ return $this->_getApi()->capture(
135
+ $parentTransactionId,
136
+ $transactionSequenceId,
137
+ $amount,
138
+ $this->getPayment()->getOrder()->getBaseCurrencyCode(),
139
+ Creativestyle_AmazonPayments_Model_Simulator::simulate($this->getPayment(), 'Capture')
140
+ );
141
+ }
142
+
143
+ /**
144
+ * Refund amount on Amazon Payments gateway
145
+ *
146
+ * @param float $amount
147
+ * @param string $transactionSequenceId
148
+ * @param string $parentTransactionId
149
+ *
150
+ * @return OffAmazonPaymentsService_Model_AuthorizationDetails
151
+ */
152
+ public function refund($amount, $transactionSequenceId, $parentTransactionId) {
153
+ return $this->_getApi()->refund(
154
+ $parentTransactionId,
155
+ $transactionSequenceId,
156
+ $amount,
157
+ $this->getPayment()->getOrder()->getBaseCurrencyCode(),
158
+ Creativestyle_AmazonPayments_Model_Simulator::simulate($this->getPayment(), 'Refund')
159
+ );
160
+ }
161
+
162
+ /**
163
+ * Public wrapper for _importTransactionDetails() method
164
+ *
165
+ * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
166
+ * @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
167
+ *
168
+ * @return Varien_Object
169
+ */
170
+ public function importTransactionDetails($transaction, $transactionDetails = null) {
171
+ return $this->_importTransactionDetails($transaction, $transactionDetails);
172
+ }
173
+
174
+ }
app/code/community/Creativestyle/AmazonPayments/Model/Processor/TransactionAdapter.php ADDED
@@ -0,0 +1,452 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
22
+ const TRANSACTION_STATE_DRAFT = 'Draft';
23
+ const TRANSACTION_STATE_PENDING = 'Pending';
24
+ const TRANSACTION_STATE_OPEN = 'Open';
25
+ const TRANSACTION_STATE_SUSPENDED = 'Suspended';
26
+ const TRANSACTION_STATE_DECLINED = 'Declined';
27
+ const TRANSACTION_STATE_COMPLETED = 'Completed';
28
+ const TRANSACTION_STATE_CANCELED = 'Canceled';
29
+ const TRANSACTION_STATE_CLOSED = 'Closed';
30
+
31
+ const TRANSACTION_REASON_INVALID_PAYMENT = 'InvalidPaymentMethod';
32
+ const TRANSACTION_REASON_TIMEOUT = 'TransactionTimedOut';
33
+ const TRANSACTION_REASON_AMAZON_REJECTED = 'AmazonRejected';
34
+
35
+ /**
36
+ * TODO: [$_store description]
37
+ *
38
+ * @var null
39
+ */
40
+ protected $_store = null;
41
+
42
+ /**
43
+ * Magento payment transaction instance
44
+ *
45
+ * @var Mage_Sales_Model_Order_Payment_Transaction|null
46
+ */
47
+ protected $_transaction = null;
48
+
49
+ /**
50
+ * Transaction details object retrieved from Amazon Payments API
51
+ *
52
+ * @var OffAmazonPaymentsService_Model|OffAmazonPayments_Model|null
53
+ */
54
+ protected $_transactionDetails = null;
55
+
56
+ /**
57
+ * Transaction amount extracted from transaction details
58
+ *
59
+ * @var float|null
60
+ */
61
+ protected $_transactionAmount = null;
62
+
63
+ /**
64
+ * An array reflecting transaction status change in the recently
65
+ * got Amazon Payments API call response in comparison to
66
+ * corresponding Magento transaction saved in database
67
+ *
68
+ * @var array|false|null
69
+ */
70
+ protected $_statusChange = null;
71
+
72
+ /**
73
+ * TODO: [_getApi description]
74
+ *
75
+ * @return Creativestyle_AmazonPayments_Model_Api_Advanced
76
+ */
77
+ protected function _getApi() {
78
+ return Mage::getSingleton('amazonpayments/api_advanced')->setStore($this->_store);
79
+ }
80
+
81
+ /**
82
+ * Extract transaction status from the transaction details
83
+ *
84
+ * Extract and return transaction status array (state, reason code)
85
+ * from the transaction details.
86
+ *
87
+ * @param string $key
88
+ *
89
+ * @return array|null
90
+ */
91
+ protected function _extractTransactionStatus($key = null) {
92
+ if (null !== $this->_transaction && $this->getTransactionDetails()) {
93
+ if (call_user_func(array($this->getTransactionDetails(), 'isSet' . $this->_getAmazonTransactionType() . 'Status'))) {
94
+ $transactionStatus = call_user_func(array($this->getTransactionDetails(), 'get' . $this->_getAmazonTransactionType() . 'Status'));
95
+ $status = array(self::TRANSACTION_STATE_KEY => $transactionStatus->getState());
96
+ if ($transactionStatus->isSetReasonCode()) {
97
+ $status[self::TRANSACTION_REASON_CODE_KEY] = $transactionStatus->getReasonCode();
98
+ }
99
+ if ($transactionStatus->isSetReasonDescription()) {
100
+ $status[self::TRANSACTION_REASON_DESCRIPTION_KEY] = $transactionStatus->getReasonDescription();
101
+ }
102
+ if (null !== $key) {
103
+ if (array_key_exists($key, $status)) {
104
+ return $status[$key];
105
+ }
106
+ return null;
107
+ }
108
+ return $status;
109
+ }
110
+ }
111
+ return null;
112
+ }
113
+
114
+ /**
115
+ * Check if transaction status has changed
116
+ *
117
+ * Extract transaction status from the transaction details. If the
118
+ * status in assigned transaction details is the same as in
119
+ * corresponding transaction saved in Magento then return false to
120
+ * distinguish in the further processes that there's no need to
121
+ * update payment or order data.
122
+ *
123
+ * @return array|false
124
+ */
125
+ protected function _checkStatusChange() {
126
+ $transactionStatus = $this->_extractTransactionStatus();
127
+ if (null !== $transactionStatus && Mage::helper('amazonpayments')->getTransactionInformation($this->_transaction, self::TRANSACTION_STATE_KEY) != $transactionStatus[self::TRANSACTION_STATE_KEY]) {
128
+ return $transactionStatus;
129
+ }
130
+ return false;
131
+ }
132
+
133
+ /**
134
+ * TODO: [_extractIdList description]
135
+ *
136
+ * @return array|null
137
+ */
138
+ protected function _extractIdList() {
139
+ $transactionDetails = $this->getTransactionDetails();
140
+ if (is_callable(array($transactionDetails, 'isSetIdList'))) {
141
+ if ($transactionDetails->isSetIdList()) {
142
+ $idList = $transactionDetails->getIdList();
143
+ if (is_callable(array($idList, 'isSetmember'))) {
144
+ if ($idList->isSetmember()) {
145
+ return $idList->getmember();
146
+ }
147
+ } else if (is_callable(array($idList, 'isSetId'))) {
148
+ if ($idList->isSetId()) {
149
+ return $idList->getId();
150
+ }
151
+ }
152
+ }
153
+ }
154
+ return null;
155
+ }
156
+
157
+ /**
158
+ * Retrieve transaction details from Amazon Payments API
159
+ *
160
+ * Retrieves details for provided Magento transaction object using
161
+ * Amazon Payments API client. Before making a call, identifies the
162
+ * type of provided transaction type by using appropriate function.
163
+ *
164
+ * @return OffAmazonPayments_Model|null
165
+ */
166
+ protected function _fetchTransactionDetails() {
167
+ if (null !== $this->_transaction) {
168
+ return call_user_func(array($this->_getApi(), 'get' . $this->_getAmazonTransactionType() . 'Details'), $this->getTransactionId());
169
+ }
170
+ return null;
171
+ }
172
+
173
+ /**
174
+ * Returns Amazon Payments-specific name for transaction type
175
+ *
176
+ * Checks the type of provided payment transaction object and
177
+ * returns its corresponding Amazon transaction name. Returns
178
+ * null if type of provided transaction object is neither
179
+ * recognized nor has an Amazon Payments equivalent.
180
+ *
181
+ * @param Mage_Sales_Model_Order_Payment_Transaction $transaction
182
+ *
183
+ * @return string|null
184
+ */
185
+ protected function _getAmazonTransactionType() {
186
+ switch ($this->getTransactionType()) {
187
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
188
+ return 'OrderReference';
189
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
190
+ return 'Authorization';
191
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
192
+ return 'Capture';
193
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
194
+ return 'Refund';
195
+ }
196
+ return null;
197
+ }
198
+
199
+ /**
200
+ * Update status of Magento payment transaction object
201
+ *
202
+ * @param array $transactionStatus
203
+ *
204
+ * @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
205
+ */
206
+ protected function _updateTransactionStatus($transactionStatus) {
207
+ $this->_transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transactionStatus);
208
+ if (is_array($transactionStatus) && array_key_exists(self::TRANSACTION_STATE_KEY, $transactionStatus)) {
209
+ switch ($transactionStatus[self::TRANSACTION_STATE_KEY]) {
210
+ case self::TRANSACTION_STATE_DECLINED:
211
+ case self::TRANSACTION_STATE_CANCELED:
212
+ case self::TRANSACTION_STATE_CLOSED:
213
+ case self::TRANSACTION_STATE_COMPLETED:
214
+ $this->_transaction->setIsClosed(true);
215
+ break;
216
+ default:
217
+ break;
218
+ }
219
+ }
220
+ return $this;
221
+ }
222
+
223
+ /**
224
+ * TODO: [setStore description]
225
+ *
226
+ * @param [type] $store
227
+ *
228
+ * @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
229
+ */
230
+ public function setStore($store) {
231
+ $this->_store = $store;
232
+ return $this;
233
+ }
234
+
235
+ /**
236
+ * TODO: [setTransaction description]
237
+ *
238
+ * @param Mage_Sales_Model_Order_Payment_Transaction $transaction [description]
239
+ *
240
+ * @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
241
+ */
242
+ public function setTransaction($transaction) {
243
+ $this->_transaction = $transaction;
244
+ return $this;
245
+ }
246
+
247
+ /**
248
+ * TODO: [setTransactionDetails description]
249
+ *
250
+ * @param OffAmazonPaymentsService_Model|OffAmazonPayments_Model $transactionDetails
251
+ *
252
+ * @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
253
+ */
254
+ public function setTransactionDetails($transactionDetails) {
255
+ $this->_transactionDetails = $transactionDetails;
256
+ return $this;
257
+ }
258
+
259
+ /**
260
+ * TODO: [getTransaction description]
261
+ *
262
+ * @return Mage_Sales_Model_Order_Payment_Transaction|null
263
+ */
264
+ public function getTransaction() {
265
+ return $this->_transaction;
266
+ }
267
+
268
+ /**
269
+ * TODO: [getTransactionType description]
270
+ *
271
+ * @return string|null
272
+ */
273
+ public function getTransactionType() {
274
+ if (null !== $this->_transaction) {
275
+ return $this->_transaction->getTxnType();
276
+ }
277
+ return null;
278
+ }
279
+
280
+ /**
281
+ * TODO: [getTransactionId description]
282
+ *
283
+ * @return string
284
+ */
285
+ public function getTransactionId() {
286
+ if (null !== $this->_transaction) {
287
+ return $this->_transaction->getTxnId();
288
+ }
289
+ return null;
290
+ }
291
+
292
+ /**
293
+ * TODO: [getTransactionDetails description]
294
+ *
295
+ * @return OffAmazonPaymentsService_Model|OffAmazonPayments_Model|null
296
+ */
297
+ public function getTransactionDetails() {
298
+ if (null === $this->_transactionDetails) {
299
+ $this->_transactionDetails = $this->_fetchTransactionDetails();
300
+ }
301
+ return $this->_transactionDetails;
302
+ }
303
+
304
+ /**
305
+ * TODO: [getTransactionAmount description]
306
+ *
307
+ * @return float
308
+ */
309
+ public function getTransactionAmount() {
310
+ if (null === $this->_transactionAmount) {
311
+ $transactionAmountObject = call_user_func(array($this->getTransactionDetails(), $this->getTransactionType() == Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER ? 'getOrderTotal' : 'get' . $this->_getAmazonTransactionType() . 'Amount'));
312
+ $this->_transactionAmount = $transactionAmountObject->getAmount();
313
+ }
314
+ return $this->_transactionAmount;
315
+ }
316
+
317
+ /**
318
+ * TODO: [getStatusChange description]
319
+ *
320
+ * @param string $key
321
+ *
322
+ * @return array|string|false|null
323
+ */
324
+ public function getStatusChange($key = null) {
325
+ if (null === $this->_statusChange) {
326
+ $this->_statusChange = $this->_checkStatusChange();
327
+ if ($this->_statusChange) {
328
+ $this->_updateTransactionStatus($this->_statusChange);
329
+ }
330
+ }
331
+ if (null !== $key) {
332
+ if (is_array($this->_statusChange) && array_key_exists($key, $this->_statusChange)) {
333
+ return $this->_statusChange[$key];
334
+ }
335
+ return null;
336
+ }
337
+ return $this->_statusChange;
338
+ }
339
+
340
+ /**
341
+ * TODO: [processRelatedObjects description]
342
+ *
343
+ * @param Mage_Sales_Model_Order $order
344
+ *
345
+ * @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter|null
346
+ */
347
+ public function processRelatedObjects($order) {
348
+ switch ($this->getTransactionType()) {
349
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
350
+ if ($this->_extractTransactionStatus(self::TRANSACTION_STATE_KEY) == self::TRANSACTION_STATE_OPEN) {
351
+ $authTransaction = $order->getPayment()->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
352
+ if ($authTransaction && $authTransaction->getIsClosed() && ($order->getBaseTotalDue() > 0)) {
353
+ $order->getPayment()->getMethodInstance()->setStore($order->getStoreId())->authorize($order->getPayment(), $order->getBaseTotalDue());
354
+ }
355
+ }
356
+ break;
357
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
358
+ $childrenIds = $this->_extractIdList();
359
+ if (is_array($childrenIds)) {
360
+ foreach ($childrenIds as $childTransactionId) {
361
+ if (!$order->getPayment()->lookupTransaction($childTransactionId)) {
362
+ $childTransaction = $order->getPayment()->setIsTransactionClosed(false)
363
+ ->setTransactionId($childTransactionId)
364
+ ->setParentTransactionId($this->getTransactionId())
365
+ ->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
366
+ $captureAdapter = Mage::getSingleton('amazonpayments/processor_payment')
367
+ ->setPaymentObject($order->getPayment())
368
+ ->importTransactionDetails($childTransaction);
369
+ $captureAdapter->validateTransactionStatus();
370
+ $invoice = $order->prepareInvoice()
371
+ ->setTransactionId($childTransactionId)
372
+ ->register()
373
+ ->pay();
374
+ $order->addRelatedObject($invoice);
375
+ return $captureAdapter;
376
+ }
377
+ }
378
+ }
379
+ break;
380
+ }
381
+ return null;
382
+ }
383
+
384
+ /**
385
+ * TODO: [saveTransaction description]
386
+ *
387
+ * @return Creativestyle_AmazonPayments_Model_Processor_TransactionAdapter
388
+ */
389
+ public function saveTransaction() {
390
+ $this->_transaction->save();
391
+ return $this;
392
+ }
393
+
394
+ /**
395
+ * TODO: [validateTransactionStatus description]
396
+ *
397
+ * @return bool
398
+ *
399
+ * @throws Creativestyle_AmazonPayments_Exception_InvalidStatus_Recoverable
400
+ * @throws Creativestyle_AmazonPayments_Exception_InvalidStatus
401
+ * @throws Creativestyle_AmazonPayments_Exception
402
+ */
403
+ public function validateTransactionStatus() {
404
+ $transactionStatus = $this->getStatusChange();
405
+ if (is_array($transactionStatus)) {
406
+ $state = array_key_exists(self::TRANSACTION_STATE_KEY, $transactionStatus) ? $transactionStatus[self::TRANSACTION_STATE_KEY] : null;
407
+ $reason = array_key_exists(self::TRANSACTION_REASON_CODE_KEY, $transactionStatus) ? $transactionStatus[self::TRANSACTION_REASON_CODE_KEY] : null;
408
+ switch ($this->getTransactionType()) {
409
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER:
410
+ switch ($state) {
411
+ case self::TRANSACTION_STATE_OPEN:
412
+ return true;
413
+ default:
414
+ throw new Creativestyle_AmazonPayments_Exception('Invalid Order Reference status');
415
+ }
416
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH:
417
+ switch ($state) {
418
+ case self::TRANSACTION_STATE_PENDING:
419
+ case self::TRANSACTION_STATE_OPEN:
420
+ case self::TRANSACTION_STATE_CLOSED:
421
+ return true;
422
+ case self::TRANSACTION_STATE_DECLINED:
423
+ switch ($reason) {
424
+ case self::TRANSACTION_REASON_INVALID_PAYMENT:
425
+ throw new Creativestyle_AmazonPayments_Exception_InvalidStatus_Recoverable('Invalid Authorization status');
426
+ case self::TRANSACTION_REASON_TIMEOUT:
427
+ case self::TRANSACTION_REASON_AMAZON_REJECTED:
428
+ throw new Creativestyle_AmazonPayments_Exception_InvalidStatus('Invalid Authorization status');
429
+ }
430
+ default:
431
+ throw new Creativestyle_AmazonPayments_Exception('Invalid Authorization status');
432
+ }
433
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE:
434
+ switch ($state) {
435
+ case self::TRANSACTION_STATE_PENDING:
436
+ case self::TRANSACTION_STATE_COMPLETED:
437
+ return true;
438
+ default:
439
+ throw new Creativestyle_AmazonPayments_Exception('Invalid Capture status');
440
+ }
441
+ case Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND:
442
+ default:
443
+ return true;
444
+ //throw new Creativestyle_AmazonPayments_Exception('Invalid Refund status');
445
+ default:
446
+ throw new Creativestyle_AmazonPayments_Exception('Invalid transaction type');
447
+ }
448
+ }
449
+ throw new Creativestyle_AmazonPayments_Exception('Invalid transaction status');
450
+ }
451
+
452
+ }
app/code/community/Creativestyle/AmazonPayments/controllers/Adminhtml/OrderController.php CHANGED
@@ -39,7 +39,8 @@ class Creativestyle_AmazonPayments_Adminhtml_OrderController extends Mage_Adminh
39
  $order->getPayment()
40
  ->setAmountAuthorized($order->getTotalDue())
41
  ->setBaseAmountAuthorized($order->getBaseTotalDue())
42
- ->getMethodInstance()->authorize($order->getPayment(), $order->getBaseTotalDue())->saveOrder($order);
 
43
  }
44
  }
45
  } catch (OffAmazonPaymentsService_Exception $e) {
39
  $order->getPayment()
40
  ->setAmountAuthorized($order->getTotalDue())
41
  ->setBaseAmountAuthorized($order->getBaseTotalDue())
42
+ ->getMethodInstance()->authorize($order->getPayment(), $order->getBaseTotalDue());
43
+ $order->save();
44
  }
45
  }
46
  } catch (OffAmazonPaymentsService_Exception $e) {
app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/IpnController.php CHANGED
@@ -56,7 +56,7 @@ class Creativestyle_AmazonPayments_Advanced_IpnController extends Mage_Core_Cont
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(
@@ -67,7 +67,7 @@ class Creativestyle_AmazonPayments_Advanced_IpnController extends Mage_Core_Cont
67
  'request_body' => Mage::app()->getRequest()->getRawBody()
68
  )
69
  ));
70
- Mage::getSingleton('amazonpayments/manager')->processNotification($notification);
71
  $this->_sendResponse(200);
72
  } catch (Exception $e) {
73
  Creativestyle_AmazonPayments_Model_Logger::logException($e);
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(
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);
app/code/community/Creativestyle/AmazonPayments/controllers/Advanced/LoginController.php CHANGED
@@ -29,6 +29,10 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
29
  return Mage::getSingleton('amazonpayments/config');
30
  }
31
 
 
 
 
 
32
  private function _getCustomerSession() {
33
  return Mage::getSingleton('customer/session');
34
  }
@@ -169,10 +173,22 @@ class Creativestyle_AmazonPayments_Advanced_LoginController extends Mage_Core_Co
169
  throw new Creativestyle_AmazonPayments_Exception('[LWA-controller] Provided access_token is invalid');
170
  } catch (Exception $e) {
171
  Creativestyle_AmazonPayments_Model_Logger::logException($e);
172
- $this->_getCustomerSession()->addError($this->__('There was an error connecting your Amazon account. Please contact us or try again later.'));
 
 
 
 
173
  $this->_redirectReferer();
174
  return;
175
  }
 
 
 
 
 
 
 
 
176
  }
177
  $this->_forward('noRoute');
178
  }
29
  return Mage::getSingleton('amazonpayments/config');
30
  }
31
 
32
+ private function _getCheckoutSession() {
33
+ return Mage::getSingleton('checkout/session');
34
+ }
35
+
36
  private function _getCustomerSession() {
37
  return Mage::getSingleton('customer/session');
38
  }
173
  throw new Creativestyle_AmazonPayments_Exception('[LWA-controller] Provided access_token is invalid');
174
  } catch (Exception $e) {
175
  Creativestyle_AmazonPayments_Model_Logger::logException($e);
176
+ if (strtolower($this->getRequest()->getParam('target', null)) == 'checkout') {
177
+ $this->_getCheckoutSession()->addError($this->__('There was an error connecting your Amazon account. Please contact us or try again later.'));
178
+ } else {
179
+ $this->_getCustomerSession()->addError($this->__('There was an error connecting your Amazon account. Please contact us or try again later.'));
180
+ }
181
  $this->_redirectReferer();
182
  return;
183
  }
184
+ } elseif ($error = $this->getRequest()->getParam('error', false)) {
185
+ if (strtolower($this->getRequest()->getParam('target', null)) == 'checkout') {
186
+ $this->_getCheckoutSession()->addError($this->__('You have aborted the login with Amazon. Please contact us or try again.'));
187
+ } else {
188
+ $this->_getCustomerSession()->addError($this->__('You have aborted the login with Amazon. Please contact us or try again.'));
189
+ }
190
+ $this->_redirectUrl($this->_getRedirectFailureUrl());
191
+ return;
192
  }
193
  $this->_forward('noRoute');
194
  }
app/code/community/Creativestyle/AmazonPayments/etc/config.xml CHANGED
@@ -17,7 +17,7 @@
17
  <config>
18
  <modules>
19
  <Creativestyle_AmazonPayments>
20
- <version>1.6.0</version>
21
  </Creativestyle_AmazonPayments>
22
  </modules>
23
  <global>
17
  <config>
18
  <modules>
19
  <Creativestyle_AmazonPayments>
20
+ <version>1.6.2</version>
21
  </Creativestyle_AmazonPayments>
22
  </modules>
23
  <global>
app/code/community/Creativestyle/AmazonPayments/sql/amazonpayments_setup/mysql4-install-1.6.2.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
17
+ $installer = $this;
18
+ $installer->startSetup();
19
+
20
+ $installer->addAttribute('customer', 'amazon_user_id', array(
21
+ 'type' => 'varchar',
22
+ 'label' => 'Amazon UID',
23
+ 'visible' => false,
24
+ 'required' => false,
25
+ 'unique' => true
26
+ ));
27
+
28
+ $installer->endSetup();
app/locale/de_DE/Creativestyle_AmazonPayments.csv CHANGED
@@ -151,3 +151,4 @@
151
  "Whoops! Your Secret Access Key seems to be invalid.","Whoops! Ihr Secret Access Key ist nicht korrekt.""With Amazon Payments, 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.","Mit Login und Bezahlen über Amazon können Sie im Webshop mit den Zahlungs- und Versandinformationen aus Ihrem Amazon-Kundenkonto bezahlen. Das macht Einkaufen bei uns schnell, einfach und sicher."
152
  "X-Large","Sehr groß"
153
  "X-Large (173 x 27 pixels)","Sehr groß (173 x 27 Pixel)"
 
151
  "Whoops! Your Secret Access Key seems to be invalid.","Whoops! Ihr Secret Access Key ist nicht korrekt.""With Amazon Payments, 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.","Mit Login und Bezahlen über Amazon können Sie im Webshop mit den Zahlungs- und Versandinformationen aus Ihrem Amazon-Kundenkonto bezahlen. Das macht Einkaufen bei uns schnell, einfach und sicher."
152
  "X-Large","Sehr groß"
153
  "X-Large (173 x 27 pixels)","Sehr groß (173 x 27 Pixel)"
154
+ "You have aborted the login with Amazon. Please contact us or try again.","Sie haben den Login mit Amazon abgebrochen. Kontaktieren Sie uns oder probieren Sie es bitte später erneut."
app/locale/en_GB/Creativestyle_AmazonPayments.csv CHANGED
@@ -151,3 +151,4 @@
151
  "With Amazon Payments, 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.","With Amazon Payments, 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."
152
  "X-Large","X-Large"
153
  "X-Large (173 x 27 pixels)","X-Large (173 x 27 pixels)"
 
151
  "With Amazon Payments, 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.","With Amazon Payments, 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."
152
  "X-Large","X-Large"
153
  "X-Large (173 x 27 pixels)","X-Large (173 x 27 pixels)"
154
+ "You have aborted the login with Amazon. Please contact us or try again.","You have aborted the login with Amazon. Please contact us or try again."
app/locale/en_US/Creativestyle_AmazonPayments.csv CHANGED
@@ -151,3 +151,4 @@
151
  "With Amazon Payments, 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.","With Amazon Payments, 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."
152
  "X-Large","X-Large"
153
  "X-Large (173 x 27 pixels)","X-Large (173 x 27 pixels)"
 
151
  "With Amazon Payments, 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.","With Amazon Payments, 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."
152
  "X-Large","X-Large"
153
  "X-Large (173 x 27 pixels)","X-Large (173 x 27 pixels)"
154
+ "You have aborted the login with Amazon. Please contact us or try again.","You have aborted the login with Amazon. Please contact us or try again."
package.xml CHANGED
@@ -1,19 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Creativestyle_AmazonPayments</name>
4
- <version>1.6.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://creativecommons.org/licenses/by-nd/4.0/">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>ADDED: synchronous authorization&#xD;
12
- ADDED: initial order status config option</notes>
 
13
  <authors><author><name>creativestyle GmbH</name><user>creativestyle</user><email>amazon@creativestyle.de</email></author></authors>
14
- <date>2015-03-19</date>
15
- <time>01:08:41</time>
16
- <contents><target name="magecommunity"><dir name="Creativestyle"><dir name="AmazonPayments"><dir name="Block"><file name="Abstract.php" hash="ce9a49bde52db0195d94bf409029b8c6"/><dir name="Adminhtml"><file name="CredentialsValidator.php" hash="bb62c178c7bba1dd30fa16f22394ec85"/><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="cc798f2987cc0dffc755a88988b74912"/><file name="Info.php" hash="be764b1856eccc2b3070a1ea4cfe57f7"/><file name="IpnUrl.php" hash="f9a516356c4c9b98e02eb3761ad5bf90"/><dir name="Log"><file name="Abstract.php" hash="02887066c2d6973141dff769b385d8fa"/><dir name="Api"><file name="Grid.php" hash="8d072ba9ce4be99222c03a26680d51eb"/><file name="View.php" hash="eb30544643fa9571a454a763111d0113"/></dir><file name="Api.php" hash="5ea0736c83de5feb01df0a3ec4db4d80"/><dir name="Exception"><file name="Grid.php" hash="3c3decb0a90638d5e2b1617426ec9437"/><file name="View.php" hash="cae17d2a2d5716e8dde1c6662397131e"/></dir><file name="Exception.php" hash="c35dafcaf89ca709394341394862f4cf"/><dir name="Ipn"><file name="Grid.php" hash="74bb51ab562b09d42bd9ced6d6609ae1"/><file name="View.php" hash="6ab63414642658e95258a73a143e6955"/></dir><file name="Ipn.php" hash="a2225b081ccb354bfe94b4a646b0d521"/><dir name="View"><file name="Abstract.php" hash="0a4c977a1f89622148bdc6acc037fc1f"/></dir></dir><dir name="Renderer"><file name="Timestamp.php" hash="190325613c20e2cf97adc28950658e99"/></dir><dir name="Sales"><file name="Order.php" hash="45a5ee919501a2bf26160d38dafccd44"/></dir></dir><dir name="Button"><file name="Js.php" hash="29f5907c8898af60bdc78d957998da3f"/></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="Js"><file name="Interface.php" hash="11827746ff821b4cbda1ad041e30321e"/></dir><file name="Js.php" hash="8610dddee84cda450c4874e0fd93b5f5"/><dir name="Login"><file name="Abstract.php" hash="b84dfbbe66bbee39a547d33e856b4a8d"/><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="b122db0163e8580f42679f13a3a45726"/></dir><dir name="Pay"><file name="Abstract.php" hash="2e96e1d4a1a0e2c74cee40a46a75241c"/><file name="Button.php" hash="b76cbc47c91b88ceb9fc1fde609fa2dc"/></dir><dir name="Payment"><file name="Info.php" hash="c6285a5688834b456765317d3471bf2a"/></dir></dir><dir name="Exception"><dir name="InvalidStatus"><file name="Recoverable.php" hash="dc4d8857cf1841bb56f6da11cf92e99e"/></dir><file name="InvalidStatus.php" hash="614d45747601dea035ff2a3faadd7e18"/></dir><file name="Exception.php" hash="ca655a29842b38dd2ebf438208a6c70c"/><dir name="Helper"><file name="Data.php" hash="65a72f769e4c95f196eff518d4bd0d82"/><file name="Debug.php" hash="782ae864f43f5bb85b439cf1a4c35334"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="1814fcd0d61599f15d808d9c2990ebe4"/><file name="Advanced.php" hash="2c2359c3969f43a7e7024325d0fdbce8"/><file name="Ipn.php" hash="7796776a38fe90b9805cbd88094a773d"/><file name="Login.php" hash="d9297e66749c6930a1010a5babdfde14"/></dir><file name="Checkout.php" hash="593935995a788c113d14fbba9bce9dc5"/><file name="Config.php" hash="9ea3d65a08e6c2024bca16e1f38a2634"/><dir name="Log"><file name="Collection.php" hash="13d71847c4e164af18636a3fe5bf975b"/></dir><file name="Logger.php" hash="0821a7d8ddeea993fe3ad9495ef6f9d9"/><dir name="Lookup"><file name="Abstract.php" hash="443bbef12f4e7c896e54cf0b7463e04e"/><file name="Authentication.php" hash="56e12ebde89bb29b59ac1153be4b10cc"/><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="5e6f65d1e355ed265787b28b12c6e7a6"/></dir></dir></dir><file name="Frequency.php" hash="5115fb39b48781e5e97f9b62414a72cc"/><file name="IpnActive.php" hash="b73000f5bfc1e26b80911e125e9eec46"/><file name="PaymentAction.php" hash="6d0c15996ec3caf112d88e07ea703bb4"/><file name="Region.php" hash="8f5cc8ab970aa165e16085368b320f89"/></dir><file name="Manager.php" hash="feac7709c9d079d0aaef8ffe9a2dc105"/><file name="Mapper.php" hash="df64a034c955111ea4295ad83043fdb7"/><file name="Observer.php" hash="9f2a3aa15381483624ed4027112572db"/><dir name="Payment"><file name="Abstract.php" hash="52233ddb29cb3ef23e33364d5c4713f3"/><dir name="Advanced"><file name="Abstract.php" hash="9b4709b93da48f60769899838b1230ee"/><file name="Sandbox.php" hash="10e80bd587f2d27fc97bb6e595936b82"/></dir><file name="Advanced.php" hash="15c5dde1d3a82a9bdf01e1681c47ec3b"/></dir><file name="Processor.php" hash="7187d35e41489c357e0d853cb726ad4d"/><dir name="Service"><file name="Login.php" hash="99f99ff273e0cb6dea7b2053702bf323"/><file name="Quote.php" hash="d566370281e690ca31f3ddd47c21ef1d"/></dir><file name="Simulator.php" hash="553bb0c0ca3c74202083b366f4c33e9a"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="DataPolling"><file name="Cron.php" hash="c3d3009775702bee14da3695f0d41f68"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="DebugController.php" hash="28e0ddedf23912140158d100339bdbe8"/><file name="DocumentationController.php" hash="4e214386e032b2e513dda5a26344fd87"/><dir name="Log"><file name="ApiController.php" hash="e0a9181f57223d3ba722982572c1d003"/><file name="ExceptionController.php" hash="5daaa04ec6479396edfb1f62910f4ad3"/><file name="IpnController.php" hash="f00870c68a6b18d460c59d0b76d4a67d"/></dir><file name="OrderController.php" hash="b8def9d164db295d0c5536c194237d84"/><file name="SystemController.php" hash="52c60fa39dba8582b4ca81c2f065dbc5"/></dir><dir name="Advanced"><file name="CheckoutController.php" hash="2f80227774f7fac74b545ef47030423d"/><file name="IpnController.php" hash="0d8a52a891d493870dd1081f9a407170"/><file name="LoginController.php" hash="284a5be104f8dccf36528824c7233df8"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2dc1b70997469f8f0cd6a80eff845842"/><file name="config.xml" hash="e78d96a109b9a682fb5359e2bd1dd6be"/><file name="system.xml" hash="46a57e809ec61cb902e0926789e988c7"/></dir><dir name="sql"><dir name="amazonpayments_setup"><file name="mysql4-install-1.0.0.php" hash="d4681b9a39905cc9e9dcc660688dea85"/><file name="mysql4-upgrade-1.1.6-1.2.0.php" hash="27f8e108bac4268d3c17e812b413dbbc"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="amazonpayments.xml" hash="4bc12228bba39bd925ed129d7cf64258"/></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="92e2a91aa6f25e20fe8e89bad751e8cf"/></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="8f58e70d3d5974c60d182450b424e521"/><file name="init.phtml" hash="ba9d53045077e63b4e6c25c6b7bb685c"/><dir name="payment"><file name="info.phtml" hash="200af8569ab7792e7f16c5f4a93c6897"/><dir name="pdf"><file name="info.phtml" hash="1fb213f3fcc3aeecaa6305c07cff3b73"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="amazonpayments.xml" hash="7c1c1fc8f1476bb000c6b5cd60a46814"/></dir><dir name="template"><dir name="creativestyle"><dir name="amazonpayments"><dir name="button"><file name="js.phtml" hash="4eb92ecb1032a8f57c6b0230a333f88e"/></dir><dir name="checkout"><file name="capture_notice.phtml" hash="f9c75cd05a596d0a16c55f0169b4ee6c"/><file name="js.phtml" hash="71f1e2eb29af46959f268b7f0bc5e416"/><dir name="review"><file name="button.phtml" hash="1312572385c9ff653d283bb0c3f47b1b"/></dir><file name="sandbox_toolbox.phtml" hash="ff639266f99827e3ec3a9e8305bd7eb7"/><file name="shipping_method.phtml" hash="852008f89fc32c7af6c250cafdde5f51"/></dir><file name="checkout.phtml" hash="6873b347a7e10b3b5c35fda1b48345b1"/><file name="js.phtml" hash="13581f0bcdf7c39da46be530892e8183"/><dir name="login"><dir name="button"><file name="account_login.phtml" hash="0ce9b9d891af3f6c5b1c83a17d311e6b"/></dir><file name="button.phtml" hash="b5d66280337ecc895ae9a2bc48c469e4"/><dir name="form"><file name="account_confirm.phtml" hash="cff4c9f656b2e790bd65723d4e2042b9"/><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="95e053ca57f36df23180af93b77a6557"/></dir><dir name="pay"><file name="button.phtml" hash="dfcccab45794c81d2d3ca52f709019d4"/></dir><dir name="payment"><file name="info.phtml" hash="3631896707e596d9675f526a7d021617"/><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="en_US"><file name="Creativestyle_AmazonPayments.csv" hash="85bdadb798a0fb92e9423fab4bffb5ee"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="ad694ba24051f779698d483bc32d9b75"/></dir></dir></dir><dir name="en_GB"><file name="Creativestyle_AmazonPayments.csv" hash="d6246a04524c0b4bb038ad3d75fd023e"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="1a933579acb1fbb3d78ae47ca990521b"/></dir></dir></dir><dir name="de_DE"><file name="Creativestyle_AmazonPayments.csv" hash="dd65389283b888d868afb7a2fd9a3c12"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="4879ccbfbea101548700da52b058bd0b"/></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="creativestyle"><file name="apa_checkout.min.js" hash="5cc918fcd6b6858f9f1bdcd2936a9332"/><file name="apa_sandbox_toolbox.min.js" hash="9c04a2cae7d749b99e70036676e57019"/><dir name="vendors"><file name="prism.js" hash="c700de3d980f7ef1e056dc5400acfd44"/></dir><file name="apa_checkout.js" hash="897599282955169727aa8673324b0beb"/></dir></dir></target><target name="magelib"><dir name="OffAmazonPayments"><file name="Model.php" hash="36434820209eb10952abc8e41259d96c"/></dir><dir name="OffAmazonPaymentsNotifications"><file name="Client.php" hash="3b2d2c969c03e774ff86fa876e12b278"/><dir name="Impl"><file name="Certificate.php" hash="3b49f95f652daa628a586c5d57a1b96f"/><file name="IpnNotificationParser.php" hash="41c7c75dfb26e2df9071263a464f4810"/><file name="Message.php" hash="d6a798d889d4fa1c6938b1493932925d"/><file name="OpenSslVerifySignature.php" hash="41ebc72238ef3eebe7741e21e18a9788"/><file name="SnsMessageParser.php" hash="7ebf58afecd5d3a3c859f6daf60b19c4"/><file name="SnsMessageValidator.php" hash="4d4a2452b4587d622926b6cfbfb4b179"/><file name="VerifySignature.php" hash="b03c485451a27ada7e67497988093e47"/><file name="XmlNotificationParser.php" hash="17ee03585854ed24eb4add7834e9f02d"/></dir><file name="Interface.php" hash="2c527d58c518632f8cc1b6a973c08e05"/><file name="InvalidCertificateException.php" hash="5412d2fc7ca03ac822bcb4066d558b50"/><file name="InvalidMessageException.php" hash="5fc7cb16c37c4cde49d87744c5a583c0"/><dir name="Model"><file name="AuthorizationDetails.php" hash="fccb851dc730850b8d185016dbca2590"/><file name="AuthorizationNotification.php" hash="80250048069681142a95cac51e3fa21c"/><file name="BillingAgreement.php" hash="087f904ec04b8c63a0120940f177c698"/><file name="BillingAgreementLimits.php" hash="801a01b85a09eababfa08b2186c44cd4"/><file name="BillingAgreementNotification.php" hash="dd8af8bd716a907f507c0dd885b3ed4c"/><file name="BillingAgreementStatus.php" hash="788a292faf04486d93b1f70b14cf156c"/><file name="CaptureDetails.php" hash="326a26f5b981710e4c6328cf1ea91459"/><file name="CaptureNotification.php" hash="50aaaf110b451b3a95e08a1525ec29c4"/><file name="IdList.php" hash="5c4b01c197bd17841dbba5ad37bd7b10"/><file name="IpnNotificationMetadata.php" hash="5e894a2584bbf0469ec73f32d7059ac6"/><file name="MerchantRegistrationDetails.php" hash="d4de7689d8e216567abd710dde7ef4ed"/><file name="NotificationImpl.php" hash="717df190c76f9d3b9a95999dbd962cd4"/><file name="NotificationMetadataImpl.php" hash="045d988afb0c21179d22e086e263a84d"/><file name="OrderItemCategories.php" hash="143c9a7a5d0e048fd8f3d35d7193699c"/><file name="OrderReference.php" hash="aa46198885e00b987c4b19c316920b9a"/><file name="OrderReferenceNotification.php" hash="5757807850c3afa08dd17a49803f317a"/><file name="OrderReferenceStatus.php" hash="91332f4bb02b984d57a6c519df3f90ed"/><file name="OrderTotal.php" hash="9414289b9477ffe27d3dfd0511aa0729"/><file name="Price.php" hash="f8c2a436b7244bc026078fd02887da82"/><file name="ProviderCreditDetails.php" hash="d355185842eb0816de151fb535b14edc"/><file name="ProviderCreditNotification.php" hash="833ef1e2383d6a97a28b1d61d352e824"/><file name="ProviderCreditReversalDetails.php" hash="a789bbf3c7074bc800053967e64286c7"/><file name="ProviderCreditReversalNotification.php" hash="84a36f2d6157424a571ddada073b2be5"/><file name="ProviderCreditReversalSummary.php" hash="1f9cd50005ade77d793a15e029b3cf69"/><file name="ProviderCreditReversalSummaryList.php" hash="6d3a3913ea433fa54ac34197825354ff"/><file name="ProviderCreditSummary.php" hash="4403e12b73867b58021655df3fcf6720"/><file name="ProviderCreditSummaryList.php" hash="8a5a83e94ce75fc3992f98525d47765d"/><file name="RefundDetails.php" hash="4b2dacdc4ce32db6b6dff7613e5b6098"/><file name="RefundNotification.php" hash="55225faad22f6a5b9b44603239488ebb"/><file name="SellerBillingAgreementAttributes.php" hash="c772791d5522be53415d339e169c6a12"/><file name="SellerOrderAttributes.php" hash="116f00df52e1cc7d9b0a23c58dc0c93d"/><file name="SnsNotificationMetadata.php" hash="79a8aacd35588ce20daea2d8ded574ac"/><file name="SolutionProviderMerchantNotification.php" hash="d5829f16e032db871798f1ba45732f39"/><file name="SolutionProviderOption.php" hash="df8fbbb1ad2fef1796e3b42a9a417a64"/><file name="SolutionProviderOptions.php" hash="8f5f0e7415bb9dfc5dfafaab236d91df"/><file name="Status.php" hash="5ac5d81fafbb7a45c7ef67b7d61e3ccf"/></dir><file name="Notification.php" hash="f14f5fded3845499c03ed011ff115b13"/><file name="NotificationMetadata.php" hash="fcbdda900353d35a850ab518c24506ca"/></dir><dir name="OffAmazonPaymentsService"><file name="Client.php" hash="bba604078e0d7491ee6dbcce80258aea"/><file name="Environments.php" hash="5c469c72e7e1fc24eeda2b6a22917d77"/><file name="Exception.php" hash="965ca3466457e04d79ee9250fc946803"/><file name="Interface.php" hash="822113682cd65aa8b02f61f18ab07984"/><file name="MerchantValues.php" hash="ef10d79a38b3ae5ded1c2ed9d55e1f6c"/><dir name="Model"><file name="Address.php" hash="2cac12c7465df053c1fbfebd7c0c3e4b"/><file name="AuthorizationDetails.php" hash="9ef03efd7eb35c2f1c764e60a7492be6"/><file name="AuthorizeOnBillingAgreementRequest.php" hash="08084c850ebbc53f1a691fec0db5d011"/><file name="AuthorizeOnBillingAgreementResponse.php" hash="c2bc2dab6950c7a6be5ec3c55b71b4f9"/><file name="AuthorizeOnBillingAgreementResult.php" hash="b52d0c0ad908617cbd39345aba54882b"/><file name="AuthorizeRequest.php" hash="d01f4a32ec8e57a44a0804ba7350bfef"/><file name="AuthorizeResponse.php" hash="ccbb769ef3012724c48b1d76acd6e0ef"/><file name="AuthorizeResult.php" hash="a90eaf3bb2a12a6945407c01a0f967d0"/><file name="BillingAddress.php" hash="9d3881a26603f1392f9b93b55a8a8a5a"/><file name="BillingAgreementAttributes.php" hash="30046b148b8a7b4cd6026ebd0fc482b5"/><file name="BillingAgreementDetails.php" hash="9b9d0d8722afa825d45f98b9c5cece6e"/><file name="BillingAgreementLimits.php" hash="9984271b285397d7e08322c91d9ccd08"/><file name="BillingAgreementStatus.php" hash="f3a6ac460a66e62a4e5cff1f966e1a4a"/><file name="Buyer.php" hash="10df01a4c7815bf4760e56308957351a"/><file name="CancelOrderReferenceRequest.php" hash="2a1aea8fad7cf8a87d2a9f6ff6fcea78"/><file name="CancelOrderReferenceResponse.php" hash="c3f81641827af137bf4a6010e58bb62c"/><file name="CancelOrderReferenceResult.php" hash="504557ccf47b0b5b6a071f138ba962f0"/><file name="CaptureDetails.php" hash="f907d38d2148b1c1703d6f1a3d958f34"/><file name="CaptureRequest.php" hash="f2ddfd0218c81f234b0ba05c74efe1dd"/><file name="CaptureResponse.php" hash="6faf1938d380ebaeb6fcf1ff6e865624"/><file name="CaptureResult.php" hash="f174ee46f021bd40751e0d63245bd850"/><file name="CloseAuthorizationRequest.php" hash="07191ba72e4eee57553ecd41e15f779d"/><file name="CloseAuthorizationResponse.php" hash="70e8e86c4edbfb2f96ec139560636494"/><file name="CloseAuthorizationResult.php" hash="2c406dd340ef5b838a37a75aabb4f149"/><file name="CloseBillingAgreementRequest.php" hash="c80b8e3cb690595dc72c3924f5e7a13f"/><file name="CloseBillingAgreementResponse.php" hash="8994fb56dc5f487302937c1395d0963d"/><file name="CloseBillingAgreementResult.php" hash="10517589598754b0e58be29c5082c3ce"/><file name="CloseOrderReferenceRequest.php" hash="523c2061c026540e0189872e87ed1af1"/><file name="CloseOrderReferenceResponse.php" hash="fd13d871e69eb5413526c19cf5f66de8"/><file name="CloseOrderReferenceResult.php" hash="0e5afd3aa795bf82684c0f40744e2e04"/><file name="ConfirmBillingAgreementRequest.php" hash="098e7fd225da377b14799a0957991d0a"/><file name="ConfirmBillingAgreementResponse.php" hash="54327b4909053fc3fc65197e796c5d59"/><file name="ConfirmBillingAgreementResult.php" hash="f1ab41657391d37de4148fa07b0849da"/><file name="ConfirmOrderReferenceRequest.php" hash="c0667576d46907f0965c89a36e5dc1aa"/><file name="ConfirmOrderReferenceResponse.php" hash="497d3a7f3710ece7bd1a25fd5261707f"/><file name="Constraint.php" hash="5dfaa3ce9fb9c0fe8a1f20e24a053f6e"/><file name="Constraints.php" hash="e831530f17d7df39cc03bceaafed0216"/><file name="CreateOrderReferenceForIdRequest.php" hash="84a50944a1e0d58bd1e77306f1f7ada7"/><file name="CreateOrderReferenceForIdResponse.php" hash="3b9d3020b2e874f191e0083203d46723"/><file name="CreateOrderReferenceForIdResult.php" hash="46f720aea9c58694b2ca4b81142abcfa"/><file name="Destination.php" hash="4da36642b21ab96ab6bdee10781d8d07"/><file name="Error.php" hash="a0b83f2bc8edc3e503efae6d98ecb464"/><file name="ErrorResponse.php" hash="00391c711283b2fd5a6859f6a341cbbf"/><file name="GetAuthorizationDetailsRequest.php" hash="fdfeafa306e64b92325972b67bb12f92"/><file name="GetAuthorizationDetailsResponse.php" hash="eae478e879b021b30e22188af50c2e2c"/><file name="GetAuthorizationDetailsResult.php" hash="270d0ebb53cf595593a72ba29ca3d1f0"/><file name="GetBillingAgreementDetailsRequest.php" hash="e8124ac8d748b26642456c090a86463b"/><file name="GetBillingAgreementDetailsResponse.php" hash="5e05dd77c3b176b303af9711eeea97fd"/><file name="GetBillingAgreementDetailsResult.php" hash="b320ede4586359d2b5f1f1d7333b2743"/><file name="GetCaptureDetailsRequest.php" hash="b4d9e5414e63840b87c97a1d5f8ec9bb"/><file name="GetCaptureDetailsResponse.php" hash="049306e3f85755114fb033732111c613"/><file name="GetCaptureDetailsResult.php" hash="ab7ccba1bfaf183205a2a5a7c495fd19"/><file name="GetOrderReferenceDetailsRequest.php" hash="21d60f781305cf963ea2a40099decdf7"/><file name="GetOrderReferenceDetailsResponse.php" hash="eebbc1b4482d78a0d3d57bbf8d1c5a66"/><file name="GetOrderReferenceDetailsResult.php" hash="f4425bd39c8279e66f4c9052d452925d"/><file name="GetProviderCreditDetailsRequest.php" hash="1b613acafc8f66e0385379705bcf664c"/><file name="GetProviderCreditDetailsResponse.php" hash="9fcdbd8af985e96579c93378259c5e4a"/><file name="GetProviderCreditDetailsResult.php" hash="3a660d2ad0f6528e16f554987caf9a51"/><file name="GetProviderCreditReversalDetailsRequest.php" hash="592caa40f517ed1cfc66dd9a12e9bac3"/><file name="GetProviderCreditReversalDetailsResponse.php" hash="85d1fb8584f14d443cf7e4956c3dd03f"/><file name="GetProviderCreditReversalDetailsResult.php" hash="06effa515f870d1bd5fff7bc62a1d752"/><file name="GetRefundDetailsRequest.php" hash="a433b45ba3dc2894042d2e8072286bd1"/><file name="GetRefundDetailsResponse.php" hash="58771173d1a1c43f2a8a9f5515f4823b"/><file name="GetRefundDetailsResult.php" hash="0d51a779b95371ad425a4c9bc0aa6f82"/><file name="IdList.php" hash="a7a531e733a67f5a320bdb77c6ebd1a6"/><file name="OrderItemCategories.php" hash="1ed3edbf18fda5819ace2284bff49c15"/><file name="OrderReferenceAttributes.php" hash="d3d2d00f6626ab2116553cf2d266bb38"/><file name="OrderReferenceDetails.php" hash="a3ae5a3c4a6d5b8b3fa4f84593d1c33a"/><file name="OrderReferenceStatus.php" hash="5605fd30208a09dedea1aab688d92f49"/><file name="OrderTotal.php" hash="3ba85975c17821e7b72710b713f48f93"/><file name="ParentDetails.php" hash="b0d8bc8245fc4f8e75842e7c48e5b174"/><file name="Price.php" hash="ebd5fe74f1840f7804b3f869ce25384b"/><file name="ProviderCredit.php" hash="331663826ea8f444d5b0c05c59d69874"/><file name="ProviderCreditDetails.php" hash="0b916937d2397ad51d0dc1b0cf86777b"/><file name="ProviderCreditList.php" hash="3467cfe1dc096d07c33e2fadb3cb90d1"/><file name="ProviderCreditReversal.php" hash="b965141481deddd3b8e1c48a68d8c292"/><file name="ProviderCreditReversalDetails.php" hash="aaf5a41e7d6aba6758b5c24de2affe4d"/><file name="ProviderCreditReversalList.php" hash="47ff9cee9313ea98b23cec3257fdd704"/><file name="ProviderCreditReversalSummary.php" hash="decb86a0305f061206625dea1c8aacdb"/><file name="ProviderCreditReversalSummaryList.php" hash="4948d8e2034b7e60fc7157d7be149ea1"/><file name="ProviderCreditSummary.php" hash="06f9ad261e09b3709107d074604a1227"/><file name="ProviderCreditSummaryList.php" hash="28652df460f09e5d907d0c07f98b1b8f"/><file name="RefundDetails.php" hash="e12c1a6a49bda599d628e382de6f8874"/><file name="RefundRequest.php" hash="1e6f8500871cbae8b1d57a7a853cd298"/><file name="RefundResponse.php" hash="f2af68623a6f37a0f0227ea9e648603f"/><file name="RefundResult.php" hash="2b73f810b388d8ea30ded964bb1d1644"/><file name="ResponseHeaderMetadata.php" hash="4305e32c733bf48b2e34b2de0f0eee7f"/><file name="ResponseMetadata.php" hash="c5efe1da81e4a9fa3c76b9901c90f9fe"/><file name="ReverseProviderCreditRequest.php" hash="51af6c8b7e31efd4fffafd83994fbc63"/><file name="ReverseProviderCreditResponse.php" hash="3a959a1b22156ddb81e2eed9e02a0da4"/><file name="ReverseProviderCreditResult.php" hash="6dc02bb8141e136a55d28034add4b101"/><file name="SellerBillingAgreementAttributes.php" hash="0c1c845a25dbcd724d0c6ca2a8e07ab4"/><file name="SellerOrderAttributes.php" hash="326ac3910572ddfcc88d467e837283af"/><file name="SetBillingAgreementDetailsRequest.php" hash="19522c9d1290c1ae63e22902cd1655d9"/><file name="SetBillingAgreementDetailsResponse.php" hash="029e631097cb557f2a44ccc0f108aeae"/><file name="SetBillingAgreementDetailsResult.php" hash="4006851ac3799e4ee89fe6665e78be66"/><file name="SetOrderReferenceDetailsRequest.php" hash="61de911c937a20dc795727ca66a90b89"/><file name="SetOrderReferenceDetailsResponse.php" hash="e2bcd0495e0249c654a3cfedc0e3697e"/><file name="SetOrderReferenceDetailsResult.php" hash="ad903a104466558226f58e790a2bb061"/><file name="Status.php" hash="92253830c1eeb08094f5eca6506a0b0f"/><file name="ValidateBillingAgreementRequest.php" hash="b3a0ae148f92a2b0132af201f49c98d4"/><file name="ValidateBillingAgreementResponse.php" hash="c3866b3ffa85037b5c070ffed2d6cf06"/><file name="ValidateBillingAgreementResult.php" hash="2c96a303ad608eb9c840971c374125f4"/></dir><file name="Model.php" hash="7452a81d314d6212937d79e71b040e01"/><file name="RegionSpecificProperties.php" hash="4cad5116fb2608d5000c0e9aed5bace9"/><file name="Regions.php" hash="849549c7834fac2fb94749276eabeb97"/></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="a1f07a48b8de6d1fa9391a4eed2f12be"/><file name="amazonpayments-highlight.css" hash="f6daf03c989ac56ad436300b5520f0df"/></dir><dir name="images"><file name="amazon-payments-advanced-creativestyle-logo.png" hash="bb507d0085dab135ac313b8068515620"/><file name="amazon-payments-advanced-creativestyle-header-logo.png" hash="1f17fc7a61f8aaf929000d1d87f7d943"/><file name="amazon-payments-advanced-creativestyle-header-logo-white.png" hash="4ce4ba0d8d210a26caa380217804e200"/><file name="amazon-payments-advanced-header.png" hash="60f587870fbdb1242368c8c3b553bd8c"/><file name="amazon-payments-advanced-section.png" hash="8bc620f345eb46c920c51875d4cfad7c"/><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="98669e803a468cc7e01d481ce1647a0e"/><file name="amazonpayments-widgets.css" hash="35704192aaeb204e407e8b853c118d16"/><file name="amazonpayments-responsive-widgets.css" hash="ffca5cdc8a4e0585946c78258044c471"/></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"/></dir></dir></dir></dir></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>dom</name><min/><max/></extension><extension><name>curl</name><min/><max/></extension></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Creativestyle_AmazonPayments</name>
4
+ <version>1.6.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://creativecommons.org/licenses/by-nd/4.0/">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>FIXED: bugs in refactored payment model&#xD;
12
+ FIXED: IPN processing bugs in v.1.6.0&#xD;
13
+ FIXED: 404 error when customer press "Cancel" on Amazon login form</notes>
14
  <authors><author><name>creativestyle GmbH</name><user>creativestyle</user><email>amazon@creativestyle.de</email></author></authors>
15
+ <date>2015-04-23</date>
16
+ <time>22:39:16</time>
17
+ <contents><target name="magecommunity"><dir name="Creativestyle"><dir name="AmazonPayments"><dir name="Block"><file name="Abstract.php" hash="ce9a49bde52db0195d94bf409029b8c6"/><dir name="Adminhtml"><file name="CredentialsValidator.php" hash="bb62c178c7bba1dd30fa16f22394ec85"/><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="cc798f2987cc0dffc755a88988b74912"/><file name="Info.php" hash="be764b1856eccc2b3070a1ea4cfe57f7"/><file name="IpnUrl.php" hash="f9a516356c4c9b98e02eb3761ad5bf90"/><dir name="Log"><file name="Abstract.php" hash="02887066c2d6973141dff769b385d8fa"/><dir name="Api"><file name="Grid.php" hash="8d072ba9ce4be99222c03a26680d51eb"/><file name="View.php" hash="eb30544643fa9571a454a763111d0113"/></dir><file name="Api.php" hash="5ea0736c83de5feb01df0a3ec4db4d80"/><dir name="Exception"><file name="Grid.php" hash="3c3decb0a90638d5e2b1617426ec9437"/><file name="View.php" hash="cae17d2a2d5716e8dde1c6662397131e"/></dir><file name="Exception.php" hash="c35dafcaf89ca709394341394862f4cf"/><dir name="Ipn"><file name="Grid.php" hash="74bb51ab562b09d42bd9ced6d6609ae1"/><file name="View.php" hash="6ab63414642658e95258a73a143e6955"/></dir><file name="Ipn.php" hash="a2225b081ccb354bfe94b4a646b0d521"/><dir name="View"><file name="Abstract.php" hash="0a4c977a1f89622148bdc6acc037fc1f"/></dir></dir><dir name="Renderer"><file name="Timestamp.php" hash="190325613c20e2cf97adc28950658e99"/></dir><dir name="Sales"><file name="Order.php" hash="45a5ee919501a2bf26160d38dafccd44"/></dir></dir><dir name="Button"><file name="Js.php" hash="29f5907c8898af60bdc78d957998da3f"/></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="Js"><file name="Interface.php" hash="11827746ff821b4cbda1ad041e30321e"/></dir><file name="Js.php" hash="8610dddee84cda450c4874e0fd93b5f5"/><dir name="Login"><file name="Abstract.php" hash="b84dfbbe66bbee39a547d33e856b4a8d"/><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="b122db0163e8580f42679f13a3a45726"/></dir><dir name="Pay"><file name="Abstract.php" hash="2e96e1d4a1a0e2c74cee40a46a75241c"/><file name="Button.php" hash="b76cbc47c91b88ceb9fc1fde609fa2dc"/></dir><dir name="Payment"><file name="Info.php" hash="c6285a5688834b456765317d3471bf2a"/></dir></dir><dir name="Exception"><dir name="InvalidStatus"><file name="Recoverable.php" hash="dc4d8857cf1841bb56f6da11cf92e99e"/></dir><file name="InvalidStatus.php" hash="614d45747601dea035ff2a3faadd7e18"/></dir><file name="Exception.php" hash="ca655a29842b38dd2ebf438208a6c70c"/><dir name="Helper"><file name="Data.php" hash="d2b92ae2df83c78f17bbd27ce2765fe0"/><file name="Debug.php" hash="782ae864f43f5bb85b439cf1a4c35334"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="1814fcd0d61599f15d808d9c2990ebe4"/><file name="Advanced.php" hash="2c2359c3969f43a7e7024325d0fdbce8"/><file name="Ipn.php" hash="7796776a38fe90b9805cbd88094a773d"/><file name="Login.php" hash="d9297e66749c6930a1010a5babdfde14"/></dir><file name="Checkout.php" hash="593935995a788c113d14fbba9bce9dc5"/><file name="Config.php" hash="9ea3d65a08e6c2024bca16e1f38a2634"/><dir name="Log"><file name="Collection.php" hash="13d71847c4e164af18636a3fe5bf975b"/></dir><file name="Logger.php" hash="0821a7d8ddeea993fe3ad9495ef6f9d9"/><dir name="Lookup"><file name="Abstract.php" hash="443bbef12f4e7c896e54cf0b7463e04e"/><file name="Authentication.php" hash="56e12ebde89bb29b59ac1153be4b10cc"/><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="5e6f65d1e355ed265787b28b12c6e7a6"/></dir></dir></dir><file name="Frequency.php" hash="5115fb39b48781e5e97f9b62414a72cc"/><file name="IpnActive.php" hash="b73000f5bfc1e26b80911e125e9eec46"/><file name="PaymentAction.php" hash="6d0c15996ec3caf112d88e07ea703bb4"/><file name="Region.php" hash="8f5cc8ab970aa165e16085368b320f89"/></dir><file name="Observer.php" hash="2fb10b97964dc2a76a3a272eaa7b7583"/><dir name="Payment"><file name="Abstract.php" hash="7555f27dd55e2e5af3a82a555f31f939"/><dir name="Advanced"><file name="Sandbox.php" hash="10e80bd587f2d27fc97bb6e595936b82"/></dir><file name="Advanced.php" hash="15c5dde1d3a82a9bdf01e1681c47ec3b"/></dir><dir name="Processor"><file name="Ipn.php" hash="d0541388acac591e34efd7b75dcd0b57"/><file name="Order.php" hash="bc9adbc3c4227f41e8574310f376016d"/><file name="Payment.php" hash="48986e137bd5febee8378ae876139ac2"/><file name="TransactionAdapter.php" hash="b2c09a44be6b448ed3b3afbfea282a0f"/></dir><dir name="Service"><file name="Login.php" hash="99f99ff273e0cb6dea7b2053702bf323"/><file name="Quote.php" hash="d566370281e690ca31f3ddd47c21ef1d"/></dir><file name="Simulator.php" hash="553bb0c0ca3c74202083b366f4c33e9a"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="DataPolling"><file name="Cron.php" hash="c3d3009775702bee14da3695f0d41f68"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="DebugController.php" hash="28e0ddedf23912140158d100339bdbe8"/><file name="DocumentationController.php" hash="4e214386e032b2e513dda5a26344fd87"/><dir name="Log"><file name="ApiController.php" hash="e0a9181f57223d3ba722982572c1d003"/><file name="ExceptionController.php" hash="5daaa04ec6479396edfb1f62910f4ad3"/><file name="IpnController.php" hash="f00870c68a6b18d460c59d0b76d4a67d"/></dir><file name="OrderController.php" hash="cae5700331ca6aa6f26b78314c3507d9"/><file name="SystemController.php" hash="52c60fa39dba8582b4ca81c2f065dbc5"/></dir><dir name="Advanced"><file name="CheckoutController.php" hash="2f80227774f7fac74b545ef47030423d"/><file name="IpnController.php" hash="78277323844f97a30b6531aa331eef86"/><file name="LoginController.php" hash="a2ec1a2c457dca39afab9cad463a4f2e"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2dc1b70997469f8f0cd6a80eff845842"/><file name="config.xml" hash="f297095d8567cebe22668ff366786c0a"/><file name="system.xml" hash="46a57e809ec61cb902e0926789e988c7"/></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"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="amazonpayments.xml" hash="4bc12228bba39bd925ed129d7cf64258"/></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="92e2a91aa6f25e20fe8e89bad751e8cf"/></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="8f58e70d3d5974c60d182450b424e521"/><file name="init.phtml" hash="ba9d53045077e63b4e6c25c6b7bb685c"/><dir name="payment"><file name="info.phtml" hash="200af8569ab7792e7f16c5f4a93c6897"/><dir name="pdf"><file name="info.phtml" hash="1fb213f3fcc3aeecaa6305c07cff3b73"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="amazonpayments.xml" hash="7c1c1fc8f1476bb000c6b5cd60a46814"/></dir><dir name="template"><dir name="creativestyle"><dir name="amazonpayments"><dir name="button"><file name="js.phtml" hash="4eb92ecb1032a8f57c6b0230a333f88e"/></dir><dir name="checkout"><file name="capture_notice.phtml" hash="f9c75cd05a596d0a16c55f0169b4ee6c"/><file name="js.phtml" hash="71f1e2eb29af46959f268b7f0bc5e416"/><dir name="review"><file name="button.phtml" hash="1312572385c9ff653d283bb0c3f47b1b"/></dir><file name="sandbox_toolbox.phtml" hash="ff639266f99827e3ec3a9e8305bd7eb7"/><file name="shipping_method.phtml" hash="852008f89fc32c7af6c250cafdde5f51"/></dir><file name="checkout.phtml" hash="6873b347a7e10b3b5c35fda1b48345b1"/><file name="js.phtml" hash="13581f0bcdf7c39da46be530892e8183"/><dir name="login"><dir name="button"><file name="account_login.phtml" hash="0ce9b9d891af3f6c5b1c83a17d311e6b"/></dir><file name="button.phtml" hash="b5d66280337ecc895ae9a2bc48c469e4"/><dir name="form"><file name="account_confirm.phtml" hash="cff4c9f656b2e790bd65723d4e2042b9"/><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="95e053ca57f36df23180af93b77a6557"/></dir><dir name="pay"><file name="button.phtml" hash="dfcccab45794c81d2d3ca52f709019d4"/></dir><dir name="payment"><file name="info.phtml" hash="3631896707e596d9675f526a7d021617"/><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="en_US"><file name="Creativestyle_AmazonPayments.csv" hash="dfb38de32c84f3c48c8895becf4fce4d"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="ad694ba24051f779698d483bc32d9b75"/></dir></dir></dir><dir name="en_GB"><file name="Creativestyle_AmazonPayments.csv" hash="04298df067e72cb97bbea55457114bed"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="1a933579acb1fbb3d78ae47ca990521b"/></dir></dir></dir><dir name="de_DE"><file name="Creativestyle_AmazonPayments.csv" hash="33fd070c347a79ce0378068a7c02cc4b"/><dir name="template"><dir name="email"><file name="amazon_payments_failed.html" hash="4879ccbfbea101548700da52b058bd0b"/></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="creativestyle"><file name="apa_checkout.min.js" hash="5cc918fcd6b6858f9f1bdcd2936a9332"/><file name="apa_sandbox_toolbox.min.js" hash="9c04a2cae7d749b99e70036676e57019"/><dir name="vendors"><file name="prism.js" hash="c700de3d980f7ef1e056dc5400acfd44"/></dir><file name="apa_checkout.js" hash="897599282955169727aa8673324b0beb"/></dir></dir></target><target name="magelib"><dir name="OffAmazonPayments"><file name="Model.php" hash="36434820209eb10952abc8e41259d96c"/></dir><dir name="OffAmazonPaymentsNotifications"><file name="Client.php" hash="3b2d2c969c03e774ff86fa876e12b278"/><dir name="Impl"><file name="Certificate.php" hash="3b49f95f652daa628a586c5d57a1b96f"/><file name="IpnNotificationParser.php" hash="41c7c75dfb26e2df9071263a464f4810"/><file name="Message.php" hash="d6a798d889d4fa1c6938b1493932925d"/><file name="OpenSslVerifySignature.php" hash="41ebc72238ef3eebe7741e21e18a9788"/><file name="SnsMessageParser.php" hash="7ebf58afecd5d3a3c859f6daf60b19c4"/><file name="SnsMessageValidator.php" hash="4d4a2452b4587d622926b6cfbfb4b179"/><file name="VerifySignature.php" hash="b03c485451a27ada7e67497988093e47"/><file name="XmlNotificationParser.php" hash="17ee03585854ed24eb4add7834e9f02d"/></dir><file name="Interface.php" hash="2c527d58c518632f8cc1b6a973c08e05"/><file name="InvalidCertificateException.php" hash="5412d2fc7ca03ac822bcb4066d558b50"/><file name="InvalidMessageException.php" hash="5fc7cb16c37c4cde49d87744c5a583c0"/><dir name="Model"><file name="AuthorizationDetails.php" hash="fccb851dc730850b8d185016dbca2590"/><file name="AuthorizationNotification.php" hash="80250048069681142a95cac51e3fa21c"/><file name="BillingAgreement.php" hash="087f904ec04b8c63a0120940f177c698"/><file name="BillingAgreementLimits.php" hash="801a01b85a09eababfa08b2186c44cd4"/><file name="BillingAgreementNotification.php" hash="dd8af8bd716a907f507c0dd885b3ed4c"/><file name="BillingAgreementStatus.php" hash="788a292faf04486d93b1f70b14cf156c"/><file name="CaptureDetails.php" hash="326a26f5b981710e4c6328cf1ea91459"/><file name="CaptureNotification.php" hash="50aaaf110b451b3a95e08a1525ec29c4"/><file name="IdList.php" hash="5c4b01c197bd17841dbba5ad37bd7b10"/><file name="IpnNotificationMetadata.php" hash="5e894a2584bbf0469ec73f32d7059ac6"/><file name="MerchantRegistrationDetails.php" hash="d4de7689d8e216567abd710dde7ef4ed"/><file name="NotificationImpl.php" hash="717df190c76f9d3b9a95999dbd962cd4"/><file name="NotificationMetadataImpl.php" hash="045d988afb0c21179d22e086e263a84d"/><file name="OrderItemCategories.php" hash="143c9a7a5d0e048fd8f3d35d7193699c"/><file name="OrderReference.php" hash="aa46198885e00b987c4b19c316920b9a"/><file name="OrderReferenceNotification.php" hash="5757807850c3afa08dd17a49803f317a"/><file name="OrderReferenceStatus.php" hash="91332f4bb02b984d57a6c519df3f90ed"/><file name="OrderTotal.php" hash="9414289b9477ffe27d3dfd0511aa0729"/><file name="Price.php" hash="f8c2a436b7244bc026078fd02887da82"/><file name="ProviderCreditDetails.php" hash="d355185842eb0816de151fb535b14edc"/><file name="ProviderCreditNotification.php" hash="833ef1e2383d6a97a28b1d61d352e824"/><file name="ProviderCreditReversalDetails.php" hash="a789bbf3c7074bc800053967e64286c7"/><file name="ProviderCreditReversalNotification.php" hash="84a36f2d6157424a571ddada073b2be5"/><file name="ProviderCreditReversalSummary.php" hash="1f9cd50005ade77d793a15e029b3cf69"/><file name="ProviderCreditReversalSummaryList.php" hash="6d3a3913ea433fa54ac34197825354ff"/><file name="ProviderCreditSummary.php" hash="4403e12b73867b58021655df3fcf6720"/><file name="ProviderCreditSummaryList.php" hash="8a5a83e94ce75fc3992f98525d47765d"/><file name="RefundDetails.php" hash="4b2dacdc4ce32db6b6dff7613e5b6098"/><file name="RefundNotification.php" hash="55225faad22f6a5b9b44603239488ebb"/><file name="SellerBillingAgreementAttributes.php" hash="c772791d5522be53415d339e169c6a12"/><file name="SellerOrderAttributes.php" hash="116f00df52e1cc7d9b0a23c58dc0c93d"/><file name="SnsNotificationMetadata.php" hash="79a8aacd35588ce20daea2d8ded574ac"/><file name="SolutionProviderMerchantNotification.php" hash="d5829f16e032db871798f1ba45732f39"/><file name="SolutionProviderOption.php" hash="df8fbbb1ad2fef1796e3b42a9a417a64"/><file name="SolutionProviderOptions.php" hash="8f5f0e7415bb9dfc5dfafaab236d91df"/><file name="Status.php" hash="5ac5d81fafbb7a45c7ef67b7d61e3ccf"/></dir><file name="Notification.php" hash="f14f5fded3845499c03ed011ff115b13"/><file name="NotificationMetadata.php" hash="fcbdda900353d35a850ab518c24506ca"/></dir><dir name="OffAmazonPaymentsService"><file name="Client.php" hash="bba604078e0d7491ee6dbcce80258aea"/><file name="Environments.php" hash="5c469c72e7e1fc24eeda2b6a22917d77"/><file name="Exception.php" hash="965ca3466457e04d79ee9250fc946803"/><file name="Interface.php" hash="822113682cd65aa8b02f61f18ab07984"/><file name="MerchantValues.php" hash="ef10d79a38b3ae5ded1c2ed9d55e1f6c"/><dir name="Model"><file name="Address.php" hash="2cac12c7465df053c1fbfebd7c0c3e4b"/><file name="AuthorizationDetails.php" hash="9ef03efd7eb35c2f1c764e60a7492be6"/><file name="AuthorizeOnBillingAgreementRequest.php" hash="08084c850ebbc53f1a691fec0db5d011"/><file name="AuthorizeOnBillingAgreementResponse.php" hash="c2bc2dab6950c7a6be5ec3c55b71b4f9"/><file name="AuthorizeOnBillingAgreementResult.php" hash="b52d0c0ad908617cbd39345aba54882b"/><file name="AuthorizeRequest.php" hash="d01f4a32ec8e57a44a0804ba7350bfef"/><file name="AuthorizeResponse.php" hash="ccbb769ef3012724c48b1d76acd6e0ef"/><file name="AuthorizeResult.php" hash="a90eaf3bb2a12a6945407c01a0f967d0"/><file name="BillingAddress.php" hash="9d3881a26603f1392f9b93b55a8a8a5a"/><file name="BillingAgreementAttributes.php" hash="30046b148b8a7b4cd6026ebd0fc482b5"/><file name="BillingAgreementDetails.php" hash="9b9d0d8722afa825d45f98b9c5cece6e"/><file name="BillingAgreementLimits.php" hash="9984271b285397d7e08322c91d9ccd08"/><file name="BillingAgreementStatus.php" hash="f3a6ac460a66e62a4e5cff1f966e1a4a"/><file name="Buyer.php" hash="10df01a4c7815bf4760e56308957351a"/><file name="CancelOrderReferenceRequest.php" hash="2a1aea8fad7cf8a87d2a9f6ff6fcea78"/><file name="CancelOrderReferenceResponse.php" hash="c3f81641827af137bf4a6010e58bb62c"/><file name="CancelOrderReferenceResult.php" hash="504557ccf47b0b5b6a071f138ba962f0"/><file name="CaptureDetails.php" hash="f907d38d2148b1c1703d6f1a3d958f34"/><file name="CaptureRequest.php" hash="f2ddfd0218c81f234b0ba05c74efe1dd"/><file name="CaptureResponse.php" hash="6faf1938d380ebaeb6fcf1ff6e865624"/><file name="CaptureResult.php" hash="f174ee46f021bd40751e0d63245bd850"/><file name="CloseAuthorizationRequest.php" hash="07191ba72e4eee57553ecd41e15f779d"/><file name="CloseAuthorizationResponse.php" hash="70e8e86c4edbfb2f96ec139560636494"/><file name="CloseAuthorizationResult.php" hash="2c406dd340ef5b838a37a75aabb4f149"/><file name="CloseBillingAgreementRequest.php" hash="c80b8e3cb690595dc72c3924f5e7a13f"/><file name="CloseBillingAgreementResponse.php" hash="8994fb56dc5f487302937c1395d0963d"/><file name="CloseBillingAgreementResult.php" hash="10517589598754b0e58be29c5082c3ce"/><file name="CloseOrderReferenceRequest.php" hash="523c2061c026540e0189872e87ed1af1"/><file name="CloseOrderReferenceResponse.php" hash="fd13d871e69eb5413526c19cf5f66de8"/><file name="CloseOrderReferenceResult.php" hash="0e5afd3aa795bf82684c0f40744e2e04"/><file name="ConfirmBillingAgreementRequest.php" hash="098e7fd225da377b14799a0957991d0a"/><file name="ConfirmBillingAgreementResponse.php" hash="54327b4909053fc3fc65197e796c5d59"/><file name="ConfirmBillingAgreementResult.php" hash="f1ab41657391d37de4148fa07b0849da"/><file name="ConfirmOrderReferenceRequest.php" hash="c0667576d46907f0965c89a36e5dc1aa"/><file name="ConfirmOrderReferenceResponse.php" hash="497d3a7f3710ece7bd1a25fd5261707f"/><file name="Constraint.php" hash="5dfaa3ce9fb9c0fe8a1f20e24a053f6e"/><file name="Constraints.php" hash="e831530f17d7df39cc03bceaafed0216"/><file name="CreateOrderReferenceForIdRequest.php" hash="84a50944a1e0d58bd1e77306f1f7ada7"/><file name="CreateOrderReferenceForIdResponse.php" hash="3b9d3020b2e874f191e0083203d46723"/><file name="CreateOrderReferenceForIdResult.php" hash="46f720aea9c58694b2ca4b81142abcfa"/><file name="Destination.php" hash="4da36642b21ab96ab6bdee10781d8d07"/><file name="Error.php" hash="a0b83f2bc8edc3e503efae6d98ecb464"/><file name="ErrorResponse.php" hash="00391c711283b2fd5a6859f6a341cbbf"/><file name="GetAuthorizationDetailsRequest.php" hash="fdfeafa306e64b92325972b67bb12f92"/><file name="GetAuthorizationDetailsResponse.php" hash="eae478e879b021b30e22188af50c2e2c"/><file name="GetAuthorizationDetailsResult.php" hash="270d0ebb53cf595593a72ba29ca3d1f0"/><file name="GetBillingAgreementDetailsRequest.php" hash="e8124ac8d748b26642456c090a86463b"/><file name="GetBillingAgreementDetailsResponse.php" hash="5e05dd77c3b176b303af9711eeea97fd"/><file name="GetBillingAgreementDetailsResult.php" hash="b320ede4586359d2b5f1f1d7333b2743"/><file name="GetCaptureDetailsRequest.php" hash="b4d9e5414e63840b87c97a1d5f8ec9bb"/><file name="GetCaptureDetailsResponse.php" hash="049306e3f85755114fb033732111c613"/><file name="GetCaptureDetailsResult.php" hash="ab7ccba1bfaf183205a2a5a7c495fd19"/><file name="GetOrderReferenceDetailsRequest.php" hash="21d60f781305cf963ea2a40099decdf7"/><file name="GetOrderReferenceDetailsResponse.php" hash="eebbc1b4482d78a0d3d57bbf8d1c5a66"/><file name="GetOrderReferenceDetailsResult.php" hash="f4425bd39c8279e66f4c9052d452925d"/><file name="GetProviderCreditDetailsRequest.php" hash="1b613acafc8f66e0385379705bcf664c"/><file name="GetProviderCreditDetailsResponse.php" hash="9fcdbd8af985e96579c93378259c5e4a"/><file name="GetProviderCreditDetailsResult.php" hash="3a660d2ad0f6528e16f554987caf9a51"/><file name="GetProviderCreditReversalDetailsRequest.php" hash="592caa40f517ed1cfc66dd9a12e9bac3"/><file name="GetProviderCreditReversalDetailsResponse.php" hash="85d1fb8584f14d443cf7e4956c3dd03f"/><file name="GetProviderCreditReversalDetailsResult.php" hash="06effa515f870d1bd5fff7bc62a1d752"/><file name="GetRefundDetailsRequest.php" hash="a433b45ba3dc2894042d2e8072286bd1"/><file name="GetRefundDetailsResponse.php" hash="58771173d1a1c43f2a8a9f5515f4823b"/><file name="GetRefundDetailsResult.php" hash="0d51a779b95371ad425a4c9bc0aa6f82"/><file name="IdList.php" hash="a7a531e733a67f5a320bdb77c6ebd1a6"/><file name="OrderItemCategories.php" hash="1ed3edbf18fda5819ace2284bff49c15"/><file name="OrderReferenceAttributes.php" hash="d3d2d00f6626ab2116553cf2d266bb38"/><file name="OrderReferenceDetails.php" hash="a3ae5a3c4a6d5b8b3fa4f84593d1c33a"/><file name="OrderReferenceStatus.php" hash="5605fd30208a09dedea1aab688d92f49"/><file name="OrderTotal.php" hash="3ba85975c17821e7b72710b713f48f93"/><file name="ParentDetails.php" hash="b0d8bc8245fc4f8e75842e7c48e5b174"/><file name="Price.php" hash="ebd5fe74f1840f7804b3f869ce25384b"/><file name="ProviderCredit.php" hash="331663826ea8f444d5b0c05c59d69874"/><file name="ProviderCreditDetails.php" hash="0b916937d2397ad51d0dc1b0cf86777b"/><file name="ProviderCreditList.php" hash="3467cfe1dc096d07c33e2fadb3cb90d1"/><file name="ProviderCreditReversal.php" hash="b965141481deddd3b8e1c48a68d8c292"/><file name="ProviderCreditReversalDetails.php" hash="aaf5a41e7d6aba6758b5c24de2affe4d"/><file name="ProviderCreditReversalList.php" hash="47ff9cee9313ea98b23cec3257fdd704"/><file name="ProviderCreditReversalSummary.php" hash="decb86a0305f061206625dea1c8aacdb"/><file name="ProviderCreditReversalSummaryList.php" hash="4948d8e2034b7e60fc7157d7be149ea1"/><file name="ProviderCreditSummary.php" hash="06f9ad261e09b3709107d074604a1227"/><file name="ProviderCreditSummaryList.php" hash="28652df460f09e5d907d0c07f98b1b8f"/><file name="RefundDetails.php" hash="e12c1a6a49bda599d628e382de6f8874"/><file name="RefundRequest.php" hash="1e6f8500871cbae8b1d57a7a853cd298"/><file name="RefundResponse.php" hash="f2af68623a6f37a0f0227ea9e648603f"/><file name="RefundResult.php" hash="2b73f810b388d8ea30ded964bb1d1644"/><file name="ResponseHeaderMetadata.php" hash="4305e32c733bf48b2e34b2de0f0eee7f"/><file name="ResponseMetadata.php" hash="c5efe1da81e4a9fa3c76b9901c90f9fe"/><file name="ReverseProviderCreditRequest.php" hash="51af6c8b7e31efd4fffafd83994fbc63"/><file name="ReverseProviderCreditResponse.php" hash="3a959a1b22156ddb81e2eed9e02a0da4"/><file name="ReverseProviderCreditResult.php" hash="6dc02bb8141e136a55d28034add4b101"/><file name="SellerBillingAgreementAttributes.php" hash="0c1c845a25dbcd724d0c6ca2a8e07ab4"/><file name="SellerOrderAttributes.php" hash="326ac3910572ddfcc88d467e837283af"/><file name="SetBillingAgreementDetailsRequest.php" hash="19522c9d1290c1ae63e22902cd1655d9"/><file name="SetBillingAgreementDetailsResponse.php" hash="029e631097cb557f2a44ccc0f108aeae"/><file name="SetBillingAgreementDetailsResult.php" hash="4006851ac3799e4ee89fe6665e78be66"/><file name="SetOrderReferenceDetailsRequest.php" hash="61de911c937a20dc795727ca66a90b89"/><file name="SetOrderReferenceDetailsResponse.php" hash="e2bcd0495e0249c654a3cfedc0e3697e"/><file name="SetOrderReferenceDetailsResult.php" hash="ad903a104466558226f58e790a2bb061"/><file name="Status.php" hash="92253830c1eeb08094f5eca6506a0b0f"/><file name="ValidateBillingAgreementRequest.php" hash="b3a0ae148f92a2b0132af201f49c98d4"/><file name="ValidateBillingAgreementResponse.php" hash="c3866b3ffa85037b5c070ffed2d6cf06"/><file name="ValidateBillingAgreementResult.php" hash="2c96a303ad608eb9c840971c374125f4"/></dir><file name="Model.php" hash="7452a81d314d6212937d79e71b040e01"/><file name="RegionSpecificProperties.php" hash="4cad5116fb2608d5000c0e9aed5bace9"/><file name="Regions.php" hash="849549c7834fac2fb94749276eabeb97"/></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="a1f07a48b8de6d1fa9391a4eed2f12be"/><file name="amazonpayments-highlight.css" hash="f6daf03c989ac56ad436300b5520f0df"/></dir><dir name="images"><file name="amazon-payments-advanced-creativestyle-logo.png" hash="bb507d0085dab135ac313b8068515620"/><file name="amazon-payments-advanced-creativestyle-header-logo.png" hash="1f17fc7a61f8aaf929000d1d87f7d943"/><file name="amazon-payments-advanced-creativestyle-header-logo-white.png" hash="4ce4ba0d8d210a26caa380217804e200"/><file name="amazon-payments-advanced-header.png" hash="60f587870fbdb1242368c8c3b553bd8c"/><file name="amazon-payments-advanced-section.png" hash="8bc620f345eb46c920c51875d4cfad7c"/><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="98669e803a468cc7e01d481ce1647a0e"/><file name="amazonpayments-widgets.css" hash="35704192aaeb204e407e8b853c118d16"/><file name="amazonpayments-responsive-widgets.css" hash="ffca5cdc8a4e0585946c78258044c471"/></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"/></dir></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>dom</name><min/><max/></extension><extension><name>curl</name><min/><max/></extension></required></dependencies>
20
  </package>