klarnapayments - Version 5.3.55

Version Notes

This version is not compatible with any Klarna module version of 4.x or earlier.

Download this release

Release Info

Developer Klarna
Extension klarnapayments
Version 5.3.55
Comparing to
See all releases


Code changes from version 5.3.31 to 5.3.55

Files changed (28) hide show
  1. app/code/community/Vaimo/Klarna/Block/Adminhtml/Sales/Creditmemo/Totals.php +136 -0
  2. app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Ga.php +4 -0
  3. app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Klarnacheckout.php +44 -5
  4. app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Success.php +70 -4
  5. app/code/community/Vaimo/Klarna/Helper/Data.php +82 -0
  6. app/code/community/Vaimo/Klarna/Model/Api/Abstract.php +29 -0
  7. app/code/community/Vaimo/Klarna/Model/Api/Kco.php +58 -26
  8. app/code/community/Vaimo/Klarna/Model/Api/Rest.php +59 -16
  9. app/code/community/Vaimo/Klarna/Model/Api/Xmlrpc.php +1 -1
  10. app/code/community/Vaimo/Klarna/Model/Creditmemo/Tax.php +2 -0
  11. app/code/community/Vaimo/Klarna/Model/Creditmemo/Total.php +1 -25
  12. app/code/community/Vaimo/Klarna/Model/Cron.php +10 -5
  13. app/code/community/Vaimo/Klarna/Model/Invoice/Pdf/Total.php +3 -0
  14. app/code/community/Vaimo/Klarna/Model/Klarnacheckout.php +169 -95
  15. app/code/community/Vaimo/Klarna/Model/Klarnacheckout/Abstract.php +54 -13
  16. app/code/community/Vaimo/Klarna/Model/Observer.php +7 -0
  17. app/code/community/Vaimo/Klarna/Model/Payment/Abstract.php +24 -1
  18. app/code/community/Vaimo/Klarna/Model/Payment/Checkout.php +0 -15
  19. app/code/community/Vaimo/Klarna/Model/Transport/Abstract.php +14 -12
  20. app/code/community/Vaimo/Klarna/controllers/Checkout/KlarnaController.php +219 -86
  21. app/code/community/Vaimo/Klarna/etc/config.xml +19 -2
  22. app/code/community/Vaimo/Klarna/etc/system.xml +130 -64
  23. app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/success.phtml +27 -2
  24. app/locale/fi_FI/Vaimo_Klarna.csv +1 -0
  25. app/locale/sv_SE/Vaimo_Klarna.csv +21 -1
  26. js/vaimo/klarna/klarnacheckout.js +2 -2
  27. lib/Klarna/Klarna.php +1 -1
  28. package.xml +4 -4
app/code/community/Vaimo/Klarna/Block/Adminhtml/Sales/Creditmemo/Totals.php CHANGED
@@ -25,6 +25,43 @@
25
 
26
  class Vaimo_Klarna_Block_Adminhtml_Sales_Creditmemo_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
27
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * Initialize order totals array
30
  *
@@ -33,6 +70,8 @@ class Vaimo_Klarna_Block_Adminhtml_Sales_Creditmemo_Totals extends Mage_Adminhtm
33
  protected function initTotals()
34
  {
35
  $parent = $this->getParentBlock();
 
 
36
  $creditmemo = $parent->getCreditmemo();
37
  if ($creditmemo) {
38
  if ($creditmemo->getVaimoKlarnaFee()) {
@@ -49,6 +88,103 @@ class Vaimo_Klarna_Block_Adminhtml_Sales_Creditmemo_Totals extends Mage_Adminhtm
49
  $fee->setCode('vaimo_klarna_fee');
50
  $parent->addTotal($fee, 'subtotal');
51
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
  return $this;
54
  }
25
 
26
  class Vaimo_Klarna_Block_Adminhtml_Sales_Creditmemo_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
27
  {
28
+ /**
29
+ * Tax configuration model
30
+ *
31
+ * @var Mage_Tax_Model_Config
32
+ */
33
+ protected $_config;
34
+ protected $_order;
35
+ protected $_source;
36
+
37
+ /**
38
+ * Initialize configuration object
39
+ */
40
+ protected function _construct()
41
+ {
42
+ $this->_config = Mage::getSingleton('tax/config');
43
+ }
44
+
45
+ /**
46
+ * Check if we nedd display full tax total info
47
+ *
48
+ * @return bool
49
+ */
50
+ public function displayFullSummary()
51
+ {
52
+ return $this->_config->displaySalesFullSummary($this->getOrder()->getStore());
53
+ }
54
+
55
+ /**
56
+ * Get data (totals) source model
57
+ *
58
+ * @return Varien_Object
59
+ */
60
+ public function getSource()
61
+ {
62
+ return $this->_source;
63
+ }
64
+
65
  /**
66
  * Initialize order totals array
67
  *
70
  protected function initTotals()
71
  {
72
  $parent = $this->getParentBlock();
73
+ $this->_order = $parent->getOrder();
74
+ $this->_source = $parent->getSource();
75
  $creditmemo = $parent->getCreditmemo();
76
  if ($creditmemo) {
77
  if ($creditmemo->getVaimoKlarnaFee()) {
88
  $fee->setCode('vaimo_klarna_fee');
89
  $parent->addTotal($fee, 'subtotal');
90
  }
91
+
92
+ $this->_initSubtotal();
93
+ }
94
+
95
+ return $this;
96
+ }
97
+
98
+ /**
99
+ * Get order store object
100
+ *
101
+ * @return Mage_Core_Model_Store
102
+ */
103
+ public function getStore()
104
+ {
105
+ return $this->_order->getStore();
106
+ }
107
+
108
+ /**
109
+ * Correction of subtotal after Mage_Tax_Block_Sales_Order_Tax::_initSubtotal()
110
+ * Correction will be applied only in case if subtotal with tax is equal to 0
111
+ *
112
+ * @return Vaimo_Klarna_Block_Adminhtml_Sales_Creditmemo_Totals
113
+ */
114
+ protected function _initSubtotal()
115
+ {
116
+ $store = $this->getStore();
117
+ $parent = $this->getParentBlock();
118
+ $subtotal = $parent->getTotal('subtotal');
119
+ if (!$subtotal) {
120
+ return $this;
121
+ }
122
+ if ($this->_config->displaySalesSubtotalBoth($store)) {
123
+ $subtotal = (float) $this->_source->getSubtotal();
124
+ $baseSubtotal = (float) $this->_source->getBaseSubtotal();
125
+ $subtotalIncl = (float) $this->_source->getSubtotalInclTax();
126
+ $baseSubtotalIncl= (float) $this->_source->getBaseSubtotalInclTax();
127
+
128
+ if (!$subtotalIncl || !$baseSubtotalIncl) {
129
+ //Calculate the subtotal if not set
130
+ $subtotalIncl = $subtotal + $this->_source->getTaxAmount()
131
+ - $this->_source->getShippingTaxAmount()
132
+ - $this->_source->getVaimoKlarnaFeeTax();
133
+ $baseSubtotalIncl = $baseSubtotal + $this->_source->getBaseTaxAmount()
134
+ - $this->_source->getBaseShippingTaxAmount()
135
+ - $this->_source->getVaimoKlarnaBaseFeeTax();
136
+
137
+ if ($this->_source instanceof Mage_Sales_Model_Order) {
138
+ //Adjust the discount amounts for the base and well as the weee to display the right totals
139
+ foreach ($this->_source->getAllItems() as $item) {
140
+ $subtotalIncl += $item->getHiddenTaxAmount() + $item->getDiscountAppliedForWeeeTax();
141
+ $baseSubtotalIncl += $item->getBaseHiddenTaxAmount() +
142
+ $item->getBaseDiscountAppliedForWeeeTax();
143
+ }
144
+ }
145
+ }
146
+
147
+ $taxHelper = Mage::helper('tax');
148
+
149
+ $subtotalIncl = max(0, $subtotalIncl);
150
+ $baseSubtotalIncl = max(0, $baseSubtotalIncl);
151
+ $totalExcl = new Varien_Object(array(
152
+ 'code' => 'subtotal_excl',
153
+ 'value' => $subtotal,
154
+ 'base_value'=> $baseSubtotal,
155
+ 'label' => $taxHelper->__('Subtotal (Excl.Tax)')
156
+ ));
157
+ $totalIncl = new Varien_Object(array(
158
+ 'code' => 'subtotal_incl',
159
+ 'value' => $subtotalIncl,
160
+ 'base_value'=> $baseSubtotalIncl,
161
+ 'label' => $taxHelper->__('Subtotal (Incl.Tax)')
162
+ ));
163
+ $parent->addTotal($totalExcl, 'subtotal');
164
+ $parent->addTotal($totalIncl, 'subtotal_excl');
165
+ $parent->removeTotal('subtotal');
166
+ } elseif ($this->_config->displaySalesSubtotalInclTax($store)) {
167
+ $subtotalIncl = (float) $this->_source->getSubtotalInclTax();
168
+ $baseSubtotalIncl= (float) $this->_source->getBaseSubtotalInclTax();
169
+
170
+ if (!$subtotalIncl) {
171
+ $subtotalIncl = $this->_source->getSubtotal()
172
+ + $this->_source->getTaxAmount()
173
+ - $this->_source->getShippingTaxAmount()
174
+ - $this->_source->getVaimoKlarnaFeeTax();
175
+ }
176
+ if (!$baseSubtotalIncl) {
177
+ $baseSubtotalIncl = $this->_source->getBaseSubtotal()
178
+ + $this->_source->getBaseTaxAmount()
179
+ - $this->_source->getBaseShippingTaxAmount()
180
+ - $this->_source->getVaimoKlarnaBaseFeeTax();
181
+ }
182
+
183
+ $total = $parent->getTotal('subtotal');
184
+ if ($total) {
185
+ $total->setValue(max(0, $subtotalIncl));
186
+ $total->setBaseValue(max(0, $baseSubtotalIncl));
187
+ }
188
  }
189
  return $this;
190
  }
app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Ga.php CHANGED
@@ -35,6 +35,10 @@ class Vaimo_Klarna_Block_Klarnacheckout_Ga extends Mage_GoogleAnalytics_Block_Ga
35
  {
36
  $result = parent::_getOrdersTrackingCode();
37
 
 
 
 
 
38
  /** @var Klarna_Checkout_Order $klarnaOrder */
39
  // Not happy with this, but I guess we can't solve it in other ways.
40
  // can use it without getting hold of and use the actual KlarnaOrder
35
  {
36
  $result = parent::_getOrdersTrackingCode();
37
 
38
+ if ($result) {
39
+ return $result;
40
+ }
41
+
42
  /** @var Klarna_Checkout_Order $klarnaOrder */
43
  // Not happy with this, but I guess we can't solve it in other ways.
44
  // can use it without getting hold of and use the actual KlarnaOrder
app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Klarnacheckout.php CHANGED
@@ -35,15 +35,49 @@ class Vaimo_Klarna_Block_Klarnacheckout_Klarnacheckout extends Mage_Core_Block_T
35
  return $this->getCheckout()->getQuote();
36
  }
37
 
38
- public function getKlarnaHtml()
39
  {
40
  try {
41
  $klarna = Mage::getModel('klarna/klarnacheckout');
42
  $klarna->setQuote($this->getQuote(), Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
43
- // Want to send down kco id here, but then it will not call updateOrder
44
- // in initKlarnaOrder, which is just ugly code... Need to fix that!
45
- // $klarna->getQuote()->getKlarnaCheckoutId()
46
- $html = $klarna->getKlarnaOrderHtml(NULL, true, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  } catch (Exception $e) {
48
  Mage::helper('klarna')->logKlarnaException($e);
49
  $html = $e->getMessage();
@@ -59,6 +93,11 @@ class Vaimo_Klarna_Block_Klarnacheckout_Klarnacheckout extends Mage_Core_Block_T
59
  $extraInfo
60
  );
61
  }
 
 
 
 
 
62
  }
63
 
64
  return $html;
35
  return $this->getCheckout()->getQuote();
36
  }
37
 
38
+ protected function _getKlarnaOrderHtml()
39
  {
40
  try {
41
  $klarna = Mage::getModel('klarna/klarnacheckout');
42
  $klarna->setQuote($this->getQuote(), Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
43
+ $html = $klarna->getKlarnaOrderHtml($klarna->getQuote()->getKlarnaCheckoutId(), true, true);
44
+ } catch (Exception $e) {
45
+ $quote = Mage::helper('klarna')->findQuote($klarna->getQuote()->getKlarnaCheckoutId());
46
+ $orderCreated = false;
47
+ if ($quote && $quote->getId()) {
48
+ $order = Mage::getModel('sales/order')->load($quote->getId(), 'quote_id');
49
+ if ($order->getId()) {
50
+ $orderCreated = true;
51
+ }
52
+ }
53
+ if ($quote && ($quote->getId()!=$klarna->getQuote()->getId() || !$quote->getIsActive() || $orderCreated)) {
54
+ if (!$quote->getIsActive()) {
55
+ Mage::helper('klarna')->logKlarnaApi('getKlarnaOrderHtml failed with checkout id: ' . $klarna->getQuote()->getKlarnaCheckoutId() . '. ' . $e->getMessage() . '. ' . 'Exiting since quote is inactive ' . $quote->getId());
56
+ } elseif ($order->getId()) {
57
+ Mage::helper('klarna')->logKlarnaApi('getKlarnaOrderHtml failed with checkout id: ' . $klarna->getQuote()->getKlarnaCheckoutId() . '. ' . $e->getMessage() . '. ' . 'Exiting since quote has already created an order ' . $order->getIncrementId());
58
+ } else {
59
+ Mage::helper('klarna')->logKlarnaApi('getKlarnaOrderHtml failed with checkout id: ' . $klarna->getQuote()->getKlarnaCheckoutId() . '. ' . $e->getMessage() . '. ' . 'Exiting since quote is wrong' . $quote->getId());
60
+ }
61
+ if ($quote->getIsActive()) {
62
+ $quote->setIsActive(false);
63
+ $quote->save();
64
+ }
65
+ Mage::helper('klarna')->logKlarnaException($e);
66
+ Mage::throwException(Mage::helper('klarna')->__('Current cart is not active. Please try again'));
67
+ } else {
68
+ Mage::helper('klarna')->logKlarnaApi('getKlarnaOrderHtml failed with checkout id: ' . $klarna->getQuote()->getKlarnaCheckoutId() . '. Trying with null.');
69
+ $klarna->getQuote()->setKlarnaCheckoutId(null);
70
+ $html = $klarna->getKlarnaOrderHtml(null, true, true);
71
+ Mage::helper('klarna')->logKlarnaApi('getKlarnaOrderHtml succeeded with null');
72
+ }
73
+ }
74
+ return $html;
75
+ }
76
+
77
+ public function getKlarnaHtml()
78
+ {
79
+ try {
80
+ $html = $this->_getKlarnaOrderHtml();
81
  } catch (Exception $e) {
82
  Mage::helper('klarna')->logKlarnaException($e);
83
  $html = $e->getMessage();
93
  $extraInfo
94
  );
95
  }
96
+ $this->getCheckout()->addError($html);
97
+ Mage::app()->getResponse()
98
+ ->setRedirect(Mage::getBaseUrl() . Mage::helper('klarna')->getKCORedirectToCartUrl($this->getQuote()->getStoreId()))
99
+ ->sendResponse();
100
+ exit(0);
101
  }
102
 
103
  return $html;
app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Success.php CHANGED
@@ -28,13 +28,18 @@ class Vaimo_Klarna_Block_Klarnacheckout_Success extends Mage_Core_Block_Template
28
  public function getKlarnaHtml()
29
  {
30
  try {
31
- $checkoutId = Mage::getSingleton('checkout/session')->getKlarnaCheckoutId();
32
 
33
  /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
34
  $klarna = Mage::getModel('klarna/klarnacheckout');
35
- $klarna->setStoreInformation();
36
- // Klarna model must know the correct store at this point, which we can not...
37
- $klarna->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
 
 
 
 
 
38
  $html = $klarna->getKlarnaOrderHtml($checkoutId, false, false);
39
  } catch (Exception $e) {
40
  Mage::helper('klarna')->logKlarnaException($e);
@@ -43,4 +48,65 @@ class Vaimo_Klarna_Block_Klarnacheckout_Success extends Mage_Core_Block_Template
43
 
44
  return $html;
45
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
28
  public function getKlarnaHtml()
29
  {
30
  try {
31
+ $checkoutId = Mage::getSingleton('checkout/session')->getKlarnaCheckoutPrevId();
32
 
33
  /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
34
  $klarna = Mage::getModel('klarna/klarnacheckout');
35
+ $quote = Mage::helper('klarna')->findQuote($checkoutId);
36
+ if ($quote) {
37
+ $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
38
+ } else {
39
+ // Klarna model must know the correct store at this point, which we can not...
40
+ $klarna->setStoreInformation();
41
+ $klarna->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
42
+ }
43
  $html = $klarna->getKlarnaOrderHtml($checkoutId, false, false);
44
  } catch (Exception $e) {
45
  Mage::helper('klarna')->logKlarnaException($e);
48
 
49
  return $html;
50
  }
51
+
52
+ /**
53
+ * Only returns valid information if order is created during success
54
+ *
55
+ * @return Mage_Core_Model_Abstract
56
+ */
57
+ public function getOrder()
58
+ {
59
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
60
+ $order = Mage::getModel('sales/order')->load($orderId);
61
+ return $order;
62
+ }
63
+
64
+ /**
65
+ * Only returns valid information if order is created during success
66
+ *
67
+ * @return string
68
+ */
69
+ public function getRealOrderId()
70
+ {
71
+ $res = Mage::getSingleton('checkout/session')->getLastRealOrderId();
72
+ return $res;
73
+ }
74
+
75
+ public function getViewOrderUrl()
76
+ {
77
+ return $this->_getData('view_order_id');
78
+ }
79
+
80
+ /**
81
+ * Initialize data and prepare it for output
82
+ */
83
+ protected function _beforeToHtml()
84
+ {
85
+ $this->_prepareLastOrder();
86
+ return parent::_beforeToHtml();
87
+ }
88
+
89
+ /**
90
+ * Get last order ID from session, fetch it and check whether it can be viewed, printed etc
91
+ */
92
+ protected function _prepareLastOrder()
93
+ {
94
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
95
+ if ($orderId) {
96
+ $order = Mage::getModel('sales/order')->load($orderId);
97
+ if ($order->getId()) {
98
+ $isVisible = !in_array($order->getState(),
99
+ Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
100
+ $this->addData(array(
101
+ 'is_order_visible' => $isVisible,
102
+ 'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
103
+ 'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
104
+ 'can_print_order' => $isVisible,
105
+ 'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
106
+ 'order_id' => $order->getIncrementId(),
107
+ ));
108
+ }
109
+ }
110
+ }
111
+
112
  }
app/code/community/Vaimo/Klarna/Helper/Data.php CHANGED
@@ -309,6 +309,19 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
309
  return $res;
310
  }
311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  /**
313
  * Check if FireCheckout is activated or not
314
  *
@@ -971,6 +984,10 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
971
 
972
  public function findQuote($klarna_id)
973
  {
 
 
 
 
974
  /** @var Mage_Core_Model_Resource $resource */
975
  $resource = Mage::getSingleton('core/resource');
976
  /** @var Varien_Db_Adapter_Interface $read */
@@ -991,6 +1008,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
991
  ->setStoreId($r['store_id'])
992
  ->load($r['entity_id']);
993
 
 
994
  return $quote;
995
  }
996
 
@@ -1034,4 +1052,68 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
1034
  return self::$isEnterprise;
1035
  }
1036
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1037
  }
309
  return $res;
310
  }
311
 
312
+ /**
313
+ * Returns checkout/cart unless specific redirect specified
314
+ *
315
+ */
316
+ public function getKCORedirectToCartUrl($store = null)
317
+ {
318
+ $res = Mage::getStoreConfig('payment/vaimo_klarna_checkout/cart_redirect', $store);
319
+ if (!$res) {
320
+ $res = 'checkout/cart';
321
+ }
322
+ return $res;
323
+ }
324
+
325
  /**
326
  * Check if FireCheckout is activated or not
327
  *
984
 
985
  public function findQuote($klarna_id)
986
  {
987
+ if (!$klarna_id) {
988
+ Mage::helper('klarna')->logKlarnaApi('findQuote no klarna_id provided!');
989
+ return null;
990
+ }
991
  /** @var Mage_Core_Model_Resource $resource */
992
  $resource = Mage::getSingleton('core/resource');
993
  /** @var Varien_Db_Adapter_Interface $read */
1008
  ->setStoreId($r['store_id'])
1009
  ->load($r['entity_id']);
1010
 
1011
+ $quote->setTotalsCollectedFlag(true);
1012
  return $quote;
1013
  }
1014
 
1052
  return self::$isEnterprise;
1053
  }
1054
 
1055
+
1056
+ protected function _isAdminUserLoggedIn()
1057
+ {
1058
+ return Mage::getSingleton('admin/session')->isLoggedIn();
1059
+ }
1060
+
1061
+
1062
+ public function prepareVaimoKlarnaFeeRefund(Mage_Sales_Model_Order_Creditmemo $creditmemo)
1063
+ {
1064
+ if (!$this->_isAdminUserLoggedIn() || $creditmemo->hasVaimoKlarnaFeeRefund()) {
1065
+ return $this;
1066
+ }
1067
+
1068
+ $data = $this->_getRequest()->getParam('creditmemo', array());
1069
+ if (!isset($data['vaimo_klarna_fee_refund'])) {
1070
+ return $this;
1071
+ }
1072
+ $refundAmount = empty($data['vaimo_klarna_fee_refund']) ? 0 : $data['vaimo_klarna_fee_refund'];
1073
+
1074
+ $store = $creditmemo->getOrder()->getStore();
1075
+ $baseRefundAmount = $store->convertPrice($refundAmount, false);
1076
+
1077
+ $creditmemo->setVaimoKlarnaFeeRefund($refundAmount)
1078
+ ->setVaimoKlarnaBaseFeeRefund($baseRefundAmount);
1079
+
1080
+ return $this;
1081
+ }
1082
+
1083
+ public function checkPaymentMethod($quote, $logf = false)
1084
+ {
1085
+ if ($quote->getPayment()->getMethod() != Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT) {
1086
+ if ($logf) {
1087
+ $this->logDebugInfo('_createTheOrder quote ' . $quote->getId() .
1088
+ ' not proper method (' . $quote->getPayment()->getMethod() .
1089
+ '), changing to ' .
1090
+ Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
1091
+ }
1092
+ if ($quote->isVirtual()) {
1093
+ $quote->getBillingAddress()->setPaymentMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
1094
+ } else {
1095
+ $quote->getShippingAddress()->setPaymentMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
1096
+ }
1097
+ $quote->getPayment()->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
1098
+ return true;
1099
+ }
1100
+ return false;
1101
+ }
1102
+
1103
+ /**
1104
+ * Check if exception is triggered by local XML-RPC library
1105
+ *
1106
+ * @param Exception $e
1107
+ * @return boolean
1108
+ */
1109
+ public function isXmlRpcException(Exception $e)
1110
+ {
1111
+ if (empty($GLOBALS['xmlrpcerr']) || empty($GLOBALS['xmlrpcstr'])) {
1112
+ return false;
1113
+ }
1114
+
1115
+ $xmlRpcErrorCode = array_search($e->getCode(), $GLOBALS['xmlrpcerr']);
1116
+ return ($xmlRpcErrorCode !== false)
1117
+ && (strpos($e->getMessage(), $GLOBALS['xmlrpcstr'][$xmlRpcErrorCode]) === 0);
1118
+ }
1119
  }
app/code/community/Vaimo/Klarna/Model/Api/Abstract.php CHANGED
@@ -29,6 +29,8 @@ abstract class Vaimo_Klarna_Model_Api_Abstract extends Varien_Object
29
 
30
  protected $_transport = NULL;
31
 
 
 
32
  public function setTransport($model)
