klarnapayments - Version 5.2.11

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.2.11
Comparing to
See all releases


Code changes from version 5.2.8 to 5.2.11

Files changed (42) hide show
  1. app/code/community/Vaimo/Klarna/Block/Catalog/Product/Pricewidget.php +20 -4
  2. app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Autofill.php +1 -0
  3. app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Othermethod.php +18 -0
  4. app/code/community/Vaimo/Klarna/Block/System/Config/Form/Field/Position.php +6 -0
  5. app/code/community/Vaimo/Klarna/Block/System/Config/Form/Field/Position/Attribute/Set.php +6 -0
  6. app/code/community/Vaimo/Klarna/Helper/Data.php +30 -0
  7. app/code/community/Vaimo/Klarna/Model/Adminhtml/System/Config/Backend/Admin/Json.php +1 -1
  8. app/code/community/Vaimo/Klarna/Model/Api.php +6 -4
  9. app/code/community/Vaimo/Klarna/Model/Api/Abstract.php +1 -1
  10. app/code/community/Vaimo/Klarna/Model/Api/Kco.php +80 -21
  11. app/code/community/Vaimo/Klarna/Model/Api/Rest.php +129 -20
  12. app/code/community/Vaimo/Klarna/Model/Api/Xmlrpc.php +8 -0
  13. app/code/community/Vaimo/Klarna/Model/Klarna.php +39 -1
  14. app/code/community/Vaimo/Klarna/Model/Klarna/Abstract.php +67 -1
  15. app/code/community/Vaimo/Klarna/Model/Klarnacheckout.php +53 -10
  16. app/code/community/Vaimo/Klarna/Model/Klarnacheckout/Abstract.php +1 -1
  17. app/code/community/Vaimo/Klarna/Model/Observer.php +9 -1
  18. app/code/community/Vaimo/Klarna/Model/Payment/Abstract.php +0 -1
  19. app/code/community/Vaimo/Klarna/Model/Source/Apiversion.php +6 -4
  20. app/code/community/Vaimo/Klarna/Model/Transport/Abstract.php +25 -6
  21. app/code/community/Vaimo/Klarna/controllers/Checkout/KlarnaController.php +69 -10
  22. app/code/community/Vaimo/Klarna/etc/config.xml +11 -10
  23. app/code/community/Vaimo/Klarna/etc/system.xml +21 -19
  24. app/design/frontend/base/default/layout/vaimo_klarna.xml +3 -1
  25. app/design/frontend/base/default/template/vaimo/klarna/form/children/addressresult.phtml +10 -0
  26. app/design/frontend/base/default/template/vaimo/klarna/form/paymentplan/information.phtml +1 -1
  27. app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/account-login.phtml +4 -1
  28. app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/cart.phtml +1 -1
  29. app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/othermethod.phtml +11 -2
  30. app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/shipping_method/available.phtml +26 -26
  31. app/locale/da_DK/Vaimo_Klarna.csv +3 -0
  32. app/locale/de_AT/Vaimo_Klarna.csv +4 -1
  33. app/locale/de_DE/Vaimo_Klarna.csv +4 -1
  34. app/locale/fi_FI/Vaimo_Klarna.csv +4 -1
  35. app/locale/nb_NO/Vaimo_Klarna.csv +3 -0
  36. app/locale/nl_NL/Vaimo_Klarna.csv +3 -0
  37. app/locale/nn_NO/Vaimo_Klarna.csv +7 -4
  38. app/locale/sv_SE/Vaimo_Klarna.csv +3 -0
  39. js/vaimo/klarna/klarnacheckout.js +633 -585
  40. js/vaimo/klarna/klarnautils.js +11 -6
  41. package.xml +4 -4
  42. skin/frontend/base/default/css/vaimo/klarna/klarnacheckout.css +5 -0
app/code/community/Vaimo/Klarna/Block/Catalog/Product/Pricewidget.php CHANGED
@@ -70,10 +70,14 @@ class Vaimo_Klarna_Block_Catalog_Product_Pricewidget extends Mage_Core_Block_Tem
70
  } else {
71
  $klarna = Mage::getModel('klarna/klarna');
72
  $klarna->setQuote($this->getQuote(), Vaimo_Klarna_Helper_Data::KLARNA_METHOD_ACCOUNT);
73
- if ($klarna->getConfigData('disable_product_widget')) {
74
  $activef = false;
75
  } else {
76
- $klarnaSetup = $klarna->getKlarnaSetup();
 
 
 
 
77
  }
78
  }
79
  if ($activef) {
@@ -91,10 +95,22 @@ class Vaimo_Klarna_Block_Catalog_Product_Pricewidget extends Mage_Core_Block_Tem
91
  return Mage::helper('klarna')->getVaimoKlarnaFeeInclVat($this->getQuote(), false);
92
  }
93
 
94
- public function getProductPriceInclVat()
95
  {
96
  // @TODO This only returns Incl TAX if settings are set to Display prices including TAX... Needs to be Incl VAT, always
97
- return Mage::helper('tax')->getPrice($this->getProduct(), $this->getProduct()->getFinalPrice(), true);
 
 
 
 
 
 
 
 
 
 
 
 
98
  }
99
 
100
  }
70
  } else {
71
  $klarna = Mage::getModel('klarna/klarna');
72
  $klarna->setQuote($this->getQuote(), Vaimo_Klarna_Helper_Data::KLARNA_METHOD_ACCOUNT);
73
+ if (!$this->getConfigData('active')) {
74
  $activef = false;
75
  } else {
76
+ if ($klarna->getConfigData('disable_product_widget')) {
77
+ $activef = false;
78
+ } else {
79
+ $klarnaSetup = $klarna->getKlarnaSetup();
80
+ }
81
  }
82
  }
83
  if ($activef) {
95
  return Mage::helper('klarna')->getVaimoKlarnaFeeInclVat($this->getQuote(), false);
96
  }
97
 
98
+ public function getProductPriceInclVat($store = NULL)
99
  {
100
  // @TODO This only returns Incl TAX if settings are set to Display prices including TAX... Needs to be Incl VAT, always
101
+ // return Mage::helper('tax')->getPrice($this->getProduct(), $this->getProduct()->getFinalPrice(), true);
102
+ $product = $this->getProduct();
103
+ $res = $product->getFinalPrice();
104
+ $inclTax = Mage::getSingleton('tax/config')->priceIncludesTax($store);
105
+ if (!$inclTax) {
106
+ $taxClassId = $product->getTaxClassId();
107
+ $request = Mage::getSingleton('tax/calculation')
108
+ ->getRateRequest(false, false, false, $store);
109
+ $includingPercent = Mage::getSingleton('tax/calculation')
110
+ ->getRate($request->setProductClassId($taxClassId));
111
+ $res = Mage::app()->getStore()->roundPrice($res * (1 + ($includingPercent / 100)));
112
+ }
113
+ return $res;
114
  }
115
 
116
  }
app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Autofill.php CHANGED
@@ -47,6 +47,7 @@ class Vaimo_Klarna_Block_Klarnacheckout_Autofill extends Mage_Core_Block_Templat
47
  }
48
  return $res;
49
  }
 
50
  public function getTermsLink()
51
  {
52
  try {
47
  }
48
  return $res;
49
  }
50
+
51
  public function getTermsLink()
52
  {
53
  try {
app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Othermethod.php CHANGED
@@ -86,4 +86,22 @@ class Vaimo_Klarna_Block_Klarnacheckout_Othermethod extends Mage_Core_Block_Temp
86
 
87
  return $res;
88
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
86
 
87
  return $res;
88
  }
89
+
90
+ /**
91
+ * Should not have been in here, but didn't want to create a new block for this one
92
+ * function. So I added it here instead, as it's being loaded at the same time...
93
+ */
94
+ public function updateWhenPostcodeChanges()
95
+ {
96
+ try {
97
+ $klarna = Mage::getModel('klarna/klarnacheckout');
98
+ $klarna->setQuote($this->getQuote(), Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
99
+ $res = $klarna->getConfigData('enable_postcode_update');
100
+ } catch (Exception $e) {
101
+ $res = false;
102
+ }
103
+
104
+ return $res;
105
+ }
106
+
107
  }
app/code/community/Vaimo/Klarna/Block/System/Config/Form/Field/Position.php CHANGED
@@ -23,6 +23,12 @@
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
25
 
 
 
 
 
 
 
26
  class Vaimo_Klarna_Block_System_Config_Form_Field_Position extends Mage_Core_Block_Html_Select
27
  {
28
  public function getOptions()
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
25
 
26
+ /**
27
+ * This function is no longer used! It will not be removed, as it was once used as a frontend model
28
+ * If an attribute exists that has this as it's frontend model it will cause a crash if removed
29
+ *
30
+ */
31
+
32
  class Vaimo_Klarna_Block_System_Config_Form_Field_Position extends Mage_Core_Block_Html_Select
33
  {
34
  public function getOptions()
app/code/community/Vaimo/Klarna/Block/System/Config/Form/Field/Position/Attribute/Set.php CHANGED
@@ -22,6 +22,12 @@
22
  * @package Vaimo_Klarna
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
 
 
 
 
 
 
25
 
26
  class Vaimo_Klarna_Block_System_Config_Form_Field_Position_Attribute_Set extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
27
  {
22
  * @package Vaimo_Klarna
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
25
+
26
+ /**
27
+ * This function is no longer used! It will not be removed, as it was once used as a frontend model
28
+ * If an attribute exists that has this as it's frontend model it will cause a crash if removed
29
+ *
30
+ */
31
 
32
  class Vaimo_Klarna_Block_System_Config_Form_Field_Position_Attribute_Set extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
33
  {
app/code/community/Vaimo/Klarna/Helper/Data.php CHANGED
@@ -113,11 +113,18 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
113
  const KLARNA_DISPATCH_CAPTURED = 'vaimo_paymentmethod_order_captured';
114
  const KLARNA_DISPATCH_REFUNDED = 'vaimo_paymentmethod_order_refunded';
115
  const KLARNA_DISPATCH_CANCELED = 'vaimo_paymentmethod_order_canceled';
 
 
 
116
 
117
  const KLARNA_EXTRA_VARIABLES_GUI_OPTIONS = 0;
118
  const KLARNA_EXTRA_VARIABLES_GUI_LAYOUT = 1;
119
  const KLARNA_EXTRA_VARIABLES_OPTIONS = 2;
120
 
 
 
 
 
121
 
122
  protected $_supportedMethods = array(
123
  Vaimo_Klarna_Helper_Data::KLARNA_METHOD_INVOICE,
@@ -262,6 +269,11 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
262
  return true;
263
  }
264
 
 
 
 
 
 
265
  /**
266
  * Check if OneStepCheckout is activated or not
267
  * It also checks if OneStepCheckout is activated, but it's currently using
@@ -787,6 +799,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
787
  public function logKlarnaApi($comment)
788
  {
789
  $this->_log('klarnaapi.log', $comment);
 
790
  }
791
 
792
  /**
@@ -833,5 +846,22 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
833
  if ($e->getFile()) $errstr = $errstr . ' File: ' . $e->getFile();
834
  $this->_logAlways('klarnaerror.log', $errstr);
835
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
836
 
837
  }
113
  const KLARNA_DISPATCH_CAPTURED = 'vaimo_paymentmethod_order_captured';
114
  const KLARNA_DISPATCH_REFUNDED = 'vaimo_paymentmethod_order_refunded';
115
  const KLARNA_DISPATCH_CANCELED = 'vaimo_paymentmethod_order_canceled';
116
+
117
+ const KLARNA_LOG_START_TAG = '---------------START---------------';
118
+ const KLARNA_LOG_END_TAG = '----------------END----------------';
119
 
120
  const KLARNA_EXTRA_VARIABLES_GUI_OPTIONS = 0;
121
  const KLARNA_EXTRA_VARIABLES_GUI_LAYOUT = 1;
122
  const KLARNA_EXTRA_VARIABLES_OPTIONS = 2;
123
 
124
+ const KLARNA_KCO_API_VERSION_STD = 2;
125
+ const KLARNA_KCO_API_VERSION_UK = 3;
126
+ const KLARNA_KCO_API_VERSION_USA = 4;
127
+
128
 
129
  protected $_supportedMethods = array(
130
  Vaimo_Klarna_Helper_Data::KLARNA_METHOD_INVOICE,
269
  return true;
270
  }
271
 
272
+ public function isShippingInclTax($storeId)
273
+ {
274
+ return Mage::getSingleton('tax/config')->displaySalesShippingInclTax($storeId);
275
+ }
276
+
277
  /**
278
  * Check if OneStepCheckout is activated or not
279
  * It also checks if OneStepCheckout is activated, but it's currently using
799
  public function logKlarnaApi($comment)
800
  {
801
  $this->_log('klarnaapi.log', $comment);
802
+ $this->logDebugInfo($comment);
803
  }
804
 
805
  /**
846
  if ($e->getFile()) $errstr = $errstr . ' File: ' . $e->getFile();
847
  $this->_logAlways('klarnaerror.log', $errstr);
848
  }
849
+
850
+ public function getDefaultCountry($store = NULL)
851
+ {
852
+ /* For shipping this should be called...
853
+ $taxCalculationModel = Mage::getSingleton('tax/calculation');
854
+ $request = $taxCalculationModel->getRateRequest();
855
+ x = $request->getCountryId();
856
+ y = $request->getRegionId();
857
+ z = $request->getPostcode();
858
+ */
859
+ if (version_compare(Mage::getVersion(), '1.6.2', '>=')) {
860
+ $res = Mage::helper('core')->getDefaultCountry($store);
861
+ } else {
862
+ $res = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_COUNTRY, $store);
863
+ }
864
+ return $res;
865
+ }
866
 
867
  }
app/code/community/Vaimo/Klarna/Model/Adminhtml/System/Config/Backend/Admin/Json.php CHANGED
@@ -34,7 +34,7 @@ class Vaimo_Klarna_Model_Adminhtml_System_Config_Backend_Admin_Json extends Mage
34
  protected function _beforeSave()
35
  {
36
  $json = $this->getValue();
37
- if ($json) {
38
  $extras = Mage::helper('klarna')->JsonDecode($json);
39
  if (!is_array($extras)) {
40
  Mage::throwException(Mage::helper('klarna')->__('JSON string not valid') . ': ' . $extras);
34
  protected function _beforeSave()
35
  {
36
  $json = $this->getValue();
37
+ if ($json && $json != " ") { // Allow for people to add a space in the textfield, to make it "empty"
38
  $extras = Mage::helper('klarna')->JsonDecode($json);
39
  if (!is_array($extras)) {
40
  Mage::throwException(Mage::helper('klarna')->__('JSON string not valid') . ': ' . $extras);
app/code/community/Vaimo/Klarna/Model/Api.php CHANGED
@@ -43,9 +43,9 @@ class Vaimo_Klarna_Model_Api extends Varien_Object
43
  /**
44
  * @return Vaimo_Klarna_Model_Api_Rest
45
  */
46
- protected function _getKlarnaCheckOutRestApiForUK()
47
  {
48
- return Mage::getSingleton('klarna/api_rest');
49
  }
50
 
51
  /**
@@ -82,8 +82,10 @@ class Vaimo_Klarna_Model_Api extends Varien_Object
82
  return $this->_getKlarnaPaymentMethodXmlRpcApi();
83
  break;
84
  case Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT:
85
- if ($this->_getKlarnaCheckOutApiVersion($storeId) == 3) {
86
- return $this->_getKlarnaCheckOutRestApiForUK();
 
 
87
  } else {
88
  switch ($call) {
89
  case Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_RESERVE:
43
  /**
44
  * @return Vaimo_Klarna_Model_Api_Rest
45
  */
46
+ protected function _getKlarnaCheckOutRestApi($apiVersion)
47
  {
48
+ return Mage::getSingleton('klarna/api_rest')->setApiVersion($apiVersion);
49
  }
50
 
51
  /**
82
  return $this->_getKlarnaPaymentMethodXmlRpcApi();
83
  break;
84
  case Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT:
85
+ $apiVersion = $this->_getKlarnaCheckOutApiVersion($storeId);
86
+ if ($apiVersion == Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_UK ||
87
+ $apiVersion == Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_USA) {
88
+ return $this->_getKlarnaCheckOutRestApi($apiVersion);
89
  } else {
90
  switch ($call) {
91
  case Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_RESERVE:
app/code/community/Vaimo/Klarna/Model/Api/Abstract.php CHANGED
@@ -62,7 +62,7 @@ abstract class Vaimo_Klarna_Model_Api_Abstract extends Varien_Object
62
  protected function _addUserDefinedVariables(&$create)
63
  {
64
  $json = $this->_getTransport()->getConfigData('user_defined_json');
65
- if ($json) {
66
  $extras = Mage::helper('klarna')->JsonDecode($json);
67
  if (is_array($extras)) {
68
  $create = array_merge_recursive($create, $extras);
62
  protected function _addUserDefinedVariables(&$create)
63
  {
64
  $json = $this->_getTransport()->getConfigData('user_defined_json');
65
+ if ($json && $json != " ") {
66
  $extras = Mage::helper('klarna')->JsonDecode($json);
67
  if (is_array($extras)) {
68
  $create = array_merge_recursive($create, $extras);
app/code/community/Vaimo/Klarna/Model/Api/Kco.php CHANGED
@@ -75,7 +75,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
75
  {
76
  $quote = $this->_getQuote();
77
 
78
- if ($quote->getKlarnaCheckoutId() != $checkoutId) {
79
  Mage::helper('klarna')->logDebugInfo('SET checkout id: ' . $checkoutId);
80
  Mage::helper('klarna')->logDebugInfo('Quote Id: ' . $quote->getId());
81
  $quote->setKlarnaCheckoutId($checkoutId);
@@ -116,14 +116,13 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
116
  case 'shipping':
117
  if ($total->getValue() != 0) {
118
  $amount_incl_tax = $total->getAddress()->getShippingInclTax();
119
- if (false && $amount_incl_tax) {
120
- $taxAmount = $total->getAddress()->getShippingTaxAmount();
121
- $amount = $amount_incl_tax - $taxAmount;
122
- } else {
123
- $amount = $total->getAddress()->getShippingAmount();
124
- $taxAmount = $total->getAddress()->getShippingTaxAmount();
125
- }
126
  $hiddenTaxAmount = $total->getAddress()->getShippingHiddenTaxAmount();
 
 
 
 
127
  $taxRate = ($taxAmount + $hiddenTaxAmount) / $amount * 100;
128
  $amount_incl_tax = $amount + $taxAmount + $hiddenTaxAmount;
129
  $items[] = array(
@@ -223,11 +222,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
223
  protected function _getCreateRequest()
224
  {
225
  $create = array();
226
- if (version_compare(Mage::getVersion(), '1.6.2', '>=')) {
227
- $create['purchase_country'] = Mage::helper('core')->getDefaultCountry();
228
- } else {
229
- $create['purchase_country'] = Mage::getStoreConfig('general/country/default');
230
- }
231
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
232
  $create['locale'] = str_replace('_', '-', Mage::app()->getLocale()->getLocaleCode());
233
  $create['merchant']['id'] = $this->_klarnaSetup->getMerchantId();
@@ -270,7 +265,11 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
270
  if ($data = $this->_getBillingAddressData()) {
271
  $create['shipping_address'] = $data;
272
  }
273
-
 
 
 
 
274
  Mage::helper('klarna')->logDebugInfo('_getCreateRequest', $create);
275
  $request = new Varien_Object($create);
276
  Mage::dispatchEvent('klarnacheckout_get_create_request', array('request' => $request));
@@ -293,6 +292,10 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
293
  $update['shipping_address'] = $data;
294
  }
295
 
 
 
 
 
296
  Mage::helper('klarna')->logDebugInfo('_getUpdateRequest', $update);
297
  $request = new Varien_Object($update);
298
  Mage::dispatchEvent('klarnacheckout_get_update_request', array('request' => $request));
@@ -308,14 +311,66 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
308
  $session = Mage::getSingleton('customer/session');
309
  if ($session->isLoggedIn()) {
310
  $address = $session->getCustomer()->getPrimaryBillingAddress();
311
- $result = array(
312
- 'email' => $session->getCustomer()->getEmail(),
313
- 'postal_code' => $address ? $address->getPostcode() : '',
314
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  return $result;
316
  }
317
 
318
- return array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  }
320
 
321
  public function init($klarnaSetup)
@@ -508,10 +563,14 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
508
  return NULL;
509
  }
510
 
511
- public function updateKlarnaOrder($order)
512
  {
513
  if ($this->_klarnaOrder) {
514
- Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder order no: ' . $order->getIncrementId());
 
 
 
 
515
  // Update Klarna
516
  $update = array(
517
  'status' => 'created',
75
  {
76
  $quote = $this->_getQuote();
77
 
78
+ if ($quote->getId() && $quote->getKlarnaCheckoutId() != $checkoutId) {
79
  Mage::helper('klarna')->logDebugInfo('SET checkout id: ' . $checkoutId);
80
  Mage::helper('klarna')->logDebugInfo('Quote Id: ' . $quote->getId());
81
  $quote->setKlarnaCheckoutId($checkoutId);
116
  case 'shipping':
117
  if ($total->getValue() != 0) {
118
  $amount_incl_tax = $total->getAddress()->getShippingInclTax();
119
+ $amount = $total->getAddress()->getShippingAmount();
120
+ $taxAmount = $total->getAddress()->getShippingTaxAmount();
 
 
 
 
 
121
  $hiddenTaxAmount = $total->getAddress()->getShippingHiddenTaxAmount();
122
+ //if (Mage::helper('klarna')->isShippingInclTax($quote->getStoreId())) {
123
+ if (($amount_incl_tax>0) && (round($amount_incl_tax,2) == round($amount,2))) {
124
+ $amount = $amount - $taxAmount - $hiddenTaxAmount;
125
+ }
126
  $taxRate = ($taxAmount + $hiddenTaxAmount) / $amount * 100;
127
  $amount_incl_tax = $amount + $taxAmount + $hiddenTaxAmount;
128
  $items[] = array(
222
  protected function _getCreateRequest()
223
  {
224
  $create = array();
225
+ $create['purchase_country'] = Mage::helper('klarna')->getDefaultCountry();
 
 
 
 
226
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
227
  $create['locale'] = str_replace('_', '-', Mage::app()->getLocale()->getLocaleCode());
228
  $create['merchant']['id'] = $this->_klarnaSetup->getMerchantId();
265
  if ($data = $this->_getBillingAddressData()) {
266
  $create['shipping_address'] = $data;
267
  }
268
+
269
+ if ($data = $this->_getCustomerData()) {
270
+ $create['customer'] = $data;
271
+ }
272
+
273
  Mage::helper('klarna')->logDebugInfo('_getCreateRequest', $create);
274
  $request = new Varien_Object($create);
275
  Mage::dispatchEvent('klarnacheckout_get_create_request', array('request' => $request));
292
  $update['shipping_address'] = $data;
293
  }
294
 
295
+ if ($data = $this->_getCustomerData()) {
296
+ $update['customer'] = $data;
297
+ }
298
+
299
  Mage::helper('klarna')->logDebugInfo('_getUpdateRequest', $update);
300
  $request = new Varien_Object($update);
301
  Mage::dispatchEvent('klarnacheckout_get_update_request', array('request' => $request));
311
  $session = Mage::getSingleton('customer/session');
312
  if ($session->isLoggedIn()) {
313
  $address = $session->getCustomer()->getPrimaryBillingAddress();
314
+ if ($this->_getTransport()->moreDetailsToKCORequest()) {
315
+ if ($address &&
316
+ ( preg_match('/^([^\d]*[^\d\s]) *(\d.*)$/', $address->getStreet(1), $result) )) {
317
+ $streetName = $result[1];
318
+ $streetNumber = $result[2];
319
+ }
320
+
321
+ if ($gender = $session->getCustomer()->getGender()) {
322
+ switch ($gender) {
323
+ case 1:
324
+ $gender = Mage::helper('klarna')->__('Male');
325
+ break;
326
+ case 2:
327
+ $gender = Mage::helper('klarna')->__('Female');
328
+ break;
329
+ }
330
+ }
331
+
332
+ $result = array(
333
+ 'email' => $session->getCustomer()->getEmail(),
334
+ 'postal_code' => $address ? $address->getPostcode() : '',
335
+ 'street_name' => $address ? $streetName : '',
336
+ 'street_number' => $address ? $streetNumber : '',
337
+ 'given_name' => $address ? $address->getFirstname() : '',
338
+ 'family_name' => $address ? $address->getLastname() : '',
339
+ 'city' => $address ? $address->getCity() : '',
340
+ 'phone' => $address ? $address->getTelephone() : '',
341
+ 'country' => $address ? $address->getCountryId() : '',
342
+ 'title' => $gender
343
+ );
344
+ } else {
345
+ $result = array(
346
+ 'email' => $session->getCustomer()->getEmail(),
347
+ 'postal_code' => $address ? $address->getPostcode() : '',
348
+ );
349
+ }
350
  return $result;
351
  }
352
 
353
+ return NULL;
354
+ }
355
+
356
+ protected function _getCustomerData()
357
+ {
358
+ if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
359
+
360
+ /** @var $session Mage_Customer_Model_Session */
361
+ $session = Mage::getSingleton('customer/session');
362
+ if ($session->isLoggedIn()) {
363
+ if ($this->_getTransport()->needDateOfBirth()) {
364
+ if ($session->getCustomer()->getDob()) {
365
+ $result = array(
366
+ 'date_of_birth' => substr($session->getCustomer()->getDob(),0,10),
367
+ );
368
+ return $result;
369
+ }
370
+ }
371
+ }
372
+
373
+ return NULL;
374
  }
375
 
376
  public function init($klarnaSetup)
563
  return NULL;
564
  }
565
 
566
+ public function updateKlarnaOrder($order, $repeatCall = false)
567
  {
568
  if ($this->_klarnaOrder) {
569
+ if ($repeatCall) {
570
+ Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder AGAIN for order no: ' . $order->getIncrementId());
571
+ } else {
572
+ Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder order no: ' . $order->getIncrementId());
573
+ }
574
  // Update Klarna
575
  $update = array(
576
  'status' => 'created',
app/code/community/Vaimo/Klarna/Model/Api/Rest.php CHANGED
@@ -31,14 +31,36 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
31
  protected $_klarnaOrder = null;
32
  protected $_useKlarnaOrderSessionCache = false;
33
  protected $_request = NULL;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  public function init($klarnaSetup)
36
  {
37
  $this->_klarnaSetup = $klarnaSetup;
38
  if ($this->_klarnaSetup->getHost() == 'BETA') {
39
- $this->_url = 'https://api.playground.klarna.com';
 
 
 
 
40
  } else {
41
- $this->_url = 'https://api.klarna.com';
 
 
 
 
42
  }
43
  }
44
 
@@ -80,7 +102,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
80
  $session = Mage::getSingleton('customer/session');
81
  if ($session->isLoggedIn()) {
82
  $address = $session->getCustomer()->getPrimaryBillingAddress();
83
- return array(
84
  'email' => $session->getCustomer()->getEmail(),
85
  'postal_code' => $address ? $address->getPostcode() : '',
86
  'street_address' => $address ? $address->getStreet(1) : '',
@@ -90,11 +112,35 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
90
  'phone' => $address ? $address->getTelephone() : '',
91
  'country' => $address ? $address->getCountryId() : '',
92
  );
 
 
 
 
93
  }
94
 
95
- return array();
96
  }
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  /**
99
  * Get active Klarna checkout id
100
  *
@@ -114,7 +160,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
114
  {
115
  $quote = $this->_getQuote();
116
 
117
- if ($quote->getKlarnaCheckoutId() != $checkoutId) {
118
  Mage::helper('klarna')->logDebugInfo('SET checkout id rest: ' . $checkoutId);
119
  Mage::helper('klarna')->logDebugInfo('Quote Id rest: ' . $quote->getId());
120
  $quote->setKlarnaCheckoutId($checkoutId);
@@ -156,14 +202,13 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
156
  case 'shipping':
157
  if ($total->getValue() != 0) {
158
  $amount_incl_tax = $total->getAddress()->getShippingInclTax();
159
- if (false && $amount_incl_tax) {
160
- $taxAmount = $total->getAddress()->getShippingTaxAmount();
161
- $amount = $amount_incl_tax - $taxAmount;
162
- } else {
163
- $amount = $total->getAddress()->getShippingAmount();
164
- $taxAmount = $total->getAddress()->getShippingTaxAmount();
165
- }
166
  $hiddenTaxAmount = $total->getAddress()->getShippingHiddenTaxAmount();
 
 
 
 
167
  $taxRate = ($taxAmount + $hiddenTaxAmount) / $amount * 100;
168
  $amount_incl_tax = $amount + $taxAmount + $hiddenTaxAmount;
169
  $items[] = array(
@@ -270,11 +315,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
270
  protected function _getCreateRequest()
271
  {
272
  $create = array();
273
- if (version_compare(Mage::getVersion(), '1.6.2', '>=')) {
274
- $create['purchase_country'] = Mage::helper('core')->getDefaultCountry();
275
- } else {
276
- $create['purchase_country'] = Mage::getStoreConfig('general/country/default');
277
- }
278
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
279
  $create['locale'] = str_replace('_', '-', Mage::app()->getLocale()->getLocaleCode());
280
 
@@ -298,6 +339,10 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
298
  $create['billing_address'] = $data;
299
  }
300
 
 
 
 
 
301
  $create['order_amount'] = round($this->_getQuote()->getGrandTotal() * 100);
302
  $create['order_tax_amount'] = 0;
303
  $create['order_lines'] = $this->_getCartItems();
@@ -305,13 +350,55 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
305
  foreach ($create['order_lines'] as $line) {
306
  $create['order_tax_amount'] += $line['total_tax_amount'];
307
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
 
309
  $pushUrl = Mage::getUrl('checkout/klarna/push?klarna_order={checkout.order.id}', array('_nosid' => true));
310
  if (substr($pushUrl, -1, 1) == '/') {
311
  $pushUrl = substr($pushUrl, 0, strlen($pushUrl) - 1);
312
  }
313
 
314
- $create['merchant_urls']['terms'] = Mage::getUrl(Mage::getStoreConfig('payment/vaimo_klarna_checkout/terms_url'));
315
  $create['merchant_urls']['checkout'] = Mage::getUrl('checkout/klarna');
316
  $create['merchant_urls']['confirmation'] = Mage::getUrl('checkout/klarna/success');
317
  $create['merchant_urls']['push'] = $pushUrl;
@@ -323,6 +410,9 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
323
  if (substr($validateUrl, 0, 5) == 'https') {
324
  $create['merchant']['validation_uri'] = $validateUrl;
325
  }
 
 
 
326
 
327
  Mage::helper('klarna')->logDebugInfo('_getCreateRequest rest', $create);
328
 
@@ -340,6 +430,10 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
340
  $update['billing_address'] = $data;
341
  }
342
 
 
 
 
 
343
  $update['order_amount'] = round($this->_getQuote()->getGrandTotal() * 100);
344
  $update['order_tax_amount'] = 0;
345
  $update['order_lines'] = $this->_getCartItems();
@@ -742,6 +836,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
742
  }
743
 
744
  if ($createIfNotExists) {
 
745
  if ($checkoutId = $this->_createOrder()) {
746
  $this->_fetchOrder($checkoutId);
747
  $res = $this->_klarnaOrder!=NULL;
@@ -750,6 +845,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
750
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId()); // $location
751
  }
752
  }
 
753
  return $res;
754
  }
755
  }
@@ -812,10 +908,15 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
812
  * @param Mage_Sales_Model_Order $order
813
  * @return bool
814
  */
815
- public function updateKlarnaOrder($order)
816
  {
817
  if ($this->_klarnaOrder) {
818
- Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder rest order no: ' . $order->getIncrementId());
 
 
 
 
 
819
  $this->_acknowledgeOrder($this->_klarnaOrder->getOrderId());
820
  $this->_updateMerchantReferences($this->_klarnaOrder->getOrderId(), $order->getIncrementId());
821
  Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder rest success');
@@ -901,4 +1002,12 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
901
  public function setAddresses($billingAddress, $shippingAddress, $data)
902
  {
903
  }
 
 
 
 
 
 
 
 
904
  }
31
  protected $_klarnaOrder = null;
32
  protected $_useKlarnaOrderSessionCache = false;
33
  protected $_request = NULL;
34
+ protected $_apiVersion = NULL;
35
+
36
+ /**
37
+ * Would have been solved better with two separate files, inheriting Rest.php
38
+ * But, this works as well
39
+ *
40
+ * @param $apiVersion
41
+ * @return $this
42
+ */
43
+ public function setApiVersion($apiVersion)
44
+ {
45
+ $this->_apiVersion = $apiVersion;
46
+ return $this;
47
+ }
48
 
49
  public function init($klarnaSetup)
50
  {
51
  $this->_klarnaSetup = $klarnaSetup;
52
  if ($this->_klarnaSetup->getHost() == 'BETA') {
53
+ if ($this->_apiVersion == Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_USA) {
54
+ $this->_url = 'https://api-na.playground.klarna.com';
55
+ } else {
56
+ $this->_url = 'https://api.playground.klarna.com';
57
+ }
58
  } else {
59
+ if ($this->_apiVersion == Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_USA) {
60
+ $this->_url = 'https://api-na.klarna.com';
61
+ } else {
62
+ $this->_url = 'https://api.klarna.com';
63
+ }
64
  }
65
  }
66
 
102
  $session = Mage::getSingleton('customer/session');
103
  if ($session->isLoggedIn()) {
104
  $address = $session->getCustomer()->getPrimaryBillingAddress();
105
+ $res = array(
106
  'email' => $session->getCustomer()->getEmail(),
107
  'postal_code' => $address ? $address->getPostcode() : '',
108
  'street_address' => $address ? $address->getStreet(1) : '',
112
  'phone' => $address ? $address->getTelephone() : '',
113
  'country' => $address ? $address->getCountryId() : '',
114
  );
115
+ if ($address->getRegionCode()) {
116
+ $res['region'] = $address->getRegionCode();
117
+ }
118
+ return $res;
119
  }
120
 
121
+ return NULL;
122
  }
123
 
124
+ protected function _getCustomerData()
125
+ {
126
+ if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
127
+
128
+ /** @var $session Mage_Customer_Model_Session */
129
+ $session = Mage::getSingleton('customer/session');
130
+ if ($session->isLoggedIn()) {
131
+ if ($this->_getTransport()->needDateOfBirth()) {
132
+ if ($session->getCustomer()->getDob()) {
133
+ $result = array(
134
+ 'date_of_birth' => substr($session->getCustomer()->getDob(),0,10),
135
+ );
136
+ return $result;
137
+ }
138
+ }
139
+ }
140
+
141
+ return NULL;
142
+ }
143
+
144
  /**
145
  * Get active Klarna checkout id
146
  *
160
  {
161
  $quote = $this->_getQuote();
162
 
163
+ if ($quote->getId() && $quote->getKlarnaCheckoutId() != $checkoutId) {
164
  Mage::helper('klarna')->logDebugInfo('SET checkout id rest: ' . $checkoutId);
165
  Mage::helper('klarna')->logDebugInfo('Quote Id rest: ' . $quote->getId());
166
  $quote->setKlarnaCheckoutId($checkoutId);
202
  case 'shipping':
203
  if ($total->getValue() != 0) {
204
  $amount_incl_tax = $total->getAddress()->getShippingInclTax();
205
+ $amount = $total->getAddress()->getShippingAmount();
206
+ $taxAmount = $total->getAddress()->getShippingTaxAmount();
 
 
 
 
 
207
  $hiddenTaxAmount = $total->getAddress()->getShippingHiddenTaxAmount();
208
+ //if (Mage::helper('klarna')->isShippingInclTax($quote->getStoreId())) {
209
+ if (($amount_incl_tax>0) && (round($amount_incl_tax,2) == round($amount,2))) {
210
+ $amount = $amount - $taxAmount - $hiddenTaxAmount;
211
+ }
212
  $taxRate = ($taxAmount + $hiddenTaxAmount) / $amount * 100;
213
  $amount_incl_tax = $amount + $taxAmount + $hiddenTaxAmount;
214
  $items[] = array(
315
  protected function _getCreateRequest()
316
  {
317
  $create = array();
318
+ $create['purchase_country'] = Mage::helper('klarna')->getDefaultCountry();
 
 
 
 
319
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
320
  $create['locale'] = str_replace('_', '-', Mage::app()->getLocale()->getLocaleCode());
321
 
339
  $create['billing_address'] = $data;
340
  }
341
 
342
+ if ($data = $this->_getCustomerData()) {
343
+ $create['customer'] = $data;
344
+ }
345
+
346
  $create['order_amount'] = round($this->_getQuote()->getGrandTotal() * 100);
347
  $create['order_tax_amount'] = 0;
348
  $create['order_lines'] = $this->_getCartItems();
350
  foreach ($create['order_lines'] as $line) {
351
  $create['order_tax_amount'] += $line['total_tax_amount'];
352
  }
353
+ if ($this->_apiVersion == Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_USA) {
354
+ $shippingCountries = $this->_getTransport()->getConfigData('shipping_countries');
355
+ if ($shippingCountries) {
356
+ $create['shipping_countries'] = explode(',', $shippingCountries);
357
+ }
358
+ }
359
+ if (false) {
360
+ $shippingOptions = array();
361
+ $address = $this->_getQuote()->getShippingAddress();
362
+ $originalShippingMethod = $address->getShippingMethod();
363
+ $methods = Mage::getModel('checkout/cart_shipping_api')->getShippingMethodsList($this->_getQuote()->getId());
364
+ foreach ($methods as $method) {
365
+ $address->setShippingMethod($method['code']);
366
+ $this->_getQuote()->setTotalsCollectedFlag(false)->collectTotals();
367
+ if ($address->getShippingAmount()>0) {
368
+ $taxRate = ($address->getShippingAmount + $address->getShippingTaxAmount()) / $address->getShippingAmount() * 100;
369
+ } else {
370
+ $taxRate = 0;
371
+ }
372
+ if ($method['code']==$originalShippingMethod) {
373
+ $preSelected = true;
374
+ } else {
375
+ $preSelected = false;
376
+ }
377
+ $shippingOptions[] = array(
378
+ 'id' => $method['code'],
379
+ 'name' => $method['method_title'],
380
+ 'description' => $method['carrier_title'],
381
+ 'price' => (int)($address->getShippingAmount() + $address->getShippingTaxAmount()) * 100,
382
+ 'tax_amount' => (int)$address->getShippingTaxAmount() * 100,
383
+ 'tax_rate' => (int)($taxRate * 100) * 100,
384
+ 'preselected' => $preSelected,
385
+ );
386
+ }
387
+ $address->setShippingMethod($originalShippingMethod);
388
+ $this->_getQuote()->setTotalsCollectedFlag(false)->collectTotals();
389
+ $create['shipping_options'] = $shippingOptions;
390
+ $create['selected_shipping_option'] = array(
391
+ 'id' => $address->getShippingMethod(),
392
+ 'name' => $address->getShippingDescription(),
393
+ );
394
+ }
395
 
396
  $pushUrl = Mage::getUrl('checkout/klarna/push?klarna_order={checkout.order.id}', array('_nosid' => true));
397
  if (substr($pushUrl, -1, 1) == '/') {
398
  $pushUrl = substr($pushUrl, 0, strlen($pushUrl) - 1);
399
  }
400
 
401
+ $create['merchant_urls']['terms'] = Mage::getUrl($this->_getTransport()->getConfigData('terms_url'));
402
  $create['merchant_urls']['checkout'] = Mage::getUrl('checkout/klarna');
403
  $create['merchant_urls']['confirmation'] = Mage::getUrl('checkout/klarna/success');
404
  $create['merchant_urls']['push'] = $pushUrl;
410
  if (substr($validateUrl, 0, 5) == 'https') {
411
  $create['merchant']['validation_uri'] = $validateUrl;
412
  }
413
+ if ($this->_apiVersion == Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_USA) {
414
+ $create['merchant_urls']['shipping_address_update'] = Mage::getUrl('checkout/klarna/shippingupdate');
415
+ }
416
 
417
  Mage::helper('klarna')->logDebugInfo('_getCreateRequest rest', $create);
418
 
430
  $update['billing_address'] = $data;
431
  }
432
 
433
+ if ($data = $this->_getCustomerData()) {
434
+ $update['customer'] = $data;
435
+ }
436
+
437
  $update['order_amount'] = round($this->_getQuote()->getGrandTotal() * 100);
438
  $update['order_tax_amount'] = 0;
439
  $update['order_lines'] = $this->_getCartItems();
836
  }
837
 
838
  if ($createIfNotExists) {
839
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder create');
840
  if ($checkoutId = $this->_createOrder()) {
841
  $this->_fetchOrder($checkoutId);
842
  $res = $this->_klarnaOrder!=NULL;
845
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId()); // $location
846
  }
847
  }
848
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
849
  return $res;
850
  }
851
  }
908
  * @param Mage_Sales_Model_Order $order
909
  * @return bool
910
  */
911
+ public function updateKlarnaOrder($order, $repeatCall = false)
912
  {
913
  if ($this->_klarnaOrder) {
914
+ if ($repeatCall) {
915
+ Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder AGAIN for rest order no: ' . $order->getIncrementId());
916
+ } else {
917
+ Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder rest order no: ' . $order->getIncrementId());
918
+ }
919
+
920
  $this->_acknowledgeOrder($this->_klarnaOrder->getOrderId());
921
  $this->_updateMerchantReferences($this->_klarnaOrder->getOrderId(), $order->getIncrementId());
922
  Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder rest success');
1002
  public function setAddresses($billingAddress, $shippingAddress, $data)
1003
  {
1004
  }
1005
+
1006
+ public function setShippingDetails($shipmentDetails)
1007
+ {
1008
+ if ($shipmentDetails) {
1009
+ $this->_request['shipping_info'] = $shipmentDetails;
1010
+ }
1011
+ }
1012
+
1013
  }
app/code/community/Vaimo/Klarna/Model/Api/Xmlrpc.php CHANGED
@@ -518,6 +518,7 @@ class Vaimo_Klarna_Model_Api_Xmlrpc extends Vaimo_Klarna_Model_Api_Abstract
518
  } else {
519
  $mode = Klarna::BETA;
520
  }
 
521
  $this->_klarnaApi->config(
522
  $this->_klarnaSetup->getMerchantId(),
523
  $this->_klarnaSetup->getSharedSecret(),
@@ -998,4 +999,11 @@ class Vaimo_Klarna_Model_Api_Xmlrpc extends Vaimo_Klarna_Model_Api_Abstract
998
  }
999
  }
1000
 
 
 
 
 
 
 
 
1001
  }
518
  } else {
519
  $mode = Klarna::BETA;
520
  }
521
+ $this->_klarnaApi->clear();
522
  $this->_klarnaApi->config(
523
  $this->_klarnaSetup->getMerchantId(),
524
  $this->_klarnaSetup->getSharedSecret(),
999
  }
1000
  }
1001
 
1002
+ public function setShippingDetails($shipmentDetails)
1003
+ {
1004
+ if ($shipmentDetails) {
1005
+ $this->_klarnaApi->setShipmentInfo('shipment_details', $shipmentDetails);
1006
+ }
1007
+ }
1008
+
1009
  }
app/code/community/Vaimo/Klarna/Model/Klarna.php CHANGED
@@ -35,6 +35,7 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
35
  protected $_api = NULL;
36
 
37
  protected static $_session_key = 'klarna_address';
 
38
 
39
  public function __construct($setStoreInfo = true, $moduleHelper = NULL, $entGWHelper = NULL, $salesHelper = NULL, $taxCalculation = NULL)
40
  {
@@ -95,6 +96,7 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
95
  {
96
  try {
97
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_RESERVE);
 
98
  $this->_setAdditionalInformation($this->getPayment()->getAdditionalInformation());
99
  $items = $this->getPayment()->getKlarnaItemList();
100
  $this->_createGoodsList($items);
@@ -115,6 +117,7 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
115
  $this->_getHelper()->dispatchMethodEvent($this->getOrder(), Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_RESERVED, $this->getOrder()->getTotalDue(), $this->getMethod());
116
 
117
  $this->_cleanAdditionalInfo();
 
118
 
119
  } catch (KlarnaException $e) {
120
  Mage::throwException($e->getMessage());
@@ -126,6 +129,7 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
126
  {
127
  try {
128
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_CAPTURE);
 
129
  $this->_setAdditionalInformation($this->getPayment()->getAdditionalInformation());
130
  $items = $this->getPayment()->getKlarnaItemList();
131
  $this->_createGoodsList($items);
@@ -135,6 +139,8 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
135
 
136
  $this->getApi()->setGoodsListCapture($amount);
137
  $this->getApi()->setAddresses($this->getBillingAddress(), $this->getShippingAddress(), $this->_getAdditionalInformation());
 
 
138
  $res = $this->getApi()->capture($reservation_no, $amount, $this->getConfigData('send_klarna_email'));
139
 
140
  $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_FEE_CAPTURED] = $this->_feeAmountIncluded();
@@ -142,6 +148,9 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
142
  $this->_getHelper()->dispatchMethodEvent($this->getOrder(), Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_CAPTURED, $this->getOrder()->getTotalDue(), $this->getMethod());
143
 
144
  $this->_getHelper()->logKlarnaApi('Response ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_STATUS] . ' - ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_TRANSACTION_ID]);
 
 
 
145
  } catch (KlarnaException $e) {
146
  Mage::throwException($e->getMessage());
147
  }
@@ -152,6 +161,7 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
152
  {
153
  try {
154
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_REFUND);
 
155
  $invoice_no = $this->getInfoInstance()->getParentTransactionId();
156
  $this->_setAdditionalInformation($this->getInfoInstance()->getAdditionalInformation());
157
  $items = $this->getPayment()->getKlarnaItemList();
@@ -164,6 +174,9 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
164
  $this->_getHelper()->dispatchMethodEvent($this->getOrder(), Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_REFUNDED, $amount, $this->getMethod());
165
 
166
  $this->_getHelper()->logKlarnaApi('Response ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_STATUS] . ' - ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_TRANSACTION_ID]);
 
 
 
167
  } catch (KlarnaException $e) {
168
  Mage::throwException($e->getMessage());
169
  }
@@ -174,6 +187,7 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
174
  {
175
  try {
176
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_CANCEL);
 
177
  $this->_setAdditionalInformation($this->getPayment()->getAdditionalInformation());
178
 
179
  if ($direct_rno) {
@@ -192,6 +206,9 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
192
  $this->_getHelper()->dispatchMethodEvent($this->getOrder(), Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_CANCELED, $this->getOrder()->getTotalDue(), $this->getMethod());
193
 
194
  $this->_getHelper()->logKlarnaApi('Response ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_STATUS]);
 
 
 
195
  } catch (KlarnaException $e) {
196
  Mage::throwException($e->getMessage());
197
  }
@@ -202,6 +219,7 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
202
  {
203
  try {
204
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_CHECKSTATUS);
 
205
  $this->_setAdditionalInformation($this->getPayment()->getAdditionalInformation());
206
 
207
  $reservation_no = $this->_getReservationNo();
@@ -210,6 +228,9 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
210
  $res = $this->getApi()->checkStatus($reservation_no);
211
 
212
  $this->_getHelper()->logKlarnaApi('Response ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_STATUS]);
 
 
 
213
  } catch (KlarnaException $e) {
214
  Mage::throwException($e->getMessage());
215
  }
@@ -234,6 +255,7 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
234
  }
235
 
236
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_ADDRESSES);
 
237
  $this->_getHelper()->logKlarnaApi('Call with Personal ID ' . $personal_id);
238
 
239
  $res = $this->getApi()->getAddresses($personal_id);
@@ -243,6 +265,8 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
243
  $cache[$personal_id] = $res;
244
  $_SESSION[self::$_session_key] = base64_encode( serialize($cache) );
245
 
 
 
246
  } catch (KlarnaException $e) {
247
  Mage::throwException($e->getMessage());
248
  }
@@ -389,9 +413,23 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
389
  public function getValidCheckoutPClasses($method)
390
  {
391
  try {
392
- $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_PCLASSES);
393
  $amount = $this->getQuote()->getGrandTotal();
 
 
 
 
 
 
 
 
 
 
 
394
  $res = $this->getApi()->getValidCheckoutPClasses($method, $amount);
 
 
 
 
395
  } catch (Mage_Core_Exception $e) {
396
  Mage::throwException($e->getMessage());
397
  }
35
  protected $_api = NULL;
36
 
37
  protected static $_session_key = 'klarna_address';
38
+ protected static $_pclasses_key = 'klarna_pclasses';
39
 
40
  public function __construct($setStoreInfo = true, $moduleHelper = NULL, $entGWHelper = NULL, $salesHelper = NULL, $taxCalculation = NULL)
41
  {
96
  {
97
  try {
98
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_RESERVE);
99
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
100
  $this->_setAdditionalInformation($this->getPayment()->getAdditionalInformation());
101
  $items = $this->getPayment()->getKlarnaItemList();
102
  $this->_createGoodsList($items);
117
  $this->_getHelper()->dispatchMethodEvent($this->getOrder(), Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_RESERVED, $this->getOrder()->getTotalDue(), $this->getMethod());
118
 
119
  $this->_cleanAdditionalInfo();
120
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
121
 
122
  } catch (KlarnaException $e) {
123
  Mage::throwException($e->getMessage());
129
  {
130
  try {
131
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_CAPTURE);
132
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
133
  $this->_setAdditionalInformation($this->getPayment()->getAdditionalInformation());
134
  $items = $this->getPayment()->getKlarnaItemList();
135
  $this->_createGoodsList($items);
139
 
140
  $this->getApi()->setGoodsListCapture($amount);
141
  $this->getApi()->setAddresses($this->getBillingAddress(), $this->getShippingAddress(), $this->_getAdditionalInformation());
142
+ $this->getApi()->setShippingDetails($this->_createShippingDetails($this->getOrder(), $items));
143
+
144
  $res = $this->getApi()->capture($reservation_no, $amount, $this->getConfigData('send_klarna_email'));
145
 
146
  $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_FEE_CAPTURED] = $this->_feeAmountIncluded();
148
  $this->_getHelper()->dispatchMethodEvent($this->getOrder(), Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_CAPTURED, $this->getOrder()->getTotalDue(), $this->getMethod());
149
 
150
  $this->_getHelper()->logKlarnaApi('Response ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_STATUS] . ' - ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_TRANSACTION_ID]);
151
+
152
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
153
+
154
  } catch (KlarnaException $e) {
155
  Mage::throwException($e->getMessage());
156
  }
161
  {
162
  try {
163
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_REFUND);
164
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
165
  $invoice_no = $this->getInfoInstance()->getParentTransactionId();
166
  $this->_setAdditionalInformation($this->getInfoInstance()->getAdditionalInformation());
167
  $items = $this->getPayment()->getKlarnaItemList();
174
  $this->_getHelper()->dispatchMethodEvent($this->getOrder(), Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_REFUNDED, $amount, $this->getMethod());
175
 
176
  $this->_getHelper()->logKlarnaApi('Response ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_STATUS] . ' - ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_TRANSACTION_ID]);
177
+
178
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
179
+
180
  } catch (KlarnaException $e) {
181
  Mage::throwException($e->getMessage());
182
  }
187
  {
188
  try {
189
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_CANCEL);
190
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
191
  $this->_setAdditionalInformation($this->getPayment()->getAdditionalInformation());
192
 
193
  if ($direct_rno) {
206
  $this->_getHelper()->dispatchMethodEvent($this->getOrder(), Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_CANCELED, $this->getOrder()->getTotalDue(), $this->getMethod());
207
 
208
  $this->_getHelper()->logKlarnaApi('Response ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_STATUS]);
209
+
210
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
211
+
212
  } catch (KlarnaException $e) {
213
  Mage::throwException($e->getMessage());
214
  }
219
  {
220
  try {
221
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_CHECKSTATUS);
222
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
223
  $this->_setAdditionalInformation($this->getPayment()->getAdditionalInformation());
224
 
225
  $reservation_no = $this->_getReservationNo();
228
  $res = $this->getApi()->checkStatus($reservation_no);
229
 
230
  $this->_getHelper()->logKlarnaApi('Response ' . $res[Vaimo_Klarna_Helper_Data::KLARNA_API_RESPONSE_STATUS]);
231
+
232
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
233
+
234
  } catch (KlarnaException $e) {
235
  Mage::throwException($e->getMessage());
236
  }
255
  }
256
 
257
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_ADDRESSES);
258
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
259
  $this->_getHelper()->logKlarnaApi('Call with Personal ID ' . $personal_id);
260
 
261
  $res = $this->getApi()->getAddresses($personal_id);
265
  $cache[$personal_id] = $res;
266
  $_SESSION[self::$_session_key] = base64_encode( serialize($cache) );
267
 
268
+ $this->_getHelper()->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
269
+
270
  } catch (KlarnaException $e) {
271
  Mage::throwException($e->getMessage());
272
  }