33
  {
34
  $this->_transport = $model;
@@ -39,6 +41,33 @@ abstract class Vaimo_Klarna_Model_Api_Abstract extends Varien_Object
39
  return $this->_transport;
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  /**
43
  * Get current active quote instance
44
  *
29
 
30
  protected $_transport = NULL;
31
 
32
+ protected $_lastErrorObj = NULL;
33
+
34
  public function setTransport($model)
35
  {
36
  $this->_transport = $model;
41
  return $this->_transport;
42
  }
43
 
44
+ protected function _getLastError($var = NULL)
45
+ {
46
+ if ($this->_lastErrorObj) {
47
+ if ($var) {
48
+ return $this->_lastErrorObj->getData($var);
49
+ } else {
50
+ return $this->_lastErrorObj;
51
+ }
52
+ } else {
53
+ return NULL;
54
+ }
55
+ }
56
+
57
+ protected function _updateLastError($response, $arrExtra = NULL)
58
+ {
59
+ if ($response) {
60
+ $this->_lastErrorObj = new Varien_Object(json_decode($response, true));
61
+ if ($arrExtra) {
62
+ foreach ($arrExtra as $id => $val) {
63
+ $this->_lastErrorObj->setData($id, $val);
64
+ }
65
+ }
66
+ } else {
67
+ $this->_lastErrorObj = NULL;
68
+ }
69
+ }
70
+
71
  /**
72
  * Get current active quote instance
73
  *
app/code/community/Vaimo/Klarna/Model/Api/Kco.php CHANGED
@@ -259,17 +259,17 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
259
  $create = array();
260
  $create['purchase_country'] = Mage::helper('klarna')->getDefaultCountry();
261
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
262
- $create['locale'] = str_replace('_', '-', Mage::app()->getLocale()->getLocaleCode());
263
- $sysLocaleArr = explode('-', $create['locale']);
264
- if (sizeof($sysLocaleArr)>1) {
265
- $create['locale'] = $this->_klarnaSetup->getLanguageCode() . '-' .$sysLocaleArr[1];
266
- }
267
  $create['merchant']['id'] = $this->_klarnaSetup->getMerchantId();
268
  $terms = Mage::helper('klarna')->getTermsUrl($this->_klarnaSetup->getTermsUrl());
269
  if ($terms) {
270
  $create['merchant']['terms_uri'] = $terms;
271
  }
272
- $create['merchant']['checkout_uri'] = Mage::getUrl('checkout/klarna');
 
 
 
 
273
  $create['merchant']['confirmation_uri'] = Mage::getUrl('checkout/klarna/success');
274
  $create['gui']['layout'] = $this->_isMobile() ? 'mobile' : 'desktop';
275
  if ($this->_getTransport()->getConfigData('enable_auto_focus')==false) {
@@ -489,6 +489,9 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
489
  public function getKlarnaOrderRaw($checkoutId)
490
  {
491
  if ($checkoutId) {
 
 
 
492
  $this->_klarnaOrder = new Klarna_Checkout_Order($this->_getConnector(), Klarna_Checkout_Order::$baseUri . '/' . $checkoutId);
493
  $this->_klarnaOrder->fetch();
494
  $order = new Varien_Object($this->_klarnaOrder->marshal());
@@ -510,13 +513,28 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
510
  if ($checkoutId) {
511
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder checkout id: ' . $checkoutId . ' (quote id: ' . $quoteId . ')');
512
  $loadf = true;
513
- if ($this->_useKlarnaOrderSessionCache) {
514
- if ($this->_klarnaOrder) {
515
- $loadf = false;
 
 
516
  }
517
  }
518
  if ($loadf) {
519
  $this->_klarnaOrder = new Klarna_Checkout_Order($this->_getConnector(), Klarna_Checkout_Order::$baseUri . '/' . $checkoutId);
 
 
 
 
 
 
 
 
 
 
 
 
 
520
  $this->_klarnaOrder->fetch();
521
  }
522
  $res = $this->_klarnaOrder!=NULL;
@@ -531,26 +549,31 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
531
  }
532
 
533
  if ($klarnaCheckoutId = $this->_getKlarnaCheckoutId()) {
534
- try {
535
- Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder klarnaCheckoutId id: ' . $klarnaCheckoutId . ' (quote id: ' . $quoteId . ')');
536
- $this->_klarnaOrder = new Klarna_Checkout_Order($this->_getConnector(), Klarna_Checkout_Order::$baseUri . '/' . $klarnaCheckoutId);
537
- if ($updateItems) {
538
  $this->_klarnaOrder->update($this->_getUpdateRequest());
539
- }
540
- $this->_klarnaOrder->fetch();
541
- $res = $this->_klarnaOrder!=NULL;
542
- if ($res) {
543
- if ($this->_getLocationOrderId()) {
544
- $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
 
545
  }
546
- Mage::dispatchEvent('klarnacheckout_init_klarna_order', array('klarna_order' => $this->_klarnaOrder, 'api_version' => $this->getApiVersion()));
547
  }
548
- Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
549
- return $res;
550
- } catch (Exception $e) {
551
- // when checkout in Klarna was expired, then exception, so we just ignore and create new
552
- Mage::helper('klarna')->logKlarnaException($e);
553
  }
 
 
 
 
 
 
 
 
 
 
554
  }
555
 
556
  if ($createIfNotExists) {
@@ -591,6 +614,14 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
591
  return NULL;
592
  }
593
 
 
 
 
 
 
 
 
 
594
  public function getKlarnaCheckoutGui()
595
  {
596
  if ($this->_klarnaOrder) {
@@ -671,10 +702,11 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
671
  foreach ($quote->getAllVisibleItems() as $quoteItem) {
672
  $foundf = false;
673
  $data = $createdKlarnaOrder->getData();
 
674
  if (isset($data['cart'])) {
675
  if (isset($data['cart']['items'])) {
676
  foreach ($data['cart']['items'] as $klarnaItem) {
677
- if ($klarnaItem['reference']==$quoteItem->getSku() &&
678
  $klarnaItem['quantity']==$quoteItem->getQty()
679
  ) {
680
  $foundf = true;
259
  $create = array();
260
  $create['purchase_country'] = Mage::helper('klarna')->getDefaultCountry();
261
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
262
+ $create['locale'] = str_replace('_', '-', $this->_klarnaSetup->getLocaleCode());
 
 
 
 
263
  $create['merchant']['id'] = $this->_klarnaSetup->getMerchantId();
264
  $terms = Mage::helper('klarna')->getTermsUrl($this->_klarnaSetup->getTermsUrl());
265
  if ($terms) {
266
  $create['merchant']['terms_uri'] = $terms;
267
  }
268
+ if ($this->_getTransport()->getConfigData('recreate_cart_on_failed_validate')) {
269
+ $create['merchant']['checkout_uri'] = Mage::getUrl('checkout/klarna', array('_nosid' => true, 'quote_id' => $this->_getQuote()->getId()));
270
+ } else {
271
+ $create['merchant']['checkout_uri'] = Mage::getUrl('checkout/klarna');
272
+ }
273
  $create['merchant']['confirmation_uri'] = Mage::getUrl('checkout/klarna/success');
274
  $create['gui']['layout'] = $this->_isMobile() ? 'mobile' : 'desktop';
275
  if ($this->_getTransport()->getConfigData('enable_auto_focus')==false) {
489
  public function getKlarnaOrderRaw($checkoutId)
490
  {
491
  if ($checkoutId) {
492
+ if ($this->_klarnaOrder) {
493
+ return $this->_klarnaOrder;
494
+ }
495
  $this->_klarnaOrder = new Klarna_Checkout_Order($this->_getConnector(), Klarna_Checkout_Order::$baseUri . '/' . $checkoutId);
496
  $this->_klarnaOrder->fetch();
497
  $order = new Varien_Object($this->_klarnaOrder->marshal());
513
  if ($checkoutId) {
514
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder checkout id: ' . $checkoutId . ' (quote id: ' . $quoteId . ')');
515
  $loadf = true;
516
+ if (!$updateItems) {
517
+ if ($this->_useKlarnaOrderSessionCache) {
518
+ if ($this->_klarnaOrder) {
519
+ $loadf = false;
520
+ }
521
  }
522
  }
523
  if ($loadf) {
524
  $this->_klarnaOrder = new Klarna_Checkout_Order($this->_getConnector(), Klarna_Checkout_Order::$baseUri . '/' . $checkoutId);
525
+ if ($updateItems) {
526
+ try {
527
+ $this->_klarnaOrder->update($this->_getUpdateRequest());
528
+ } catch (Exception $e) {
529
+ $this->_updateLastError($e->getMessage());
530
+ if ($this->_getLastError('http_status_code')=='403' &&
531
+ $this->_getLastError('http_status_message')=='Forbidden') {
532
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder trying to update, but it is forbidden, so we skip it and just use fetch');
533
+ } else {
534
+ throw $e;
535
+ }
536
+ }
537
+ }
538
  $this->_klarnaOrder->fetch();
539
  }
540
  $res = $this->_klarnaOrder!=NULL;
549
  }
550
 
551
  if ($klarnaCheckoutId = $this->_getKlarnaCheckoutId()) {
552
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder klarnaCheckoutId id: ' . $klarnaCheckoutId . ' (quote id: ' . $quoteId . ')');
553
+ $this->_klarnaOrder = new Klarna_Checkout_Order($this->_getConnector(), Klarna_Checkout_Order::$baseUri . '/' . $klarnaCheckoutId);
554
+ if ($updateItems) {
555
+ try {
556
  $this->_klarnaOrder->update($this->_getUpdateRequest());
557
+ } catch (Exception $e) {
558
+ $this->_updateLastError($e->getMessage());
559
+ if ($this->_getLastError('http_status_code')=='403' &&
560
+ $this->_getLastError('http_status_message')=='Forbidden') {
561
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder trying to update, but it is forbidden, so we skip it and just use fetch');
562
+ } else {
563
+ throw $e;
564
  }
 
565
  }
 
 
 
 
 
566
  }
567
+ $this->_klarnaOrder->fetch();
568
+ $res = $this->_klarnaOrder!=NULL;
569
+ if ($res) {
570
+ if ($this->_getLocationOrderId()) {
571
+ $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
572
+ }
573
+ Mage::dispatchEvent('klarnacheckout_init_klarna_order', array('klarna_order' => $this->_klarnaOrder, 'api_version' => $this->getApiVersion()));
574
+ }
575
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
576
+ return $res;
577
  }
578
 
579
  if ($createIfNotExists) {
614
  return NULL;
615
  }
616
 
617
+ public function getActualKlarnaOrderArray()
618
+ {
619
+ if ($this->getActualKlarnaOrder()) {
620
+ return $this->_klarnaOrder->marshal();
621
+ }
622
+ return array();
623
+ }
624
+
625
  public function getKlarnaCheckoutGui()
626
  {
627
  if ($this->_klarnaOrder) {
702
  foreach ($quote->getAllVisibleItems() as $quoteItem) {
703
  $foundf = false;
704
  $data = $createdKlarnaOrder->getData();
705
+ // $data is actually an object
706
  if (isset($data['cart'])) {
707
  if (isset($data['cart']['items'])) {
708
  foreach ($data['cart']['items'] as $klarnaItem) {
709
+ if ($klarnaItem['reference']==substr($quoteItem->getSku(), 0, 64) &&
710
  $klarnaItem['quantity']==$quoteItem->getQty()
711
  ) {
712
  $foundf = true;
app/code/community/Vaimo/Klarna/Model/Api/Rest.php CHANGED
@@ -81,7 +81,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
81
 
82
  public function curlHeader($ch, $str)
83
  {
84
- Mage::helper('klarna')->logDebugInfo('curlHeader rest str = ' . $str);
85
  if (strpos($str, ': ') !== false) {
86
  list($key, $value) = explode(': ', $str, 2);
87
  $this->_curlHeaders[$key] = trim($value);
@@ -410,12 +410,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
410
  $create = array();
411
  $create['purchase_country'] = Mage::helper('klarna')->getDefaultCountry();
412
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
413
- $create['locale'] = str_replace('_', '-', Mage::app()->getLocale()->getLocaleCode());
414
- $sysLocaleArr = explode('-', $create['locale']);
415
- if (sizeof($sysLocaleArr)>1) {
416
- $create['locale'] = $this->_klarnaSetup->getLanguageCode() . '-' .$sysLocaleArr[1];
417
- }
418
-
419
  $create['gui']['layout'] = $this->_isMobile() ? 'mobile' : 'desktop';
420
  if ($this->_getTransport()->getConfigData('enable_auto_focus')==false) {
421
  $create['gui']['options'] = array('disable_autofocus');
@@ -504,7 +499,11 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
504
  }
505
 
506
  $create['merchant_urls']['terms'] = Mage::helper('klarna')->getTermsUrl($this->_klarnaSetup->getTermsUrl());
507
- $create['merchant_urls']['checkout'] = Mage::getUrl('checkout/klarna');
 
 
 
 
508
  $create['merchant_urls']['confirmation'] = Mage::getUrl('checkout/klarna/success');
509
  $create['merchant_urls']['push'] = $pushUrl;
510
 
@@ -586,6 +585,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
586
  Mage::helper('klarna')->logDebugInfo('_createOrder rest response = ' . $response . ' status = ' . $status);
587
 
588
  if ($status != 201) {
 
589
  Mage::throwException('Error creating order: ' . $status);
590
  }
591
 
@@ -613,6 +613,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
613
  Mage::helper('klarna')->logDebugInfo('_fetchOrder rest response = ' . $response . ' status = ' . $status);
614
 
615
  if ($status != 200) {
 
616
  if ($silentFail) return;
617
  Mage::throwException('Error fetching order: ' . $status);
618
  }
@@ -642,6 +643,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
642
  Mage::helper('klarna')->logDebugInfo('_updateOrder rest response = ' . $response . ' status = ' . $status);
643
 
644
  if ($status != 200) {
 
645
  Mage::throwException('Error updating order: ' . $status);
646
  }
647
 
@@ -666,6 +668,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
666
  Mage::helper('klarna')->logDebugInfo('_fetchCreatedOrder rest response = ' . $response . ' status = ' . $status);
667
 
668
  if ($status != 200) {
 
669
  if ($silentFail) return;
670
  Mage::throwException('Error fetching order: ' . $status);
671
  }
@@ -749,6 +752,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
749
  $message .= '; ' . $value;
750
  }
751
  }
 
752
  Mage::throwException($message);
753
  }
754
 
@@ -799,7 +803,10 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
799
 
800
  Mage::helper('klarna')->logDebugInfo('refund rest response = ' . $response . ' status = ' . $status);
801
 
802
- if ($status != 201) {
 
 
 
803
  $response = json_decode($response, true);
804
  $message = 'Error refunding order: ' . $status;
805
  if (isset($response['error_code'])) {
@@ -810,6 +817,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
810
  $message .= '; ' . $value;
811
  }
812
  }
 
813
  Mage::throwException($message);
814
  }
815
  $res = array(
@@ -854,6 +862,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
854
  $message .= '; ' . $value;
855
  }
856
  }
 
857
  Mage::throwException($message);
858
  }
859
  $res = array(
@@ -897,6 +906,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
897
  $message .= '; ' . $value;
898
  }
899
  }
 
900
  Mage::throwException($message);
901
  }
902
  $res = array(
@@ -916,13 +926,28 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
916
  if ($checkoutId) {
917
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest checkout id: ' . $checkoutId . ' (quote id: ' . $quoteId . ')');
918
  $loadf = true;
919
- if ($this->_useKlarnaOrderSessionCache) {
920
- if ($this->_klarnaOrder) {
921
- $loadf = false;
 
 
922
  }
923
  }
924
  if ($loadf) {
925
- $this->_fetchOrder($checkoutId);
 
 
 
 
 
 
 
 
 
 
 
 
 
926
  }
927
  $res = $this->_klarnaOrder!=NULL;
928
  if ($res) {
@@ -939,7 +964,16 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
939
  try {
940
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest klarnaCheckoutId id: ' . $klarnaCheckoutId . ' (quote id: ' . $quoteId . ')');
941
  if ($updateItems) {
942
- $this->_updateOrder($klarnaCheckoutId);
 
 
 
 
 
 
 
 
 
943
  } else {
944
  $this->_fetchOrder($klarnaCheckoutId);
945
  }
@@ -991,6 +1025,14 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
991
  return NULL;
992
  }
993
 
 
 
 
 
 
 
 
 
994
  public function getKlarnaCheckoutGui()
995
  {
996
  if ($this->_klarnaOrder) {
@@ -1025,7 +1067,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
1025
  {
1026
  $this->_fetchCreatedOrder($checkoutId);
1027
  if ($this->_klarnaOrder) {
1028
- $this->_klarnaOrder->setStatus('created');
1029
  return $this->_klarnaOrder;
1030
  }
1031
  return NULL;
@@ -1167,9 +1209,10 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
1167
  foreach ($quote->getAllVisibleItems() as $quoteItem) {
1168
  $foundf = false;
1169
  $data = $createdKlarnaOrder->getData();
 
1170
  if (isset($data['order_lines'])) {
1171
  foreach ($data['order_lines'] as $klarnaItem) {
1172
- if ($klarnaItem['reference']==$quoteItem->getSku() &&
1173
  $klarnaItem['quantity']==$quoteItem->getQty()
1174
  ) {
1175
  $foundf = true;
81
 
82
  public function curlHeader($ch, $str)
83
  {
84
+ // Mage::helper('klarna')->logDebugInfo('curlHeader rest str = ' . $str);
85
  if (strpos($str, ': ') !== false) {
86
  list($key, $value) = explode(': ', $str, 2);
87
  $this->_curlHeaders[$key] = trim($value);
410
  $create = array();
411
  $create['purchase_country'] = Mage::helper('klarna')->getDefaultCountry();
412
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
413
+ $create['locale'] = str_replace('_', '-', $this->_klarnaSetup->getLocaleCode());
 
 
 
 
 
414
  $create['gui']['layout'] = $this->_isMobile() ? 'mobile' : 'desktop';
415
  if ($this->_getTransport()->getConfigData('enable_auto_focus')==false) {
416
  $create['gui']['options'] = array('disable_autofocus');
499
  }
500
 
501
  $create['merchant_urls']['terms'] = Mage::helper('klarna')->getTermsUrl($this->_klarnaSetup->getTermsUrl());
502
+ if ($this->_getTransport()->getConfigData('recreate_cart_on_failed_validate')) {
503
+ $create['merchant_urls']['checkout'] = Mage::getUrl('checkout/klarna', array('_nosid' => true, 'quote_id' => $this->_getQuote()->getId()));
504
+ } else {
505
+ $create['merchant_urls']['checkout'] = Mage::getUrl('checkout/klarna');
506
+ }
507
  $create['merchant_urls']['confirmation'] = Mage::getUrl('checkout/klarna/success');
508
  $create['merchant_urls']['push'] = $pushUrl;
509
 
585
  Mage::helper('klarna')->logDebugInfo('_createOrder rest response = ' . $response . ' status = ' . $status);
586
 
587
  if ($status != 201) {
588
+ $this->_updateLastError($response, array('status' => $status));
589
  Mage::throwException('Error creating order: ' . $status);
590
  }
591
 
613
  Mage::helper('klarna')->logDebugInfo('_fetchOrder rest response = ' . $response . ' status = ' . $status);
614
 
615
  if ($status != 200) {
616
+ $this->_updateLastError($response, array('status' => $status));
617
  if ($silentFail) return;
618
  Mage::throwException('Error fetching order: ' . $status);
619
  }
643
  Mage::helper('klarna')->logDebugInfo('_updateOrder rest response = ' . $response . ' status = ' . $status);
644
 
645
  if ($status != 200) {
646
+ $this->_updateLastError($response, array('status' => $status));
647
  Mage::throwException('Error updating order: ' . $status);
648
  }
649
 
668
  Mage::helper('klarna')->logDebugInfo('_fetchCreatedOrder rest response = ' . $response . ' status = ' . $status);
669
 
670
  if ($status != 200) {
671
+ $this->_updateLastError($response, array('status' => $status));
672
  if ($silentFail) return;
673
  Mage::throwException('Error fetching order: ' . $status);
674
  }
752
  $message .= '; ' . $value;
753
  }
754
  }
755
+ $this->_updateLastError($response, array('status' => $status));
756
  Mage::throwException($message);
757
  }
758
 
803
 
804
  Mage::helper('klarna')->logDebugInfo('refund rest response = ' . $response . ' status = ' . $status);
805
 
806
+ // 204 is correct, according to their documentation
807
+ // I don't know why this was changed to 201...
808
+ // https://developers.klarna.com/en/gb+php/kco-v3/order-management/update-order
809
+ if ($status != 204) {
810
  $response = json_decode($response, true);
811
  $message = 'Error refunding order: ' . $status;
812
  if (isset($response['error_code'])) {
817
  $message .= '; ' . $value;
818
  }
819
  }
820
+ $this->_updateLastError($response, array('status' => $status));
821
  Mage::throwException($message);
822
  }
823
  $res = array(
862
  $message .= '; ' . $value;
863
  }
864
  }
865
+ $this->_updateLastError($response, array('status' => $status));
866
  Mage::throwException($message);
867
  }
868
  $res = array(
906
  $message .= '; ' . $value;
907
  }
908
  }
909
+ $this->_updateLastError($response, array('status' => $status));
910
  Mage::throwException($message);
911
  }
912
  $res = array(
926
  if ($checkoutId) {
927
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest checkout id: ' . $checkoutId . ' (quote id: ' . $quoteId . ')');
928
  $loadf = true;
929
+ if (!$updateItems) {
930
+ if ($this->_useKlarnaOrderSessionCache) {
931
+ if ($this->_klarnaOrder) {
932
+ $loadf = false;
933
+ }
934
  }
935
  }
936
  if ($loadf) {
937
+ if ($updateItems) {
938
+ try {
939
+ $this->_updateOrder($checkoutId);
940
+ } catch (Exception $e) {
941
+ if ($this->_getLastError('status')=='403' &&
942
+ $this->_getLastError('error_code')=='READ_ONLY_ORDER') {
943
+ $this->_fetchOrder($checkoutId);
944
+ } else {
945
+ throw $e;
946
+ }
947
+ }
948
+ } else {
949
+ $this->_fetchOrder($checkoutId);
950
+ }
951
  }
952
  $res = $this->_klarnaOrder!=NULL;
953
  if ($res) {
964
  try {
965
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest klarnaCheckoutId id: ' . $klarnaCheckoutId . ' (quote id: ' . $quoteId . ')');
966
  if ($updateItems) {
967
+ try {
968
+ $this->_updateOrder($klarnaCheckoutId);
969
+ } catch (Exception $e) {
970
+ if ($this->_getLastError('status')=='403' &&
971
+ $this->_getLastError('error_code')=='READ_ONLY_ORDER') {
972
+ $this->_fetchOrder($klarnaCheckoutId);
973
+ } else {
974
+ throw $e;
975
+ }
976
+ }
977
  } else {
978
  $this->_fetchOrder($klarnaCheckoutId);
979
  }
1025
  return NULL;
1026
  }
1027
 
1028
+ public function getActualKlarnaOrderArray()
1029
+ {
1030
+ if ($this->getActualKlarnaOrder()) {
1031
+ return $this->_klarnaOrder->getData();
1032
+ }
1033
+ return array();
1034
+ }
1035
+
1036
  public function getKlarnaCheckoutGui()
1037
  {
1038
  if ($this->_klarnaOrder) {
1067
  {
1068
  $this->_fetchCreatedOrder($checkoutId);
1069
  if ($this->_klarnaOrder) {
1070
+ // $this->_klarnaOrder->setStatus('created'); // OMG!!
1071
  return $this->_klarnaOrder;
1072
  }
1073
  return NULL;
1209
  foreach ($quote->getAllVisibleItems() as $quoteItem) {
1210
  $foundf = false;
1211
  $data = $createdKlarnaOrder->getData();
1212
+ // $data is actually an object
1213
  if (isset($data['order_lines'])) {
1214
  foreach ($data['order_lines'] as $klarnaItem) {
1215
+ if ($klarnaItem['reference']==substr($quoteItem->getSku(), 0, 64) &&
1216
  $klarnaItem['quantity']==$quoteItem->getQty()
1217
  ) {
1218
  $foundf = true;
app/code/community/Vaimo/Klarna/Model/Api/Xmlrpc.php CHANGED
@@ -576,7 +576,7 @@ class Vaimo_Klarna_Model_Api_Xmlrpc extends Vaimo_Klarna_Model_Api_Abstract
576
  }
577
  Mage::helper('klarna')->logKlarnaApi($msg);
578
  Mage::helper('klarna')->logKlarnaException($e);
579
- Mage::throwException(Mage::helper('klarna')->decode($e->getMessage()));
580
  }
581
  return $res;
582
  }
576
  }
577
  Mage::helper('klarna')->logKlarnaApi($msg);
578
  Mage::helper('klarna')->logKlarnaException($e);
579
+ throw new Mage_Core_Exception(Mage::helper('klarna')->decode($e->getMessage()), $e->getCode());
580
  }
581
  return $res;
582
  }
app/code/community/Vaimo/Klarna/Model/Creditmemo/Tax.php CHANGED
@@ -56,6 +56,8 @@ class Vaimo_Klarna_Model_Creditmemo_Tax extends Mage_Sales_Model_Order_Creditmem
56
  {
57
  $order = $creditmemo->getOrder();
58
  $invoice = $creditmemo->getInvoice();
 
 
59
  if ($order && $invoice) {
60
  $payment = $order->getPayment();
61
  if ($payment) {
56
  {
57
  $order = $creditmemo->getOrder();
58
  $invoice = $creditmemo->getInvoice();
59
+ $this->_getHelper()->prepareVaimoKlarnaFeeRefund($creditmemo);
60
+
61
  if ($order && $invoice) {
62
  $payment = $order->getPayment();
63
  if ($payment) {
app/code/community/Vaimo/Klarna/Model/Creditmemo/Total.php CHANGED
@@ -45,16 +45,6 @@ class Vaimo_Klarna_Model_Creditmemo_Total extends Mage_Sales_Model_Order_Creditm
45
  return $this->_moduleHelper;
46
  }
47
 
48
- protected function _isLoggedIn()
49
- {
50
- return Mage::getSingleton('admin/session')->isLoggedIn();
51
- }
52
-
53
- protected function _getRequest($param)
54
- {
55
- return Mage::app()->getRequest()->getParam($param);
56
- }
57
-
58
  /**
59
  * Collect the order total
60
  *
@@ -71,21 +61,7 @@ class Vaimo_Klarna_Model_Creditmemo_Total extends Mage_Sales_Model_Order_Creditm
71
  */
72
  $order = $creditmemo->getOrder();
73
  $invoice = $creditmemo->getInvoice();
74
- if ($this->_isLoggedIn()) {
75
- $data = $this->_getRequest('creditmemo');
76
- if ($data) {
77
- if (isset($data['vaimo_klarna_fee_refund'])) {
78
- if ($data['vaimo_klarna_fee_refund']=='') {
79
- $data['vaimo_klarna_fee_refund'] = 0;
80
- }
81
- $refundAmount = $data['vaimo_klarna_fee_refund'];
82
- $store = $order->getStore();
83
- $baseRefundAmount = $store->convertPrice($refundAmount, false);
84
- $creditmemo->setVaimoKlarnaFeeRefund($refundAmount);
85
- $creditmemo->setVaimoKlarnaBaseFeeRefund($baseRefundAmount);
86
- }
87
- }
88
- }
89
 
90
  if ($order) {
91
  $payment = $order->getPayment();
45
  return $this->_moduleHelper;
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
48
  /**
49
  * Collect the order total
50
  *
61
  */
62
  $order = $creditmemo->getOrder();
63
  $invoice = $creditmemo->getInvoice();
64
+ $this->_getHelper()->prepareVaimoKlarnaFeeRefund($creditmemo);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  if ($order) {
67
  $payment = $order->getPayment();
app/code/community/Vaimo/Klarna/Model/Cron.php CHANGED
@@ -58,10 +58,17 @@ class Vaimo_Klarna_Model_Cron extends Mage_Core_Model_Abstract
58
  $helper->setFunctionNameForLog('cron treatPushQueue');
59
  $helper->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
60
  foreach ($collection as $pushQueue) {
 
61
  $checkoutId = $pushQueue->getKlarnaOrderNumber();
62
  $quote = $helper->findQuote($checkoutId);
63
- if ($quote == null)
 
 
 
 
 
64
  continue;
 
65
 
66
  /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
67
  $klarna = Mage::getModel('klarna/klarnacheckout');
@@ -69,14 +76,11 @@ class Vaimo_Klarna_Model_Cron extends Mage_Core_Model_Abstract
69
  if (substr($checkoutId, -1, 1) == '/') {
70
  $checkoutId = substr($checkoutId, 0, strlen($checkoutId) - 1);
71
  }
72
- $helper->logKlarnaApi('pushAction checkout id: ' . $checkoutId);
73
- if (!$quote->getId()) {
74
- $helper->logKlarnaApi('pushAction checkout quote not found!');
75
- }
76
 
77
  if ($checkoutId) {
78
  try {
79
  // createOrder returns the order if successful, otherwise an error string
 
80
  $result = $klarna->createOrder($checkoutId);
81
 
82
  if (is_array($result)) {
@@ -107,6 +111,7 @@ class Vaimo_Klarna_Model_Cron extends Mage_Core_Model_Abstract
107
  $pushQueue->setRetryAttempts($attempt + 1);
108
  $pushQueue->save();
109
  $helper->logKlarnaException($e);
 
110
  }
111
  }
112
  }
58
  $helper->setFunctionNameForLog('cron treatPushQueue');
59
  $helper->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
60
  foreach ($collection as $pushQueue) {
61
+ $helper->logKlarnaApi('Queue id: ' . $pushQueue->getId());
62
  $checkoutId = $pushQueue->getKlarnaOrderNumber();
63
  $quote = $helper->findQuote($checkoutId);
64
+ if (!$quote || !$quote->getId()) {
65
+ $pushQueue->setMessage('Quote missing, skipping');
66
+ $attempt = $pushQueue->getRetryAttempts();
67
+ $pushQueue->setRetryAttempts($attempt + 1);
68
+ $pushQueue->save();
69
+ $helper->logKlarnaApi('Quote missing, skipping');
70
  continue;
71
+ }
72
 
73
  /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
74
  $klarna = Mage::getModel('klarna/klarnacheckout');
76
  if (substr($checkoutId, -1, 1) == '/') {
77
  $checkoutId = substr($checkoutId, 0, strlen($checkoutId) - 1);
78
  }
 
 
 
 
79
 
80
  if ($checkoutId) {
81
  try {
82
  // createOrder returns the order if successful, otherwise an error string
83
+ $helper->logKlarnaApi('Calling create order with id: ' . $checkoutId);
84
  $result = $klarna->createOrder($checkoutId);
85
 
86
  if (is_array($result)) {
111
  $pushQueue->setRetryAttempts($attempt + 1);
112
  $pushQueue->save();
113
  $helper->logKlarnaException($e);
114
+ $helper->logKlarnaApi('Exception ' . $e->getMessage());
115
  }
116
  }
117
  }
app/code/community/Vaimo/Klarna/Model/Invoice/Pdf/Total.php CHANGED
@@ -126,6 +126,9 @@ class Vaimo_Klarna_Model_Invoice_Pdf_Total extends Mage_Sales_Model_Order_Pdf_To
126
  */
127
  public function canDisplay()
128
  {
 
 
 
129
  $amount = $this->getAmount();
130
  return ($this->getDisplayZero() || ($amount != 0));
131
  }
126
  */
127
  public function canDisplay()
128
  {
129
+ if (!$this->_getHelper()->isMethodKlarna($this->getOrder()->getPayment()->getMethod())) {
130
+ return false;
131
+ }
132
  $amount = $this->getAmount();
133
  return ($this->getDisplayZero() || ($amount != 0));
134
  }
app/code/community/Vaimo/Klarna/Model/Klarnacheckout.php CHANGED
@@ -106,7 +106,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
106
  *
107
  * @return string
108
  */
109
- public function getCheckoutStatus($checkoutId = null)
110
  {
111
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER);
112
  if ($checkoutId) {
@@ -114,8 +114,12 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
114
  } else {
115
  $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
116
  }
117
- $this->_api->setKlarnaOrderSessionCache(true);
118
- $this->_api->initKlarnaOrder($checkoutId);
 
 
 
 
119
  $res = $this->_api->getKlarnaCheckoutStatus();
120
  $this->_getHelper()->logKlarnaApi('Call complete');
121
  return $res;
@@ -130,6 +134,11 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
130
  return $this->_api->getActualKlarnaOrder();
131
  }
132
 
 
 
 
 
 
133
  /*
134
  * Will return the klarna order or null, if it doesn't find it
135
  * Not used by this module, but as a service for others.
@@ -181,6 +190,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
181
  if ($item->getParentItemId()) {
182
  $this->_reduceParentItem($quote, $item->getParentItemId(), $qty);
183
  }
 
184
  }
185
  }
186
  }
@@ -189,7 +199,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
189
  return $res;
190
  }
191
 
192
- public function validateQuote($checkoutId, $createOrderOnValidate = NULL, $createdKlarnaOrder = NULL)
193
  {
194
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOVALIDATE_ORDER);
195
 
@@ -197,12 +207,12 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
197
  $quote = $this->getQuote();
198
 
199
  if (!$quote->getId()) {
200
- $this->_getHelper()->logDebugInfo('validateQuote could not get quote');
201
  return $this->_getHelper()->__('could not get quote');
202
  }
203
 
204
  if (!$quote->hasItems()) {
205
- $this->_getHelper()->logDebugInfo('validateQuote has no items');
206
  return $this->_getHelper()->__('has no items');
207
  }
208
 
@@ -222,25 +232,25 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
222
  if (sizeof($result)==0) {
223
  $result = array('Unknown error');
224
  }
225
- $this->_getHelper()->logDebugInfo('validateQuote errors: ' . implode(" ", $result));
226
  return implode("\n", $result);
227
  }
228
 
229
  if (!$quote->validateMinimumAmount()) {
230
- $this->_getHelper()->logDebugInfo('validateQuote below minimum amount');
231
  return $this->_getHelper()->__('minimum amount');
232
  }
233
 
234
  $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
235
  if ($orderId>0) {
236
- $this->_getHelper()->logDebugInfo('validateQuote order already created ' . $orderId);
237
  return $this->_getHelper()->__('order already created');
238
  }
239
 
240
  if ($createdKlarnaOrder) {
241
  $noticeTextArr = $this->_checkQuote($quote, $createdKlarnaOrder);
242
  if ($noticeTextArr!=NULL) {
243
- $this->_getHelper()->logDebugInfo('validateQuote failed in checkQuote', $noticeTextArr);
244
  return $this->_getHelper()->__('not matching cart');
245
  }
246
  }
@@ -248,22 +258,52 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
248
  if ($createOrderOnValidate && $createdKlarnaOrder) {
249
  // As validation is ok, creating the order should work, if it doesn't, it's
250
  // probably a temporary reason and we should reserve ID and await the push
251
- $order = $this->_createValidateOrder($checkoutId, $quote, $createdKlarnaOrder);
252
  if ($order && $order->getId()) {
253
- $this->_getHelper()->logDebugInfo('validateQuote created order id: ' . $order->getId());
254
  } else {
255
- $this->_getHelper()->logDebugInfo('validateQuote failed to created order');
256
- $quote->reserveOrderId()->save();
257
- $this->_getHelper()->logDebugInfo('validateQuote reserved order id: ' . $quote->getReservedOrderId());
 
258
  }
259
  } else {
 
260
  $quote->reserveOrderId()->save();
261
- $this->_getHelper()->logDebugInfo('validateQuote reserved order id: ' . $quote->getReservedOrderId());
262
  }
263
 
264
  return true;
265
  }
266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  /**
268
  * This function checks valid shippingMethod
269
  *
@@ -275,7 +315,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
275
  public function checkShippingMethod()
276
  {
277
  // set shipping method
278
- $res = NULL;
279
  $quote = $this->getQuote();
280
  $shippingAddress = $quote->getShippingAddress();
281
  if (!$quote->isVirtual() && $shippingAddress && !$shippingAddress->getShippingMethod()) {
@@ -295,15 +335,15 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
295
  Changing country at this point is not accurate, it was set to that country
296
  for a reason, the fact that it lacks region and postocode, should not cause
297
  a country change..
298
-
299
  Possibly, it should default to some region if the country demands one...
300
-
301
- if (Mage::helper('klarna')->getDefaultCountry()!=$shippingAddress->getCountryId()) {
302
  if (!$shippingAddress->getRegionId() && !$shippingAddress->getPostcode()) {
303
- $shippingAddress->setCountryId(Mage::helper('klarna')->getDefaultCountry());
304
  }
305
  }
306
-
307
  */
308
  $shippingAddress->setCollectShippingRates(true);
309
  $shippingAddress->collectTotals();
@@ -351,9 +391,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
351
  $res[] = $shippingNotice;
352
  }
353
 
354
- if ($res) {
355
- $quote->collectTotals();
356
- }
357
 
358
  } catch(Exception $e) {
359
  $res = $e->getMessage();
@@ -401,6 +439,10 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
401
 
402
  protected function _createTheOrder($quote, $createdKlarnaOrder, $updatef, $pushf, $noticeTextArr = NULL)
403
  {
 
 
 
 
404
  $autoRegisterGuest = $this->getConfigData('auto_register_guest');
405
  $isAllowedGuestCheckout = Mage::helper('checkout')->isAllowedGuestCheckout($quote);
406
 
@@ -417,48 +459,35 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
417
  } else {
418
  /** @var $customer Mage_Customer_Model_Customer */
419
  $customer = $this->_loadCustomerByEmail($createdKlarnaOrder->getBillingAddress('email'), $quote->getStore());
420
- if ($customer->getId()) {
421
- $quote->setCustomer($customer);
422
- $quote->setCheckoutMethod('customer');
423
- } elseif ($autoRegisterGuest || !$isAllowedGuestCheckout) {
424
- $quote->setCheckoutMethod('register');
425
- $isNewCustomer = true;
 
 
426
  } else {
427
  $quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST);
428
  }
429
  }
430
 
431
  $billingAddress = $quote->getBillingAddress();
432
- $customerAddressId = 0;
433
-
434
- if ($customerAddressId) {
435
- $customerAddress = $this->_loadCustomerAddress($customerAddressId);
436
- if ($customerAddress->getId()) {
437
- if ($customerAddress->getCustomerId() != $this->getQuote()->getCustomerId()) {
438
- throw new Exception('Customer Address is not valid');
439
- }
440
-
441
- $billingAddress->importCustomerAddress($customerAddress)->setSaveInAddressBook(0);
442
- }
443
- } else {
444
- $billingAddress->setFirstname($createdKlarnaOrder->getBillingAddress('given_name'));
445
- $billingAddress->setLastname($createdKlarnaOrder->getBillingAddress('family_name'));
446
- $billingAddress->setCareOf($createdKlarnaOrder->getBillingAddress('care_of'));
447
- $billingAddress->setStreet($createdKlarnaOrder->getBillingAddress('street_address'));
448
- $billingAddress->setPostcode($createdKlarnaOrder->getBillingAddress('postal_code'));
449
- $billingAddress->setCity($createdKlarnaOrder->getBillingAddress('city'));
450
- $billingAddress->setCountryId(strtoupper($createdKlarnaOrder->getBillingAddress('country')));
451
- $billingAddress->setEmail($createdKlarnaOrder->getBillingAddress('email'));
452
- $billingAddress->setTelephone($createdKlarnaOrder->getBillingAddress('phone'));
453
- $billingAddress->setSaveInAddressBook(1);
454
- if ($billingRegionCode) {
455
- $billingRegionId = Mage::getModel('directory/region')->loadByCode($billingRegionCode, $billingAddress->getCountryId());
456
- $billingAddress->setRegionId($billingRegionId->getId());
457
- }
458
  }
459
 
460
- // $this->_validateCustomerData($data);
461
-
462
  $shippingAddress = $quote->getShippingAddress();
463
  $shippingAddress->setFirstname($createdKlarnaOrder->getShippingAddress('given_name'));
464
  $shippingAddress->setLastname($createdKlarnaOrder->getShippingAddress('family_name'));
@@ -469,6 +498,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
469
  $shippingAddress->setCountryId(strtoupper($createdKlarnaOrder->getShippingAddress('country')));
470
  $shippingAddress->setEmail($createdKlarnaOrder->getShippingAddress('email'));
471
  $shippingAddress->setTelephone($createdKlarnaOrder->getShippingAddress('phone'));
 
472
  if ($shippingRegionCode) {
473
  $shippingRegionId = Mage::getModel('directory/region')->loadByCode($shippingRegionCode, $shippingAddress->getCountryId());
474
  $shippingAddress->setRegionId($shippingRegionId->getId());
@@ -477,9 +507,17 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
477
  if ($this->getConfigData('packstation_enabled')) {
478
  $shippingAddress->setSameAsBilling(0);
479
  } else {
480
- $shippingAddress->setSameAsBilling(1);
 
 
 
 
 
 
 
 
 
481
  }
482
- $shippingAddress->setSaveInAddressBook(0);
483
 
484
  $quote->getBillingAddress()->setShouldIgnoreValidation(true);
485
  $quote->getShippingAddress()->setShouldIgnoreValidation(true);
@@ -499,9 +537,11 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
499
  break;
500
  }
501
 
 
 
502
  $quote->setTotalsCollectedFlag(false);
503
  $quote->collectTotals();
504
- $quote->save();
505
 
506
  Mage::dispatchEvent('klarnacheckout_quote_before_create_order', array(
507
  'quote' => $quote,
@@ -532,6 +572,12 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
532
  /** @var $order Mage_Sales_Model_Order */
533
  $order = $this->_loadOrderByKey($quote->getId());
534
 
 
 
 
 
 
 
535
  if ($pushf) {
536
  if ($order->getState()==Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
537
  $order->setState(
@@ -545,6 +591,10 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
545
 
546
  $payment = $order->getPayment();
547
 
 
 
 
 
548
  if ($createdKlarnaOrder->getReference()) {
549
  $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_REFERENCE, $createdKlarnaOrder->getReference());
550
  } else if ($createdKlarnaOrder->getKlarnaReference()) {
@@ -575,6 +625,8 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
575
  }
576
  $payment->save();
577
 
 
 
578
  if ($pushf) {
579
  // send new order email
580
  if ($order->getCanSendNewEmailFlag()) {
@@ -597,9 +649,13 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
597
  try {
598
  $this->_getHelper()->dispatchMethodEvent($order, Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_RESERVED, $order->getTotalDue(), $this->getMethod());
599
 
600
- Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($order->getId())) );
 
 
 
 
601
 
602
- $this->_getHelper()->logDebugInfo('successfully created order with no: ' . $order->getIncrementId());
603
 
604
  } catch(Exception $e) {
605
  $this->_getHelper()->logKlarnaException($e);
@@ -609,7 +665,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
609
 
610
  }
611
 
612
- protected function _createValidateOrder($checkoutId, $quote, $createdKlarnaOrder)
613
  {
614
  if ($checkoutId) {
615
  $this->_getHelper()->logKlarnaApi('Call with checkout ID ' . $checkoutId);
@@ -624,14 +680,14 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
624
  $order->setState(
625
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
626
  true,
627
- $this->_getHelper()->__('Order created during validation, waiting for confirmation')
628
  );
629
  $order->save();
630
 
631
  return $order;
632
  }
633
 
634
- public function createOrder($checkoutId = NULL)
635
  {
636
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER);
637
  if ($checkoutId) {
@@ -665,30 +721,47 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
665
 
666
  $this->_updateKlarnaOrderAddress($createdKlarnaOrder);
667
 
668
- if ($createdKlarnaOrder->getStatus() != 'checkout_complete' && $createdKlarnaOrder->getStatus() != 'created') {
 
 
 
669
  $this->_getHelper()->logDebugInfo('createOrder status not complete');
670
- return array(
671
- 'status' => 'retry',
672
- 'message' => 'status not complete'
673
- );
 
 
 
 
 
 
 
 
674
  }
675
 
676
  $updatef = false;
677
  $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
678
- if ($orderId>0) {
679
- $this->_getHelper()->logDebugInfo('createOrder order already created ' . $orderId);
680
- if (($createdKlarnaOrder->getStatus() == 'checkout_complete') || ($createdKlarnaOrder->getStatus() == 'created')) {
681
- $order = $this->_loadOrderByKey($quote->getId());
682
- $updatef = true;
 
 
 
 
 
 
 
683
  }
684
- /*
685
- return array(
686
- 'status' => 'fail',
687
- 'message' => 'order already created'
688
- );
689
- */
690
  }
691
-
 
 
 
 
 
692
  $order = $this->_createTheOrder($quote, $createdKlarnaOrder, $updatef, true, $noticeTextArr);
693
 
694
  try {
@@ -719,7 +792,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
719
  return false;
720
  }
721
 
722
- if (!$this->getConfigData('activate_ab_testing')) {
723
 
724
  if ($this->_getCustomerHelper()->isLoggedIn() && !$this->getConfigData('allow_when_logged_in')) {
725
  return false;
@@ -757,13 +830,12 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
757
  return true;
758
  }
759
 
760
- public function updateTaxAndShipping($data)
761
  {
762
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER);
763
 
764
  $newAddress = new Varien_Object($data['shipping_address']);
765
- Mage::helper('klarna')->logDebugInfo('taxshippingupdate A' . $newAddress->getGivenName());
766
- $quote = $this->getQuote();
767
  $address = $quote->getShippingAddress();
768
  $address->setFirstname($newAddress->getGivenName());
769
  $address->setLastname($newAddress->getFamilyName());
@@ -796,30 +868,32 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
796
  $quote->collectTotals();
797
  $quote->save();
798
  $this->setQuote($quote);
799
- Mage::helper('klarna')->logDebugInfo('taxshippingupdate A' . $quote->getId());
800
 
801
  $res = $this->_api->prepareTaxAndShippingReply();
802
- Mage::helper('klarna')->logDebugInfo('taxshippingupdate B' . $res);
803
  return $res;
804
  }
805
 
806
  public function checkNewsletter()
807
  {
808
  // set newsletter subscribe based on settings
809
- if ($this->getQuote()->getKlarnaCheckoutNewsletter() == null) {
 
 
810
  $type = (int)$this->getConfigData('enable_newsletter');
811
  $checked = (bool)$this->getConfigData('newsletter_checked');
812
 
813
  if (($type == Vaimo_Klarna_Helper_Data::KLARNA_CHECKOUT_NEWSLETTER_SUBSCRIBE && $checked)
814
  || ($type == Vaimo_Klarna_Helper_Data::KLARNA_CHECKOUT_NEWSLETTER_DONT_SUBSCRIBE && !$checked)) {
815
- $this->getQuote()->setKlarnaCheckoutNewsletter(1);
816
  } else {
817
- $this->getQuote()->setKlarnaCheckoutNewsletter(0);
818
  }
819
- $this->getQuote()->save();
820
  }
821
 
822
- return $this;
823
  }
824
 
825
  protected function _getTransport()
106
  *
107
  * @return string
108
  */
109
+ public function getCheckoutStatus($checkoutId = null, $useCurrentSession = true)
110
  {
111
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER);
112
  if ($checkoutId) {
114
  } else {
115
  $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
116
  }
117
+ $this->_api->setKlarnaOrderSessionCache($useCurrentSession);
118
+ if ($this->getQuote()) {
119
+ $this->_api->initKlarnaOrder($checkoutId, false, false, $this->getQuote()->getId());
120
+ } else {
121
+ $this->_api->initKlarnaOrder($checkoutId);
122
+ }
123
  $res = $this->_api->getKlarnaCheckoutStatus();
124
  $this->_getHelper()->logKlarnaApi('Call complete');
125
  return $res;
134
  return $this->_api->getActualKlarnaOrder();
135
  }
136
 
137
+ public function getActualKlarnaOrderArray()
138
+ {
139
+ return $this->_api->getActualKlarnaOrderArray();
140
+ }
141
+
142
  /*
143
  * Will return the klarna order or null, if it doesn't find it
144
  * Not used by this module, but as a service for others.
190
  if ($item->getParentItemId()) {
191
  $this->_reduceParentItem($quote, $item->getParentItemId(), $qty);
192
  }
193
+ $quote->setTotalsCollectedFlag(false);
194
  }
195
  }
196
  }
199
  return $res;
200
  }
201
 
202
+ public function validateQuote($checkoutId, $createOrderOnValidate = NULL, $createdKlarnaOrder = NULL, $logInfo = 'validate')
203
  {
204
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOVALIDATE_ORDER);
205
 
207
  $quote = $this->getQuote();
208
 
209
  if (!$quote->getId()) {
210
+ $this->_getHelper()->logDebugInfo($logInfo . 'Quote could not get quote');
211
  return $this->_getHelper()->__('could not get quote');
212
  }
213
 
214
  if (!$quote->hasItems()) {
215
+ $this->_getHelper()->logDebugInfo($logInfo . 'Quote has no items');
216
  return $this->_getHelper()->__('has no items');
217
  }
218
 
232
  if (sizeof($result)==0) {
233
  $result = array('Unknown error');
234
  }
235
+ $this->_getHelper()->logDebugInfo($logInfo . 'Quote errors: ' . implode(" ", $result));
236
  return implode("\n", $result);
237
  }
238
 
239
  if (!$quote->validateMinimumAmount()) {
240
+ $this->_getHelper()->logDebugInfo($logInfo . 'Quote below minimum amount');
241
  return $this->_getHelper()->__('minimum amount');
242
  }
243
 
244
  $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
245
  if ($orderId>0) {
246
+ $this->_getHelper()->logDebugInfo($logInfo . 'Quote order already created ' . $orderId);
247
  return $this->_getHelper()->__('order already created');
248
  }
249
 
250
  if ($createdKlarnaOrder) {
251
  $noticeTextArr = $this->_checkQuote($quote, $createdKlarnaOrder);
252
  if ($noticeTextArr!=NULL) {
253
+ $this->_getHelper()->logDebugInfo($logInfo . 'Quote failed in checkQuote', $noticeTextArr);
254
  return $this->_getHelper()->__('not matching cart');
255
  }
256
  }
258
  if ($createOrderOnValidate && $createdKlarnaOrder) {
259
  // As validation is ok, creating the order should work, if it doesn't, it's
260
  // probably a temporary reason and we should reserve ID and await the push
261
+ $order = $this->_createValidateOrder($checkoutId, $quote, $createdKlarnaOrder, $logInfo);
262
  if ($order && $order->getId()) {
263
+ $this->_getHelper()->logDebugInfo($logInfo . 'Quote created order id: ' . $order->getId());
264
  } else {
265
+ $this->_getHelper()->logDebugInfo($logInfo . 'Quote failed to created order');
266
+ return $this->_getHelper()->__('failed to created order');
267
+ //$quote->reserveOrderId()->save(); // Must be wrong...
268
+ //$this->_getHelper()->logDebugInfo($logInfo . 'Quote reserved order id: ' . $quote->getReservedOrderId());
269
  }
270
  } else {
271
+ $quote->collectTotals();
272
  $quote->reserveOrderId()->save();
273
+ $this->_getHelper()->logDebugInfo($logInfo . 'Quote reserved order id: ' . $quote->getReservedOrderId());
274
  }
275
 
276
  return true;
277
  }
278
 
279
+ public function successQuote($checkoutId, $createOrderOnSuccess, $createdKlarnaOrder)
280
+ {
281
+ $res = true;
282
+ /** @var Mage_Sales_Model_Quote $quote */
283
+ $quote = $this->getQuote();
284
+ if ($createOrderOnSuccess) {
285
+ try {
286
+
287
+ $res = $this->validateQuote($checkoutId, $createOrderOnSuccess, $createdKlarnaOrder, 'success');
288
+
289
+ } catch (Exception $e) {
290
+ $res = $this->_getHelper()->__('failed to created order on success') . ': ' . $e->getMessage();
291
+ }
292
+
293
+ } else {
294
+ // Why don't we set reserve order id on Quote??
295
+ $this->_getHelper()->logDebugInfo('successAction closing quote id: ' .
296
+ $quote->getId() . ' Klarna checkout ID: ' . $checkoutId );
297
+ // Why not these lines?
298
+ //$quote->setIsActive(false);
299
+ //$quote->save();
300
+ /** @var Mage_Core_Model_Resource $resource */
301
+ $resource = Mage::getSingleton('core/resource');
302
+ $read = $resource->getConnection('core_read');
303
+ $read->update($resource->getTableName('sales/quote'), array('is_active' => 0), 'entity_id = ' . $quote->getId());
304
+ }
305
+ return $res;
306
+ }
307
  /**
308
  * This function checks valid shippingMethod
309
  *
315
  public function checkShippingMethod()
316
  {
317
  // set shipping method
318
+ $res = false;
319
  $quote = $this->getQuote();
320
  $shippingAddress = $quote->getShippingAddress();
321
  if (!$quote->isVirtual() && $shippingAddress && !$shippingAddress->getShippingMethod()) {
335
  Changing country at this point is not accurate, it was set to that country
336
  for a reason, the fact that it lacks region and postocode, should not cause
337
  a country change..
338
+
339
  Possibly, it should default to some region if the country demands one...
340
+
341
+ if ($this->_getHelper()->getDefaultCountry()!=$shippingAddress->getCountryId()) {
342
  if (!$shippingAddress->getRegionId() && !$shippingAddress->getPostcode()) {
343
+ $shippingAddress->setCountryId($this->_getHelper()->getDefaultCountry());
344
  }
345
  }
346
+
347
  */
348
  $shippingAddress->setCollectShippingRates(true);
349
  $shippingAddress->collectTotals();
391
  $res[] = $shippingNotice;
392
  }
393
 
394
+ $quote->collectTotals();
 
 
395
 
396
  } catch(Exception $e) {
397
  $res = $e->getMessage();
439
 
440
  protected function _createTheOrder($quote, $createdKlarnaOrder, $updatef, $pushf, $noticeTextArr = NULL)
441
  {
442
+ $this->_getHelper()->logDebugInfo('_createTheOrder called with quote id: ' . $quote->getId());
443
+
444
+ $this->_getHelper()->checkPaymentMethod($quote, true);
445
+
446
  $autoRegisterGuest = $this->getConfigData('auto_register_guest');
447
  $isAllowedGuestCheckout = Mage::helper('checkout')->isAllowedGuestCheckout($quote);
448
 
459
  } else {
460
  /** @var $customer Mage_Customer_Model_Customer */
461
  $customer = $this->_loadCustomerByEmail($createdKlarnaOrder->getBillingAddress('email'), $quote->getStore());
462
+ if ($autoRegisterGuest || !$isAllowedGuestCheckout) {
463
+ if ($customer->getId()) {
464
+ $quote->setCustomer($customer);
465
+ $quote->setCheckoutMethod('customer');
466
+ } else {
467
+ $quote->setCheckoutMethod('register');
468
+ $isNewCustomer = true;
469
+ }
470
  } else {
471
  $quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST);
472
  }
473
  }
474
 
475
  $billingAddress = $quote->getBillingAddress();
476
+ $billingAddress->setFirstname($createdKlarnaOrder->getBillingAddress('given_name'));
477
+ $billingAddress->setLastname($createdKlarnaOrder->getBillingAddress('family_name'));
478
+ $billingAddress->setCareOf($createdKlarnaOrder->getBillingAddress('care_of'));
479
+ $billingAddress->setStreet($createdKlarnaOrder->getBillingAddress('street_address'));
480
+ $billingAddress->setPostcode($createdKlarnaOrder->getBillingAddress('postal_code'));
481
+ $billingAddress->setCity($createdKlarnaOrder->getBillingAddress('city'));
482
+ $billingAddress->setCountryId(strtoupper($createdKlarnaOrder->getBillingAddress('country')));
483
+ $billingAddress->setEmail($createdKlarnaOrder->getBillingAddress('email'));
484
+ $billingAddress->setTelephone($createdKlarnaOrder->getBillingAddress('phone'));
485
+ $billingAddress->setSaveInAddressBook(1);
486
+ if ($billingRegionCode) {
487
+ $billingRegionId = Mage::getModel('directory/region')->loadByCode($billingRegionCode, $billingAddress->getCountryId());
488
+ $billingAddress->setRegionId($billingRegionId->getId());
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  }
490
 
 
 
491
  $shippingAddress = $quote->getShippingAddress();
492
  $shippingAddress->setFirstname($createdKlarnaOrder->getShippingAddress('given_name'));
493
  $shippingAddress->setLastname($createdKlarnaOrder->getShippingAddress('family_name'));
498
  $shippingAddress->setCountryId(strtoupper($createdKlarnaOrder->getShippingAddress('country')));
499
  $shippingAddress->setEmail($createdKlarnaOrder->getShippingAddress('email'));
500
  $shippingAddress->setTelephone($createdKlarnaOrder->getShippingAddress('phone'));
501
+ $shippingAddress->setSaveInAddressBook(0);
502
  if ($shippingRegionCode) {
503
  $shippingRegionId = Mage::getModel('directory/region')->loadByCode($shippingRegionCode, $shippingAddress->getCountryId());
504
  $shippingAddress->setRegionId($shippingRegionId->getId());
507
  if ($this->getConfigData('packstation_enabled')) {
508
  $shippingAddress->setSameAsBilling(0);
509
  } else {
510
+ if ($this->getConfigData('allow_separate_address')) {
511
+ if (!$this->_addressIsSame($billingAddress, $shippingAddress)) {
512
+ $shippingAddress->setSameAsBilling(0);
513
+ $shippingAddress->setSaveInAddressBook(1);
514
+ } else {
515
+ $shippingAddress->setSameAsBilling(1);
516
+ }
517
+ } else {
518
+ $shippingAddress->setSameAsBilling(1);
519
+ }
520
  }
 
521
 
522
  $quote->getBillingAddress()->setShouldIgnoreValidation(true);
523
  $quote->getShippingAddress()->setShouldIgnoreValidation(true);
537
  break;
538
  }
539
 
540
+ // Some variables are not saved, so we can not trust it was done some other time
541
+ // Before we create the order, we NEED to run this to collectTotals...
542
  $quote->setTotalsCollectedFlag(false);
543
  $quote->collectTotals();
544
+ //$quote->save();
545
 
546
  Mage::dispatchEvent('klarnacheckout_quote_before_create_order', array(
547
  'quote' => $quote,
572
  /** @var $order Mage_Sales_Model_Order */
573
  $order = $this->_loadOrderByKey($quote->getId());
574
 
575
+ if (!$order->getId()) {
576
+ Mage::throwException($this->_getHelper()->__('Order cannot be created, cart not valid') . ' ' . $quote->getId());
577
+ }
578
+
579
+ $this->_getHelper()->logDebugInfo('_createTheOrder created order with ID: ' . $order->getId());
580
+
581
  if ($pushf) {
582
  if ($order->getState()==Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
583
  $order->setState(
591
 
592
  $payment = $order->getPayment();
593
 
594
+ if (!$payment) {
595
+ $this->_getHelper()->logDebugInfo('_createTheOrder payment is null');
596
+ }
597
+
598
  if ($createdKlarnaOrder->getReference()) {
599
  $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_REFERENCE, $createdKlarnaOrder->getReference());
600
  } else if ($createdKlarnaOrder->getKlarnaReference()) {
625
  }
626
  $payment->save();
627
 
628
+ $this->_getHelper()->logDebugInfo('_createTheOrder payment saved with ID: ' . $payment->getId());
629
+
630
  if ($pushf) {
631
  // send new order email
632
  if ($order->getCanSendNewEmailFlag()) {
649
  try {
650
  $this->_getHelper()->dispatchMethodEvent($order, Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_RESERVED, $order->getTotalDue(), $this->getMethod());
651
 
652
+ // This will not help GA at least, since no layout block is defined in here, since it's a callback.
653
+ // But I will leave it, if someone else has used it
654
+ // Most modules listening to this event, expects there to be a front controller available, when there isn't one it crashes
655
+ // So I'm taking this out
656
+ //Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($order->getId())) );
657
 
658
+ $this->_getHelper()->logDebugInfo('_createTheOrder successfully created order with no: ' . $order->getIncrementId());
659
 
660
  } catch(Exception $e) {
661
  $this->_getHelper()->logKlarnaException($e);
665
 
666
  }
667
 
668
+ protected function _createValidateOrder($checkoutId, $quote, $createdKlarnaOrder, $logInfo)
669
  {
670
  if ($checkoutId) {
671
  $this->_getHelper()->logKlarnaApi('Call with checkout ID ' . $checkoutId);
680
  $order->setState(
681
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
682
  true,
683
+ $this->_getHelper()->__('Order created during %s, waiting for confirmation', $logInfo)
684
  );
685
  $order->save();
686
 
687
  return $order;
688
  }
689
 
690
+ public function createOrder($checkoutId = NULL, $force = true)
691
  {
692
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER);
693
  if ($checkoutId) {
721
 
722
  $this->_updateKlarnaOrderAddress($createdKlarnaOrder);
723
 
724
+ $klarnaStatus = $createdKlarnaOrder->getStatus();
725
+ $this->_getHelper()->logDebugInfo('createOrder status of Klarna Order: ' . $klarnaStatus);
726
+
727
+ if ($klarnaStatus != 'checkout_complete' && $klarnaStatus != 'created' && $klarnaStatus != 'AUTHORIZED') {
728
  $this->_getHelper()->logDebugInfo('createOrder status not complete');
729
+ // These statuses are only valid for Rest API, need to test for v2 API codes as well
730
+ if ($klarnaStatus == 'CANCELLED' || $klarnaStatus == 'EXPIRED' || $klarnaStatus == 'CLOSED') {
731
+ return array(
732
+ 'status' => 'fail',
733
+ 'message' => 'authorization not valid ' . $createdKlarnaOrder->getStatus()
734
+ );
735
+ } else {
736
+ return array(
737
+ 'status' => 'retry',
738
+ 'message' => 'status not complete ' . $createdKlarnaOrder->getStatus()
739
+ );
740
+ }
741
  }
742
 
743
  $updatef = false;
744
  $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
745
+ if ($orderId == 0 && !$force) {
746
+ $createOrderOnSuccess = $this->getConfigData('create_order_on_success');
747
+ if ($createOrderOnSuccess) {
748
+ sleep(20);
749
+ $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
750
+ if ($orderId == 0) {
751
+ $this->_getHelper()->logDebugInfo('createOrder push before success');
752
+ return array(
753
+ 'status' => 'retry',
754
+ 'message' => 'order not yet created'
755
+ );
756
+ }
757
  }
 
 
 
 
 
 
758
  }
759
+ if ($orderId>0) {
760
+ $this->_getHelper()->logDebugInfo('createOrder order already created, with ID ' . $orderId);
761
+ $updatef = true;
762
+ } else {
763
+ $this->_getHelper()->logDebugInfo('createOrder will create new order in Magento');
764
+ }
765
  $order = $this->_createTheOrder($quote, $createdKlarnaOrder, $updatef, true, $noticeTextArr);
766
 
767
  try {
792
  return false;
793
  }
794
 
795
+ if ($this->getConfigData('activate_ab_testing')) {
796
 
797
  if ($this->_getCustomerHelper()->isLoggedIn() && !$this->getConfigData('allow_when_logged_in')) {
798
  return false;
830
  return true;
831
  }
832
 
833
+ public function updateTaxAndShipping($quote, $data)
834
  {
835
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER);
836
 
837
  $newAddress = new Varien_Object($data['shipping_address']);
838
+ $this->_getHelper()->logDebugInfo('taxshippingupdate A' . $newAddress->getGivenName());
 
839
  $address = $quote->getShippingAddress();
840
  $address->setFirstname($newAddress->getGivenName());
841
  $address->setLastname($newAddress->getFamilyName());
868
  $quote->collectTotals();
869
  $quote->save();
870
  $this->setQuote($quote);
871
+ $this->_getHelper()->logDebugInfo('taxshippingupdate A' . $quote->getId());
872
 
873
  $res = $this->_api->prepareTaxAndShippingReply();
874
+ $this->_getHelper()->logDebugInfo('taxshippingupdate B' . $res);
875
  return $res;
876
  }
877
 
878
  public function checkNewsletter()
879
  {
880
  // set newsletter subscribe based on settings
881
+ $res = false;
882
+ $quote = $this->getQuote();
883
+ if ($quote->getKlarnaCheckoutNewsletter() == null) {
884
  $type = (int)$this->getConfigData('enable_newsletter');
885
  $checked = (bool)$this->getConfigData('newsletter_checked');
886
 
887
  if (($type == Vaimo_Klarna_Helper_Data::KLARNA_CHECKOUT_NEWSLETTER_SUBSCRIBE && $checked)
888
  || ($type == Vaimo_Klarna_Helper_Data::KLARNA_CHECKOUT_NEWSLETTER_DONT_SUBSCRIBE && !$checked)) {
889
+ $quote->setKlarnaCheckoutNewsletter(1);
890
  } else {
891
+ $quote->setKlarnaCheckoutNewsletter(0);
892
  }
893
+ $res = true;
894
  }
895
 
896
+ return $res;
897
  }
898
 
899
  protected function _getTransport()
app/code/community/Vaimo/Klarna/Model/Klarnacheckout/Abstract.php CHANGED
@@ -107,6 +107,36 @@ abstract class Vaimo_Klarna_Model_Klarnacheckout_Abstract extends Vaimo_Klarna_M
107
  Mage::getModel('newsletter/subscriber')->subscribe($email);
108
  }
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  protected function _prepareGuestCustomerQuote(Mage_Sales_Model_Quote $quote)
111
  {
112
  $billing = $quote->getBillingAddress();
@@ -161,13 +191,10 @@ abstract class Vaimo_Klarna_Model_Klarnacheckout_Abstract extends Vaimo_Klarna_M
161
  $customer->setFirstname($customerBilling->getFirstname());
162
  $customer->setLastname($customerBilling->getLastname());
163
  $customer->setEmail($customerBilling->getEmail());
164
-
165
  $password = $customer->generatePassword();
166
  $customer->setPassword($password);
167
  $customer->setConfirmation($password);
168
 
169
- // $customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
170
- // $customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
171
  $quote->setCustomer($customer)->setCustomerId(true);
172
  }
173
 
@@ -176,28 +203,42 @@ abstract class Vaimo_Klarna_Model_Klarnacheckout_Abstract extends Vaimo_Klarna_M
176
  $billing = $quote->getBillingAddress();
177
  $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
178
  $customer = $this->_loadCustomer($quote->getCustomerId());
 
 
179
 
180
  if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
181
  $customerBilling = $billing->exportCustomerAddress();
182
- $customer->addAddress($customerBilling);
183
- $billing->setCustomerAddress($customerBilling);
 
 
 
 
184
  }
185
 
186
  if ($shipping && !$shipping->getSameAsBilling() &&
187
  (!$shipping->getCustomerId() || $shipping->getSaveInAddressBook())) {
188
  $customerShipping = $shipping->exportCustomerAddress();
189
- $customer->addAddress($customerShipping);
190
- $shipping->setCustomerAddress($customerShipping);
 
 
 
 
191
  }
192
 
193
- if (isset($customerBilling) && !$customer->getDefaultBilling()) {
194
- $customerBilling->setIsDefaultBilling(true);
 
 
195
  }
196
 
197
- if ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
198
- $customerShipping->setIsDefaultShipping(true);
199
- } else if (isset($customerBilling) && !$customer->getDefaultShipping()) {
200
- $customerBilling->setIsDefaultShipping(true);
 
 
201
  }
202
 
203
  $quote->setCustomer($customer);
107
  Mage::getModel('newsletter/subscriber')->subscribe($email);
108
  }
109
 
110
+ protected function _addressIsSame($billingAddress, $shippingAddress)
111
+ {
112
+ if ($billingAddress->getFirstname() != $shippingAddress->getFirstname() ||
113
+ $billingAddress->getLastname() != $shippingAddress->getLastname() ||
114
+ // $billingAddress->getCareOf() != $shippingAddress->getCareOf() ||
115
+ $billingAddress->getStreet() != $shippingAddress->getStreet() ||
116
+ $billingAddress->getPostcode() != $shippingAddress->getPostcode() ||
117
+ $billingAddress->getCity() != $shippingAddress->getCity() ||
118
+ $billingAddress->getCountryId() != $shippingAddress->getCountryId() ||
119
+ // $billingAddress->getEmail() != $shippingAddress->getEmail() ||
120
+ $billingAddress->getTelephone() != $shippingAddress->getTelephone()
121
+ ) {
122
+ return false;
123
+ }
124
+ return true;
125
+ }
126
+
127
+ protected function _customerHasAddress($customer, $address)
128
+ {
129
+ $res = false;
130
+ $collection = $customer->getAddressesCollection();
131
+ foreach ($collection as $customerAddress) {
132
+ if ($this->_addressIsSame($address, $customerAddress)) {
133
+ $res = true;
134
+ break;
135
+ }
136
+ }
137
+ return $res;
138
+ }
139
+
140
  protected function _prepareGuestCustomerQuote(Mage_Sales_Model_Quote $quote)
141
  {
142
  $billing = $quote->getBillingAddress();
191
  $customer->setFirstname($customerBilling->getFirstname());
192
  $customer->setLastname($customerBilling->getLastname());
193
  $customer->setEmail($customerBilling->getEmail());
 
194
  $password = $customer->generatePassword();
195
  $customer->setPassword($password);
196
  $customer->setConfirmation($password);
197
 
 
 
198
  $quote->setCustomer($customer)->setCustomerId(true);
199
  }
200
 
203
  $billing = $quote->getBillingAddress();
204
  $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
205
  $customer = $this->_loadCustomer($quote->getCustomerId());
206
+ $skipDefaultBilling = false;
207
+ $skipDefaultShipping = false;
208
 
209
  if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
210
  $customerBilling = $billing->exportCustomerAddress();
211
+ if (!$this->_customerHasAddress($customer, $customerBilling)) {
212
+ $customer->addAddress($customerBilling);
213
+ $billing->setCustomerAddress($customerBilling);
214
+ } else {
215
+ $skipDefaultBilling = true;
216
+ }
217
  }
218
 
219
  if ($shipping && !$shipping->getSameAsBilling() &&
220
  (!$shipping->getCustomerId() || $shipping->getSaveInAddressBook())) {
221
  $customerShipping = $shipping->exportCustomerAddress();
222
+ if (!$this->_customerHasAddress($customer, $customerShipping)) {
223
+ $customer->addAddress($customerShipping);
224
+ $shipping->setCustomerAddress($customerShipping);
225
+ } else {
226
+ $skipDefaultShipping = true;
227
+ }
228
  }
229
 
230
+ if (!$skipDefaultBilling) {
231
+ if (isset($customerBilling) && !$customer->getDefaultBilling()) {
232
+ $customerBilling->setIsDefaultBilling(true);
233
+ }
234
  }
235
 
236
+ if (!$skipDefaultShipping) {
237
+ if ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
238
+ $customerShipping->setIsDefaultShipping(true);
239
+ } else if (isset($customerBilling) && !$customer->getDefaultShipping()) {
240
+ $customerBilling->setIsDefaultShipping(true);
241
+ }
242
  }
243
 
244
  $quote->setCustomer($customer);
app/code/community/Vaimo/Klarna/Model/Observer.php CHANGED
@@ -240,4 +240,11 @@ class Vaimo_Klarna_Model_Observer extends Mage_Core_Model_Abstract
240
  }
241
  }
242
  }
 
 
 
 
 
 
 
243
  }
240
  }
241
  }