413
  public function getValidCheckoutPClasses($method)
414
  {
415
  try {
 
416
  $amount = $this->getQuote()->getGrandTotal();
417
+
418
+ $key = $method . ":" . round($amount,2);
419
+ $cache = array();
420
+
421
+ if (array_key_exists(self::$_pclasses_key, $_SESSION)) {
422
+ $cache = unserialize( base64_decode($_SESSION[self::$_pclasses_key]) );
423
+ }
424
+ if (array_key_exists($key, $cache)) {
425
+ return $cache[$key];
426
+ }
427
+ $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_PCLASSES);
428
  $res = $this->getApi()->getValidCheckoutPClasses($method, $amount);
429
+
430
+ $cache[$key] = $res;
431
+ $_SESSION[self::$_pclasses_key] = base64_encode( serialize($cache) );
432
+
433
  } catch (Mage_Core_Exception $e) {
434
  Mage::throwException($e->getMessage());
435
  }
app/code/community/Vaimo/Klarna/Model/Klarna/Abstract.php CHANGED
@@ -1119,5 +1119,71 @@ abstract class Vaimo_Klarna_Model_Klarna_Abstract extends Vaimo_Klarna_Model_Tra
1119
  }
1120
  }
1121
 
1122
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1123
  }
1119
  }
1120
  }
1121
 
1122
+ protected function _createShippingDetails($order, $invoiceItems)
1123
+ {
1124
+ $res = NULL;
1125
+ /**
1126
+ * If customer selects to create shipment directly from invoice, it will generate the
1127
+ * shipment AFTER the invoice. So I check the post here, in order to use that information.
1128
+ */
1129
+ if (isset($_POST)) {
1130
+ $usePostShipment = false;
1131
+ if (isset($_POST['invoice'])) {
1132
+ if (isset($_POST['invoice']['do_shipment'])) {
1133
+ if ($_POST['invoice']['do_shipment']=="1") {
1134
+ $usePostShipment = true;
1135
+ }
1136
+ }
1137
+ }
1138
+ if ($usePostShipment) {
1139
+ if (isset($_POST['tracking'])) {
1140
+ foreach ($_POST['tracking'] as $tracking) {
1141
+ $title = Mage::helper('klarna')->__("Unknown");
1142
+ $number = "";
1143
+ if (isset($tracking['title'])) {
1144
+ $title = $tracking['title'];
1145
+ }
1146
+ if (isset($tracking['number'])) {
1147
+ $number = $tracking['number'];
1148
+ }
1149
+ $shippingDetail = array(
1150
+ 'tracking_number' => $number,
1151
+ 'shipping_company' => $title,
1152
+ );
1153
+ if (!$res) {
1154
+ $res = array();
1155
+ }
1156
+ $res[] = $shippingDetail;
1157
+ }
1158
+ }
1159
+ }
1160
+ }
1161
+ foreach ($order->getShipmentsCollection() as $_shipment) {
1162
+ $shippingDetail = NULL;
1163
+ foreach ($_shipment->getItemsCollection() as $item) {
1164
+ foreach ($invoiceItems as $invoiceItem) {
1165
+ if ($item->getOrderItemId()==$invoiceItem->getOrderItemId()) {
1166
+ foreach ($_shipment->getTracksCollection() as $tracking) {
1167
+ $shippingDetail = array(
1168
+ 'tracking_number' => $tracking->getTrackNumber(),
1169
+ //'tracking_url' => $this->helper('shipping')->getTrackingPopupUrlBySalesModel($order), //Mage::getModel('core/url')->getUrl('sales/order/track', array('order_id' => $order->getId())),
1170
+ 'shipping_company' => $tracking->getTitle(),
1171
+ );
1172
+ if (!$res) {
1173
+ $res = array();
1174
+ }
1175
+ $res[] = $shippingDetail;
1176
+ }
1177
+ }
1178
+ if ($shippingDetail) {
1179
+ break;
1180
+ }
1181
+ }
1182
+ if ($shippingDetail) {
1183
+ break;
1184
+ }
1185
+ }
1186
+ }
1187
+ return $res;
1188
+ }
1189
  }
app/code/community/Vaimo/Klarna/Model/Klarnacheckout.php CHANGED
@@ -82,8 +82,15 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
82
  public function getKlarnaOrderHtml($checkoutId = null, $createIfNotExists = false, $updateItems = false)
83
  {
84
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER);
 
 
 
 
 
85
  $this->_api->initKlarnaOrder($checkoutId, $createIfNotExists, $updateItems);
86
- return $this->_api->getKlarnaCheckoutGui();
 
 
87
  }
88
 
89
  /**
@@ -98,9 +105,16 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
98
  public function getCheckoutStatus($checkoutId = null)
99
  {
100
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER);
 
 
 
 
 
101
  $this->_api->setKlarnaOrderSessionCache(true);
102
  $this->_api->initKlarnaOrder($checkoutId);
103
- return $this->_api->getKlarnaCheckoutStatus();
 
 
104
  }
105
 
106
  /*
@@ -120,7 +134,14 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
120
  public function getKlarnaOrderRaw($checkoutId)
121
  {
122
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER);
123
- return $this->_api->getKlarnaOrderRaw($checkoutId);
 
 
 
 
 
 
 
124
  }
125
 
126
  public function validateQuote($checkoutId)
@@ -162,6 +183,11 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
162
  public function createOrder($checkoutId = null)
163
  {
164
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER);
 
 
 
 
 
165
  if (!$this->_api->initKlarnaOrder($checkoutId)) {
166
  $this->_getHelper()->logDebugInfo('createOrder could not get klarna order');
167
  return 'could not get klarna order';
@@ -180,14 +206,16 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
180
  return 'could not create varienOrder';
181
  }
182
 
183
- $billingStreetAddress = $varienOrder->getBillingAddress('street_address');
184
  $billingStreetAddress2 = $varienOrder->getBillingAddress('street_address2');
185
- $billingStreetName = $varienOrder->getBillingAddress('street_name');
186
- $billingStreetNumber = $varienOrder->getBillingAddress('street_number');
187
- $shippingStreetAddress = $varienOrder->getShippingAddress('street_address');
 
188
  $shippingStreetAddress2 = $varienOrder->getShippingAddress('street_address2');
189
- $shippingStreetName = $varienOrder->getShippingAddress('street_name');
190
- $shippingStreetNumber = $varienOrder->getShippingAddress('street_number');
 
191
 
192
  if (!$billingStreetAddress && $billingStreetName && $billingStreetNumber) {
193
  $streetAddress = $varienOrder->getBillingAddress();
@@ -211,7 +239,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
211
  $varienOrder->setShippingAddress($streetAddress);
212
  }
213
 
214
- if ($varienOrder->getStatus() != 'checkout_complete') {
215
  $this->_getHelper()->logDebugInfo('createOrder status not complete');
216
  return 'status not complete';
217
  }
@@ -219,6 +247,11 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
219
  $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
220
  if ($orderId>0) {
221
  $this->_getHelper()->logDebugInfo('createOrder order already created ' . $orderId);
 
 
 
 
 
222
  return 'order already created';
223
  }
224
  $isNewCustomer = false;
@@ -262,6 +295,10 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
262
  $billingAddress->setEmail($varienOrder->getBillingAddress('email'));
263
  $billingAddress->setTelephone($varienOrder->getBillingAddress('phone'));
264
  $billingAddress->setSaveInAddressBook(1);
 
 
 
 
265
  }
266
 
267
  // $this->_validateCustomerData($data);
@@ -276,6 +313,10 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
276
  $shippingAddress->setCountryId(strtoupper($varienOrder->getShippingAddress('country')));
277
  $shippingAddress->setEmail($varienOrder->getShippingAddress('email'));
278
  $shippingAddress->setTelephone($varienOrder->getShippingAddress('phone'));
 
 
 
 
279
 
280
  if ($this->getConfigData('packstation_enabled')) {
281
  $shippingAddress->setSameAsBilling(0);
@@ -367,6 +408,8 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
367
 
368
  $this->_getHelper()->dispatchMethodEvent($order, Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_RESERVED, $order->getTotalDue(), $this->getMethod());
369
 
 
 
370
  $this->_getHelper()->logDebugInfo('createOrder successfully created order with no: ' . $order->getIncrementId());
371
 
372
  $this->_api->updateKlarnaOrder($order);
82
  public function getKlarnaOrderHtml($checkoutId = null, $createIfNotExists = false, $updateItems = false)
83
  {
84
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER);
85
+ if ($checkoutId) {
86
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID ' . $checkoutId);
87
+ } else {
88
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
89
+ }
90
  $this->_api->initKlarnaOrder($checkoutId, $createIfNotExists, $updateItems);
91
+ $res = $this->_api->getKlarnaCheckoutGui();
92
+ $this->_getHelper()->logKlarnaApi('Call complete');
93
+ return $res;
94
  }
95
 
96
  /**
105
  public function getCheckoutStatus($checkoutId = null)
106
  {
107
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER);
108
+ if ($checkoutId) {
109
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID ' . $checkoutId);
110
+ } else {
111
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
112
+ }
113
  $this->_api->setKlarnaOrderSessionCache(true);
114
  $this->_api->initKlarnaOrder($checkoutId);
115
+ $res = $this->_api->getKlarnaCheckoutStatus();
116
+ $this->_getHelper()->logKlarnaApi('Call complete');
117
+ return $res;
118
  }
119
 
120
  /*
134
  public function getKlarnaOrderRaw($checkoutId)
135
  {
136
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER);
137
+ if ($checkoutId) {
138
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID ' . $checkoutId);
139
+ } else {
140
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
141
+ }
142
+ $res = $this->_api->getKlarnaOrderRaw($checkoutId);
143
+ $this->_getHelper()->logKlarnaApi('Call complete');
144
+ return $res;
145
  }
146
 
147
  public function validateQuote($checkoutId)
183
  public function createOrder($checkoutId = null)
184
  {
185
  $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER);
186
+ if ($checkoutId) {
187
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID ' . $checkoutId);
188
+ } else {
189
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
190
+ }
191
  if (!$this->_api->initKlarnaOrder($checkoutId)) {
192
  $this->_getHelper()->logDebugInfo('createOrder could not get klarna order');
193
  return 'could not get klarna order';
206
  return 'could not create varienOrder';
207
  }
208
 
209
+ $billingStreetAddress = $varienOrder->getBillingAddress('street_address');
210
  $billingStreetAddress2 = $varienOrder->getBillingAddress('street_address2');
211
+ $billingStreetName = $varienOrder->getBillingAddress('street_name');
212
+ $billingStreetNumber = $varienOrder->getBillingAddress('street_number');
213
+ $billingRegionCode = $varienOrder->getBillingAddress('region');
214
+ $shippingStreetAddress = $varienOrder->getShippingAddress('street_address');
215
  $shippingStreetAddress2 = $varienOrder->getShippingAddress('street_address2');
216
+ $shippingStreetName = $varienOrder->getShippingAddress('street_name');
217
+ $shippingStreetNumber = $varienOrder->getShippingAddress('street_number');
218
+ $shippingRegionCode = $varienOrder->getShippingAddress('region');
219
 
220
  if (!$billingStreetAddress && $billingStreetName && $billingStreetNumber) {
221
  $streetAddress = $varienOrder->getBillingAddress();
239
  $varienOrder->setShippingAddress($streetAddress);
240
  }
241
 
242
+ if ($varienOrder->getStatus() != 'checkout_complete' && $varienOrder->getStatus() != 'created') {
243
  $this->_getHelper()->logDebugInfo('createOrder status not complete');
244
  return 'status not complete';
245
  }
247
  $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
248
  if ($orderId>0) {
249
  $this->_getHelper()->logDebugInfo('createOrder order already created ' . $orderId);
250
+ if (($varienOrder->getStatus() == 'checkout_complete') || ($varienOrder->getStatus() == 'created')) {
251
+ $order = $this->_loadOrderByKey($quote->getId());
252
+ $this->_api->updateKlarnaOrder($order, true);
253
+ $this->_getHelper()->logDebugInfo('updating order status on already crated order ' . $orderId);
254
+ }
255
  return 'order already created';
256
  }
257
  $isNewCustomer = false;
295
  $billingAddress->setEmail($varienOrder->getBillingAddress('email'));
296
  $billingAddress->setTelephone($varienOrder->getBillingAddress('phone'));
297
  $billingAddress->setSaveInAddressBook(1);
298
+ if ($billingRegionCode) {
299
+ $billingRegionId = Mage::getModel('directory/region')->loadByCode($billingRegionCode, $billingAddress->getCountryId());
300
+ $billingAddress->setRegionId($billingRegionId->getId());
301
+ }
302
  }
303
 
304
  // $this->_validateCustomerData($data);
313
  $shippingAddress->setCountryId(strtoupper($varienOrder->getShippingAddress('country')));
314
  $shippingAddress->setEmail($varienOrder->getShippingAddress('email'));
315
  $shippingAddress->setTelephone($varienOrder->getShippingAddress('phone'));
316
+ if ($shippingRegionCode) {
317
+ $shippingRegionId = Mage::getModel('directory/region')->loadByCode($shippingRegionCode, $shippingAddress->getCountryId());
318
+ $shippingAddress->setRegionId($shippingRegionId->getId());
319
+ }
320
 
321
  if ($this->getConfigData('packstation_enabled')) {
322
  $shippingAddress->setSameAsBilling(0);
408
 
409
  $this->_getHelper()->dispatchMethodEvent($order, Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_RESERVED, $order->getTotalDue(), $this->getMethod());
410
 
411
+ Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => $order->getId()) );
412
+
413
  $this->_getHelper()->logDebugInfo('createOrder successfully created order with no: ' . $order->getIncrementId());
414
 
415
  $this->_api->updateKlarnaOrder($order);
app/code/community/Vaimo/Klarna/Model/Klarnacheckout/Abstract.php CHANGED
@@ -104,7 +104,7 @@ abstract class Vaimo_Klarna_Model_Klarnacheckout_Abstract extends Vaimo_Klarna_M
104
 
105
  protected function _addToSubscription($email)
106
  {
107
- Mage::getModel('newsletter/subscriber')->subscribe(email);
108
  }
109
 
110
  protected function _prepareNewCustomerQuote(Mage_Sales_Model_Quote $quote)
104
 
105
  protected function _addToSubscription($email)
106
  {
107
+ Mage::getModel('newsletter/subscriber')->subscribe($email);
108
  }
109
 
110
  protected function _prepareNewCustomerQuote(Mage_Sales_Model_Quote $quote)
app/code/community/Vaimo/Klarna/Model/Observer.php CHANGED
@@ -165,8 +165,16 @@ class Vaimo_Klarna_Model_Observer extends Mage_Core_Model_Abstract
165
  if ($klarna->getConfigData('auto_reset_other_method_button')) {
166
  $controller = $observer->getEvent()->getControllerAction();
167
  $class = get_class($controller);
 
 
168
  if ((!stristr($class, 'checkout') && !stristr($class, 'ajax') && !stristr($class, 'klarna')) ||
169
- ( stristr($class, 'checkout') && !stristr($class, 'ajax') && stristr($class, 'cart'))) {
 
 
 
 
 
 
170
  $this->_getSession()->setKlarnaUseOtherMethods(false);
171
  $payment = $quote->getPayment();
172
  $payment->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
165
  if ($klarna->getConfigData('auto_reset_other_method_button')) {
166
  $controller = $observer->getEvent()->getControllerAction();
167
  $class = get_class($controller);
168
+ $action = $controller->getRequest()->getActionName();
169
+ $clearFlag = false;
170
  if ((!stristr($class, 'checkout') && !stristr($class, 'ajax') && !stristr($class, 'klarna')) ||
171
+ (stristr($class, 'checkout') && !stristr($class, 'ajax') && stristr($class, 'cart'))) {
172
+ $clearFlag = true;
173
+ }
174
+ if ((stristr($class, 'customer_account') && stristr($action, 'loginPost'))) {
175
+ $clearFlag = false;
176
+ }
177
+ if ($clearFlag) {
178
  $this->_getSession()->setKlarnaUseOtherMethods(false);
179
  $payment = $quote->getPayment();
180
  $payment->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
app/code/community/Vaimo/Klarna/Model/Payment/Abstract.php CHANGED
@@ -174,7 +174,6 @@ class Vaimo_Klarna_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abst
174
  $available = $this->_isAvailableParent($quote);
175
  if (!$available) return false;
176
 
177
- $klarna = null;
178
  try {
179
  $active = $this->_getConfigData('active'); // Only call to this
180
 
174
  $available = $this->_isAvailableParent($quote);
175
  if (!$available) return false;
176
 
 
177
  try {
178
  $active = $this->_getConfigData('active'); // Only call to this
179
 
app/code/community/Vaimo/Klarna/Model/Source/Apiversion.php CHANGED
@@ -34,8 +34,9 @@ class Vaimo_Klarna_Model_Source_Apiversion extends Vaimo_Klarna_Model_Source_Abs
34
  public function toOptionArray()
35
  {
36
  return array(
37
- array('value' => 2, 'label' => $this->_getHelper()->__('KCO V.2')),
38
- array('value' => 3, 'label' => $this->_getHelper()->__('KCO V.3 (UK)')),
 
39
  );
40
  }
41
 
@@ -47,8 +48,9 @@ class Vaimo_Klarna_Model_Source_Apiversion extends Vaimo_Klarna_Model_Source_Abs
47
  public function toArray()
48
  {
49
  return array(
50
- 2 => $this->_getHelper()->__('KCO V.2'),
51
- 3 => $this->_getHelper()->__('KCO V.3 (UK)'),
 
52
  );
53
  }
54
  }
34
  public function toOptionArray()
35
  {
36
  return array(
37
+ array('value' => Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_STD, 'label' => $this->_getHelper()->__('KCO V.2')),
38
+ array('value' => Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_UK, 'label' => $this->_getHelper()->__('KCO V.3 (UK)')),
39
+ array('value' => Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_USA, 'label' => $this->_getHelper()->__('KCO V.3.1')),
40
  );
41
  }
42
 
48
  public function toArray()
49
  {
50
  return array(
51
+ Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_STD => $this->_getHelper()->__('KCO V.2'),
52
+ Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_UK => $this->_getHelper()->__('KCO V.3 (UK)'),
53
+ Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_USA => $this->_getHelper()->__('KCO V.3.1'),
54
  );
55
  }
56
  }
app/code/community/Vaimo/Klarna/Model/Transport/Abstract.php CHANGED
@@ -177,11 +177,7 @@ abstract class Vaimo_Klarna_Model_Transport_Abstract extends Varien_Object
177
  */
178
  protected function _getDefaultCountry()
179
  {
180
- // Can't just use helpers like this, unit tests will fail... It's not important anyway, not right now.
181
- // $res = Mage::helper('core')->getMerchantCountryCode($this->_getStoreId());
182
- // if (!$res) {
183
- $res = $this->_getConfigDataCall(Mage_Core_Model_Locale::XML_PATH_DEFAULT_COUNTRY, $this->_getStoreId());
184
- // }
185
  return strtoupper($res);
186
  }
187
 
@@ -315,7 +311,9 @@ abstract class Vaimo_Klarna_Model_Transport_Abstract extends Varien_Object
315
  */
316
  protected function _setShippingAddress($address)
317
  {
318
- $this->_shippingAddress = $address;
 
 
319
  $this->_updateCountry();
320
  }
321
 
@@ -329,6 +327,9 @@ abstract class Vaimo_Klarna_Model_Transport_Abstract extends Varien_Object
329
  protected function _setBillingAddress($address)
330
  {
331
  $this->_billingAddress = $address;
 
 
 
332
  $this->_updateCountry();
333
  }
334
 
@@ -537,6 +538,23 @@ abstract class Vaimo_Klarna_Model_Transport_Abstract extends Varien_Object
537
  }
538
  }
539
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  /**
541
  * Norway has special rules regarding the details of the payment plan you are selecting
542
  *
@@ -663,6 +681,7 @@ abstract class Vaimo_Klarna_Model_Transport_Abstract extends Varien_Object
663
  public function shouldDisplayAutofillWarning()
664
  {
665
  switch ($this->_getCountryCode()) {
 
666
  case 'DE':
667
  $this->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
668
  return $this->getConfigData('active');
177
  */
178
  protected function _getDefaultCountry()
179
  {
180
+ $res = $this->_getHelper()->getDefaultCountry($this->_getStoreId());
 
 
 
 
181
  return strtoupper($res);
182
  }
183
 
311
  */
312
  protected function _setShippingAddress($address)
313
  {
314
+ if ($address) {
315
+ $this->_shippingAddress = $address;
316
+ }
317
  $this->_updateCountry();
318
  }
319
 
327
  protected function _setBillingAddress($address)
328
  {
329
  $this->_billingAddress = $address;
330
+ if ($this->_shippingAddress==NULL) {
331
+ $this->_shippingAddress = $address;
332
+ }
333
  $this->_updateCountry();
334
  }
335
 
538
  }
539
  }
540
 