242
  }
243
+
244
+ public function updateQuoteMergeAfter($observer)
245
+ {
246
+ $quote = $observer->getEvent()->getQuote();
247
+ $source = $observer->getEvent()->getSource();
248
+ $quote->setKlarnaCheckoutId($source->getKlarnaCheckoutId());
249
+ }
250
  }
app/code/community/Vaimo/Klarna/Model/Payment/Abstract.php CHANGED
@@ -25,6 +25,8 @@
25
 
26
  class Vaimo_Klarna_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract
27
  {
 
 
28
  protected $_isGateway = false;
29
  protected $_canAuthorize = true;
30
  protected $_canVoid = true;
@@ -302,6 +304,18 @@ class Vaimo_Klarna_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abst
302
  return $this;
303
  }
304
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  /**
306
  * Authorize the purchase
307
  *
@@ -363,7 +377,16 @@ class Vaimo_Klarna_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abst
363
  $payment->setTransactionId($transactionId)
364
  ->setIsTransactionClosed(0);
365
  } catch (Mage_Core_Exception $e) {
366
- Mage::throwException($this->_getHelper()->__('Technical problem occurred while using %s payment method. Please try again later.', $klarna->getMethodTitleWithFee()));
 
 
 
 
 
 
 
 
 
367
  }
368
  return $this;
369
  }
25
 
26
  class Vaimo_Klarna_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract
27
  {
28
+ const EXTENDED_ERROR_MESSAGE = 'show_extended_error_message';
29
+
30
  protected $_isGateway = false;
31
  protected $_canAuthorize = true;
32
  protected $_canVoid = true;
304
  return $this;
305
  }
306
 
307
+ /**
308
+ * Check if exception message can be shown to customer
309
+ *
310
+ * @param Exception $e
311
+ * @return boolean
312
+ */
313
+ protected function _canShowExceptionMessage(Exception $e)
314
+ {
315
+ return $this->_getConfigData(self::EXTENDED_ERROR_MESSAGE)
316
+ && $e->getCode() && $e->getMessage() && !$this->_getHelper()->isXmlRpcException($e);
317
+ }
318
+
319
  /**
320
  * Authorize the purchase
321
  *
377
  $payment->setTransactionId($transactionId)
378
  ->setIsTransactionClosed(0);
379
  } catch (Mage_Core_Exception $e) {
380
+ if ($this->_canShowExceptionMessage($e)) {
381
+ Mage::throwException($e->getMessage());
382
+ } else {
383
+ Mage::throwException(
384
+ $this->_getHelper()->__(
385
+ 'Technical problem occurred while using %s payment method. Please try again later.',
386
+ $klarna->getMethodTitleWithFee()
387
+ )
388
+ );
389
+ }
390
  }
391
  return $this;
392
  }
app/code/community/Vaimo/Klarna/Model/Payment/Checkout.php CHANGED
@@ -44,21 +44,6 @@ class Vaimo_Klarna_Model_Payment_Checkout extends Vaimo_Klarna_Model_Payment_Abs
44
  {
45
  $available = $this->_isAvailableParent($quote);
46
  if (!$available) return false;
47
- /*
48
- if (parent::isAvailable($quote) == false) return false;
49
- try {
50
- $klarna = $this->_getKlarnaModel();
51
- $klarna->setQuote($quote, $this->_code);
52
-
53
- $allowedMin = (int)$klarna->getConfigData('minimum_order_cost');
54
- $grandTotal = $quote->getGrandTotal();
55
-
56
- if ($this->_roundPrice($grandTotal) < $allowedMin) return false;
57
- } catch (Mage_Core_Exception $e) {
58
- $this->_getHelper()->logKlarnaException($e);
59
- return false;
60
- }
61
- */
62
  return true;