541
+ /**
542
+ * Some countries supports to get more details to create request
543
+ *
544
+ * @return boolean
545
+ */
546
+ public function moreDetailsToKCORequest()
547
+ {
548
+ switch ($this->_getCountryCode()) {
549
+ // case 'NL':
550
+ case 'DE':
551
+ case 'AT':
552
+ return true;
553
+ default:
554
+ return false;
555
+ }
556
+ }
557
+
558
  /**
559
  * Norway has special rules regarding the details of the payment plan you are selecting
560
  *
681
  public function shouldDisplayAutofillWarning()
682
  {
683
  switch ($this->_getCountryCode()) {
684
+ case 'AT':
685
  case 'DE':
686
  $this->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
687
  return $this->getConfigData('active');
app/code/community/Vaimo/Klarna/controllers/Checkout/KlarnaController.php CHANGED
@@ -64,7 +64,6 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
64
  $quote->getShippingAddress()->setPaymentMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
65
  }
66
  $quote->getPayment()->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
67
- $quote->save();
68
  }
69
 
70
  return $this;
@@ -75,23 +74,32 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
75
  // set shipping method
76
  $quote = $this->_getQuote();
77
  $shippingAddress = $quote->getShippingAddress();
78
- if (!$shippingAddress->getShippingMethod()) {
79
  $quote->setRemoteIp($quote->getRemoteIp());
80
- if (version_compare(Mage::getVersion(), '1.6.2', '>=')) {
81
- $countryId = Mage::helper('core')->getDefaultCountry();
82
- } else {
83
- $countryId = Mage::getStoreConfig('general/country/default');
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
- $shippingAddress->setCountryId($countryId);
86
  $shippingAddress->setCollectShippingRates(true);
 
87
  $shippingAddress->collectShippingRates();
88
  $rates = $shippingAddress->getGroupedAllShippingRates();
89
  foreach ($rates as $carrierRates) {
90
  foreach ($carrierRates as $rate) {
91
  $shippingAddress->setShippingMethod($rate->getCode());
92
  $quote->setTotalsCollectedFlag(false);
93
- $quote->collectTotals();
94
- $quote->save();
95
  break;
96
  }
97
  break;
@@ -106,7 +114,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
106
  $quote = $this->_getQuote();
107
  $klarna = Mage::getModel('klarna/klarnacheckout');
108
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
109
- $klarna->CheckNewsletter();
110
  return $this;
111
  }
112
 
@@ -176,6 +184,9 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
176
  $this->_checkShippingMethod();
177
  $this->_checkNewsletter();
178
 
 
 
 
179
  $this->loadLayout();
180
  $this->_initLayoutMessages('customer/session');
181
  $this->getLayout()->getBlock('head')->setTitle($this->__('Klarna Checkout'));
@@ -190,8 +201,50 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
190
  $quote->save();
191
  }
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  public function validateAction()
194
  {
 
195
  $checkoutId = $this->getRequest()->getParam('klarna_order');
196
  $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
197
  $klarna = Mage::getModel('klarna/klarnacheckout');
@@ -205,6 +258,8 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
205
  $result = $klarna->validateQuote($checkoutId);
206
  Mage::helper('klarna')->logKlarnaApi('validateAction result = ' . $result);
207
 
 
 
208
  if ($result !== true) {
209
  $this->getResponse()
210
  ->setHttpResponseCode(303)
@@ -214,6 +269,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
214
 
215
  public function pushAction()
216
  {
 
217
  $checkoutId = $this->getRequest()->getParam('klarna_order');
218
  $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
219
 
@@ -242,11 +298,13 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
242
  Mage::helper('klarna')->logKlarnaException($e);
243
  }
244
  }
 
245
  }
246
 
247
  public function successAction()
248
  {
249
  try {
 
250
  $checkoutId = $this->_getSession()->getKlarnaCheckoutId();
251
  $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
252
  $klarna = Mage::getModel('klarna/klarnacheckout');
@@ -298,6 +356,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
298
  $this->_getSession()->setKlarnaCheckoutId('');
299
  $this->_getSession()->setKlarnaUseOtherMethods(false);
300
  Mage::helper('klarna')->logKlarnaApi('successAction displayed success');
 
301
  } catch (Exception $e) {
302
  Mage::helper('klarna')->logKlarnaException($e);
303
  }
64
  $quote->getShippingAddress()->setPaymentMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
65
  }
66
  $quote->getPayment()->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
 
67
  }
68
 
69
  return $this;
74
  // set shipping method
75
  $quote = $this->_getQuote();
76
  $shippingAddress = $quote->getShippingAddress();
77
+ if (!$quote->isVirtual() && $shippingAddress && !$shippingAddress->getShippingMethod()) {
78
  $quote->setRemoteIp($quote->getRemoteIp());
79
+ $taxCalculationModel = Mage::getSingleton('tax/calculation');
80
+ $request = $taxCalculationModel->getRateRequest(
81
+ $quote->getShippingAddress(),
82
+ $quote->getBillingAddress(),
83
+ NULL,
84
+ $quote->getStoreId()
85
+ );
86
+ $shippingAddress->setCountryId($request->getCountryId());
87
+ $shippingAddress->setRegionId($request->getRegionId());
88
+ $shippingAddress->setPostcode($request->getPostcode());
89
+ // Massive workaround... because Shipping Origin is per website, not store...
90
+ if (Mage::helper('klarna')->getDefaultCountry()!=$shippingAddress->getCountryId()) {
91
+ if (!$shippingAddress->getRegionId() && !$shippingAddress->getPostcode()) {
92
+ $shippingAddress->setCountryId(Mage::helper('klarna')->getDefaultCountry());
93
+ }
94
  }
 
95
  $shippingAddress->setCollectShippingRates(true);
96
+ $shippingAddress->collectTotals();
97
  $shippingAddress->collectShippingRates();
98
  $rates = $shippingAddress->getGroupedAllShippingRates();
99
  foreach ($rates as $carrierRates) {
100
  foreach ($carrierRates as $rate) {
101
  $shippingAddress->setShippingMethod($rate->getCode());
102
  $quote->setTotalsCollectedFlag(false);
 
 
103
  break;
104
  }
105
  break;
114
  $quote = $this->_getQuote();
115
  $klarna = Mage::getModel('klarna/klarnacheckout');
116
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
117
+ $klarna->checkNewsletter();
118
  return $this;
119
  }
120
 
184
  $this->_checkShippingMethod();
185
  $this->_checkNewsletter();
186
 
187
+ $quote->collectTotals();
188
+ $quote->save();
189
+
190
  $this->loadLayout();
191
  $this->_initLayoutMessages('customer/session');
192
  $this->getLayout()->getBlock('head')->setTitle($this->__('Klarna Checkout'));
201
  $quote->save();
202
  }
203
 
204
+ public function addressUpdateAction()
205
+ {
206
+ $result = false;
207
+ $quote = $this->_getQuote();
208
+ $region = $this->getRequest()->getParam('region');
209
+ $address = $quote->getShippingAddress();
210
+ if ($address->getRegion()!=$region) {
211
+ $address->setRegion($region);
212
+ $result = true;
213
+ }
214
+ $postCode = $this->getRequest()->getParam('postcode');
215
+ $address = $quote->getShippingAddress();
216
+ if ($address->getPostcode()!=$postCode) {
217
+ $address->setPostcode($postCode);
218
+ $result = true;
219
+ }
220
+ if ($result) {
221
+ $quote->save();
222
+ }
223
+ $this->getResponse()->setBody(Zend_Json::encode($result));
224
+ }
225
+
226
+ public function shippingupdateAction()
227
+ {
228
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
229
+ Mage::helper('klarna')->logKlarnaApi('shippingAddress callback received');
230
+
231
+ $shippingAddress = $this->getRequest()->getParam('shipping_address');
232
+ $orderAmount = $this->getRequest()->getParam('order_amount');
233
+ $orderAmountTax = $this->getRequest()->getParam('order_tax_amount');
234
+ $orderLines = $this->getRequest()->getParam('order_lines');
235
+
236
+ Mage::helper('klarna')->logKlarnaDebug('shippingAddress = ' . $shippingAddress);
237
+ Mage::helper('klarna')->logKlarnaDebug('orderAmount = ' . $orderAmount);
238
+ Mage::helper('klarna')->logKlarnaDebug('orderAmountTax = ' . $orderAmountTax);
239
+ Mage::helper('klarna')->logKlarnaDebug('orderLines = ' . $orderLines);
240
+
241
+ Mage::helper('klarna')->logKlarnaApi('shippingAddress callback result = fejk');
242
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
243
+ }
244
+
245
  public function validateAction()
246
  {
247
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
248
  $checkoutId = $this->getRequest()->getParam('klarna_order');
249
  $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
250
  $klarna = Mage::getModel('klarna/klarnacheckout');
258
  $result = $klarna->validateQuote($checkoutId);
259
  Mage::helper('klarna')->logKlarnaApi('validateAction result = ' . $result);
260
 
261
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
262
+
263
  if ($result !== true) {
264
  $this->getResponse()
265
  ->setHttpResponseCode(303)
269
 
270
  public function pushAction()
271
  {
272
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
273
  $checkoutId = $this->getRequest()->getParam('klarna_order');
274
  $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
275
 
298
  Mage::helper('klarna')->logKlarnaException($e);
299
  }
300
  }
301
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
302
  }
303
 
304
  public function successAction()
305
  {
306
  try {
307
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
308
  $checkoutId = $this->_getSession()->getKlarnaCheckoutId();
309
  $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
310
  $klarna = Mage::getModel('klarna/klarnacheckout');
356
  $this->_getSession()->setKlarnaCheckoutId('');
357
  $this->_getSession()->setKlarnaUseOtherMethods(false);
358
  Mage::helper('klarna')->logKlarnaApi('successAction displayed success');
359
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
360
  } catch (Exception $e) {
361
  Mage::helper('klarna')->logKlarnaException($e);
362
  }
app/code/community/Vaimo/Klarna/etc/config.xml CHANGED
@@ -25,7 +25,7 @@
25
  --><config>
26
  <modules>
27
  <Vaimo_Klarna>
28
- <version>5.2.8</version>
29
  <name>Vaimo Klarna Module</name>
30
  <depends>
31
  <Mage_Payment/>
@@ -83,6 +83,14 @@
83
  </fieldsets>
84
 
85
  <events>
 
 
 
 
 
 
 
 
86
  <customer_address_format>
87
  <observers>
88
  <klarna>
@@ -272,14 +280,6 @@
272
  </modules>
273
  </translate>
274
  <events>
275
- <sales_order_payment_capture>
276
- <observers>
277
- <klarna>
278
- <class>klarna/observer</class>
279
- <method>prePaymentCapture</method>
280
- </klarna>
281
- </observers>
282
- </sales_order_payment_capture>
283
  <core_block_abstract_prepare_layout_after>
284
  <observers>
285
  <klarna>
@@ -370,7 +370,8 @@
370
  <enable_cart_above_kco>1</enable_cart_above_kco>
371
  <enable_other_button>1</enable_other_button>
372
  <enable_auto_focus>1</enable_auto_focus>
 
373
  </vaimo_klarna_checkout>
374
  </payment>
375
  </default>
376
- </config>
25
  --><config>
26
  <modules>
27
  <Vaimo_Klarna>
28
+ <version>5.2.11</version>
29
  <name>Vaimo Klarna Module</name>
30
  <depends>
31
  <Mage_Payment/>
83
  </fieldsets>
84
 
85
  <events>
86
+ <sales_order_payment_capture>
87
+ <observers>
88
+ <klarna>
89
+ <class>klarna/observer</class>
90
+ <method>prePaymentCapture</method>
91
+ </klarna>
92
+ </observers>
93
+ </sales_order_payment_capture>
94
  <customer_address_format>
95
  <observers>
96
  <klarna>
280
  </modules>
281
  </translate>
282
  <events>
 
 
 
 
 
 
 
 
283
  <core_block_abstract_prepare_layout_after>
284
  <observers>
285
  <klarna>
370
  <enable_cart_above_kco>1</enable_cart_above_kco>
371
  <enable_other_button>1</enable_other_button>
372
  <enable_auto_focus>1</enable_auto_focus>
373
+ <shipping_countries>US,MX,CA,GL</shipping_countries>
374
  </vaimo_klarna_checkout>
375
  </payment>
376
  </default>
377
+ </config>
app/code/community/Vaimo/Klarna/etc/system.xml CHANGED
@@ -749,7 +749,17 @@
749
  <show_in_website>1</show_in_website>
750
  <show_in_store>1</show_in_store>
751
  </enable_auto_focus>
752
-
 
 
 
 
 
 
 
 
 
 
753
  <heading_other_method_button translate="label">
754
  <label>Support of other payment methods</label>
755
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -861,24 +871,6 @@
861
  <show_in_store>1</show_in_store>
862
  <comment>If you do not belong to a selected customer group, standard Magento checkout will be used. None selected, means enabled for all</comment>
863
  </allow_customer_group>
864
- <!--
865
- <user_defined_parameters translate="label">
866
- <label>Extra user defined parameters sent to Klarna</label>
867
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
868
- <sort_order>900</sort_order>
869
- <show_in_default>1</show_in_default>
870
- <show_in_website>1</show_in_website>
871
- <show_in_store>1</show_in_store>
872
- </user_defined_parameters>
873
- <extra_parameters>
874
- <frontend_model>klarna/system_config_form_field_position_attribute_set</frontend_model>
875
- <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
876
- <sort_order>910</sort_order>
877
- <show_in_default>1</show_in_default>
878
- <show_in_website>1</show_in_website>
879
- <show_in_store>1</show_in_store>
880
- </extra_parameters>
881
- -->
882
  <user_defined_json translate="label">
883
  <label>User Defined Variables</label>
884
  <backend_model>klarna/adminhtml_system_config_backend_admin_json</backend_model>
@@ -889,6 +881,16 @@
889
  <show_in_store>1</show_in_store>
890
  <comment>JSON encoded array. Please consult Klarna before using this, incorrect information may cause the integration to stop working</comment>
891
  </user_defined_json>
 
 
 
 
 
 
 
 
 
 
892
  </fields>
893
  </vaimo_klarna_checkout>
894
  </groups>
749
  <show_in_website>1</show_in_website>
750
  <show_in_store>1</show_in_store>
751
  </enable_auto_focus>
752
+ <!--
753
+ <enable_postcode_update translate="label">
754
+ <label>Enable shipping recalculate when postcode changes</label>
755
+ <frontend_type>select</frontend_type>
756
+ <source_model>adminhtml/system_config_source_yesno</source_model>
757
+ <sort_order>260</sort_order>
758
+ <show_in_default>1</show_in_default>
759
+ <show_in_website>1</show_in_website>
760
+ <show_in_store>1</show_in_store>
761
+ </enable_postcode_update>
762
+ -->
763
  <heading_other_method_button translate="label">
764
  <label>Support of other payment methods</label>
765
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
871
  <show_in_store>1</show_in_store>
872
  <comment>If you do not belong to a selected customer group, standard Magento checkout will be used. None selected, means enabled for all</comment>
873
  </allow_customer_group>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874
  <user_defined_json translate="label">
875
  <label>User Defined Variables</label>
876
  <backend_model>klarna/adminhtml_system_config_backend_admin_json</backend_model>
881
  <show_in_store>1</show_in_store>
882
  <comment>JSON encoded array. Please consult Klarna before using this, incorrect information may cause the integration to stop working</comment>
883
  </user_defined_json>
884
+ <shipping_countries translate="label">
885
+ <label>Shipping Countries</label>
886
+ <frontend_type>multiselect</frontend_type>
887
+ <sort_order>930</sort_order>
888
+ <source_model>adminhtml/system_config_source_country</source_model>
889
+ <show_in_default>1</show_in_default>
890
+ <show_in_website>1</show_in_website>
891
+ <show_in_store>1</show_in_store>
892
+ <comment>Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout</comment>
893
+ </shipping_countries>
894
  </fields>
895
  </vaimo_klarna_checkout>
896
  </groups>
app/design/frontend/base/default/layout/vaimo_klarna.xml CHANGED
@@ -183,7 +183,9 @@
183
  </block>
184
  </block>
185
 
186
- <block type="core/template" name="klarna_login" template="vaimo/klarna/klarnacheckout/account-login.phtml"/>
 
 
187
 
188
  <block type="core/template" name="klarna_sidebar" as="klarna_sidebar" template="vaimo/klarna/klarnacheckout/sidebar.phtml">
189
  <block type="klarna/klarnacheckout_othermethod" name="other.payment.methods" template="vaimo/klarna/klarnacheckout/othermethod.phtml"/>
183
  </block>
184
  </block>
185
 
186
+ <block type="core/template" name="klarna_login" template="vaimo/klarna/klarnacheckout/account-login.phtml">
187
+ <block type="klarna/klarnacheckout_autofill" name="klarnacheckout.autofill" after="-" template="vaimo/klarna/klarnacheckout/autofill.phtml"/>
188
+ </block>
189
 
190
  <block type="core/template" name="klarna_sidebar" as="klarna_sidebar" template="vaimo/klarna/klarnacheckout/sidebar.phtml">
191
  <block type="klarna/klarnacheckout_othermethod" name="other.payment.methods" template="vaimo/klarna/klarnacheckout/othermethod.phtml"/>
app/design/frontend/base/default/template/vaimo/klarna/form/children/addressresult.phtml CHANGED
@@ -36,8 +36,18 @@
36
 
37
  <?php if ($this->shippingSameAsBilling()): ?>
38
  <li class="klarna_notification"><?php echo Mage::helper('klarna')->__('Please note that your official address will be used for shipping and billing address when you place your order'); ?></li>
 
 
39
  <?php endif; ?>
40
 
41
  <?php endif; ?>
42
 
 
 
 
 
 
 
 
 
43
  <?php endif; ?>
36
 
37
  <?php if ($this->shippingSameAsBilling()): ?>
38
  <li class="klarna_notification"><?php echo Mage::helper('klarna')->__('Please note that your official address will be used for shipping and billing address when you place your order'); ?></li>
39
+ <?php else: ?>
40
+ <li class="klarna_notification"><?php echo Mage::helper('klarna')->__('Please note that your official address will be used for shipping and billing address when you place your order'); ?></li>
41
  <?php endif; ?>
42
 
43
  <?php endif; ?>
44
 
45
+ <?php else: ?>
46
+
47
+ <?php if ($this->shippingSameAsBilling()): ?>
48
+ <li class="klarna_notification"><?php echo Mage::helper('klarna')->__('Please note that your official address will be used for shipping and billing address when you place your order'); ?></li>
49
+ <?php else: ?>
50
+ <li class="klarna_notification"><?php echo Mage::helper('klarna')->__('Please note that your official address will be used for shipping and billing address when you place your order'); ?></li>
51
+ <?php endif; ?>
52
+
53
  <?php endif; ?>
app/design/frontend/base/default/template/vaimo/klarna/form/paymentplan/information.phtml CHANGED
@@ -23,7 +23,7 @@
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
25
 
26
- $information = $this->getPClassDetails();
27
  $method = $this->getMethodCode();
28
  ?>
29
  <dl>
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
25
 
26
+ $information = $this->getPClassDetails(); // @todo information is object
27
  $method = $this->getMethodCode();
28
  ?>
29
  <dl>
app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/account-login.phtml CHANGED
@@ -34,4 +34,7 @@
34
 
35
  <button class="button button-action" type="submit"><?php echo $this->__('Login'); ?></button>
36
  </form>
37
- </div>
 
 
 
34
 
35
  <button class="button button-action" type="submit"><?php echo $this->__('Login'); ?></button>
36
  </form>
37
+ <div class="klarna_login_message">
38
+ <?php echo $this->getChildHtml('klarnacheckout.autofill') ?>
39
+ </div>
40
+ </div>
app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/cart.phtml CHANGED
@@ -41,7 +41,7 @@
41
  <?php else: ?>
42
  <?php if ($isTwoColumnLayout) : ?>
43
  <h2 class="klarna_block-title"><?php echo $this->__('Order Summary'); ?></h2>
44
- <? endif; ?>
45
 
46
  <?php if(!$this->hasError()): ?>
47
  <ul class="checkout-types">
41
  <?php else: ?>
42
  <?php if ($isTwoColumnLayout) : ?>
43
  <h2 class="klarna_block-title"><?php echo $this->__('Order Summary'); ?></h2>
44
+ <?php endif; ?>
45
 
46
  <?php if(!$this->hasError()): ?>
47
  <ul class="checkout-types">
app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/othermethod.phtml CHANGED
@@ -27,7 +27,7 @@ $button_name = $this->getOthermethodButtonName();
27
 
28
  ?>
29
 
30
- <?php if ($this->isButtonEnabled()==false) return; ?>
31
 
32
  <div id="klarna_methods" class="klarna_other-payment-methods klarna_block">
33
  <?php if ($this->isButtonNameUrl($button_name)): ?>
@@ -35,4 +35,13 @@ $button_name = $this->getOthermethodButtonName();
35
  <?php else: ?>
36
  <a href="#" class="button button-small button-action" onclick="klarnaCheckoutGo('<?php echo $this->getUrl('checkout/klarna/othermethod') ?>')"><?php echo $button_name?></a>
37
  <?php endif; ?>
38
- </div>
 
 
 
 
 
 
 
 
 
27
 
28
  ?>
29
 
30
+ <?php if ($this->isButtonEnabled()): ?>
31
 
32
  <div id="klarna_methods" class="klarna_other-payment-methods klarna_block">
33
  <?php if ($this->isButtonNameUrl($button_name)): ?>
35
  <?php else: ?>
36
  <a href="#" class="button button-small button-action" onclick="klarnaCheckoutGo('<?php echo $this->getUrl('checkout/klarna/othermethod') ?>')"><?php echo $button_name?></a>
37
  <?php endif; ?>
38
+ </div>
39
+
40
+ <?php endif; ?>
41
+
42
+ <?php if ($this->updateWhenPostcodeChanges()): ?>
43
+
44
+ <input id="klarna-checkout-shipping-update" type="hidden" value="<?php echo $this->getUrl('checkout/klarna/addressUpdate') ?>" />
45
+
46
+ <?php endif; ?>
47
+
app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/shipping_method/available.phtml CHANGED
@@ -33,31 +33,31 @@ $_shippingRateGroups = $this->getShippingRates();
33
 
34
  <?php else: ?>
35
 
36
- <ul>
37
- <?php $shippingCodePrice = array(); ?>
38
- <?php $_sole = count($_shippingRateGroups) == 1; ?>
39
- <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
40
- <?php $_sole = $_sole && count($_rates) == 1; ?>
41
- <?php foreach ($_rates as $_rate): ?>
42
- <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
43
- <li>
44
- <?php if ($_rate->getErrorMessage()): ?>
45
- <ul class="messages"><li class="error-msg"><ul><li><?php echo $this->escapeHtml($_rate->getErrorMessage()) ?></li></ul></li></ul>
46
- <?php else: ?>
47
- <input name="shipping_method" type="radio" class="shipping-method-input-radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> />
48
-
49
- <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $this->escapeHtml($_rate->getMethodTitle()) ?>,
50
- <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
51
- <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
52
- <?php echo $_excl; ?>
53
- <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
54
- (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
55
- <?php endif; ?>
56
- </label>
57
- <?php endif ?>
58
- </li>
59
- <?php endforeach; ?>
60
- <?php endforeach; ?>
61
- </ul>
62
 
63
  <?php endif; ?>
33
 
34
  <?php else: ?>
35
 
36
+ <ul>
37
+ <?php $shippingCodePrice = array(); ?>
38
+ <?php $_sole = count($_shippingRateGroups) == 1; ?>
39
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
40
+ <?php $_sole = $_sole && count($_rates) == 1; ?>
41
+ <?php foreach ($_rates as $_rate): ?>
42
+ <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
43
+ <li>
44
+ <?php if ($_rate->getErrorMessage()): ?>
45
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $this->escapeHtml($_rate->getErrorMessage()) ?></li></ul></li></ul>
46
+ <?php else: ?>
47
+ <input name="shipping_method" type="radio" class="shipping-method-input-radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> />
48
+
49
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $this->escapeHtml($_rate->getMethodTitle()) ?>,
50
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
51
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
52
+ <?php echo $_excl; ?>
53
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
54
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
55
+ <?php endif; ?>
56
+ </label>
57
+ <?php endif ?>
58
+ </li>
59
+ <?php endforeach; ?>
60
+ <?php endforeach; ?>
61
+ </ul>
62
 
63
  <?php endif; ?>
app/locale/da_DK/Vaimo_Klarna.csv CHANGED
@@ -162,3 +162,6 @@
162
  "2 columns with right sidebar","2 columns with right sidebar"
163
  "Show login form","Show login form"
164
  "Only for 2 column layout","Only for 2 column layout"
 
 
 
162
  "2 columns with right sidebar","2 columns with right sidebar"
163
  "Show login form","Show login form"
164
  "Only for 2 column layout","Only for 2 column layout"
165
+ "Shipping Countries","Shipping Countries"
166
+ "Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout"
167
+ "Please note that your official address will be used for shipping address when you place your order","Please note that your official address will be used for shipping address when you place your order"
app/locale/de_AT/Vaimo_Klarna.csv CHANGED
@@ -165,4 +165,7 @@
165
  "Order Summary", "Order Summary"
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
- "Login", "Login"
 
 
 
165
  "Order Summary", "Order Summary"
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
+ "Login", "Login"
169
+ "Shipping Countries","Shipping Countries"
170
+ "Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout"
171
+ "Please note that your official address will be used for shipping address when you place your order","Please note that your official address will be used for shipping address when you place your order"
app/locale/de_DE/Vaimo_Klarna.csv CHANGED
@@ -165,4 +165,7 @@
165
  "Order Summary", "Order Summary"
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
- "Login", "Login"
 
 
 
165
  "Order Summary", "Order Summary"
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
+ "Login", "Login"
169
+ "Shipping Countries","Shipping Countries"
170
+ "Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout"
171
+ "Please note that your official address will be used for shipping address when you place your order","Please note that your official address will be used for shipping address when you place your order"
app/locale/fi_FI/Vaimo_Klarna.csv CHANGED
@@ -165,4 +165,7 @@
165
  "Order Summary", "Order Summary"
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
- "Login", "Login"
 
 
 
165
  "Order Summary", "Order Summary"
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
+ "Login", "Login"
169
+ "Shipping Countries","Shipping Countries"
170
+ "Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout"
171
+ "Please note that your official address will be used for shipping address when you place your order","Please note that your official address will be used for shipping address when you place your order"
app/locale/nb_NO/Vaimo_Klarna.csv CHANGED
@@ -166,3 +166,6 @@
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
  "Login", "Login"
 
 
 
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
  "Login", "Login"
169
+ "Shipping Countries","Shipping Countries"
170
+ "Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout"
171
+ "Please note that your official address will be used for shipping address when you place your order","Please note that your official address will be used for shipping address when you place your order"
app/locale/nl_NL/Vaimo_Klarna.csv CHANGED
@@ -166,3 +166,6 @@
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
  "Login", "Login"
 
 
 
166
  "E-mail", "E-mail"
167
  "Password", "Password"
168
  "Login", "Login"
169
+ "Shipping Countries","Shipping Countries"
170
+ "Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout"
171
+ "Please note that your official address will be used for shipping address when you place your order","Please note that your official address will be used for shipping address when you place your order"
app/locale/nn_NO/Vaimo_Klarna.csv CHANGED
@@ -162,7 +162,10 @@
162
  "2 columns with right sidebar","2 columns with right sidebar"
163
  "Show login form","Show login form"
164
  "Only for 2 column layout","Only for 2 column layout"
165
- "Order Summary"
166
- "E-mail"
167
- "Password"
168
- "Login"
 
 
 
162
  "2 columns with right sidebar","2 columns with right sidebar"
163
  "Show login form","Show login form"
164
  "Only for 2 column layout","Only for 2 column layout"
165
+ "Order Summary", "Order Summary"
166
+ "E-mail", "E-mail"
167
+ "Password", "Password"
168
+ "Login", "Login"
169
+ "Shipping Countries","Shipping Countries"
170
+ "Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout","Specific for API V.3.1. List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout"
171
+ "Please note that your official address will be used for shipping address when you place your order","Please note that your official address will be used for shipping address when you place your order"
app/locale/sv_SE/Vaimo_Klarna.csv CHANGED
@@ -166,3 +166,6 @@
166
  "E-mail", "E-post"
167
  "Password", "Lösenord"
168
  "Login", "Logga in"
 
 
 
166
  "E-mail", "E-post"
167
  "Password", "Lösenord"
168
  "Login", "Logga in"
169
+ "Shipping Countries","Leverans till länder"
170
+ "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"
171
+ "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"
js/vaimo/klarna/klarnacheckout.js CHANGED
@@ -3,30 +3,160 @@
3
  var klarnaResponsive;
4
 
5
  function getCookie(name) {
6
- var re = new RegExp(name + "=([^;]+)");
7
- var value = re.exec(document.cookie);
8
- return (value != null) ? unescape(value[1]) : null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  };
10
 
11
  function updateCartKlarna(type, input, quantity) {
12
- var klarnaCart = document.getElementById("klarna_sidebar"), //"klarna_wrapper");
13
- klarnaContainer = document.getElementById("klarna_container"),
14
- klarnaLoader = document.getElementById("klarna_loader"),
15
- klarnaMsg = document.getElementById("klarna_msg"),
16
- klarnaMsgContent = document.getElementById("klarna_msg_content"),
17
- klarnaCartHtml = document.getElementById("klarna_cart_reload"),
18
- klarnaHtml = document.getElementById("klarna_checkout_reload"),
19
- klarnaCheckout = document.getElementById("klarna_checkout"),
20
- klarnaTotals = document.getElementById("klarna_totals"),
21
- klarnaCheckoutContainer = document.getElementById('klarna-checkout-container'),
22
- klarnaQtyInput = typeof input != 'undefined' ? input : null,
23
- klarnaQty = typeof quantity != 'undefined' ? quantity : null;
24
-
25
- klarnaMsg.style.display = 'none';
26
- klarnaMsg.className = klarnaMsg.className.replace( /(?:^|\s)error(?!\S)/g , '' );
27
- fadeIn(klarnaLoader);
28
-
29
- // Checks what part that triggered the updateCartKlarna()
30
  var formID = null;
31
  switch (type) {
32
  case 'cart':
@@ -39,12 +169,12 @@ function updateCartKlarna(type, input, quantity) {
39
  formID = document.getElementById('klarna_coupon');
40
  break;
41
  case 'giftcard':
42
- formID = document.getElementById('giftcard-form');
43
- break;
44
  case 'giftcard-remove':
45
- formID = document.getElementById('giftcard-form');
46
- ajaxUrl = input;
47
- break;
48
  case 'reward':
49
  formID = document.getElementById('klarna-checkout-reward');
50
  break;
@@ -56,139 +186,12 @@ function updateCartKlarna(type, input, quantity) {
56
 
57
  var dataString = formID.serialize(false);
58
  if (typeof ajaxUrl === "undefined") {
59
- var ajaxUrl = formID.getAttribute("action");
60
  }
61
 
62
  _klarnaCheckoutWrapper(function(api) {
63
  vanillaAjax(ajaxUrl, dataString,
64
- function (data) {
65
- var obj = JSON.parse(data);
66
- fadeOut(klarnaLoader);
67
- if (obj.redirect_url) {
68
- window.location.href = obj.redirect_url;
69
- } else if (obj.success) {
70
- if (getCookie("klarnaAddShipping") != 1) {
71
- klarnaMsgContent.innerHTML = obj.success;
72
- fadeIn(klarnaMsg);
73
- } else {
74
- document.cookie = 'klarnaAddShipping=0; expires=-1;';
75
- }
76
-
77
- var klarnaCartValue = '';
78
- if (klarnaCartHtml) {
79
- klarnaCartValue = klarnaCartHtml.value;
80
- }
81
-
82
- if (klarnaCartValue) {
83
- // Reload the Klarna iFrame.
84
- vanillaAjax(
85
- klarnaCartValue,
86
- '',
87
- function (results) {
88
- var objHtml = JSON.parse(results),
89
- matrixRateFeeEl = document.getElementById('s_method_matrixrate_matrixrate_free');
90
-
91
- // Redraw layout if is in responsive mode
92
- if(klarnaResponsive.getLayout() === 'two-column') {
93
- // Create a node for the fetched block
94
- var tempEl = document.createElement('span');
95
- tempEl.innerHTML = objHtml.update_sections.html;
96
-
97
- klarnaResponsive.drawLayoutForElement(tempEl.firstChild);
98
- }
99
- else { // Otherwise just replace the old sidebar with the new one
100
- document.getElementById('klarna_default').innerHTML = objHtml.update_sections.html;
101
- }
102
-
103
- if (getCookie("klarnaDiscountShipping") == 1) {
104
- document.cookie = 'klarnaDiscountShipping=0; expires=0;';
105
- if (matrixRateFeeEl && matrixRateFeeEl.innerHTML.length > 0 && matrixRateFeeEl.checked){
106
- matrixRateFeeEl.checked = true;
107
- }
108
- updateCartKlarna("shipping");
109
- }
110
-
111
- //for (i=0;i<3;i++) { // "Highlight" the totals table
112
- // fadeOut(document.getElementById("klarna_totals"));
113
- fadeIn(document.getElementById("klarna_totals"));
114
- //}
115
-
116
- vanillaAjax( // Refresh the Klarna iFrame
117
- klarnaHtml.value,
118
- '',
119
- function(results) {
120
- var objKlarnaHtml = JSON.parse(results);
121
- var evaluatedObjKlarnaHtml = objKlarnaHtml.update_sections.html;
122
- var textNode = document.createTextNode(objKlarnaHtml.update_sections.html);
123
- var scriptToEval = textNode.substringData(evaluatedObjKlarnaHtml.search('<script')+31, evaluatedObjKlarnaHtml.search('</script')-evaluatedObjKlarnaHtml.search('<script')-31);
124
- var js = document.createElement('script');
125
- js.async = true;
126
- js.innerHTML = scriptToEval;
127
-
128
- klarnaCheckoutContainer.innerHTML = '';//eval(scriptToEval);
129
- klarnaCheckoutContainer.appendChild(js);
130
- bindCheckoutControls();
131
-
132
- //klarnaCheckout.innerHTML = objKlarnaHtml.update_sections.html;//eval(scriptToEval);
133
-
134
- /*
135
- var scripts = document.getElementsByTagName('script');
136
- for (i=0; i<scripts.length;i++) {
137
- scriptNode = scripts[i];
138
- if (scriptNode.parentNode.id=='klarna-checkout-container') {
139
- //eval(scriptNode.innerHTML);
140
- console.log(scriptNode.innerHTML);
141
- }
142
- }*/
143
-
144
- api.resume();
145
- }, '', ''
146
- );
147
- }, '', ''
148
- );
149
- } else {
150
- vanillaAjax( // Refresh the Klarna iFrame
151
- klarnaHtml.value,
152
- '',
153
- function(results) {
154
- if (getCookie("klarnaDiscountShipping") == 1) {
155
- document.cookie = 'klarnaDiscountShipping=0; expires=0;';
156
- if (document.getElementById('s_method_matrixrate_matrixrate_free').innerHTML.length > 0 && document.getElementById('s_method_matrixrate_matrixrate_free').checked){
157
- document.getElementById('s_method_matrixrate_matrixrate_free').checked = true;
158
- }
159
- updateCartKlarna("shipping");
160
- }
161
-
162
- //for (i=0;i<3;i++) { // "Highlight" the totals table
163
- // fadeOut(document.getElementById("klarna_totals"));
164
- fadeIn(document.getElementById("klarna_totals"));
165
- //}
166
- var objKlarnaHtml = JSON.parse(results);
167
- var evaluatedObjKlarnaHtml = objKlarnaHtml.update_sections.html;
168
- var textNode = document.createTextNode(objKlarnaHtml.update_sections.html);
169
- var scriptToEval = textNode.substringData(evaluatedObjKlarnaHtml.search('<script')+31, evaluatedObjKlarnaHtml.search('</script')-evaluatedObjKlarnaHtml.search('<script')-31);
170
- var js = document.createElement('script');
171
- js.async = true;
172
- js.innerHTML = scriptToEval;
173
-
174
- klarnaCheckoutContainer.innerHTML = '';//eval(scriptToEval);
175
- klarnaCheckoutContainer.appendChild(js);
176
- bindCheckoutControls();
177
-
178
- api.resume();
179
- }, '', ''
180
- );
181
- }
182
- } else if (obj.error) {
183
- klarnaMsgContent.innerHTML = obj.error;
184
- klarnaMsg.className += "error";
185
- fadeIn(klarnaMsg);
186
- if (klarnaQtyInput) {
187
- klarnaQtyInput.value = klarnaQty;
188
- }
189
- api.resume();
190
- }
191
- },
192
  function(data) {
193
  alert(data);
194
  },
@@ -197,161 +200,168 @@ function updateCartKlarna(type, input, quantity) {
197
  }
198
  );
199
  });
200
- setTimeout(function() { // Fade out the "alert" after 3,5 seconds
201
- fadeOut(klarnaMsg);
202
- }, 3500)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  };
204
 
205
  /** Bindings * */
206
 
207
  function bindCheckoutControls() {
208
 
209
- // Helpfull element variables
210
- var
211
  removeItemElement = document.getElementsByClassName('remove-item'),
212
  subtrackItemElement = document.getElementsByClassName('subtract-item'),
213
  addItemElement = document.getElementsByClassName('add-item'),
214
  qtyInputList = document.getElementsByClassName('qty-input'),
215
  shippingMethods = document.getElementsByName('shipping_method');
216
 
217
- // Bind newsletter checkbox
218
- if (document.getElementById('klarna-checkout-newsletter')) {
219
- document.getElementById('klarna-checkout-newsletter').onchange = function() {
220
- var url = document.getElementById('klarna-checkout-newsletter-url').value;
221
- var type = Number(document.getElementById('klarna-checkout-newsletter-type').value);
222
- var checked = false;
223
- switch (type) {
224
- case 1:
225
- checked = this.checked ? 1 : 0;
226
- break;
227
- case 2:
228
- checked = this.checked ? 0 : 1;
229
- break;
230
- }
231
- this.disabled = 'disabled';
232
- vanillaAjax(url, 'subscribe_to_newsletter=checked', function(){
233
- document.getElementById('klarna-checkout-newsletter').disabled = '';
234
- });
235
- };
236
- };
237
-
238
- // Reward
239
- if (document.getElementsByName('use_reward_points')[0]) {
240
- document.getElementsByName('use_reward_points')[0].onchange = function() {
241
- updateCartKlarna('reward');
242
- };
243
- };
244
-
245
- // Store Credit
246
- if (document.getElementsByName('use_customer_balance')[0]) {
247
- document.getElementsByName('use_customer_balance')[0].onchange = function() {
248
- updateCartKlarna('customer_balance');
249
- };
250
- };
251
-
252
- // Change shipping method
253
- if (shippingMethods) {
254
  for (var q=0; q<shippingMethods.length; q++) {
255
  shippingMethodItem = shippingMethods[q];
256
  shippingMethodItem.onchange = function() {
257
- updateCartKlarna("shipping");
258
- updateCartKlarna("cart");
259
  return false;
260
  };
261
  };
262
- };
263
-
264
-
265
- // Coupon
266
- if (document.querySelector('#klarna_coupon button')) {
267
- document.querySelector('#klarna_coupon button').onclick = function() {
268
- var couponRemove = document.getElementById('remove-coupone');
269
- var couponInput = document.getElementById('coupon_code');
270
-
271
- if (this.className.match(/(?:^|\s)cancel-btn(?!\S)/)) {
272
- couponRemove.value = 1;
273
- document.cookie = 'klarnaDiscountShipping=1; expires=0;';
274
- updateCartKlarna("coupon");
275
- updateCartKlarna("cart");
276
- } else if (!couponInput.value) {
277
- couponInput.focus();
278
- for(i=0;i<3;i++) {
279
- fadeOut(couponInput);
280
- fadeIn(couponInput);
281
- }
282
- setTimeout(function() {
283
- couponInput.className = couponInput.className.replace( /(?:^|\s)error(?!\S)/g , '' )
284
- }, 6000)
285
- } else {
286
- document.cookie = 'klarnaDiscountShipping=1; expires=0;';
287
- updateCartKlarna('coupon');
288
- updateCartKlarna("cart");
289
- }
290
- };
291
- }
292
 
293
  if (document.getElementById('coupon_code')) {
294
- document.getElementById('coupon_code').onkeydown = function(e) {
295
- if (e.which == 13) {
296
- e.preventDefault();
297
- updateCartKlarna("coupon");
298
- }
299
- };
300
- }
301
 
302
 
303
- // Giftcard
304
  if (document.querySelector('#giftcard-form button')) {
305
- document.querySelector('#giftcard-form button').onclick = function(e) {
306
- e.preventDefault();
307
- var giftcardInput = document.getElementById('giftcard_code');
308
-
309
- if (!giftcardInput.value) {
310
- giftcardInput.focus();
311
- for (i = 0; i < 3; i++) {
312
- fadeOut(giftcardInput);
313
- fadeIn(giftcardInput);
314
- }
315
- setTimeout(function() {
316
- giftcardInput.className = couponInput.className.replace(
317
- /(?:^|\s)error(?!\S)/g, '')
318
- }, 6000)
319
- } else {
320
- updateCartKlarna('giftcard');
321
- updateCartKlarna('cart');
322
- }
323
- };
324
- }
325
-
326
- if (document.getElementById('giftcard_code')) {
327
- document.getElementById('giftcard_code').onkeydown = function(e) {
328
- if (e.which == 13) {
329
- e.preventDefault();
330
- updateCartKlarna("giftcard");
331
- }
332
- };
333
- }
334
-
335
- // Giftcard remove on Klarna
336
- if (document.querySelector('#applied-gift-cards .btn-remove')) {
337
- document.querySelector('#applied-gift-cards .btn-remove').onclick = function(e) {
338
- e.preventDefault();
339
- updateCartKlarna('giftcard-remove', this.getAttribute('href'));
340
- updateCartKlarna('cart');
341
- };
342
- }
343
-
344
- for (var q = 0; q < removeItemElement.length; q++) {
345
- var removeItem = removeItemElement[q];
346
- removeItem.addEventListener('click', function (e) {
347
- e.preventDefault();
348
-
349
- var itemid = this.getAttribute('data-itemid');
350
- fadeOut(document.getElementById('cart_item_' + itemid));
351
- document.getElementById('cart_item_qty_' + itemid).value = 0;
352
- updateCartKlarna("cart");
353
- });
354
- }
355
 
356
  for (var q=0; q<subtrackItemElement.length; q++) {
357
  subtrackItem = subtrackItemElement[q];
@@ -364,7 +374,7 @@ function bindCheckoutControls() {
364
  if (qtyCurrent - 1 == 0) {
365
  fadeOut(document.getElementById('cart_item_' + itemid));
366
  }
367
- updateCartKlarna("cart", qtyInput, qtyCurrent);
368
  return false;
369
  };
370
  };
@@ -377,293 +387,305 @@ function bindCheckoutControls() {
377
  qtyCurrent = parseInt(qtyInput.value);
378
 
379
  qtyInput.value = (qtyCurrent + 1);
380
- updateCartKlarna("cart", qtyInput, qtyCurrent);
381
  return false;
382
  };
383
  };
384
 
385
- for (var q=0; q<qtyInputList.length; q++) {
386
- inputField = qtyInputList[q];
387
-
388
- inputField.onblur = function() {
389
- var itemid = this.getAttribute('data-itemid'),
390
- qtyInput = document.getElementById('cart_item_qty_' + itemid),
391
- qtyCurrent = parseInt(qtyInput.value),
392
- qtyOrgInput = document.getElementById('cart_item_qty_org_' + itemid),
393
- qtyOrgCurrent = parseInt(qtyOrgInput.value);
394
-
395
- if (qtyCurrent != qtyOrgCurrent) {
396
- updateCartKlarna("cart", qtyInput, qtyOrgCurrent);
397
- }
398
- };
399
-
400
- inputField.onkeydown = function(e) {
401
- if (e.which == 13) {
402
- e.preventDefault();
403
- var itemid = this.getAttribute('data-itemid'),
404
- qtyInput = document.getElementById('cart_item_qty_' + itemid),
405
- qtyCurrent = parseInt(qtyInput.value),
406
- qtyOrgInput = document.getElementById('cart_item_qty_org_' + itemid),
407
- qtyOrgCurrent = parseInt(qtyOrgInput.value);
408
-
409
- if (qtyCurrent != qtyOrgCurrent) {
410
- updateCartKlarna("cart", qtyInput, qtyOrgCurrent);
411
- }
412
- }
413
- };
414
- };
415
 
416
  };
417
 
418
  var KlarnaLogin = (function () {
419
- "use strict";
420
-
421
- var me = function (config) {
422
- var cfg = config || {};
423
-
424
- this.form = cfg.form || document.getElementById('klarna_form-login');
425
- this.registerListeners();
426
- };
427
-
428
- me.prototype.registerListeners = function () {
429
- if(this.form) {
430
- this.form.addEventListener('submit', this.doLogin.bind(this));
431
- }
432
- };
433
-
434
- me.prototype.doLogin = function (e) {
435
- e.preventDefault();
436
-
437
- var form = e.target,
438
- data = form.serialize(false),
439
- url = form.action;
440
-
441
- vanillaAjax(url, data, this.successCallback.bind(this), this.errorCallback.bind(this));
442
- };
443
-
444
- me.prototype.showMessage = function (message) {
445
- var messageEl = document.getElementById('klarna_msg'),
446
- messageContentEl = messageEl.querySelector('.klarna_msg-content');
447
-
448
- messageContentEl.textContent = message;
449
- fadeIn(messageEl);
450
- };
451
-
452
- me.prototype.successCallback = function (response) {
453
- var data = JSON.parse(response),
454
- messageEl = document.getElementById('klarna_msg');
455
-
456
- // Show message if we get a response code
457
- if(!isNaN(data['r_code'])) {
458
-
459
- if (data['r_code'] < 0 || messageEl.classList.contains('error')) { // Error
460
- messageEl.classList.add('error');
461
- this.showMessage(data.message);
462
- } else {
463
- messageEl.classList.remove('error'); // Success
464
-
465
- this.showMessage(data.message);
466
-
467
- /**
468
- * Reload the page so that the Klarna iframe is updated with
469
- * the user's email, address etc.
470
- */
471
- window.location.reload();
472
- }
473
- }
474
- };
475
-
476
- me.prototype.errorCallback = function (response) {
477
- try {
478
- var data = JSON.parse(response);
479
- this.showMessage(data.message);
480
- }
481
- catch (e) {
482
- var loginFailedText = Translator.translate("Could not log in. Please try again");
483
- this.showMessage(loginFailedText);
484
- }
485
-
486
- console.log("Login failed! Here's the data:");
487
- console.log(data);
488
- };
489
-
490
- return me;
491
  })();
492
 
493
  var KlarnaResponsive = (function () {
494
- var me = function (config) {
495
- var cfg = config || {};
496
-
497
- this.element = cfg.element || document.getElementById('klarna_container');
498
- this.isRunning = false;
499
- this.storedSidebarEl = document.createDocumentFragment();
500
- this.mobileBreakPoint = 992;
501
-
502
- // Only run init functions if the site admin has set the Klarna module to use the responsive layout
503
- if(this.getLayout() === 'two-column') {
504
- this.registerListeners();
505
- this.updateLayout();
506
- }
507
- };
508
-
509
- me.prototype.registerListeners = function () {
510
- window.addEventListener('resize', resize.bind(this));
511
- };
512
-
513
- function resize(e) {
514
- if (!this.isRunning) {
515
- this.isRunning = true;
516
-
517
- if (window.requestAnimationFrame) {
518
- window.requestAnimationFrame(this.updateLayout.bind(this));
519
- } else {
520
- setTimeout(this.updateLayout.bind(this), 66);
521
- }
522
- }
523
- }
524
-
525
- me.prototype.getLayout = function () {
526
- var layoutVal = parseInt(this.element.getAttribute('data-layout'));
527
-
528
- if(layoutVal === 0) {
529
- return 'default';
530
- }
531
- else if (layoutVal === 1) {
532
- return 'two-column';
533
- }
534
-
535
- return '';
536
- };
537
-
538
- me.prototype.getDesktopLayout = function (el) {
539
- var sidebarEls = getSidebarElements(el),
540
- docFragment = document.createDocumentFragment(),
541
- fragmentSidebarEl,
542
- sidebarEl = el || this.storedSidebarEl;
543
-
544
- docFragment.appendChild(sidebarEl);
545
- fragmentSidebarEl = docFragment.querySelector('#klarna_sidebar');
546
-
547
- // Add all sidebar items to the temporary sidebar fragment
548
- fragmentSidebarEl.appendChild(sidebarEls.payment);
549
- fragmentSidebarEl.appendChild(sidebarEls.shipping);
550
- fragmentSidebarEl.appendChild(sidebarEls.cart);
551
- fragmentSidebarEl.appendChild(sidebarEls.discount);
552
-
553
- return docFragment;
554
- };
555
-
556
- me.prototype.setMobileLayout = function (el) {
557
- var groupedEls = getSidebarElements(el, true),
558
- sidebarEls = getSidebarElements(el),
559
- mainContentEl = document.getElementById('klarna_main'),
560
- iframeEl = document.getElementById('klarna_checkout'),
561
- tempEl = document.createDocumentFragment();
562
-
563
- for(var key in groupedEls) {
564
- if(groupedEls.hasOwnProperty(key)) {
565
- tempEl.appendChild(groupedEls[key]);
566
- }
567
- }
568
-
569
- mainContentEl.insertBefore(tempEl, iframeEl);
570
- mainContentEl.appendChild(sidebarEls.payment);
571
- };
572
-
573
- /**
574
- * Gets the sidebar children elements as an object
575
- * @param sidebarEl (optional)
576
- * @param getGroup
577
- * @returns {{cart: HTMLElement, shipping: HTMLElement, discount: HTMLElement}}
578
- */
579
- function getSidebarElements (sidebarEl, getGroup) {
580
- var ref = sidebarEl || document,
581
- cartEl = ref.querySelector('#klarna_cart-container'),
582
- shippingEl = ref.querySelector('#klarna_shipping'),
583
- discountEl = ref.querySelector('#klarna_discount'),
584
- groupedEls = {
585
- cart: cartEl,
586
- shipping: shippingEl,
587
- discount: discountEl
588
- },
589
- sidebarEls = groupedEls;
590
-
591
- sidebarEls.payment = ref.querySelector('#klarna_methods');
592
-
593
- return getGroup ? groupedEls : sidebarEls;
594
- }
595
-
596
- /**
597
- * Checks if the current viewport width corresponds to the predefined mobile breakpoint
598
- * and if so changes the layout to mobile. Otherwise the layout is set to desktop.
599
- */
600
- me.prototype.updateLayout = function () {
601
- var sidebarEl = document.getElementById('klarna_sidebar'),
602
- klarnaContainer = document.getElementById('klarna_container'),
603
- mainContentEl = document.getElementById('klarna_main'),
604
- cartEl = document.getElementById('klarna_cart-container');
605
-
606
- if(this.getMode() === 'mobile' && sidebarEl && !mainContentEl.contains(cartEl)) {
607
- this.storedSidebarEl = sidebarEl.cloneNode(false);
608
-
609
- this.setMobileLayout();
610
-
611
- sidebarEl.parentNode.removeChild(sidebarEl);
612
- }
613
- else if(this.getMode() === 'desktop' && !sidebarEl && mainContentEl.contains(cartEl)) {
614
- klarnaContainer.appendChild(this.getDesktopLayout());
615
- }
616
-
617
- this.isRunning = false;
618
- };
619
-
620
- me.prototype.getMode = function () {
621
- var viewportWidth = window.innerWidth;
622
-
623
- if(viewportWidth < this.mobileBreakPoint) {
624
- return 'mobile';
625
- }
626
- else if(viewportWidth >= this.mobileBreakPoint) {
627
- return 'desktop';
628
- }
629
- else {
630
- return false;
631
- }
632
- };
633
-
634
- /**
635
- * Renders the given element as a sidebar or as a part of the main content depending
636
- * on whether the browser window is in "mobile" or "desktop" mode. This is mostly intended to be used
637
- * when the cart is updated through AJAX as the AJAX response will typically be an html view.
638
- * @param el {HTMLElement}
639
- */
640
- me.prototype.drawLayoutForElement = function (el) {
641
- if(!el) {
642
- return false;
643
- }
644
-
645
- var klarnaContainer = document.getElementById('klarna_container'),
646
- mainContentEl = document.getElementById('klarna_main');
647
-
648
- if(this.getMode() === 'mobile') {
649
- var sidebarEls = getSidebarElements(null, true);
650
-
651
- // Remove all the current sidebar items inside the main content area
652
- for(var key in sidebarEls) {
653
- if(sidebarEls.hasOwnProperty(key)) {
654
- mainContentEl.removeChild(sidebarEls[key]);
655
- }
656
- }
657
-
658
- this.setMobileLayout(el);
659
- }
660
- else {
661
- var newSidebar = this.getDesktopLayout(el);
662
- klarnaContainer.replaceChild(newSidebar, klarnaContainer.querySelector('#klarna_sidebar'));
663
- }
664
- };
665
-
666
- return me;
 
 
 
 
 
 
 
 
 
 
 
 
667
  })();
668
 
669
 