63
  }
64
 
44
  {
45
  $available = $this->_isAvailableParent($quote);
46
  if (!$available) return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  return true;
48
  }
49
 
app/code/community/Vaimo/Klarna/Model/Transport/Abstract.php CHANGED
@@ -287,18 +287,20 @@ abstract class Vaimo_Klarna_Model_Transport_Abstract extends Varien_Object
287
  */
288
  protected function _updateCountry()
289
  {
290
- if ($this->_shippingAddress && $this->_shippingAddress->getCountry()) {
291
- $this->_countryCode = strtoupper($this->_shippingAddress->getCountry());
292
- } elseif ($this->_billingAddress && $this->_billingAddress->getCountry()) {
293
- $this->_countryCode = strtoupper($this->_billingAddress->getCountry());
294
- }
295
- if ($this->_countryCode!=$this->_getDefaultCountry()) {
296
- $this->_updateNonDefaultCountryLanguage();
297
- } else {
298
- // It's only necessary to call this if updateNonDefaultCountryLanguage
299
- // has been called. A minor speed improvement possible here, as
300
- // _updateCountry() is called quite a number of times.
301
- $this->_setDefaultLanguageCode();
 
 
302
  }
303
  }
304
 
287
  */
288
  protected function _updateCountry()
289
  {
290
+ if ($this->getMethod()!=Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT) {
291
+ if ($this->_shippingAddress && $this->_shippingAddress->getCountry()) {
292
+ $this->_countryCode = strtoupper($this->_shippingAddress->getCountry());
293
+ } elseif ($this->_billingAddress && $this->_billingAddress->getCountry()) {
294
+ $this->_countryCode = strtoupper($this->_billingAddress->getCountry());
295
+ }
296
+ if ($this->_countryCode!=$this->_getDefaultCountry()) {
297
+ $this->_updateNonDefaultCountryLanguage();
298
+ } else {
299
+ // It's only necessary to call this if updateNonDefaultCountryLanguage
300
+ // has been called. A minor speed improvement possible here, as
301
+ // _updateCountry() is called quite a number of times.
302
+ $this->_setDefaultLanguageCode();
303
+ }
304
  }
305
  }
306
 
app/code/community/Vaimo/Klarna/controllers/Checkout/KlarnaController.php CHANGED
@@ -48,6 +48,11 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
48
  return Mage::getSingleton('checkout/type_onepage');
49
  }
50
 
 
 
 
 
 
51
  /**
52
  * Get current active quote instance
53
  *
@@ -58,23 +63,6 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
58
  return $this->_getCart()->getQuote();
59
  }
60
 
61
- protected function _checkPaymentMethod()
62
- {
63
- // set payment method
64
- $quote = $this->_getQuote();
65
-
66
- if ($quote->getPayment()->getMethod() != Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT) {
67
- if ($quote->isVirtual()) {
68
- $quote->getBillingAddress()->setPaymentMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
69
- } else {
70
- $quote->getShippingAddress()->setPaymentMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
71
- }
72
- $quote->getPayment()->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
73
- }
74
-
75
- return $this;
76
- }
77
-
78
  /**
79
  * This function checks valid shippingMethod
80
  *
@@ -89,7 +77,11 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
89
  $quote = $this->_getQuote();
90
  $klarna = Mage::getModel('klarna/klarnacheckout');
91
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
92
- $klarna->checkShippingMethod();
 
 
 
 
93
  }
94
 
95
  protected function _checkNewsletter()
@@ -97,18 +89,25 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
97
  $quote = $this->_getQuote();
98
  $klarna = Mage::getModel('klarna/klarnacheckout');
99
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
100
- $klarna->checkNewsletter();
101
- return $this;
102
  }
103
 
104
  public function othermethodAction()
105
  {
 
 
 
 
 
 
106
  $quote = $this->_getQuote();
107
- // @todo find active method, not just Invoice automatically
108
- $quote->getPayment()->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_INVOICE);
109
  $quote->setTotalsCollectedFlag(false);
110
  $quote->collectTotals();
111
  $quote->save();
 
 
112
  $this->_getSession()->setKlarnaUseOtherMethods(true);
113
  if (Mage::helper('klarna')->isOneStepCheckout()) {
114
  $this->_redirect('onestepcheckout');
@@ -137,15 +136,60 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
137
 
138
  protected function _redirectToCart($store = null)
139
  {
140
- $path = Mage::getStoreConfig('payment/vaimo_klarna_checkout/cart_redirect', $store);
141
- if (is_null($path))
142
- $path = 'checkout/cart';
143
  $this->_redirect($path);
144
  }
145
 
146
  public function indexAction()
147
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  $quote = $this->_getQuote();
 
 
 
 
 
 
 
149
  $klarna = Mage::getModel('klarna/klarnacheckout');
150
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
151
  if (!$klarna->getKlarnaCheckoutEnabled()) {
@@ -157,11 +201,6 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
157
  return;
158
  }
159
 
160
- if (!$quote->hasItems() || $quote->getHasError()) {
161
- $this->_redirectToCart($quote->getStoreId());
162
- return;
163
- }
164
-
165
  if (!$quote->validateMinimumAmount()) {
166
  $error = Mage::getStoreConfig('sales/minimum_order/error_message') ?
167
  Mage::getStoreConfig('sales/minimum_order/error_message') :
@@ -172,13 +211,21 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
172
  return;
173
  }
174
 
175
- $this->_checkPaymentMethod();
176
- $this->_checkShippingMethod();
177
- $this->_checkNewsletter();
178
-
179
- $quote->collectTotals();
180
- $quote->save();
 
 
 
 
181
 
 
 
 
 
182
  $this->loadLayout();
183
  $this->_initLayoutMessages('customer/session');
184
  $this->getLayout()->getBlock('head')->setTitle($this->__('Klarna Checkout'));
@@ -259,14 +306,19 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
259
 
260
  //$quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
261
  $quote = Mage::helper('klarna')->findQuote($checkoutId);
262
- $klarna = Mage::getModel('klarna/klarnacheckout');
263
- $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
264
 
265
- $post_body = file_get_contents('php://input');
266
- $data = json_decode($post_body, true);
267
- Mage::helper('klarna')->logDebugInfo('taxshippingupdate data', $data);
 
 
 
 
268
 
269
- $result = $klarna->updateTaxAndShipping($data);
 
 
 
270
 
271
  Mage::helper('klarna')->logDebugInfo('taxshippingupdate response', $result);
272
  $this->getResponse()->setBody(Zend_Json::encode($result));
@@ -281,13 +333,18 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
281
  $checkoutId = $this->getRequest()->getParam('klarna_order');
282
  //$quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
283
  $quote = Mage::helper('klarna')->findQuote($checkoutId);
284
- $payment = $quote->getPayment();
285
- $errors = $payment->getAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_VALIDATE_ERRORS);
286
- Mage::helper('klarna')->logKlarnaApi('failedAction errors: ' . $errors);
287
- if ($errors) {
288
- $payment->unsAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_VALIDATE_ERRORS);
289
- $payment->save();
290
- $this->_getSession()->addError($errors);
 
 
 
 
 
291
  }
292
 
293
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
@@ -295,7 +352,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
295
  $this->_redirectToCart($quote->getStoreId());
296
  return;
297
  }
298
-
299
  protected function _initPushOrValidate($checkoutId)
300
  {
301
  $quote = Mage::helper('klarna')->findQuote($checkoutId);
@@ -307,7 +364,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
307
  }
308
  return $quote;
309
  }
310
-
311
  protected function _initPushQueue($checkoutId)
312
  {
313
  $pushQueue = Mage::getModel('klarna/pushqueue');
@@ -327,7 +384,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
327
 
328
  $checkoutId = $this->getRequest()->getParam('klarna_order');
329
  $quote = $this->_initPushOrValidate($checkoutId);
330
-
331
  Mage::helper('klarna')->logKlarnaApi('validateAction checkout id: ' . $checkoutId);
332
  if (!$quote) {
333
  Mage::helper('klarna')->logKlarnaApi('validateAction checkout quote not found!');
@@ -350,8 +407,9 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
350
 
351
  if ($checkoutId) {
352
  try {
353
- // validateQuote returns true if successful, a string if failed
354
  $createOrderOnValidate = $klarna->getConfigData('create_order_on_validation');
 
 
355
  $result = $klarna->validateQuote($checkoutId, $createOrderOnValidate, $createdKlarnaOrder);
356
 
357
  Mage::helper('klarna')->logKlarnaApi('validateAction result = ' . $result);
@@ -367,10 +425,18 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
367
  $this->getResponse()
368
  ->setHttpResponseCode(303)
369
  ->setHeader('Location', Mage::getUrl('checkout/klarna/validateFailed', array('klarna_order' => $checkoutId)));
 
370
  }
371
  $this->getResponse()
372
  ->setHttpResponseCode(200);
373
  } catch (Exception $e) {
 
 
 
 
 
 
 
374
  Mage::helper('klarna')->logKlarnaException($e);
375
  $this->getResponse()
376
  ->setHttpResponseCode(303)
@@ -385,6 +451,11 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
385
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
386
 
387
  $checkoutId = $this->getRequest()->getParam('klarna_order');
 
 
 
 
 
388
  $quote = $this->_initPushOrValidate($checkoutId);
389
  $pushQueue = $this->_initPushQueue($checkoutId);
390
 
@@ -398,7 +469,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
398
  /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
399
  $klarna = Mage::getModel('klarna/klarnacheckout');
400
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
401
-
402
  if (substr($checkoutId, -1, 1) == '/') {
403
  $checkoutId = substr($checkoutId, 0, strlen($checkoutId) - 1);
404
  }
@@ -406,7 +477,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
406
  if ($checkoutId) {
407
  try {
408
  // createOrder returns the order if successful, otherwise an error string
409
- $result = $klarna->createOrder($checkoutId);
410
 
411
  if (is_array($result)) {
412
  if ($result['status']=='success') {
@@ -444,56 +515,116 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
444
  $checkoutId = $this->_getSession()->getKlarnaCheckoutPrevId();
445
  if ($checkoutId) {
446
  $revisitedf = true;
447
- Mage::helper('klarna')->logKlarnaApi('successAction revisited, checkout id: ' . $checkoutId);
448
  }
449
  }
 
 
 
 
 
 
 
 
 
450
  //$quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
451
  $quote = Mage::helper('klarna')->findQuote($checkoutId);
 
 
 
452
  $klarna = Mage::getModel('klarna/klarnacheckout');
453
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
454
- if (!$revisitedf) {
455
- Mage::helper('klarna')->logKlarnaApi('successAction checkout id: ' . $checkoutId);
456
 
457
- if (!$checkoutId) {
458
- Mage::helper('klarna')->logKlarnaApi('successAction checkout id is empty, so we do nothing');
459
- //$this->_redirect('');
460
- //return;
461
- exit(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
  }
 
 
 
 
 
 
 
463
  }
 
464
 
465
- $status = $klarna->getCheckoutStatus($checkoutId);
466
- $canDisplaySuccess = $status == 'checkout_complete' || $status == 'created';
467
-
468
  if (!$canDisplaySuccess) {
469
  Mage::helper('klarna')->logKlarnaApi('successAction ERROR: order not created: ' . $status);
470
- $this->_redirect('');
471
- return;
 
 
472
  } else {
473
  Mage::helper('klarna')->logKlarnaApi('successAction displaying success');
474
  }
475
 
476
- // close the quote if push hasn't closed it already
477
- //$quote = $this->_getQuote(); // Should be loaded already...
478
  if (!$revisitedf) {
 
479
  if ($quote->getId() && $quote->getIsActive()) {
480
- Mage::helper('klarna')->logKlarnaApi('successAction closing quote');
481
- /** @var Mage_Core_Model_Resource $resource */
482
- $resource = Mage::getSingleton('core/resource');
483
- $read = $resource->getConnection('core_read');
484
- $read->update($resource->getTableName('sales/quote'), array('is_active' => 0), 'entity_id = ' . $quote->getId());
 
 
 
 
 
 
 
485
  }
486
 
487
- $this->_getSession()->setLastQuoteId($quote->getId());
488
  $this->_getSession()->clearHelperData();
489
  $this->_getSession()->clear();
490
- $this->_getCart()->unsetData('quote');
 
 
 
 
 
 
 
 
 
491
  }
492
 
493
  $this->loadLayout();
494
  $this->_initLayoutMessages('customer/session');
495
  $this->getLayout()->getBlock('head')->setTitle($this->__('Klarna Checkout'));
496
 
 
 
 
 
497
  // This is KCO specific for the current API... This must find another solution
498
  if ($block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('google_analytics')) {
499
  $block->setKlarnaCheckoutOrder($klarna->getActualKlarnaOrder());
@@ -501,13 +632,12 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
501
 
502
  $this->renderLayout();
503
 
504
- $this->_getSession()->setKlarnaCheckoutId(''); // This needs to be cleared, to be able to create new orders
505
- $this->_getSession()->setKlarnaCheckoutPrevId($checkoutId);
506
- $this->_getSession()->setKlarnaUseOtherMethods(false);
507
  Mage::helper('klarna')->logKlarnaApi('successAction displayed success');
508
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
509
  } catch (Exception $e) {
 
510
  Mage::helper('klarna')->logKlarnaException($e);
 
511
  }
512
  }
513
 
@@ -679,19 +809,20 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
679
  }
680
  }
681
  $cart = $this->_getCart();
682
- if (! $cart->getCustomerSession()->getCustomer()->getId() && $cart->getQuote()->getCustomerId()) {
683
- $cart->getQuote()->setCustomerId(null);
 
684
  }
685
  $cartData = $cart->suggestItemsQty($cartData);
686
  $cart->updateItems($cartData);
687
 
688
  // Addon to check qty vs stock to support ajax response
689
- $items = $cart->getQuote()->getItemsCollection();
690
 
691
  foreach ($items as $item) {
692
  $item->checkData();
693
  }
694
- $errors = $cart->getQuote()->getErrors();
695
  $messages = array();
696
 
697
  foreach ($errors as $error) {
@@ -702,12 +833,14 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
702
  Mage::throwException(implode(', ', $messages));
703
  }
704
 
 
 
705
  $this->_checkShippingMethod();
706
  $cart->save();
707
 
708
  // Addon for ajax to redirect to cart
709
  if ($this->_getCart()->getSummaryQty() <= 0) {
710
- $result['redirect_url'] = Mage::getUrl('checkout/cart');
711
  }
712
  }
713
  $this->_getSession()->setCartWasUpdated(true);
@@ -877,4 +1010,4 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
877
  $quote->collectTotals()->save();
878
  $this->getResponse()->setBody(Zend_Json::encode($result));
879
  }
880
- }
48
  return Mage::getSingleton('checkout/type_onepage');
49
  }
50
 
51
+ protected function _getCoreSession()
52
+ {
53
+ return Mage::getSingleton('core/session');
54
+ }
55
+
56
  /**
57
  * Get current active quote instance
58
  *
63
  return $this->_getCart()->getQuote();
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  /**
67
  * This function checks valid shippingMethod
68
  *
77
  $quote = $this->_getQuote();
78
  $klarna = Mage::getModel('klarna/klarnacheckout');
79
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
80
+ $res = $klarna->checkShippingMethod();
81
+ if ($res!==false) {
82
+ $res = true;
83
+ }
84
+ return $res;
85
  }
86
 
87
  protected function _checkNewsletter()
89
  $quote = $this->_getQuote();
90
  $klarna = Mage::getModel('klarna/klarnacheckout');
91
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
92
+ $res = $klarna->checkNewsletter();
93
+ return $res;
94
  }
95
 
96
  public function othermethodAction()
97
  {
98
+
99
+ /* Method set to false so when customer gets to standard checkout,
100
+ * the first payment method is listed. Otherwise klarna_checkout is
101
+ * carried through, makes the return button selected and causes totals
102
+ * not to display until customer manually selects required method
103
+ */
104
  $quote = $this->_getQuote();
105
+ $quote->getPayment()->setMethod(false);
 
106
  $quote->setTotalsCollectedFlag(false);
107
  $quote->collectTotals();
108
  $quote->save();
109
+ /* end of clear method code */
110
+
111
  $this->_getSession()->setKlarnaUseOtherMethods(true);
112
  if (Mage::helper('klarna')->isOneStepCheckout()) {
113
  $this->_redirect('onestepcheckout');
136
 
137
  protected function _redirectToCart($store = null)
138
  {
139
+ $path = Mage::helper('klarna')->getKCORedirectToCartUrl($store);
 
 
140
  $this->_redirect($path);
141
  }
142
 
143
  public function indexAction()
144
  {
145
+ if (!$this->_getCart()->hasQuote()) {
146
+ // If recreate_cart_on_failed_validate is set to no, this parameter is not included
147
+ $id = $this->getRequest()->getParam('quote_id');
148
+ if ($id) {
149
+ $order = Mage::getModel('sales/order')->load($id, 'quote_id');
150
+ if ($order && $order->getId()) {
151
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
152
+ $comment = $this->__('Order created by Validate, but was abandoned');
153
+ Mage::helper('klarna')->logKlarnaApi($comment . ' (' . $order->getIncrementId() . ')');
154
+
155
+ $order->addStatusHistoryComment($comment);
156
+ $order->cancel();
157
+ $order->save();
158
+
159
+ $quoteNew = Mage::getModel('sales/quote');
160
+ $quoteOld = Mage::getModel('sales/quote')->load($id);
161
+
162
+ $quoteNew->setStoreId($quoteOld->getStoreId())
163
+ ->merge($quoteOld)
164
+ ->setKlarnaCheckoutId(NULL)
165
+ ->collectTotals()
166
+ ->save();
167
+ $this->_getSession()->replaceQuote($quoteNew);
168
+
169
+ $comment = $this->__('Canceled order and created new cart from original cart');
170
+ Mage::helper('klarna')->logKlarnaApi($comment . ' (' . $quoteNew->getId() . ')');
171
+
172
+ $order->addStatusHistoryComment($comment);
173
+ $order->save();
174
+
175
+ $error = $this->__('Payment cancelled or some error occured. Please try again.');
176
+ $this->_getSession()->addError($error);
177
+
178
+ $this->_redirectToCart($quoteNew->getStoreId());
179
+ return;
180
+ }
181
+ }
182
+ }
183
+ }
184
+
185
  $quote = $this->_getQuote();
186
+
187
+ if (!$quote->getId() || !$quote->hasItems() || $quote->getHasError()) {
188
+ $this->_redirectToCart($quote->getStoreId());
189
+ return;
190
+ }
191
+
192
+ $quote->load($quote->getId());
193
  $klarna = Mage::getModel('klarna/klarnacheckout');
194
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
195
  if (!$klarna->getKlarnaCheckoutEnabled()) {
201
  return;
202
  }
203
 
 
 
 
 
 
204
  if (!$quote->validateMinimumAmount()) {
205
  $error = Mage::getStoreConfig('sales/minimum_order/error_message') ?
206
  Mage::getStoreConfig('sales/minimum_order/error_message') :
211
  return;
212
  }
213
 
214
+ $updateQuote = false;
215
+ if (Mage::helper('klarna')->checkPaymentMethod($quote)) {
216
+ $updateQuote = true;
217
+ }
218
+ if ($this->_checkShippingMethod()) {
219
+ $updateQuote = true;
220
+ }
221
+ if ($this->_checkNewsletter()) {
222
+ $updateQuote = true;
223
+ }
224
 
225
+ if ($updateQuote) {
226
+ $quote->collectTotals();
227
+ $quote->save();
228
+ }
229
  $this->loadLayout();
230
  $this->_initLayoutMessages('customer/session');
231
  $this->getLayout()->getBlock('head')->setTitle($this->__('Klarna Checkout'));
306
 
307
  //$quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
308
  $quote = Mage::helper('klarna')->findQuote($checkoutId);
 
 
309
 
310
+ if ($quote && $quote->getId()) {
311
+ $klarna = Mage::getModel('klarna/klarnacheckout');
312
+ $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
313
+
314
+ $post_body = file_get_contents('php://input');
315
+ $data = json_decode($post_body, true);
316
+ Mage::helper('klarna')->logDebugInfo('taxshippingupdate data', $data);
317
 
318
+ $result = $klarna->updateTaxAndShipping($quote, $data);
319
+ } else {
320
+ $result = '';
321
+ }
322
 
323
  Mage::helper('klarna')->logDebugInfo('taxshippingupdate response', $result);
324
  $this->getResponse()->setBody(Zend_Json::encode($result));
333
  $checkoutId = $this->getRequest()->getParam('klarna_order');
334
  //$quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
335
  $quote = Mage::helper('klarna')->findQuote($checkoutId);
336
+ if ($quote && $quote->getId()) {
337
+ $payment = $quote->getPayment();
338
+ $errors = $payment->getAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_VALIDATE_ERRORS);
339
+ Mage::helper('klarna')->logKlarnaApi('failedAction errors: ' . $errors);
340
+ if ($errors) {
341
+ $payment->unsAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_VALIDATE_ERRORS);
342
+ $payment->save();
343
+ $this->_getSession()->addError($errors);
344
+ }
345
+ } else {
346
+ $error = $this->__('Cart not available. Please try again');
347
+ $this->_getSession()->addError($error);
348
  }
349
 
350
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
352
  $this->_redirectToCart($quote->getStoreId());
353
  return;
354
  }
355
+
356
  protected function _initPushOrValidate($checkoutId)
357
  {
358
  $quote = Mage::helper('klarna')->findQuote($checkoutId);
364
  }
365
  return $quote;
366
  }
367
+
368
  protected function _initPushQueue($checkoutId)