@@ -671,27 +693,53 @@ var KlarnaResponsive = (function () {
671
  // If there's no shipping option selected when the document loads, then select
672
  // the first option
673
  docReady(function() {
674
- // Enable responsive mode if layout is 2-column-right
675
- //var isDefaultLayout = document.getElementById('klarna_container').getAttribute('data-layout');
676
- //if(!isDefaultLayout && isDefaultLayout !== '') {
677
- klarnaResponsive = new KlarnaResponsive();
678
- //}
679
-
680
- // Add login functionality if the form exists
681
- if (document.getElementById('klarna_form-login')) {
682
- new KlarnaLogin();
683
- }
684
-
685
- var shippingChecked = document.getElementsByClassName('.shipping-method-input-radio:checked');
686
- document.cookie = 'klarnaDiscountShipping=0; expires=0;';
687
-
688
- if (!shippingChecked) {
689
- document.querySelector("input[name=shipping_method]:first-child").checked = true;
690
- document.cookie = 'klarnaAddShipping=1; expires=0;';
691
- updateCartKlarna("shipping");
692
- }
693
-
694
- bindCheckoutControls();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
695
 
696
  });
697
 
3
  var klarnaResponsive;
4
 
5
  function getCookie(name) {
6
+ var re = new RegExp(name + "=([^;]+)");
7
+ var value = re.exec(document.cookie);
8
+ return (value != null) ? unescape(value[1]) : null;
9
+ };
10
+
11
+ function reloadKlarnaIFrame(results) {
12
+ var klarnaCart = document.getElementById("klarna_sidebar"), //"klarna_wrapper");
13
+ klarnaContainer = document.getElementById("klarna_container"),
14
+ klarnaLoader = document.getElementById("klarna_loader"),
15
+ klarnaMsg = document.getElementById("klarna_msg"),
16
+ klarnaMsgContent = document.getElementById("klarna_msg_content"),
17
+ klarnaCartHtml = document.getElementById("klarna_cart_reload"),
18
+ klarnaHtml = document.getElementById("klarna_checkout_reload"),
19
+ klarnaCheckout = document.getElementById("klarna_checkout"),
20
+ klarnaTotals = document.getElementById("klarna_totals"),
21
+ klarnaCheckoutContainer = document.getElementById('klarna-checkout-container'),
22
+ klarnaQtyInput = typeof input != 'undefined' ? input : null,
23
+ klarnaQty = typeof quantity != 'undefined' ? quantity : null;
24
+ var objHtml = JSON.parse(results),
25
+ matrixRateFeeEl = document.getElementById('s_method_matrixrate_matrixrate_free');
26
+
27
+ // Redraw layout if is in responsive mode
28
+ if(klarnaResponsive.getLayout() === 'two-column') {
29
+ // Create a node for the fetched block
30
+ var tempEl = document.createElement('span');
31
+ tempEl.innerHTML = objHtml.update_sections.html;
32
+
33
+ klarnaResponsive.drawLayoutForElement(tempEl.firstChild);
34
+ }
35
+ else { // Otherwise just replace the old sidebar with the new one
36
+ document.getElementById('klarna_default').innerHTML = objHtml.update_sections.html;
37
+ }
38
+
39
+ if (getCookie("klarnaDiscountShipping") == 1) {
40
+ document.cookie = 'klarnaDiscountShipping=0; expires=0;';
41
+ if (matrixRateFeeEl && matrixRateFeeEl.innerHTML.length > 0 && matrixRateFeeEl.checked){
42
+ matrixRateFeeEl.checked = true;
43
+ }
44
+ massUpdateCartKlarna(["shipping"], '', '');
45
+ }
46
+
47
+ fadeIn(document.getElementById("klarna_totals"));
48
+
49
+ vanillaAjax( // Refresh the Klarna iFrame
50
+ klarnaHtml.value,
51
+ '',
52
+ refreshKlarnaIFrame, '', '');
53
+ };
54
+
55
+ function refreshKlarnaIFrame(results) {
56
+ var klarnaCart = document.getElementById("klarna_sidebar"), //"klarna_wrapper");
57
+ klarnaContainer = document.getElementById("klarna_container"),
58
+ klarnaLoader = document.getElementById("klarna_loader"),
59
+ klarnaMsg = document.getElementById("klarna_msg"),
60
+ klarnaMsgContent = document.getElementById("klarna_msg_content"),
61
+ klarnaCartHtml = document.getElementById("klarna_cart_reload"),
62
+ klarnaHtml = document.getElementById("klarna_checkout_reload"),
63
+ klarnaCheckout = document.getElementById("klarna_checkout"),
64
+ klarnaTotals = document.getElementById("klarna_totals"),
65
+ klarnaCheckoutContainer = document.getElementById('klarna-checkout-container'),
66
+ klarnaQtyInput = typeof input != 'undefined' ? input : null,
67
+ klarnaQty = typeof quantity != 'undefined' ? quantity : null;
68
+
69
+ if (getCookie("klarnaDiscountShipping") == 1) {
70
+ document.cookie = 'klarnaDiscountShipping=0; expires=0;';
71
+ if (document.getElementById('s_method_matrixrate_matrixrate_free') && document.getElementById('s_method_matrixrate_matrixrate_free').checked){
72
+ document.getElementById('s_method_matrixrate_matrixrate_free').checked = true;
73
+ }
74
+ massUpdateCartKlarna(["shipping"], '', '');
75
+ }
76
+
77
+ fadeIn(document.getElementById("klarna_totals"));
78
+ var objKlarnaHtml = JSON.parse(results);
79
+ var evaluatedObjKlarnaHtml = objKlarnaHtml.update_sections.html;
80
+ var textNode = document.createTextNode(objKlarnaHtml.update_sections.html);
81
+ var scriptToEval = textNode.substringData(evaluatedObjKlarnaHtml.search('<script')+31, evaluatedObjKlarnaHtml.search('</script')-evaluatedObjKlarnaHtml.search('<script')-31);
82
+ var js = document.createElement('script');
83
+ js.async = true;
84
+ js.innerHTML = scriptToEval;
85
+
86
+ klarnaCheckoutContainer.innerHTML = '';//eval(scriptToEval);
87
+ klarnaCheckoutContainer.appendChild(js);
88
+ bindCheckoutControls();
89
+ hideLoader();
90
+ };
91
+
92
+ function refreshKlarna(data) {
93
+ var klarnaCart = document.getElementById("klarna_sidebar"), //"klarna_wrapper");
94
+ klarnaContainer = document.getElementById("klarna_container"),
95
+ klarnaLoader = document.getElementById("klarna_loader"),
96
+ klarnaMsg = document.getElementById("klarna_msg"),
97
+ klarnaMsgContent = document.getElementById("klarna_msg_content"),
98
+ klarnaCartHtml = document.getElementById("klarna_cart_reload"),
99
+ klarnaHtml = document.getElementById("klarna_checkout_reload");
100
+
101
+ var obj = JSON.parse(data);
102
+ //fadeOut(klarnaLoader);
103
+ if (obj.redirect_url) {
104
+ window.location.href = obj.redirect_url;
105
+ } else if (obj.success) {
106
+ if (getCookie("klarnaAddShipping") != 1) {
107
+ klarnaMsgContent.innerHTML = obj.success;
108
+ fadeIn(klarnaMsg);
109
+ } else {
110
+ document.cookie = 'klarnaAddShipping=0; expires=-1;';
111
+ }
112
+
113
+ var klarnaCartValue = '';
114
+ if (klarnaCartHtml) {
115
+ klarnaCartValue = klarnaCartHtml.value;
116
+ }
117
+
118
+ if (klarnaCartValue && window.reloadKlarnaIFrameFlag) {
119
+ // Reload the Klarna iFrame.
120
+ vanillaAjax(
121
+ klarnaCartValue,
122
+ '',
123
+ reloadKlarnaIFrame, '', ''
124
+ );
125
+ } else if (window.reloadKlarnaIFrameFlag) {
126
+ vanillaAjax( // Refresh the Klarna iFrame
127
+ klarnaHtml.value,
128
+ '',
129
+ refreshKlarnaIFrame, '', ''
130
+ );
131
+ }
132
+ } else if (obj.error) {
133
+ klarnaMsgContent.innerHTML = obj.error;
134
+ klarnaMsg.className += "error";
135
+ fadeIn(klarnaMsg);
136
+ if (klarnaQtyInput) {
137
+ klarnaQtyInput.value = klarnaQty;
138
+ }
139
+ }
140
  };
141
 
142
  function updateCartKlarna(type, input, quantity) {
143
+ var klarnaCart = document.getElementById("klarna_sidebar"), //"klarna_wrapper");
144
+ klarnaContainer = document.getElementById("klarna_container"),
145
+ klarnaLoader = document.getElementById("klarna_loader"),
146
+ klarnaMsg = document.getElementById("klarna_msg"),
147
+ klarnaMsgContent = document.getElementById("klarna_msg_content"),
148
+ klarnaCartHtml = document.getElementById("klarna_cart_reload"),
149
+ klarnaHtml = document.getElementById("klarna_checkout_reload"),
150
+ klarnaCheckout = document.getElementById("klarna_checkout"),
151
+ klarnaTotals = document.getElementById("klarna_totals"),
152
+ klarnaCheckoutContainer = document.getElementById('klarna-checkout-container'),
153
+ klarnaQtyInput = typeof input != 'undefined' ? input : null,
154
+ klarnaQty = typeof quantity != 'undefined' ? quantity : null;
155
+
156
+ klarnaMsg.style.display = 'none';
157
+ klarnaMsg.className = klarnaMsg.className.replace( /(?:^|\s)error(?!\S)/g , '' );
158
+
159
+ // Checks what part that triggered the updateCartKlarna()
 
160
  var formID = null;
161
  switch (type) {
162
  case 'cart':
169
  formID = document.getElementById('klarna_coupon');
170
  break;
171
  case 'giftcard':
172
+ formID = document.getElementById('giftcard-form');
173
+ break;
174
  case 'giftcard-remove':
175
+ formID = document.getElementById('giftcard-form');
176
+ ajaxUrl = input;
177
+ break;
178
  case 'reward':
179
  formID = document.getElementById('klarna-checkout-reward');
180
  break;
186
 
187
  var dataString = formID.serialize(false);
188
  if (typeof ajaxUrl === "undefined") {
189
+ var ajaxUrl = formID.getAttribute("action");
190
  }
191
 
192
  _klarnaCheckoutWrapper(function(api) {
193
  vanillaAjax(ajaxUrl, dataString,
194
+ refreshKlarna,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  function(data) {
196
  alert(data);
197
  },
200
  }
201
  );
202
  });
203
+ setTimeout(function() { // Fade out the "alert" after 3,5 seconds
204
+ fadeOut(klarnaMsg);
205
+ }, 3500)
206
+ };
207
+
208
+ function hideLoader() {
209
+ var klarnaLoader = document.getElementById("klarna_loader");
210
+ fadeOut(klarnaLoader);
211
+ }
212
+
213
+ function massUpdateCartKlarna(typeArray, input, quantity) {
214
+ klarnaCheckoutSuspend();
215
+ window.reloadKlarnaIFrameFlag = false;
216
+ for (i = 0; i < typeArray.length; i++) {
217
+ if (i == typeArray.length-1) { window.reloadKlarnaIFrameFlag = true; }
218
+ updateCartKlarna(typeArray[i], input, quantity);
219
+ }
220
+ klarnaCheckoutResume();
221
  };
222
 
223
  /** Bindings * */
224
 
225
  function bindCheckoutControls() {
226
 
227
+ // Helpfull element variables
228
+ var
229
  removeItemElement = document.getElementsByClassName('remove-item'),
230
  subtrackItemElement = document.getElementsByClassName('subtract-item'),
231
  addItemElement = document.getElementsByClassName('add-item'),
232
  qtyInputList = document.getElementsByClassName('qty-input'),
233
  shippingMethods = document.getElementsByName('shipping_method');
234
 
235
+ // Bind newsletter checkbox
236
+ if (document.getElementById('klarna-checkout-newsletter')) {
237
+ document.getElementById('klarna-checkout-newsletter').onchange = function() {
238
+ var url = document.getElementById('klarna-checkout-newsletter-url').value;
239
+ var type = Number(document.getElementById('klarna-checkout-newsletter-type').value);
240
+ var checked = false;
241
+ switch (type) {
242
+ case 1:
243
+ checked = this.checked ? 1 : 0;
244
+ break;
245
+ case 2:
246
+ checked = this.checked ? 0 : 1;
247
+ break;
248
+ }
249
+ this.disabled = 'disabled';
250
+ vanillaAjax(url, 'subscribe_to_newsletter=' + checked, function(){
251
+ document.getElementById('klarna-checkout-newsletter').disabled = '';
252
+ });
253
+ };
254
+ };
255
+
256
+ // Reward
257
+ if (document.getElementsByName('use_reward_points')[0]) {
258
+ document.getElementsByName('use_reward_points')[0].onchange = function() {
259
+ massUpdateCartKlarna(['reward'], '', '');
260
+ };
261
+ };
262
+
263
+ // Store Credit
264
+ if (document.getElementsByName('use_customer_balance')[0]) {
265
+ document.getElementsByName('use_customer_balance')[0].onchange = function() {
266
+ massUpdateCartKlarna(['customer_balance'], '', '');
267
+ };
268
+ };
269
+
270
+ // Change shipping method
271
+ if (shippingMethods) {
272
  for (var q=0; q<shippingMethods.length; q++) {
273
  shippingMethodItem = shippingMethods[q];
274
  shippingMethodItem.onchange = function() {
275
+ massUpdateCartKlarna(["shipping","cart"], '', '');
 
276
  return false;
277
  };
278
  };
279
+ };
280
+
281
+
282
+ // Coupon
283
+ if (document.querySelector('#klarna_coupon button')) {
284
+ document.querySelector('#klarna_coupon button').onclick = function() {
285
+ var couponRemove = document.getElementById('remove-coupone');
286
+ var couponInput = document.getElementById('coupon_code');
287
+
288
+ if (this.className.match(/(?:^|\s)cancel-btn(?!\S)/)) {
289
+ couponRemove.value = 1;
290
+ document.cookie = 'klarnaDiscountShipping=1; expires=0;';
291
+ massUpdateCartKlarna(["coupon", "cart"], '', '');
292
+ } else if (!couponInput.value) {
293
+ couponInput.focus();
294
+ couponInput.className += " error";
295
+ setTimeout(function() {
296
+ couponInput.className = couponInput.className.replace( /(?:^|\s)error(?!\S)/g , '' )
297
+ }, 6000)
298
+ } else {
299
+ document.cookie = 'klarnaDiscountShipping=1; expires=0;';
300
+ massUpdateCartKlarna(["coupon", "cart"], '', '');
301
+ }
302
+ };
303
+ }
 
 
 
 
 
304
 
305
  if (document.getElementById('coupon_code')) {
306
+ document.getElementById('coupon_code').onkeydown = function(e) {
307
+ if (e.which == 13) {
308
+ e.preventDefault();
309
+ massUpdateCartKlarna(["coupon"], '', '');
310
+ }
311
+ };
312
+ }
313
 
314
 
315
+ // Giftcard
316
  if (document.querySelector('#giftcard-form button')) {
317
+ document.querySelector('#giftcard-form button').onclick = function(e) {
318
+ e.preventDefault();
319
+ var giftcardInput = document.getElementById('giftcard_code');
320
+
321
+ if (!giftcardInput.value) {
322
+ giftcardInput.focus();
323
+ for (i = 0; i < 3; i++) {
324
+ fadeOut(giftcardInput);
325
+ fadeIn(giftcardInput);
326
+ }
327
+ setTimeout(function() {
328
+ giftcardInput.className = couponInput.className.replace(
329
+ /(?:^|\s)error(?!\S)/g, '')
330
+ }, 6000)
331
+ } else {
332
+ massUpdateCartKlarna(['giftcard', 'cart'], '', '');
333
+ }
334
+ };
335
+ }
336
+
337
+ if (document.getElementById('giftcard_code')) {
338
+ document.getElementById('giftcard_code').onkeydown = function(e) {
339
+ if (e.which == 13) {
340
+ e.preventDefault();
341
+ massUpdateCartKlarna(["giftcard"], '', '');
342
+ }
343
+ };
344
+ }
345
+
346
+ // Giftcard remove on Klarna
347
+ if (document.querySelector('#applied-gift-cards .btn-remove')) {
348
+ document.querySelector('#applied-gift-cards .btn-remove').onclick = function(e) {
349
+ e.preventDefault();
350
+ massUpdateCartKlarna(['giftcard-remove', 'cart'], this.getAttribute('href'), '');
351
+ };
352
+ }
353
+
354
+ for (var q = 0; q < removeItemElement.length; q++) {
355
+ var removeItem = removeItemElement[q];
356
+ removeItem.addEventListener('click', function (e) {
357
+ e.preventDefault();
358
+
359
+ var itemid = this.getAttribute('data-itemid');
360
+ fadeOut(document.getElementById('cart_item_' + itemid));
361
+ document.getElementById('cart_item_qty_' + itemid).value = 0;
362
+ massUpdateCartKlarna(["cart"], '', '');
363
+ });
364
+ }
 
 
365
 
366
  for (var q=0; q<subtrackItemElement.length; q++) {
367
  subtrackItem = subtrackItemElement[q];
374
  if (qtyCurrent - 1 == 0) {
375
  fadeOut(document.getElementById('cart_item_' + itemid));
376
  }
377
+ massUpdateCartKlarna(["cart"], qtyInput, qtyCurrent);
378
  return false;
379
  };
380
  };
387
  qtyCurrent = parseInt(qtyInput.value);
388
 
389
  qtyInput.value = (qtyCurrent + 1);
390
+ massUpdateCartKlarna(["cart"], qtyInput, qtyCurrent);
391
  return false;
392
  };
393
  };
394
 
395
+ for (var q=0; q<qtyInputList.length; q++) {
396
+ inputField = qtyInputList[q];
397
+ /*
398
+ inputField.onblur = function() {
399
+ var itemid = this.getAttribute('data-itemid'),
400
+ qtyInput = document.getElementById('cart_item_qty_' + itemid),
401
+ qtyCurrent = parseInt(qtyInput.value),
402
+ qtyOrgInput = document.getElementById('cart_item_qty_org_' + itemid),
403
+ qtyOrgCurrent = parseInt(qtyOrgInput.value);
404
+
405
+ if (qtyCurrent != qtyOrgCurrent) {
406
+ massUpdateCartKlarna(["cart"], qtyInput, qtyOrgCurrent, hideLoader);
407
+ }
408
+ };
409
+ */
410
+ inputField.onkeydown = function(e) {
411
+ if (e.which == 13) {
412
+ e.preventDefault();
413
+ var itemid = this.getAttribute('data-itemid'),
414
+ qtyInput = document.getElementById('cart_item_qty_' + itemid),
415
+ qtyCurrent = parseInt(qtyInput.value),
416
+ qtyOrgInput = document.getElementById('cart_item_qty_org_' + itemid),
417
+ qtyOrgCurrent = parseInt(qtyOrgInput.value);
418
+
419
+ if (qtyCurrent != qtyOrgCurrent) {
420
+ massUpdateCartKlarna(["cart"], qtyInput, qtyOrgCurrent);
421
+ }
422
+ }
423
+ };
424
+ };
425
 
426
  };
427
 
428
  var KlarnaLogin = (function () {
429
+ "use strict";
430
+
431
+ var me = function (config) {
432
+ var cfg = config || {};
433
+
434
+ this.form = cfg.form || document.getElementById('klarna_form-login');
435
+ this.registerListeners();
436
+ };
437
+
438
+ me.prototype.registerListeners = function () {
439
+ if(this.form) {
440
+ this.form.addEventListener('submit', this.doLogin.bind(this));
441
+ }
442
+ };
443
+
444
+ me.prototype.doLogin = function (e) {
445
+ e.preventDefault();
446
+
447
+ var form = e.target,
448
+ data = form.serialize(false),
449
+ url = form.action;
450
+
451
+ vanillaAjax(url, data, this.successCallback.bind(this), this.errorCallback.bind(this));
452
+ };
453
+
454
+ me.prototype.showMessage = function (message) {
455
+ var messageEl = document.getElementById('klarna_msg'),
456
+ messageContentEl = messageEl.querySelector('.klarna_msg-content');
457
+
458
+ messageContentEl.textContent = message;
459
+ fadeIn(messageEl);
460
+ };
461
+
462
+ me.prototype.successCallback = function (response) {
463
+ var data = JSON.parse(response),
464
+ messageEl = document.getElementById('klarna_msg');
465
+
466
+ // Show message if we get a response code
467
+ if(!isNaN(data['r_code'])) {
468
+
469
+ if (data['r_code'] < 0 || messageEl.classList.contains('error')) { // Error
470
+ messageEl.classList.add('error');
471
+ this.showMessage(data.message);
472
+ } else {
473
+ messageEl.classList.remove('error'); // Success
474
+
475
+ this.showMessage(data.message);
476
+
477
+ /**
478
+ * Reload the page so that the Klarna iframe is updated with
479
+ * the user's email, address etc.
480
+ */
481
+ window.location.reload();
482
+ }
483
+ }
484
+ };
485
+
486
+ me.prototype.errorCallback = function (response) {
487
+ try {
488
+ var data = JSON.parse(response);
489
+ this.showMessage(data.message);
490
+ }
491
+ catch (e) {
492
+ var loginFailedText = Translator.translate("Could not log in. Please try again");
493
+ this.showMessage(loginFailedText);
494
+ }
495
+
496
+ console.log("Login failed! Here's the data:");
497
+ console.log(data);
498
+ };
499
+
500
+ return me;
501
  })();
502
 
503
  var KlarnaResponsive = (function () {
504
+ var me = function (config) {
505
+ var cfg = config || {};
506
+
507
+ this.element = cfg.element || document.getElementById('klarna_container');
508
+ this.isRunning = false;
509
+ this.storedSidebarEl = document.createDocumentFragment();
510
+ this.mobileBreakPoint = 992;
511
+
512
+ // Only run init functions if the site admin has set the Klarna module to use the responsive layout
513
+ if(this.getLayout() === 'two-column') {
514
+ this.registerListeners();
515
+ this.updateLayout();
516
+ }
517
+ };
518
+
519
+ me.prototype.registerListeners = function () {
520
+ window.addEventListener('resize', resize.bind(this));
521
+ };
522
+
523
+ function resize(e) {
524
+ if (!this.isRunning) {
525
+ this.isRunning = true;
526
+
527
+ if (window.requestAnimationFrame) {
528
+ window.requestAnimationFrame(this.updateLayout.bind(this));
529
+ } else {
530
+ setTimeout(this.updateLayout.bind(this), 66);
531
+ }
532
+ }
533
+ }
534
+
535
+ me.prototype.getLayout = function () {
536
+ var layoutVal = parseInt(this.element.getAttribute('data-layout'));
537
+
538
+ if(layoutVal === 0) {
539
+ return 'default';
540
+ }
541
+ else if (layoutVal === 1) {
542
+ return 'two-column';
543
+ }
544
+
545
+ return '';
546
+ };
547
+
548
+ me.prototype.getDesktopLayout = function (el) {
549
+ var sidebarEls = getSidebarElements(el),
550
+ docFragment = document.createDocumentFragment(),
551
+ fragmentSidebarEl,
552
+ sidebarEl = el || this.storedSidebarEl;
553
+
554
+ if (sidebarEl) {
555
+ docFragment.appendChild(sidebarEl);
556
+ }
557
+ fragmentSidebarEl = docFragment.querySelector('#klarna_sidebar');
558
+
559
+ // Add all sidebar items to the temporary sidebar fragment
560
+ if (sidebarEls.payment) {
561
+ fragmentSidebarEl.appendChild(sidebarEls.payment);
562
+ }
563
+ if (sidebarEls.shipping) {
564
+ fragmentSidebarEl.appendChild(sidebarEls.shipping);
565
+ }
566
+ if (sidebarEls.cart) {
567
+ fragmentSidebarEl.appendChild(sidebarEls.cart);
568
+ }
569
+ if (sidebarEls.discount) {
570
+ fragmentSidebarEl.appendChild(sidebarEls.discount);
571
+ }
572
+
573
+ return docFragment;
574
+ };
575
+
576
+ me.prototype.setMobileLayout = function (el) {
577
+ var groupedEls = getSidebarElements(el, true),
578
+ sidebarEls = getSidebarElements(el),
579
+ mainContentEl = document.getElementById('klarna_main'),
580
+ iframeEl = document.getElementById('klarna_checkout'),
581
+ tempEl = document.createDocumentFragment();
582
+
583
+ for(var key in groupedEls) {
584
+ if(groupedEls.hasOwnProperty(key)) {
585
+ tempEl.appendChild(groupedEls[key]);
586
+ }
587
+ }
588
+
589
+ mainContentEl.insertBefore(tempEl, iframeEl);
590
+ if (sidebarEls.payment) {
591
+ mainContentEl.appendChild(sidebarEls.payment);
592
+ }
593
+ };
594
+
595
+ /**
596
+ * Gets the sidebar children elements as an object
597
+ * @param sidebarEl (optional)
598
+ * @param getGroup
599
+ * @returns {{cart: HTMLElement, shipping: HTMLElement, discount: HTMLElement}}
600
+ */
601
+ function getSidebarElements (sidebarEl, getGroup) {
602
+ var ref = sidebarEl || document,
603
+ cartEl = document.getElementById('#klarna_cart-container') ? ref.querySelector('#klarna_cart-container') : null,
604
+ shippingEl = document.getElementById('#klarna_shipping') ? ref.querySelector('#klarna_shipping') : null,
605
+ discountEl = document.getElementById('#klarna_discount') ? ref.querySelector('#klarna_discount') : null,
606
+ groupedEls = {
607
+ cart: cartEl,
608
+ shipping: shippingEl,
609
+ discount: discountEl
610
+ },
611
+ sidebarEls = groupedEls;
612
+
613
+ sidebarEls.payment = document.getElementById('#klarna_methods') ? ref.querySelector('#klarna_methods') : null;
614
+
615
+ return getGroup ? groupedEls : sidebarEls;
616
+ }
617
+
618
+ /**
619
+ * Checks if the current viewport width corresponds to the predefined mobile breakpoint
620
+ * and if so changes the layout to mobile. Otherwise the layout is set to desktop.
621
+ */
622
+ me.prototype.updateLayout = function () {
623
+ var sidebarEl = document.getElementById('klarna_sidebar'),
624
+ klarnaContainer = document.getElementById('klarna_container'),
625
+ mainContentEl = document.getElementById('klarna_main'),
626
+ cartEl = document.getElementById('klarna_cart-container');
627
+
628
+ if(this.getMode() === 'mobile' && sidebarEl && !mainContentEl.contains(cartEl)) {
629
+ this.storedSidebarEl = sidebarEl.cloneNode(false);
630
+
631
+ this.setMobileLayout();
632
+
633
+ sidebarEl.parentNode.removeChild(sidebarEl);
634
+ }
635
+ else if(this.getMode() === 'desktop' && !sidebarEl && mainContentEl.contains(cartEl)) {
636
+ klarnaContainer.appendChild(this.getDesktopLayout());
637
+ }
638
+
639
+ this.isRunning = false;
640
+ };
641
+
642
+ me.prototype.getMode = function () {
643
+ var viewportWidth = window.innerWidth;
644
+
645
+ if(viewportWidth < this.mobileBreakPoint) {
646
+ return 'mobile';
647
+ }
648
+ else if(viewportWidth >= this.mobileBreakPoint) {
649
+ return 'desktop';
650
+ }
651
+ else {
652
+ return false;
653
+ }
654
+ };
655
+
656
+ /**
657
+ * Renders the given element as a sidebar or as a part of the main content depending
658
+ * on whether the browser window is in "mobile" or "desktop" mode. This is mostly intended to be used
659
+ * when the cart is updated through AJAX as the AJAX response will typically be an html view.
660
+ * @param el {HTMLElement}
661
+ */
662
+ me.prototype.drawLayoutForElement = function (el) {
663
+ if(!el) {
664
+ return false;
665
+ }
666
+
667
+ var klarnaContainer = document.getElementById('klarna_container'),
668
+ mainContentEl = document.getElementById('klarna_main');
669
+
670
+ if(this.getMode() === 'mobile') {
671
+ var sidebarEls = getSidebarElements(null, true);
672
+
673
+ // Remove all the current sidebar items inside the main content area
674
+ for(var key in sidebarEls) {
675
+ if(sidebarEls.hasOwnProperty(key)) {
676
+ mainContentEl.removeChild(sidebarEls[key]);
677
+ }
678
+ }
679
+
680
+ this.setMobileLayout(el);
681
+ }
682
+ else {
683
+ var newSidebar = this.getDesktopLayout(el);
684
+ klarnaContainer.replaceChild(newSidebar, klarnaContainer.querySelector('#klarna_sidebar'));
685
+ }
686
+ };
687
+
688
+ return me;
689
  })();