369
  {
370
  $pushQueue = Mage::getModel('klarna/pushqueue');
384
 
385
  $checkoutId = $this->getRequest()->getParam('klarna_order');
386
  $quote = $this->_initPushOrValidate($checkoutId);
387
+
388
  Mage::helper('klarna')->logKlarnaApi('validateAction checkout id: ' . $checkoutId);
389
  if (!$quote) {
390
  Mage::helper('klarna')->logKlarnaApi('validateAction checkout quote not found!');
407
 
408
  if ($checkoutId) {
409
  try {
 
410
  $createOrderOnValidate = $klarna->getConfigData('create_order_on_validation');
411
+
412
+ // validateQuote returns true if successful, a string if failed
413
  $result = $klarna->validateQuote($checkoutId, $createOrderOnValidate, $createdKlarnaOrder);
414
 
415
  Mage::helper('klarna')->logKlarnaApi('validateAction result = ' . $result);
425
  $this->getResponse()
426
  ->setHttpResponseCode(303)
427
  ->setHeader('Location', Mage::getUrl('checkout/klarna/validateFailed', array('klarna_order' => $checkoutId)));
428
+ return;
429
  }
430
  $this->getResponse()
431
  ->setHttpResponseCode(200);
432
  } catch (Exception $e) {
433
+ if ($quote && $quote->getId()) {
434
+ $payment = $quote->getPayment();
435
+ if ($payment && $payment->getId()) {
436
+ $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_VALIDATE_ERRORS, $e->getMessage());
437
+ $payment->save();
438
+ }
439
+ }
440
  Mage::helper('klarna')->logKlarnaException($e);
441
  $this->getResponse()
442
  ->setHttpResponseCode(303)
451
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
452
 
453
  $checkoutId = $this->getRequest()->getParam('klarna_order');
454
+ if (!$checkoutId) {
455
+ Mage::helper('klarna')->logKlarnaApi('pushAction klarna_order missing!');
456
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
457
+ return;
458
+ }
459
  $quote = $this->_initPushOrValidate($checkoutId);
460
  $pushQueue = $this->_initPushQueue($checkoutId);
461
 
469
  /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
470
  $klarna = Mage::getModel('klarna/klarnacheckout');
471
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
472
+
473
  if (substr($checkoutId, -1, 1) == '/') {
474
  $checkoutId = substr($checkoutId, 0, strlen($checkoutId) - 1);
475
  }
477
  if ($checkoutId) {
478
  try {
479
  // createOrder returns the order if successful, otherwise an error string
480
+ $result = $klarna->createOrder($checkoutId, false);
481
 
482
  if (is_array($result)) {
483
  if ($result['status']=='success') {
515
  $checkoutId = $this->_getSession()->getKlarnaCheckoutPrevId();
516
  if ($checkoutId) {
517
  $revisitedf = true;
 
518
  }
519
  }
520
+ if (!$checkoutId) {
521
+ Mage::helper('klarna')->logKlarnaApi('successAction checkout id is empty, so we do nothing');
522
+ exit(1);
523
+ }
524
+ if (!$revisitedf) {
525
+ Mage::helper('klarna')->logKlarnaApi('successAction checkout id: ' . $checkoutId);
526
+ } else {
527
+ Mage::helper('klarna')->logKlarnaApi('successAction revisited, checkout id: ' . $checkoutId);
528
+ }
529
  //$quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
530
  $quote = Mage::helper('klarna')->findQuote($checkoutId);
531
+ if (!$quote || !$quote->getId()) {
532
+ Mage::throwException($this->__('Cart not available. Please try again') . ': ' . $checkoutId . ' revisitedf = ' . $revisitedf);
533
+ }
534
  $klarna = Mage::getModel('klarna/klarnacheckout');
535
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
 
 
536
 
537
+ } catch (Exception $e) {
538
+ // Will show empty success page... however unlikely it is to get here, it's not very good
539
+ Mage::helper('klarna')->logKlarnaException($e);
540
+ return $this;
541
+ }
542
+
543
+ $canDisplaySuccess = null;
544
+ // Sometimes there is a timeout or incorrect status is given by the call to Klarna,
545
+ // especially when running against test server
546
+ // Now we try 5 times at least, before showing blank page...
547
+ $useCurrentOrderSession = true;
548
+ for ($cnt = 0; $cnt < 5; $cnt++) {
549
+ try {
550
+ $status = $klarna->getCheckoutStatus($checkoutId, $useCurrentOrderSession);
551
+ $canDisplaySuccess =
552
+ $status == 'checkout_complete' ||
553
+ $status == 'created' ||
554
+ $status == 'AUTHORIZED';
555
+ if (!$canDisplaySuccess) {
556
+ Mage::helper('klarna')->logDebugInfo(
557
+ 'successAction got incorrect status: ' . $status . ' ' .
558
+ 'for klarna order id: ' . $checkoutId . '. ' .
559
+ 'Retrying (' . ($cnt + 1) . ' / 5)'
560
+ );
561
+ $useCurrentOrderSession = false; // Reinitiate communication
562
+ } else {
563
+ break;
564
  }
565
+ } catch (Exception $e) {
566
+ Mage::helper('klarna')->logKlarnaException($e);
567
+ Mage::helper('klarna')->logDebugInfo(
568
+ 'successAction caused an exception: ' . $e->getMessage() .
569
+ 'Retrying (' . ($cnt + 1) . ' / 5)'
570
+ );
571
+ $useCurrentOrderSession = false; // Reinitiate communication
572
  }
573
+ }
574
 
575
+ try {
 
 
576
  if (!$canDisplaySuccess) {
577
  Mage::helper('klarna')->logKlarnaApi('successAction ERROR: order not created: ' . $status);
578
+ $error = $this->__('Checkout incomplete, please try again.');
579
+ $this->_getSession()->addError($error);
580
+ $this->_redirectToCart($quote->getStoreId());
581
+ return $this;
582
  } else {
583
  Mage::helper('klarna')->logKlarnaApi('successAction displaying success');
584
  }
585
 
586
+ $createOrderOnSuccess = $klarna->getConfigData('create_order_on_success');
587
+
588
  if (!$revisitedf) {
589
+
590
  if ($quote->getId() && $quote->getIsActive()) {
591
+
592
+ // successQuote returns true if successful, a string if failed
593
+ $createdKlarnaOrder = new Varien_Object($klarna->getActualKlarnaOrderArray());
594
+ $result = $klarna->successQuote($checkoutId, $createOrderOnSuccess, $createdKlarnaOrder);
595
+ Mage::helper('klarna')->logKlarnaApi('successQuote result = ' . $result);
596
+
597
+ $order = Mage::getModel('sales/order')->load($quote->getId(), 'quote_id');
598
+
599
+ if ($order && $order->getId()) {
600
+ Mage::helper('klarna')->logDebugInfo('successQuote successfully created order with no: ' . $order->getIncrementId());
601
+ }
602
+
603
  }
604
 
605
+ $this->_getCart()->unsetData('quote');
606
  $this->_getSession()->clearHelperData();
607
  $this->_getSession()->clear();
608
+ $this->_getSession()->setLastQuoteId($quote->getId());
609
+ $this->_getSession()->setLastSuccessQuoteId($quote->getId());
610
+ $order = Mage::getModel('sales/order')->load($quote->getId(), 'quote_id');
611
+ if ($order && $order->getId()) {
612
+ $this->_getSession()->setLastOrderId($order->getId());
613
+ $this->_getSession()->setLastRealOrderId($order->getIncrementId());
614
+ }
615
+ $this->_getSession()->setKlarnaCheckoutPrevId($checkoutId);
616
+ $this->_getSession()->setKlarnaCheckoutId(''); // This needs to be cleared, to be able to create new orders
617
+ $this->_getSession()->setKlarnaUseOtherMethods(false);
618
  }
619
 
620
  $this->loadLayout();
621
  $this->_initLayoutMessages('customer/session');
622
  $this->getLayout()->getBlock('head')->setTitle($this->__('Klarna Checkout'));
623
 
624
+ if ($this->_getSession()->getLastOrderId()) {
625
+ Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($this->_getSession()->getLastOrderId())));
626
+ }
627
+
628
  // This is KCO specific for the current API... This must find another solution
629
  if ($block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('google_analytics')) {
630
  $block->setKlarnaCheckoutOrder($klarna->getActualKlarnaOrder());
632
 
633
  $this->renderLayout();
634
 
 
 
 
635
  Mage::helper('klarna')->logKlarnaApi('successAction displayed success');
636
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
637
  } catch (Exception $e) {
638
+ // Will show empty success page... however unlikely it is to get here, it's not very good
639
  Mage::helper('klarna')->logKlarnaException($e);
640
+ return $this;
641
  }
642
  }
643
 
809
  }
810
  }
811
  $cart = $this->_getCart();
812
+ $quote = $cart->getQuote();
813
+ if (! $cart->getCustomerSession()->getCustomer()->getId() && $quote->getCustomerId()) {
814
+ $quote->setCustomerId(null);
815
  }
816
  $cartData = $cart->suggestItemsQty($cartData);
817
  $cart->updateItems($cartData);
818
 
819
  // Addon to check qty vs stock to support ajax response
820
+ $items = $quote->getItemsCollection();
821
 
822
  foreach ($items as $item) {
823
  $item->checkData();
824
  }
825
+ $errors = $quote->getErrors();
826
  $messages = array();
827
 
828
  foreach ($errors as $error) {
833
  Mage::throwException(implode(', ', $messages));
834
  }
835
 
836
+ $quote->getShippingAddress()->setCollectShippingRates(true);
837
+ $quote->collectTotals();
838
  $this->_checkShippingMethod();
839
  $cart->save();
840
 
841
  // Addon for ajax to redirect to cart
842
  if ($this->_getCart()->getSummaryQty() <= 0) {
843
+ $result['redirect_url'] = Mage::getBaseUrl() . Mage::helper('klarna')->getKCORedirectToCartUrl($this->getQuote()->getStoreId());
844
  }
845
  }
846
  $this->_getSession()->setCartWasUpdated(true);
1010
  $quote->collectTotals()->save();
1011
  $this->getResponse()->setBody(Zend_Json::encode($result));
1012
  }
1013
+ }
app/code/community/Vaimo/Klarna/etc/config.xml CHANGED
@@ -25,7 +25,7 @@
25
  --><config>
26
  <modules>
27
  <Vaimo_Klarna>
28
- <version>5.3.31</version>
29
  <name>Vaimo Klarna Module</name>
30
  <depends>
31
  <Mage_Payment/>
@@ -239,6 +239,14 @@
239
  </klarna>
240
  </observers>
241
  </sales_order_save_after>
 
 
 
 
 
 
 
 
242
  <controller_action_predispatch_checkout_onepage_index>
243
  <observers>
244
  <klarna>
@@ -350,6 +358,7 @@
350
  <order_status_denied>klarna_denied</order_status_denied>
351
  <host>BETA</host>
352
  <allow_separate_address>1</allow_separate_address>
 
353
  </vaimo_klarna_invoice>
354
  <vaimo_klarna_account>
355
  <title>Klarna Account</title>
@@ -363,6 +372,7 @@
363
  <order_status_denied>klarna_denied</order_status_denied>
364
  <host>BETA</host>
365
  <allow_separate_address>1</allow_separate_address>
 
366
  </vaimo_klarna_account>
367
  <vaimo_klarna_special>
368
  <title>Klarna Campaign</title>
@@ -376,6 +386,7 @@
376
  <order_status_denied>klarna_denied</order_status_denied>
377
  <host>BETA</host>
378
  <allow_separate_address>1</allow_separate_address>
 
379
  </vaimo_klarna_special>
380
  <vaimo_klarna_checkout>
381
  <title>Klarna Checkout</title>
@@ -399,7 +410,13 @@
399
  <auto_register_guest>1</auto_register_guest>
400
  <create_order_on_validation>1</create_order_on_validation>
401
  <other_countries>1</other_countries>
 
402
  </vaimo_klarna_checkout>
403
  </payment>
 
 
 
 
 
404
  </default>
405
- </config>
25
  --><config>
26
  <modules>
27
  <Vaimo_Klarna>
28
+ <version>5.3.55</version>
29
  <name>Vaimo Klarna Module</name>
30
  <depends>
31
  <Mage_Payment/>
239
  </klarna>
240
  </observers>
241
  </sales_order_save_after>
242
+ <sales_quote_merge_after>
243
+ <observers>
244
+ <klarna>
245
+ <class>klarna/observer</class>
246
+ <method>updateQuoteMergeAfter</method>
247
+ </klarna>
248
+ </observers>
249
+ </sales_quote_merge_after>
250
  <controller_action_predispatch_checkout_onepage_index>
251
  <observers>
252
  <klarna>
358
  <order_status_denied>klarna_denied</order_status_denied>
359
  <host>BETA</host>
360
  <allow_separate_address>1</allow_separate_address>
361
+ <show_extended_error_message>1</show_extended_error_message>
362
  </vaimo_klarna_invoice>
363
  <vaimo_klarna_account>
364
  <title>Klarna Account</title>
372
  <order_status_denied>klarna_denied</order_status_denied>
373
  <host>BETA</host>
374
  <allow_separate_address>1</allow_separate_address>
375
+ <show_extended_error_message>1</show_extended_error_message>
376
  </vaimo_klarna_account>
377
  <vaimo_klarna_special>
378
  <title>Klarna Campaign</title>
386
  <order_status_denied>klarna_denied</order_status_denied>
387
  <host>BETA</host>
388
  <allow_separate_address>1</allow_separate_address>
389
+ <show_extended_error_message>1</show_extended_error_message>
390
  </vaimo_klarna_special>
391
  <vaimo_klarna_checkout>
392
  <title>Klarna Checkout</title>
410
  <auto_register_guest>1</auto_register_guest>
411
  <create_order_on_validation>1</create_order_on_validation>
412
  <other_countries>1</other_countries>
413
+ <show_extended_error_message>1</show_extended_error_message>
414
  </vaimo_klarna_checkout>
415
  </payment>
416
+ <icorder>
417
+ <excluded_payment_methods>
418
+ <vaimo_klarna_checkout/>
419
+ </excluded_payment_methods>
420
+ </icorder>
421
  </default>
422
+ </config>
app/code/community/Vaimo/Klarna/etc/system.xml CHANGED
@@ -45,7 +45,7 @@
45
  <show_in_store>1</show_in_store>
46
  <show_in_website>1</show_in_website>
47
  </active>
48
- <merchant_id translate="label">
49
  <label>Merchant ID</label>
50
  <frontend_type>text</frontend_type>
51
  <sort_order>10</sort_order>
@@ -54,7 +54,7 @@
54
  <show_in_website>1</show_in_website>
55
  <comment>The merchant id that you have received from Klarna</comment>
56
  </merchant_id>
57
- <shared_secret translate="label">
58
  <label>Shared secret</label>
59
  <frontend_type>text</frontend_type>
60
  <sort_order>15</sort_order>
@@ -71,7 +71,7 @@
71
  <show_in_store>1</show_in_store>
72
  <show_in_website>1</show_in_website>
73
  </title>
74
- <host translate="label">
75
  <label>Server</label>
76
  <frontend_type>select</frontend_type>
77
  <source_model>klarna/source_servermode</source_model>
@@ -90,7 +90,7 @@
90
  <show_in_store>1</show_in_store>
91
  <show_in_website>1</show_in_website>
92
  </order_status>
93
- <invoice_fee translate="label">
94
  <label>Invoice fee</label>
95
  <sort_order>50</sort_order>
96
  <show_in_default>1</show_in_default>
@@ -113,7 +113,7 @@
113
  <show_in_store>1</show_in_store>
114
  <show_in_website>1</show_in_website>
115
  </minimum_order_cost>
116
- <pending_status_action translate="label">
117
  <label>Cancel pending reservations</label>
118
  <frontend_type>select</frontend_type>
119
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -123,7 +123,7 @@
123
  <show_in_website>1</show_in_website>
124
  <comment>Automatically cancel orders when the reservation becomes pending</comment>
125
  </pending_status_action>
126
- <send_klarna_email translate="label">
127
  <label>Send invoice via e-mail</label>
128
  <frontend_type>select</frontend_type>
129
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -133,7 +133,7 @@
133
  <show_in_website>1</show_in_website>
134
  <comment>If set to yes, Klarna will send out the invoices as soon as the reservation is activated</comment>
135
  </send_klarna_email>
136
- <allow_separate_address translate="label">
137
  <label>Allow separate addresses</label>
138
  <frontend_type>select</frontend_type>
139
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -143,7 +143,7 @@
143
  <show_in_website>1</show_in_website>
144
  <comment>Allow shipping address to be different from billing address. You might need acceptance from Klarna if activated</comment>
145
  </allow_separate_address>
146
- <disable_company_purchase translate="label">
147
  <label>Disable method for company purchase</label>
148
  <frontend_type>select</frontend_type>
149
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -153,7 +153,7 @@
153
  <show_in_website>1</show_in_website>
154
  <comment>Disable this method when company field is filled in during checkout</comment>
155
  </disable_company_purchase>
156
- <disable_backend_calls translate="label">
157
  <label>Disable Klarna Backend</label>
158
  <frontend_type>select</frontend_type>
159
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -163,7 +163,18 @@
163
  <show_in_website>1</show_in_website>
164
  <comment>Disable all calls to Klarna from Admin, such as Capture, Credit and Cancel. This feature can be used if those functions are maintained by an external system</comment>
165
  </disable_backend_calls>
166
- <terms_url translate="label">
 
 
 
 
 
 
 
 
 
 
 
167
  <label>URL to terms and conditions</label>
168
  <frontend_type>text</frontend_type>
169
  <sort_order>700</sort_order>
@@ -172,7 +183,7 @@
172
  <show_in_website>1</show_in_website>
173
  <comment>URL to this stores own terms and conditions (only used in Germany and Austria)</comment>
174
  </terms_url>
175
- <klarna_language>
176
  <label>Language</label>
177
  <frontend_type>select</frontend_type>
178
  <source_model>klarna/source_language</source_model>
@@ -225,7 +236,7 @@
225
  <show_in_store>1</show_in_store>
226
  <show_in_website>1</show_in_website>
227
  </active>
228
- <merchant_id translate="label">
229
  <label>Merchant ID</label>
230
  <frontend_type>text</frontend_type>
231
  <sort_order>10</sort_order>
@@ -234,7 +245,7 @@
234
  <show_in_website>1</show_in_website>
235
  <comment>The merchant id that you have received from Klarna</comment>
236
  </merchant_id>
237
- <shared_secret translate="label">
238
  <label>Shared secret</label>
239
  <frontend_type>text</frontend_type>
240
  <sort_order>15</sort_order>
@@ -261,7 +272,7 @@
261
  <show_in_store>1</show_in_store>
262
  <show_in_website>1</show_in_website>
263
  </title>
264
- <host translate="label">
265
  <label>Server</label>
266
  <frontend_type>select</frontend_type>
267
  <source_model>klarna/source_servermode</source_model>
@@ -280,7 +291,7 @@
280
  <show_in_store>1</show_in_store>
281
  <show_in_website>1</show_in_website>
282
  </order_status>
283
- <pending_status_action translate="label">
284
  <label>Cancel pending reservations</label>
285
  <frontend_type>select</frontend_type>
286
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -290,7 +301,7 @@
290
  <show_in_website>1</show_in_website>
291
  <comment>Automatically cancel orders when the reservation becomes pending</comment>
292
  </pending_status_action>
293
- <send_klarna_email translate="label">
294
  <label>Send invoice via e-mail</label>
295
  <frontend_type>select</frontend_type>
296
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -300,7 +311,7 @@
300
  <show_in_website>1</show_in_website>
301
  <comment>If set to yes, Klarna will send out the invoices as soon as the reservation is activated</comment>
302
  </send_klarna_email>
303
- <allow_separate_address translate="label">
304
  <label>Allow separate addresses</label>
305
  <frontend_type>select</frontend_type>
306
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -310,7 +321,7 @@
310
  <show_in_website>1</show_in_website>
311
  <comment>Allow shipping address to be different from billing address. You might need acceptance from Klarna if activated</comment>
312
  </allow_separate_address>
313
- <disable_company_purchase translate="label">
314
  <label>Disable method for company purchase</label>
315
  <frontend_type>select</frontend_type>
316
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -320,7 +331,7 @@
320
  <show_in_website>1</show_in_website>
321
  <comment>Disable this method when company field is filled in during checkout</comment>
322
  </disable_company_purchase>
323
- <disable_backend_calls translate="label">
324
  <label>Disable Klarna Backend</label>
325
  <frontend_type>select</frontend_type>
326
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -330,7 +341,18 @@
330
  <show_in_website>1</show_in_website>
331
  <comment>Disable all calls to Klarna from Admin, such as Capture, Credit and Cancel. This feature can be used if those functions are maintained by an external system</comment>
332
  </disable_backend_calls>
333
- <disable_product_widget translate="label">
 
 
 
 
 
 
 
 
 
 
 
334
  <label>Disable payment widget on product page</label>
335
  <frontend_type>select</frontend_type>
336
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -340,7 +362,7 @@
340
  <show_in_website>1</show_in_website>
341
  <comment>If set to yes, the payment information from Klarna will not appear on the product page</comment>
342
  </disable_product_widget>
343
- <terms_url translate="label">
344
  <label>URL to terms and conditions</label>
345
  <frontend_type>text</frontend_type>
346
  <sort_order>700</sort_order>
@@ -349,7 +371,7 @@
349
  <show_in_website>1</show_in_website>
350
  <comment>URL to this stores own terms and conditions (only used in Germany and Austria)</comment>
351
  </terms_url>
352
- <klarna_language>
353
  <label>Language</label>
354
  <frontend_type>select</frontend_type>
355
  <source_model>klarna/source_language</source_model>
@@ -402,7 +424,7 @@
402
  <show_in_store>1</show_in_store>
403
  <show_in_website>1</show_in_website>
404
  </active>
405
- <merchant_id translate="label">
406
  <label>Merchant ID</label>
407
  <frontend_type>text</frontend_type>
408
  <sort_order>10</sort_order>
@@ -411,7 +433,7 @@
411
  <show_in_website>1</show_in_website>
412
  <comment>The merchant id that you have received from Klarna</comment>
413
  </merchant_id>
414
- <shared_secret translate="label">
415
  <label>Shared secret</label>
416
  <frontend_type>text</frontend_type>
417
  <sort_order>15</sort_order>
@@ -428,7 +450,7 @@
428
  <show_in_store>1</show_in_store>
429
  <show_in_website>1</show_in_website>
430
  </title>
431
- <host translate="label">
432
  <label>Server</label>
433
  <frontend_type>select</frontend_type>
434
  <source_model>klarna/source_servermode</source_model>
@@ -447,7 +469,7 @@
447
  <show_in_store>1</show_in_store>
448
  <show_in_website>1</show_in_website>
449
  </order_status>
450
- <pending_status_action translate="label">
451
  <label>Cancel pending reservations</label>
452
  <frontend_type>select</frontend_type>
453
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -457,7 +479,7 @@
457
  <show_in_website>1</show_in_website>
458
  <comment>Automatically cancel orders when the reservation becomes pending</comment>
459
  </pending_status_action>
460
- <send_klarna_email translate="label">
461
  <label>Send invoice via e-mail</label>
462
  <frontend_type>select</frontend_type>
463
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -467,7 +489,7 @@
467
  <show_in_website>1</show_in_website>
468
  <comment>If set to yes, Klarna will send out the invoices as soon as the reservation is activated</comment>
469
  </send_klarna_email>
470
- <allow_separate_address translate="label">
471
  <label>Allow separate addresses</label>
472
  <frontend_type>select</frontend_type>
473
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -477,7 +499,7 @@
477
  <show_in_website>1</show_in_website>
478
  <comment>Allow shipping address to be different from billing address. You might need acceptance from Klarna if activated</comment>
479
  </allow_separate_address>
480
- <disable_company_purchase translate="label">
481
  <label>Disable method for company purchase</label>
482
  <frontend_type>select</frontend_type>
483
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -487,7 +509,7 @@
487
  <show_in_website>1</show_in_website>
488
  <comment>Disable this method when company field is filled in during checkout</comment>
489
  </disable_company_purchase>
490
- <disable_backend_calls translate="label">
491
  <label>Disable Klarna Backend</label>
492
  <frontend_type>select</frontend_type>
493
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -497,7 +519,18 @@
497
  <show_in_website>1</show_in_website>
498
  <comment>Disable all calls to Klarna from Admin, such as Capture, Credit and Cancel. This feature can be used if those functions are maintained by an external system</comment>
499
  </disable_backend_calls>
500
- <terms_url translate="label">
 
 
 
 
 
 
 
 
 
 
 
501
  <label>URL to terms and conditions</label>
502
  <frontend_type>text</frontend_type>
503
  <sort_order>700</sort_order>
@@ -506,7 +539,7 @@
506
  <show_in_website>1</show_in_website>
507
  <comment>URL to this stores own terms and conditions (only used in Germany and Austria)</comment>
508
  </terms_url>
509
- <cdn_logotype_override translate="label">
510
  <label>URL to special logotype</label>
511
  <frontend_type>text</frontend_type>
512
  <sort_order>710</sort_order>
@@ -525,7 +558,7 @@
525
  <show_in_website>1</show_in_website>
526
  </cdn_terms_override>
527
  -->
528
- <klarna_language>
529
  <label>Language</label>
530
  <frontend_type>select</frontend_type>
531
  <source_model>klarna/source_language</source_model>
@@ -587,7 +620,7 @@
587
  <show_in_website>1</show_in_website>
588
  <show_in_store>1</show_in_store>
589
  </api_version>
590
- <merchant_id translate="label">
591
  <label>Merchant ID</label>
592
  <frontend_type>text</frontend_type>
593
  <sort_order>30</sort_order>
@@ -596,7 +629,7 @@
596
  <show_in_store>1</show_in_store>
597
  <comment>The merchant id that you have received from Klarna</comment>
598
  </merchant_id>
599
- <shared_secret translate="label">
600
  <label>Shared secret</label>
601
  <frontend_type>text</frontend_type>
602
  <sort_order>40</sort_order>
@@ -605,7 +638,7 @@
605
  <show_in_store>1</show_in_store>
606
  <comment>The shared secret that you have received from Klarna</comment>
607
  </shared_secret>
608
- <host translate="label">
609
  <label>Server</label>
610
  <frontend_type>select</frontend_type>
611
  <source_model>klarna/source_servermode</source_model>
@@ -615,7 +648,7 @@
615
  <show_in_store>1</show_in_store>
616
  <comment>Choose what server to make calls to</comment>
617
  </host>
618
- <auto_prefil translate="label">
619
  <label>Auto prefill known Klarna details</label>
620
  <frontend_type>select</frontend_type>
621
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -634,7 +667,7 @@
634
  <show_in_website>1</show_in_website>
635
  <show_in_store>0</show_in_store>
636
  </order_status>
637
- <disable_backend_calls translate="label">
638
  <label>Disable Klarna Backend</label>
639
  <frontend_type>select</frontend_type>
640
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -644,7 +677,7 @@
644
  <show_in_website>1</show_in_website>
645
  <comment>Disable all calls to Klarna from Admin, such as Capture, Credit and Cancel. This feature can be used if those functions are maintained by an external system</comment>
646
  </disable_backend_calls>
647
- <disable_product_widget translate="label">
648
  <label>Disable payment widget on product page</label>
649
  <frontend_type>select</frontend_type>
650
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -654,7 +687,18 @@
654
  <show_in_store>1</show_in_store>
655
  <comment>If set to yes, the payment information from Klarna will not appear on the product page</comment>
656
  </disable_product_widget>
657
- <terms_url translate="label">
 
 
 
 
 
 
 
 
 
 
 
658
  <label>URL to terms and conditions</label>
659
  <frontend_type>text</frontend_type>
660
  <sort_order>90</sort_order>
@@ -663,7 +707,7 @@
663
  <show_in_store>1</show_in_store>
664
  <comment>URL to this stores own terms and conditions</comment>
665
  </terms_url>
666
- <cart_redirect translate="label">
667
  <label>Cart redirect</label>
668
  <frontend_type>text</frontend_type>
669
  <sort_order>95</sort_order>
@@ -681,7 +725,7 @@
681
  <show_in_website>1</show_in_website>
682
  <show_in_store>1</show_in_store>
683
  </klarna_layout>
684
- <klarna_language>
685
  <label>Language</label>
686
  <frontend_type>select</frontend_type>
687
  <source_model>klarna/source_language</source_model>
@@ -691,7 +735,7 @@
691
  <show_in_website>1</show_in_website>
692
  <comment>Can be used if site is in a different language than the official language of current country</comment>
693
  </klarna_language>
694
- <show_login_form translate="label">
695
  <label>Show login form</label>
696
  <frontend_type>select</frontend_type>
697
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -701,7 +745,7 @@
701
  <show_in_store>1</show_in_store>
702
  <comment>Only for 2 column layout</comment>
703
  </show_login_form>
704
- <extra_order_attribute translate="label">
705
  <label>Extra order ID attribute</label>
706
  <frontend_type>text</frontend_type>
707
  <sort_order>150</sort_order>
@@ -710,7 +754,7 @@
710
  <show_in_store>1</show_in_store>
711
  <comment>Will be used in the orderid2 field on the Klarna order</comment>
712
  </extra_order_attribute>
713
- <allow_separate_address translate="label">
714
  <label>Allow separate addresses</label>
715
  <frontend_type>select</frontend_type>
716
  <source_model>klarna/source_yesnodefault</source_model>
@@ -729,7 +773,7 @@
729
  <show_in_website>1</show_in_website>
730
  <show_in_store>1</show_in_store>
731
  </force_phonenumber>
732
- <packstation_enabled translate="label">
733
  <label>Enable DHL Packstation</label>
734
  <frontend_type>select</frontend_type>
735
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -757,7 +801,7 @@
757
  <show_in_website>1</show_in_website>
758
  <show_in_store>1</show_in_store>
759
  </enable_auto_focus>
760
- <enable_trigger_changed_js>
761
  <label>Enable javascript trigger for address update</label>
762
  <frontend_type>select</frontend_type>
763
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -766,7 +810,7 @@
766
  <show_in_website>1</show_in_website>
767
  <show_in_store>1</show_in_store>
768
  </enable_trigger_changed_js>
769
- <auto_register_guest translate="label">
770
  <label>Automatically register guests on checkout</label>
771
  <frontend_type>select</frontend_type>
772
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -776,11 +820,21 @@
776
  <show_in_website>1</show_in_website>
777
  <comment>If disabled and Guest Checkout is allowed in Magento Checkout Options, orders will be placed as guests.</comment>
778
  </auto_register_guest>
779
- <user_defined_json translate="label">
 
 
 
 
 
 
 
 
 
 
780
  <label>User Defined Variables</label>
781
  <backend_model>klarna/adminhtml_system_config_backend_admin_json</backend_model>
782
  <frontend_type>textarea</frontend_type>
783
- <sort_order>290</sort_order>
784
  <show_in_default>1</show_in_default>
785
  <show_in_website>1</show_in_website>
786
  <show_in_store>1</show_in_store>
@@ -794,7 +848,7 @@
794
  <show_in_website>1</show_in_website>
795
  <show_in_store>1</show_in_store>
796
  </heading_https_only>
797
- <enable_validation translate="label">
798
  <label>Enable Validation of Order before Klarna proceeds</label>
799
  <frontend_type>select</frontend_type>
800
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -804,7 +858,7 @@
804
  <show_in_store>1</show_in_store>
805
  <comment>An extra validation is made for the cart, stock levels for example, just before the order is created in Klarna.</comment>
806
  </enable_validation>
807
- <create_order_on_validation translate="label">
808
  <label>Create order on Validation</label>
809
  <frontend_type>select</frontend_type>
810
  <depends><enable_validation>1</enable_validation></depends>
@@ -815,7 +869,19 @@
815
  <show_in_store>1</show_in_store>
816
  <comment>Create pending order on Validation and only update it when completed.</comment>
817
  </create_order_on_validation>
818
- <enable_postcode_update translate="label">
 
 
 
 
 
 
 
 
 
 
 
 
819
  <label>Enable tax and shipping updates</label>
820
  <frontend_type>select</frontend_type>
821
  <depends><enable_trigger_changed_js>1</enable_trigger_changed_js></depends>
@@ -834,7 +900,7 @@
834
  <show_in_website>1</show_in_website>
835
  <show_in_store>1</show_in_store>
836
  </heading_other_method_button>
837
- <enable_other_button translate="label">
838
  <label>Enabled</label>
839
  <frontend_type>select</frontend_type>
840
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -844,7 +910,7 @@
844
  <show_in_store>1</show_in_store>
845
  <comment>If enabled, one button will be placed on klarna checkout page and one in the payment section of standard checkout</comment>
846
  </enable_other_button>
847
- <label_other_button translate="label">
848
  <label>Label for Other Payment Methods button</label>
849
  <frontend_type>text</frontend_type>
850
  <depends><enable_other_button>1</enable_other_button></depends>
@@ -854,7 +920,7 @@
854
  <show_in_store>1</show_in_store>
855
  <comment>This can be free text or a complete URL to a reasonably sized image</comment>
856
  </label_other_button>
857
- <label_back_button translate="label">
858
  <label>Label for Back to Klarna Checkout button</label>
859
  <frontend_type>text</frontend_type>
860
  <depends><enable_other_button>1</enable_other_button></depends>
@@ -864,7 +930,7 @@
864
  <show_in_store>1</show_in_store>
865
  <comment>This can be free text or a complete URL to a reasonably sized image</comment>
866
  </label_back_button>
867
- <auto_reset_other_method_button translate="label">
868
  <label>Automatically reactivate Klarna Checkout</label>
869
  <frontend_type>select</frontend_type>
870
  <depends><enable_other_button>1</enable_other_button></depends>
@@ -875,7 +941,7 @@
875
  <show_in_store>1</show_in_store>
876
  <comment>If enabled, it will go to Klarna Checkout next time checkout is requested, if user exits standard checkout by going to another page. Attention! If there are many customizations in standard checkout, it might cause this reactivation as well!</comment>
877
  </auto_reset_other_method_button>
878
- <explicit_usage translate="label">
879
  <label>Only run Klarma Checkout if Explicitly called</label>
880
  <frontend_type>select</frontend_type>
881
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -894,7 +960,7 @@
894
  <show_in_website>1</show_in_website>
895
  <show_in_store>1</show_in_store>
896
  </heading_newsletter>
897
- <enable_newsletter translate="label">
898
  <label>Enabled</label>
899
  <frontend_type>select</frontend_type>
900
  <source_model>klarna/source_newsletter</source_model>
@@ -930,7 +996,7 @@
930
  <show_in_website>1</show_in_website>
931
  <show_in_store>1</show_in_store>
932
  </activate_ab_testing>
933
- <allowed_ip_range translate="label">
934
  <label>Enable for IP range (last digit)</label>
935
  <frontend_type>text</frontend_type>
936
  <depends><activate_ab_testing>1</activate_ab_testing></depends>
@@ -940,7 +1006,7 @@
940
  <show_in_store>1</show_in_store>
941
  <comment>Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses</comment>
942
  </allowed_ip_range>
943
- <allow_when_logged_in translate="label">
944
  <label>Enable for logged in Customers</label>
945
  <frontend_type>select</frontend_type>
946
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -951,7 +1017,7 @@
951
  <show_in_store>1</show_in_store>
952
  <comment>If not enabled, logged in customers will use standard Magento checkout</comment>
953
  </allow_when_logged_in>
954
- <allow_customer_group translate="label">
955
  <label>Enable for specific customer groups</label>
956
  <frontend_type>multiselect</frontend_type>
957
  <source_model>klarna/source_customergroup</source_model>
@@ -979,7 +1045,7 @@
979
  <show_in_website>1</show_in_website>
980
  <show_in_store>1</show_in_store>
981
  </other_countries>
982
- <shipping_countries translate="label">
983
  <label>Shipping Countries</label>
984
  <frontend_type>multiselect</frontend_type>
985
  <depends><other_countries>1</other_countries></depends>
@@ -990,7 +1056,7 @@
990
  <show_in_store>1</show_in_store>
991
  <comment>List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout</comment>
992
  </shipping_countries>
993
- <shipping_options translate="label">
994
  <label>Include Shipping Options</label>
995
  <frontend_type>select</frontend_type>
996
  <source_model>adminhtml/system_config_source_yesno</source_model>
45
  <show_in_store>1</show_in_store>
46
  <show_in_website>1</show_in_website>
47
  </active>
48
+ <merchant_id translate="label comment">
49
  <label>Merchant ID</label>
50
  <frontend_type>text</frontend_type>
51
  <sort_order>10</sort_order>
54
  <show_in_website>1</show_in_website>
55
  <comment>The merchant id that you have received from Klarna</comment>
56
  </merchant_id>
57
+ <shared_secret translate="label comment">
58
  <label>Shared secret</label>
59
  <frontend_type>text</frontend_type>
60
  <sort_order>15</sort_order>
71
  <show_in_store>1</show_in_store>
72
  <show_in_website>1</show_in_website>
73
  </title>
74
+ <host translate="label comment">
75
  <label>Server</label>
76
  <frontend_type>select</frontend_type>
77
  <source_model>klarna/source_servermode</source_model>
90
  <show_in_store>1</show_in_store>
91
  <show_in_website>1</show_in_website>
92
  </order_status>
93
+ <invoice_fee translate="label comment">
94
  <label>Invoice fee</label>
95
  <sort_order>50</sort_order>
96
  <show_in_default>1</show_in_default>
113
  <show_in_store>1</show_in_store>
114
  <show_in_website>1</show_in_website>
115
  </minimum_order_cost>
116
+ <pending_status_action translate="label comment">
117
  <label>Cancel pending reservations</label>
118
  <frontend_type>select</frontend_type>
119
  <source_model>adminhtml/system_config_source_yesno</source_model>
123
  <show_in_website>1</show_in_website>
124
  <comment>Automatically cancel orders when the reservation becomes pending</comment>
125
  </pending_status_action>
126
+ <send_klarna_email translate="label comment">
127
  <label>Send invoice via e-mail</label>
128
  <frontend_type>select</frontend_type>
129
  <source_model>adminhtml/system_config_source_yesno</source_model>
133
  <show_in_website>1</show_in_website>
134
  <comment>If set to yes, Klarna will send out the invoices as soon as the reservation is activated</comment>
135
  </send_klarna_email>
136
+ <allow_separate_address translate="label comment">
137
  <label>Allow separate addresses</label>
138
  <frontend_type>select</frontend_type>
139
  <source_model>adminhtml/system_config_source_yesno</source_model>
143
  <show_in_website>1</show_in_website>
144
  <comment>Allow shipping address to be different from billing address. You might need acceptance from Klarna if activated</comment>
145
  </allow_separate_address>
146
+ <disable_company_purchase translate="label comment">
147
  <label>Disable method for company purchase</label>
148
  <frontend_type>select</frontend_type>
149
  <source_model>adminhtml/system_config_source_yesno</source_model>
153
  <show_in_website>1</show_in_website>
154
  <comment>Disable this method when company field is filled in during checkout</comment>
155
  </disable_company_purchase>
156
+ <disable_backend_calls translate="label comment">
157
  <label>Disable Klarna Backend</label>
158
  <frontend_type>select</frontend_type>
159
  <source_model>adminhtml/system_config_source_yesno</source_model>
163
  <show_in_website>1</show_in_website>
164
  <comment>Disable all calls to Klarna from Admin, such as Capture, Credit and Cancel. This feature can be used if those functions are maintained by an external system</comment>
165
  </disable_backend_calls>
166
+ <show_extended_error_message translate="label comment tooltip">
167
+ <label>Show Extended Error Message</label>
168
+ <frontend_type>select</frontend_type>
169
+ <source_model>adminhtml/system_config_source_yesno</source_model>
170
+ <sort_order>240</sort_order>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_store>1</show_in_store>
173
+ <show_in_website>1</show_in_website>
174
+ <comment><![CDATA["Yes" - show error messages provided by Klarna. "No" - show default error message]]></comment>
175
+ <tooltip><![CDATA[Show extended error message in case if authorization was failed]]></tooltip>
176
+ </show_extended_error_message>
177
+ <terms_url translate="label comment">
178
  <label>URL to terms and conditions</label>
179
  <frontend_type>text</frontend_type>
180
  <sort_order>700</sort_order>
183
  <show_in_website>1</show_in_website>
184
  <comment>URL to this stores own terms and conditions (only used in Germany and Austria)</comment>
185
  </terms_url>
186
+ <klarna_language translate="label">
187
  <label>Language</label>
188
  <frontend_type>select</frontend_type>
189
  <source_model>klarna/source_language</source_model>
236
  <show_in_store>1</show_in_store>
237
  <show_in_website>1</show_in_website>
238
  </active>
239
+ <merchant_id translate="label comment">
240
  <label>Merchant ID</label>
241
  <frontend_type>text</frontend_type>
242
  <sort_order>10</sort_order>
245
  <show_in_website>1</show_in_website>
246
  <comment>The merchant id that you have received from Klarna</comment>
247
  </merchant_id>
248
+ <shared_secret translate="label comment">
249
  <label>Shared secret</label>
250
  <frontend_type>text</frontend_type>
251
  <sort_order>15</sort_order>
272
  <show_in_store>1</show_in_store>
273
  <show_in_website>1</show_in_website>
274
  </title>
275
+ <host translate="label comment">
276
  <label>Server</label>
277
  <frontend_type>select</frontend_type>
278
  <source_model>klarna/source_servermode</source_model>
291
  <show_in_store>1</show_in_store>
292
  <show_in_website>1</show_in_website>
293
  </order_status>
294
+ <pending_status_action translate="label comment">
295
  <label>Cancel pending reservations</label>
296
  <frontend_type>select</frontend_type>
297
  <source_model>adminhtml/system_config_source_yesno</source_model>
301
  <show_in_website>1</show_in_website>
302
  <comment>Automatically cancel orders when the reservation becomes pending</comment>
303
  </pending_status_action>
304
+ <send_klarna_email translate="label comment">
305
  <label>Send invoice via e-mail</label>
306
  <frontend_type>select</frontend_type>
307
  <source_model>adminhtml/system_config_source_yesno</source_model>
311
  <show_in_website>1</show_in_website>
312
  <comment>If set to yes, Klarna will send out the invoices as soon as the reservation is activated</comment>
313
  </send_klarna_email>
314
+ <allow_separate_address translate="label comment">
315
  <label>Allow separate addresses</label>
316
  <frontend_type>select</frontend_type>
317
  <source_model>adminhtml/system_config_source_yesno</source_model>
321
  <show_in_website>1</show_in_website>
322
  <comment>Allow shipping address to be different from billing address. You might need acceptance from Klarna if activated</comment>
323
  </allow_separate_address>
324
+ <disable_company_purchase translate="label comment">
325
  <label>Disable method for company purchase</label>
326
  <frontend_type>select</frontend_type>
327
  <source_model>adminhtml/system_config_source_yesno</source_model>
331
  <show_in_website>1</show_in_website>
332
  <comment>Disable this method when company field is filled in during checkout</comment>
333
  </disable_company_purchase>
334
+ <disable_backend_calls translate="label comment">
335
  <label>Disable Klarna Backend</label>
336
  <frontend_type>select</frontend_type>
337
  <source_model>adminhtml/system_config_source_yesno</source_model>
341
  <show_in_website>1</show_in_website>
342
  <comment>Disable all calls to Klarna from Admin, such as Capture, Credit and Cancel. This feature can be used if those functions are maintained by an external system</comment>
343
  </disable_backend_calls>
344
+ <show_extended_error_message translate="label comment tooltip">
345
+ <label>Show Extended Error Message</label>
346
+ <frontend_type>select</frontend_type>
347
+ <source_model>adminhtml/system_config_source_yesno</source_model>
348
+ <sort_order>240</sort_order>
349
+ <show_in_default>1</show_in_default>
350
+ <show_in_store>1</show_in_store>
351
+ <show_in_website>1</show_in_website>
352
+ <comment><![CDATA["Yes" - show error messages provided by Klarna. "No" - show default error message]]></comment>
353
+ <tooltip><![CDATA[Show extended error message in case if authorization was failed]]></tooltip>
354
+ </show_extended_error_message>
355
+ <disable_product_widget translate="label comment">
356
  <label>Disable payment widget on product page</label>
357
  <frontend_type>select</frontend_type>
358
  <source_model>adminhtml/system_config_source_yesno</source_model>
362
  <show_in_website>1</show_in_website>
363
  <comment>If set to yes, the payment information from Klarna will not appear on the product page</comment>
364
  </disable_product_widget>
365
+ <terms_url translate="label comment">
366
  <label>URL to terms and conditions</label>
367
  <frontend_type>text</frontend_type>
368
  <sort_order>700</sort_order>
371
  <show_in_website>1</show_in_website>
372
  <comment>URL to this stores own terms and conditions (only used in Germany and Austria)</comment>
373
  </terms_url>
374
+ <klarna_language translate="label">
375
  <label>Language</label>
376
  <frontend_type>select</frontend_type>
377
  <source_model>klarna/source_language</source_model>
424
  <show_in_store>1</show_in_store>
425
  <show_in_website>1</show_in_website>
426
  </active>
427
+ <merchant_id translate="label comment">
428
  <label>Merchant ID</label>
429
  <frontend_type>text</frontend_type>
430
  <sort_order>10</sort_order>
433
  <show_in_website>1</show_in_website>
434
  <comment>The merchant id that you have received from Klarna</comment>
435
  </merchant_id>
436
+ <shared_secret translate="label comment">
437
  <label>Shared secret</label>
438
  <frontend_type>text</frontend_type>
439
  <sort_order>15</sort_order>
450
  <show_in_store>1</show_in_store>
451
  <show_in_website>1</show_in_website>
452
  </title>
453
+ <host translate="label comment">
454
  <label>Server</label>
455
  <frontend_type>select</frontend_type>
456
  <source_model>klarna/source_servermode</source_model>
469
  <show_in_store>1</show_in_store>
470
  <show_in_website>1</show_in_website>
471
  </order_status>
472
+ <pending_status_action translate="label comment">
473
  <label>Cancel pending reservations</label>
474
  <frontend_type>select</frontend_type>
475
  <source_model>adminhtml/system_config_source_yesno</source_model>
479
  <show_in_website>1</show_in_website>
480
  <comment>Automatically cancel orders when the reservation becomes pending</comment>
481
  </pending_status_action>
482
+ <send_klarna_email translate="label comment">
483
  <label>Send invoice via e-mail</label>
484
  <frontend_type>select</frontend_type>
485
  <source_model>adminhtml/system_config_source_yesno</source_model>
489
  <show_in_website>1</show_in_website>
490
  <comment>If set to yes, Klarna will send out the invoices as soon as the reservation is activated</comment>
491
  </send_klarna_email>
492
+ <allow_separate_address translate="label comment">
493
  <label>Allow separate addresses</label>
494
  <frontend_type>select</frontend_type>
495
  <source_model>adminhtml/system_config_source_yesno</source_model>
499
  <show_in_website>1</show_in_website>
500
  <comment>Allow shipping address to be different from billing address. You might need acceptance from Klarna if activated</comment>
501
  </allow_separate_address>
502
+ <disable_company_purchase translate="label comment">
503
  <label>Disable method for company purchase</label>
504
  <frontend_type>select</frontend_type>
505
  <source_model>adminhtml/system_config_source_yesno</source_model>
509
  <show_in_website>1</show_in_website>
510
  <comment>Disable this method when company field is filled in during checkout</comment>
511
  </disable_company_purchase>
512
+ <disable_backend_calls translate="label comment">
513
  <label>Disable Klarna Backend</label>
514
  <frontend_type>select</frontend_type>
515
  <source_model>adminhtml/system_config_source_yesno</source_model>
519
  <show_in_website>1</show_in_website>
520
  <comment>Disable all calls to Klarna from Admin, such as Capture, Credit and Cancel. This feature can be used if those functions are maintained by an external system</comment>
521
  </disable_backend_calls>
522
+ <show_extended_error_message translate="label comment tooltip">
523
+ <label>Show Extended Error Message</label>
524
+ <frontend_type>select</frontend_type>
525
+ <source_model>adminhtml/system_config_source_yesno</source_model>
526
+ <sort_order>240</sort_order>
527
+ <show_in_default>1</show_in_default>
528
+ <show_in_store>1</show_in_store>
529
+ <show_in_website>1</show_in_website>
530
+ <comment><![CDATA["Yes" - show error messages provided by Klarna. "No" - show default error message]]></comment>
531
+ <tooltip><![CDATA[Show extended error message in case if authorization was failed]]></tooltip>
532
+ </show_extended_error_message>
533
+ <terms_url translate="label comment">
534
  <label>URL to terms and conditions</label>
535
  <frontend_type>text</frontend_type>
536
  <sort_order>700</sort_order>
539
  <show_in_website>1</show_in_website>
540
  <comment>URL to this stores own terms and conditions (only used in Germany and Austria)</comment>
541
  </terms_url>
542
+ <cdn_logotype_override translate="label comment">
543
  <label>URL to special logotype</label>
544
  <frontend_type>text</frontend_type>
545
  <sort_order>710</sort_order>
558
  <show_in_website>1</show_in_website>
559
  </cdn_terms_override>
560
  -->
561
+ <klarna_language translate="label">
562
  <label>Language</label>
563
  <frontend_type>select</frontend_type>
564
  <source_model>klarna/source_language</source_model>
620
  <show_in_website>1</show_in_website>
621
  <show_in_store>1</show_in_store>
622
  </api_version>
623
+ <merchant_id translate="label comment">
624
  <label>Merchant ID</label>
625
  <frontend_type>text</frontend_type>
626
  <sort_order>30</sort_order>
629
  <show_in_store>1</show_in_store>
630
  <comment>The merchant id that you have received from Klarna</comment>
631
  </merchant_id>
632
+ <shared_secret translate="label comment">
633
  <label>Shared secret</label>
634
  <frontend_type>text</frontend_type>
635
  <sort_order>40</sort_order>
638
  <show_in_store>1</show_in_store>
639
  <comment>The shared secret that you have received from Klarna</comment>
640
  </shared_secret>
641
+ <host translate="label comment">
642
  <label>Server</label>
643
  <frontend_type>select</frontend_type>
644
  <source_model>klarna/source_servermode</source_model>
648
  <show_in_store>1</show_in_store>
649
  <comment>Choose what server to make calls to</comment>
650
  </host>
651
+ <auto_prefil translate="label comment">
652
  <label>Auto prefill known Klarna details</label>
653
  <frontend_type>select</frontend_type>
654
  <source_model>adminhtml/system_config_source_yesno</source_model>
667
  <show_in_website>1</show_in_website>
668
  <show_in_store>0</show_in_store>
669
  </order_status>
670
+ <disable_backend_calls translate="label comment">
671
  <label>Disable Klarna Backend</label>
672
  <frontend_type>select</frontend_type>
673
  <source_model>adminhtml/system_config_source_yesno</source_model>
677
  <show_in_website>1</show_in_website>
678
  <comment>Disable all calls to Klarna from Admin, such as Capture, Credit and Cancel. This feature can be used if those functions are maintained by an external system</comment>
679
  </disable_backend_calls>
680
+ <disable_product_widget translate="label comment">
681
  <label>Disable payment widget on product page</label>
682
  <frontend_type>select</frontend_type>
683
  <source_model>adminhtml/system_config_source_yesno</source_model>
687
  <show_in_store>1</show_in_store>
688
  <comment>If set to yes, the payment information from Klarna will not appear on the product page</comment>
689
  </disable_product_widget>
690
+ <show_extended_error_message translate="label comment tooltip">
691
+ <label>Show Extended Error Message</label>
692
+ <frontend_type>select</frontend_type>
693
+ <source_model>adminhtml/system_config_source_yesno</source_model>
694
+ <sort_order>85</sort_order>
695
+ <show_in_default>1</show_in_default>
696
+ <show_in_store>1</show_in_store>
697
+ <show_in_website>1</show_in_website>
698
+ <comment><![CDATA["Yes" - show error messages provided by Klarna. "No" - show default error message]]></comment>
699
+ <tooltip><![CDATA[Show extended error message in case if authorization was failed]]></tooltip>
700
+ </show_extended_error_message>
701
+ <terms_url translate="label comment">
702
  <label>URL to terms and conditions</label>
703
  <frontend_type>text</frontend_type>
704
  <sort_order>90</sort_order>
707
  <show_in_store>1</show_in_store>
708
  <comment>URL to this stores own terms and conditions</comment>
709
  </terms_url>
710
+ <cart_redirect translate="label comment">
711
  <label>Cart redirect</label>
712
  <frontend_type>text</frontend_type>
713
  <sort_order>95</sort_order>
725
  <show_in_website>1</show_in_website>
726
  <show_in_store>1</show_in_store>
727
  </klarna_layout>
728
+ <klarna_language translate="label comment">
729
  <label>Language</label>
730
  <frontend_type>select</frontend_type>
731
  <source_model>klarna/source_language</source_model>
735
  <show_in_website>1</show_in_website>
736
  <comment>Can be used if site is in a different language than the official language of current country</comment>
737
  </klarna_language>
738
+ <show_login_form translate="label comment">
739
  <label>Show login form</label>
740
  <frontend_type>select</frontend_type>
741
  <source_model>adminhtml/system_config_source_yesno</source_model>
745
  <show_in_store>1</show_in_store>
746
  <comment>Only for 2 column layout</comment>
747
  </show_login_form>
748
+ <extra_order_attribute translate="label comment">
749
  <label>Extra order ID attribute</label>
750
  <frontend_type>text</frontend_type>
751
  <sort_order>150</sort_order>
754
  <show_in_store>1</show_in_store>
755
  <comment>Will be used in the orderid2 field on the Klarna order</comment>
756
  </extra_order_attribute>
757
+ <allow_separate_address translate="label comment">
758
  <label>Allow separate addresses</label>
759
  <frontend_type>select</frontend_type>
760
  <source_model>klarna/source_yesnodefault</source_model>
773
  <show_in_website>1</show_in_website>
774
  <show_in_store>1</show_in_store>
775
  </force_phonenumber>
776
+ <packstation_enabled translate="label comment">
777
  <label>Enable DHL Packstation</label>
778
  <frontend_type>select</frontend_type>
779
  <source_model>adminhtml/system_config_source_yesno</source_model>
801
  <show_in_website>1</show_in_website>
802
  <show_in_store>1</show_in_store>
803
  </enable_auto_focus>
804
+ <enable_trigger_changed_js translate="label">
805
  <label>Enable javascript trigger for address update</label>
806
  <frontend_type>select</frontend_type>
807
  <source_model>adminhtml/system_config_source_yesno</source_model>
810
  <show_in_website>1</show_in_website>
811
  <show_in_store>1</show_in_store>
812
  </enable_trigger_changed_js>
813
+ <auto_register_guest translate="label comment">
814
  <label>Automatically register guests on checkout</label>
815
  <frontend_type>select</frontend_type>
816
  <source_model>adminhtml/system_config_source_yesno</source_model>
820
  <show_in_website>1</show_in_website>
821
  <comment>If disabled and Guest Checkout is allowed in Magento Checkout Options, orders will be placed as guests.</comment>
822
  </auto_register_guest>
823
+ <create_order_on_success translate="label comment">
824
+ <label>Create order on Success</label>
825
+ <frontend_type>select</frontend_type>
826
+ <source_model>adminhtml/system_config_source_yesno</source_model>
827
+ <sort_order>290</sort_order>
828
+ <show_in_default>1</show_in_default>
829
+ <show_in_website>1</show_in_website>
830
+ <show_in_store>1</show_in_store>
831
+ <comment>Create pending order on Success and only update it when completed (will work together with creating it on Validate).</comment>
832
+ </create_order_on_success>
833
+ <user_defined_json translate="label comment">
834
  <label>User Defined Variables</label>
835
  <backend_model>klarna/adminhtml_system_config_backend_admin_json</backend_model>
836
  <frontend_type>textarea</frontend_type>
837
+ <sort_order>390</sort_order>
838
  <show_in_default>1</show_in_default>
839
  <show_in_website>1</show_in_website>
840
  <show_in_store>1</show_in_store>
848
  <show_in_website>1</show_in_website>
849
  <show_in_store>1</show_in_store>
850
  </heading_https_only>
851
+ <enable_validation translate="label comment">
852
  <label>Enable Validation of Order before Klarna proceeds</label>
853
  <frontend_type>select</frontend_type>
854
  <source_model>adminhtml/system_config_source_yesno</source_model>
858
  <show_in_store>1</show_in_store>
859
  <comment>An extra validation is made for the cart, stock levels for example, just before the order is created in Klarna.</comment>
860
  </enable_validation>
861
+ <create_order_on_validation translate="label comment">
862
  <label>Create order on Validation</label>
863
  <frontend_type>select</frontend_type>
864
  <depends><enable_validation>1</enable_validation></depends>
869
  <show_in_store>1</show_in_store>
870
  <comment>Create pending order on Validation and only update it when completed.</comment>
871
  </create_order_on_validation>
872
+ <recreate_cart_on_failed_validate translate="label comment">
873
+ <label>Recreate Cart if validation Fails</label>
874
+ <frontend_type>select</frontend_type>
875
+ <depends><enable_validation>1</enable_validation></depends>
876
+ <depends><create_order_on_validation>1</create_order_on_validation></depends>
877
+ <source_model>adminhtml/system_config_source_yesno</source_model>
878
+ <sort_order>616</sort_order>
879
+ <show_in_default>1</show_in_default>
880
+ <show_in_website>1</show_in_website>
881
+ <show_in_store>1</show_in_store>
882
+ <comment>If order creation during validation fails, for whatever reason, recreate cart so customer can try again or use another method</comment>
883
+ </recreate_cart_on_failed_validate>
884
+ <enable_postcode_update translate="label comment">
885
  <label>Enable tax and shipping updates</label>
886
  <frontend_type>select</frontend_type>
887
  <depends><enable_trigger_changed_js>1</enable_trigger_changed_js></depends>
900
  <show_in_website>1</show_in_website>
901
  <show_in_store>1</show_in_store>
902
  </heading_other_method_button>
903
+ <enable_other_button translate="label comment">
904
  <label>Enabled</label>
905
  <frontend_type>select</frontend_type>
906
  <source_model>adminhtml/system_config_source_yesno</source_model>
910
  <show_in_store>1</show_in_store>
911
  <comment>If enabled, one button will be placed on klarna checkout page and one in the payment section of standard checkout</comment>
912
  </enable_other_button>
913
+ <label_other_button translate="label comment">
914
  <label>Label for Other Payment Methods button</label>
915
  <frontend_type>text</frontend_type>
916
  <depends><enable_other_button>1</enable_other_button></depends>
920
  <show_in_store>1</show_in_store>
921
  <comment>This can be free text or a complete URL to a reasonably sized image</comment>
922
  </label_other_button>
923
+ <label_back_button translate="label comment">
924
  <label>Label for Back to Klarna Checkout button</label>
925
  <frontend_type>text</frontend_type>
926
  <depends><enable_other_button>1</enable_other_button></depends>
930
  <show_in_store>1</show_in_store>
931
  <comment>This can be free text or a complete URL to a reasonably sized image</comment>
932
  </label_back_button>
933
+ <auto_reset_other_method_button translate="label comment">
934
  <label>Automatically reactivate Klarna Checkout</label>
935
  <frontend_type>select</frontend_type>
936
  <depends><enable_other_button>1</enable_other_button></depends>
941
  <show_in_store>1</show_in_store>
942
  <comment>If enabled, it will go to Klarna Checkout next time checkout is requested, if user exits standard checkout by going to another page. Attention! If there are many customizations in standard checkout, it might cause this reactivation as well!</comment>
943
  </auto_reset_other_method_button>
944
+ <explicit_usage translate="label comment">
945
  <label>Only run Klarma Checkout if Explicitly called</label>
946
  <frontend_type>select</frontend_type>
947
  <source_model>adminhtml/system_config_source_yesno</source_model>
960
  <show_in_website>1</show_in_website>
961
  <show_in_store>1</show_in_store>
962
  </heading_newsletter>
963
+ <enable_newsletter translate="label comment">
964
  <label>Enabled</label>
965
  <frontend_type>select</frontend_type>
966
  <source_model>klarna/source_newsletter</source_model>
996
  <show_in_website>1</show_in_website>
997
  <show_in_store>1</show_in_store>
998
  </activate_ab_testing>
999
+ <allowed_ip_range translate="label comment">
1000
  <label>Enable for IP range (last digit)</label>
1001
  <frontend_type>text</frontend_type>
1002
  <depends><activate_ab_testing>1</activate_ab_testing></depends>
1006
  <show_in_store>1</show_in_store>
1007
  <comment>Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses</comment>
1008
  </allowed_ip_range>
1009
+ <allow_when_logged_in translate="label comment">
1010
  <label>Enable for logged in Customers</label>
1011
  <frontend_type>select</frontend_type>
1012
  <source_model>adminhtml/system_config_source_yesno</source_model>
1017
  <show_in_store>1</show_in_store>
1018
  <comment>If not enabled, logged in customers will use standard Magento checkout</comment>
1019
  </allow_when_logged_in>
1020
+ <allow_customer_group translate="label comment">
1021
  <label>Enable for specific customer groups</label>
1022
  <frontend_type>multiselect</frontend_type>
1023
  <source_model>klarna/source_customergroup</source_model>
1045
  <show_in_website>1</show_in_website>
1046
  <show_in_store>1</show_in_store>
1047
  </other_countries>
1048
+ <shipping_countries translate="label comment">
1049
  <label>Shipping Countries</label>
1050
  <frontend_type>multiselect</frontend_type>
1051
  <depends><other_countries>1</other_countries></depends>
1056
  <show_in_store>1</show_in_store>
1057
  <comment>List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout</comment>
1058
  </shipping_countries>
1059
+ <shipping_options translate="label comment">
1060
  <label>Include Shipping Options</label>
1061
  <frontend_type>select</frontend_type>
1062
  <source_model>adminhtml/system_config_source_yesno</source_model>
app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/success.phtml CHANGED
@@ -23,7 +23,32 @@
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
25
  ?>
26
-
27
  <div id="vaimo_klarna_klarnacheckout_success">
28
- <?php echo $this->getKlarnaHtml() ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  </div>
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
25
  ?>
 
26
  <div id="vaimo_klarna_klarnacheckout_success">