690
 
691
 
693
  // If there's no shipping option selected when the document loads, then select
694
  // the first option
695
  docReady(function() {
696
+ // Enable responsive mode if layout is 2-column-right
697
+ //var isDefaultLayout = document.getElementById('klarna_container').getAttribute('data-layout');
698
+ //if(!isDefaultLayout && isDefaultLayout !== '') {
699
+ klarnaResponsive = new KlarnaResponsive();
700
+ //}
701
+
702
+ // Add login functionality if the form exists
703
+ if (document.getElementById('klarna_form-login')) {
704
+ new KlarnaLogin();
705
+ }
706
+
707
+ var shippingChecked = document.getElementsByClassName('.shipping-method-input-radio:checked');
708
+ document.cookie = 'klarnaDiscountShipping=0; expires=0;';
709
+
710
+ if (!shippingChecked) {
711
+ document.querySelector("input[name=shipping_method]:first-child").checked = true;
712
+ document.cookie = 'klarnaAddShipping=1; expires=0;';
713
+ massUpdateCartKlarna(["shipping"], '', '');
714
+ }
715
+
716
+ bindCheckoutControls();
717
+
718
+ // This will trigger whenever you get out of editing the address in KCO
719
+ // We send an invisible Ajax call to Magento, updating quote, if different postcode
720
+ // If different postcode, it sends back true, which is where we need to update KCO
721
+ // Perhaps we can update shipping section in THAT ajax call, lets see...
722
+ // Using updateCartKlarna('shipping'); is NOT correct at least :)
723
+ _klarnaCheckout(function(api) {
724
+ api.on({
725
+ 'change': function(data) {
726
+ if (document.getElementById('klarna-checkout-shipping-update')) {
727
+ var url = document.getElementById('klarna-checkout-shipping-update').value;
728
+ vanillaAjax(url, 'email=' + data.email +
729
+ '&postcode=' + data.postal_code +
730
+ '&firstname=' + data.given_name +
731
+ '&lastname=' + data.family_name,
732
+ function(response){
733
+ var answer = JSON.parse(response);
734
+ if (answer) {
735
+ massUpdateCartKlarna(["shipping"], '', '');
736
+ }
737
+ }
738
+ );
739
+ }
740
+ }
741
+ });
742
+ });
743
 
744
  });
745
 
js/vaimo/klarna/klarnautils.js CHANGED
@@ -50,19 +50,24 @@
50
  function _klarnaCheckoutWrapper(callback) {
51
  if (typeof _klarnaCheckout != 'undefined') {
52
  _klarnaCheckout(function(api) {
53
- api.suspend();
54
- typeof callback === 'function' && callback(api);
 
55
  });
56
  }
57
  };
58
 
59
  // Helpers for Klarna: Suspend and resume
60
  function klarnaCheckoutSuspend() {
61
- _klarnaCheckoutWrapper();
 
 
 
 
62
  };
63
 
64
  function klarnaCheckoutResume() {
65
- _klarnaCheckoutWrapper(function(api) {
66
  api.resume();
67
  });
68
  };
@@ -104,7 +109,7 @@ function vanillaAjax(url, dataString, callbackOnSuccess, callbackOnError, callba
104
 
105
  // fade out
106
  function fadeOut(el){
107
- el.style.opacity = 1;
108
 
109
  (function fade() {
110
  if ((el.style.opacity -= .1) < 0) {
@@ -118,7 +123,7 @@ function fadeOut(el){
118
  // fade in
119
  function fadeIn(el, display){
120
  if (el) {
121
- el.style.opacity = 0;
122
  el.style.display = display || "block";
123
 
124
  (function fade() {
50
  function _klarnaCheckoutWrapper(callback) {
51
  if (typeof _klarnaCheckout != 'undefined') {
52
  _klarnaCheckout(function(api) {
53
+ if (typeof callback === 'function') {
54
+ callback(api);
55
+ }
56
  });
57
  }
58
  };
59
 
60
  // Helpers for Klarna: Suspend and resume
61
  function klarnaCheckoutSuspend() {
62
+ var klarnaLoader = document.getElementById("klarna_loader");
63
+ fadeIn(klarnaLoader);
64
+ _klarnaCheckout(function(api) {
65
+ api.suspend();
66
+ });
67
  };
68
 
69
  function klarnaCheckoutResume() {
70
+ _klarnaCheckout(function(api) {
71
  api.resume();
72
  });
73
  };
109
 
110
  // fade out
111
  function fadeOut(el){
112
+ el.style.opacity = 0;
113
 
114
  (function fade() {
115
  if ((el.style.opacity -= .1) < 0) {
123
  // fade in
124
  function fadeIn(el, display){
125
  if (el) {
126
+ el.style.opacity = 1;
127
  el.style.display = display || "block";
128
 
129
  (function fade() {
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>klarnapayments</name>
4
- <version>5.2.8</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-02-06</date>
14
- <time>15:57:56</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="6c35211c76987e619b51f6b6f06b0707"/><dir name="children"><file name="invoicefee.phtml" hash="2b721be479706716f6468c8395455fa5"/><file name="invoices.phtml" hash="ac4e3bd4aea83e9ea3479fc04ed0d5a4"/><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="cf7f571eecc4442b87f20636c51d3046"/></dir><dir name="template"><dir name="vaimo"><dir name="klarna"><dir name="catalog"><dir name="product"><file name="pricewidget.phtml" hash="f5838b8bb129634487a398ca2557f48b"/></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="78ec2685231b4664ec9106be2fb1b847"/><dir name="address"><file name="search.phtml" hash="473e03908fdb841f7152ed78671fcef0"/></dir><file name="checkout.phtml" hash="fe86056c73f86d53a73ebda5c5f3547c"/><dir name="children"><file name="addressresult.phtml" hash="bcbad92d0cdda60c480d5d453b35a85e"/><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="485d9f8e90ca6ff3c8152d2c3a0ee138"/><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="96495650061287f034fd789a372359a2"/><dir name="paymentplan"><file name="information.phtml" hash="d19f6766d1bebdacb367aee65edb06fd"/></dir><file name="special.phtml" hash="a81e468c29aff1c020cde8d9b3b1f223"/></dir><dir name="info"><file name="account.phtml" hash="a848c9544a5e400bc27e26d050eafa3c"/><file name="checkout.phtml" hash="1364aae5f0b71233e215e8a1c40ea7f7"/><dir name="children"><file name="invoicefee.phtml" hash="c6b4ccff75e220c5641a8fadd6753131"/><file name="invoices.phtml" hash="cbdd0256b8e1d742257bcba9b1eef67a"/><file name="paymentplan.phtml" hash="3a73d918dc733c0888f18e442f9eb64c"/><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="62a935a8d1d4b9e96d0891d214c3f591"/><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="b054a35d7a5a920c5f002b1af34a88dc"/><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="72a8383c77bbdcbf0b7ecbbc98098cf7"/><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="3bff2c1800c9b7ca865ccb976cb4f868"/><file name="reward.phtml" hash="0e1d0a7d42738662fddd04dab09f5765"/><dir name="shipping_method"><file name="available.phtml" hash="a441651173fda6ec78742e4fcb859b97"/></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="f62810eeea7f3b7a5b48c31de848bdb1"/></dir><dir name="de_AT"><file name="Vaimo_Klarna.csv" hash="3cb46912c2d748d1dccba73bdda8a706"/></dir><dir name="de_DE"><file name="Vaimo_Klarna.csv" hash="3c285ec05879160c2ff207bac728ea17"/></dir><dir name="fi_FI"><file name="Vaimo_Klarna.csv" hash="86eb9aa45e77a7116dfb23e3357824aa"/></dir><dir name="nb_NO"><file name="Vaimo_Klarna.csv" hash="7f09078abd3e5045c6f026796bdd3c72"/></dir><dir name="nl_NL"><file name="Vaimo_Klarna.csv" hash="9be2500a48904256c315c01c57e20931"/></dir><dir name="nn_NO"><file name="Vaimo_Klarna.csv" hash="c24b3bb865cfbed3ff10b2874c73f274"/></dir><dir name="sv_SE"><file name="Vaimo_Klarna.csv" hash="1c531fba46e1785d98078b87c61f1681"/></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="1bab89ebb2900ae298f96911a38a162f"/><file name="klarnautils.js" hash="950b0f12148b596aa0e7fd4db3a85d94"/></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="a732fe831cd76bc4a9b883b0bccfd8f4"/><file name="klarnadefault.css" hash="a7322fe612f4be03d3c5e78dee7a9c9c"/><file name="product.css" hash="d41d8cd98f00b204e9800998ecf8427e"/><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="a1001513f617098414fbdf228c187989"/></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="b42636bfd8019f522342ca2b9118d246"/><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="586393b00cd2c57ed6d53b8b50a8a535"/><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="9bfabd568384b14c70175218f62fab9a"/><dir name="Customer"><file name="Balance.php" hash="e35153845d979d91ff79d0558e7b6c0b"/></dir><file name="Discount.php" hash="d56512c70315f0ad2ee1f8b857f30c78"/><file name="Ga.php" hash="e69dc6575162c137669bc6fba3d854cd"/><file name="Klarnacheckout.php" hash="03ebec0f6c1197caaa59eb43a65e1872"/><file name="Newsletter.php" hash="ce97e11c097b0cd9696919936fa59dc6"/><file name="Othermethod.php" hash="a31bc678ce541f8eea1d043801c13974"/><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="b2d6ab863caa8498d8f067a949cd67be"/></dir></dir><file name="Position.php" hash="8e48499e9f0604019e0d0d0584f12986"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AddressController.php" hash="e3272d6463e7ea0082c249924c31e34b"/><dir name="Adminhtml"><dir name="Klarna"><file name="MassactionController.php" hash="e182c149c750934ae4463efb96f5091c"/><file name="PclassController.php" hash="3a83e55251281b4414d7099b4481e245"/></dir></dir><dir name="Checkout"><file name="KlarnaController.php" hash="70f8fc27b553dfed7ea6097b2b117028"/></dir><file name="LoginController.php" hash="3c7e56482f9af9ed0696fb0507cc5444"/><file name="PaymentplanController.php" hash="fea9d33a5dbd5d4858ef174569dae636"/></dir><dir name="etc"><file name="config.xml" hash="e3de7f7ad090700e1d6d392c5f47cdb9"/><file name="system.xml" hash="0baa2ff40fd31a75e0fbf3a8a2aaf954"/></dir><dir name="Helper"><file name="Data.php" hash="9eef17f8d146493907a725e91dcd1950"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Admin"><file name="Json.php" hash="6e9bffda94a9d8898aeeb25677c761de"/></dir></dir></dir></dir></dir><dir name="Api"><file name="Abstract.php" hash="4bc3ea8874cd8755a248e8ac69b2e100"/><file name="Kco.php" hash="67ef094626e0623e1559dbae9d5ee603"/><file name="Rest.php" hash="3e71d235b7bba97c9d98638b0c26a245"/><file name="Xmlrpc.php" hash="68083465148581be0709904d2752c610"/></dir><file name="Api.php" hash="5c3f199a2fb6a8d733bd9c8d8996791e"/><dir name="Creditmemo"><file name="Tax.php" hash="c3d5162de38f5ef2075bca483085e5d0"/><file name="Total.php" hash="8da0e6596826ba5fc03695e7834734f0"/></dir><file name="Cron.php" hash="ce9f0c59c6772af96f0132335dc3a194"/><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="fd0a1e6ced04dcb213ed1af11e1d3a6a"/></dir><file name="Klarna.php" hash="de2b8c617f33a9ac4b7dbc8143970c8b"/><dir name="Klarnacheckout"><file name="Abstract.php" hash="ae4c167242096aec289ddcc339469853"/></dir><file name="Klarnacheckout.php" hash="1f1fd568bd89c4022a7cb2189ff849e0"/><file name="Observer.php" hash="4ac430de53c9246fbfe37a33e13a7f05"/><dir name="Payment"><file name="Abstract.php" hash="d2f91324f0ed03a121441e4d06982da9"/><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><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><dir name="Source"><file name="Abstract.php" hash="8d0d746d1cd2e5bc7d11350908a01585"/><file name="Allspecificcountries.php" hash="1a98316e25baeaba307b3be62364e1ca"/><file name="Apiversion.php" hash="536c62f5022aec99d71f68e1118c0d99"/><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="530e4780b702f641f993ba0e49382d5d"/><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="278cc337e85a75db9d466c96f56c36af"/></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"/></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.2.11</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>2015-04-01</date>
14
+ <time>13:33:51</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="6c35211c76987e619b51f6b6f06b0707"/><dir name="children"><file name="invoicefee.phtml" hash="2b721be479706716f6468c8395455fa5"/><file name="invoices.phtml" hash="ac4e3bd4aea83e9ea3479fc04ed0d5a4"/><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="744b3c349a84d348f0571852888dee8e"/></dir><dir name="template"><dir name="vaimo"><dir name="klarna"><dir name="catalog"><dir name="product"><file name="pricewidget.phtml" hash="f5838b8bb129634487a398ca2557f48b"/></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="78ec2685231b4664ec9106be2fb1b847"/><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="485d9f8e90ca6ff3c8152d2c3a0ee138"/><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="96495650061287f034fd789a372359a2"/><dir name="paymentplan"><file name="information.phtml" hash="d013f147f38502cb4baf591d56d177d9"/></dir><file name="special.phtml" hash="a81e468c29aff1c020cde8d9b3b1f223"/></dir><dir name="info"><file name="account.phtml" hash="a848c9544a5e400bc27e26d050eafa3c"/><file name="checkout.phtml" hash="1364aae5f0b71233e215e8a1c40ea7f7"/><dir name="children"><file name="invoicefee.phtml" hash="c6b4ccff75e220c5641a8fadd6753131"/><file name="invoices.phtml" hash="cbdd0256b8e1d742257bcba9b1eef67a"/><file name="paymentplan.phtml" hash="3a73d918dc733c0888f18e442f9eb64c"/><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="08279a9c8ecb32c4b7de2fe643aacb61"/><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="f81a950407bd23fe476e03854fe4928b"/><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="72a8383c77bbdcbf0b7ecbbc98098cf7"/><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="ae8ab1ec8ec3de1546cb5bafcf34fcc4"/><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="64cfdbb02d0246455199fdc9e8102229"/></dir><dir name="de_AT"><file name="Vaimo_Klarna.csv" hash="55154195257090edded254824700bf77"/></dir><dir name="de_DE"><file name="Vaimo_Klarna.csv" hash="b92f42663b4ba46b0d4a2b1c25ff4bac"/></dir><dir name="fi_FI"><file name="Vaimo_Klarna.csv" hash="1b2878f61f0c4b2f6ce3c0f2bf29ca57"/></dir><dir name="nb_NO"><file name="Vaimo_Klarna.csv" hash="151680993f4a94d14f661c485b0cb3f1"/></dir><dir name="nl_NL"><file name="Vaimo_Klarna.csv" hash="382ee1100c720d8d0019618fd37ce1c5"/></dir><dir name="nn_NO"><file name="Vaimo_Klarna.csv" hash="7b78711096873772f9c7d2389319cc1d"/></dir><dir name="sv_SE"><file name="Vaimo_Klarna.csv" hash="02f679cc801f247f0a7b01ff94c62974"/></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="0bde5577610971d460ad256fe9c5f66e"/><file name="klarnautils.js" hash="a3ff8f14c437af5f1135578ae90c8e8a"/></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="74cced1472da33802967cb66dafa7a47"/><file name="klarnadefault.css" hash="a7322fe612f4be03d3c5e78dee7a9c9c"/><file name="product.css" hash="d41d8cd98f00b204e9800998ecf8427e"/><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="b42636bfd8019f522342ca2b9118d246"/><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="586393b00cd2c57ed6d53b8b50a8a535"/><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="d56512c70315f0ad2ee1f8b857f30c78"/><file name="Ga.php" hash="e69dc6575162c137669bc6fba3d854cd"/><file name="Klarnacheckout.php" hash="03ebec0f6c1197caaa59eb43a65e1872"/><file name="Newsletter.php" hash="ce97e11c097b0cd9696919936fa59dc6"/><file name="Othermethod.php" hash="09155e9bd989e68ba6bcaa81ae359dd8"/><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="e3272d6463e7ea0082c249924c31e34b"/><dir name="Adminhtml"><dir name="Klarna"><file name="MassactionController.php" hash="e182c149c750934ae4463efb96f5091c"/><file name="PclassController.php" hash="3a83e55251281b4414d7099b4481e245"/></dir></dir><dir name="Checkout"><file name="KlarnaController.php" hash="74f61556ba1f5d1f57f53438becd7163"/></dir><file name="LoginController.php" hash="3c7e56482f9af9ed0696fb0507cc5444"/><file name="PaymentplanController.php" hash="fea9d33a5dbd5d4858ef174569dae636"/></dir><dir name="etc"><file name="config.xml" hash="acf41cb9f9c6b6879e82d6691747d5db"/><file name="system.xml" hash="4eb8cb1423fd87a85471e7e9d21b68d1"/></dir><dir name="Helper"><file name="Data.php" hash="f675ce57ca74fc732eb931c8cf8b802d"/></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="7d9de06a1b4ee92c3c7f4afa4eca6bff"/><file name="Rest.php" hash="996c016aaf495292698662cb9a4fe19f"/><file name="Xmlrpc.php" hash="37696a1c20760e3aef620a392ca0bfe8"/></dir><file name="Api.php" hash="aea682b90c3c046515808ab8d444eecc"/><dir name="Creditmemo"><file name="Tax.php" hash="c3d5162de38f5ef2075bca483085e5d0"/><file name="Total.php" hash="8da0e6596826ba5fc03695e7834734f0"/></dir><file name="Cron.php" hash="ce9f0c59c6772af96f0132335dc3a194"/><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="bbe5b02445fba6bd26222a638bfd0f75"/></dir><file name="Klarna.php" hash="9638b2c470b2908072b50709556198ee"/><dir name="Klarnacheckout"><file name="Abstract.php" hash="adff3707bf6b3c9bed26282ed67e3afc"/></dir><file name="Klarnacheckout.php" hash="e301e30f62582c6c4a6e6cfc2f6aa015"/><file name="Observer.php" hash="91642cabebb5846e5bfcb1b251de89c9"/><dir name="Payment"><file name="Abstract.php" hash="2e1cc5592202e53fcbe9354da156e450"/><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><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><dir name="Source"><file name="Abstract.php" hash="8d0d746d1cd2e5bc7d11350908a01585"/><file name="Allspecificcountries.php" hash="1a98316e25baeaba307b3be62364e1ca"/><file name="Apiversion.php" hash="64c78e105f7934dca2f59da41ef137d4"/><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="530e4780b702f641f993ba0e49382d5d"/><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="6473d1e8fe180f55c0b3a461a16c3383"/></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"/></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>
skin/frontend/base/default/css/vaimo/klarna/klarnacheckout.css CHANGED
@@ -186,6 +186,11 @@
186
  display: none;
187
  }
188
 
 
 
 
 
 
189
  @media all and (max-width: 500px) {
190
  .klarna_login .klarna_input-text {
191
  width: 100%;
186
  display: none;
187
  }
188
 
189
+ .klarna_login .klarna_login_message {
190
+ font-size: 10px;
191
+ padding-left: 2px;
192
+ }
193
+
194
  @media all and (max-width: 500px) {
195
  .klarna_login .klarna_input-text {
196
  width: 100%;