27
+
28
+ <?php
29
+ /*
30
+ * This now works, if you wish to output it together with the iframe. It will contain the order id, if:
31
+ *
32
+ * The Order gets created during validation OR during success
33
+ * OR
34
+ * The push has arrived BEFORE success
35
+ *
36
+ * If none of those criterias are met, it will not display anything, as OrderId will not be set.
37
+ *
38
+ * There is no design done for this, this is a pure customisation suggestion
39
+ *
40
+ */
41
+ ?>
42
+
43
+ <?php if (false):?>
44
+ <?php if ($this->getOrderId()):?>
45
+ <?php if ($this->getCanViewOrder()) :?>
46
+ <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
47
+ <?php else :?>
48
+ <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
49
+ <?php endif;?>
50
+ <?php endif;?>
51
+ <?php endif;?>
52
+
53
+ <?php echo $this->getKlarnaHtml() ?>
54
  </div>
app/locale/fi_FI/Vaimo_Klarna.csv CHANGED
@@ -173,3 +173,4 @@
173
  "Shopping Cart","Ostoskori"
174
  "Choose shipping method","Valitse toimitustapa"
175
  "Quantity","Määrä"
 
173
  "Shopping Cart","Ostoskori"
174
  "Choose shipping method","Valitse toimitustapa"
175
  "Quantity","Määrä"
176
+ "Payment cancelled or some error occured. Please try again.","Maksu peruuntui tai tapahtui jokin muu virhe. Yritä hetken kuluttua uudelleen."
app/locale/sv_SE/Vaimo_Klarna.csv CHANGED
@@ -170,4 +170,24 @@
170
  "Shipping Countries","Leverans till länder"
171
  "Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Endast för API V.3.1. Lista över tillåtna länder att leverera till. Är ingen vald, visas ingen. Listan visas i Klarna Checkout"
172
  "Please note that your official address will be used for shipping address when you place your order","Leveransadressen kommer att uppdateras till din officiella adress när du lägger ordern"
173
- "Technical problem occurred while using %s payment method. Please try again later.","Ett tekniskt problem inträffade för betalningsmetoden %s. Var god försök igen senare."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  "Shipping Countries","Leverans till länder"
171
  "Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Endast för API V.3.1. Lista över tillåtna länder att leverera till. Är ingen vald, visas ingen. Listan visas i Klarna Checkout"
172
  "Please note that your official address will be used for shipping address when you place your order","Leveransadressen kommer att uppdateras till din officiella adress när du lägger ordern"
173
+ "Technical problem occurred while using %s payment method. Please try again later.","Ett tekniskt problem inträffade för betalningsmetoden %s. Var god försök igen senare."
174
+
175
+ "Cart redirect","Cart redirect"
176
+ "Default is cart, custom redirect must not go to any checkout page","Default is cart, custom redirect must not go to any checkout page"
177
+ "Enable javascript trigger for address update","Enable javascript trigger for address update"
178
+ "Automatically register guests on checkout","Automatically register guests on checkout"
179
+ "If disabled and Guest Checkout is allowed in Magento Checkout Options, orders will be placed as guests.","If disabled and Guest Checkout is allowed in Magento Checkout Options, orders will be placed as guests."
180
+ "Only when https is activated in checkout","Only when https is activated in checkout"
181
+ "Automatically reactivate Klarna Checkout","Automatically reactivate Klarna Checkout"
182
+ "If enabled, it will go to Klarna Checkout next time checkout is requested, if user exits standard checkout by going to another page. Attention! If there are many customizations in standard checkout, it might cause this reactivation as well!","If enabled, it will go to Klarna Checkout next time checkout is requested, if user exits standard checkout by going to another page. Attention! If there are many customizations in standard checkout, it might cause this reactivation as well!"
183
+ "Only run Klarma Checkout if Explicitly called","Only run Klarma Checkout if Explicitly called"
184
+ "If set to Yes, and you go to checkout without any customisation, it will go to standard checkout rather than Klarna Checkout by default","If set to Yes, and you go to checkout without any customisation, it will go to standard checkout rather than Klarna Checkout by default"
185
+ "Enable A/B Testing","Enable A/B Testing"
186
+ "Specific for API V.3x (US and UK)","Endast för API V.3x (US och UK)"
187
+ "Show other allowed shipping countries","Show other allowed shipping countries"
188
+ "List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Lista över tillåtna länder att leverera till. Är ingen vald, visas ingen. Listan visas i Klarna Checkout"
189
+ "Include Shipping Options","Include Shipping Options"
190
+ "List of available shipping options that should appear in Klarna Checkout.","List of available shipping options that should appear in Klarna Checkout."
191
+ "Show Extended Error Message","Show Extended Error Message"
192
+ """Yes"" - show error messages provided by Klarna. ""No"" - show default error message","""Yes"" - show error messages provided by Klarna. ""No"" - show default error message"
193
+ "Show extended error message in case if authorization was failed","Show extended error message in case if authorization was failed"
js/vaimo/klarna/klarnacheckout.js CHANGED
@@ -434,7 +434,7 @@ function registerKlarnaApiChange()
434
  _klarnaCheckout(function(api) {
435
  api.on({
436
  'change': function(data) {
437
- // showLoader();
438
  var url = document.getElementById('klarna-checkout-shipping-update').value;
439
  vanillaAjax(url, 'email=' + data.email +
440
  '&firstname=' + data.given_name +
@@ -456,7 +456,7 @@ function registerKlarnaApiChange()
456
  _klarnaCheckout(function(api) {
457
  api.on({
458
  'shipping_address_change': function(data) {
459
- // showLoader();
460
  var url = document.getElementById('klarna-checkout-shipping-update-postcode').value;
461
  vanillaAjax(url, 'email=' + data.email +
462
  '&firstname=' + data.given_name +
434
  _klarnaCheckout(function(api) {
435
  api.on({
436
  'change': function(data) {
437
+ showLoader(); // very annoying, but needs to be here, or we receive updates mid editing...
438
  var url = document.getElementById('klarna-checkout-shipping-update').value;
439
  vanillaAjax(url, 'email=' + data.email +
440
  '&firstname=' + data.given_name +
456
  _klarnaCheckout(function(api) {
457
  api.on({
458
  'shipping_address_change': function(data) {
459
+ showLoader(); // very annoying, but needs to be here, or we receive updates mid editing...
460
  var url = document.getElementById('klarna-checkout-shipping-update-postcode').value;
461
  vanillaAjax(url, 'email=' + data.email +
462
  '&firstname=' + data.given_name +
lib/Klarna/Klarna.php CHANGED
@@ -1186,7 +1186,7 @@ class Klarna
1186
  return trim($forwarded[0]);
1187
  }
1188
 
1189
- return $tmp_ip;
1190
  }
1191
 
1192
  /**
1186
  return trim($forwarded[0]);
1187
  }
1188
 
1189
+ return ($x_fwd ? $x_fwd : $tmp_ip);
1190
  }
1191
 
1192
  /**
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>klarnapayments</name>
4
- <version>5.3.31</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Klarna payment module for Klarna Checkout, invoice and part payments. This module works for all countries were Klarna's product offering is applicable. To use this module requires that you have a contract with Klarna.</description>
11
  <notes>This version is not compatible with any Klarna module version of 4.x or earlier.</notes>
12
  <authors><author><name>Klarna</name><user>Klarna</user><email>magento@klarna.com</email></author><author><name>Vaimo</name><user>VAIMO</user><email>info@vaimo.com</email></author></authors>
13
- <date>2015-12-10</date>
14
- <time>08:11:47</time>
15
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="vaimo_klarna.xml" hash="19a196d33bcc2e1eaf4413dcefeb5f04"/></dir><dir name="template"><dir name="vaimo"><dir name="klarna"><dir name="creditmemo"><dir name="totals"><file name="adjustments.phtml" hash="b0299ac0b1ca75b4d143413cc8eb8217"/></dir></dir><dir name="info"><file name="account.phtml" hash="4c51cb3b4aeb54bb009e384d300ece98"/><file name="checkout.phtml" hash="679e88a49ec331cec8df1b8f09e39758"/><dir name="children"><file name="invoicefee.phtml" hash="2b721be479706716f6468c8395455fa5"/><file name="invoices.phtml" hash="ac4e3bd4aea83e9ea3479fc04ed0d5a4"/><file name="notices.phtml" hash="a5053c7829df05fd8afb30d5019b1aca"/><file name="paymentplan.phtml" hash="885c020c05afd4516a42a33a6986f32f"/><file name="reference.phtml" hash="a789d5c8d4253c6ba4d894e2f0465f9c"/><file name="reservation.phtml" hash="d96f36640577e8e053050c24bfb4ec43"/></dir><file name="invoice.phtml" hash="498a1d706ac1da4fc71982f1232de492"/><file name="special.phtml" hash="4c51cb3b4aeb54bb009e384d300ece98"/></dir><dir name="pclass"><file name="list.phtml" hash="5cef6b0093bb5da18dbf1f9fd7316c66"/><file name="update.phtml" hash="ed53d5eb248f8181cd601e7b10cb170f"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="vaimo_klarna.xml" hash="4fda0bc7525f55705ef334c26f10a36d"/></dir><dir name="template"><dir name="vaimo"><dir name="klarna"><dir name="catalog"><dir name="product"><file name="pricewidget.phtml" hash="ade52495b519d3cfd6f53a4285be895f"/></dir></dir><dir name="checkout"><file name="fee.phtml" hash="3a58d7e7278bf9fcae1cdb9d836d4ff3"/><file name="header.phtml" hash="51a7f95f2fcb5f7b02e19b13690631a8"/><file name="top.phtml" hash="9cc1ce32346bd6ed7c16139f3f960a95"/></dir><dir name="form"><file name="account.phtml" hash="7b763a6452a9268b2489885cf7e2bb98"/><dir name="address"><file name="search.phtml" hash="473e03908fdb841f7152ed78671fcef0"/></dir><file name="checkout.phtml" hash="fe86056c73f86d53a73ebda5c5f3547c"/><dir name="children"><file name="addressresult.phtml" hash="4bb8fd4309c9b4012bfeb2d31c90076a"/><file name="checkoutservice.phtml" hash="3ae5ecf2420cb457304ef0b9f4227b9c"/><file name="consent.phtml" hash="a4f446258fa20a453d3566cffc20085d"/><file name="dateofbirth.phtml" hash="e1dbe367ce43029d671dae6f7d3ca956"/><file name="gender.phtml" hash="c8428e9b76db957a866cfc109d7a0c09"/><file name="notifications.phtml" hash="2d91f392c4c2fee89ada3c53719dc47f"/><file name="paymentplan_information.phtml" hash="8f28c418c08df3e664744ef28bc283c3"/><file name="pclass.phtml" hash="848a7e485badbdf11d10628c93906b21"/><file name="personalnumber.phtml" hash="dcea08f692ed978689242ba8309f3cdb"/><file name="phonenumber.phtml" hash="6348b12795e073d8881ab0b74d7df175"/></dir><file name="invoice.phtml" hash="0c1053b8b024035ab023fd39c473752b"/><dir name="paymentplan"><file name="information.phtml" hash="d013f147f38502cb4baf591d56d177d9"/></dir><file name="special.phtml" hash="05ada24ff6c7cb813f498920eddd90bb"/></dir><dir name="info"><file name="account.phtml" hash="a848c9544a5e400bc27e26d050eafa3c"/><file name="checkout.phtml" hash="cbcd2d9379f2afbd450fb925c05aa4ed"/><dir name="children"><file name="invoicefee.phtml" hash="c6b4ccff75e220c5641a8fadd6753131"/><file name="invoices.phtml" hash="892672664fe645193471a26bb052c18b"/><file name="notices.phtml" hash="26571bbd4c152f4f39c5b0281adff251"/><file name="paymentplan.phtml" hash="3a73d918dc733c0888f18e442f9eb64c"/><file name="reference.phtml" hash="60e6eaabc7ff88a7762ce97c45d151e0"/><file name="reservation.phtml" hash="9880ef8208f672d531cc10eef8467856"/></dir><file name="invoice.phtml" hash="cd3514e43dd441b4530b95e408784d84"/><file name="special.phtml" hash="c472684055c8839b8e365b80a5e1ee0c"/></dir><dir name="klarnacheckout"><file name="account-login.phtml" hash="487de8f489b7e65416bf3559e1819abd"/><file name="autofill.phtml" hash="6bdd6c22fd1771106f52876e66d7f4de"/><dir name="cart"><dir name="item"><file name="default.phtml" hash="cb76c84ce20dbd391a1615756f2d72d7"/></dir><file name="totals.phtml" hash="a8496f65d2bd8390cee2bb5c89bad555"/></dir><file name="cart.phtml" hash="9dd4348207c7bab904a92e51da1126ec"/><file name="checkout.phtml" hash="c71826694ac6270f82a05e69a896d66b"/><dir name="customer"><file name="balance.phtml" hash="af890728b26b0808c299ab199bc5f4c0"/></dir><file name="default.phtml" hash="357abf99f4cb926d728c7c5253ea4b1e"/><dir name="discount"><file name="coupon.phtml" hash="0e4c2c52f677212b2071e3acddcc217a"/><file name="giftcardaccount.phtml" hash="8895e32abbc97d84fce366221637a1d9"/></dir><file name="discount.phtml" hash="7ce3289506c3e8abdd4af610e0f7f273"/><file name="header.phtml" hash="d25937ce1facfe47e16e63dff56e337a"/><file name="klarnacheckout.phtml" hash="a51ee31586f4cbeb5bfe0ffe1ca32c84"/><file name="main.phtml" hash="079d3162d46b762574eb2cd4641c14c2"/><file name="msg.phtml" hash="d716a2a466835c99f71bea1742533cc0"/><file name="newsletter.phtml" hash="34e007c7bd516cd37e93cb5bd9f19478"/><file name="othermethod.phtml" hash="f619075a30bf6240753a186636b5c2f4"/><file name="reward.phtml" hash="0e1d0a7d42738662fddd04dab09f5765"/><dir name="shipping_method"><file name="available.phtml" hash="62991e138e2a296fc0aff83ebfae2aea"/></dir><file name="shipping_method.phtml" hash="78afd96ad7c9facd083673c1122e6d42"/><file name="sidebar.phtml" hash="a8c13bf43d0c415f153d198a2bb6fa1f"/><file name="success.phtml" hash="b1f276ce825e09d472aef29d631ddf7b"/></dir><dir name="page"><dir name="html"><file name="logo.phtml" hash="fb2d29e255453128bbdf37218289caf1"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vaimo_Klarna.xml" hash="fece558fa050794401aca834b1b12fd4"/></dir></target><target name="magelocale"><dir name="da_DK"><file name="Vaimo_Klarna.csv" hash="867abdb2985a30f0dd4c0fc29d55f481"/></dir><dir name="de_AT"><file name="Vaimo_Klarna.csv" hash="f1006c802ab50acd76a8f1b9e060461b"/></dir><dir name="de_DE"><file name="Vaimo_Klarna.csv" hash="9707fefff9e5debda444de8ec7805ba7"/></dir><dir name="fi_FI"><file name="Vaimo_Klarna.csv" hash="69252093f9de3450c82c21f54a1e2215"/></dir><dir name="nb_NO"><file name="Vaimo_Klarna.csv" hash="29fced20f334587c190cbc4ab8a310da"/></dir><dir name="nl_NL"><file name="Vaimo_Klarna.csv" hash="81c5a6c11d1adf5ab0fd114f53d9fcb8"/></dir><dir name="nn_NO"><file name="Vaimo_Klarna.csv" hash="6bbb8c704ed2f19a943fd8dbc6338e58"/></dir><dir name="sv_SE"><file name="Vaimo_Klarna.csv" hash="001c5a9082dfd31ad86874c594adbbfd"/></dir></target><target name="mage"><dir name="js"><dir name="vaimo"><dir name="klarna"><file name="klarna.js" hash="9462fee4ca415ee3d11a00d8b85548ec"/><file name="klarnacheckout.js" hash="5d752b81f028b2c7a8a98671350554da"/><file name="klarnautils.js" hash="a114420988fdd3c1c90a1e08b24e49fe"/></dir></dir></dir></target><target name="magelib"><dir name="Klarna"><file name="CHANGELOG" hash="9808fe4dfd049d5130f7088adc374d72"/><file name="Changelog-Vaimo.txt" hash="b4f3e9df96ec0afcaf81ba1417fd7ebe"/><dir name="Checkout"><file name="BasicConnector.php" hash="8a9d008cda8e0805537b70d1e0e3bcd5"/><file name="ConnectionErrorException.php" hash="352ae3f5bbb18c04f0a9d3ca1be30faf"/><file name="Connector.php" hash="199d9134e8c5188e5b8f958ac1f17029"/><file name="ConnectorException.php" hash="fe4017579c8757798e018fb0755496c0"/><file name="ConnectorInterface.php" hash="0ebfd5610fec6ddce7b7fd0f45f3d1d6"/><file name="Digest.php" hash="d7c2ea4ff1f22c8919685aad7e4e9c8b"/><file name="Exception.php" hash="31a95e8212f01d149265f75e20b31bcb"/><dir name="HTTP"><file name="CURLFactory.php" hash="591493c487797a80fd76f4f80ca598d0"/><file name="CURLHandle.php" hash="2d58ba553ffddafdcc9c80bea0c2c5ee"/><file name="CURLHandleInterface.php" hash="df5e3ddf82deb09164c75249c7235756"/><file name="CURLHeaders.php" hash="2a900efb8591defaf9230368403c975f"/><file name="CURLTransport.php" hash="c35a9910a04007372c2d6673f4657b89"/><file name="Request.php" hash="180f04ffd522b713b4261087a7e60c68"/><file name="Response.php" hash="86993580c2a11b14bab4af6328caa6de"/><file name="Transport.php" hash="4aa96d5086e105d79b0f97593fbe5d9b"/><file name="TransportInterface.php" hash="3d6aab36479741136c9dee1bbcf3914e"/></dir><file name="Order.php" hash="568242a47b838ae9abf8438a4bc7301e"/><file name="ResourceInterface.php" hash="55fc925edc0f69a89f2d79e348152a2c"/><file name="UserAgent.php" hash="ee6a35f67e56391f5bdfa387616e5618"/></dir><file name="Checkout.php" hash="6e16bb237ecfc54f086a0d533a8e69e3"/><file name="CheckoutServiceRequest.php" hash="1167bf796772a24c5cf56586c255715b"/><file name="CheckoutServiceResponse.php" hash="021edd2464930618a0de024ea9bfc9f7"/><file name="Country.php" hash="449272bb9d3c4cf023137ab85266546c"/><file name="CurlHandle.php" hash="d7418f2db8bf726cb2913e10ce9a63ce"/><file name="CurlTransport.php" hash="03599602490c2089d7609c3006fe392c"/><file name="Currency.php" hash="b11ecbc754029f8b1d99d361b7daa2d3"/><file name="Encoding.php" hash="1893ca72010090f41ab5fab9a9a0029b"/><file name="Exceptions.php" hash="a94eb2811f2004c7e87ba5a82bd61d40"/><file name="Flags.php" hash="dcb034831717186be38530f52a39b24e"/><file name="Klarna.php" hash="849fa477cb91df3a0156e6c5f62c4aea"/><file name="Language.php" hash="a89d7e2d756db8ae94b5b2177507c319"/><dir name="checkoutkpm"><file name="checkouthtml.intf.php" hash="f6cc7512fbb13c0446d8492f747cd436"/><file name="threatmetrix.class.php" hash="ec5ceb6742df44623d96ce321c24fba5"/></dir><dir name="examples"><file name="activate.php" hash="3e2dbb97106ee405253330de0aa826d8"/><file name="cancelReservation.php" hash="948a933b769dea6a9684731adb471b8c"/><file name="checkOrderStatus.php" hash="1229fc0c6c96dbd81eec8d8919c4add5"/><file name="checkoutService.php" hash="fbaf5d7764d93fbc1b220e5f90518a90"/><file name="creditInvoice.php" hash="32669c3a1e52e716147ca63f0063c4a2"/><file name="creditPart.php" hash="594631f8358a32de1083ad98417feafe"/><file name="emailInvoice.php" hash="3c0d6ce69e2e33a85ea3f0e2d5c6fc7e"/><file name="fetchPClasses.php" hash="7bf7620a596da1edb52436e4f188827d"/><file name="getAddresses.php" hash="cf5eed9d9b772983f8e41a39b374c6ab"/><file name="hasAccount.php" hash="29670e02a3178df1afccbfb911474a6a"/><file name="helperFunctions.php" hash="3b25b4f51f83e156c33dadc6dcbb2097"/><file name="reserveAmount.php" hash="aa140d9548e31cade6c42a38e78f64df"/><file name="reserveOCR.php" hash="fcadfe8c99debda5a8f935b7fbc1ba4e"/><file name="returnAmount.php" hash="ef600f9a84d62fcce825f66bb1b570e2"/><file name="sendInvoice.php" hash="2e2a53099c64daeb9f06abd81af2a0f5"/><file name="splitReservation.php" hash="ec2d26bae9dae03679f5272b7782a4e1"/><file name="update.php" hash="6e1fcd9f371cc4b12caca37933a51a55"/></dir><file name="klarnaaddr.php" hash="01075b4e2dd3987ef38efaa6b1ced54b"/><file name="klarnacalc.php" hash="2df31b6126716e91eaeea90f7ab2ca87"/><file name="klarnaconfig.php" hash="369278865db177e690b6d7757ca38c07"/><file name="klarnapclass.php" hash="30c5f867b8c8febc944871e75d240e65"/><dir name="pclasses"><file name="jsonstorage.class.php" hash="04f0d90ada9fd12d5f0de6448466f798"/><file name="mysqlstorage.class.php" hash="ad2d075301d730f97c7a895a2ebb7523"/><file name="sqlstorage.class.php" hash="e00df72512eac3998710a4b2f9ea89c8"/><file name="storage.intf.php" hash="032631d1f075d1eff09ccf926ea56417"/><file name="xmlstorage.class.php" hash="a47820de9cdcfb261de0e95fc92a2a64"/></dir><dir name="transport"><dir name="xmlrpc-3.0.0.beta"><dir name="lib"><file name="xmlrpc.inc" hash="5a74ea2a831648febc9b2c8f809b252c"/><file name="xmlrpc_wrappers.inc" hash="5aa00141ead09fc5498d9a3c9fcab888"/><file name="xmlrpcs.inc" hash="158b97bda79333e9b40793d876b6e98f"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="vaimo"><dir name="klarna"><dir name="css"><file name="admin.css" hash="ef4915be839e2039fb037f29c1506d30"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="vaimo"><dir name="klarna"><file name="checkout.css" hash="7d7fe12675f4ba51ad1fd608849f06ce"/><file name="checkout_osc.css" hash="126a8d2869872306ded4aef943db809c"/><file name="global.css" hash="22b6a446e6e874e6a95608f7046eac2a"/><file name="klarnacheckout.css" hash="00c9b9ec2e2458207a7e6a8fe061529a"/><file name="klarnadefault.css" hash="30bff2ef19a5a70b4ee9a458c504870c"/><file name="product.css" hash="ef6a838858ceb0c1ef6364bb089273c0"/><dir name="vendor"><file name="bootstrap-grid.css" hash="093d2cb25f2e4d0bc80233ed70cbcb9a"/><file name="bootstrap-grid.min.css" hash="9087d9a8c2457c96b6c216fea959b298"/><file name="fontawesome.css" hash="76ca4ed8592634fb5c421b4e19c35918"/><file name="fontawesome.min.css" hash="7b7b345da453c034563dd2ac7ca9666b"/><dir name="fonts"><file name="FontAwesome.otf" hash="19231917733e2bcdf257c9be99cdbaf1"/><file name="fontawesome-webfont.eot" hash="7149833697a959306ec3012a8588dcfa"/><file name="fontawesome-webfont.svg" hash="65bcbc899f379216109acd0b6c494618"/><file name="fontawesome-webfont.ttf" hash="c4668ed2440df82d3fd2f8be9d31d07d"/><file name="fontawesome-webfont.woff" hash="d95d6f5d5ab7cfefd09651800b69bd54"/></dir></dir></dir></dir></dir><dir name="images"><dir name="vaimo"><dir name="klarna"><file name="balk_afm3.jpg" hash="8855567960bff35b1e3ba486670b5878"/><file name="icons.png" hash="7f0808d4cf63c3d43637d40a703f30fe"/></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Vaimo"><dir name="Klarna"><dir name="Block"><dir name="Adminhtml"><dir name="Pclass"><file name="List.php" hash="7c68e3ec74e5cea1b62bb0218d297089"/><file name="Update.php" hash="fd444645b9f78fc4ea65c91ee3fc0044"/></dir><dir name="Sales"><dir name="Creditmemo"><dir name="Create"><file name="Adjustments.php" hash="12074f6aabbe90f14b8d30b7f65da9dc"/></dir><file name="Totals.php" hash="198afd117e90e17999f24c419a92b24b"/></dir><dir name="Invoice"><file name="Totals.php" hash="bc28f21c484fe2b4ca6d7a06da726fc3"/></dir><dir name="Order"><file name="Totals.php" hash="c80ca5283b0341964c36e70a850faaf6"/></dir></dir></dir><dir name="Catalog"><dir name="Product"><file name="Pricewidget.php" hash="a77d8ca953136f3fe9797166f8a51e93"/></dir></dir><dir name="Checkout"><file name="Fee.php" hash="1ffae1896b12e6d87fbbd2d3843fef75"/><file name="Top.php" hash="a8f9084322c1f924ef6fb4802908019d"/></dir><dir name="Form"><file name="Abstract.php" hash="da5fa0957ab2b1e3b57ca99a9323fadb"/><file name="Account.php" hash="f6bf008c1af0b93ead5b5a2577b59ea5"/><dir name="Address"><file name="Search.php" hash="439e9f9a5d9480a4356043bb73f9c9c7"/></dir><file name="Checkout.php" hash="a7e6876317a29184f07040b646b84ec7"/><file name="Invoice.php" hash="105a41b84e52b45f26f3c5de2d4bdd4a"/><dir name="Paymentplan"><file name="Information.php" hash="7c66acd887a1e3a165e3cd967d0f3331"/></dir><file name="Special.php" hash="8db5a5f33510cd32d724c6ecd6368aa2"/></dir><dir name="Info"><file name="Abstract.php" hash="b1f368a985cb611c2bb97385a313d6d7"/><file name="Account.php" hash="d302c2fc556e05858464fadd51cd4854"/><file name="Checkout.php" hash="df92291673e6bfe63ac968ad7297cca3"/><file name="Invoice.php" hash="f98adb5521f6c546c462f2e5bde31295"/><file name="Special.php" hash="e07662f39f0ff65505bfd627045c7766"/></dir><dir name="Invoice"><file name="Totals.php" hash="2437d7c7d7499d3ee2fcb7e0426ad64d"/></dir><dir name="Klarnacheckout"><file name="Autofill.php" hash="4fb4d1c806c2224d20a388b62f027e33"/><dir name="Customer"><file name="Balance.php" hash="e35153845d979d91ff79d0558e7b6c0b"/></dir><file name="Discount.php" hash="63bb0c1991030522371eb3b798055c39"/><file name="Ga.php" hash="e69dc6575162c137669bc6fba3d854cd"/><file name="Klarnacheckout.php" hash="adc7aa285e45b1198ba8cbe8542311c8"/><file name="Newsletter.php" hash="ce97e11c097b0cd9696919936fa59dc6"/><file name="Othermethod.php" hash="7af2512fb570dc467fd0d240c4963417"/><file name="Reward.php" hash="98d72b6cf65070dcb4cc87a303cd8b54"/><file name="Success.php" hash="88e538e4c165142c55d74a3efecebef6"/></dir><dir name="Order"><file name="Totals.php" hash="2e56335ff1b4a1d6752e7336b107bd13"/></dir><dir name="Page"><dir name="Html"><file name="Logo.php" hash="fda8fc32997328feb9c7ebf15c8a51fa"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><dir name="Position"><dir name="Attribute"><file name="Set.php" hash="b47d1dff880be4e0d22f8f169f180bc3"/></dir></dir><file name="Position.php" hash="469a02a99354ae219f5b744b248c76b8"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AddressController.php" hash="4ae9ea28491b66ca7a69c3bd0646cacb"/><dir name="Adminhtml"><dir name="Klarna"><file name="MassactionController.php" hash="a5679cee64b19d9742753f2b537cdaeb"/><file name="PclassController.php" hash="96836bd2a4ae7b145d9bedbbdf20e4f5"/></dir></dir><dir name="Checkout"><file name="KlarnaController.php" hash="a4e126b1d3761cb36e9ffbc08f62cd60"/></dir><file name="LoginController.php" hash="1356e1cb1b8889bb1f8b9bdf624f96ab"/><file name="PaymentplanController.php" hash="fea9d33a5dbd5d4858ef174569dae636"/></dir><dir name="etc"><file name="config.xml" hash="abd3713ca426b2c07185574c37053f66"/><file name="system.xml" hash="cc1eec0c953577c92a7e96be2af2c9e9"/></dir><dir name="Helper"><file name="Data.php" hash="de1634310e60e2149e3759f8b4d8e3b0"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Admin"><file name="Json.php" hash="e6413eca01dc9e4e6715e518ffa59eae"/></dir></dir></dir></dir></dir><dir name="Api"><file name="Abstract.php" hash="83e5d60fee0d104ef283a6abcba6d391"/><file name="Kco.php" hash="999ca4d1486de0bd04960143f0b27992"/><file name="Rest.php" hash="212c3d2cf1b666e03359b04dbf7fb550"/><file name="Xmlrpc.php" hash="5f9ddd41ea5b1c7dc77e35f702700b9c"/></dir><file name="Api.php" hash="0c9a565b4909373b16c6701af7356186"/><dir name="Creditmemo"><file name="Tax.php" hash="c3d5162de38f5ef2075bca483085e5d0"/><file name="Total.php" hash="8da0e6596826ba5fc03695e7834734f0"/></dir><file name="Cron.php" hash="3c2aa833ce3e9220a4f11184ae4b9097"/><dir name="Invoice"><dir name="Pdf"><file name="Total.php" hash="06412f97df9ac6a1854978b61f68fb36"/></dir><file name="Tax.php" hash="b2203547b3f05d6179e7307d14b55c6d"/><file name="Total.php" hash="c2f4a2207550915e1aaa9868e6759f94"/></dir><dir name="Klarna"><file name="Abstract.php" hash="df64121d6fd494d631acc997b8d66f55"/></dir><file name="Klarna.php" hash="1352e5b163aa33f872c20981710d410d"/><dir name="Klarnacheckout"><file name="Abstract.php" hash="3cd1fd4a58d6b6b09b291df26b761f2a"/></dir><file name="Klarnacheckout.php" hash="0bccd4a1e716a88613e73eccc6761c81"/><file name="Observer.php" hash="d24956bfb6fc0237a11285b9e8f432e6"/><dir name="Payment"><file name="Abstract.php" hash="2ad6b92c51a62431cadde7af6b4f6bba"/><file name="Account.php" hash="95931980dba66fc274f3acfa4df2b91a"/><file name="Checkout.php" hash="d8fb8bbadb12a901f782ed7067d12bc2"/><file name="Invoice.php" hash="eef0e5ea5466469942a14d28e8507333"/><file name="Special.php" hash="53754f59a474e32f168220c795b80c2f"/></dir><file name="Pushqueue.php" hash="cb74fc4cd2e34077b8be5f45c49dac28"/><dir name="Quote"><file name="Tax.php" hash="b53f4a52d0f09afc7daeb094d6e30881"/><file name="Total.php" hash="a1442ecba3f2c49a42ff43e006057878"/></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="0a40d43403823a6053d74bd2d2f688e7"/></dir><dir name="Pushqueue"><file name="Collection.php" hash="cdbfe12d3f3d82c60c699e2e4700645b"/></dir><file name="Pushqueue.php" hash="0ccf2419c79a847f8095f9ef8ca349de"/></dir><dir name="Source"><file name="Abstract.php" hash="8d0d746d1cd2e5bc7d11350908a01585"/><file name="Allspecificcountries.php" hash="1a98316e25baeaba307b3be62364e1ca"/><file name="Apiversion.php" hash="a1be9e12b858927cbfa459509fff3647"/><file name="Capture.php" hash="c2d31ebb607202555e9905e439dbe86d"/><file name="Country.php" hash="2444140a6155e42d2e4909ae150037b7"/><file name="Customergroup.php" hash="01c6e41abac6e7105e4d290f53f68733"/><file name="Klarnalayout.php" hash="6c7b9d3a871d8cdb2a11a0cadde83f4a"/><file name="Language.php" hash="ca8bc4334348501a96f109aec5f9a01a"/><file name="Newsletter.php" hash="f1532e5ff4c7e04384e9410cbb0969fa"/><file name="Servermode.php" hash="7acd8c7bb39f640dccef12df69ed7c57"/><file name="Taxclass.php" hash="de1ebcf0027eaff23f676da569034ed7"/><file name="Yesnodefault.php" hash="a296d6a62f1f1858ac093c0d7974cf6a"/></dir><dir name="Tax"><file name="Config.php" hash="7767f6d07f63df09228ab6c496ed0c05"/></dir><dir name="Transport"><file name="Abstract.php" hash="09816f0e578fc920293da4963eff48ea"/></dir></dir><dir name="sql"><dir name="klarna_setup"><file name="mysql4-install-0.1.0.php" hash="d36b51433fd28241386594f39def3080"/><file name="mysql4-upgrade-5.1.6-5.1.7.php" hash="014a7b827a8958a94c57a0229127a427"/><file name="mysql4-upgrade-5.2.5-5.2.6.php" hash="1dd874e1a94730ab976b6187a34e6c77"/><file name="mysql4-upgrade-5.3.24-5.3.25.php" hash="ec5af38cfd42c2b2b16343546a152fd8"/><file name="mysql4-upgrade-5.3.4-5.3.5.php" hash="64ff4fc928b39153a89857169faa7c70"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name></name><channel>connect.magentocommerce.com/core</channel><min></min><max></max></package></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>klarnapayments</name>
4
+ <version>5.3.55</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
10
  <description>Klarna payment module for Klarna Checkout, invoice and part payments. This module works for all countries were Klarna's product offering is applicable. To use this module requires that you have a contract with Klarna.</description>
11
  <notes>This version is not compatible with any Klarna module version of 4.x or earlier.</notes>
12
  <authors><author><name>Klarna</name><user>Klarna</user><email>magento@klarna.com</email></author><author><name>Vaimo</name><user>VAIMO</user><email>info@vaimo.com</email></author></authors>
13
+ <date>2016-05-10</date>
14
+ <time>19:55:15</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="vaimo_klarna.xml" hash="19a196d33bcc2e1eaf4413dcefeb5f04"/></dir><dir name="template"><dir name="vaimo"><dir name="klarna"><dir name="creditmemo"><dir name="totals"><file name="adjustments.phtml" hash="b0299ac0b1ca75b4d143413cc8eb8217"/></dir></dir><dir name="info"><file name="account.phtml" hash="4c51cb3b4aeb54bb009e384d300ece98"/><file name="checkout.phtml" hash="679e88a49ec331cec8df1b8f09e39758"/><dir name="children"><file name="invoicefee.phtml" hash="2b721be479706716f6468c8395455fa5"/><file name="invoices.phtml" hash="ac4e3bd4aea83e9ea3479fc04ed0d5a4"/><file name="notices.phtml" hash="a5053c7829df05fd8afb30d5019b1aca"/><file name="paymentplan.phtml" hash="885c020c05afd4516a42a33a6986f32f"/><file name="reference.phtml" hash="a789d5c8d4253c6ba4d894e2f0465f9c"/><file name="reservation.phtml" hash="d96f36640577e8e053050c24bfb4ec43"/></dir><file name="invoice.phtml" hash="498a1d706ac1da4fc71982f1232de492"/><file name="special.phtml" hash="4c51cb3b4aeb54bb009e384d300ece98"/></dir><dir name="pclass"><file name="list.phtml" hash="5cef6b0093bb5da18dbf1f9fd7316c66"/><file name="update.phtml" hash="ed53d5eb248f8181cd601e7b10cb170f"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="vaimo_klarna.xml" hash="4fda0bc7525f55705ef334c26f10a36d"/></dir><dir name="template"><dir name="vaimo"><dir name="klarna"><dir name="catalog"><dir name="product"><file name="pricewidget.phtml" hash="ade52495b519d3cfd6f53a4285be895f"/></dir></dir><dir name="checkout"><file name="fee.phtml" hash="3a58d7e7278bf9fcae1cdb9d836d4ff3"/><file name="header.phtml" hash="51a7f95f2fcb5f7b02e19b13690631a8"/><file name="top.phtml" hash="9cc1ce32346bd6ed7c16139f3f960a95"/></dir><dir name="form"><file name="account.phtml" hash="7b763a6452a9268b2489885cf7e2bb98"/><dir name="address"><file name="search.phtml" hash="473e03908fdb841f7152ed78671fcef0"/></dir><file name="checkout.phtml" hash="fe86056c73f86d53a73ebda5c5f3547c"/><dir name="children"><file name="addressresult.phtml" hash="4bb8fd4309c9b4012bfeb2d31c90076a"/><file name="checkoutservice.phtml" hash="3ae5ecf2420cb457304ef0b9f4227b9c"/><file name="consent.phtml" hash="a4f446258fa20a453d3566cffc20085d"/><file name="dateofbirth.phtml" hash="e1dbe367ce43029d671dae6f7d3ca956"/><file name="gender.phtml" hash="c8428e9b76db957a866cfc109d7a0c09"/><file name="notifications.phtml" hash="2d91f392c4c2fee89ada3c53719dc47f"/><file name="paymentplan_information.phtml" hash="8f28c418c08df3e664744ef28bc283c3"/><file name="pclass.phtml" hash="848a7e485badbdf11d10628c93906b21"/><file name="personalnumber.phtml" hash="dcea08f692ed978689242ba8309f3cdb"/><file name="phonenumber.phtml" hash="6348b12795e073d8881ab0b74d7df175"/></dir><file name="invoice.phtml" hash="0c1053b8b024035ab023fd39c473752b"/><dir name="paymentplan"><file name="information.phtml" hash="d013f147f38502cb4baf591d56d177d9"/></dir><file name="special.phtml" hash="05ada24ff6c7cb813f498920eddd90bb"/></dir><dir name="info"><file name="account.phtml" hash="a848c9544a5e400bc27e26d050eafa3c"/><file name="checkout.phtml" hash="cbcd2d9379f2afbd450fb925c05aa4ed"/><dir name="children"><file name="invoicefee.phtml" hash="c6b4ccff75e220c5641a8fadd6753131"/><file name="invoices.phtml" hash="892672664fe645193471a26bb052c18b"/><file name="notices.phtml" hash="26571bbd4c152f4f39c5b0281adff251"/><file name="paymentplan.phtml" hash="3a73d918dc733c0888f18e442f9eb64c"/><file name="reference.phtml" hash="60e6eaabc7ff88a7762ce97c45d151e0"/><file name="reservation.phtml" hash="9880ef8208f672d531cc10eef8467856"/></dir><file name="invoice.phtml" hash="cd3514e43dd441b4530b95e408784d84"/><file name="special.phtml" hash="c472684055c8839b8e365b80a5e1ee0c"/></dir><dir name="klarnacheckout"><file name="account-login.phtml" hash="487de8f489b7e65416bf3559e1819abd"/><file name="autofill.phtml" hash="6bdd6c22fd1771106f52876e66d7f4de"/><dir name="cart"><dir name="item"><file name="default.phtml" hash="cb76c84ce20dbd391a1615756f2d72d7"/></dir><file name="totals.phtml" hash="a8496f65d2bd8390cee2bb5c89bad555"/></dir><file name="cart.phtml" hash="9dd4348207c7bab904a92e51da1126ec"/><file name="checkout.phtml" hash="c71826694ac6270f82a05e69a896d66b"/><dir name="customer"><file name="balance.phtml" hash="af890728b26b0808c299ab199bc5f4c0"/></dir><file name="default.phtml" hash="357abf99f4cb926d728c7c5253ea4b1e"/><dir name="discount"><file name="coupon.phtml" hash="0e4c2c52f677212b2071e3acddcc217a"/><file name="giftcardaccount.phtml" hash="8895e32abbc97d84fce366221637a1d9"/></dir><file name="discount.phtml" hash="7ce3289506c3e8abdd4af610e0f7f273"/><file name="header.phtml" hash="d25937ce1facfe47e16e63dff56e337a"/><file name="klarnacheckout.phtml" hash="a51ee31586f4cbeb5bfe0ffe1ca32c84"/><file name="main.phtml" hash="079d3162d46b762574eb2cd4641c14c2"/><file name="msg.phtml" hash="d716a2a466835c99f71bea1742533cc0"/><file name="newsletter.phtml" hash="34e007c7bd516cd37e93cb5bd9f19478"/><file name="othermethod.phtml" hash="f619075a30bf6240753a186636b5c2f4"/><file name="reward.phtml" hash="0e1d0a7d42738662fddd04dab09f5765"/><dir name="shipping_method"><file name="available.phtml" hash="62991e138e2a296fc0aff83ebfae2aea"/></dir><file name="shipping_method.phtml" hash="78afd96ad7c9facd083673c1122e6d42"/><file name="sidebar.phtml" hash="a8c13bf43d0c415f153d198a2bb6fa1f"/><file name="success.phtml" hash="0be1560fb1634864692691618aaea7bc"/></dir><dir name="page"><dir name="html"><file name="logo.phtml" hash="fb2d29e255453128bbdf37218289caf1"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vaimo_Klarna.xml" hash="fece558fa050794401aca834b1b12fd4"/></dir></target><target name="magelocale"><dir name="da_DK"><file name="Vaimo_Klarna.csv" hash="867abdb2985a30f0dd4c0fc29d55f481"/></dir><dir name="de_AT"><file name="Vaimo_Klarna.csv" hash="f1006c802ab50acd76a8f1b9e060461b"/></dir><dir name="de_DE"><file name="Vaimo_Klarna.csv" hash="9707fefff9e5debda444de8ec7805ba7"/></dir><dir name="fi_FI"><file name="Vaimo_Klarna.csv" hash="8ec8cefda241e48a2302f3461e6f4f53"/></dir><dir name="nb_NO"><file name="Vaimo_Klarna.csv" hash="29fced20f334587c190cbc4ab8a310da"/></dir><dir name="nl_NL"><file name="Vaimo_Klarna.csv" hash="81c5a6c11d1adf5ab0fd114f53d9fcb8"/></dir><dir name="nn_NO"><file name="Vaimo_Klarna.csv" hash="6bbb8c704ed2f19a943fd8dbc6338e58"/></dir><dir name="sv_SE"><file name="Vaimo_Klarna.csv" hash="9c5a37bedb48277445ae0f6b643cb0c3"/></dir></target><target name="mage"><dir name="js"><dir name="vaimo"><dir name="klarna"><file name="klarna.js" hash="9462fee4ca415ee3d11a00d8b85548ec"/><file name="klarnacheckout.js" hash="625a1142a40bb621ad1a6193d38e1036"/><file name="klarnautils.js" hash="a114420988fdd3c1c90a1e08b24e49fe"/></dir></dir></dir></target><target name="magelib"><dir name="Klarna"><file name="CHANGELOG" hash="9808fe4dfd049d5130f7088adc374d72"/><file name="Changelog-Vaimo.txt" hash="b4f3e9df96ec0afcaf81ba1417fd7ebe"/><dir name="Checkout"><file name="BasicConnector.php" hash="8a9d008cda8e0805537b70d1e0e3bcd5"/><file name="ConnectionErrorException.php" hash="352ae3f5bbb18c04f0a9d3ca1be30faf"/><file name="Connector.php" hash="199d9134e8c5188e5b8f958ac1f17029"/><file name="ConnectorException.php" hash="fe4017579c8757798e018fb0755496c0"/><file name="ConnectorInterface.php" hash="0ebfd5610fec6ddce7b7fd0f45f3d1d6"/><file name="Digest.php" hash="d7c2ea4ff1f22c8919685aad7e4e9c8b"/><file name="Exception.php" hash="31a95e8212f01d149265f75e20b31bcb"/><dir name="HTTP"><file name="CURLFactory.php" hash="591493c487797a80fd76f4f80ca598d0"/><file name="CURLHandle.php" hash="2d58ba553ffddafdcc9c80bea0c2c5ee"/><file name="CURLHandleInterface.php" hash="df5e3ddf82deb09164c75249c7235756"/><file name="CURLHeaders.php" hash="2a900efb8591defaf9230368403c975f"/><file name="CURLTransport.php" hash="c35a9910a04007372c2d6673f4657b89"/><file name="Request.php" hash="180f04ffd522b713b4261087a7e60c68"/><file name="Response.php" hash="86993580c2a11b14bab4af6328caa6de"/><file name="Transport.php" hash="4aa96d5086e105d79b0f97593fbe5d9b"/><file name="TransportInterface.php" hash="3d6aab36479741136c9dee1bbcf3914e"/></dir><file name="Order.php" hash="568242a47b838ae9abf8438a4bc7301e"/><file name="ResourceInterface.php" hash="55fc925edc0f69a89f2d79e348152a2c"/><file name="UserAgent.php" hash="ee6a35f67e56391f5bdfa387616e5618"/></dir><file name="Checkout.php" hash="6e16bb237ecfc54f086a0d533a8e69e3"/><file name="CheckoutServiceRequest.php" hash="1167bf796772a24c5cf56586c255715b"/><file name="CheckoutServiceResponse.php" hash="021edd2464930618a0de024ea9bfc9f7"/><file name="Country.php" hash="449272bb9d3c4cf023137ab85266546c"/><file name="CurlHandle.php" hash="d7418f2db8bf726cb2913e10ce9a63ce"/><file name="CurlTransport.php" hash="03599602490c2089d7609c3006fe392c"/><file name="Currency.php" hash="b11ecbc754029f8b1d99d361b7daa2d3"/><file name="Encoding.php" hash="1893ca72010090f41ab5fab9a9a0029b"/><file name="Exceptions.php" hash="a94eb2811f2004c7e87ba5a82bd61d40"/><file name="Flags.php" hash="dcb034831717186be38530f52a39b24e"/><file name="Klarna.php" hash="7179469796b1b63dcd96b692dfa0b1a2"/><file name="Language.php" hash="a89d7e2d756db8ae94b5b2177507c319"/><dir name="checkoutkpm"><file name="checkouthtml.intf.php" hash="f6cc7512fbb13c0446d8492f747cd436"/><file name="threatmetrix.class.php" hash="ec5ceb6742df44623d96ce321c24fba5"/></dir><dir name="examples"><file name="activate.php" hash="3e2dbb97106ee405253330de0aa826d8"/><file name="cancelReservation.php" hash="948a933b769dea6a9684731adb471b8c"/><file name="checkOrderStatus.php" hash="1229fc0c6c96dbd81eec8d8919c4add5"/><file name="checkoutService.php" hash="fbaf5d7764d93fbc1b220e5f90518a90"/><file name="creditInvoice.php" hash="32669c3a1e52e716147ca63f0063c4a2"/><file name="creditPart.php" hash="594631f8358a32de1083ad98417feafe"/><file name="emailInvoice.php" hash="3c0d6ce69e2e33a85ea3f0e2d5c6fc7e"/><file name="fetchPClasses.php" hash="7bf7620a596da1edb52436e4f188827d"/><file name="getAddresses.php" hash="cf5eed9d9b772983f8e41a39b374c6ab"/><file name="hasAccount.php" hash="29670e02a3178df1afccbfb911474a6a"/><file name="helperFunctions.php" hash="3b25b4f51f83e156c33dadc6dcbb2097"/><file name="reserveAmount.php" hash="aa140d9548e31cade6c42a38e78f64df"/><file name="reserveOCR.php" hash="fcadfe8c99debda5a8f935b7fbc1ba4e"/><file name="returnAmount.php" hash="ef600f9a84d62fcce825f66bb1b570e2"/><file name="sendInvoice.php" hash="2e2a53099c64daeb9f06abd81af2a0f5"/><file name="splitReservation.php" hash="ec2d26bae9dae03679f5272b7782a4e1"/><file name="update.php" hash="6e1fcd9f371cc4b12caca37933a51a55"/></dir><file name="klarnaaddr.php" hash="01075b4e2dd3987ef38efaa6b1ced54b"/><file name="klarnacalc.php" hash="2df31b6126716e91eaeea90f7ab2ca87"/><file name="klarnaconfig.php" hash="369278865db177e690b6d7757ca38c07"/><file name="klarnapclass.php" hash="30c5f867b8c8febc944871e75d240e65"/><dir name="pclasses"><file name="jsonstorage.class.php" hash="04f0d90ada9fd12d5f0de6448466f798"/><file name="mysqlstorage.class.php" hash="ad2d075301d730f97c7a895a2ebb7523"/><file name="sqlstorage.class.php" hash="e00df72512eac3998710a4b2f9ea89c8"/><file name="storage.intf.php" hash="032631d1f075d1eff09ccf926ea56417"/><file name="xmlstorage.class.php" hash="a47820de9cdcfb261de0e95fc92a2a64"/></dir><dir name="transport"><dir name="xmlrpc-3.0.0.beta"><dir name="lib"><file name="xmlrpc.inc" hash="5a74ea2a831648febc9b2c8f809b252c"/><file name="xmlrpc_wrappers.inc" hash="5aa00141ead09fc5498d9a3c9fcab888"/><file name="xmlrpcs.inc" hash="158b97bda79333e9b40793d876b6e98f"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="vaimo"><dir name="klarna"><dir name="css"><file name="admin.css" hash="ef4915be839e2039fb037f29c1506d30"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="vaimo"><dir name="klarna"><file name="checkout.css" hash="7d7fe12675f4ba51ad1fd608849f06ce"/><file name="checkout_osc.css" hash="126a8d2869872306ded4aef943db809c"/><file name="global.css" hash="22b6a446e6e874e6a95608f7046eac2a"/><file name="klarnacheckout.css" hash="00c9b9ec2e2458207a7e6a8fe061529a"/><file name="klarnadefault.css" hash="30bff2ef19a5a70b4ee9a458c504870c"/><file name="product.css" hash="ef6a838858ceb0c1ef6364bb089273c0"/><dir name="vendor"><file name="bootstrap-grid.css" hash="093d2cb25f2e4d0bc80233ed70cbcb9a"/><file name="bootstrap-grid.min.css" hash="9087d9a8c2457c96b6c216fea959b298"/><file name="fontawesome.css" hash="76ca4ed8592634fb5c421b4e19c35918"/><file name="fontawesome.min.css" hash="7b7b345da453c034563dd2ac7ca9666b"/><dir name="fonts"><file name="FontAwesome.otf" hash="19231917733e2bcdf257c9be99cdbaf1"/><file name="fontawesome-webfont.eot" hash="7149833697a959306ec3012a8588dcfa"/><file name="fontawesome-webfont.svg" hash="65bcbc899f379216109acd0b6c494618"/><file name="fontawesome-webfont.ttf" hash="c4668ed2440df82d3fd2f8be9d31d07d"/><file name="fontawesome-webfont.woff" hash="d95d6f5d5ab7cfefd09651800b69bd54"/></dir></dir></dir></dir></dir><dir name="images"><dir name="vaimo"><dir name="klarna"><file name="balk_afm3.jpg" hash="8855567960bff35b1e3ba486670b5878"/><file name="icons.png" hash="7f0808d4cf63c3d43637d40a703f30fe"/></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Vaimo"><dir name="Klarna"><dir name="Block"><dir name="Adminhtml"><dir name="Pclass"><file name="List.php" hash="7c68e3ec74e5cea1b62bb0218d297089"/><file name="Update.php" hash="fd444645b9f78fc4ea65c91ee3fc0044"/></dir><dir name="Sales"><dir name="Creditmemo"><dir name="Create"><file name="Adjustments.php" hash="12074f6aabbe90f14b8d30b7f65da9dc"/></dir><file name="Totals.php" hash="f66e5ee88f95b0b4c2f032b2a4378b5d"/></dir><dir name="Invoice"><file name="Totals.php" hash="bc28f21c484fe2b4ca6d7a06da726fc3"/></dir><dir name="Order"><file name="Totals.php" hash="c80ca5283b0341964c36e70a850faaf6"/></dir></dir></dir><dir name="Catalog"><dir name="Product"><file name="Pricewidget.php" hash="a77d8ca953136f3fe9797166f8a51e93"/></dir></dir><dir name="Checkout"><file name="Fee.php" hash="1ffae1896b12e6d87fbbd2d3843fef75"/><file name="Top.php" hash="a8f9084322c1f924ef6fb4802908019d"/></dir><dir name="Form"><file name="Abstract.php" hash="da5fa0957ab2b1e3b57ca99a9323fadb"/><file name="Account.php" hash="f6bf008c1af0b93ead5b5a2577b59ea5"/><dir name="Address"><file name="Search.php" hash="439e9f9a5d9480a4356043bb73f9c9c7"/></dir><file name="Checkout.php" hash="a7e6876317a29184f07040b646b84ec7"/><file name="Invoice.php" hash="105a41b84e52b45f26f3c5de2d4bdd4a"/><dir name="Paymentplan"><file name="Information.php" hash="7c66acd887a1e3a165e3cd967d0f3331"/></dir><file name="Special.php" hash="8db5a5f33510cd32d724c6ecd6368aa2"/></dir><dir name="Info"><file name="Abstract.php" hash="b1f368a985cb611c2bb97385a313d6d7"/><file name="Account.php" hash="d302c2fc556e05858464fadd51cd4854"/><file name="Checkout.php" hash="df92291673e6bfe63ac968ad7297cca3"/><file name="Invoice.php" hash="f98adb5521f6c546c462f2e5bde31295"/><file name="Special.php" hash="e07662f39f0ff65505bfd627045c7766"/></dir><dir name="Invoice"><file name="Totals.php" hash="2437d7c7d7499d3ee2fcb7e0426ad64d"/></dir><dir name="Klarnacheckout"><file name="Autofill.php" hash="4fb4d1c806c2224d20a388b62f027e33"/><dir name="Customer"><file name="Balance.php" hash="e35153845d979d91ff79d0558e7b6c0b"/></dir><file name="Discount.php" hash="63bb0c1991030522371eb3b798055c39"/><file name="Ga.php" hash="85c7c0c08945c3470feefd60f905f7a2"/><file name="Klarnacheckout.php" hash="edf4af7c33d250c894087ad7c8a73936"/><file name="Newsletter.php" hash="ce97e11c097b0cd9696919936fa59dc6"/><file name="Othermethod.php" hash="7af2512fb570dc467fd0d240c4963417"/><file name="Reward.php" hash="98d72b6cf65070dcb4cc87a303cd8b54"/><file name="Success.php" hash="be47582d12b9b9362ac119715f3e6ea7"/></dir><dir name="Order"><file name="Totals.php" hash="2e56335ff1b4a1d6752e7336b107bd13"/></dir><dir name="Page"><dir name="Html"><file name="Logo.php" hash="fda8fc32997328feb9c7ebf15c8a51fa"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><dir name="Position"><dir name="Attribute"><file name="Set.php" hash="b47d1dff880be4e0d22f8f169f180bc3"/></dir></dir><file name="Position.php" hash="469a02a99354ae219f5b744b248c76b8"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AddressController.php" hash="4ae9ea28491b66ca7a69c3bd0646cacb"/><dir name="Adminhtml"><dir name="Klarna"><file name="MassactionController.php" hash="a5679cee64b19d9742753f2b537cdaeb"/><file name="PclassController.php" hash="96836bd2a4ae7b145d9bedbbdf20e4f5"/></dir></dir><dir name="Checkout"><file name="KlarnaController.php" hash="467d6a238cbe4593fd0d31bee3029636"/></dir><file name="LoginController.php" hash="1356e1cb1b8889bb1f8b9bdf624f96ab"/><file name="PaymentplanController.php" hash="fea9d33a5dbd5d4858ef174569dae636"/></dir><dir name="etc"><file name="config.xml" hash="758c59e6c73b01702b1d7c99adf774b0"/><file name="system.xml" hash="77b296f292066eea0c18073db115922d"/></dir><dir name="Helper"><file name="Data.php" hash="931649a11c0c9c6b290196109b62923f"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Admin"><file name="Json.php" hash="e6413eca01dc9e4e6715e518ffa59eae"/></dir></dir></dir></dir></dir><dir name="Api"><file name="Abstract.php" hash="856b33b3edda10b04f560247b8d3ca43"/><file name="Kco.php" hash="431d191a2ca99a6a97c078a900d33eba"/><file name="Rest.php" hash="98a8111a8be139e6d977fdace60c00e5"/><file name="Xmlrpc.php" hash="f95a37b0178102a56a3e3dbe8129258f"/></dir><file name="Api.php" hash="0c9a565b4909373b16c6701af7356186"/><dir name="Creditmemo"><file name="Tax.php" hash="5ea5e807daf26d1501d39708b2fdb4e8"/><file name="Total.php" hash="f6df6603a344038b332c88f5f61c585e"/></dir><file name="Cron.php" hash="2c1725cd81cd50a3c577193a58d178a9"/><dir name="Invoice"><dir name="Pdf"><file name="Total.php" hash="ad43316939aab5ff1910ebb45ab1f9e4"/></dir><file name="Tax.php" hash="b2203547b3f05d6179e7307d14b55c6d"/><file name="Total.php" hash="c2f4a2207550915e1aaa9868e6759f94"/></dir><dir name="Klarna"><file name="Abstract.php" hash="df64121d6fd494d631acc997b8d66f55"/></dir><file name="Klarna.php" hash="1352e5b163aa33f872c20981710d410d"/><dir name="Klarnacheckout"><file name="Abstract.php" hash="891e47c5367f4d921e6ffea051d1838b"/></dir><file name="Klarnacheckout.php" hash="6c000738b9ae4723711b78520b2425b6"/><file name="Observer.php" hash="d792a487f8c1d4b032a656e79307443a"/><dir name="Payment"><file name="Abstract.php" hash="20a6b0e61de17ddb456983a44cfd2bcc"/><file name="Account.php" hash="95931980dba66fc274f3acfa4df2b91a"/><file name="Checkout.php" hash="1f9a97206d5fa20e46e3174da799b5fa"/><file name="Invoice.php" hash="eef0e5ea5466469942a14d28e8507333"/><file name="Special.php" hash="53754f59a474e32f168220c795b80c2f"/></dir><file name="Pushqueue.php" hash="cb74fc4cd2e34077b8be5f45c49dac28"/><dir name="Quote"><file name="Tax.php" hash="b53f4a52d0f09afc7daeb094d6e30881"/><file name="Total.php" hash="a1442ecba3f2c49a42ff43e006057878"/></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="0a40d43403823a6053d74bd2d2f688e7"/></dir><dir name="Pushqueue"><file name="Collection.php" hash="cdbfe12d3f3d82c60c699e2e4700645b"/></dir><file name="Pushqueue.php" hash="0ccf2419c79a847f8095f9ef8ca349de"/></dir><dir name="Source"><file name="Abstract.php" hash="8d0d746d1cd2e5bc7d11350908a01585"/><file name="Allspecificcountries.php" hash="1a98316e25baeaba307b3be62364e1ca"/><file name="Apiversion.php" hash="a1be9e12b858927cbfa459509fff3647"/><file name="Capture.php" hash="c2d31ebb607202555e9905e439dbe86d"/><file name="Country.php" hash="2444140a6155e42d2e4909ae150037b7"/><file name="Customergroup.php" hash="01c6e41abac6e7105e4d290f53f68733"/><file name="Klarnalayout.php" hash="6c7b9d3a871d8cdb2a11a0cadde83f4a"/><file name="Language.php" hash="ca8bc4334348501a96f109aec5f9a01a"/><file name="Newsletter.php" hash="f1532e5ff4c7e04384e9410cbb0969fa"/><file name="Servermode.php" hash="7acd8c7bb39f640dccef12df69ed7c57"/><file name="Taxclass.php" hash="de1ebcf0027eaff23f676da569034ed7"/><file name="Yesnodefault.php" hash="a296d6a62f1f1858ac093c0d7974cf6a"/></dir><dir name="Tax"><file name="Config.php" hash="7767f6d07f63df09228ab6c496ed0c05"/></dir><dir name="Transport"><file name="Abstract.php" hash="983db79406daa52d7206245dd4140bcc"/></dir></dir><dir name="sql"><dir name="klarna_setup"><file name="mysql4-install-0.1.0.php" hash="d36b51433fd28241386594f39def3080"/><file name="mysql4-upgrade-5.1.6-5.1.7.php" hash="014a7b827a8958a94c57a0229127a427"/><file name="mysql4-upgrade-5.2.5-5.2.6.php" hash="1dd874e1a94730ab976b6187a34e6c77"/><file name="mysql4-upgrade-5.3.24-5.3.25.php" hash="ec5af38cfd42c2b2b16343546a152fd8"/><file name="mysql4-upgrade-5.3.4-5.3.5.php" hash="64ff4fc928b39153a89857169faa7c70"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name></name><channel>connect.magentocommerce.com/core</channel><min></min><max></max></package></required></dependencies>
18
  </package>