klarnapayments - Version 5.3.24

Version Notes

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

Download this release

Release Info

Developer Klarna
Extension klarnapayments
Version 5.3.24
Comparing to
See all releases


Code changes from version 5.3.1 to 5.3.24

Files changed (52) hide show
  1. app/code/community/Vaimo/Klarna/Block/Info/Abstract.php +6 -0
  2. app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Discount.php +8 -11
  3. app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Klarnacheckout.php +4 -1
  4. app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Othermethod.php +3 -1
  5. app/code/community/Vaimo/Klarna/Helper/Data.php +168 -29
  6. app/code/community/Vaimo/Klarna/Model/Api.php +4 -3
  7. app/code/community/Vaimo/Klarna/Model/Api/Kco.php +98 -32
  8. app/code/community/Vaimo/Klarna/Model/Api/Rest.php +111 -74
  9. app/code/community/Vaimo/Klarna/Model/Api/Xmlrpc.php +5 -5
  10. app/code/community/Vaimo/Klarna/Model/Cron.php +117 -44
  11. app/code/community/Vaimo/Klarna/Model/Klarna.php +15 -4
  12. app/code/community/Vaimo/Klarna/Model/Klarna/Abstract.php +42 -18
  13. app/code/community/Vaimo/Klarna/Model/Klarnacheckout.php +450 -184
  14. app/code/community/Vaimo/Klarna/Model/Klarnacheckout/Abstract.php +28 -0
  15. app/code/community/Vaimo/Klarna/Model/Observer.php +15 -6
  16. app/code/community/Vaimo/Klarna/Model/Payment/Abstract.php +13 -4
  17. app/code/community/Vaimo/Klarna/Model/Pushqueue.php +54 -0
  18. app/code/community/Vaimo/Klarna/Model/Resource/Pushqueue.php +52 -0
  19. app/code/community/Vaimo/Klarna/Model/Resource/Pushqueue/Collection.php +45 -0
  20. app/code/community/Vaimo/Klarna/Model/Source/Apiversion.php +2 -2
  21. app/code/community/Vaimo/Klarna/Model/Transport/Abstract.php +1 -1
  22. app/code/community/Vaimo/Klarna/controllers/AddressController.php +2 -2
  23. app/code/community/Vaimo/Klarna/controllers/Adminhtml/Klarna/MassactionController.php +6 -0
  24. app/code/community/Vaimo/Klarna/controllers/Adminhtml/Klarna/PclassController.php +5 -0
  25. app/code/community/Vaimo/Klarna/controllers/Checkout/KlarnaController.php +168 -111
  26. app/code/community/Vaimo/Klarna/etc/config.xml +24 -4
  27. app/code/community/Vaimo/Klarna/etc/system.xml +111 -29
  28. app/code/community/Vaimo/Klarna/sql/klarna_setup/mysql4-upgrade-5.3.4-5.3.5.php +51 -0
  29. app/design/adminhtml/default/default/template/vaimo/klarna/info/checkout.phtml +2 -0
  30. app/design/adminhtml/default/default/template/vaimo/klarna/info/children/notices.phtml +40 -0
  31. app/design/frontend/base/default/layout/vaimo_klarna.xml +2 -1
  32. app/design/frontend/base/default/template/vaimo/klarna/form/account.phtml +4 -0
  33. app/design/frontend/base/default/template/vaimo/klarna/form/children/notifications.phtml +2 -0
  34. app/design/frontend/base/default/template/vaimo/klarna/form/invoice.phtml +4 -0
  35. app/design/frontend/base/default/template/vaimo/klarna/form/special.phtml +4 -0
  36. app/design/frontend/base/default/template/vaimo/klarna/info/checkout.phtml +10 -0
  37. app/design/frontend/base/default/template/vaimo/klarna/info/children/invoices.phtml +5 -3
  38. app/design/frontend/base/default/template/vaimo/klarna/info/children/notices.phtml +40 -0
  39. app/design/frontend/base/default/template/vaimo/klarna/info/children/reference.phtml +35 -0
  40. app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/cart.phtml +2 -2
  41. app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/header.phtml +5 -1
  42. app/locale/da_DK/Vaimo_Klarna.csv +1 -0
  43. app/locale/de_AT/Vaimo_Klarna.csv +1 -0
  44. app/locale/de_DE/Vaimo_Klarna.csv +1 -0
  45. app/locale/fi_FI/Vaimo_Klarna.csv +2 -0
  46. app/locale/nb_NO/Vaimo_Klarna.csv +1 -0
  47. app/locale/nl_NL/Vaimo_Klarna.csv +1 -0
  48. app/locale/nn_NO/Vaimo_Klarna.csv +1 -0
  49. app/locale/sv_SE/Vaimo_Klarna.csv +1 -0
  50. js/vaimo/klarna/klarnacheckout.js +12 -8
  51. js/vaimo/klarna/klarnautils.js +1 -0
  52. package.xml +4 -4
app/code/community/Vaimo/Klarna/Block/Info/Abstract.php CHANGED
@@ -156,6 +156,12 @@ class Vaimo_Klarna_Block_Info_Abstract extends Mage_Payment_Block_Info
156
  return $this->toHtml();
157
  }
158
 
 
 
 
 
 
 
159
  public function getPaymentPlanHtml()
160
  {
161
  $this->setTemplate('vaimo/klarna/info/children/paymentplan.phtml');
156
  return $this->toHtml();
157
  }
158
 
159
+ public function getNoticesHtml()
160
+ {
161
+ $this->setTemplate('vaimo/klarna/info/children/notices.phtml');
162
+ return $this->toHtml();
163
+ }
164
+
165
  public function getPaymentPlanHtml()
166
  {
167
  $this->setTemplate('vaimo/klarna/info/children/paymentplan.phtml');
app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Discount.php CHANGED
@@ -28,18 +28,15 @@ class Vaimo_Klarna_Block_Klarnacheckout_Discount extends Mage_Core_Block_Templat
28
  public function _beforeToHtml()
29
  {
30
  parent::_beforeToHtml();
31
- try {
32
- if (class_exists('Enterprise_GiftCard_Model_Giftcard', true)) {
33
- /** @var Mage_Core_Block_Template $giftCardAccountBlock */
34
- $giftCardAccountBlock = $this->getLayout()->createBlock(
35
- 'enterprise_giftcardaccount/checkout_cart_giftcardaccount', 'checkout.cart.giftcardaccount'
36
- );
37
- if ($giftCardAccountBlock) {
38
- $giftCardAccountBlock->setTemplate('vaimo/klarna/klarnacheckout/discount/giftcardaccount.phtml');
39
- $this->setChild('giftcards', $giftCardAccountBlock);
40
- }
41
  }
42
- } catch (Exception $e) {
43
  }
44
  return $this;
45
  }
28
  public function _beforeToHtml()
29
  {
30
  parent::_beforeToHtml();
31
+ if (Mage::helper('klarna')->isEnterpriseAndHasClass('Enterprise_GiftCard_Model_Giftcard')) {
32
+ /** @var Mage_Core_Block_Template $giftCardAccountBlock */
33
+ $giftCardAccountBlock = $this->getLayout()->createBlock(
34
+ 'enterprise_giftcardaccount/checkout_cart_giftcardaccount', 'checkout.cart.giftcardaccount'
35
+ );
36
+ if ($giftCardAccountBlock) {
37
+ $giftCardAccountBlock->setTemplate('vaimo/klarna/klarnacheckout/discount/giftcardaccount.phtml');
38
+ $this->setChild('giftcards', $giftCardAccountBlock);
 
 
39
  }
 
40
  }
41
  return $this;
42
  }
app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Klarnacheckout.php CHANGED
@@ -40,7 +40,10 @@ class Vaimo_Klarna_Block_Klarnacheckout_Klarnacheckout extends Mage_Core_Block_T
40
  try {
41
  $klarna = Mage::getModel('klarna/klarnacheckout');
42
  $klarna->setQuote($this->getQuote(), Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
43
- $html = $klarna->getKlarnaOrderHtml(null, true, true);
 
 
 
44
  } catch (Exception $e) {
45
  Mage::helper('klarna')->logKlarnaException($e);
46
  $html = $e->getMessage();
40
  try {
41
  $klarna = Mage::getModel('klarna/klarnacheckout');
42
  $klarna->setQuote($this->getQuote(), Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
43
+ // Want to send down kco id here, but then it will not call updateOrder
44
+ // in initKlarnaOrder, which is just ugly code... Need to fix that!
45
+ // $klarna->getQuote()->getKlarnaCheckoutId()
46
+ $html = $klarna->getKlarnaOrderHtml(NULL, true, true);
47
  } catch (Exception $e) {
48
  Mage::helper('klarna')->logKlarnaException($e);
49
  $html = $e->getMessage();
app/code/community/Vaimo/Klarna/Block/Klarnacheckout/Othermethod.php CHANGED
@@ -93,6 +93,8 @@ class Vaimo_Klarna_Block_Klarnacheckout_Othermethod extends Mage_Core_Block_Temp
93
  */
94
  public function triggerChangedJSInputId()
95
  {
 
 
96
  try {
97
  $klarna = Mage::getModel('klarna/klarnacheckout');
98
  $klarna->setQuote($this->getQuote(), Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
@@ -110,4 +112,4 @@ class Vaimo_Klarna_Block_Klarnacheckout_Othermethod extends Mage_Core_Block_Temp
110
  return $res;
111
  }
112
 
113
- }
93
  */
94
  public function triggerChangedJSInputId()
95
  {
96
+ $res = false;
97
+
98
  try {
99
  $klarna = Mage::getModel('klarna/klarnacheckout');
100
  $klarna->setQuote($this->getQuote(), Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
112
  return $res;
113
  }
114
 
115
+ }
app/code/community/Vaimo/Klarna/Helper/Data.php CHANGED
@@ -41,11 +41,14 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
41
 
42
  const KLARNA_API_CALL_KCODISPLAY_ORDER = 'kco_display_order';
43
  const KLARNA_API_CALL_KCOCREATE_ORDER = 'kco_create_order';
44
-
 
 
 
45
  const KLARNA_STATUS_ACCEPTED = 'accepted';
46
  const KLARNA_STATUS_PENDING = 'pending';
47
  const KLARNA_STATUS_DENIED = 'denied';
48
-
49
  const KLARNA_INFO_FIELD_FEE = 'vaimo_klarna_fee';
50
  const KLARNA_INFO_FIELD_FEE_TAX = 'vaimo_klarna_fee_tax';
51
  const KLARNA_INFO_FIELD_BASE_FEE = 'vaimo_klarna_base_fee';
@@ -64,6 +67,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
64
  const KLARNA_INFO_FIELD_INVOICE_LIST_KCO_ID = 'invoice_kco_id';
65
  const KLARNA_INFO_FIELD_HOST = 'klarna_reservation_host';
66
  const KLARNA_INFO_FIELD_MERCHANT_ID = 'merchant_id';
 
67
 
68
  const KLARNA_INFO_FIELD_PAYMENT_PLAN = 'payment_plan';
69
  const KLARNA_INFO_FIELD_PAYMENT_PLAN_TYPE = 'payment_plan_type';
@@ -83,7 +87,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
83
  const KLARNA_FORM_FIELD_CONSENT = 'consent';
84
  const KLARNA_FORM_FIELD_GENDER = 'gender';
85
  const KLARNA_FORM_FIELD_EMAIL = 'email';
86
-
87
  const KLARNA_API_RESPONSE_STATUS = 'response_status';
88
  const KLARNA_API_RESPONSE_TRANSACTION_ID = 'response_transaction_id';
89
  const KLARNA_API_RESPONSE_FEE_REFUNDED = 'response_fee_refunded';
@@ -108,12 +112,12 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
108
  const KLARNA_LOGOTYPE_POSITION_FRONTEND = 'frontend';
109
  const KLARNA_LOGOTYPE_POSITION_PRODUCT = 'product';
110
  const KLARNA_LOGOTYPE_POSITION_CHECKOUT = 'checkout';
111
-
112
  const KLARNA_DISPATCH_RESERVED = 'vaimo_paymentmethod_order_reserved';
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
 
@@ -125,6 +129,8 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
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,
@@ -170,12 +176,12 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
170
  self::KLARNA_FORM_FIELD_CONSENT,
171
  self::KLARNA_FORM_FIELD_GENDER,
172
  self::KLARNA_FORM_FIELD_EMAIL,
173
-
174
  );
175
 
176
  const KLARNA_CHECKOUT_ENABLE_NEWSLETTER = 'payment/vaimo_klarna_checkout/enable_newsletter';
177
  const KLARNA_CHECKOUT_EXTRA_ORDER_ATTRIBUTE = 'payment/vaimo_klarna_checkout/extra_order_attribute';
178
- const KLARNA_CHECKOUT_ENABLE_CART_ABOVE_KCO = 'payment/vaimo_klarna_checkout/enable_cart_above_kco';
179
 
180
  const KLARNA_CHECKOUT_NEWSLETTER_DISABLED = 0;
181
  const KLARNA_CHECKOUT_NEWSLETTER_SUBSCRIBE = 1;
@@ -251,7 +257,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
251
  }
252
  return false;
253
  }
254
-
255
  public function getInvoiceLink($order, $transactionId)
256
  {
257
  $link = "";
@@ -269,6 +275,10 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
269
  public function shouldItemBeIncluded($item)
270
  {
271
  if ($item->getParentItemId()>0 && $item->getPriceInclTax()==0) return false;
 
 
 
 
272
  return true;
273
  }
274
 
@@ -299,6 +309,34 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
299
  return $res;
300
  }
301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  /**
303
  * Check if Vaimo_QuickCheckout is activated or not
304
  *
@@ -308,8 +346,11 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
308
  {
309
  $res = false;
310
  try {
311
- if (class_exists('Icommerce_QuickCheckout_Helper_Data', true)) {
312
- $res = true;
 
 
 
313
  }
314
  } catch (Exception $e) {
315
  }
@@ -501,7 +542,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
501
  * Either I have done something wrong or the versions have changed how they work...
502
  *
503
  */
504
-
505
  /*
506
  * Add tax to grand total on invoice collect or not
507
  */
@@ -514,7 +555,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
514
  return true;
515
  }
516
  }
517
-
518
  /*
519
  * Call parent of quote collect or not
520
  */
@@ -528,7 +569,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
528
  return false;
529
  }
530
  }
531
-
532
  /*
533
  * Use extra tax in quote instead of adding to Tax, I don't know why this has to be
534
  * different in EE, but it clearly seems to be...
@@ -626,7 +667,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
626
  }
627
 
628
  /*
629
- *
630
  *
631
  */
632
  public function dispatchReserveInfo($order, $pno)
@@ -638,7 +679,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
638
  'pno' => $pno
639
  ));
640
  }
641
-
642
  /*
643
  * Whenever a refund, capture, reserve or cancel is performed, we send out an event
644
  * This can be listened to for financial reconciliation
@@ -653,7 +694,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
653
  'method' => $method,
654
  'amount' => $amount
655
  ));
656
-
657
  // Vaimo specific dispatch
658
  $event_name = NULL;
659
  switch ($eventcode) {
@@ -725,7 +766,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
725
  }
726
  return $res;
727
  }
728
-
729
  public function getTermsUrlLink($url)
730
  {
731
  if ($url) {
@@ -765,7 +806,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
765
  {
766
  $_SESSION[self::LOG_FUNCTION_SESSION_NAME] = $functionName;
767
  }
768
-
769
  /**
770
  * Returns the function name set by the constructors in each class
771
  *
@@ -775,7 +816,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
775
  {
776
  return array_key_exists(self::LOG_FUNCTION_SESSION_NAME, $_SESSION) ? $_SESSION[self::LOG_FUNCTION_SESSION_NAME] : '';
777
  }
778
-
779
  /**
780
  * Log function that does the writing to log file
781
  *
@@ -788,7 +829,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
788
  {
789
  Mage::log('PID(' . getmypid() . '): ' . $this->getFunctionNameForLog() . ': ' . $msg, null, $filename, true);
790
  }
791
-
792
  /**
793
  * Log function that does the writing to log file
794
  *
@@ -819,7 +860,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
819
  return;
820
  }
821
  }
822
-
823
  /**
824
  * Log function that logs all Klarna API calls and replies, this to see what functions are called and what reply they get
825
  *
@@ -832,7 +873,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
832
  $this->_log('klarnaapi.log', $comment);
833
  $this->logDebugInfo($comment);
834
  }
835
-
836
  /**
837
  * Log function used for various debug log information, array is optional
838
  *
@@ -843,22 +884,23 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
843
  */
844
  public function logDebugInfo($info, $arr = NULL)
845
  {
846
- if (!$arr) {
847
- $this->_log('klarnadebug.log', $info);
848
- } else {
849
  if (is_array($arr)) {
850
  $this->_log('klarnadebug.log', print_r($arr, true));
851
  } elseif (is_object($arr)) {
852
  $this->_log('klarnadebug.log', print_r(array($arr), true));
 
 
853
  }
854
  }
855
  }
856
-
857
  protected function _logMagentoException($e)
858
  {
859
  Mage::logException($e);
860
  }
861
-
862
  /**
863
  * If there is an exception, this log function should be used
864
  * This is mainly meant for exceptions concerning klarna API calls, but can be used for any exception
@@ -877,7 +919,7 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
877
  if ($e->getFile()) $errstr = $errstr . ' File: ' . $e->getFile();
878
  $this->_logAlways('klarnaerror.log', $errstr);
879
  }
880
-
881
  public function getDefaultCountry($store = NULL)
882
  {
883
  /* For shipping this should be called...
@@ -895,4 +937,101 @@ class Vaimo_Klarna_Helper_Data extends Mage_Core_Helper_Abstract
895
  return $res;
896
  }
897
 
898
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  const KLARNA_API_CALL_KCODISPLAY_ORDER = 'kco_display_order';
43
  const KLARNA_API_CALL_KCOCREATE_ORDER = 'kco_create_order';
44
+ const KLARNA_API_CALL_KCOVALIDATE_ORDER = 'kco_validate_order';
45
+
46
+ const KLARNA_KCO_QUEUE_RETRY_ATTEMPTS = 10;
47
+
48
  const KLARNA_STATUS_ACCEPTED = 'accepted';
49
  const KLARNA_STATUS_PENDING = 'pending';
50
  const KLARNA_STATUS_DENIED = 'denied';
51
+
52
  const KLARNA_INFO_FIELD_FEE = 'vaimo_klarna_fee';
53
  const KLARNA_INFO_FIELD_FEE_TAX = 'vaimo_klarna_fee_tax';
54
  const KLARNA_INFO_FIELD_BASE_FEE = 'vaimo_klarna_base_fee';
67
  const KLARNA_INFO_FIELD_INVOICE_LIST_KCO_ID = 'invoice_kco_id';
68
  const KLARNA_INFO_FIELD_HOST = 'klarna_reservation_host';
69
  const KLARNA_INFO_FIELD_MERCHANT_ID = 'merchant_id';
70
+ const KLARNA_INFO_FIELD_NOTICE = 'klarna_notice';
71
 
72
  const KLARNA_INFO_FIELD_PAYMENT_PLAN = 'payment_plan';
73
  const KLARNA_INFO_FIELD_PAYMENT_PLAN_TYPE = 'payment_plan_type';
87
  const KLARNA_FORM_FIELD_CONSENT = 'consent';
88
  const KLARNA_FORM_FIELD_GENDER = 'gender';
89
  const KLARNA_FORM_FIELD_EMAIL = 'email';
90
+
91
  const KLARNA_API_RESPONSE_STATUS = 'response_status';
92
  const KLARNA_API_RESPONSE_TRANSACTION_ID = 'response_transaction_id';
93
  const KLARNA_API_RESPONSE_FEE_REFUNDED = 'response_fee_refunded';
112
  const KLARNA_LOGOTYPE_POSITION_FRONTEND = 'frontend';
113
  const KLARNA_LOGOTYPE_POSITION_PRODUCT = 'product';
114
  const KLARNA_LOGOTYPE_POSITION_CHECKOUT = 'checkout';
115
+
116
  const KLARNA_DISPATCH_RESERVED = 'vaimo_paymentmethod_order_reserved';
117
  const KLARNA_DISPATCH_CAPTURED = 'vaimo_paymentmethod_order_captured';
118
  const KLARNA_DISPATCH_REFUNDED = 'vaimo_paymentmethod_order_refunded';
119
  const KLARNA_DISPATCH_CANCELED = 'vaimo_paymentmethod_order_canceled';
120
+
121
  const KLARNA_LOG_START_TAG = '---------------START---------------';
122
  const KLARNA_LOG_END_TAG = '----------------END----------------';
123
 
129
  const KLARNA_KCO_API_VERSION_UK = 3;
130
  const KLARNA_KCO_API_VERSION_USA = 4;
131
 
132
+ public static $isEnterprise;
133
+
134
 
135
  protected $_supportedMethods = array(
136
  Vaimo_Klarna_Helper_Data::KLARNA_METHOD_INVOICE,
176
  self::KLARNA_FORM_FIELD_CONSENT,
177
  self::KLARNA_FORM_FIELD_GENDER,
178
  self::KLARNA_FORM_FIELD_EMAIL,
179
+
180
  );
181
 
182
  const KLARNA_CHECKOUT_ENABLE_NEWSLETTER = 'payment/vaimo_klarna_checkout/enable_newsletter';
183
  const KLARNA_CHECKOUT_EXTRA_ORDER_ATTRIBUTE = 'payment/vaimo_klarna_checkout/extra_order_attribute';
184
+ const KLARNA_CHECKOUT_ENABLE_CART_ABOVE_KCO = 'payment/vaimo_klarna_checkout/enable_cart_above_kco';
185
 
186
  const KLARNA_CHECKOUT_NEWSLETTER_DISABLED = 0;
187
  const KLARNA_CHECKOUT_NEWSLETTER_SUBSCRIBE = 1;
257
  }
258
  return false;
259
  }
260
+
261
  public function getInvoiceLink($order, $transactionId)
262
  {
263
  $link = "";
275
  public function shouldItemBeIncluded($item)
276
  {
277
  if ($item->getParentItemId()>0 && $item->getPriceInclTax()==0) return false;
278
+ if ($item->getOrderItemId()) {
279
+ $orderItem = Mage::getModel('sales/order_item')->load($item->getOrderItemId());
280
+ if ($orderItem->getParentItemId()>0 && $item->getPriceInclTax()==0) return false;
281
+ }
282
  return true;
283
  }
284
 
309
  return $res;
310
  }
311
 
312
+ /**
313
+ * Check if FireCheckout is activated or not
314
+ *
315
+ * @return bool
316
+ */
317
+ public function isFireCheckout($store = null)
318
+ {
319
+ $res = false;
320
+ if (Mage::getStoreConfig('firecheckout/general/enabled', $store)) {
321
+ $res = true;
322
+ }
323
+ return $res;
324
+ }
325
+
326
+ /**
327
+ * Check if VaimoCheckout is activated or not
328
+ *
329
+ * @return bool
330
+ */
331
+ public function isVaimoCheckout($store = null)
332
+ {
333
+ $res = false;
334
+ if (Mage::getStoreConfig('checkout/options/vaimo_checkout_enabled', $store)) {
335
+ $res = true;
336
+ }
337
+ return $res;
338
+ }
339
+
340
  /**
341
  * Check if Vaimo_QuickCheckout is activated or not
342
  *
346
  {
347
  $res = false;
348
  try {
349
+ $node = Mage::getConfig()->getNode("modules/Icommerce_QuickCheckout");
350
+ if ($node) {
351
+ if ($node->active=='true'){
352
+ $res = true;
353
+ }
354
  }
355
  } catch (Exception $e) {
356
  }
542
  * Either I have done something wrong or the versions have changed how they work...
543
  *
544
  */
545
+
546
  /*
547
  * Add tax to grand total on invoice collect or not
548
  */
555
  return true;
556
  }
557
  }
558
+
559
  /*
560
  * Call parent of quote collect or not
561
  */
569
  return false;
570
  }
571
  }
572
+
573
  /*
574
  * Use extra tax in quote instead of adding to Tax, I don't know why this has to be
575
  * different in EE, but it clearly seems to be...
667
  }
668
 
669
  /*
670
+ *
671
  *
672
  */
673
  public function dispatchReserveInfo($order, $pno)
679
  'pno' => $pno
680
  ));
681
  }
682
+
683
  /*
684
  * Whenever a refund, capture, reserve or cancel is performed, we send out an event
685
  * This can be listened to for financial reconciliation
694
  'method' => $method,
695
  'amount' => $amount
696
  ));
697
+
698
  // Vaimo specific dispatch
699
  $event_name = NULL;
700
  switch ($eventcode) {
766
  }
767
  return $res;
768
  }
769
+
770
  public function getTermsUrlLink($url)
771
  {
772
  if ($url) {
806
  {
807
  $_SESSION[self::LOG_FUNCTION_SESSION_NAME] = $functionName;
808
  }
809
+
810
  /**
811
  * Returns the function name set by the constructors in each class
812
  *
816
  {
817
  return array_key_exists(self::LOG_FUNCTION_SESSION_NAME, $_SESSION) ? $_SESSION[self::LOG_FUNCTION_SESSION_NAME] : '';
818
  }
819
+
820
  /**
821
  * Log function that does the writing to log file
822
  *
829
  {
830
  Mage::log('PID(' . getmypid() . '): ' . $this->getFunctionNameForLog() . ': ' . $msg, null, $filename, true);
831
  }
832
+
833
  /**
834
  * Log function that does the writing to log file
835
  *
860
  return;
861
  }
862
  }
863
+
864
  /**
865
  * Log function that logs all Klarna API calls and replies, this to see what functions are called and what reply they get
866
  *
873
  $this->_log('klarnaapi.log', $comment);
874
  $this->logDebugInfo($comment);
875
  }
876
+
877
  /**
878
  * Log function used for various debug log information, array is optional
879
  *
884
  */
885
  public function logDebugInfo($info, $arr = NULL)
886
  {
887
+ $this->_log('klarnadebug.log', $info);
888
+ if ($arr) {
 
889
  if (is_array($arr)) {
890
  $this->_log('klarnadebug.log', print_r($arr, true));
891
  } elseif (is_object($arr)) {
892
  $this->_log('klarnadebug.log', print_r(array($arr), true));
893
+ } elseif (is_string($arr)) {
894
+ $this->_log('klarnadebug.log', $arr);
895
  }
896
  }
897
  }
898
+
899
  protected function _logMagentoException($e)
900
  {
901
  Mage::logException($e);
902
  }
903
+
904
  /**
905
  * If there is an exception, this log function should be used
906
  * This is mainly meant for exceptions concerning klarna API calls, but can be used for any exception
919
  if ($e->getFile()) $errstr = $errstr . ' File: ' . $e->getFile();
920
  $this->_logAlways('klarnaerror.log', $errstr);
921
  }
922
+
923
  public function getDefaultCountry($store = NULL)
924
  {
925
  /* For shipping this should be called...
937
  return $res;
938
  }
939
 
940
+ public function isEnterpriseAndHasClass($class = null)
941
+ {
942
+ $res = false;
943
+ try {
944
+ $isEE = self::isEnterprise();
945
+
946
+ if ($class && $isEE) {
947
+ if (class_exists($class, true)) {
948
+ $res = true;
949
+ }
950
+ }
951
+ } catch (Exception $e) {
952
+ }
953
+ return $res;
954
+ }
955
+
956
+ /**
957
+ * Escape quotes inside html attributes
958
+ * Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc)
959
+ *
960
+ * @param string $data
961
+ * @param bool $addSlashes
962
+ * @return string
963
+ */
964
+ public function quoteEscape($data, $addSlashes = false)
965
+ {
966
+ if ($addSlashes === true) {
967
+ $data = addslashes($data);
968
+ }
969
+ return htmlspecialchars($data, ENT_QUOTES, null, false);
970
+ }
971
+
972
+ public function findQuote($klarna_id)
973
+ {
974
+ /** @var Mage_Core_Model_Resource $resource */
975
+ $resource = Mage::getSingleton('core/resource');
976
+ /** @var Varien_Db_Adapter_Interface $read */
977
+ $read = $resource->getConnection('core_read');
978
+ /** @var Varien_Db_Select $select */
979
+ $select = $read->select()->from($resource->getTableName('sales/quote'), Array('entity_id', 'store_id'))
980
+ ->where('klarna_checkout_id=?', $klarna_id);
981
+ $r = $read->fetchAll($select);
982
+ if (count($r) < 1) {
983
+ Mage::helper('klarna')->logKlarnaApi('findQuote no checkout quote found!' . $klarna_id);
984
+ return null;
985
+ }
986
+ else if (count($r) > 1) {
987
+ Mage::helper('klarna')->logKlarnaApi('findQuote more than one quote found!' . $klarna_id);
988
+ }
989
+ $r = $r[0];
990
+ $quote = Mage::getModel('sales/quote')
991
+ ->setStoreId($r['store_id'])
992
+ ->load($r['entity_id']);
993
+
994
+ return $quote;
995
+ }
996
+
997
+ /**
998
+ * Check if a product is a dynamic bundle product and reset a price.
999
+ *
1000
+ * @param $item // Might not be Mage_Sales_Model_Quote_Item...
1001
+ * @param Mage_Catalog_Model_Product|null $product
1002
+ * @return bool
1003
+ */
1004
+ public function checkBundles(&$item, $product = null)
1005
+ {
1006
+ $res = false;
1007
+ if (!$product) {
1008
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
1009
+ }
1010
+ $productType = $item->getProductType();
1011
+ if ($productType===NULL) {
1012
+ if ($item->getOrderItemId()) {
1013
+ $orderItem = Mage::getModel('sales/order_item')->load($item->getOrderItemId());
1014
+ $productType = $orderItem->getProductType();
1015
+ }
1016
+ }
1017
+ if ($productType == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE
1018
+ && $product->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) {
1019
+ $res = true;
1020
+ }
1021
+ return $res;
1022
+ }
1023
+
1024
+ public static function isEnterprise()
1025
+ {
1026
+ if (!isset(self::$isEnterprise)) {
1027
+ if (method_exists('Mage', 'getEdition')) {
1028
+ self::$isEnterprise = Mage::getEdition() == Mage::EDITION_ENTERPRISE;
1029
+ } else {
1030
+ self::$isEnterprise = (boolean) Mage::getConfig()->getModuleConfig('Enterprise_Enterprise');
1031
+ }
1032
+ }
1033
+
1034
+ return self::$isEnterprise;
1035
+ }
1036
+
1037
+ }
app/code/community/Vaimo/Klarna/Model/Api.php CHANGED
@@ -51,9 +51,9 @@ class Vaimo_Klarna_Model_Api extends Varien_Object
51
  /**
52
  * @return Vaimo_Klarna_Model_Api_Kco
53
  */
54
- protected function _getKlarnaCheckOutOriginalApi()
55
  {
56
- return Mage::getSingleton('klarna/api_kco');
57
  }
58
 
59
  /**
@@ -91,7 +91,8 @@ class Vaimo_Klarna_Model_Api extends Varien_Object
91
  case Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_RESERVE:
92
  case Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER:
93
  case Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER:
94
- return $this->_getKlarnaCheckOutOriginalApi();
 
95
  break;
96
  default:
97
  return $this->_getKlarnaPaymentMethodXmlRpcApi();
51
  /**
52
  * @return Vaimo_Klarna_Model_Api_Kco
53
  */
54
+ protected function _getKlarnaCheckOutOriginalApi($apiVersion)
55
  {
56
+ return Mage::getSingleton('klarna/api_kco')->setApiVersion($apiVersion);
57
  }
58
 
59
  /**
91
  case Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_RESERVE:
92
  case Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCODISPLAY_ORDER:
93
  case Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER:
94
+ case Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOVALIDATE_ORDER:
95
+ return $this->_getKlarnaCheckOutOriginalApi(Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_STD);
96
  break;
97
  default:
98
  return $this->_getKlarnaPaymentMethodXmlRpcApi();
app/code/community/Vaimo/Klarna/Model/Api/Kco.php CHANGED
@@ -36,6 +36,17 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
36
  protected $_klarnaOrder = NULL;
37
  protected $_useKlarnaOrderSessionCache = false;
38
 
 
 
 
 
 
 
 
 
 
 
 
39
  protected function _getLocationOrderId()
40
  {
41
  $res = $this->_klarnaOrder->getLocation();
@@ -45,7 +56,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
45
  }
46
  return $res;
47
  }
48
-
49
  /**
50
  * Get current active quote instance
51
  *
@@ -95,17 +106,33 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
95
  $quote = $this->_getQuote();
96
  $items = array();
97
 
98
- foreach ($quote->getAllVisibleItems() as $quoteItem) {
 
 
 
 
 
 
99
  if ($quoteItem->getTaxPercent() > 0) {
100
  $taxRate = $quoteItem->getTaxPercent();
101
  } else {
102
  $taxRate = $quoteItem->getTaxAmount() / $quoteItem->getRowTotal() * 100;
103
  }
 
 
 
 
 
 
 
 
 
 
104
  $items[] = array(
105
  'reference' => $quoteItem->getSku(),
106
  'name' => $quoteItem->getName(),
107
  'quantity' => round($quoteItem->getQty()),
108
- 'unit_price' => round($quoteItem->getPriceInclTax() * 100),
109
  // 'discount_rate' => round($quoteItem->getDiscountPercent() * 100),
110
  'tax_rate' => round($taxRate * 100),
111
  );
@@ -226,7 +253,10 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
226
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
227
  $create['locale'] = str_replace('_', '-', Mage::app()->getLocale()->getLocaleCode());
228
  $create['merchant']['id'] = $this->_klarnaSetup->getMerchantId();
229
- $create['merchant']['terms_uri'] = Mage::helper('klarna')->getTermsUrl($this->_klarnaSetup->getTermsUrl());
 
 
 
230
  $create['merchant']['checkout_uri'] = Mage::getUrl('checkout/klarna');
231
  $create['merchant']['confirmation_uri'] = Mage::getUrl('checkout/klarna/success');
232
  $create['gui']['layout'] = $this->_isMobile() ? 'mobile' : 'desktop';
@@ -267,11 +297,11 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
267
  if ($data = $this->_getBillingAddressData()) {
268
  $create['shipping_address'] = $data;
269
  }
270
-
271
  if ($data = $this->_getCustomerData()) {
272
  $create['customer'] = $data;
273
  }
274
-
275
  Mage::helper('klarna')->logDebugInfo('_getCreateRequest', $create);
276
  $request = new Varien_Object($create);
277
  Mage::dispatchEvent('klarnacheckout_get_create_request', array('request' => $request));
@@ -297,7 +327,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
297
  if ($data = $this->_getCustomerData()) {
298
  $update['customer'] = $data;
299
  }
300
-
301
  Mage::helper('klarna')->logDebugInfo('_getUpdateRequest', $update);
302
  $request = new Varien_Object($update);
303
  Mage::dispatchEvent('klarnacheckout_get_update_request', array('request' => $request));
@@ -308,7 +338,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
308
  protected function _getBillingAddressData()
309
  {
310
  if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
311
-
312
  /** @var $session Mage_Customer_Model_Session */
313
  $session = Mage::getSingleton('customer/session');
314
  if ($session->isLoggedIn()) {
@@ -323,12 +353,12 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
323
  }
324
  }
325
  if ($this->_getTransport()->moreDetailsToKCORequest()) {
326
- if ($address &&
327
  ( preg_match('/^([^\d]*[^\d\s]) *(\d.*)$/', $address->getStreet(1), $tmp) )) {
328
  $streetName = $tmp[1];
329
  $streetNumber = $tmp[2];
330
  }
331
-
332
  if ($gender = $session->getCustomer()->getGender()) {
333
  switch ($gender) {
334
  case 1:
@@ -370,12 +400,12 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
370
  }
371
 
372
  return NULL;
373
- }
374
 
375
  protected function _getCustomerData()
376
  {
377
  if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
378
-
379
  /** @var $session Mage_Customer_Model_Session */
380
  $session = Mage::getSingleton('customer/session');
381
  if ($session->isLoggedIn()) {
@@ -390,7 +420,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
390
  }
391
 
392
  return NULL;
393
- }
394
 
395
  public function init($klarnaSetup)
396
  {
@@ -415,7 +445,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
415
  if (method_exists('Mage', 'getEdition')) {
416
  $magentoEdition = Mage::getEdition();
417
  } else {
418
- if (class_exists("Enterprise_UrlRewrite_Model_Redirect", false)) {
419
  $magentoEdition = "Enterprise";
420
  } else {
421
  $magentoEdition = "Community";
@@ -433,12 +463,12 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
433
  );
434
  return Klarna_Checkout_Connector::create($secret, $module_info);
435
  }
436
-
437
  public function setKlarnaOrderSessionCache($value)
438
  {
439
  $this->_useKlarnaOrderSessionCache = $value;
440
  }
441
-
442
  /*
443
  * Will return the klarna order or null, if it doesn't find it
444
  * Not used by this module, but as a service for others.
@@ -454,7 +484,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
454
  }
455
  return NULL;
456
  }
457
-
458
  /**
459
  * Get Klarna checkout order
460
  *
@@ -463,10 +493,10 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
463
  * @param bool $updateItems
464
  * @return Klarna_Checkout_Order|null
465
  */
466
- public function initKlarnaOrder($checkoutId = null, $createIfNotExists = false, $updateItems = false)
467
  {
468
  if ($checkoutId) {
469
- Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder checkout id: ' . $checkoutId);
470
  $loadf = true;
471
  if ($this->_useKlarnaOrderSessionCache) {
472
  if ($this->_klarnaOrder) {
@@ -482,6 +512,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
482
  if ($this->_getLocationOrderId()) {
483
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
484
  }
 
485
  }
486
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
487
  return $res;
@@ -489,7 +520,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
489
 
490
  if ($klarnaCheckoutId = $this->_getKlarnaCheckoutId()) {
491
  try {
492
- Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder klarnaCheckoutId id: ' . $klarnaCheckoutId);
493
  $this->_klarnaOrder = new Klarna_Checkout_Order($this->_getConnector(), Klarna_Checkout_Order::$baseUri . '/' . $klarnaCheckoutId);
494
  if ($updateItems) {
495
  $this->_klarnaOrder->update($this->_getUpdateRequest());
@@ -500,6 +531,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
500
  if ($this->_getLocationOrderId()) {
501
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
502
  }
 
503
  }
504
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
505
  return $res;
@@ -516,9 +548,12 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
516
  $this->_klarnaOrder->fetch();
517
  $res = $this->_klarnaOrder!=NULL;
518
  if ($res) {
519
- if ($this->_getLocationOrderId()) {
520
- $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
 
 
521
  }
 
522
  }
523
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
524
  return $res;
@@ -526,7 +561,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
526
 
527
  return false;
528
  }
529
-
530
  public function prepareTaxAndShippingReply()
531
  {
532
  return '';
@@ -543,7 +578,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
543
  }
544
  return NULL;
545
  }
546
-
547
  public function getKlarnaCheckoutGui()
548
  {
549
  if ($this->_klarnaOrder) {
@@ -554,7 +589,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
554
  }
555
  return '';
556
  }
557
-
558
  public function getKlarnaCheckoutStatus()
559
  {
560
  if ($this->_klarnaOrder) {
@@ -564,19 +599,19 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
564
  }
565
  return '';
566
  }
567
-
568
  public function loadQuote()
569
  {
570
  if ($this->_klarnaOrder) {
571
  /** @var $quote Mage_Sales_Model_Quote */
572
- $quote = Mage::getModel('sales/quote')->load($this->_getLocationOrderId(), 'klarna_checkout_id');
573
- if ($quote->getId()) {
574
  return $quote;
575
  }
576
  }
577
  return NULL;
578
  }
579
-
580
  public function fetchCreatedOrder($checkoutId)
581
  {
582
  $this->initKlarnaOrder($checkoutId);
@@ -588,7 +623,7 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
588
  }
589
  return NULL;
590
  }
591
-
592
  public function updateKlarnaOrder($order, $repeatCall = false)
593
  {
594
  if ($this->_klarnaOrder) {
@@ -609,12 +644,43 @@ class Vaimo_Klarna_Model_Api_Kco extends Vaimo_Klarna_Model_Api_Abstract
609
  $orderid2Value = $order->getData($orderid2Code);
610
  $update['merchant_reference']['orderid2'] = $orderid2Value;
611
  }
612
-
613
  $this->_klarnaOrder->update($update);
614
  Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder success');
615
  return true;
616
  }
617
  return false;
618
  }
619
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
620
  }
36
  protected $_klarnaOrder = NULL;
37
  protected $_useKlarnaOrderSessionCache = false;
38
 
39
+ public function setApiVersion($apiVersion)
40
+ {
41
+ $this->_apiVersion = $apiVersion;
42
+ return $this;
43
+ }
44
+
45
+ public function getApiVersion()
46
+ {
47
+ return ($this->_apiVersion);
48
+ }
49
+
50
  protected function _getLocationOrderId()
51
  {
52
  $res = $this->_klarnaOrder->getLocation();
56
  }
57
  return $res;
58
  }
59
+
60
  /**
61
  * Get current active quote instance
62
  *
106
  $quote = $this->_getQuote();
107
  $items = array();
108
 
109
+ foreach ($quote->getAllItems() as $quoteItem) {
110
+ if (Mage::helper('klarna')->shouldItemBeIncluded($quoteItem)==false) {
111
+ continue;
112
+ }
113
+
114
+ $shouldSumsBeZero = Mage::helper('klarna')->checkBundles($quoteItem);
115
+
116
  if ($quoteItem->getTaxPercent() > 0) {
117
  $taxRate = $quoteItem->getTaxPercent();
118
  } else {
119
  $taxRate = $quoteItem->getTaxAmount() / $quoteItem->getRowTotal() * 100;
120
  }
121
+
122
+ $price = $quoteItem->getPriceInclTax();
123
+ $totalInclTax = $quoteItem->getRowTotalInclTax();
124
+ $taxAmount = $quoteItem->getTaxAmount();
125
+ if ($shouldSumsBeZero) {
126
+ $price = 0;
127
+ $totalInclTax = 0;
128
+ $taxAmount = 0;
129
+ }
130
+
131
  $items[] = array(
132
  'reference' => $quoteItem->getSku(),
133
  'name' => $quoteItem->getName(),
134
  'quantity' => round($quoteItem->getQty()),
135
+ 'unit_price' => round($price * 100),
136
  // 'discount_rate' => round($quoteItem->getDiscountPercent() * 100),
137
  'tax_rate' => round($taxRate * 100),
138
  );
253
  $create['purchase_currency'] = $this->_getQuote()->getQuoteCurrencyCode();
254
  $create['locale'] = str_replace('_', '-', Mage::app()->getLocale()->getLocaleCode());
255
  $create['merchant']['id'] = $this->_klarnaSetup->getMerchantId();
256
+ $terms = Mage::helper('klarna')->getTermsUrl($this->_klarnaSetup->getTermsUrl());
257
+ if ($terms) {
258
+ $create['merchant']['terms_uri'] = $terms;
259
+ }
260
  $create['merchant']['checkout_uri'] = Mage::getUrl('checkout/klarna');
261
  $create['merchant']['confirmation_uri'] = Mage::getUrl('checkout/klarna/success');
262
  $create['gui']['layout'] = $this->_isMobile() ? 'mobile' : 'desktop';
297
  if ($data = $this->_getBillingAddressData()) {
298
  $create['shipping_address'] = $data;
299
  }
300
+
301
  if ($data = $this->_getCustomerData()) {
302
  $create['customer'] = $data;
303
  }
304
+
305
  Mage::helper('klarna')->logDebugInfo('_getCreateRequest', $create);
306
  $request = new Varien_Object($create);
307
  Mage::dispatchEvent('klarnacheckout_get_create_request', array('request' => $request));
327
  if ($data = $this->_getCustomerData()) {
328
  $update['customer'] = $data;
329
  }
330
+
331
  Mage::helper('klarna')->logDebugInfo('_getUpdateRequest', $update);
332
  $request = new Varien_Object($update);
333
  Mage::dispatchEvent('klarnacheckout_get_update_request', array('request' => $request));
338
  protected function _getBillingAddressData()
339
  {
340
  if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
341
+
342
  /** @var $session Mage_Customer_Model_Session */
343
  $session = Mage::getSingleton('customer/session');
344
  if ($session->isLoggedIn()) {
353
  }
354
  }
355
  if ($this->_getTransport()->moreDetailsToKCORequest()) {
356
+ if ($address &&
357
  ( preg_match('/^([^\d]*[^\d\s]) *(\d.*)$/', $address->getStreet(1), $tmp) )) {
358
  $streetName = $tmp[1];
359
  $streetNumber = $tmp[2];
360
  }
361
+
362
  if ($gender = $session->getCustomer()->getGender()) {
363
  switch ($gender) {
364
  case 1:
400
  }
401
 
402
  return NULL;
403
+ }
404
 
405
  protected function _getCustomerData()
406
  {
407
  if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
408
+
409
  /** @var $session Mage_Customer_Model_Session */
410
  $session = Mage::getSingleton('customer/session');
411
  if ($session->isLoggedIn()) {
420
  }
421
 
422
  return NULL;
423
+ }
424
 
425
  public function init($klarnaSetup)
426
  {
445
  if (method_exists('Mage', 'getEdition')) {
446
  $magentoEdition = Mage::getEdition();
447
  } else {
448
+ if (Mage::helper('klarna')->isEnterpriseAndHasClass()) {
449
  $magentoEdition = "Enterprise";
450
  } else {
451
  $magentoEdition = "Community";
463
  );
464
  return Klarna_Checkout_Connector::create($secret, $module_info);
465
  }
466
+
467
  public function setKlarnaOrderSessionCache($value)
468
  {
469
  $this->_useKlarnaOrderSessionCache = $value;
470
  }
471
+
472
  /*
473
  * Will return the klarna order or null, if it doesn't find it
474
  * Not used by this module, but as a service for others.
484
  }
485
  return NULL;
486
  }
487
+
488
  /**
489
  * Get Klarna checkout order
490
  *
493
  * @param bool $updateItems
494
  * @return Klarna_Checkout_Order|null
495
  */
496
+ public function initKlarnaOrder($checkoutId = null, $createIfNotExists = false, $updateItems = false, $quoteId = '')
497
  {
498
  if ($checkoutId) {
499
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder checkout id: ' . $checkoutId . ' (quote id: ' . $quoteId . ')');
500
  $loadf = true;
501
  if ($this->_useKlarnaOrderSessionCache) {
502
  if ($this->_klarnaOrder) {
512
  if ($this->_getLocationOrderId()) {
513
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
514
  }
515
+ Mage::dispatchEvent('klarnacheckout_init_klarna_order', array('klarna_order' => $this->_klarnaOrder, 'api_version' => $this->getApiVersion()));
516
  }
517
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
518
  return $res;
520
 
521
  if ($klarnaCheckoutId = $this->_getKlarnaCheckoutId()) {
522
  try {
523
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder klarnaCheckoutId id: ' . $klarnaCheckoutId . ' (quote id: ' . $quoteId . ')');
524
  $this->_klarnaOrder = new Klarna_Checkout_Order($this->_getConnector(), Klarna_Checkout_Order::$baseUri . '/' . $klarnaCheckoutId);
525
  if ($updateItems) {
526
  $this->_klarnaOrder->update($this->_getUpdateRequest());
531
  if ($this->_getLocationOrderId()) {
532
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
533
  }
534
+ Mage::dispatchEvent('klarnacheckout_init_klarna_order', array('klarna_order' => $this->_klarnaOrder, 'api_version' => $this->getApiVersion()));
535
  }
536
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
537
  return $res;
548
  $this->_klarnaOrder->fetch();
549
  $res = $this->_klarnaOrder!=NULL;
550
  if ($res) {
551
+ $klarnaCheckoutId = $this->_getLocationOrderId();
552
+ if ($klarnaCheckoutId) {
553
+ $this->_setKlarnaCheckoutId($klarnaCheckoutId);
554
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder created, klarnaCheckoutId id: ' . $klarnaCheckoutId . ' (quote id: ' . $quoteId . ')');
555
  }
556
+ Mage::dispatchEvent('klarnacheckout_init_klarna_order', array('klarna_order' => $this->_klarnaOrder, 'api_version' => $this->getApiVersion()));
557
  }
558
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
559
  return $res;
561
 
562
  return false;
563
  }
564
+
565
  public function prepareTaxAndShippingReply()
566
  {
567
  return '';
578
  }
579
  return NULL;
580
  }
581
+
582
  public function getKlarnaCheckoutGui()
583
  {
584
  if ($this->_klarnaOrder) {
589
  }
590
  return '';
591
  }
592
+
593
  public function getKlarnaCheckoutStatus()
594
  {
595
  if ($this->_klarnaOrder) {
599
  }
600
  return '';
601
  }
602
+
603
  public function loadQuote()
604
  {
605
  if ($this->_klarnaOrder) {
606
  /** @var $quote Mage_Sales_Model_Quote */
607
+ $quote = Mage::helper('klarna')->findQuote($this->_getLocationOrderId());
608
+ if ($quote && $quote->getId()) {
609
  return $quote;
610
  }
611
  }
612
  return NULL;
613
  }
614
+
615
  public function fetchCreatedOrder($checkoutId)
616
  {
617
  $this->initKlarnaOrder($checkoutId);
623
  }
624
  return NULL;
625
  }
626
+
627
  public function updateKlarnaOrder($order, $repeatCall = false)
628
  {
629
  if ($this->_klarnaOrder) {
644
  $orderid2Value = $order->getData($orderid2Code);
645
  $update['merchant_reference']['orderid2'] = $orderid2Value;
646
  }
647
+
648
  $this->_klarnaOrder->update($update);
649
  Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder success');
650
  return true;
651
  }
652
  return false;
653
  }
654
+
655
+ public function sanityTestQuote($createdKlarnaOrder, $quote)
656
+ {
657
+ $res = NULL;
658
+
659
+ foreach ($quote->getAllVisibleItems() as $quoteItem) {
660
+ $foundf = false;
661
+ $data = $createdKlarnaOrder->getData();
662
+ if (isset($data['cart'])) {
663
+ if (isset($data['cart']['items'])) {
664
+ foreach ($data['cart']['items'] as $klarnaItem) {
665
+ if ($klarnaItem['reference']==$quoteItem->getSku() &&
666
+ $klarnaItem['quantity']==$quoteItem->getQty()
667
+ ) {
668
+ $foundf = true;
669
+ continue;
670
+ }
671
+ }
672
+ if ($foundf) {
673
+ continue;
674
+ }
675
+ }
676
+ }
677
+ if (!$foundf) {
678
+ if (!$res) $res = array();
679
+ $res[] = Mage::helper('klarna')->__('Product not the same as on reservation:') . $quoteItem->getSku() . ' ' . $quoteItem->getName();
680
+ }
681
+ }
682
+
683
+ return $res;
684
+ }
685
+
686
  }
app/code/community/Vaimo/Klarna/Model/Api/Rest.php CHANGED
@@ -46,6 +46,11 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
46
  return $this;
47
  }
48
 
 
 
 
 
 
49
  protected function _isUSA()
50
  {
51
  return $this->_apiVersion == Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_USA;
@@ -68,7 +73,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
68
  }
69
  }
70
  }
71
-
72
  protected function _getUrl()
73
  {
74
  return $this->_url;
@@ -98,7 +103,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
98
  }
99
  return $res;
100
  }
101
-
102
  protected function _getAddressData($useTransport = false, $type = Mage_Sales_Model_Quote_Address::TYPE_BILLING)
103
  {
104
  if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
@@ -160,7 +165,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
160
  protected function _getCustomerData()
161
  {
162
  if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
163
-
164
  /** @var $session Mage_Customer_Model_Session */
165
  $session = Mage::getSingleton('customer/session');
166
  if ($session->isLoggedIn()) {
@@ -175,7 +180,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
175
  }
176
 
177
  return NULL;
178
- }
179
 
180
  /**
181
  * Get active Klarna checkout id
@@ -214,7 +219,6 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
214
  $quote = $this->_getQuote();
215
  }
216
  $items = array();
217
- $taxes = array();
218
  $calculator = Mage::getSingleton('tax/calculation');
219
 
220
  foreach ($quote->getAllVisibleItems() as $quoteItem) {
@@ -224,11 +228,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
224
  $taxRate = $quoteItem->getTaxAmount() / $quoteItem->getRowTotal() * 100;
225
  }
226
  $taxAmount = $calculator->calcTaxAmount($quoteItem->getRowTotalInclTax(), $taxRate, true);
227
- if (isset($taxes[$taxRate])) {
228
- $taxes[$taxRate] += $taxAmount;
229
- } else {
230
- $taxes[$taxRate] = $taxAmount;
231
- }
232
  if ($this->_isUSA()) {
233
  // $unitPrice = $quoteItem->getPrice();
234
  $totalAmount = $quoteItem->getRowTotalInclTax() - $taxAmount;
@@ -267,7 +267,6 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
267
  $amount = $amount - $taxAmount - $hiddenTaxAmount;
268
  }
269
  $taxRate = ($taxAmount + $hiddenTaxAmount) / $amount * 100;
270
- $taxes[$taxRate] += $taxAmount;
271
  if ($this->_isUSA()) {
272
  $unitPrice = $amount;
273
  $totalAmount = $amount;
@@ -299,7 +298,6 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
299
  $taxAmount = $total->getAddress()->getHiddenTaxAmount();
300
  $amount = -$total->getAddress()->getDiscountAmount() - $taxAmount;
301
  $taxRate = $taxAmount / $amount * 100;
302
- $taxes[$taxRate] -= $taxAmount;
303
  if ($this->_isUSA()) {
304
  $unitPrice = $amount;
305
  $totalAmount = $amount;
@@ -390,12 +388,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
390
  $totalAmount += $item['total_amount'];
391
  }
392
  $totalTax = (($quote->getGrandTotal() * 100) - $totalAmount) / 100;
393
- /*
394
- $totalTax = 0;
395
- foreach ($taxes as $taxRate => $tax) {
396
- $totalTax += $tax;
397
- }
398
- */
399
  $items[] = array(
400
  'type' => 'sales_tax',
401
  'reference' => Mage::helper('klarna')->__('Sales Tax'),
@@ -442,7 +435,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
442
  if ($data = $this->_getCustomerData()) {
443
  $create['customer'] = $data;
444
  }
445
-
446
  $create['order_amount'] = round($this->_getQuote()->getGrandTotal() * 100);
447
  $create['order_tax_amount'] = 0;
448
  $create['order_lines'] = $this->_getCartItems();
@@ -455,51 +448,50 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
455
  } else {
456
  $create['order_tax_amount'] += $line['total_tax_amount'];
457
  }
458
-
459
  }
460
- if ($this->_isUSA()) {
461
 
 
462
  $shippingCountries = $this->_getTransport()->getConfigData('shipping_countries');
463
  if ($shippingCountries) {
464
  $create['shipping_countries'] = explode(',', $shippingCountries);
465
  }
 
466
 
467
- if ($this->_getTransport()->getConfigData('shipping_options')) {
468
- $shippingOptions = array();
469
- $address = $this->_getQuote()->getShippingAddress();
470
- $originalShippingMethod = $address->getShippingMethod();
471
- $methods = Mage::getModel('checkout/cart_shipping_api')->getShippingMethodsList($this->_getQuote()->getId());
472
- foreach ($methods as $method) {
473
- $address->setShippingMethod($method['code']);
474
- $this->_getQuote()->setTotalsCollectedFlag(false)->collectTotals();
475
- if ($address->getShippingAmount()>0) {
476
- $taxRate = ($address->getShippingAmount + $address->getShippingTaxAmount()) / $address->getShippingAmount() * 100;
477
- } else {
478
- $taxRate = 0;
479
- }
480
- if ($method['code']==$originalShippingMethod) {
481
- $preSelected = true;
482
- } else {
483
- $preSelected = false;
484
- }
485
- $shippingOptions[] = array(
486
- 'id' => $method['code'],
487
- 'name' => $method['method_title'],
488
- 'description' => $method['carrier_title'],
489
- 'price' => (int)($address->getShippingAmount() + $address->getShippingTaxAmount()) * 100,
490
- 'tax_amount' => (int)$address->getShippingTaxAmount() * 100,
491
- 'tax_rate' => (int)($taxRate * 100) * 100,
492
- 'preselected' => $preSelected,
493
- );
494
- }
495
- $address->setShippingMethod($originalShippingMethod);
496
  $this->_getQuote()->setTotalsCollectedFlag(false)->collectTotals();
497
- $create['shipping_options'] = $shippingOptions;
498
- $create['selected_shipping_option'] = array(
499
- 'id' => $address->getShippingMethod(),
500
- 'name' => $address->getShippingDescription(),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
  );
502
  }
 
 
 
 
 
 
 
503
  }
504
 
505
  $pushUrl = Mage::getUrl('checkout/klarna/push?klarna_order={checkout.order.id}', array('_nosid' => true));
@@ -534,7 +526,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
534
  Mage::helper('klarna')->logDebugInfo('_getCreateRequest rest', $create);
535
 
536
  $request = new Varien_Object($create);
537
- Mage::dispatchEvent('klarnacheckout_get_create_request', array('request' => $request));
538
 
539
  return $request->getData();
540
  }
@@ -562,7 +554,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
562
  }
563
 
564
  $request = new Varien_Object($update);
565
- Mage::dispatchEvent('klarnacheckout_get_update_request', array('request' => $request));
566
 
567
  return $request->getData();
568
  }
@@ -600,7 +592,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
600
  return false;
601
  }
602
 
603
- protected function _fetchOrder($checkoutId)
604
  {
605
  $ch = curl_init();
606
  $location = $this->_getUrl() . '/checkout/v3/orders/' . $checkoutId;
@@ -617,6 +609,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
617
  Mage::helper('klarna')->logDebugInfo('_fetchOrder rest response = ' . $response . ' status = ' . $status);
618
 
619
  if ($status != 200) {
 
620
  Mage::throwException('Error fetching order: ' . $status);
621
  }
622
 
@@ -635,7 +628,8 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
635
  curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'curlHeader'));
636
  curl_setopt($ch, CURLOPT_HEADER, false);
637
  curl_setopt($ch, CURLOPT_POST, true);
638
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($this->_getCreateRequest()));
 
639
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
640
  $response = curl_exec($ch);
641
  $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
@@ -651,7 +645,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
651
  $this->_klarnaOrder->setLocation($location);
652
  }
653
 
654
- protected function _fetchCreatedOrder($checkoutId)
655
  {
656
  $ch = curl_init();
657
  $location = $this->_getUrl() . '/ordermanagement/v1/orders/' . $checkoutId;
@@ -668,6 +662,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
668
  Mage::helper('klarna')->logDebugInfo('_fetchCreatedOrder rest response = ' . $response . ' status = ' . $status);
669
 
670
  if ($status != 200) {
 
671
  Mage::throwException('Error fetching order: ' . $status);
672
  }
673
 
@@ -752,7 +747,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
752
  }
753
  Mage::throwException($message);
754
  }
755
-
756
  $capture_id = "";
757
  if (isset($this->_curlHeaders['Location'])) {
758
  $location = $this->_curlHeaders['Location'];
@@ -800,7 +795,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
800
 
801
  Mage::helper('klarna')->logDebugInfo('refund rest response = ' . $response . ' status = ' . $status);
802
 
803
- if ($status != 204) {
804
  $response = json_decode($response, true);
805
  $message = 'Error refunding order: ' . $status;
806
  if (isset($response['error_code'])) {
@@ -912,10 +907,10 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
912
  $this->_useKlarnaOrderSessionCache = $value;
913
  }
914
 
915
- public function initKlarnaOrder($checkoutId = null, $createIfNotExists = false, $updateItems = false)
916
  {
917
  if ($checkoutId) {
918
- Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest checkout id: ' . $checkoutId);
919
  $loadf = true;
920
  if ($this->_useKlarnaOrderSessionCache) {
921
  if ($this->_klarnaOrder) {
@@ -930,6 +925,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
930
  if ($this->_getLocationOrderId()) {
931
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
932
  }
 
933
  }
934
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest true');
935
  return $res;
@@ -937,7 +933,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
937
 
938
  if ($klarnaCheckoutId = $this->_getKlarnaCheckoutId()) {
939
  try {
940
- Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest klarnaCheckoutId id: ' . $klarnaCheckoutId);
941
  if ($updateItems) {
942
  $this->_updateOrder($klarnaCheckoutId);
943
  } else {
@@ -948,6 +944,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
948
  if ($this->_getLocationOrderId()) {
949
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
950
  }
 
951
  }
952
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest true');
953
  return $res;
@@ -963,9 +960,12 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
963
  $this->_fetchOrder($checkoutId);
964
  $res = $this->_klarnaOrder!=NULL;
965
  if ($res) {
966
- if ($this->_getLocationOrderId()) {
967
- $this->_setKlarnaCheckoutId($this->_getLocationOrderId()); // $location
 
 
968
  }
 
969
  }
970
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
971
  return $res;
@@ -974,7 +974,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
974
 
975
  return false;
976
  }
977
-
978
  /*
979
  * Not happy with this, but I guess we can't solve it in other ways.
980
  *
@@ -986,7 +986,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
986
  }
987
  return NULL;
988
  }
989
-
990
  public function getKlarnaCheckoutGui()
991
  {
992
  if ($this->_klarnaOrder) {
@@ -1009,8 +1009,8 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
1009
  {
1010
  if ($this->_klarnaOrder) {
1011
  /** @var $quote Mage_Sales_Model_Quote */
1012
- $quote = Mage::getModel('sales/quote')->load($this->_getLocationOrderId(), 'klarna_checkout_id');
1013
- if ($quote->getId()) {
1014
  return $quote;
1015
  }
1016
  }
@@ -1039,7 +1039,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
1039
  } else {
1040
  Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder rest order no: ' . $order->getIncrementId());
1041
  }
1042
-
1043
  $this->_acknowledgeOrder($this->_klarnaOrder->getOrderId());
1044
  $this->_updateMerchantReferences($this->_klarnaOrder->getOrderId(), $order->getIncrementId());
1045
  Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder rest success');
@@ -1092,7 +1092,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
1092
  );
1093
  }
1094
  }
1095
-
1096
  /**
1097
  * Set the goods list for Capture
1098
  * Klarna seems to switch the order of the items in capture, so we simply add them backwards.
@@ -1107,7 +1107,7 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
1107
 
1108
  $this->_setRequestList();
1109
  }
1110
-
1111
  /**
1112
  * Set the goods list for Refund
1113
  *
@@ -1141,8 +1141,45 @@ class Vaimo_Klarna_Model_Api_Rest extends Vaimo_Klarna_Model_Api_Abstract
1141
  public function getKlarnaOrderRaw($checkoutId)
1142
  {
1143
  if ($checkoutId) {
1144
- return $this->fetchCreatedOrder($checkoutId);
 
 
 
 
 
 
 
 
 
 
1145
  }
1146
  return NULL;
1147
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1148
  }
46
  return $this;
47
  }
48
 
49
+ public function getApiVersion()
50
+ {
51
+ return ($this->_apiVersion);
52
+ }
53
+
54
  protected function _isUSA()
55
  {
56
  return $this->_apiVersion == Vaimo_Klarna_Helper_Data::KLARNA_KCO_API_VERSION_USA;
73
  }
74
  }
75
  }
76
+
77
  protected function _getUrl()
78
  {
79
  return $this->_url;
103
  }
104
  return $res;
105
  }
106
+
107
  protected function _getAddressData($useTransport = false, $type = Mage_Sales_Model_Quote_Address::TYPE_BILLING)
108
  {
109
  if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
165
  protected function _getCustomerData()
166
  {
167
  if (!$this->_getTransport()->getConfigData('auto_prefil')) return NULL;
168
+
169
  /** @var $session Mage_Customer_Model_Session */
170
  $session = Mage::getSingleton('customer/session');
171
  if ($session->isLoggedIn()) {
180
  }
181
 
182
  return NULL;
183
+ }
184
 
185
  /**
186
  * Get active Klarna checkout id
219
  $quote = $this->_getQuote();
220
  }
221
  $items = array();
 
222
  $calculator = Mage::getSingleton('tax/calculation');
223
 
224
  foreach ($quote->getAllVisibleItems() as $quoteItem) {
228
  $taxRate = $quoteItem->getTaxAmount() / $quoteItem->getRowTotal() * 100;
229
  }
230
  $taxAmount = $calculator->calcTaxAmount($quoteItem->getRowTotalInclTax(), $taxRate, true);
231
+
 
 
 
 
232
  if ($this->_isUSA()) {
233
  // $unitPrice = $quoteItem->getPrice();
234
  $totalAmount = $quoteItem->getRowTotalInclTax() - $taxAmount;
267
  $amount = $amount - $taxAmount - $hiddenTaxAmount;
268
  }
269
  $taxRate = ($taxAmount + $hiddenTaxAmount) / $amount * 100;
 
270
  if ($this->_isUSA()) {
271
  $unitPrice = $amount;
272
  $totalAmount = $amount;
298
  $taxAmount = $total->getAddress()->getHiddenTaxAmount();
299
  $amount = -$total->getAddress()->getDiscountAmount() - $taxAmount;
300
  $taxRate = $taxAmount / $amount * 100;
 
301
  if ($this->_isUSA()) {
302
  $unitPrice = $amount;
303
  $totalAmount = $amount;
388
  $totalAmount += $item['total_amount'];
389
  }
390
  $totalTax = (($quote->getGrandTotal() * 100) - $totalAmount) / 100;
391
+
 
 
 
 
 
392
  $items[] = array(
393
  'type' => 'sales_tax',
394
  'reference' => Mage::helper('klarna')->__('Sales Tax'),
435
  if ($data = $this->_getCustomerData()) {
436
  $create['customer'] = $data;
437
  }
438
+
439
  $create['order_amount'] = round($this->_getQuote()->getGrandTotal() * 100);
440
  $create['order_tax_amount'] = 0;
441
  $create['order_lines'] = $this->_getCartItems();
448
  } else {
449
  $create['order_tax_amount'] += $line['total_tax_amount'];
450
  }
 
451
  }
 
452
 
453
+ if ($this->_getTransport()->getConfigData('other_countries')) {
454
  $shippingCountries = $this->_getTransport()->getConfigData('shipping_countries');
455
  if ($shippingCountries) {
456
  $create['shipping_countries'] = explode(',', $shippingCountries);
457
  }
458
+ }
459
 
460
+ if ($this->_getTransport()->getConfigData('shipping_options')) {
461
+ $shippingOptions = array();
462
+ $address = $this->_getQuote()->getShippingAddress();
463
+ $originalShippingMethod = $address->getShippingMethod();
464
+ $methods = Mage::getModel('checkout/cart_shipping_api')->getShippingMethodsList($this->_getQuote()->getId());
465
+ foreach ($methods as $method) {
466
+ $address->setShippingMethod($method['code']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  $this->_getQuote()->setTotalsCollectedFlag(false)->collectTotals();
468
+ if ($address->getShippingAmount()>0) {
469
+ $taxRate = ($address->getShippingAmount() + $address->getShippingTaxAmount()) / $address->getShippingAmount() * 100;
470
+ } else {
471
+ $taxRate = 0;
472
+ }
473
+ if ($method['code']==$originalShippingMethod) {
474
+ $preSelected = true;
475
+ } else {
476
+ $preSelected = false;
477
+ }
478
+ $shippingOptions[] = array(
479
+ 'id' => $method['code'],
480
+ 'name' => $method['method_title'],
481
+ 'description' => $method['carrier_title'],
482
+ 'price' => (int)($address->getShippingAmount() + $address->getShippingTaxAmount()) * 100,
483
+ 'tax_amount' => (int)$address->getShippingTaxAmount() * 100,
484
+ 'tax_rate' => (int)($taxRate * 100) * 100,
485
+ 'preselected' => $preSelected,
486
  );
487
  }
488
+ $address->setShippingMethod($originalShippingMethod);
489
+ $this->_getQuote()->setTotalsCollectedFlag(false)->collectTotals();
490
+ $create['shipping_options'] = $shippingOptions;
491
+ $create['selected_shipping_option'] = array(
492
+ 'id' => $address->getShippingMethod(),
493
+ 'name' => $address->getShippingDescription(),
494
+ );
495
  }
496
 
497
  $pushUrl = Mage::getUrl('checkout/klarna/push?klarna_order={checkout.order.id}', array('_nosid' => true));
526
  Mage::helper('klarna')->logDebugInfo('_getCreateRequest rest', $create);
527
 
528
  $request = new Varien_Object($create);
529
+ Mage::dispatchEvent('klarnacheckout_get_create_request', array('request' => $request, 'api_version' => $this->getApiVersion()));
530
 
531
  return $request->getData();
532
  }
554
  }
555
 
556
  $request = new Varien_Object($update);
557
+ Mage::dispatchEvent('klarnacheckout_get_update_request', array('request' => $request, 'api_version' => $this->getApiVersion()));
558
 
559
  return $request->getData();
560
  }
592
  return false;
593
  }
594
 
595
+ protected function _fetchOrder($checkoutId, $silentFail = false)
596
  {
597
  $ch = curl_init();
598
  $location = $this->_getUrl() . '/checkout/v3/orders/' . $checkoutId;
609
  Mage::helper('klarna')->logDebugInfo('_fetchOrder rest response = ' . $response . ' status = ' . $status);
610
 
611
  if ($status != 200) {
612
+ if ($silentFail) return;
613
  Mage::throwException('Error fetching order: ' . $status);
614
  }
615
 
628
  curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'curlHeader'));
629
  curl_setopt($ch, CURLOPT_HEADER, false);
630
  curl_setopt($ch, CURLOPT_POST, true);
631
+ $request = json_encode($this->_getCreateRequest());
632
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
633
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
634
  $response = curl_exec($ch);
635
  $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
645
  $this->_klarnaOrder->setLocation($location);
646
  }
647
 
648
+ protected function _fetchCreatedOrder($checkoutId, $silentFail = false)
649
  {
650
  $ch = curl_init();
651
  $location = $this->_getUrl() . '/ordermanagement/v1/orders/' . $checkoutId;
662
  Mage::helper('klarna')->logDebugInfo('_fetchCreatedOrder rest response = ' . $response . ' status = ' . $status);
663
 
664
  if ($status != 200) {
665
+ if ($silentFail) return;
666
  Mage::throwException('Error fetching order: ' . $status);
667
  }
668
 
747
  }
748
  Mage::throwException($message);
749
  }
750
+
751
  $capture_id = "";
752
  if (isset($this->_curlHeaders['Location'])) {
753
  $location = $this->_curlHeaders['Location'];
795
 
796
  Mage::helper('klarna')->logDebugInfo('refund rest response = ' . $response . ' status = ' . $status);
797
 
798
+ if ($status != 201) {
799
  $response = json_decode($response, true);
800
  $message = 'Error refunding order: ' . $status;
801
  if (isset($response['error_code'])) {
907
  $this->_useKlarnaOrderSessionCache = $value;
908
  }
909
 
910
+ public function initKlarnaOrder($checkoutId = null, $createIfNotExists = false, $updateItems = false, $quoteId = '')
911
  {
912
  if ($checkoutId) {
913
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest checkout id: ' . $checkoutId . ' (quote id: ' . $quoteId . ')');
914
  $loadf = true;
915
  if ($this->_useKlarnaOrderSessionCache) {
916
  if ($this->_klarnaOrder) {
925
  if ($this->_getLocationOrderId()) {
926
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
927
  }
928
+ Mage::dispatchEvent('klarnacheckout_init_klarna_order', array('klarna_order' => $this->_klarnaOrder, 'api_version' => $this->getApiVersion()));
929
  }
930
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest true');
931
  return $res;
933
 
934
  if ($klarnaCheckoutId = $this->_getKlarnaCheckoutId()) {
935
  try {
936
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest klarnaCheckoutId id: ' . $klarnaCheckoutId . ' (quote id: ' . $quoteId . ')');
937
  if ($updateItems) {
938
  $this->_updateOrder($klarnaCheckoutId);
939
  } else {
944
  if ($this->_getLocationOrderId()) {
945
  $this->_setKlarnaCheckoutId($this->_getLocationOrderId());
946
  }
947
+ Mage::dispatchEvent('klarnacheckout_init_klarna_order', array('klarna_order' => $this->_klarnaOrder, 'api_version' => $this->getApiVersion()));
948
  }
949
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest true');
950
  return $res;
960
  $this->_fetchOrder($checkoutId);
961
  $res = $this->_klarnaOrder!=NULL;
962
  if ($res) {
963
+ $klarnaCheckoutId = $this->_getLocationOrderId();
964
+ if ($klarnaCheckoutId) {
965
+ $this->_setKlarnaCheckoutId($klarnaCheckoutId);
966
+ Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder rest created, klarnaCheckoutId id: ' . $klarnaCheckoutId . ' (quote id: ' . $quoteId . ')');
967
  }
968
+ Mage::dispatchEvent('klarnacheckout_init_klarna_order', array('klarna_order' => $this->_klarnaOrder, 'api_version' => $this->getApiVersion()));
969
  }
970
  Mage::helper('klarna')->logKlarnaApi('initKlarnaOrder res: ' . $res);
971
  return $res;
974
 
975
  return false;
976
  }
977
+
978
  /*
979
  * Not happy with this, but I guess we can't solve it in other ways.
980
  *
986
  }
987
  return NULL;
988
  }
989
+
990
  public function getKlarnaCheckoutGui()
991
  {
992
  if ($this->_klarnaOrder) {
1009
  {
1010
  if ($this->_klarnaOrder) {
1011
  /** @var $quote Mage_Sales_Model_Quote */
1012
+ $quote = Mage::helper('klarna')->findQuote($this->_getLocationOrderId());
1013
+ if ($quote && $quote->getId()) {
1014
  return $quote;
1015
  }
1016
  }
1039
  } else {
1040
  Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder rest order no: ' . $order->getIncrementId());
1041
  }
1042
+
1043
  $this->_acknowledgeOrder($this->_klarnaOrder->getOrderId());
1044
  $this->_updateMerchantReferences($this->_klarnaOrder->getOrderId(), $order->getIncrementId());
1045
  Mage::helper('klarna')->logKlarnaApi('updateKlarnaOrder rest success');
1092
  );
1093
  }
1094
  }
1095
+
1096
  /**
1097
  * Set the goods list for Capture
1098
  * Klarna seems to switch the order of the items in capture, so we simply add them backwards.
1107
 
1108
  $this->_setRequestList();
1109
  }
1110
+
1111
  /**
1112
  * Set the goods list for Refund
1113
  *
1141
  public function getKlarnaOrderRaw($checkoutId)
1142
  {
1143
  if ($checkoutId) {
1144
+ if ($this->_klarnaOrder) {
1145
+ return $this->_klarnaOrder;
1146
+ }
1147
+ $this->_fetchCreatedOrder($checkoutId, true);
1148
+ if ($this->_klarnaOrder) {
1149
+ return $this->_klarnaOrder;
1150
+ }
1151
+ $this->_fetchOrder($checkoutId, true);
1152
+ if ($this->_klarnaOrder) {
1153
+ return $this->_klarnaOrder;
1154
+ }
1155
  }
1156
  return NULL;
1157
  }
1158
+
1159
+ public function sanityTestQuote($createdKlarnaOrder, $quote)
1160
+ {
1161
+ $res = NULL;
1162
+
1163
+ foreach ($quote->getAllVisibleItems() as $quoteItem) {
1164
+ $foundf = false;
1165
+ $data = $createdKlarnaOrder->getData();
1166
+ if (isset($data['order_lines'])) {
1167
+ foreach ($data['order_lines'] as $klarnaItem) {
1168
+ if ($klarnaItem['reference']==$quoteItem->getSku() &&
1169
+ $klarnaItem['quantity']==$quoteItem->getQty()
1170
+ ) {
1171
+ $foundf = true;
1172
+ continue;
1173
+ }
1174
+ }
1175
+ }
1176
+ if (!$foundf) {
1177
+ if (!$res) $res = array();
1178
+ $res[] = Mage::helper('klarna')->__('Product not the same as on reservation:') . $quoteItem->getSku() . ' ' . $quoteItem->getName();
1179
+ }
1180
+ }
1181
+
1182
+ return $res;
1183
+ }
1184
+
1185
  }
app/code/community/Vaimo/Klarna/Model/Api/Xmlrpc.php CHANGED
@@ -538,7 +538,7 @@ class Vaimo_Klarna_Model_Api_Xmlrpc extends Vaimo_Klarna_Model_Api_Abstract
538
  if (method_exists('Mage', 'getEdition')) {
539
  $magentoEdition = Mage::getEdition();
540
  } else {
541
- if (class_exists("Enterprise_UrlRewrite_Model_Redirect", false)) {
542
  $magentoEdition = "Enterprise";
543
  } else {
544
  $magentoEdition = "Community";
@@ -975,12 +975,12 @@ class Vaimo_Klarna_Model_Api_Xmlrpc extends Vaimo_Klarna_Model_Api_Abstract
975
  */
976
  public function setGoodsListCapture($amount)
977
  {
978
- foreach (array_reverse($this->_getTransport()->getExtras()) as $extra) {
979
- $this->_addArtNo($extra);
980
- }
981
- foreach (array_reverse($this->_getTransport()->getGoodsList()) as $item) {
982
  $this->_addArtNo($item);
983
  }
 
 
 
984
  }
985
 
986
  /**
538
  if (method_exists('Mage', 'getEdition')) {
539
  $magentoEdition = Mage::getEdition();
540
  } else {
541
+ if (Mage::helper('klarna')->isEnterpriseAndHasClass()) {
542
  $magentoEdition = "Enterprise";
543
  } else {
544
  $magentoEdition = "Community";
975
  */
976
  public function setGoodsListCapture($amount)
977
  {
978
+ foreach ($this->_getTransport()->getGoodsList() as $item) {
 
 
 
979
  $this->_addArtNo($item);
980
  }
981
+ foreach ($this->_getTransport()->getExtras() as $extra) {
982
+ $this->_addArtNo($extra);
983
+ }
984
  }
985
 
986
  /**
app/code/community/Vaimo/Klarna/Model/Cron.php CHANGED
@@ -1,44 +1,117 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2009-2014 Vaimo AB
4
- *
5
- * Vaimo reserves all rights in the Program as delivered. The Program
6
- * or any portion thereof may not be reproduced in any form whatsoever without
7
- * the written consent of Vaimo, except as provided by licence. A licence
8
- * under Vaimo's rights in the Program may be available directly from
9
- * Vaimo.
10
- *
11
- * Disclaimer:
12
- * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF.
13
- * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS
19
- * IN THE PROGRAM.
20
- *
21
- * @category Vaimo
22
- * @package Vaimo_Klarna
23
- * @copyright Copyright (c) 2009-2014 Vaimo AB
24
- */
25
-
26
-
27
- class Vaimo_Klarna_Model_Cron extends Mage_Core_Model_Abstract
28
- {
29
- public function statusUpdateOfPendingOrders()
30
- {
31
- $orders = Mage::getModel("sales/order")->getCollection()
32
- ->addFieldToFilter("state", array('eq' => Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW))
33
- ->addFieldToFilter("updated_at", array('gteq' => date("Y-m-d H:i:s", time() - 172800))); // 2 Days
34
- foreach ($orders as $order) {
35
- try {
36
- $order->getPayment()
37
- ->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true);
38
- $order->save();
39
- } catch (Exception $e) {
40
- // Do nothing?
41
- }
42
- }
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2009-2014 Vaimo AB
4
+ *
5
+ * Vaimo reserves all rights in the Program as delivered. The Program
6
+ * or any portion thereof may not be reproduced in any form whatsoever without
7
+ * the written consent of Vaimo, except as provided by licence. A licence
8
+ * under Vaimo's rights in the Program may be available directly from
9
+ * Vaimo.
10
+ *
11
+ * Disclaimer:
12
+ * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF.
13
+ * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS
19
+ * IN THE PROGRAM.
20
+ *
21
+ * @category Vaimo
22
+ * @package Vaimo_Klarna
23
+ * @copyright Copyright (c) 2009-2014 Vaimo AB
24
+ */
25
+
26
+
27
+ class Vaimo_Klarna_Model_Cron extends Mage_Core_Model_Abstract
28
+ {
29
+ public function statusUpdateOfPendingOrders()
30
+ {
31
+ $orders = Mage::getModel("sales/order")->getCollection()
32
+ ->addFieldToFilter("state", array('eq' => Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW))
33
+ ->addFieldToFilter("updated_at", array('gteq' => date("Y-m-d H:i:s", time() - 172800))); // 2 Days
34
+ foreach ($orders as $order) {
35
+ try {
36
+ $payment = $order->getPayment();
37
+ if (Mage::helper('klarna')->isMethodKlarna($payment->getMethod())) {
38
+ $payment->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true);
39
+ $order->save();
40
+ }
41
+ } catch (Exception $e) {
42
+ // Do nothing?
43
+ }
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Basically a copy of the KlarnaController pushAction
49
+ * This will be unified later
50
+ */
51
+ public function treatPushQueue()
52
+ {
53
+ $collection = Mage::getModel('klarna/pushqueue')
54
+ ->getCollection()
55
+ ->applyRetryFilter(Vaimo_Klarna_Helper_Data::KLARNA_KCO_QUEUE_RETRY_ATTEMPTS);
56
+ if ($collection->count()>0) {
57
+ $helper = Mage::helper('klarna');
58
+ $helper->setFunctionNameForLog('cron treatPushQueue');
59
+ $helper->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
60
+ foreach ($collection as $pushQueue) {
61
+ $checkoutId = $pushQueue->getKlarnaOrderNumber();
62
+ $quote = $helper->findQuote($checkoutId);
63
+ if ($quote == null)
64
+ continue;
65
+
66
+ /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
67
+ $klarna = Mage::getModel('klarna/klarnacheckout');
68
+ $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
69
+ if (substr($checkoutId, -1, 1) == '/') {
70
+ $checkoutId = substr($checkoutId, 0, strlen($checkoutId) - 1);
71
+ }
72
+ $helper->logKlarnaApi('pushAction checkout id: ' . $checkoutId);
73
+ if (!$quote->getId()) {
74
+ $helper->logKlarnaApi('pushAction checkout quote not found!');
75
+ }
76
+
77
+ if ($checkoutId) {
78
+ try {
79
+ // createOrder returns the order if successful, otherwise an error string
80
+ $result = $klarna->createOrder($checkoutId);
81
+
82
+ if (is_array($result)) {
83
+ if ($result['status']=='success') {
84
+ $pushQueue->delete();
85
+ $helper->logKlarnaApi('Klarna cron order created successfully, order id: ' . $result['order']->getId());
86
+ } elseif ($result['status']=='fail') {
87
+ $pushQueue->delete();
88
+ $helper->logKlarnaApi($result['message']);
89
+ } else {
90
+ $pushQueue->setMessage($result['message']);
91
+ $attempt = $pushQueue->getRetryAttempts();
92
+ $pushQueue->setRetryAttempts($attempt + 1);
93
+ $pushQueue->save();
94
+ $helper->logKlarnaApi($result['message']);
95
+ }
96
+ } else {
97
+ $pushQueue->setMessage('Unkown error from createOrder');
98
+ $attempt = $pushQueue->getRetryAttempts();
99
+ $pushQueue->setRetryAttempts($attempt + 1);
100
+ $pushQueue->save();
101
+ $helper->logKlarnaApi('Unkown error from createOrder');
102
+ }
103
+
104
+ } catch (Exception $e) {
105
+ $pushQueue->setMessage($e->getMessage());
106
+ $attempt = $pushQueue->getRetryAttempts();
107
+ $pushQueue->setRetryAttempts($attempt + 1);
108
+ $pushQueue->save();
109
+ $helper->logKlarnaException($e);
110
+ }
111
+ }
112
+ }
113
+ $helper->setFunctionNameForLog('cron treatPushQueue');
114
+ $helper->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
115
+ }
116
+ }
117
+ }
app/code/community/Vaimo/Klarna/Model/Klarna.php CHANGED
@@ -290,7 +290,10 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
290
  * in this function. Authorize will attempt to use the value and give an error message, which means
291
  * it will be checked and reported anyway
292
  */
293
- if (!$this->_getHelper()->isOneStepCheckout() && !$this->_getHelper()->isQuickCheckout()) {
 
 
 
294
  Mage::throwException($this->_getHelper()->__(
295
  'Unknown address, please specify correct personal id in the payment selection and press Fetch again, or use another payment method'
296
  )
@@ -308,7 +311,10 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
308
  /*
309
  * No error message here if using OneStepCheckout
310
  */
311
- if (!$this->_getHelper()->isOneStepCheckout() && !$this->_getHelper()->isQuickCheckout()) {
 
 
 
312
  Mage::throwException($this->_getHelper()->__(
313
  'Unknown address, please specify correct personal id in the payment selection and press Fetch again, or use another payment method'
314
  )
@@ -554,8 +560,8 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
554
  {
555
  $id = $this->getPostValues(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN);
556
  // @todo read from checkoutService to find new details for Sweden and Norway and store them
557
- $method = $this->getPostValues('method');
558
- if ($id) {
559
  $pclassArray = $this->_getSpecificPClass($id);
560
  if (!$pclassArray) {
561
  Mage::throwException($this->_getHelper()->__('Unexpected error, pclass does not exist, please reload page and try again'));
@@ -570,9 +576,11 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
570
  Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN_TYPE => $pclassArray['type'],
571
  ));
572
  } else {
 
573
  if ($method==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_ACCOUNT || $method==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_SPECIAL ) {
574
  Mage::throwException($this->_getHelper()->__('You must choose a payment plan'));
575
  }
 
576
  $this->addPostValues(array(
577
  Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN_DESCRIPTION => '',
578
  Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN_MONTHLY_COST => '',
@@ -628,6 +636,9 @@ class Vaimo_Klarna_Model_Klarna extends Vaimo_Klarna_Model_Klarna_Abstract
628
  Mage::throwException($this->_getHelper()->__('You need to enter your gender to be able to continue'));
629
  }
630
  }
 
 
 
631
  }
632
 
633
  public function createItemListRefund()
290
  * in this function. Authorize will attempt to use the value and give an error message, which means
291
  * it will be checked and reported anyway
292
  */
293
+ if (!$this->_getHelper()->isOneStepCheckout() &&
294
+ !$this->_getHelper()->isFireCheckout() &&
295
+ !$this->_getHelper()->isVaimoCheckout() &&
296
+ !$this->_getHelper()->isQuickCheckout()) {
297
  Mage::throwException($this->_getHelper()->__(
298
  'Unknown address, please specify correct personal id in the payment selection and press Fetch again, or use another payment method'
299
  )
311
  /*
312
  * No error message here if using OneStepCheckout
313
  */
314
+ if (!$this->_getHelper()->isOneStepCheckout() &&
315
+ !$this->_getHelper()->isFireCheckout() &&
316
+ !$this->_getHelper()->isVaimoCheckout() &&
317
+ !$this->_getHelper()->isQuickCheckout()) {
318
  Mage::throwException($this->_getHelper()->__(
319
  'Unknown address, please specify correct personal id in the payment selection and press Fetch again, or use another payment method'
320
  )
560
  {
561
  $id = $this->getPostValues(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN);
562
  // @todo read from checkoutService to find new details for Sweden and Norway and store them
563
+ $method = $this->getMethod();
564
+ if ($id && $method==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_ACCOUNT) {
565
  $pclassArray = $this->_getSpecificPClass($id);
566
  if (!$pclassArray) {
567
  Mage::throwException($this->_getHelper()->__('Unexpected error, pclass does not exist, please reload page and try again'));
576
  Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN_TYPE => $pclassArray['type'],
577
  ));
578
  } else {
579
+ /*
580
  if ($method==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_ACCOUNT || $method==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_SPECIAL ) {
581
  Mage::throwException($this->_getHelper()->__('You must choose a payment plan'));
582
  }
583
+ */
584
  $this->addPostValues(array(
585
  Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN_DESCRIPTION => '',
586
  Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN_MONTHLY_COST => '',
636
  Mage::throwException($this->_getHelper()->__('You need to enter your gender to be able to continue'));
637
  }
638
  }
639
+ if ($this->_checkPaymentPlan()==false) {
640
+ Mage::throwException($this->_getHelper()->__('You must choose a payment plan'));
641
+ }
642
  }
643
 
644
  public function createItemListRefund()
app/code/community/Vaimo/Klarna/Model/Klarna/Abstract.php CHANGED
@@ -57,11 +57,8 @@ abstract class Vaimo_Klarna_Model_Klarna_Abstract extends Vaimo_Klarna_Model_Tra
57
  $this->_entGWHelper = $entGWHelper;
58
  if ($this->_entGWHelper==NULL) {
59
  $this->_entGWHelper = $moduleHelper; // entGWHelper only used as a transaltor, if different GW is used than Magento, it will just not translate it
60
- try {
61
- if (class_exists("Enterprise_GiftWrapping_Helper_Data", true)) {
62
- $this->_entGWHelper = Mage::helper('enterprise_giftwrapping');
63
- }
64
- } catch (Exception $e) {
65
  }
66
  }
67
  $this->_salesHelper = $salesHelper;
@@ -215,15 +212,6 @@ abstract class Vaimo_Klarna_Model_Klarna_Abstract extends Vaimo_Klarna_Model_Tra
215
  );
216
  return $calculation->getRate($request->setProductClassId($taxClass));
217
  }
218
-
219
- protected function _checkBundles(&$item, $product)
220
- {
221
- if ($item->getProductType()==Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
222
- if ($product->getPriceType()==Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) {
223
- $item->setPriceInclTax(0);
224
- }
225
- }
226
- }
227
 
228
  /**
229
  * Create the goods list for Reservations
@@ -252,18 +240,27 @@ abstract class Vaimo_Klarna_Model_Klarna_Abstract extends Vaimo_Klarna_Model_Tra
252
  $id = $item->getProductId();
253
  $product = $this->_loadProductById($id);
254
 
255
- $this->_checkBundles($item, $product);
256
 
257
  $taxRate = $this->_getTaxRate($product->getTaxClassId());
258
 
 
 
 
 
 
 
 
 
 
259
  $this->_goods_list[] =
260
  array(
261
  "qty" => $qty,
262
  "sku" => $item->getSku(),
263
  "name" => $item->getName(),
264
- "price" => $item->getPriceInclTax(),
265
- "total_amount" => $item->getRowTotalInclTax(),
266
- "total_tax_amount" => $item->getTaxAmount(),
267
  "tax" => $taxRate,
268
  "discount" => 0,
269
  "flags" => Vaimo_Klarna_Helper_Data::KLARNA_FLAG_ITEM_NORMAL,
@@ -867,6 +864,33 @@ abstract class Vaimo_Klarna_Model_Klarna_Abstract extends Vaimo_Klarna_Model_Tra
867
  return true;
868
  }
869
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
870
  /**
871
  * Check that gender has been selected
872
  *
57
  $this->_entGWHelper = $entGWHelper;
58
  if ($this->_entGWHelper==NULL) {
59
  $this->_entGWHelper = $moduleHelper; // entGWHelper only used as a transaltor, if different GW is used than Magento, it will just not translate it
60
+ if ($this->_getHelper()->isEnterpriseAndHasClass('Enterprise_GiftWrapping_Helper_Data')) {
61
+ $this->_entGWHelper = Mage::helper('enterprise_giftwrapping');
 
 
 
62
  }
63
  }
64
  $this->_salesHelper = $salesHelper;
212
  );
213
  return $calculation->getRate($request->setProductClassId($taxClass));
214
  }
 
 
 
 
 
 
 
 
 
215
 
216
  /**
217
  * Create the goods list for Reservations
240
  $id = $item->getProductId();
241
  $product = $this->_loadProductById($id);
242
 
243
+ $shouldSumsBeZero = $this->_getHelper()->checkBundles($item, $product);
244
 
245
  $taxRate = $this->_getTaxRate($product->getTaxClassId());
246
 
247
+ $price = $item->getPriceInclTax();
248
+ $totalInclTax = $item->getRowTotalInclTax();
249
+ $taxAmount = $item->getTaxAmount();
250
+ if ($shouldSumsBeZero) {
251
+ $price = 0;
252
+ $totalInclTax = 0;
253
+ $taxAmount = 0;
254
+ }
255
+
256
  $this->_goods_list[] =
257
  array(
258
  "qty" => $qty,
259
  "sku" => $item->getSku(),
260
  "name" => $item->getName(),
261
+ "price" => $price,
262
+ "total_amount" => $totalInclTax,
263
+ "total_tax_amount" => $taxAmount,
264
  "tax" => $taxRate,
265
  "discount" => 0,
266
  "flags" => Vaimo_Klarna_Helper_Data::KLARNA_FLAG_ITEM_NORMAL,
864
  return true;
865
  }
866
 
867
+ /**
868
+ * Check payment plan, that one was chosen if using account method
869
+ *
870
+ * @return bool
871
+ */
872
+ protected function _checkPaymentPlan()
873
+ {
874
+ try {
875
+ if ($this->getMethod()==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_ACCOUNT) {
876
+ $data = $this->getInfoInstance();
877
+ if (!$data->getAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN)) {
878
+ return false;
879
+ } else {
880
+ $id = $data->getAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_PAYMENT_PLAN);
881
+ $paymentType = $this->_getSpecificPClass($id);
882
+ if (!$paymentType) {
883
+ return false;
884
+ }
885
+ }
886
+ }
887
+ } catch (Mage_Core_Exception $e) {
888
+ $this->_getHelper()->logKlarnaException($e);
889
+ return false;
890
+ }
891
+ return true;
892
+ }
893
+
894
  /**
895
  * Check that gender has been selected
896
  *
app/code/community/Vaimo/Klarna/Model/Klarnacheckout.php CHANGED
@@ -87,19 +87,23 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
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
  /**
97
  * When we call this function, order is already done and complete. We can then cache
98
  * the information we get from Klarna so when we call initKlarnaOrder again (from
99
  * phtml files) we can use the cached order instead of fetching it again.
100
- *
101
  * @param string $checkoutId
102
- *
103
  * @return string
104
  */
105
  public function getCheckoutStatus($checkoutId = null)
@@ -116,7 +120,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
116
  $this->_getHelper()->logKlarnaApi('Call complete');
117
  return $res;
118
  }
119
-
120
  /*
121
  * Not happy with this, but I guess we can't solve it in other ways.
122
  *
@@ -125,7 +129,7 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
125
  {
126
  return $this->_api->getActualKlarnaOrder();
127
  }
128
-
129
  /*
130
  * Will return the klarna order or null, if it doesn't find it
131
  * Not used by this module, but as a service for others.
@@ -143,23 +147,20 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
143
  $this->_getHelper()->logKlarnaApi('Call complete');
144
  return $res;
145
  }
146
-
147
- public function validateQuote()
148
- {
149
- /** @var Mage_Sales_Model_Quote $quote */
150
- $quote = $this->getQuote();
151
 
152
- if (!$quote->getId()) {
153
- $this->_getHelper()->logDebugInfo('validateQuote could not get quote');
154
- return 'could not get quote';
 
 
 
 
155
  }
 
156
 
157
- if (!$quote->hasItems()) {
158
- $this->_getHelper()->logDebugInfo('validateQuote has no items');
159
- return 'has no items';
160
- }
161
-
162
- $result = array();
163
  $simpleQty = array();
164
  foreach ($quote->getItemsCollection() as $item) {
165
  if ($item->getProductType()=='simple') {
@@ -171,12 +172,43 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
171
  $simpleQty[$item->getSku()] = $item->getQty();
172
  }
173
  if (!$stockItem->checkQty($simpleQty[$item->getSku()])) {
174
- $result[] = $this->_getHelper()->__('The requested quantity for "%s" is not available.', $item->getName());
 
 
 
 
 
 
 
 
 
175
  }
176
  }
177
  }
178
  }
179
- if (sizeof($result)>0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  return implode("\n", $result);
181
  }
182
 
@@ -196,47 +228,143 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
196
 
197
  if (!$quote->validateMinimumAmount()) {
198
  $this->_getHelper()->logDebugInfo('validateQuote below minimum amount');
199
- return 'minimum amount';
200
  }
201
 
202
- $quote->reserveOrderId()->save();
203
- $this->_getHelper()->logDebugInfo('validateQuote reserved order id: ' . $quote->getReservedOrderId());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
  return true;
206
  }
207
 
208
- public function createOrder($checkoutId = null)
 
 
 
 
 
 
 
 
209
  {
210
- $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER);
211
- if ($checkoutId) {
212
- $this->_getHelper()->logKlarnaApi('Call with checkout ID ' . $checkoutId);
213
- } else {
214
- $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  }
216
- $createdKlarnaOrder = $this->_api->fetchCreatedOrder($checkoutId);
217
- if (!$createdKlarnaOrder) {
218
- $this->_getHelper()->logDebugInfo('createOrder could not fetch createdKlarnaOrder');
219
- return 'could not fetch createdKlarnaOrder';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  }
221
-
222
- $quote = $this->_api->loadQuote();
223
- if (!$quote) {
224
- $this->_getHelper()->logDebugInfo('createOrder could not get quote');
225
- return 'could not get quote';
226
  }
227
- $this->setQuote($quote);
228
-
229
 
 
 
230
  $billingStreetAddress = $createdKlarnaOrder->getBillingAddress('street_address');
231
  $billingStreetAddress2 = $createdKlarnaOrder->getBillingAddress('street_address2');
232
  $billingStreetName = $createdKlarnaOrder->getBillingAddress('street_name');
233
  $billingStreetNumber = $createdKlarnaOrder->getBillingAddress('street_number');
234
- $billingRegionCode = $createdKlarnaOrder->getBillingAddress('region');
235
  $shippingStreetAddress = $createdKlarnaOrder->getShippingAddress('street_address');
236
  $shippingStreetAddress2 = $createdKlarnaOrder->getShippingAddress('street_address2');
237
  $shippingStreetName = $createdKlarnaOrder->getShippingAddress('street_name');
238
  $shippingStreetNumber = $createdKlarnaOrder->getShippingAddress('street_number');
239
- $shippingRegionCode = $createdKlarnaOrder->getShippingAddress('region');
240
 
241
  if (!$billingStreetAddress && $billingStreetName && $billingStreetNumber) {
242
  $streetAddress = $createdKlarnaOrder->getBillingAddress();
@@ -260,119 +388,131 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
260
  $createdKlarnaOrder->setShippingAddress($streetAddress);
261
  }
262
 
263
- if ($createdKlarnaOrder->getStatus() != 'checkout_complete' && $createdKlarnaOrder->getStatus() != 'created') {
264
- $this->_getHelper()->logDebugInfo('createOrder status not complete');
265
- return 'status not complete';
266
- }
267
 
268
- $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
269
- if ($orderId>0) {
270
- $this->_getHelper()->logDebugInfo('createOrder order already created ' . $orderId);
271
- if (($createdKlarnaOrder->getStatus() == 'checkout_complete') || ($createdKlarnaOrder->getStatus() == 'created')) {
272
- $order = $this->_loadOrderByKey($quote->getId());
273
- $this->_api->updateKlarnaOrder($order, true);
274
- $this->_getHelper()->logDebugInfo('updating order status on already crated order ' . $orderId);
275
- }
276
- return 'order already created';
277
- }
278
- $isNewCustomer = false;
279
 
280
- if ($quote->getCustomerId()) {
281
- $customer = $this->_loadCustomer($quote->getCustomerId());
282
- $quote->setCustomer($customer);
283
- $quote->setCheckoutMethod('customer');
284
- } else {
285
- /** @var $customer Mage_Customer_Model_Customer */
286
- $customer = $this->_loadCustomerByEmail($createdKlarnaOrder->getBillingAddress('email'), $quote->getStore());
287
- if ($customer->getId()) {
288
  $quote->setCustomer($customer);
289
  $quote->setCheckoutMethod('customer');
290
  } else {
291
- $quote->setCheckoutMethod('register');
292
- $isNewCustomer = true;
 
 
 
 
 
 
 
 
 
293
  }
294
- }
295
 
296
- $billingAddress = $quote->getBillingAddress();
297
- $customerAddressId = 0;
298
 
299
- if ($customerAddressId) {
300
- $customerAddress = $this->_loadCustomerAddress($customerAddressId);
301
- if ($customerAddress->getId()) {
302
- if ($customerAddress->getCustomerId() != $this->getQuote()->getCustomerId()) {
303
- throw new Exception('Customer Address is not valid');
304
- }
305
 
306
- $billingAddress->importCustomerAddress($customerAddress)->setSaveInAddressBook(0);
307
- }
308
- } else {
309
- $billingAddress->setFirstname($createdKlarnaOrder->getBillingAddress('given_name'));
310
- $billingAddress->setLastname($createdKlarnaOrder->getBillingAddress('family_name'));
311
- $billingAddress->setCareOf($createdKlarnaOrder->getBillingAddress('care_of'));
312
- $billingAddress->setStreet($createdKlarnaOrder->getBillingAddress('street_address'));
313
- $billingAddress->setPostcode($createdKlarnaOrder->getBillingAddress('postal_code'));
314
- $billingAddress->setCity($createdKlarnaOrder->getBillingAddress('city'));
315
- $billingAddress->setCountryId(strtoupper($createdKlarnaOrder->getBillingAddress('country')));
316
- $billingAddress->setEmail($createdKlarnaOrder->getBillingAddress('email'));
317
- $billingAddress->setTelephone($createdKlarnaOrder->getBillingAddress('phone'));
318
- $billingAddress->setSaveInAddressBook(1);
319
- if ($billingRegionCode) {
320
- $billingRegionId = Mage::getModel('directory/region')->loadByCode($billingRegionCode, $billingAddress->getCountryId());
321
- $billingAddress->setRegionId($billingRegionId->getId());
 
322
  }
323
- }
324
 
325
- // $this->_validateCustomerData($data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
 
327
- $shippingAddress = $quote->getShippingAddress();
328
- $shippingAddress->setFirstname($createdKlarnaOrder->getShippingAddress('given_name'));
329
- $shippingAddress->setLastname($createdKlarnaOrder->getShippingAddress('family_name'));
330
- $shippingAddress->setCareOf($createdKlarnaOrder->getShippingAddress('care_of'));
331
- $shippingAddress->setStreet($createdKlarnaOrder->getShippingAddress('street_address'));
332
- $shippingAddress->setPostcode($createdKlarnaOrder->getShippingAddress('postal_code'));
333
- $shippingAddress->setCity($createdKlarnaOrder->getShippingAddress('city'));
334
- $shippingAddress->setCountryId(strtoupper($createdKlarnaOrder->getShippingAddress('country')));
335
- $shippingAddress->setEmail($createdKlarnaOrder->getShippingAddress('email'));
336
- $shippingAddress->setTelephone($createdKlarnaOrder->getShippingAddress('phone'));
337
- if ($shippingRegionCode) {
338
- $shippingRegionId = Mage::getModel('directory/region')->loadByCode($shippingRegionCode, $shippingAddress->getCountryId());
339
- $shippingAddress->setRegionId($shippingRegionId->getId());
340
- }
341
-
342
- if ($this->getConfigData('packstation_enabled')) {
343
- $shippingAddress->setSameAsBilling(0);
344
- } else {
345
- $shippingAddress->setSameAsBilling(1);
346
- }
347
- $shippingAddress->setSaveInAddressBook(0);
 
 
 
348
 
349
- $quote->getBillingAddress()->setShouldIgnoreValidation(true);
350
- $quote->getShippingAddress()->setShouldIgnoreValidation(true);
 
351
 
352
- $quote->setTotalsCollectedFlag(true);
353
- $quote->save();
 
 
 
354
 
355
- switch ($quote->getCheckoutMethod()) {
356
- case 'register':
357
- $this->_prepareNewCustomerQuote($quote);
358
- break;
359
- case 'customer':
360
- $this->_prepareCustomerQuote($quote);
361
- break;
362
- }
363
 
364
- $service = $this->_getServiceQuote($quote);
365
- $service->submitAll();
366
-
367
- if ($isNewCustomer) {
368
- try {
369
- $this->_involveNewCustomer($quote);
370
- } catch (Exception $e) {
371
- $this->_getHelper()->logKlarnaException($e);
372
  }
373
- }
374
 
375
- $quote->save();
 
376
 
377
  $reservation = $createdKlarnaOrder->getReservation();
378
  if ($createdKlarnaOrder->getOrderId()) {
@@ -382,6 +522,18 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
382
  // Update Order
383
  /** @var $order Mage_Sales_Model_Order */
384
  $order = $this->_loadOrderByKey($quote->getId());
 
 
 
 
 
 
 
 
 
 
 
 
385
  $payment = $order->getPayment();
386
 
387
  if ($createdKlarnaOrder->getReference()) {
@@ -400,44 +552,155 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
400
  $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_HOST, $this->getConfigData("host") );
401
  $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_MERCHANT_ID, $this->getConfigData("merchant_id") );
402
 
 
 
 
403
 
404
- $payment->setTransactionId($reservation)
405
- ->setIsTransactionClosed(0)
406
- ->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED);
407
- if ($transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)) {
408
- $transaction->save();
 
 
409
  }
410
  $payment->save();
411
 
412
- // send new order email
413
- if ($order->getCanSendNewEmailFlag()) {
 
 
 
 
 
 
 
 
 
414
  try {
415
- $order->sendNewOrderEmail();
416
- } catch (Exception $e) {
 
 
417
  $this->_getHelper()->logKlarnaException($e);
418
  }
419
- }
420
 
421
- // Subscribe customer to newsletter
422
- try {
423
- if ($quote->getKlarnaCheckoutNewsletter()) {
424
- $this->_addToSubscription($createdKlarnaOrder->getBillingAddress('email'));
 
 
 
 
 
425
  }
426
- } catch(Exception $e) {
427
- $this->_getHelper()->logKlarnaException($e);
428
  }
 
429
 
430
- $this->_getHelper()->dispatchMethodEvent($order, Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_RESERVED, $order->getTotalDue(), $this->getMethod());
431
 
432
- Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => $order->getId()) );
 
 
 
 
 
 
 
 
433
 
434
- $this->_getHelper()->logDebugInfo('createOrder successfully created order with no: ' . $order->getIncrementId());
435
 
436
- $this->_api->updateKlarnaOrder($order);
 
 
 
 
 
437
 
438
  return $order;
439
  }
440
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
  public function getKlarnaCheckoutEnabled()
442
  {
443
  $remoteAddr = $this->_getCoreHttpHelper()->getRemoteAddr();
@@ -447,35 +710,38 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
447
  return false;
448
  }
449
 
450
- if ($this->_getCustomerHelper()->isLoggedIn() && !$this->getConfigData('allow_when_logged_in')) {
451
- return false;
452
- }
453
- $allowedCustomerGroups = $this->getConfigData('allow_customer_group');
454
- if (isset($allowedCustomerGroups)) {
455
- $allowedCustomerGroups = explode(',', $allowedCustomerGroups);
456
 
457
- if (!in_array(Vaimo_Klarna_Helper_Data::KLARNA_CHECKOUT_ALLOW_ALL_GROUP_ID, $allowedCustomerGroups)) {
458
- $customerGroupId = $this->_getCustomerSession()->getCustomerGroupId();
459
- if (!in_array($customerGroupId, $allowedCustomerGroups)) {
460
- return false;
 
 
 
 
 
 
 
 
461
  }
462
  }
463
- }
464
- if ($allowedIpRange = $this->getConfigData('allowed_ip_range')) {
465
- $ipParts = explode('.', $remoteAddr);
466
 
467
- if (is_array($ipParts) && count($ipParts) >= 4) {
468
- $lastDigit = intval($ipParts[3]);
469
- } else {
470
- $lastDigit = 0;
471
- }
472
 
473
- list ($allowIpFrom, $allowIpTo) = explode('-', $allowedIpRange, 2);
474
 
475
- if ($lastDigit >= (int)$allowIpFrom && $lastDigit <= (int)$allowIpTo) {
476
- return true;
477
- } else {
478
- return false;
 
479
  }
480
  }
481
 
@@ -551,5 +817,5 @@ class Vaimo_Klarna_Model_Klarnacheckout extends Vaimo_Klarna_Model_Klarnacheckou
551
  {
552
  return $this;
553
  }
554
-
555
  }
87
  } else {
88
  $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
89
  }
90
+ if ($this->getQuote()) {
91
+ $this->_api->initKlarnaOrder($checkoutId, $createIfNotExists, $updateItems, $this->getQuote()->getId());
92
+ } else {
93
+ $this->_api->initKlarnaOrder($checkoutId, $createIfNotExists, $updateItems);
94
+ }
95
  $res = $this->_api->getKlarnaCheckoutGui();
96
  $this->_getHelper()->logKlarnaApi('Call complete');
97
  return $res;
98
  }
99
+
100
  /**
101
  * When we call this function, order is already done and complete. We can then cache
102
  * the information we get from Klarna so when we call initKlarnaOrder again (from
103
  * phtml files) we can use the cached order instead of fetching it again.
104
+ *
105
  * @param string $checkoutId
106
+ *
107
  * @return string
108
  */
109
  public function getCheckoutStatus($checkoutId = null)
120
  $this->_getHelper()->logKlarnaApi('Call complete');
121
  return $res;
122
  }
123
+
124
  /*
125
  * Not happy with this, but I guess we can't solve it in other ways.
126
  *
129
  {
130
  return $this->_api->getActualKlarnaOrder();
131
  }
132
+
133
  /*
134
  * Will return the klarna order or null, if it doesn't find it
135
  * Not used by this module, but as a service for others.
147
  $this->_getHelper()->logKlarnaApi('Call complete');
148
  return $res;
149
  }
 
 
 
 
 
150
 
151
+ protected function _reduceParentItem($quote, $id, $qty)
152
+ {
153
+ foreach ($quote->getItemsCollection() as $item) {
154
+ if ($item->getId()==$id) {
155
+ $item->setQty($qty);
156
+ $item->save();
157
+ }
158
  }
159
+ }
160
 
161
+ protected function _checkItems($quote, $adjustFlag = false)
162
+ {
163
+ $res = NULL;
 
 
 
164
  $simpleQty = array();
165
  foreach ($quote->getItemsCollection() as $item) {
166
  if ($item->getProductType()=='simple') {
172
  $simpleQty[$item->getSku()] = $item->getQty();
173
  }
174
  if (!$stockItem->checkQty($simpleQty[$item->getSku()])) {
175
+ if (!$res) $res = array();
176
+ $res[] = $this->_getHelper()->__('The requested quantity for "%s" is not available.', $item->getName());
177
+ if ($adjustFlag) {
178
+ $qty = 0;
179
+ $item->setData('qty', $qty);
180
+ $item->save();
181
+ if ($item->getParentItemId()) {
182
+ $this->_reduceParentItem($quote, $item->getParentItemId(), $qty);
183
+ }
184
+ }
185
  }
186
  }
187
  }
188
  }
189
+ return $res;
190
+ }
191
+
192
+ public function validateQuote($checkoutId, $createOrderOnValidate = NULL, $createdKlarnaOrder = NULL)
193
+ {
194
+ $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOVALIDATE_ORDER);
195
+
196
+ /** @var Mage_Sales_Model_Quote $quote */
197
+ $quote = $this->getQuote();
198
+
199
+ if (!$quote->getId()) {
200
+ $this->_getHelper()->logDebugInfo('validateQuote could not get quote');
201
+ return $this->_getHelper()->__('could not get quote');
202
+ }
203
+
204
+ if (!$quote->hasItems()) {
205
+ $this->_getHelper()->logDebugInfo('validateQuote has no items');
206
+ return $this->_getHelper()->__('has no items');
207
+ }
208
+
209
+ $result = $this->_checkItems($quote);
210
+
211
+ if ($result) {
212
  return implode("\n", $result);
213
  }
214
 
228
 
229
  if (!$quote->validateMinimumAmount()) {
230
  $this->_getHelper()->logDebugInfo('validateQuote below minimum amount');
231
+ return $this->_getHelper()->__('minimum amount');
232
  }
233
 
234
+ $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
235
+ if ($orderId>0) {
236
+ $this->_getHelper()->logDebugInfo('validateQuote order already created ' . $orderId);
237
+ return $this->_getHelper()->__('order already created');
238
+ }
239
+
240
+ if ($createdKlarnaOrder) {
241
+ $noticeTextArr = $this->_checkQuote($quote, $createdKlarnaOrder);
242
+ if ($noticeTextArr!=NULL) {
243
+ $this->_getHelper()->logDebugInfo('validateQuote failed in checkQuote', $noticeTextArr);
244
+ return $this->_getHelper()->__('not matching cart');
245
+ }
246
+ }
247
+
248
+ if ($createOrderOnValidate && $createdKlarnaOrder) {
249
+ // As validation is ok, creating the order should work, if it doesn't, it's
250
+ // probably a temporary reason and we should reserve ID and await the push
251
+ $order = $this->_createValidateOrder($checkoutId, $quote, $createdKlarnaOrder);
252
+ if ($order && $order->getId()) {
253
+ $this->_getHelper()->logDebugInfo('validateQuote created order id: ' . $order->getId());
254
+ } else {
255
+ $this->_getHelper()->logDebugInfo('validateQuote failed to created order');
256
+ $quote->reserveOrderId()->save();
257
+ $this->_getHelper()->logDebugInfo('validateQuote reserved order id: ' . $quote->getReservedOrderId());
258
+ }
259
+ } else {
260
+ $quote->reserveOrderId()->save();
261
+ $this->_getHelper()->logDebugInfo('validateQuote reserved order id: ' . $quote->getReservedOrderId());
262
+ }
263
 
264
  return true;
265
  }
266
 
267
+ /**
268
+ * This function checks valid shippingMethod
269
+ *
270
+ * There must be a better way...
271
+ *
272
+ * @return $this
273
+ *
274
+ */
275
+ public function checkShippingMethod()
276
  {
277
+ // set shipping method
278
+ $res = NULL;
279
+ $quote = $this->getQuote();
280
+ $shippingAddress = $quote->getShippingAddress();
281
+ if (!$quote->isVirtual() && $shippingAddress && !$shippingAddress->getShippingMethod()) {
282
+ $quote->setRemoteIp($quote->getRemoteIp());
283
+ $taxCalculationModel = Mage::getSingleton('tax/calculation');
284
+ $request = $taxCalculationModel->getRateRequest(
285
+ $quote->getShippingAddress(),
286
+ $quote->getBillingAddress(),
287
+ NULL,
288
+ $quote->getStoreId()
289
+ );
290
+ $shippingAddress->setCountryId($request->getCountryId());
291
+ $shippingAddress->setRegionId($request->getRegionId());
292
+ $shippingAddress->setPostcode($request->getPostcode());
293
+ // Massive workaround... because Shipping Origin is per website, not store...
294
+ if (Mage::helper('klarna')->getDefaultCountry()!=$shippingAddress->getCountryId()) {
295
+ if (!$shippingAddress->getRegionId() && !$shippingAddress->getPostcode()) {
296
+ $shippingAddress->setCountryId(Mage::helper('klarna')->getDefaultCountry());
297
+ }
298
+ }
299
+ $shippingAddress->setCollectShippingRates(true);
300
+ $shippingAddress->collectTotals();
301
+ $shippingAddress->collectShippingRates();
302
+ $rates = $shippingAddress->getGroupedAllShippingRates();
303
+ foreach ($rates as $carrierRates) {
304
+ foreach ($carrierRates as $rate) {
305
+ $shippingAddress->setShippingMethod($rate->getCode());
306
+ $quote->setTotalsCollectedFlag(false);
307
+ break;
308
+ }
309
+ break;
310
+ }
311
+ $shippingAddress->save();
312
+ $res = $this->_getHelper()->__('Shipping method was not set on cart, setting default to allow the order');
313
+ }
314
+ if ($shippingAddress->getShippingMethod() && !$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())) {
315
+ $shippingAddress->setCollectShippingRates(true);
316
+ $shippingAddress->collectTotals();
317
+ $shippingAddress->collectShippingRates();
318
+ $shippingAddress->save();
319
+ if (!$res) {
320
+ $res = $this->_getHelper()->__('Shipping rate was not properly set, recalculating');
321
+ }
322
  }
323
+
324
+ return $res;
325
+ }
326
+
327
+
328
+ protected function _checkQuote($quote, $createdKlarnaOrder)
329
+ {
330
+ $res = NULL;
331
+
332
+ try {
333
+
334
+ $itemNotices = $this->_checkItems($quote, true);
335
+ $klarnaNotices = $this->_api->sanityTestQuote($createdKlarnaOrder, $quote);
336
+ $shippingNotice = $this->checkShippingMethod();
337
+
338
+ if ($itemNotices || $klarnaNotices || $shippingNotice) {
339
+ if (!$itemNotices) $itemNotices = array();
340
+ if (!$klarnaNotices) $klarnaNotices = array();
341
+ $res = array_merge($itemNotices, $klarnaNotices);
342
+ $res[] = $shippingNotice;
343
+ }
344
+
345
+ if ($res) {
346
+ $quote->collectTotals();
347
+ }
348
+
349
+ } catch(Exception $e) {
350
+ $res = $e->getMessage();
351
  }
352
+ if ($res) {
353
+ $this->_getHelper()->logDebugInfo('_checkQuote return', $res);
 
 
 
354
  }
355
+ return $res;
356
+ }
357
 
358
+ protected function _updateKlarnaOrderAddress($createdKlarnaOrder)
359
+ {
360
  $billingStreetAddress = $createdKlarnaOrder->getBillingAddress('street_address');
361
  $billingStreetAddress2 = $createdKlarnaOrder->getBillingAddress('street_address2');
362
  $billingStreetName = $createdKlarnaOrder->getBillingAddress('street_name');
363
  $billingStreetNumber = $createdKlarnaOrder->getBillingAddress('street_number');
 
364
  $shippingStreetAddress = $createdKlarnaOrder->getShippingAddress('street_address');
365
  $shippingStreetAddress2 = $createdKlarnaOrder->getShippingAddress('street_address2');
366
  $shippingStreetName = $createdKlarnaOrder->getShippingAddress('street_name');
367
  $shippingStreetNumber = $createdKlarnaOrder->getShippingAddress('street_number');
 
368
 
369
  if (!$billingStreetAddress && $billingStreetName && $billingStreetNumber) {
370
  $streetAddress = $createdKlarnaOrder->getBillingAddress();
388
  $createdKlarnaOrder->setShippingAddress($streetAddress);
389
  }
390
 
391
+ }
 
 
 
392
 
393
+ protected function _createTheOrder($quote, $createdKlarnaOrder, $updatef, $pushf, $noticeTextArr = NULL)
394
+ {
395
+ $autoRegisterGuest = $this->getConfigData('auto_register_guest');
396
+ $isAllowedGuestCheckout = Mage::helper('checkout')->isAllowedGuestCheckout($quote);
 
 
 
 
 
 
 
397
 
398
+ if ($updatef==false) {
399
+ $isNewCustomer = false;
400
+
401
+ $billingRegionCode = $createdKlarnaOrder->getBillingAddress('region');
402
+ $shippingRegionCode = $createdKlarnaOrder->getShippingAddress('region');
403
+
404
+ if ($quote->getCustomerId()) {
405
+ $customer = $this->_loadCustomer($quote->getCustomerId());
406
  $quote->setCustomer($customer);
407
  $quote->setCheckoutMethod('customer');
408
  } else {
409
+ /** @var $customer Mage_Customer_Model_Customer */
410
+ $customer = $this->_loadCustomerByEmail($createdKlarnaOrder->getBillingAddress('email'), $quote->getStore());
411
+ if ($customer->getId()) {
412
+ $quote->setCustomer($customer);
413
+ $quote->setCheckoutMethod('customer');
414
+ } elseif ($autoRegisterGuest || !$isAllowedGuestCheckout) {
415
+ $quote->setCheckoutMethod('register');
416
+ $isNewCustomer = true;
417
+ } else {
418
+ $quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST);
419
+ }
420
  }
 
421
 
422
+ $billingAddress = $quote->getBillingAddress();
423
+ $customerAddressId = 0;
424
 
425
+ if ($customerAddressId) {
426
+ $customerAddress = $this->_loadCustomerAddress($customerAddressId);
427
+ if ($customerAddress->getId()) {
428
+ if ($customerAddress->getCustomerId() != $this->getQuote()->getCustomerId()) {
429
+ throw new Exception('Customer Address is not valid');
430
+ }
431
 
432
+ $billingAddress->importCustomerAddress($customerAddress)->setSaveInAddressBook(0);
433
+ }
434
+ } else {
435
+ $billingAddress->setFirstname($createdKlarnaOrder->getBillingAddress('given_name'));
436
+ $billingAddress->setLastname($createdKlarnaOrder->getBillingAddress('family_name'));
437
+ $billingAddress->setCareOf($createdKlarnaOrder->getBillingAddress('care_of'));
438
+ $billingAddress->setStreet($createdKlarnaOrder->getBillingAddress('street_address'));
439
+ $billingAddress->setPostcode($createdKlarnaOrder->getBillingAddress('postal_code'));
440
+ $billingAddress->setCity($createdKlarnaOrder->getBillingAddress('city'));
441
+ $billingAddress->setCountryId(strtoupper($createdKlarnaOrder->getBillingAddress('country')));
442
+ $billingAddress->setEmail($createdKlarnaOrder->getBillingAddress('email'));
443
+ $billingAddress->setTelephone($createdKlarnaOrder->getBillingAddress('phone'));
444
+ $billingAddress->setSaveInAddressBook(1);
445
+ if ($billingRegionCode) {
446
+ $billingRegionId = Mage::getModel('directory/region')->loadByCode($billingRegionCode, $billingAddress->getCountryId());
447
+ $billingAddress->setRegionId($billingRegionId->getId());
448
+ }
449
  }
 
450
 
451
+ // $this->_validateCustomerData($data);
452
+
453
+ $shippingAddress = $quote->getShippingAddress();
454
+ $shippingAddress->setFirstname($createdKlarnaOrder->getShippingAddress('given_name'));
455
+ $shippingAddress->setLastname($createdKlarnaOrder->getShippingAddress('family_name'));
456
+ $shippingAddress->setCareOf($createdKlarnaOrder->getShippingAddress('care_of'));
457
+ $shippingAddress->setStreet($createdKlarnaOrder->getShippingAddress('street_address'));
458
+ $shippingAddress->setPostcode($createdKlarnaOrder->getShippingAddress('postal_code'));
459
+ $shippingAddress->setCity($createdKlarnaOrder->getShippingAddress('city'));
460
+ $shippingAddress->setCountryId(strtoupper($createdKlarnaOrder->getShippingAddress('country')));
461
+ $shippingAddress->setEmail($createdKlarnaOrder->getShippingAddress('email'));
462
+ $shippingAddress->setTelephone($createdKlarnaOrder->getShippingAddress('phone'));
463
+ if ($shippingRegionCode) {
464
+ $shippingRegionId = Mage::getModel('directory/region')->loadByCode($shippingRegionCode, $shippingAddress->getCountryId());
465
+ $shippingAddress->setRegionId($shippingRegionId->getId());
466
+ }
467
 
468
+ if ($this->getConfigData('packstation_enabled')) {
469
+ $shippingAddress->setSameAsBilling(0);
470
+ } else {
471
+ $shippingAddress->setSameAsBilling(1);
472
+ }
473
+ $shippingAddress->setSaveInAddressBook(0);
474
+
475
+ $quote->getBillingAddress()->setShouldIgnoreValidation(true);
476
+ $quote->getShippingAddress()->setShouldIgnoreValidation(true);
477
+
478
+ switch ($quote->getCheckoutMethod()) {
479
+ case Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST:
480
+ $this->_prepareGuestCustomerQuote($quote);
481
+ $quote->setCustomerIsGuest(1);
482
+ $quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
483
+ break;
484
+ case 'register':
485
+ $this->_prepareNewCustomerQuote($quote);
486
+ break;
487
+ case 'login_in':
488
+ case 'customer':
489
+ $this->_prepareCustomerQuote($quote);
490
+ break;
491
+ }
492
 
493
+ $quote->setTotalsCollectedFlag(false);
494
+ $quote->collectTotals();
495
+ $quote->save();
496
 
497
+ Mage::dispatchEvent('klarnacheckout_quote_before_create_order', array(
498
+ 'quote' => $quote,
499
+ 'klarna_order' => $createdKlarnaOrder,
500
+ 'is_push' => $pushf
501
+ ));
502
 
503
+ $service = $this->_getServiceQuote($quote);
504
+ $service->submitAll();
 
 
 
 
 
 
505
 
506
+ if ($isNewCustomer) {
507
+ try {
508
+ $this->_involveNewCustomer($quote);
509
+ } catch (Exception $e) {
510
+ $this->_getHelper()->logKlarnaException($e);
511
+ }
 
 
512
  }
 
513
 
514
+ $quote->save();
515
+ }
516
 
517
  $reservation = $createdKlarnaOrder->getReservation();
518
  if ($createdKlarnaOrder->getOrderId()) {
522
  // Update Order
523
  /** @var $order Mage_Sales_Model_Order */
524
  $order = $this->_loadOrderByKey($quote->getId());
525
+
526
+ if ($pushf) {
527
+ if ($order->getState()==Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
528
+ $order->setState(
529
+ Mage_Sales_Model_Order::STATE_NEW,
530
+ $this->getConfigData('order_status'),
531
+ $this->_getHelper()->__('Confirmation received')
532
+ );
533
+ $order->save();
534
+ }
535
+ }
536
+
537
  $payment = $order->getPayment();
538
 
539
  if ($createdKlarnaOrder->getReference()) {
552
  $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_HOST, $this->getConfigData("host") );
553
  $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_MERCHANT_ID, $this->getConfigData("merchant_id") );
554
 
555
+ if ($noticeTextArr) {
556
+ $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_NOTICE, $noticeTextArr );
557
+ }
558
 
559
+ if ($pushf) {
560
+ $payment->setTransactionId($reservation)
561
+ ->setIsTransactionClosed(0)
562
+ ->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED);
563
+ if ($transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)) {
564
+ $transaction->save();
565
+ }
566
  }
567
  $payment->save();
568
 
569
+ if ($pushf) {
570
+ // send new order email
571
+ if ($order->getCanSendNewEmailFlag()) {
572
+ try {
573
+ $order->sendNewOrderEmail();
574
+ } catch (Exception $e) {
575
+ $this->_getHelper()->logKlarnaException($e);
576
+ }
577
+ }
578
+
579
+ // Subscribe customer to newsletter
580
  try {
581
+ if ($quote->getKlarnaCheckoutNewsletter()) {
582
+ $this->_addToSubscription($createdKlarnaOrder->getBillingAddress('email'));
583
+ }
584
+ } catch(Exception $e) {
585
  $this->_getHelper()->logKlarnaException($e);
586
  }
 
587
 
588
+ try {
589
+ $this->_getHelper()->dispatchMethodEvent($order, Vaimo_Klarna_Helper_Data::KLARNA_DISPATCH_RESERVED, $order->getTotalDue(), $this->getMethod());
590
+
591
+ Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($order->getId())) );
592
+
593
+ $this->_getHelper()->logDebugInfo('successfully created order with no: ' . $order->getIncrementId());
594
+
595
+ } catch(Exception $e) {
596
+ $this->_getHelper()->logKlarnaException($e);
597
  }
 
 
598
  }
599
+ return $order;
600
 
601
+ }
602
 
603
+ protected function _createValidateOrder($checkoutId, $quote, $createdKlarnaOrder)
604
+ {
605
+ if ($checkoutId) {
606
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID ' . $checkoutId);
607
+ } else {
608
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
609
+ }
610
+
611
+ $this->_updateKlarnaOrderAddress($createdKlarnaOrder);
612
 
613
+ $order = $this->_createTheOrder($quote, $createdKlarnaOrder, false, false);
614
 
615
+ $order->setState(
616
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
617
+ true,
618
+ $this->_getHelper()->__('Order created during validation, waiting for confirmation')
619
+ );
620
+ $order->save();
621
 
622
  return $order;
623
  }
624
+
625
+ public function createOrder($checkoutId = NULL)
626
+ {
627
+ $this->_init(Vaimo_Klarna_Helper_Data::KLARNA_API_CALL_KCOCREATE_ORDER);
628
+ if ($checkoutId) {
629
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID ' . $checkoutId);
630
+ } else {
631
+ $this->_getHelper()->logKlarnaApi('Call with checkout ID NULL');
632
+ }
633
+ $createdKlarnaOrder = $this->_api->fetchCreatedOrder($checkoutId);
634
+ if (!$createdKlarnaOrder) {
635
+ $this->_getHelper()->logDebugInfo('createOrder could not fetch createdKlarnaOrder');
636
+ return array(
637
+ 'status' => 'retry',
638
+ 'message' => 'could not fetch createdKlarnaOrder'
639
+ );
640
+ }
641
+
642
+ $quote = $this->getQuote();
643
+ if ($quote == null) {
644
+ $quote = $this->_api->loadQuote();
645
+ if (!$quote) {
646
+ $this->_getHelper()->logDebugInfo('createOrder could not get quote');
647
+ return array(
648
+ 'status' => 'fail',
649
+ 'message' => 'could not get quote'
650
+ );
651
+ }
652
+ $this->setQuote($quote);
653
+ }
654
+
655
+ $noticeTextArr = $this->_checkQuote($quote, $createdKlarnaOrder);
656
+
657
+ $this->_updateKlarnaOrderAddress($createdKlarnaOrder);
658
+
659
+ if ($createdKlarnaOrder->getStatus() != 'checkout_complete' && $createdKlarnaOrder->getStatus() != 'created') {
660
+ $this->_getHelper()->logDebugInfo('createOrder status not complete');
661
+ return array(
662
+ 'status' => 'retry',
663
+ 'message' => 'status not complete'
664
+ );
665
+ }
666
+
667
+ $updatef = false;
668
+ $orderId = $this->_findAlreadyCreatedOrder($quote->getId());
669
+ if ($orderId>0) {
670
+ $this->_getHelper()->logDebugInfo('createOrder order already created ' . $orderId);
671
+ if (($createdKlarnaOrder->getStatus() == 'checkout_complete') || ($createdKlarnaOrder->getStatus() == 'created')) {
672
+ $order = $this->_loadOrderByKey($quote->getId());
673
+ $updatef = true;
674
+ }
675
+ /*
676
+ return array(
677
+ 'status' => 'fail',
678
+ 'message' => 'order already created'
679
+ );
680
+ */
681
+ }
682
+
683
+ $order = $this->_createTheOrder($quote, $createdKlarnaOrder, $updatef, true, $noticeTextArr);
684
+
685
+ try {
686
+ $this->_api->updateKlarnaOrder($order);
687
+
688
+ if ($noticeTextArr) {
689
+ if ($order->canHold()) {
690
+ $order->hold();
691
+ $order->save();
692
+ }
693
+ }
694
+ } catch(Exception $e) {
695
+ $this->_getHelper()->logKlarnaException($e);
696
+ }
697
+
698
+ return array(
699
+ 'status' => 'success',
700
+ 'order' => $order
701
+ );
702
+ }
703
+
704
  public function getKlarnaCheckoutEnabled()
705
  {
706
  $remoteAddr = $this->_getCoreHttpHelper()->getRemoteAddr();
710
  return false;
711
  }
712
 
713
+ if (!$this->getConfigData('activate_ab_testing')) {
 
 
 
 
 
714
 
715
+ if ($this->_getCustomerHelper()->isLoggedIn() && !$this->getConfigData('allow_when_logged_in')) {
716
+ return false;
717
+ }
718
+ $allowedCustomerGroups = $this->getConfigData('allow_customer_group');
719
+ if (isset($allowedCustomerGroups)) {
720
+ $allowedCustomerGroups = explode(',', $allowedCustomerGroups);
721
+
722
+ if (!in_array(Vaimo_Klarna_Helper_Data::KLARNA_CHECKOUT_ALLOW_ALL_GROUP_ID, $allowedCustomerGroups)) {
723
+ $customerGroupId = $this->_getCustomerSession()->getCustomerGroupId();
724
+ if (!in_array($customerGroupId, $allowedCustomerGroups)) {
725
+ return false;
726
+ }
727
  }
728
  }
729
+ if ($allowedIpRange = $this->getConfigData('allowed_ip_range')) {
730
+ $ipParts = explode('.', $remoteAddr);
 
731
 
732
+ if (is_array($ipParts) && count($ipParts) >= 4) {
733
+ $lastDigit = intval($ipParts[3]);
734
+ } else {
735
+ $lastDigit = 0;
736
+ }
737
 
738
+ list ($allowIpFrom, $allowIpTo) = explode('-', $allowedIpRange, 2);
739
 
740
+ if ($lastDigit >= (int)$allowIpFrom && $lastDigit <= (int)$allowIpTo) {
741
+ return true;
742
+ } else {
743
+ return false;
744
+ }
745
  }
746
  }
747
 
817
  {
818
  return $this;
819
  }
820
+
821
  }
app/code/community/Vaimo/Klarna/Model/Klarnacheckout/Abstract.php CHANGED
@@ -107,6 +107,34 @@ abstract class Vaimo_Klarna_Model_Klarnacheckout_Abstract extends Vaimo_Klarna_M
107
  Mage::getModel('newsletter/subscriber')->subscribe($email);
108
  }
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  protected function _prepareNewCustomerQuote(Mage_Sales_Model_Quote $quote)
111
  {
112
  $billing = $quote->getBillingAddress();
107
  Mage::getModel('newsletter/subscriber')->subscribe($email);
108
  }
109
 
110
+ protected function _prepareGuestCustomerQuote(Mage_Sales_Model_Quote $quote)
111
+ {
112
+ $billing = $quote->getBillingAddress();
113
+ $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
114
+
115
+ /** @var $customer Mage_Customer_Model_Customer */
116
+ $customer = $quote->getCustomer();
117
+ $customerBilling = $billing->exportCustomerAddress();
118
+ $customer->addAddress($customerBilling);
119
+ $billing->setCustomerAddress($customerBilling);
120
+ $customerBilling->setIsDefaultBilling(true);
121
+
122
+ if ($shipping && !$shipping->getSameAsBilling()) {
123
+ $customerShipping = $shipping->exportCustomerAddress();
124
+ $customer->addAddress($customerShipping);
125
+ $shipping->setCustomerAddress($customerShipping);
126
+ $customerShipping->setIsDefaultShipping(true);
127
+ } else {
128
+ $customerBilling->setIsDefaultShipping(true);
129
+ }
130
+
131
+ $customer->setFirstname($customerBilling->getFirstname());
132
+ $customer->setLastname($customerBilling->getLastname());
133
+ $customer->setEmail($customerBilling->getEmail());
134
+
135
+ $quote->setCustomer($customer);
136
+ }
137
+
138
  protected function _prepareNewCustomerQuote(Mage_Sales_Model_Quote $quote)
139
  {
140
  $billing = $quote->getBillingAddress();
app/code/community/Vaimo/Klarna/Model/Observer.php CHANGED
@@ -126,6 +126,13 @@ class Vaimo_Klarna_Model_Observer extends Mage_Core_Model_Abstract
126
  $order->setStatus($klarna->getConfigData('order_status'));
127
  }
128
  }
 
 
 
 
 
 
 
129
  }
130
  }
131
 
@@ -160,11 +167,13 @@ class Vaimo_Klarna_Model_Observer extends Mage_Core_Model_Abstract
160
  $klarna = Mage::getModel('klarna/klarnacheckout');
161
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
162
  if ($klarna->getKlarnaCheckoutEnabled()) {
163
- $controllerAction = $observer->getControllerAction();
164
- $controllerAction->getResponse()
165
- ->setRedirect(Mage::getUrl('checkout/klarna'))
166
- ->sendResponse();
167
- exit;
 
 
168
  }
169
  }
170
  }
@@ -198,7 +207,7 @@ class Vaimo_Klarna_Model_Observer extends Mage_Core_Model_Abstract
198
  $clearFlag = false;
199
  }
200
  if ($clearFlag) {
201
- Mage::helper('klarna')->logKlarnaDebug('checkDisableUseOtherMethods clearFlag is true. class = ' . $class . ' and action = ' . $action);
202
  $this->_getSession()->setKlarnaUseOtherMethods(false);
203
  $payment = $quote->getPayment();
204
  $payment->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
126
  $order->setStatus($klarna->getConfigData('order_status'));
127
  }
128
  }
129
+ if ($orderOriginal->getState()==Mage_Sales_Model_Order::STATE_HOLDED) {
130
+ if ($order->getState()==Mage_Sales_Model_Order::STATE_NEW) {
131
+ $klarna = Mage::getModel('klarna/klarna');
132
+ $klarna->setOrder($order);
133
+ $order->setStatus($klarna->getConfigData('order_status'));
134
+ }
135
+ }
136
  }
137
  }
138
 
167
  $klarna = Mage::getModel('klarna/klarnacheckout');
168
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
169
  if ($klarna->getKlarnaCheckoutEnabled()) {
170
+ if (!$klarna->getConfigData('explicit_usage')) {
171
+ $controllerAction = $observer->getControllerAction();
172
+ $controllerAction->getResponse()
173
+ ->setRedirect(Mage::getUrl('checkout/klarna'))
174
+ ->sendResponse();
175
+ exit;
176
+ }
177
  }
178
  }
179
  }
207
  $clearFlag = false;
208
  }
209
  if ($clearFlag) {
210
+ Mage::helper('klarna')->logDebugInfo('checkDisableUseOtherMethods clearFlag is true. class = ' . $class . ' and action = ' . $action);
211
  $this->_getSession()->setKlarnaUseOtherMethods(false);
212
  $payment = $quote->getPayment();
213
  $payment->setMethod(Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
app/code/community/Vaimo/Klarna/Model/Payment/Abstract.php CHANGED
@@ -139,7 +139,8 @@ class Vaimo_Klarna_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abst
139
  $presetTitle = $serviceMethod['group']['title'];
140
  if ($serviceMethod['vaimo_klarna_method']==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_INVOICE ||
141
  $serviceMethod['vaimo_klarna_method']==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_SPECIAL) {
142
- $presetTitle .= ' ' . $serviceMethod['title'];
 
143
  }
144
  break;
145
  }
@@ -287,7 +288,9 @@ class Vaimo_Klarna_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abst
287
 
288
  // We cannot perform basic tests with OneStepCheckout because they try
289
  // to save the payment method as soon as the customer views the checkout
290
- if ($this->_getHelper()->isOneStepCheckout()) {
 
 
291
  return $this;
292
  }
293
 
@@ -315,7 +318,9 @@ class Vaimo_Klarna_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abst
315
  * we do them here instead
316
  */
317
  $klarna = $this->_getKlarnaModel();
318
- if ($this->_getHelper()->isOneStepCheckout()) {
 
 
319
  $klarna->setInfoInstance($this->getInfoInstance());
320
  $klarna->setPayment($payment);
321
  $klarna->doBasicTests();
@@ -325,7 +330,11 @@ class Vaimo_Klarna_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abst
325
  $klarna->setPayment($payment);
326
  $klarna->updateAuthorizeAddress();
327
 
328
- if ($this->_getHelper()->isOneStepCheckout() && $klarna->shippingSameAsBilling()) {
 
 
 
 
329
  $klarna->updateBillingAddress();
330
  }
331
 
139
  $presetTitle = $serviceMethod['group']['title'];
140
  if ($serviceMethod['vaimo_klarna_method']==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_INVOICE ||
141
  $serviceMethod['vaimo_klarna_method']==Vaimo_Klarna_Helper_Data::KLARNA_METHOD_SPECIAL) {
142
+ $presetTitle = $serviceMethod['title'];
143
+ // $presetTitle .= ' ' . $serviceMethod['title'];
144
  }
145
  break;
146
  }
288
 
289
  // We cannot perform basic tests with OneStepCheckout because they try
290
  // to save the payment method as soon as the customer views the checkout
291
+ if ($this->_getHelper()->isOneStepCheckout() ||
292
+ $this->_getHelper()->isVaimoCheckout() ||
293
+ $this->_getHelper()->isFireCheckout()) {
294
  return $this;
295
  }
296
 
318
  * we do them here instead
319
  */
320
  $klarna = $this->_getKlarnaModel();
321
+ if ($this->_getHelper()->isOneStepCheckout() ||
322
+ $this->_getHelper()->isVaimoCheckout() ||
323
+ $this->_getHelper()->isFireCheckout()) {
324
  $klarna->setInfoInstance($this->getInfoInstance());
325
  $klarna->setPayment($payment);
326
  $klarna->doBasicTests();
330
  $klarna->setPayment($payment);
331
  $klarna->updateAuthorizeAddress();
332
 
333
+ if (($this->_getHelper()->isOneStepCheckout() ||
334
+ $this->_getHelper()->isVaimoCheckout() ||
335
+ $this->_getHelper()->isFireCheckout()
336
+ ) &&
337
+ $klarna->shippingSameAsBilling()) {
338
  $klarna->updateBillingAddress();
339
  }
340
 
app/code/community/Vaimo/Klarna/Model/Pushqueue.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2009-2014 Vaimo AB
4
+ *
5
+ * Vaimo reserves all rights in the Program as delivered. The Program
6
+ * or any portion thereof may not be reproduced in any form whatsoever without
7
+ * the written consent of Vaimo, except as provided by licence. A licence
8
+ * under Vaimo's rights in the Program may be available directly from
9
+ * Vaimo.
10
+ *
11
+ * Disclaimer:
12
+ * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF.
13
+ * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS
19
+ * IN THE PROGRAM.
20
+ *
21
+ * @category Vaimo
22
+ * @package Vaimo_Klarna
23
+ * @copyright Copyright (c) 2009-2014 Vaimo AB
24
+ */
25
+
26
+ class Vaimo_Klarna_Model_Pushqueue extends Mage_Core_Model_Abstract
27
+ {
28
+ protected function _construct()
29
+ {
30
+ parent::_construct();
31
+ $this->_init('klarna/pushqueue');
32
+ }
33
+
34
+ /**
35
+ * Register queue creation date
36
+ *
37
+ * @return Mage_Core_Model_Abstract|void
38
+ */
39
+ protected function _beforeSave()
40
+ {
41
+ parent::_beforeSave();
42
+
43
+ if (!$this->getCreatedAt()) {
44
+ $this->setCreatedAt(Mage::getSingleton('core/date')->gmtDate());
45
+ }
46
+ }
47
+
48
+ public function loadByKlarnaOrderNumber($klarnaOrderNumber)
49
+ {
50
+ $this->_getResource()->loadByKlarnaOrderNumber($this, $klarnaOrderNumber);
51
+ return $this;
52
+ }
53
+
54
+ }
app/code/community/Vaimo/Klarna/Model/Resource/Pushqueue.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2009-2014 Vaimo AB
4
+ *
5
+ * Vaimo reserves all rights in the Program as delivered. The Program
6
+ * or any portion thereof may not be reproduced in any form whatsoever without
7
+ * the written consent of Vaimo, except as provided by licence. A licence
8
+ * under Vaimo's rights in the Program may be available directly from
9
+ * Vaimo.
10
+ *
11
+ * Disclaimer:
12
+ * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF.
13
+ * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS
19
+ * IN THE PROGRAM.
20
+ *
21
+ * @category Vaimo
22
+ * @package Vaimo_Klarna
23
+ * @copyright Copyright (c) 2009-2014 Vaimo AB
24
+ */
25
+
26
+ class Vaimo_Klarna_Model_Resource_Pushqueue extends Mage_Core_Model_Resource_Db_Abstract
27
+ {
28
+ protected function _construct()
29
+ {
30
+ $this->_init('klarna/pushqueue', 'id');
31
+ }
32
+
33
+ public function loadByKlarnaOrderNumber(Vaimo_Klarna_Model_Pushqueue $pushqueue, $klarnaOrderNumber)
34
+ {
35
+ $adapter = $this->_getReadAdapter();
36
+ $pushqueueTable = $this->getTable('klarna/pushqueue');
37
+ $bind = array('klarna_order_number' => $klarnaOrderNumber);
38
+ $select = $adapter->select()
39
+ ->from($pushqueueTable)
40
+ ->where('klarna_order_number = :klarna_order_number');
41
+
42
+ $pushQueueId = $adapter->fetchOne($select, $bind);
43
+ if ($pushQueueId) {
44
+ $this->load($pushqueue, $pushQueueId);
45
+ } else {
46
+ $pushqueue->setData(array());
47
+ }
48
+
49
+ return $this;
50
+ }
51
+
52
+ }
app/code/community/Vaimo/Klarna/Model/Resource/Pushqueue/Collection.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2009-2014 Vaimo AB
4
+ *
5
+ * Vaimo reserves all rights in the Program as delivered. The Program
6
+ * or any portion thereof may not be reproduced in any form whatsoever without
7
+ * the written consent of Vaimo, except as provided by licence. A licence
8
+ * under Vaimo's rights in the Program may be available directly from
9
+ * Vaimo.
10
+ *
11
+ * Disclaimer:
12
+ * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF.
13
+ * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS
19
+ * IN THE PROGRAM.
20
+ *
21
+ * @category Vaimo
22
+ * @package Vaimo_Klarna
23
+ * @copyright Copyright (c) 2009-2014 Vaimo AB
24
+ */
25
+
26
+ class Vaimo_Klarna_Model_Resource_Pushqueue_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
27
+ {
28
+ protected function _construct()
29
+ {
30
+ parent::_construct();
31
+ $this->_init('klarna/pushqueue');
32
+ }
33
+
34
+ /**
35
+ * Apply retry filter
36
+ *
37
+ * @return Vaimo_Klarna_Model_Resource_Pushqueue_Collection
38
+ */
39
+ public function applyRetryFilter($maxCnt)
40
+ {
41
+ $this->getSelect()->where('retry_attempts < ?', $maxCnt);
42
+ return $this;
43
+ }
44
+
45
+ }
app/code/community/Vaimo/Klarna/Model/Source/Apiversion.php CHANGED
@@ -36,7 +36,7 @@ class Vaimo_Klarna_Model_Source_Apiversion extends Vaimo_Klarna_Model_Source_Abs
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
 
@@ -50,7 +50,7 @@ class Vaimo_Klarna_Model_Source_Apiversion extends Vaimo_Klarna_Model_Source_Abs
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
  }
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 (US)')),
40
  );
41
  }
42
 
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 (US)'),
54
  );
55
  }
56
  }
app/code/community/Vaimo/Klarna/Model/Transport/Abstract.php CHANGED
@@ -974,7 +974,7 @@ abstract class Vaimo_Klarna_Model_Transport_Abstract extends Varien_Object
974
  try {
975
  if (!$this->getConfigData('active')) {
976
  if ($this->getMethod()!=Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT) {
977
- Mage::throwException($this->_getHelper()->__('Current payment method not available'));
978
  }
979
  }
980
  $res = new Varien_Object(
974
  try {
975
  if (!$this->getConfigData('active')) {
976
  if ($this->getMethod()!=Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT) {
977
+ // throw new Exception($this->_getHelper()->__('Current payment method not available'));
978
  }
979
  }
980
  $res = new Varien_Object(
app/code/community/Vaimo/Klarna/controllers/AddressController.php CHANGED
@@ -46,7 +46,7 @@ class Vaimo_Klarna_AddressController extends Mage_Core_Controller_Front_Action
46
  $request = $this->getRequest();
47
  $pno = $request->getParam('pno');
48
  if (!$pno) {
49
- Mage::throwException(Mage::helper('klarna')->__('Please enter your personal ID and try again'));
50
  }
51
  $method = $request->getParam('method');
52
  $klarna = Mage::getModel('klarna/klarna');
@@ -58,7 +58,7 @@ class Vaimo_Klarna_AddressController extends Mage_Core_Controller_Front_Action
58
  $block->setAddresses($addresses);
59
  $block->setMethodCode($method);
60
  $result['html'] = $block->toHtml();
61
- } catch (Mage_Core_Exception $e) {
62
  $result['error'] = true;
63
  $result['message'] = $e->getMessage();
64
  }
46
  $request = $this->getRequest();
47
  $pno = $request->getParam('pno');
48
  if (!$pno) {
49
+ throw new Exception(Mage::helper('klarna')->__('Please enter your personal ID and try again'));
50
  }
51
  $method = $request->getParam('method');
52
  $klarna = Mage::getModel('klarna/klarna');
58
  $block->setAddresses($addresses);
59
  $block->setMethodCode($method);
60
  $result['html'] = $block->toHtml();
61
+ } catch (Exception $e) {
62
  $result['error'] = true;
63
  $result['message'] = $e->getMessage();
64
  }
app/code/community/Vaimo/Klarna/controllers/Adminhtml/Klarna/MassactionController.php CHANGED
@@ -25,6 +25,12 @@
25
 
26
  class Vaimo_Klarna_Adminhtml_Klarna_MassactionController extends Mage_Adminhtml_Controller_Action
27
  {
 
 
 
 
 
 
28
  /**
29
  * @param Mage_Sales_Model_Order $order
30
  * @return array
25
 
26
  class Vaimo_Klarna_Adminhtml_Klarna_MassactionController extends Mage_Adminhtml_Controller_Action
27
  {
28
+
29
+ protected function _isAllowed()
30
+ {
31
+ return true;
32
+ }
33
+
34
  /**
35
  * @param Mage_Sales_Model_Order $order
36
  * @return array
app/code/community/Vaimo/Klarna/controllers/Adminhtml/Klarna/PclassController.php CHANGED
@@ -25,6 +25,11 @@
25
 
26
  class Vaimo_Klarna_Adminhtml_Klarna_PclassController extends Mage_Adminhtml_Controller_Action
27
  {
 
 
 
 
 
28
  public function dispatchAction()
29
  {
30
  }
25
 
26
  class Vaimo_Klarna_Adminhtml_Klarna_PclassController extends Mage_Adminhtml_Controller_Action
27
  {
28
+ protected function _isAllowed()
29
+ {
30
+ return true;
31
+ }
32
+
33
  public function dispatchAction()
34
  {
35
  }
app/code/community/Vaimo/Klarna/controllers/Checkout/KlarnaController.php CHANGED
@@ -75,44 +75,21 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
75
  return $this;
76
  }
77
 
 
 
 
 
 
 
 
 
78
  protected function _checkShippingMethod()
79
  {
80
  // set shipping method
81
  $quote = $this->_getQuote();
82
- $shippingAddress = $quote->getShippingAddress();
83
- if (!$quote->isVirtual() && $shippingAddress && !$shippingAddress->getShippingMethod()) {
84
- $quote->setRemoteIp($quote->getRemoteIp());
85
- $taxCalculationModel = Mage::getSingleton('tax/calculation');
86
- $request = $taxCalculationModel->getRateRequest(
87
- $quote->getShippingAddress(),
88
- $quote->getBillingAddress(),
89
- NULL,
90
- $quote->getStoreId()
91
- );
92
- $shippingAddress->setCountryId($request->getCountryId());
93
- $shippingAddress->setRegionId($request->getRegionId());
94
- $shippingAddress->setPostcode($request->getPostcode());
95
- // Massive workaround... because Shipping Origin is per website, not store...
96
- if (Mage::helper('klarna')->getDefaultCountry()!=$shippingAddress->getCountryId()) {
97
- if (!$shippingAddress->getRegionId() && !$shippingAddress->getPostcode()) {
98
- $shippingAddress->setCountryId(Mage::helper('klarna')->getDefaultCountry());
99
- }
100
- }
101
- $shippingAddress->setCollectShippingRates(true);
102
- $shippingAddress->collectTotals();
103
- $shippingAddress->collectShippingRates();
104
- $rates = $shippingAddress->getGroupedAllShippingRates();
105
- foreach ($rates as $carrierRates) {
106
- foreach ($carrierRates as $rate) {
107
- $shippingAddress->setShippingMethod($rate->getCode());
108
- $quote->setTotalsCollectedFlag(false);
109
- break;
110
- }
111
- break;
112
- }
113
- }
114
-
115
- return $this;
116
  }
117
 
118
  protected function _checkNewsletter()
@@ -148,11 +125,22 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
148
  $quote->collectTotals();
149
  $quote->save();
150
  $this->_getSession()->setKlarnaUseOtherMethods(false);
 
 
151
  if (Mage::helper('klarna')->isOneStepCheckout()) {
152
  $this->_redirect('onestepcheckout');
153
  } else {
154
  $this->_redirect('checkout/onepage');
155
  }
 
 
 
 
 
 
 
 
 
156
  }
157
 
158
  public function indexAction()
@@ -169,10 +157,8 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
169
  return;
170
  }
171
 
172
- $quote = $this->_getQuote();
173
-
174
  if (!$quote->hasItems() || $quote->getHasError()) {
175
- $this->_redirect('checkout/cart');
176
  return;
177
  }
178
 
@@ -182,7 +168,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
182
  Mage::helper('checkout')->__('Subtotal must exceed minimum order amount');
183
 
184
  $this->_getSession()->addError($error);
185
- $this->_redirect('checkout/cart');
186
  return;
187
  }
188
 
@@ -271,7 +257,8 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
271
  $checkoutId = $this->getRequest()->getParam('klarna_order');
272
  Mage::helper('klarna')->logKlarnaApi('taxshippingupdate callback received for ID ' . $checkoutId);
273
 
274
- $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
 
275
  $klarna = Mage::getModel('klarna/klarnacheckout');
276
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
277
 
@@ -283,7 +270,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
283
 
284
  Mage::helper('klarna')->logDebugInfo('taxshippingupdate response', $result);
285
  $this->getResponse()->setBody(Zend_Json::encode($result));
286
-
287
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
288
  }
289
 
@@ -292,7 +279,8 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
292
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
293
 
294
  $checkoutId = $this->getRequest()->getParam('klarna_order');
295
- $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
 
296
  $payment = $quote->getPayment();
297
  $errors = $payment->getAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_VALIDATE_ERRORS);
298
  Mage::helper('klarna')->logKlarnaApi('failedAction errors: ' . $errors);
@@ -304,70 +292,142 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
304
 
305
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
306
 
307
- $this->_redirect('checkout/cart');
308
  return;
309
  }
310
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  public function validateAction()
312
  {
313
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
314
 
315
  $checkoutId = $this->getRequest()->getParam('klarna_order');
316
- $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
 
 
 
 
 
 
 
 
 
317
  $klarna = Mage::getModel('klarna/klarnacheckout');
318
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
319
 
320
- Mage::helper('klarna')->logKlarnaApi('validateAction checkout id: ' . $checkoutId);
 
 
 
321
 
322
- $result = $klarna->validateQuote();
 
 
323
 
324
- Mage::helper('klarna')->logKlarnaApi('validateAction result = ' . $result);
325
- Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
 
 
 
326
 
327
- if ($result !== true) {
328
- $payment = $quote->getPayment();
329
 
330
- if ($payment->getId()) {
331
- $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_VALIDATE_ERRORS, $result);
332
- $payment->save();
333
- }
 
 
 
334
 
335
- $this->getResponse()
336
- ->setHttpResponseCode(303)
337
- ->setHeader('Location', Mage::getUrl('checkout/klarna/validateFailed', array('klarna_order' => $checkoutId)));
 
 
 
 
 
 
 
 
 
338
  }
339
- $this->getResponse()
340
- ->setHttpResponseCode(200);
341
  }
342
 
343
  public function pushAction()
344
  {
345
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
 
346
  $checkoutId = $this->getRequest()->getParam('klarna_order');
347
- $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
 
 
 
 
 
 
 
 
348
 
349
  /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
350
  $klarna = Mage::getModel('klarna/klarnacheckout');
351
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
 
352
  if (substr($checkoutId, -1, 1) == '/') {
353
  $checkoutId = substr($checkoutId, 0, strlen($checkoutId) - 1);
354
  }
355
- Mage::helper('klarna')->logKlarnaApi('pushAction checkout id: ' . $checkoutId);
356
- if (!$quote->getId()) {
357
- Mage::helper('klarna')->logKlarnaApi('pushAction checkout quote not found!');
358
- }
359
 
360
  if ($checkoutId) {
361
  try {
362
  // createOrder returns the order if successful, otherwise an error string
363
  $result = $klarna->createOrder($checkoutId);
364
 
365
- if (is_object($result)) {
366
- Mage::helper('klarna')->logKlarnaApi('pushAction order created successfully, order id: ' . $result->getId());
 
 
 
 
 
 
 
 
 
 
367
  } else {
368
- Mage::helper('klarna')->logKlarnaApi($result);
 
 
369
  }
370
  } catch (Exception $e) {
 
 
371
  Mage::helper('klarna')->logKlarnaException($e);
372
  }
373
  }
@@ -378,17 +438,28 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
378
  {
379
  try {
380
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
 
381
  $checkoutId = $this->_getSession()->getKlarnaCheckoutId();
382
- $quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
 
 
 
 
 
 
 
 
383
  $klarna = Mage::getModel('klarna/klarnacheckout');
384
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
385
- Mage::helper('klarna')->logKlarnaApi('successAction checkout id: ' . $checkoutId);
386
-
387
- if (!$checkoutId) {
388
- Mage::helper('klarna')->logKlarnaApi('successAction checkout id is empty, so we do nothing');
389
- //$this->_redirect('');
390
- //return;
391
- exit(1);
 
 
392
  }
393
 
394
  $status = $klarna->getCheckoutStatus($checkoutId);
@@ -403,19 +474,21 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
403
  }
404
 
405
  // close the quote if push hasn't closed it already
406
- $quote = $this->_getQuote();
407
- if ($quote->getId() && $quote->getIsActive()) {
408
- Mage::helper('klarna')->logKlarnaApi('successAction closing quote');
409
- /** @var Mage_Core_Model_Resource $resource */
410
- $resource = Mage::getSingleton('core/resource');
411
- $read = $resource->getConnection('core_read');
412
- $read->update($resource->getTableName('sales/quote'), array('is_active' => 0), 'entity_id = ' . $quote->getId());
413
- }
 
414
 
415
- $this->_getSession()->setLastQuoteId($quote->getId());
416
- $this->_getSession()->clearHelperData();
417
- $this->_getSession()->clear();
418
- $this->_getCart()->unsetData('quote');
 
419
 
420
  $this->loadLayout();
421
  $this->_initLayoutMessages('customer/session');
@@ -428,7 +501,8 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
428
 
429
  $this->renderLayout();
430
 
431
- $this->_getSession()->setKlarnaCheckoutId('');
 
432
  $this->_getSession()->setKlarnaUseOtherMethods(false);
433
  Mage::helper('klarna')->logKlarnaApi('successAction displayed success');
434
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
@@ -453,23 +527,9 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
453
  array(
454
  'request' => $this->getRequest(),
455
  'quote' => $this->_getOnepage()->getQuote()));
 
456
  $this->_getOnepage()->getQuote()->collectTotals()->save();
457
  }
458
- /*
459
- // This code should work just as well, it won't call all the saveShippingMethod functions
460
- $quote = $this->_getQuote();
461
- $shippingAddress = $quote->getShippingAddress();
462
- $shippingAddress->setShippingMethod($data);
463
- Mage::dispatchEvent(
464
- 'klarnacheckout_controller_klarna_save_shipping_method',
465
- array(
466
- 'request' => $this->getRequest(),
467
- 'quote' => $quote
468
- )
469
- );
470
- $quote->setTotalsCollectedFlag(false);
471
- $quote->collectTotals()->save();
472
- */
473
  }
474
  catch (Exception $e) {
475
  $resultMessage['error'] = $e->getMessage();
@@ -478,7 +538,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
478
  $resultMessage['success'] = 'Shipping method successfully saved';
479
  }
480
 
481
- if ($this->getRequest()->isXmlHttpRequest()) {
482
  $this->getResponse()->setBody(Zend_Json::encode($resultMessage));
483
  } else {
484
  $this->_redirect('checkout/klarna');
@@ -496,6 +556,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
496
  ->loadByCode($code)
497
  ->addToCart(false);
498
 
 
499
  $quote = $this->_getQuote();
500
  $quote->collectTotals();
501
  $quote->save();
@@ -516,8 +577,6 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
516
  }
517
  }
518
 
519
- $this->_checkShippingMethod();
520
-
521
  if ($this->getRequest()->isXmlHttpRequest()) {
522
  $this->getResponse()->setBody(Zend_Json::encode($resultMessage));
523
  } else {
@@ -534,6 +593,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
534
  ->loadByCode($code)
535
  ->removeFromCart(false);
536
 
 
537
  $quote = $this->_getQuote();
538
  $quote->collectTotals();
539
  $quote->save();
@@ -553,8 +613,6 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
553
  }
554
  }
555
 
556
- $this->_checkShippingMethod();
557
-
558
  if ($this->getRequest()->isXmlHttpRequest()) {
559
  $this->getResponse()->setBody(Zend_Json::encode($resultMessage));
560
  } else {
@@ -644,6 +702,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
644
  Mage::throwException(implode(', ', $messages));
645
  }
646
 
 
647
  $cart->save();
648
 
649
  // Addon for ajax to redirect to cart
@@ -661,7 +720,6 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
661
  Mage::logException($e);
662
  }
663
 
664
- $this->_checkShippingMethod();
665
  $this->getResponse()->setBody(Zend_Json::encode($result));
666
  }
667
 
@@ -728,7 +786,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
728
  throw new Exception($this->__('No coupon code was submitted.'));
729
  }
730
 
731
- $this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
732
  $this->_getQuote()->setCouponCode(strlen($couponCode) ? $couponCode : '')
733
  ->collectTotals()
734
  ->save();
@@ -750,7 +808,6 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
750
  $result['error'] = $e->getMessage();
751
  }
752
 
753
- $this->_checkShippingMethod();
754
  $this->getResponse()->setBody(Zend_Json::encode($result));
755
  }
756
 
@@ -775,6 +832,7 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
775
  );
776
 
777
  if ($reward->getId() && $reward->getPointsBalance() >= $minPointsBalance) {
 
778
  $quote->setRewardInstance($reward);
779
  $quote->collectTotals();
780
  $quote->save();
@@ -788,7 +846,6 @@ class Vaimo_Klarna_Checkout_KlarnaController extends Mage_Core_Controller_Front_
788
  $result['success'] = $this->__('Reward points unused');
789
  }
790
 
791
- $this->_checkShippingMethod();
792
  $this->getResponse()->setBody(Zend_Json::encode($result));
793
  }
794
 
75
  return $this;
76
  }
77
 
78
+ /**
79
+ * This function checks valid shippingMethod
80
+ *
81
+ * There must be a better way...
82
+ *
83
+ * @return $this
84
+ *
85
+ */
86
  protected function _checkShippingMethod()
87
  {
88
  // set shipping method
89
  $quote = $this->_getQuote();
90
+ $klarna = Mage::getModel('klarna/klarnacheckout');
91
+ $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
92
+ $klarna->checkShippingMethod();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
 
95
  protected function _checkNewsletter()
125
  $quote->collectTotals();
126
  $quote->save();
127
  $this->_getSession()->setKlarnaUseOtherMethods(false);
128
+ $this->_redirect('checkout/klarna');
129
+ /*
130
  if (Mage::helper('klarna')->isOneStepCheckout()) {
131
  $this->_redirect('onestepcheckout');
132
  } else {
133
  $this->_redirect('checkout/onepage');
134
  }
135
+ */
136
+ }
137
+
138
+ protected function _redirectToCart($store = null)
139
+ {
140
+ $path = Mage::getStoreConfig('payment/vaimo_klarna_checkout/cart_redirect', $store);
141
+ if (is_null($path))
142
+ $path = 'checkout/cart';
143
+ $this->_redirect($path);
144
  }
145
 
146
  public function indexAction()
157
  return;
158
  }
159
 
 
 
160
  if (!$quote->hasItems() || $quote->getHasError()) {
161
+ $this->_redirectToCart($quote->getStoreId());
162
  return;
163
  }
164
 
168
  Mage::helper('checkout')->__('Subtotal must exceed minimum order amount');
169
 
170
  $this->_getSession()->addError($error);
171
+ $this->_redirectToCart($quote->getStoreId());
172
  return;
173
  }
174
 
257
  $checkoutId = $this->getRequest()->getParam('klarna_order');
258
  Mage::helper('klarna')->logKlarnaApi('taxshippingupdate callback received for ID ' . $checkoutId);
259
 
260
+ //$quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
261
+ $quote = Mage::helper('klarna')->findQuote($checkoutId);
262
  $klarna = Mage::getModel('klarna/klarnacheckout');
263
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
264
 
270
 
271
  Mage::helper('klarna')->logDebugInfo('taxshippingupdate response', $result);
272
  $this->getResponse()->setBody(Zend_Json::encode($result));
273
+
274
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
275
  }
276
 
279
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
280
 
281
  $checkoutId = $this->getRequest()->getParam('klarna_order');
282
+ //$quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
283
+ $quote = Mage::helper('klarna')->findQuote($checkoutId);
284
  $payment = $quote->getPayment();
285
  $errors = $payment->getAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_VALIDATE_ERRORS);
286
  Mage::helper('klarna')->logKlarnaApi('failedAction errors: ' . $errors);
292
 
293
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
294
 
295
+ $this->_redirectToCart($quote->getStoreId());
296
  return;
297
  }
298
 
299
+ protected function _initPushOrValidate($checkoutId)
300
+ {
301
+ $quote = Mage::helper('klarna')->findQuote($checkoutId);
302
+ if (!$quote || !$quote->getId()) {
303
+ return NULL;
304
+ }
305
+ if ($quote->getStoreId()!=Mage::app()->getStore()->getId()) {
306
+ Mage::app()->setCurrentStore($quote->getStoreId());
307
+ }
308
+ return $quote;
309
+ }
310
+
311
+ protected function _initPushQueue($checkoutId)
312
+ {
313
+ $pushQueue = Mage::getModel('klarna/pushqueue');
314
+ $pushQueue->loadByKlarnaOrderNumber($checkoutId);
315
+ if ($pushQueue->getId()) {
316
+ $pushQueue->setRetryAttempts(0);
317
+ } else {
318
+ $pushQueue->setKlarnaOrderNumber($checkoutId);
319
+ }
320
+ $pushQueue->save();
321
+ return $pushQueue;
322
+ }
323
+
324
  public function validateAction()
325
  {
326
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
327
 
328
  $checkoutId = $this->getRequest()->getParam('klarna_order');
329
+ $quote = $this->_initPushOrValidate($checkoutId);
330
+
331
+ Mage::helper('klarna')->logKlarnaApi('validateAction checkout id: ' . $checkoutId);
332
+ if (!$quote) {
333
+ Mage::helper('klarna')->logKlarnaApi('validateAction checkout quote not found!');
334
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
335
+ return;
336
+ }
337
+
338
+ /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
339
  $klarna = Mage::getModel('klarna/klarnacheckout');
340
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
341
 
342
+ $post_body = file_get_contents('php://input');
343
+ $klarnaOrderData = json_decode($post_body, true);
344
+ Mage::helper('klarna')->logDebugInfo('validateAction klarnaOrderData', $klarnaOrderData);
345
+ $createdKlarnaOrder = new Varien_Object($klarnaOrderData);
346
 
347
+ if (substr($checkoutId, -1, 1) == '/') {
348
+ $checkoutId = substr($checkoutId, 0, strlen($checkoutId) - 1);
349
+ }
350
 
351
+ if ($checkoutId) {
352
+ try {
353
+ // validateQuote returns true if successful, a string if failed
354
+ $createOrderOnValidate = $klarna->getConfigData('create_order_on_validation');
355
+ $result = $klarna->validateQuote($checkoutId, $createOrderOnValidate, $createdKlarnaOrder);
356
 
357
+ Mage::helper('klarna')->logKlarnaApi('validateAction result = ' . $result);
 
358
 
359
+ if ($result !== true) {
360
+ $payment = $quote->getPayment();
361
+
362
+ if ($payment->getId()) {
363
+ $payment->setAdditionalInformation(Vaimo_Klarna_Helper_Data::KLARNA_VALIDATE_ERRORS, $result);
364
+ $payment->save();
365
+ }
366
 
367
+ $this->getResponse()
368
+ ->setHttpResponseCode(303)
369
+ ->setHeader('Location', Mage::getUrl('checkout/klarna/validateFailed', array('klarna_order' => $checkoutId)));
370
+ }
371
+ $this->getResponse()
372
+ ->setHttpResponseCode(200);
373
+ } catch (Exception $e) {
374
+ Mage::helper('klarna')->logKlarnaException($e);
375
+ $this->getResponse()
376
+ ->setHttpResponseCode(303)
377
+ ->setHeader('Location', Mage::getUrl('checkout/klarna/validateFailed', array('klarna_order' => $checkoutId)));
378
+ }
379
  }
380
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
 
381
  }
382
 
383
  public function pushAction()
384
  {
385
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
386
+
387
  $checkoutId = $this->getRequest()->getParam('klarna_order');
388
+ $quote = $this->_initPushOrValidate($checkoutId);
389
+ $pushQueue = $this->_initPushQueue($checkoutId);
390
+
391
+ Mage::helper('klarna')->logKlarnaApi('pushAction checkout id: ' . $checkoutId);
392
+ if (!$quote) {
393
+ Mage::helper('klarna')->logKlarnaApi('pushAction checkout quote not found!');
394
+ Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
395
+ return;
396
+ }
397
 
398
  /** @var Vaimo_Klarna_Model_Klarnacheckout $klarna */
399
  $klarna = Mage::getModel('klarna/klarnacheckout');
400
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
401
+
402
  if (substr($checkoutId, -1, 1) == '/') {
403
  $checkoutId = substr($checkoutId, 0, strlen($checkoutId) - 1);
404
  }
 
 
 
 
405
 
406
  if ($checkoutId) {
407
  try {
408
  // createOrder returns the order if successful, otherwise an error string
409
  $result = $klarna->createOrder($checkoutId);
410
 
411
+ if (is_array($result)) {
412
+ if ($result['status']=='success') {
413
+ $pushQueue->delete();
414
+ Mage::helper('klarna')->logKlarnaApi('pushAction order created successfully, order id: ' . $result['order']->getId());
415
+ } elseif ($result['status']=='fail') {
416
+ $pushQueue->delete();
417
+ Mage::helper('klarna')->logKlarnaApi($result['message']);
418
+ } else {
419
+ $pushQueue->setMessage($result['message']);
420
+ $pushQueue->save();
421
+ Mage::helper('klarna')->logKlarnaApi($result['message']);
422
+ }
423
  } else {
424
+ $pushQueue->setMessage('Unkown error from createOrder');
425
+ $pushQueue->save();
426
+ Mage::helper('klarna')->logKlarnaApi('Unkown error from createOrder');
427
  }
428
  } catch (Exception $e) {
429
+ $pushQueue->setMessage($e->getMessage());
430
+ $pushQueue->save();
431
  Mage::helper('klarna')->logKlarnaException($e);
432
  }
433
  }
438
  {
439
  try {
440
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_START_TAG);
441
+ $revisitedf = false;
442
  $checkoutId = $this->_getSession()->getKlarnaCheckoutId();
443
+ if (!$checkoutId) {
444
+ $checkoutId = $this->_getSession()->getKlarnaCheckoutPrevId();
445
+ if ($checkoutId) {
446
+ $revisitedf = true;
447
+ Mage::helper('klarna')->logKlarnaApi('successAction revisited, checkout id: ' . $checkoutId);
448
+ }
449
+ }
450
+ //$quote = Mage::getModel('sales/quote')->load($checkoutId, 'klarna_checkout_id');
451
+ $quote = Mage::helper('klarna')->findQuote($checkoutId);
452
  $klarna = Mage::getModel('klarna/klarnacheckout');
453
  $klarna->setQuote($quote, Vaimo_Klarna_Helper_Data::KLARNA_METHOD_CHECKOUT);
454
+ if (!$revisitedf) {
455
+ Mage::helper('klarna')->logKlarnaApi('successAction checkout id: ' . $checkoutId);
456
+
457
+ if (!$checkoutId) {
458
+ Mage::helper('klarna')->logKlarnaApi('successAction checkout id is empty, so we do nothing');
459
+ //$this->_redirect('');
460
+ //return;
461
+ exit(1);
462
+ }
463
  }
464
 
465
  $status = $klarna->getCheckoutStatus($checkoutId);
474
  }
475
 
476
  // close the quote if push hasn't closed it already
477
+ //$quote = $this->_getQuote(); // Should be loaded already...
478
+ if (!$revisitedf) {
479
+ if ($quote->getId() && $quote->getIsActive()) {
480
+ Mage::helper('klarna')->logKlarnaApi('successAction closing quote');
481
+ /** @var Mage_Core_Model_Resource $resource */
482
+ $resource = Mage::getSingleton('core/resource');
483
+ $read = $resource->getConnection('core_read');
484
+ $read->update($resource->getTableName('sales/quote'), array('is_active' => 0), 'entity_id = ' . $quote->getId());
485
+ }
486
 
487
+ $this->_getSession()->setLastQuoteId($quote->getId());
488
+ $this->_getSession()->clearHelperData();
489
+ $this->_getSession()->clear();
490
+ $this->_getCart()->unsetData('quote');
491
+ }
492
 
493
  $this->loadLayout();
494
  $this->_initLayoutMessages('customer/session');
501
 
502
  $this->renderLayout();
503
 
504
+ $this->_getSession()->setKlarnaCheckoutId(''); // This needs to be cleared, to be able to create new orders
505
+ $this->_getSession()->setKlarnaCheckoutPrevId($checkoutId);
506
  $this->_getSession()->setKlarnaUseOtherMethods(false);
507
  Mage::helper('klarna')->logKlarnaApi('successAction displayed success');
508
  Mage::helper('klarna')->logKlarnaApi(Vaimo_Klarna_Helper_Data::KLARNA_LOG_END_TAG);
527
  array(
528
  'request' => $this->getRequest(),
529
  'quote' => $this->_getOnepage()->getQuote()));
530
+ $this->_checkShippingMethod();
531
  $this->_getOnepage()->getQuote()->collectTotals()->save();
532
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
533
  }
534
  catch (Exception $e) {
535
  $resultMessage['error'] = $e->getMessage();
538
  $resultMessage['success'] = 'Shipping method successfully saved';
539
  }
540
 
541
+ if ($this->getRequest()->isXmlHttpRequest()) {
542
  $this->getResponse()->setBody(Zend_Json::encode($resultMessage));
543
  } else {
544
  $this->_redirect('checkout/klarna');
556
  ->loadByCode($code)
557
  ->addToCart(false);
558
 
559
+ $this->_checkShippingMethod();
560
  $quote = $this->_getQuote();
561
  $quote->collectTotals();
562
  $quote->save();
577
  }
578
  }
579
 
 
 
580
  if ($this->getRequest()->isXmlHttpRequest()) {
581
  $this->getResponse()->setBody(Zend_Json::encode($resultMessage));
582
  } else {
593
  ->loadByCode($code)
594
  ->removeFromCart(false);
595
 
596
+ $this->_checkShippingMethod();
597
  $quote = $this->_getQuote();
598
  $quote->collectTotals();
599
  $quote->save();
613
  }
614
  }
615
 
 
 
616
  if ($this->getRequest()->isXmlHttpRequest()) {
617
  $this->getResponse()->setBody(Zend_Json::encode($resultMessage));
618
  } else {
702
  Mage::throwException(implode(', ', $messages));
703
  }
704
 
705
+ $this->_checkShippingMethod();
706
  $cart->save();
707
 
708
  // Addon for ajax to redirect to cart
720
  Mage::logException($e);
721
  }
722
 
 
723
  $this->getResponse()->setBody(Zend_Json::encode($result));
724
  }
725
 
786
  throw new Exception($this->__('No coupon code was submitted.'));
787
  }
788
 
789
+ $this->_checkShippingMethod();
790
  $this->_getQuote()->setCouponCode(strlen($couponCode) ? $couponCode : '')
791
  ->collectTotals()
792
  ->save();
808
  $result['error'] = $e->getMessage();
809
  }
810
 
 
811
  $this->getResponse()->setBody(Zend_Json::encode($result));
812
  }
813
 
832
  );
833
 
834
  if ($reward->getId() && $reward->getPointsBalance() >= $minPointsBalance) {
835
+ $this->_checkShippingMethod();
836
  $quote->setRewardInstance($reward);
837
  $quote->collectTotals();
838
  $quote->save();
846
  $result['success'] = $this->__('Reward points unused');
847
  }
848
 
 
849
  $this->getResponse()->setBody(Zend_Json::encode($result));
850
  }
851
 
app/code/community/Vaimo/Klarna/etc/config.xml CHANGED
@@ -25,7 +25,7 @@
25
  --><config>
26
  <modules>
27
  <Vaimo_Klarna>
28
- <version>5.3.1</version>
29
  <name>Vaimo Klarna Module</name>
30
  <depends>
31
  <Mage_Payment/>
@@ -42,7 +42,16 @@
42
  <models>
43
  <klarna>
44
  <class>Vaimo_Klarna_Model</class>
 
45
  </klarna>
 
 
 
 
 
 
 
 
46
  </models>
47
  <helpers>
48
  <klarna>
@@ -259,14 +268,22 @@
259
 
260
  <crontab>
261
  <jobs>
262
- <update_transactions>
263
  <schedule>
264
- <cron_expr>0 */2 * * *</cron_expr>
265
  </schedule>
266
  <run>
267
  <model>klarna/cron::statusUpdateOfPendingOrders</model>
268
  </run>
269
- </update_transactions>
 
 
 
 
 
 
 
 
270
  </jobs>
271
  </crontab>
272
 
@@ -379,6 +396,9 @@
379
  <enable_other_button>1</enable_other_button>
380
  <enable_auto_focus>1</enable_auto_focus>
381
  <shipping_countries>US,MX,CA,GL</shipping_countries>
 
 
 
382
  </vaimo_klarna_checkout>
383
  </payment>
384
  </default>
25
  --><config>
26
  <modules>
27
  <Vaimo_Klarna>
28
+ <version>5.3.24</version>
29
  <name>Vaimo Klarna Module</name>
30
  <depends>
31
  <Mage_Payment/>
42
  <models>
43
  <klarna>
44
  <class>Vaimo_Klarna_Model</class>
45
+ <resourceModel>klarna_resource</resourceModel>
46
  </klarna>
47
+ <klarna_resource>
48
+ <class>Vaimo_Klarna_Model_Resource</class>
49
+ <entities>
50
+ <pushqueue>
51
+ <table>vaimo_klarna_pushqueue</table>
52
+ </pushqueue>
53
+ </entities>
54
+ </klarna_resource>
55
  </models>
56
  <helpers>
57
  <klarna>
268
 
269
  <crontab>
270
  <jobs>
271
+ <update_klarna_transactions>
272
  <schedule>
273
+ <cron_expr>0 * * * *</cron_expr>
274
  </schedule>
275
  <run>
276
  <model>klarna/cron::statusUpdateOfPendingOrders</model>
277
  </run>
278
+ </update_klarna_transactions>
279
+ <check_klarna_pushqueue>
280
+ <schedule>
281
+ <cron_expr>0 * * * *</cron_expr>
282
+ </schedule>
283
+ <run>
284
+ <model>klarna/cron::treatPushQueue</model>
285
+ </run>
286
+ </check_klarna_pushqueue>
287
  </jobs>
288
  </crontab>
289
 
396
  <enable_other_button>1</enable_other_button>
397
  <enable_auto_focus>1</enable_auto_focus>
398
  <shipping_countries>US,MX,CA,GL</shipping_countries>
399
+ <auto_register_guest>1</auto_register_guest>
400
+ <create_order_on_validation>1</create_order_on_validation>
401
+ <other_countries>1</other_countries>
402
  </vaimo_klarna_checkout>
403
  </payment>
404
  </default>
app/code/community/Vaimo/Klarna/etc/system.xml CHANGED
@@ -35,7 +35,7 @@
35
  <show_in_default>1</show_in_default>
36
  <show_in_store>1</show_in_store>
37
  <show_in_website>1</show_in_website>
38
- <fields>
39
  <active translate="label">
40
  <label>Enabled</label>
41
  <frontend_type>select</frontend_type>
@@ -215,7 +215,7 @@
215
  <show_in_default>1</show_in_default>
216
  <show_in_store>1</show_in_store>
217
  <show_in_website>1</show_in_website>
218
- <fields>
219
  <active translate="label">
220
  <label>Enabled</label>
221
  <frontend_type>select</frontend_type>
@@ -392,7 +392,7 @@
392
  <show_in_default>1</show_in_default>
393
  <show_in_store>1</show_in_store>
394
  <show_in_website>1</show_in_website>
395
- <fields>
396
  <active translate="label">
397
  <label>Enabled</label>
398
  <frontend_type>select</frontend_type>
@@ -663,6 +663,15 @@
663
  <show_in_store>1</show_in_store>
664
  <comment>URL to this stores own terms and conditions</comment>
665
  </terms_url>
 
 
 
 
 
 
 
 
 
666
  <klarna_layout translate="label">
667
  <label>Layout</label>
668
  <frontend_type>select</frontend_type>
@@ -749,35 +758,75 @@
749
  <show_in_website>1</show_in_website>
750
  <show_in_store>1</show_in_store>
751
  </enable_auto_focus>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
752
  <enable_validation translate="label">
753
  <label>Enable Validation of Order before Klarna proceeds</label>
754
  <frontend_type>select</frontend_type>
755
  <source_model>adminhtml/system_config_source_yesno</source_model>
756
- <sort_order>260</sort_order>
757
  <show_in_default>1</show_in_default>
758
  <show_in_website>1</show_in_website>
759
  <show_in_store>1</show_in_store>
760
- <comment>An extra validation is made for the cart, stock levels for example, just before the order is created in Klarna. Works only if HTTPS is activated for checkout.</comment>
761
  </enable_validation>
762
- <enable_postcode_update translate="label">
763
- <label>Enable tax and shipping updates</label>
764
  <frontend_type>select</frontend_type>
 
765
  <source_model>adminhtml/system_config_source_yesno</source_model>
766
- <sort_order>270</sort_order>
767
  <show_in_default>1</show_in_default>
768
  <show_in_website>1</show_in_website>
769
  <show_in_store>1</show_in_store>
770
- <comment>Klarna contacts Magento to recalculate taxes and shippment amounts when address is updated. Works only if HTTPS is activated for checkout.</comment>
771
- </enable_postcode_update>
772
- <enable_trigger_changed_js>
773
- <label>Enable javascript trigger for address update</label>
774
  <frontend_type>select</frontend_type>
 
775
  <source_model>adminhtml/system_config_source_yesno</source_model>
776
- <sort_order>280</sort_order>
777
  <show_in_default>1</show_in_default>
778
  <show_in_website>1</show_in_website>
779
  <show_in_store>1</show_in_store>
780
- </enable_trigger_changed_js>
 
781
  <heading_other_method_button translate="label">
782
  <label>Support of other payment methods</label>
783
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -799,6 +848,7 @@
799
  <label_other_button translate="label">
800
  <label>Label for Other Payment Methods button</label>
801
  <frontend_type>text</frontend_type>
 
802
  <sort_order>722</sort_order>
803
  <show_in_default>1</show_in_default>
804
  <show_in_website>1</show_in_website>
@@ -808,6 +858,7 @@
808
  <label_back_button translate="label">
809
  <label>Label for Back to Klarna Checkout button</label>
810
  <frontend_type>text</frontend_type>
 
811
  <sort_order>723</sort_order>
812
  <show_in_default>1</show_in_default>
813
  <show_in_website>1</show_in_website>
@@ -817,13 +868,24 @@
817
  <auto_reset_other_method_button translate="label">
818
  <label>Automatically reactivate Klarna Checkout</label>
819
  <frontend_type>select</frontend_type>
 
820
  <source_model>adminhtml/system_config_source_yesno</source_model>
821
  <sort_order>724</sort_order>
822
  <show_in_default>1</show_in_default>
823
  <show_in_website>1</show_in_website>
824
  <show_in_store>1</show_in_store>
825
- <comment>If enabled, it will go to Klarna Checkout next time checkout is requested, if user exits checkout by going to another page. Attention! If there are many customizations in standard checkout, it might cause this reactivation as well!</comment>
826
  </auto_reset_other_method_button>
 
 
 
 
 
 
 
 
 
 
827
 
828
  <heading_newsletter translate="label">
829
  <label>Newsletter</label>
@@ -860,9 +922,19 @@
860
  <show_in_website>1</show_in_website>
861
  <show_in_store>1</show_in_store>
862
  </heading_ab_testing>
 
 
 
 
 
 
 
 
 
863
  <allowed_ip_range translate="label">
864
  <label>Enable for IP range (last digit)</label>
865
  <frontend_type>text</frontend_type>
 
866
  <sort_order>860</sort_order>
867
  <show_in_default>1</show_in_default>
868
  <show_in_website>1</show_in_website>
@@ -873,6 +945,7 @@
873
  <label>Enable for logged in Customers</label>
874
  <frontend_type>select</frontend_type>
875
  <source_model>adminhtml/system_config_source_yesno</source_model>
 
876
  <sort_order>870</sort_order>
877
  <show_in_default>1</show_in_default>
878
  <show_in_website>1</show_in_website>
@@ -883,41 +956,50 @@
883
  <label>Enable for specific customer groups</label>
884
  <frontend_type>multiselect</frontend_type>
885
  <source_model>klarna/source_customergroup</source_model>
 
886
  <sort_order>880</sort_order>
887
  <show_in_default>1</show_in_default>
888
  <show_in_website>1</show_in_website>
889
  <show_in_store>1</show_in_store>
890
  <comment>If you do not belong to a selected customer group, standard Magento checkout will be used. None selected, means enabled for all</comment>
891
  </allow_customer_group>
892
- <user_defined_json translate="label">
893
- <label>User Defined Variables</label>
894
- <backend_model>klarna/adminhtml_system_config_backend_admin_json</backend_model>
895
- <frontend_type>textarea</frontend_type>
896
- <sort_order>920</sort_order>
897
  <show_in_default>1</show_in_default>
898
  <show_in_website>1</show_in_website>
899
  <show_in_store>1</show_in_store>
900
- <comment>JSON encoded array. Please consult Klarna before using this, incorrect information may cause the integration to stop working</comment>
901
- </user_defined_json>
 
 
 
 
 
 
 
 
902
  <shipping_countries translate="label">
903
  <label>Shipping Countries</label>
904
  <frontend_type>multiselect</frontend_type>
905
- <sort_order>930</sort_order>
 
906
  <source_model>adminhtml/system_config_source_country</source_model>
907
  <show_in_default>1</show_in_default>
908
  <show_in_website>1</show_in_website>
909
  <show_in_store>1</show_in_store>
910
- <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>
911
  </shipping_countries>
912
  <shipping_options translate="label">
913
- <label>Shipping Countries</label>
914
- <frontend_type>multiselect</frontend_type>
915
- <sort_order>930</sort_order>
916
- <source_model>adminhtml/system_config_source_country</source_model>
917
  <show_in_default>1</show_in_default>
918
  <show_in_website>1</show_in_website>
919
  <show_in_store>1</show_in_store>
920
- <comment>Specific for API V.3.1. List of available shipping options appear in Klarna Checkout.</comment>
921
  </shipping_options>
922
  </fields>
923
  </vaimo_klarna_checkout>
35
  <show_in_default>1</show_in_default>
36
  <show_in_store>1</show_in_store>
37
  <show_in_website>1</show_in_website>
38
+ <fields>
39
  <active translate="label">
40
  <label>Enabled</label>
41
  <frontend_type>select</frontend_type>
215
  <show_in_default>1</show_in_default>
216
  <show_in_store>1</show_in_store>
217
  <show_in_website>1</show_in_website>
218
+ <fields>
219
  <active translate="label">
220
  <label>Enabled</label>
221
  <frontend_type>select</frontend_type>
392
  <show_in_default>1</show_in_default>
393
  <show_in_store>1</show_in_store>
394
  <show_in_website>1</show_in_website>
395
+ <fields>
396
  <active translate="label">
397
  <label>Enabled</label>
398
  <frontend_type>select</frontend_type>
663
  <show_in_store>1</show_in_store>
664
  <comment>URL to this stores own terms and conditions</comment>
665
  </terms_url>
666
+ <cart_redirect translate="label">
667
+ <label>Cart redirect</label>
668
+ <frontend_type>text</frontend_type>
669
+ <sort_order>95</sort_order>
670
+ <show_in_default>1</show_in_default>
671
+ <show_in_store>1</show_in_store>
672
+ <show_in_website>1</show_in_website>
673
+ <comment>Default is cart, custom redirect must not go to any checkout page</comment>
674
+ </cart_redirect>
675
  <klarna_layout translate="label">
676
  <label>Layout</label>
677
  <frontend_type>select</frontend_type>
758
  <show_in_website>1</show_in_website>
759
  <show_in_store>1</show_in_store>
760
  </enable_auto_focus>
761
+ <enable_trigger_changed_js>
762
+ <label>Enable javascript trigger for address update</label>
763
+ <frontend_type>select</frontend_type>
764
+ <source_model>adminhtml/system_config_source_yesno</source_model>
765
+ <sort_order>270</sort_order>
766
+ <show_in_default>1</show_in_default>
767
+ <show_in_website>1</show_in_website>
768
+ <show_in_store>1</show_in_store>
769
+ </enable_trigger_changed_js>
770
+ <auto_register_guest translate="label">
771
+ <label>Automatically register guests on checkout</label>
772
+ <frontend_type>select</frontend_type>
773
+ <source_model>adminhtml/system_config_source_yesno</source_model>
774
+ <sort_order>280</sort_order>
775
+ <show_in_default>1</show_in_default>
776
+ <show_in_store>1</show_in_store>
777
+ <show_in_website>1</show_in_website>
778
+ <comment>If disabled and Guest Checkout is allowed in Magento Checkout Options, orders will be placed as guests.</comment>
779
+ </auto_register_guest>
780
+ <user_defined_json translate="label">
781
+ <label>User Defined Variables</label>
782
+ <backend_model>klarna/adminhtml_system_config_backend_admin_json</backend_model>
783
+ <frontend_type>textarea</frontend_type>
784
+ <sort_order>290</sort_order>
785
+ <show_in_default>1</show_in_default>
786
+ <show_in_website>1</show_in_website>
787
+ <show_in_store>1</show_in_store>
788
+ <comment>JSON encoded array. Please consult Klarna before using this, incorrect information may cause the integration to stop working</comment>
789
+ </user_defined_json>
790
+ <heading_https_only translate="label">
791
+ <label>Only when https is activated in checkout</label>
792
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
793
+ <sort_order>600</sort_order>
794
+ <show_in_default>1</show_in_default>
795
+ <show_in_website>1</show_in_website>
796
+ <show_in_store>1</show_in_store>
797
+ </heading_https_only>
798
  <enable_validation translate="label">
799
  <label>Enable Validation of Order before Klarna proceeds</label>
800
  <frontend_type>select</frontend_type>
801
  <source_model>adminhtml/system_config_source_yesno</source_model>
802
+ <sort_order>610</sort_order>
803
  <show_in_default>1</show_in_default>
804
  <show_in_website>1</show_in_website>
805
  <show_in_store>1</show_in_store>
806
+ <comment>An extra validation is made for the cart, stock levels for example, just before the order is created in Klarna.</comment>
807
  </enable_validation>
808
+ <create_order_on_validation translate="label">
809
+ <label>Create order on Validation</label>
810
  <frontend_type>select</frontend_type>
811
+ <depends><enable_validation>1</enable_validation></depends>
812
  <source_model>adminhtml/system_config_source_yesno</source_model>
813
+ <sort_order>615</sort_order>
814
  <show_in_default>1</show_in_default>
815
  <show_in_website>1</show_in_website>
816
  <show_in_store>1</show_in_store>
817
+ <comment>Create pending order on Validation and only update it when completed.</comment>
818
+ </create_order_on_validation>
819
+ <enable_postcode_update translate="label">
820
+ <label>Enable tax and shipping updates</label>
821
  <frontend_type>select</frontend_type>
822
+ <depends><enable_trigger_changed_js>1</enable_trigger_changed_js></depends>
823
  <source_model>adminhtml/system_config_source_yesno</source_model>
824
+ <sort_order>620</sort_order>
825
  <show_in_default>1</show_in_default>
826
  <show_in_website>1</show_in_website>
827
  <show_in_store>1</show_in_store>
828
+ <comment>Klarna contacts Magento to recalculate taxes and shippment amounts when address is updated.</comment>
829
+ </enable_postcode_update>
830
  <heading_other_method_button translate="label">
831
  <label>Support of other payment methods</label>
832
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
848
  <label_other_button translate="label">
849
  <label>Label for Other Payment Methods button</label>
850
  <frontend_type>text</frontend_type>
851
+ <depends><enable_other_button>1</enable_other_button></depends>
852
  <sort_order>722</sort_order>
853
  <show_in_default>1</show_in_default>
854
  <show_in_website>1</show_in_website>
858
  <label_back_button translate="label">
859
  <label>Label for Back to Klarna Checkout button</label>
860
  <frontend_type>text</frontend_type>
861
+ <depends><enable_other_button>1</enable_other_button></depends>
862
  <sort_order>723</sort_order>
863
  <show_in_default>1</show_in_default>
864
  <show_in_website>1</show_in_website>
868
  <auto_reset_other_method_button translate="label">
869
  <label>Automatically reactivate Klarna Checkout</label>
870
  <frontend_type>select</frontend_type>
871
+ <depends><enable_other_button>1</enable_other_button></depends>
872
  <source_model>adminhtml/system_config_source_yesno</source_model>
873
  <sort_order>724</sort_order>
874
  <show_in_default>1</show_in_default>
875
  <show_in_website>1</show_in_website>
876
  <show_in_store>1</show_in_store>
877
+ <comment>If enabled, it will go to Klarna Checkout next time checkout is requested, if user exits standard checkout by going to another page. Attention! If there are many customizations in standard checkout, it might cause this reactivation as well!</comment>
878
  </auto_reset_other_method_button>
879
+ <explicit_usage translate="label">
880
+ <label>Only run Klarma Checkout if Explicitly called</label>
881
+ <frontend_type>select</frontend_type>
882
+ <source_model>adminhtml/system_config_source_yesno</source_model>
883
+ <sort_order>725</sort_order>
884
+ <show_in_default>1</show_in_default>
885
+ <show_in_website>1</show_in_website>
886
+ <show_in_store>1</show_in_store>
887
+ <comment>If set to Yes, and you go to checkout without any customisation, it will go to standard checkout rather than Klarna Checkout by default</comment>
888
+ </explicit_usage>
889
 
890
  <heading_newsletter translate="label">
891
  <label>Newsletter</label>
922
  <show_in_website>1</show_in_website>
923
  <show_in_store>1</show_in_store>
924
  </heading_ab_testing>
925
+ <activate_ab_testing translate="label">
926
+ <label>Enable A/B Testing</label>
927
+ <frontend_type>select</frontend_type>
928
+ <source_model>adminhtml/system_config_source_yesno</source_model>
929
+ <sort_order>851</sort_order>
930
+ <show_in_default>1</show_in_default>
931
+ <show_in_website>1</show_in_website>
932
+ <show_in_store>1</show_in_store>
933
+ </activate_ab_testing>
934
  <allowed_ip_range translate="label">
935
  <label>Enable for IP range (last digit)</label>
936
  <frontend_type>text</frontend_type>
937
+ <depends><activate_ab_testing>1</activate_ab_testing></depends>
938
  <sort_order>860</sort_order>
939
  <show_in_default>1</show_in_default>
940
  <show_in_website>1</show_in_website>
945
  <label>Enable for logged in Customers</label>
946
  <frontend_type>select</frontend_type>
947
  <source_model>adminhtml/system_config_source_yesno</source_model>
948
+ <depends><activate_ab_testing>1</activate_ab_testing></depends>
949
  <sort_order>870</sort_order>
950
  <show_in_default>1</show_in_default>
951
  <show_in_website>1</show_in_website>
956
  <label>Enable for specific customer groups</label>
957
  <frontend_type>multiselect</frontend_type>
958
  <source_model>klarna/source_customergroup</source_model>
959
+ <depends><activate_ab_testing>1</activate_ab_testing></depends>
960
  <sort_order>880</sort_order>
961
  <show_in_default>1</show_in_default>
962
  <show_in_website>1</show_in_website>
963
  <show_in_store>1</show_in_store>
964
  <comment>If you do not belong to a selected customer group, standard Magento checkout will be used. None selected, means enabled for all</comment>
965
  </allow_customer_group>
966
+ <heading_api_v3x_only translate="label">
967
+ <label>Specific for API V.3x (US and UK)</label>
968
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
969
+ <sort_order>990</sort_order>
 
970
  <show_in_default>1</show_in_default>
971
  <show_in_website>1</show_in_website>
972
  <show_in_store>1</show_in_store>
973
+ </heading_api_v3x_only>
974
+ <other_countries translate="label">
975
+ <label>Show other allowed shipping countries</label>
976
+ <frontend_type>select</frontend_type>
977
+ <source_model>adminhtml/system_config_source_yesno</source_model>
978
+ <sort_order>992</sort_order>
979
+ <show_in_default>1</show_in_default>
980
+ <show_in_website>1</show_in_website>
981
+ <show_in_store>1</show_in_store>
982
+ </other_countries>
983
  <shipping_countries translate="label">
984
  <label>Shipping Countries</label>
985
  <frontend_type>multiselect</frontend_type>
986
+ <depends><other_countries>1</other_countries></depends>
987
+ <sort_order>993</sort_order>
988
  <source_model>adminhtml/system_config_source_country</source_model>
989
  <show_in_default>1</show_in_default>
990
  <show_in_website>1</show_in_website>
991
  <show_in_store>1</show_in_store>
992
+ <comment>List of allowed shipping countries. If none selected, none will be supported. List will appear in Klarna Checkout</comment>
993
  </shipping_countries>
994
  <shipping_options translate="label">
995
+ <label>Include Shipping Options</label>
996
+ <frontend_type>select</frontend_type>
997
+ <source_model>adminhtml/system_config_source_yesno</source_model>
998
+ <sort_order>996</sort_order>
999
  <show_in_default>1</show_in_default>
1000
  <show_in_website>1</show_in_website>
1001
  <show_in_store>1</show_in_store>
1002
+ <comment>List of available shipping options that should appear in Klarna Checkout.</comment>
1003
  </shipping_options>
1004
  </fields>
1005
  </vaimo_klarna_checkout>
app/code/community/Vaimo/Klarna/sql/klarna_setup/mysql4-upgrade-5.3.4-5.3.5.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2009-2012 Vaimo AB
4
+ *
5
+ * Vaimo reserves all rights in the Program as delivered. The Program
6
+ * or any portion thereof may not be reproduced in any form whatsoever without
7
+ * the written consent of Vaimo, except as provided by licence. A licence
8
+ * under Vaimo's rights in the Program may be available directly from
9
+ * Vaimo.
10
+ *
11
+ * Disclaimer:
12
+ * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF.
13
+ * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS
19
+ * IN THE PROGRAM.
20
+ *
21
+ * @category Vaimo
22
+ * @package Vaimo_Klarna
23
+ * @copyright Copyright (c) 2009-2013 Vaimo AB
24
+ */
25
+
26
+ /** @var $installer Mage_Sales_Model_Resource_Setup */
27
+ $installer = Mage::getResourceModel('sales/setup', 'sales_setup');
28
+
29
+ $installer->startSetup();
30
+
31
+ $table = $installer->getConnection()
32
+ ->newTable($installer->getTable('klarna/pushqueue'))
33
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
34
+ 'identity' => true,
35
+ 'unsigned' => true,
36
+ 'nullable' => false,
37
+ 'primary' => true,
38
+ ), 'Id')
39
+ ->addColumn('klarna_order_number', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(), 'Klarna Order Number')
40
+ ->addColumn('retry_attempts', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
41
+ 'nullable' => false,
42
+ ), 'Retry attempts')
43
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
44
+ 'nullable' => false,
45
+ ), 'Created At')
46
+ ->addColumn('message', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(), 'Possible error message')
47
+ ->setComment('Klarna Push Queue');
48
+
49
+ $installer->getConnection()->createTable($table);
50
+
51
+ $installer->endSetup();
app/design/adminhtml/default/default/template/vaimo/klarna/info/checkout.phtml CHANGED
@@ -39,5 +39,7 @@
39
 
40
  <?php echo $this->getReferenceHtml(); ?>
41
 
 
 
42
  </ul>
43
 
39
 
40
  <?php echo $this->getReferenceHtml(); ?>
41
 
42
+ <?php echo $this->getNoticesHtml(); ?>
43
+
44
  </ul>
45
 
app/design/adminhtml/default/default/template/vaimo/klarna/info/children/notices.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2009-2014 Vaimo AB
4
+ *
5
+ * Vaimo reserves all rights in the Program as delivered. The Program
6
+ * or any portion thereof may not be reproduced in any form whatsoever without
7
+ * the written consent of Vaimo, except as provided by licence. A licence
8
+ * under Vaimo's rights in the Program may be available directly from
9
+ * Vaimo.
10
+ *
11
+ * Disclaimer:
12
+ * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF.
13
+ * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS
19
+ * IN THE PROGRAM.
20
+ *
21
+ * @category Vaimo
22
+ * @package Vaimo_Klarna
23
+ * @copyright Copyright (c) 2009-2014 Vaimo AB
24
+ */
25
+
26
+ $info = $this->getPaymentInfo();
27
+
28
+ ?>
29
+
30
+ <?php if ($info): ?>
31
+
32
+ <?php if ($info->getKlarnaNotice()): ?>
33
+ <?php foreach ($info->getKlarnaNotice() as $notice): ?>
34
+ <li>
35
+ <?php echo Mage::helper('klarna')->__('Notice') . ': ' . '<strong style="color:orange">' . $notice . '</strong>';?>
36
+ </li>
37
+ <?php endforeach; ?>
38
+ <?php endif; ?>
39
+
40
+ <?php endif; ?>
app/design/frontend/base/default/layout/vaimo_klarna.xml CHANGED
@@ -251,7 +251,8 @@
251
  </checkout_klarna_success>
252
 
253
  <default>
254
- <reference name="google_analytics">
 
255
  <block type="klarna/klarnacheckout_ga" name="google_analytics" as="google_analytics" template="googleanalytics/ga.phtml" />
256
  </reference>
257
  </default>
251
  </checkout_klarna_success>
252
 
253
  <default>
254
+ <reference name="head">
255
+ <action method="unsetChild"><name>google_analytics</name></action>
256
  <block type="klarna/klarnacheckout_ga" name="google_analytics" as="google_analytics" template="googleanalytics/ga.phtml" />
257
  </reference>
258
  </default>
app/design/frontend/base/default/template/vaimo/klarna/form/account.phtml CHANGED
@@ -42,6 +42,8 @@ $_showServiceMethods = false;
42
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
43
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
44
  <?php echo $this->useServiceLogotypes($serviceMethod, 90); ?>
 
 
45
  <?php else: ?>
46
  <li>
47
  <?php echo $this->useServiceLogotypes($serviceMethod, 125); ?>
@@ -54,6 +56,8 @@ $_showServiceMethods = false;
54
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
55
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
56
  <?php echo '<img src="' . $this->getKlarnaLogotype(90) . '" />'; ?>
 
 
57
  <?php else: ?>
58
  <li>
59
  <?php echo '<img src="' . $this->getKlarnaLogotype(125) . '" />'; ?>
42
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
43
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
44
  <?php echo $this->useServiceLogotypes($serviceMethod, 90); ?>
45
+ <?php elseif (Mage::helper('klarna')->isFireCheckout()): ?>
46
+ <?php echo $this->useServiceLogotypes($serviceMethod, 90); ?>
47
  <?php else: ?>
48
  <li>
49
  <?php echo $this->useServiceLogotypes($serviceMethod, 125); ?>
56
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
57
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
58
  <?php echo '<img src="' . $this->getKlarnaLogotype(90) . '" />'; ?>
59
+ <?php elseif (Mage::helper('klarna')->isFireCheckout()): ?>
60
+ <?php echo '<img src="' . $this->getKlarnaLogotype(90) . '" />'; ?>
61
  <?php else: ?>
62
  <li>
63
  <?php echo '<img src="' . $this->getKlarnaLogotype(125) . '" />'; ?>
app/design/frontend/base/default/template/vaimo/klarna/form/children/notifications.phtml CHANGED
@@ -31,6 +31,8 @@ $klarnaSetup = $this->getKlarnaSetup();
31
  <li>
32
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
33
  <?php $width = '100%'; ?>
 
 
34
  <?php else: ?>
35
  <?php $width = '40%'; ?>
36
  <?php endif; ?>
31
  <li>
32
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
33
  <?php $width = '100%'; ?>
34
+ <?php elseif (Mage::helper('klarna')->isFireCheckout()): ?>
35
+ <?php $width = '100%'; ?>
36
  <?php else: ?>
37
  <?php $width = '40%'; ?>
38
  <?php endif; ?>
app/design/frontend/base/default/template/vaimo/klarna/form/invoice.phtml CHANGED
@@ -43,6 +43,8 @@ $_showServiceMethods = false;
43
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
44
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
45
  <?php echo $this->useServiceLogotypes($serviceMethod, 90); ?>
 
 
46
  <?php else: ?>
47
  <li>
48
  <?php echo $this->useServiceLogotypes($serviceMethod, 125); ?>
@@ -55,6 +57,8 @@ $_showServiceMethods = false;
55
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
56
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
57
  <?php echo '<img src="' . $this->getKlarnaLogotype(90) . '" />'; ?>
 
 
58
  <?php else: ?>
59
  <li>
60
  <?php echo '<img src="' . $this->getKlarnaLogotype(125) . '" />'; ?>
43
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
44
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
45
  <?php echo $this->useServiceLogotypes($serviceMethod, 90); ?>
46
+ <?php elseif (Mage::helper('klarna')->isFireCheckout()): ?>
47
+ <?php echo $this->useServiceLogotypes($serviceMethod, 90); ?>
48
  <?php else: ?>
49
  <li>
50
  <?php echo $this->useServiceLogotypes($serviceMethod, 125); ?>
57
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
58
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
59
  <?php echo '<img src="' . $this->getKlarnaLogotype(90) . '" />'; ?>
60
+ <?php elseif (Mage::helper('klarna')->isFireCheckout()): ?>
61
+ <?php echo '<img src="' . $this->getKlarnaLogotype(90) . '" />'; ?>
62
  <?php else: ?>
63
  <li>
64
  <?php echo '<img src="' . $this->getKlarnaLogotype(125) . '" />'; ?>
app/design/frontend/base/default/template/vaimo/klarna/form/special.phtml CHANGED
@@ -42,6 +42,8 @@ $_showServiceMethods = false;
42
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
43
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
44
  <?php echo $this->useServiceLogotypes($serviceMethod, 90); ?>
 
 
45
  <?php else: ?>
46
  <li>
47
  <?php echo $this->useServiceLogotypes($serviceMethod, 125); ?>
@@ -54,6 +56,8 @@ $_showServiceMethods = false;
54
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
55
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
56
  <?php echo '<img src="' . $this->getKlarnaLogotype(90) . '" />'; ?>
 
 
57
  <?php else: ?>
58
  <li>
59
  <?php echo '<img src="' . $this->getKlarnaLogotype(125) . '" />'; ?>
42
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
43
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
44
  <?php echo $this->useServiceLogotypes($serviceMethod, 90); ?>
45
+ <?php elseif (Mage::helper('klarna')->isFireCheckout()): ?>
46
+ <?php echo $this->useServiceLogotypes($serviceMethod, 90); ?>
47
  <?php else: ?>
48
  <li>
49
  <?php echo $this->useServiceLogotypes($serviceMethod, 125); ?>
56
  <?php if (Mage::helper('klarna')->showTitleAsTextOnly()): ?>
57
  <?php if (Mage::helper('klarna')->isOneStepCheckout()): ?>
58
  <?php echo '<img src="' . $this->getKlarnaLogotype(90) . '" />'; ?>
59
+ <?php elseif (Mage::helper('klarna')->isFireCheckout()): ?>
60
+ <?php echo '<img src="' . $this->getKlarnaLogotype(90) . '" />'; ?>
61
  <?php else: ?>
62
  <li>
63
  <?php echo '<img src="' . $this->getKlarnaLogotype(125) . '" />'; ?>
app/design/frontend/base/default/template/vaimo/klarna/info/checkout.phtml CHANGED
@@ -29,6 +29,16 @@
29
  <tr>
30
  <th align="left"><?php echo '<img src="' . $this->getKlarnaLogotype(125) . '" alt="' . Mage::helper('klarna')->__($this->getMethodTitle()) . '"/>'; ?></th>
31
  </tr>
 
 
 
 
32
  <?php echo $this->getInvoicesHtml(); ?>
 
 
 
 
 
 
33
  </tbody>
34
  </table>
29
  <tr>
30
  <th align="left"><?php echo '<img src="' . $this->getKlarnaLogotype(125) . '" alt="' . Mage::helper('klarna')->__($this->getMethodTitle()) . '"/>'; ?></th>
31
  </tr>
32
+ <tr>
33
+ <td><?php echo Mage::helper('klarna')->__($this->getMethodTitle()); ?></td>
34
+ </tr>
35
+
36
  <?php echo $this->getInvoicesHtml(); ?>
37
+
38
+ <?php echo $this->getReservationHtml(); ?>
39
+
40
+ <?php echo $this->getReferenceHtml(); ?>
41
+
42
+ <?php echo $this->getNoticesHtml(); ?>
43
  </tbody>
44
  </table>
app/design/frontend/base/default/template/vaimo/klarna/info/children/invoices.phtml CHANGED
@@ -33,9 +33,11 @@ $info = $this->getPaymentInfo();
33
 
34
  <?php if ($info->getKlarnaInvoiceList()): ?>
35
  <?php foreach ($info->getKlarnaInvoiceList() as $invoice): ?>
36
- <tr>
37
- <td><?php echo Mage::helper('klarna')->__('Invoice') . ' <a href="' . $this->getKlarnaInvoiceLink($invoice['invoice_id']) . '">' . $invoice['invoice_id'] . '</a>'; ?></td>
38
- </tr>
 
 
39
  <?php endforeach; ?>
40
  <?php endif; ?>
41
 
33
 
34
  <?php if ($info->getKlarnaInvoiceList()): ?>
35
  <?php foreach ($info->getKlarnaInvoiceList() as $invoice): ?>
36
+ <?php if (!isset($invoice[Vaimo_Klarna_Helper_Data::KLARNA_INFO_FIELD_INVOICE_LIST_KCO_ID])): ?>
37
+ <tr>
38
+ <td><?php echo Mage::helper('klarna')->__('Invoice') . ' <a href="' . $this->getKlarnaInvoiceLink($invoice['invoice_id']) . '">' . $invoice['invoice_id'] . '</a>'; ?></td>
39
+ </tr>
40
+ <?php endif; ?>
41
  <?php endforeach; ?>
42
  <?php endif; ?>
43
 
app/design/frontend/base/default/template/vaimo/klarna/info/children/notices.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2009-2014 Vaimo AB
4
+ *
5
+ * Vaimo reserves all rights in the Program as delivered. The Program
6
+ * or any portion thereof may not be reproduced in any form whatsoever without
7
+ * the written consent of Vaimo, except as provided by licence. A licence
8
+ * under Vaimo's rights in the Program may be available directly from
9
+ * Vaimo.
10
+ *
11
+ * Disclaimer:
12
+ * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF.
13
+ * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS
19
+ * IN THE PROGRAM.
20
+ *
21
+ * @category Vaimo
22
+ * @package Vaimo_Klarna
23
+ * @copyright Copyright (c) 2009-2014 Vaimo AB
24
+ */
25
+
26
+ $info = $this->getPaymentInfo();
27
+
28
+ ?>
29
+
30
+ <?php if ($info): ?>
31
+
32
+ <?php if ($info->getKlarnaNotice()): ?>
33
+ <?php foreach ($info->getKlarnaNotice() as $notice): ?>
34
+ <tr>
35
+ <td><?php echo Mage::helper('klarna')->__('Notice') . ': ' . '<strong style="color:orange">' . $notice . '</strong>';?></td>
36
+ </tr>
37
+ <?php endforeach; ?>
38
+ <?php endif; ?>
39
+
40
+ <?php endif; ?>
app/design/frontend/base/default/template/vaimo/klarna/info/children/reference.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2009-2014 Vaimo AB
4
+ *
5
+ * Vaimo reserves all rights in the Program as delivered. The Program
6
+ * or any portion thereof may not be reproduced in any form whatsoever without
7
+ * the written consent of Vaimo, except as provided by licence. A licence
8
+ * under Vaimo's rights in the Program may be available directly from
9
+ * Vaimo.
10
+ *
11
+ * Disclaimer:
12
+ * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF.
13
+ * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS
19
+ * IN THE PROGRAM.
20
+ *
21
+ * @category Vaimo
22
+ * @package Vaimo_Klarna
23
+ * @copyright Copyright (c) 2009-2014 Vaimo AB
24
+ */
25
+
26
+ $info = $this->getPaymentInfo();
27
+ ?>
28
+
29
+ <?php if ($info): ?>
30
+ <?php if ($info->getKlarnaReservationReference()): ?>
31
+ <tr>
32
+ <td><?php echo Mage::helper('klarna')->__('Reference') . ' ' . $info->getKlarnaReservationReference(); ?></td>
33
+ </tr>
34
+ <?php endif; ?>
35
+ <?php endif; ?>
app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/cart.phtml CHANGED
@@ -35,7 +35,7 @@
35
  <?php if (Mage::helper('klarna')->excludeCartInKlarnaCheckout()) : ?>
36
  <form id="klarna_cart" action="<?php echo $this->getUrl('checkout/klarna/cartUpdatePost') ?>" method="post">
37
  <input type="hidden" name="return_url" value="<?php echo $this->getUrl('checkout/klarna') ?>"/>
38
- <!-- <input type="hidden" id="klarna_cart_reload" name="klarna_cart_reload" value="<?php //echo $this->getUrl('checkout/klarna/getKlarnaWrapperHtml') ?>"/> -->
39
  <input type="hidden" id="klarna_checkout_reload" name="klarna_checkout_reload" value="<?php echo $this->getUrl('checkout/klarna/getKlarnaCheckout') ?>"/>
40
  </form>
41
  <?php else: ?>
@@ -105,7 +105,7 @@
105
  <tfoot>
106
  <tr>
107
  <td colspan="6">
108
- <a href="<?php echo $this->getContinueShoppingUrl() ?>" title="<?php echo $this->__('Continue Shopping') ?>">&lt;&lt; <?php echo $this->__('Continue Shopping') ?></a>
109
  </td>
110
  </tr>
111
  </tfoot>
35
  <?php if (Mage::helper('klarna')->excludeCartInKlarnaCheckout()) : ?>
36
  <form id="klarna_cart" action="<?php echo $this->getUrl('checkout/klarna/cartUpdatePost') ?>" method="post">
37
  <input type="hidden" name="return_url" value="<?php echo $this->getUrl('checkout/klarna') ?>"/>
38
+ <input type="hidden" id="klarna_cart_reload" name="klarna_cart_reload" value="<?php echo $this->getUrl('checkout/klarna/getKlarnaWrapperHtml', $cartUpdateParams) ?>"/>
39
  <input type="hidden" id="klarna_checkout_reload" name="klarna_checkout_reload" value="<?php echo $this->getUrl('checkout/klarna/getKlarnaCheckout') ?>"/>
40
  </form>
41
  <?php else: ?>
105
  <tfoot>
106
  <tr>
107
  <td colspan="6">
108
+ <a href="<?php echo $this->getContinueShoppingUrl() ?>" title="<?php echo Mage::helper('klarna')->quoteEscape($this->__('Continue Shopping')) ?>">&lt;&lt; <?php echo $this->__('Continue Shopping') ?></a>
109
  </td>
110
  </tr>
111
  </tfoot>
app/design/frontend/base/default/template/vaimo/klarna/klarnacheckout/header.phtml CHANGED
@@ -23,11 +23,15 @@
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
25
  ?>
 
 
 
 
26
 
27
  <div id="klarna_loader" class="klarna_loader"><img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>" alt="" id="klarna_loader_img" /></div>
28
 
29
  <div class="page-title">
30
- <h1 class="klarna_page-title"><?php echo $this->__('Shopping Cart') ?></h1>
31
  </div>
32
 
33
  <?php echo $this->getChildHtml('klarna_msg'); ?>
23
  * @copyright Copyright (c) 2009-2014 Vaimo AB
24
  */
25
  ?>
26
+ <?php
27
+ $_helper = Mage::helper('klarna');
28
+ ?>
29
+
30
 
31
  <div id="klarna_loader" class="klarna_loader"><img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>" alt="" id="klarna_loader_img" /></div>
32
 
33
  <div class="page-title">
34
+ <h1 class="klarna_page-title"><?php echo $_helper->__('Shopping Cart') ?></h1>
35
  </div>
36
 
37
  <?php echo $this->getChildHtml('klarna_msg'); ?>
app/locale/da_DK/Vaimo_Klarna.csv CHANGED
@@ -114,6 +114,7 @@
114
  "If checkbox for newsletter should be shown in checkout page.","Hvis afkrydsningsboksen til nyhedsbrev skal vises i kassen"
115
  "Checked by default","Markeret som standardindstilling"
116
  "A/B Testing settings","A/B testindstillinger"
 
117
  "Enable for IP range","Aktiver for IP-rækkevidde"
118
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Specificer to cifre mellem 0 og 255, adskilt med bindestreg. Eksempel: ”0-50”. En tom værdi aktiverer alle IP-adresser"
119
  "Enable for logged in Customers","Aktiver for kunder som er logget ind"
114
  "If checkbox for newsletter should be shown in checkout page.","Hvis afkrydsningsboksen til nyhedsbrev skal vises i kassen"
115
  "Checked by default","Markeret som standardindstilling"
116
  "A/B Testing settings","A/B testindstillinger"
117
+ "Activate A/B Testing","Activate A/B Testing"
118
  "Enable for IP range","Aktiver for IP-rækkevidde"
119
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Specificer to cifre mellem 0 og 255, adskilt med bindestreg. Eksempel: ”0-50”. En tom værdi aktiverer alle IP-adresser"
120
  "Enable for logged in Customers","Aktiver for kunder som er logget ind"
app/locale/de_AT/Vaimo_Klarna.csv CHANGED
@@ -114,6 +114,7 @@
114
  "If checkbox for newsletter should be shown in checkout page.","Wenn Kontrollbox für den Newsletter auf der Checkout Seite angezeigt werden soll."
115
  "Checked by default","Per Voreinstellung geprüft"
116
  "A/B Testing settings","A/B Testing Einstellungen"
 
117
  "Enable for IP range","Für IP-Bereich aktiveren"
118
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","SSpezifiziert Zahlen zwischen 2 und 255, durch “-” getrennt. Beispiel: '0-50'. Keine Eingabe ermöglicht alle IP Adressen"
119
  "Enable for logged in Customers","Für eingeloggte Kunden ermöglichen"
114
  "If checkbox for newsletter should be shown in checkout page.","Wenn Kontrollbox für den Newsletter auf der Checkout Seite angezeigt werden soll."
115
  "Checked by default","Per Voreinstellung geprüft"
116
  "A/B Testing settings","A/B Testing Einstellungen"
117
+ "Activate A/B Testing","Activate A/B Testing"
118
  "Enable for IP range","Für IP-Bereich aktiveren"
119
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","SSpezifiziert Zahlen zwischen 2 und 255, durch “-” getrennt. Beispiel: '0-50'. Keine Eingabe ermöglicht alle IP Adressen"
120
  "Enable for logged in Customers","Für eingeloggte Kunden ermöglichen"
app/locale/de_DE/Vaimo_Klarna.csv CHANGED
@@ -114,6 +114,7 @@
114
  "If checkbox for newsletter should be shown in checkout page.","Wenn Kontrollbox für den Newsletter auf der Checkout Seite angezeigt werden soll."
115
  "Checked by default","Per Voreinstellung geprüft"
116
  "A/B Testing settings","A/B Testing Einstellungen"
 
117
  "Enable for IP range","Für IP-Bereich aktiveren"
118
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","SSpezifiziert Zahlen zwischen 2 und 255, durch “-” getrennt. Beispiel: '0-50'. Keine Eingabe ermöglicht alle IP Adressen"
119
  "Enable for logged in Customers","Für eingeloggte Kunden ermöglichen"
114
  "If checkbox for newsletter should be shown in checkout page.","Wenn Kontrollbox für den Newsletter auf der Checkout Seite angezeigt werden soll."
115
  "Checked by default","Per Voreinstellung geprüft"
116
  "A/B Testing settings","A/B Testing Einstellungen"
117
+ "Activate A/B Testing","Activate A/B Testing"
118
  "Enable for IP range","Für IP-Bereich aktiveren"
119
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","SSpezifiziert Zahlen zwischen 2 und 255, durch “-” getrennt. Beispiel: '0-50'. Keine Eingabe ermöglicht alle IP Adressen"
120
  "Enable for logged in Customers","Für eingeloggte Kunden ermöglichen"
app/locale/fi_FI/Vaimo_Klarna.csv CHANGED
@@ -114,6 +114,7 @@
114
  "If checkbox for newsletter should be shown in checkout page.","Jos uutiskirjeen valintaruudun tulisi näkyä kassasivulla."
115
  "Checked by default","Oletuksena valittu"
116
  "A/B Testing settings","A/B-Testausasetukset"
 
117
  "Enable for IP range","Salli IP-alue"
118
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Valitse kaksi numeroa välillä 0 ja 255, viivalla erotettuna. Esimerkiksi: '0-50'. Tyhjä arvo sallii kaikki IP-osoitteet"
119
  "Enable for logged in Customers","Salli sisäänkirjautuneet asiakkaat"
@@ -171,3 +172,4 @@
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"
172
  "Shopping Cart","Ostoskori"
173
  "Choose shipping method","Valitse toimitustapa"
 
114
  "If checkbox for newsletter should be shown in checkout page.","Jos uutiskirjeen valintaruudun tulisi näkyä kassasivulla."
115
  "Checked by default","Oletuksena valittu"
116
  "A/B Testing settings","A/B-Testausasetukset"
117
+ "Activate A/B Testing","Activate A/B Testing"
118
  "Enable for IP range","Salli IP-alue"
119
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Valitse kaksi numeroa välillä 0 ja 255, viivalla erotettuna. Esimerkiksi: '0-50'. Tyhjä arvo sallii kaikki IP-osoitteet"
120
  "Enable for logged in Customers","Salli sisäänkirjautuneet asiakkaat"
172
  "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"
173
  "Shopping Cart","Ostoskori"
174
  "Choose shipping method","Valitse toimitustapa"
175
+ "Quantity","Määrä"
app/locale/nb_NO/Vaimo_Klarna.csv CHANGED
@@ -114,6 +114,7 @@
114
  "If checkbox for newsletter should be shown in checkout page.","If checkbox for newsletter should be shown in checkout page."
115
  "Checked by default","Checked by default"
116
  "A/B Testing settings","A/B Testing settings"
 
117
  "Enable for IP range","Enable for IP range"
118
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses"
119
  "Enable for logged in Customers","Enable for logged in Customers"
114
  "If checkbox for newsletter should be shown in checkout page.","If checkbox for newsletter should be shown in checkout page."
115
  "Checked by default","Checked by default"
116
  "A/B Testing settings","A/B Testing settings"
117
+ "Activate A/B Testing","Activate A/B Testing"
118
  "Enable for IP range","Enable for IP range"
119
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses"
120
  "Enable for logged in Customers","Enable for logged in Customers"
app/locale/nl_NL/Vaimo_Klarna.csv CHANGED
@@ -114,6 +114,7 @@
114
  "If checkbox for newsletter should be shown in checkout page.","De checkbox voor de nieuwsbrief moet worden weergegeven in de checkout pagina."
115
  "Checked by default","Default gecontroleerd"
116
  "A/B Testing settings","A/B test instellingen"
 
117
  "Enable for IP range","Geactiveerd voor IP range"
118
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses"
119
  "Enable for logged in Customers","Geactiveerd voor ingelogde klanten"
114
  "If checkbox for newsletter should be shown in checkout page.","De checkbox voor de nieuwsbrief moet worden weergegeven in de checkout pagina."
115
  "Checked by default","Default gecontroleerd"
116
  "A/B Testing settings","A/B test instellingen"
117
+ "Activate A/B Testing","Activate A/B Testing"
118
  "Enable for IP range","Geactiveerd voor IP range"
119
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses"
120
  "Enable for logged in Customers","Geactiveerd voor ingelogde klanten"
app/locale/nn_NO/Vaimo_Klarna.csv CHANGED
@@ -114,6 +114,7 @@
114
  "If checkbox for newsletter should be shown in checkout page.","If checkbox for newsletter should be shown in checkout page."
115
  "Checked by default","Checked by default"
116
  "A/B Testing settings","A/B Testing settings"
 
117
  "Enable for IP range","Enable for IP range"
118
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses"
119
  "Enable for logged in Customers","Enable for logged in Customers"
114
  "If checkbox for newsletter should be shown in checkout page.","If checkbox for newsletter should be shown in checkout page."
115
  "Checked by default","Checked by default"
116
  "A/B Testing settings","A/B Testing settings"
117
+ "Activate A/B Testing","Activate A/B Testing"
118
  "Enable for IP range","Enable for IP range"
119
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses"
120
  "Enable for logged in Customers","Enable for logged in Customers"
app/locale/sv_SE/Vaimo_Klarna.csv CHANGED
@@ -114,6 +114,7 @@
114
  "If checkbox for newsletter should be shown in checkout page.","Om checkboxen för nyhetsbrev ska visas i checkout"
115
  "Checked by default","Checkbox ifylld automatiskt"
116
  "A/B Testing settings","A/B testning inställningar"
 
117
  "Enable for IP range","Aktivera för IP intervall"
118
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Två siffror, separerade med minus tecken. Till exempel 0-50"
119
  "Enable for logged in Customers","Aktivera för inloggade kunder"
114
  "If checkbox for newsletter should be shown in checkout page.","Om checkboxen för nyhetsbrev ska visas i checkout"
115
  "Checked by default","Checkbox ifylld automatiskt"
116
  "A/B Testing settings","A/B testning inställningar"
117
+ "Activate A/B Testing","Aktivera A/B testning"
118
  "Enable for IP range","Aktivera för IP intervall"
119
  "Specify 2 numbers between 0 and 255, separated by dash. Example: '0-50'. Empty value enables all IP addresses","Två siffror, separerade med minus tecken. Till exempel 0-50"
120
  "Enable for logged in Customers","Aktivera för inloggade kunder"
js/vaimo/klarna/klarnacheckout.js CHANGED
@@ -14,7 +14,7 @@ function refreshCheckout(data) {
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
  klarnaQtyInput = typeof window.klarnaQtyInput != 'undefined' ? window.klarnaQtyInput : null,
20
  klarnaQty = typeof window.klarnaQtyInputQuantity != 'undefined' ? window.klarnaQtyInputQuantity : null;;
@@ -36,11 +36,15 @@ function refreshCheckout(data) {
36
  klarnaCartValue = klarnaCartHtml.value;
37
  }
38
 
39
- vanillaAjax(
40
- klarnaCartValue,
41
- '',
42
- updateSections, '', '', false
43
- );
 
 
 
 
44
  } else if (obj.error) {
45
  window.reloadKlarnaIFrameFlag = false;
46
  klarnaMsgContent.innerHTML = obj.error;
@@ -430,7 +434,7 @@ function registerKlarnaApiChange()
430
  _klarnaCheckout(function(api) {
431
  api.on({
432
  'change': function(data) {
433
- showLoader();
434
  var url = document.getElementById('klarna-checkout-shipping-update').value;
435
  vanillaAjax(url, 'email=' + data.email +
436
  '&firstname=' + data.given_name +
@@ -452,7 +456,7 @@ function registerKlarnaApiChange()
452
  _klarnaCheckout(function(api) {
453
  api.on({
454
  'shipping_address_change': function(data) {
455
- showLoader();
456
  var url = document.getElementById('klarna-checkout-shipping-update-postcode').value;
457
  vanillaAjax(url, 'email=' + data.email +
458
  '&firstname=' + data.given_name +
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"), // Will now exist, even if cart is disabled
18
  klarnaHtml = document.getElementById("klarna_checkout_reload"),
19
  klarnaQtyInput = typeof window.klarnaQtyInput != 'undefined' ? window.klarnaQtyInput : null,
20
  klarnaQty = typeof window.klarnaQtyInputQuantity != 'undefined' ? window.klarnaQtyInputQuantity : null;;
36
  klarnaCartValue = klarnaCartHtml.value;
37
  }
38
 
39
+ if (klarnaCartValue) {
40
+ vanillaAjax(
41
+ klarnaCartValue,
42
+ '',
43
+ updateSections, '', '', false
44
+ );
45
+ } else {
46
+ hideLoader();
47
+ }
48
  } else if (obj.error) {
49
  window.reloadKlarnaIFrameFlag = false;
50
  klarnaMsgContent.innerHTML = obj.error;
434
  _klarnaCheckout(function(api) {
435
  api.on({
436
  'change': function(data) {
437
+ // showLoader();
438
  var url = document.getElementById('klarna-checkout-shipping-update').value;
439
  vanillaAjax(url, 'email=' + data.email +
440
  '&firstname=' + data.given_name +
456
  _klarnaCheckout(function(api) {
457
  api.on({
458
  'shipping_address_change': function(data) {
459
+ // showLoader();
460
  var url = document.getElementById('klarna-checkout-shipping-update-postcode').value;
461
  vanillaAjax(url, 'email=' + data.email +
462
  '&firstname=' + data.given_name +
js/vaimo/klarna/klarnautils.js CHANGED
@@ -262,6 +262,7 @@ HTMLFormElement.prototype.serialize = function(asObject) {
262
  /* Omit this types */
263
  break;
264
  case 'radio':
 
265
  if (element.checked) {
266
  add(element.name, element.value);
267
  }
262
  /* Omit this types */
263
  break;
264
  case 'radio':
265
+ case 'checkbox':
266
  if (element.checked) {
267
  add(element.name, element.value);
268
  }
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>klarnapayments</name>
4
- <version>5.3.1</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-06-17</date>
14
- <time>15:12:58</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="ade52495b519d3cfd6f53a4285be895f"/></dir></dir><dir name="checkout"><file name="fee.phtml" hash="3a58d7e7278bf9fcae1cdb9d836d4ff3"/><file name="header.phtml" hash="51a7f95f2fcb5f7b02e19b13690631a8"/><file name="top.phtml" hash="9cc1ce32346bd6ed7c16139f3f960a95"/></dir><dir name="form"><file name="account.phtml" hash="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="487de8f489b7e65416bf3559e1819abd"/><file name="autofill.phtml" hash="6bdd6c22fd1771106f52876e66d7f4de"/><dir name="cart"><dir name="item"><file name="default.phtml" hash="cb76c84ce20dbd391a1615756f2d72d7"/></dir><file name="totals.phtml" hash="a8496f65d2bd8390cee2bb5c89bad555"/></dir><file name="cart.phtml" hash="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="f619075a30bf6240753a186636b5c2f4"/><file name="reward.phtml" hash="0e1d0a7d42738662fddd04dab09f5765"/><dir name="shipping_method"><file name="available.phtml" hash="62991e138e2a296fc0aff83ebfae2aea"/></dir><file name="shipping_method.phtml" hash="78afd96ad7c9facd083673c1122e6d42"/><file name="sidebar.phtml" hash="a8c13bf43d0c415f153d198a2bb6fa1f"/><file name="success.phtml" hash="b1f276ce825e09d472aef29d631ddf7b"/></dir><dir name="page"><dir name="html"><file name="logo.phtml" hash="fb2d29e255453128bbdf37218289caf1"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vaimo_Klarna.xml" hash="fece558fa050794401aca834b1b12fd4"/></dir></target><target name="magelocale"><dir name="da_DK"><file name="Vaimo_Klarna.csv" hash="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="5314f647852b0fef0e4dbe6c0f03bae0"/></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="ff4dd375e6bcd9ae0a27e53fb7799825"/><file name="klarnautils.js" hash="d7cea514ef3e9adc4f7d9a107b1a838f"/></dir></dir></dir></target><target name="magelib"><dir name="Klarna"><file name="CHANGELOG" hash="9808fe4dfd049d5130f7088adc374d72"/><file name="Changelog-Vaimo.txt" hash="b4f3e9df96ec0afcaf81ba1417fd7ebe"/><dir name="Checkout"><file name="BasicConnector.php" hash="8a9d008cda8e0805537b70d1e0e3bcd5"/><file name="ConnectionErrorException.php" hash="352ae3f5bbb18c04f0a9d3ca1be30faf"/><file name="Connector.php" hash="199d9134e8c5188e5b8f958ac1f17029"/><file name="ConnectorException.php" hash="fe4017579c8757798e018fb0755496c0"/><file name="ConnectorInterface.php" hash="0ebfd5610fec6ddce7b7fd0f45f3d1d6"/><file name="Digest.php" hash="d7c2ea4ff1f22c8919685aad7e4e9c8b"/><file name="Exception.php" hash="31a95e8212f01d149265f75e20b31bcb"/><dir name="HTTP"><file name="CURLFactory.php" hash="591493c487797a80fd76f4f80ca598d0"/><file name="CURLHandle.php" hash="2d58ba553ffddafdcc9c80bea0c2c5ee"/><file name="CURLHandleInterface.php" hash="df5e3ddf82deb09164c75249c7235756"/><file name="CURLHeaders.php" hash="2a900efb8591defaf9230368403c975f"/><file name="CURLTransport.php" hash="c35a9910a04007372c2d6673f4657b89"/><file name="Request.php" hash="180f04ffd522b713b4261087a7e60c68"/><file name="Response.php" hash="86993580c2a11b14bab4af6328caa6de"/><file name="Transport.php" hash="4aa96d5086e105d79b0f97593fbe5d9b"/><file name="TransportInterface.php" hash="3d6aab36479741136c9dee1bbcf3914e"/></dir><file name="Order.php" hash="568242a47b838ae9abf8438a4bc7301e"/><file name="ResourceInterface.php" hash="55fc925edc0f69a89f2d79e348152a2c"/><file name="UserAgent.php" hash="ee6a35f67e56391f5bdfa387616e5618"/></dir><file name="Checkout.php" hash="6e16bb237ecfc54f086a0d533a8e69e3"/><file name="CheckoutServiceRequest.php" hash="1167bf796772a24c5cf56586c255715b"/><file name="CheckoutServiceResponse.php" hash="021edd2464930618a0de024ea9bfc9f7"/><file name="Country.php" hash="449272bb9d3c4cf023137ab85266546c"/><file name="CurlHandle.php" hash="d7418f2db8bf726cb2913e10ce9a63ce"/><file name="CurlTransport.php" hash="03599602490c2089d7609c3006fe392c"/><file name="Currency.php" hash="b11ecbc754029f8b1d99d361b7daa2d3"/><file name="Encoding.php" hash="1893ca72010090f41ab5fab9a9a0029b"/><file name="Exceptions.php" hash="a94eb2811f2004c7e87ba5a82bd61d40"/><file name="Flags.php" hash="dcb034831717186be38530f52a39b24e"/><file name="Klarna.php" hash="849fa477cb91df3a0156e6c5f62c4aea"/><file name="Language.php" hash="a89d7e2d756db8ae94b5b2177507c319"/><dir name="checkoutkpm"><file name="checkouthtml.intf.php" hash="f6cc7512fbb13c0446d8492f747cd436"/><file name="threatmetrix.class.php" hash="ec5ceb6742df44623d96ce321c24fba5"/></dir><dir name="examples"><file name="activate.php" hash="3e2dbb97106ee405253330de0aa826d8"/><file name="cancelReservation.php" hash="948a933b769dea6a9684731adb471b8c"/><file name="checkOrderStatus.php" hash="1229fc0c6c96dbd81eec8d8919c4add5"/><file name="checkoutService.php" hash="fbaf5d7764d93fbc1b220e5f90518a90"/><file name="creditInvoice.php" hash="32669c3a1e52e716147ca63f0063c4a2"/><file name="creditPart.php" hash="594631f8358a32de1083ad98417feafe"/><file name="emailInvoice.php" hash="3c0d6ce69e2e33a85ea3f0e2d5c6fc7e"/><file name="fetchPClasses.php" hash="7bf7620a596da1edb52436e4f188827d"/><file name="getAddresses.php" hash="cf5eed9d9b772983f8e41a39b374c6ab"/><file name="hasAccount.php" hash="29670e02a3178df1afccbfb911474a6a"/><file name="helperFunctions.php" hash="3b25b4f51f83e156c33dadc6dcbb2097"/><file name="reserveAmount.php" hash="aa140d9548e31cade6c42a38e78f64df"/><file name="reserveOCR.php" hash="fcadfe8c99debda5a8f935b7fbc1ba4e"/><file name="returnAmount.php" hash="ef600f9a84d62fcce825f66bb1b570e2"/><file name="sendInvoice.php" hash="2e2a53099c64daeb9f06abd81af2a0f5"/><file name="splitReservation.php" hash="ec2d26bae9dae03679f5272b7782a4e1"/><file name="update.php" hash="6e1fcd9f371cc4b12caca37933a51a55"/></dir><file name="klarnaaddr.php" hash="01075b4e2dd3987ef38efaa6b1ced54b"/><file name="klarnacalc.php" hash="2df31b6126716e91eaeea90f7ab2ca87"/><file name="klarnaconfig.php" hash="369278865db177e690b6d7757ca38c07"/><file name="klarnapclass.php" hash="30c5f867b8c8febc944871e75d240e65"/><dir name="pclasses"><file name="jsonstorage.class.php" hash="04f0d90ada9fd12d5f0de6448466f798"/><file name="mysqlstorage.class.php" hash="ad2d075301d730f97c7a895a2ebb7523"/><file name="sqlstorage.class.php" hash="e00df72512eac3998710a4b2f9ea89c8"/><file name="storage.intf.php" hash="032631d1f075d1eff09ccf926ea56417"/><file name="xmlstorage.class.php" hash="a47820de9cdcfb261de0e95fc92a2a64"/></dir><dir name="transport"><dir name="xmlrpc-3.0.0.beta"><dir name="lib"><file name="xmlrpc.inc" hash="5a74ea2a831648febc9b2c8f809b252c"/><file name="xmlrpc_wrappers.inc" hash="5aa00141ead09fc5498d9a3c9fcab888"/><file name="xmlrpcs.inc" hash="158b97bda79333e9b40793d876b6e98f"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="vaimo"><dir name="klarna"><dir name="css"><file name="admin.css" hash="ef4915be839e2039fb037f29c1506d30"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="vaimo"><dir name="klarna"><file name="checkout.css" hash="7d7fe12675f4ba51ad1fd608849f06ce"/><file name="checkout_osc.css" hash="126a8d2869872306ded4aef943db809c"/><file name="global.css" hash="22b6a446e6e874e6a95608f7046eac2a"/><file name="klarnacheckout.css" hash="00c9b9ec2e2458207a7e6a8fe061529a"/><file name="klarnadefault.css" hash="30bff2ef19a5a70b4ee9a458c504870c"/><file name="product.css" hash="ef6a838858ceb0c1ef6364bb089273c0"/><dir name="vendor"><file name="bootstrap-grid.css" hash="093d2cb25f2e4d0bc80233ed70cbcb9a"/><file name="bootstrap-grid.min.css" hash="9087d9a8c2457c96b6c216fea959b298"/><file name="fontawesome.css" hash="76ca4ed8592634fb5c421b4e19c35918"/><file name="fontawesome.min.css" hash="7b7b345da453c034563dd2ac7ca9666b"/><dir name="fonts"><file name="FontAwesome.otf" hash="19231917733e2bcdf257c9be99cdbaf1"/><file name="fontawesome-webfont.eot" hash="7149833697a959306ec3012a8588dcfa"/><file name="fontawesome-webfont.svg" hash="65bcbc899f379216109acd0b6c494618"/><file name="fontawesome-webfont.ttf" hash="c4668ed2440df82d3fd2f8be9d31d07d"/><file name="fontawesome-webfont.woff" hash="d95d6f5d5ab7cfefd09651800b69bd54"/></dir></dir></dir></dir></dir><dir name="images"><dir name="vaimo"><dir name="klarna"><file name="balk_afm3.jpg" hash="8855567960bff35b1e3ba486670b5878"/><file name="icons.png" hash="7f0808d4cf63c3d43637d40a703f30fe"/></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Vaimo"><dir name="Klarna"><dir name="Block"><dir name="Adminhtml"><dir name="Pclass"><file name="List.php" hash="7c68e3ec74e5cea1b62bb0218d297089"/><file name="Update.php" hash="fd444645b9f78fc4ea65c91ee3fc0044"/></dir><dir name="Sales"><dir name="Creditmemo"><dir name="Create"><file name="Adjustments.php" hash="12074f6aabbe90f14b8d30b7f65da9dc"/></dir><file name="Totals.php" hash="198afd117e90e17999f24c419a92b24b"/></dir><dir name="Invoice"><file name="Totals.php" hash="bc28f21c484fe2b4ca6d7a06da726fc3"/></dir><dir name="Order"><file name="Totals.php" hash="c80ca5283b0341964c36e70a850faaf6"/></dir></dir></dir><dir name="Catalog"><dir name="Product"><file name="Pricewidget.php" hash="a77d8ca953136f3fe9797166f8a51e93"/></dir></dir><dir name="Checkout"><file name="Fee.php" hash="1ffae1896b12e6d87fbbd2d3843fef75"/><file name="Top.php" hash="a8f9084322c1f924ef6fb4802908019d"/></dir><dir name="Form"><file name="Abstract.php" hash="da5fa0957ab2b1e3b57ca99a9323fadb"/><file name="Account.php" hash="f6bf008c1af0b93ead5b5a2577b59ea5"/><dir name="Address"><file name="Search.php" hash="439e9f9a5d9480a4356043bb73f9c9c7"/></dir><file name="Checkout.php" hash="a7e6876317a29184f07040b646b84ec7"/><file name="Invoice.php" hash="105a41b84e52b45f26f3c5de2d4bdd4a"/><dir name="Paymentplan"><file name="Information.php" hash="7c66acd887a1e3a165e3cd967d0f3331"/></dir><file name="Special.php" hash="8db5a5f33510cd32d724c6ecd6368aa2"/></dir><dir name="Info"><file name="Abstract.php" hash="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="ee3f18170c2fcb885076b36d06c8db5e"/><file name="Newsletter.php" hash="ce97e11c097b0cd9696919936fa59dc6"/><file name="Othermethod.php" hash="48594b48a64dc1116e3eef44a742e472"/><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="083176de18ddace804584806e8bcdfe5"/></dir><file name="LoginController.php" hash="bc5e1832feaa3401f553c62d7473155b"/><file name="PaymentplanController.php" hash="fea9d33a5dbd5d4858ef174569dae636"/></dir><dir name="etc"><file name="config.xml" hash="069a9a452cbddd7ef36233244dbb69df"/><file name="system.xml" hash="c7790aeda2d2a2ec059de9d5c882cd06"/></dir><dir name="Helper"><file name="Data.php" hash="37d84e62d8e7bc3153b8a6213b00826d"/></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="a63eb99e4cc5d9abd23d2424fb01a1d2"/><file name="Rest.php" hash="bf1b9743df4dd991d78ccde1be085317"/><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="5d7377da11ad7cbd26a8c6f14d24bbe2"/><file name="Observer.php" hash="f44cdd7b899c5eceb12da74ab80937d1"/><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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>klarnapayments</name>
4
+ <version>5.3.24</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-11-20</date>
14
+ <time>14:48:38</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="vaimo_klarna.xml" hash="19a196d33bcc2e1eaf4413dcefeb5f04"/></dir><dir name="template"><dir name="vaimo"><dir name="klarna"><dir name="creditmemo"><dir name="totals"><file name="adjustments.phtml" hash="b0299ac0b1ca75b4d143413cc8eb8217"/></dir></dir><dir name="info"><file name="account.phtml" hash="4c51cb3b4aeb54bb009e384d300ece98"/><file name="checkout.phtml" hash="679e88a49ec331cec8df1b8f09e39758"/><dir name="children"><file name="invoicefee.phtml" hash="2b721be479706716f6468c8395455fa5"/><file name="invoices.phtml" hash="ac4e3bd4aea83e9ea3479fc04ed0d5a4"/><file name="notices.phtml" hash="a5053c7829df05fd8afb30d5019b1aca"/><file name="paymentplan.phtml" hash="885c020c05afd4516a42a33a6986f32f"/><file name="reference.phtml" hash="a789d5c8d4253c6ba4d894e2f0465f9c"/><file name="reservation.phtml" hash="d96f36640577e8e053050c24bfb4ec43"/></dir><file name="invoice.phtml" hash="498a1d706ac1da4fc71982f1232de492"/><file name="special.phtml" hash="4c51cb3b4aeb54bb009e384d300ece98"/></dir><dir name="pclass"><file name="list.phtml" hash="5cef6b0093bb5da18dbf1f9fd7316c66"/><file name="update.phtml" hash="ed53d5eb248f8181cd601e7b10cb170f"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="vaimo_klarna.xml" hash="4fda0bc7525f55705ef334c26f10a36d"/></dir><dir name="template"><dir name="vaimo"><dir name="klarna"><dir name="catalog"><dir name="product"><file name="pricewidget.phtml" hash="ade52495b519d3cfd6f53a4285be895f"/></dir></dir><dir name="checkout"><file name="fee.phtml" hash="3a58d7e7278bf9fcae1cdb9d836d4ff3"/><file name="header.phtml" hash="51a7f95f2fcb5f7b02e19b13690631a8"/><file name="top.phtml" hash="9cc1ce32346bd6ed7c16139f3f960a95"/></dir><dir name="form"><file name="account.phtml" hash="7b763a6452a9268b2489885cf7e2bb98"/><dir name="address"><file name="search.phtml" hash="473e03908fdb841f7152ed78671fcef0"/></dir><file name="checkout.phtml" hash="fe86056c73f86d53a73ebda5c5f3547c"/><dir name="children"><file name="addressresult.phtml" hash="4bb8fd4309c9b4012bfeb2d31c90076a"/><file name="checkoutservice.phtml" hash="3ae5ecf2420cb457304ef0b9f4227b9c"/><file name="consent.phtml" hash="a4f446258fa20a453d3566cffc20085d"/><file name="dateofbirth.phtml" hash="e1dbe367ce43029d671dae6f7d3ca956"/><file name="gender.phtml" hash="c8428e9b76db957a866cfc109d7a0c09"/><file name="notifications.phtml" hash="2d91f392c4c2fee89ada3c53719dc47f"/><file name="paymentplan_information.phtml" hash="8f28c418c08df3e664744ef28bc283c3"/><file name="pclass.phtml" hash="848a7e485badbdf11d10628c93906b21"/><file name="personalnumber.phtml" hash="dcea08f692ed978689242ba8309f3cdb"/><file name="phonenumber.phtml" hash="6348b12795e073d8881ab0b74d7df175"/></dir><file name="invoice.phtml" hash="0c1053b8b024035ab023fd39c473752b"/><dir name="paymentplan"><file name="information.phtml" hash="d013f147f38502cb4baf591d56d177d9"/></dir><file name="special.phtml" hash="05ada24ff6c7cb813f498920eddd90bb"/></dir><dir name="info"><file name="account.phtml" hash="a848c9544a5e400bc27e26d050eafa3c"/><file name="checkout.phtml" hash="cbcd2d9379f2afbd450fb925c05aa4ed"/><dir name="children"><file name="invoicefee.phtml" hash="c6b4ccff75e220c5641a8fadd6753131"/><file name="invoices.phtml" hash="892672664fe645193471a26bb052c18b"/><file name="notices.phtml" hash="26571bbd4c152f4f39c5b0281adff251"/><file name="paymentplan.phtml" hash="3a73d918dc733c0888f18e442f9eb64c"/><file name="reference.phtml" hash="60e6eaabc7ff88a7762ce97c45d151e0"/><file name="reservation.phtml" hash="9880ef8208f672d531cc10eef8467856"/></dir><file name="invoice.phtml" hash="cd3514e43dd441b4530b95e408784d84"/><file name="special.phtml" hash="c472684055c8839b8e365b80a5e1ee0c"/></dir><dir name="klarnacheckout"><file name="account-login.phtml" hash="487de8f489b7e65416bf3559e1819abd"/><file name="autofill.phtml" hash="6bdd6c22fd1771106f52876e66d7f4de"/><dir name="cart"><dir name="item"><file name="default.phtml" hash="cb76c84ce20dbd391a1615756f2d72d7"/></dir><file name="totals.phtml" hash="a8496f65d2bd8390cee2bb5c89bad555"/></dir><file name="cart.phtml" hash="9dd4348207c7bab904a92e51da1126ec"/><file name="checkout.phtml" hash="c71826694ac6270f82a05e69a896d66b"/><dir name="customer"><file name="balance.phtml" hash="af890728b26b0808c299ab199bc5f4c0"/></dir><file name="default.phtml" hash="357abf99f4cb926d728c7c5253ea4b1e"/><dir name="discount"><file name="coupon.phtml" hash="0e4c2c52f677212b2071e3acddcc217a"/><file name="giftcardaccount.phtml" hash="8895e32abbc97d84fce366221637a1d9"/></dir><file name="discount.phtml" hash="7ce3289506c3e8abdd4af610e0f7f273"/><file name="header.phtml" hash="d25937ce1facfe47e16e63dff56e337a"/><file name="klarnacheckout.phtml" hash="a51ee31586f4cbeb5bfe0ffe1ca32c84"/><file name="main.phtml" hash="079d3162d46b762574eb2cd4641c14c2"/><file name="msg.phtml" hash="d716a2a466835c99f71bea1742533cc0"/><file name="newsletter.phtml" hash="34e007c7bd516cd37e93cb5bd9f19478"/><file name="othermethod.phtml" hash="f619075a30bf6240753a186636b5c2f4"/><file name="reward.phtml" hash="0e1d0a7d42738662fddd04dab09f5765"/><dir name="shipping_method"><file name="available.phtml" hash="62991e138e2a296fc0aff83ebfae2aea"/></dir><file name="shipping_method.phtml" hash="78afd96ad7c9facd083673c1122e6d42"/><file name="sidebar.phtml" hash="a8c13bf43d0c415f153d198a2bb6fa1f"/><file name="success.phtml" hash="b1f276ce825e09d472aef29d631ddf7b"/></dir><dir name="page"><dir name="html"><file name="logo.phtml" hash="fb2d29e255453128bbdf37218289caf1"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vaimo_Klarna.xml" hash="fece558fa050794401aca834b1b12fd4"/></dir></target><target name="magelocale"><dir name="da_DK"><file name="Vaimo_Klarna.csv" hash="867abdb2985a30f0dd4c0fc29d55f481"/></dir><dir name="de_AT"><file name="Vaimo_Klarna.csv" hash="f1006c802ab50acd76a8f1b9e060461b"/></dir><dir name="de_DE"><file name="Vaimo_Klarna.csv" hash="9707fefff9e5debda444de8ec7805ba7"/></dir><dir name="fi_FI"><file name="Vaimo_Klarna.csv" hash="69252093f9de3450c82c21f54a1e2215"/></dir><dir name="nb_NO"><file name="Vaimo_Klarna.csv" hash="29fced20f334587c190cbc4ab8a310da"/></dir><dir name="nl_NL"><file name="Vaimo_Klarna.csv" hash="81c5a6c11d1adf5ab0fd114f53d9fcb8"/></dir><dir name="nn_NO"><file name="Vaimo_Klarna.csv" hash="6bbb8c704ed2f19a943fd8dbc6338e58"/></dir><dir name="sv_SE"><file name="Vaimo_Klarna.csv" hash="de4fc631edc9e8d11f292589f29aa1da"/></dir></target><target name="mage"><dir name="js"><dir name="vaimo"><dir name="klarna"><file name="klarna.js" hash="9462fee4ca415ee3d11a00d8b85548ec"/><file name="klarnacheckout.js" hash="5d752b81f028b2c7a8a98671350554da"/><file name="klarnautils.js" hash="61f549cd61d81ea27dea5c22e58c005e"/></dir></dir></dir></target><target name="magelib"><dir name="Klarna"><file name="CHANGELOG" hash="9808fe4dfd049d5130f7088adc374d72"/><file name="Changelog-Vaimo.txt" hash="b4f3e9df96ec0afcaf81ba1417fd7ebe"/><dir name="Checkout"><file name="BasicConnector.php" hash="8a9d008cda8e0805537b70d1e0e3bcd5"/><file name="ConnectionErrorException.php" hash="352ae3f5bbb18c04f0a9d3ca1be30faf"/><file name="Connector.php" hash="199d9134e8c5188e5b8f958ac1f17029"/><file name="ConnectorException.php" hash="fe4017579c8757798e018fb0755496c0"/><file name="ConnectorInterface.php" hash="0ebfd5610fec6ddce7b7fd0f45f3d1d6"/><file name="Digest.php" hash="d7c2ea4ff1f22c8919685aad7e4e9c8b"/><file name="Exception.php" hash="31a95e8212f01d149265f75e20b31bcb"/><dir name="HTTP"><file name="CURLFactory.php" hash="591493c487797a80fd76f4f80ca598d0"/><file name="CURLHandle.php" hash="2d58ba553ffddafdcc9c80bea0c2c5ee"/><file name="CURLHandleInterface.php" hash="df5e3ddf82deb09164c75249c7235756"/><file name="CURLHeaders.php" hash="2a900efb8591defaf9230368403c975f"/><file name="CURLTransport.php" hash="c35a9910a04007372c2d6673f4657b89"/><file name="Request.php" hash="180f04ffd522b713b4261087a7e60c68"/><file name="Response.php" hash="86993580c2a11b14bab4af6328caa6de"/><file name="Transport.php" hash="4aa96d5086e105d79b0f97593fbe5d9b"/><file name="TransportInterface.php" hash="3d6aab36479741136c9dee1bbcf3914e"/></dir><file name="Order.php" hash="568242a47b838ae9abf8438a4bc7301e"/><file name="ResourceInterface.php" hash="55fc925edc0f69a89f2d79e348152a2c"/><file name="UserAgent.php" hash="ee6a35f67e56391f5bdfa387616e5618"/></dir><file name="Checkout.php" hash="6e16bb237ecfc54f086a0d533a8e69e3"/><file name="CheckoutServiceRequest.php" hash="1167bf796772a24c5cf56586c255715b"/><file name="CheckoutServiceResponse.php" hash="021edd2464930618a0de024ea9bfc9f7"/><file name="Country.php" hash="449272bb9d3c4cf023137ab85266546c"/><file name="CurlHandle.php" hash="d7418f2db8bf726cb2913e10ce9a63ce"/><file name="CurlTransport.php" hash="03599602490c2089d7609c3006fe392c"/><file name="Currency.php" hash="b11ecbc754029f8b1d99d361b7daa2d3"/><file name="Encoding.php" hash="1893ca72010090f41ab5fab9a9a0029b"/><file name="Exceptions.php" hash="a94eb2811f2004c7e87ba5a82bd61d40"/><file name="Flags.php" hash="dcb034831717186be38530f52a39b24e"/><file name="Klarna.php" hash="849fa477cb91df3a0156e6c5f62c4aea"/><file name="Language.php" hash="a89d7e2d756db8ae94b5b2177507c319"/><dir name="checkoutkpm"><file name="checkouthtml.intf.php" hash="f6cc7512fbb13c0446d8492f747cd436"/><file name="threatmetrix.class.php" hash="ec5ceb6742df44623d96ce321c24fba5"/></dir><dir name="examples"><file name="activate.php" hash="3e2dbb97106ee405253330de0aa826d8"/><file name="cancelReservation.php" hash="948a933b769dea6a9684731adb471b8c"/><file name="checkOrderStatus.php" hash="1229fc0c6c96dbd81eec8d8919c4add5"/><file name="checkoutService.php" hash="fbaf5d7764d93fbc1b220e5f90518a90"/><file name="creditInvoice.php" hash="32669c3a1e52e716147ca63f0063c4a2"/><file name="creditPart.php" hash="594631f8358a32de1083ad98417feafe"/><file name="emailInvoice.php" hash="3c0d6ce69e2e33a85ea3f0e2d5c6fc7e"/><file name="fetchPClasses.php" hash="7bf7620a596da1edb52436e4f188827d"/><file name="getAddresses.php" hash="cf5eed9d9b772983f8e41a39b374c6ab"/><file name="hasAccount.php" hash="29670e02a3178df1afccbfb911474a6a"/><file name="helperFunctions.php" hash="3b25b4f51f83e156c33dadc6dcbb2097"/><file name="reserveAmount.php" hash="aa140d9548e31cade6c42a38e78f64df"/><file name="reserveOCR.php" hash="fcadfe8c99debda5a8f935b7fbc1ba4e"/><file name="returnAmount.php" hash="ef600f9a84d62fcce825f66bb1b570e2"/><file name="sendInvoice.php" hash="2e2a53099c64daeb9f06abd81af2a0f5"/><file name="splitReservation.php" hash="ec2d26bae9dae03679f5272b7782a4e1"/><file name="update.php" hash="6e1fcd9f371cc4b12caca37933a51a55"/></dir><file name="klarnaaddr.php" hash="01075b4e2dd3987ef38efaa6b1ced54b"/><file name="klarnacalc.php" hash="2df31b6126716e91eaeea90f7ab2ca87"/><file name="klarnaconfig.php" hash="369278865db177e690b6d7757ca38c07"/><file name="klarnapclass.php" hash="30c5f867b8c8febc944871e75d240e65"/><dir name="pclasses"><file name="jsonstorage.class.php" hash="04f0d90ada9fd12d5f0de6448466f798"/><file name="mysqlstorage.class.php" hash="ad2d075301d730f97c7a895a2ebb7523"/><file name="sqlstorage.class.php" hash="e00df72512eac3998710a4b2f9ea89c8"/><file name="storage.intf.php" hash="032631d1f075d1eff09ccf926ea56417"/><file name="xmlstorage.class.php" hash="a47820de9cdcfb261de0e95fc92a2a64"/></dir><dir name="transport"><dir name="xmlrpc-3.0.0.beta"><dir name="lib"><file name="xmlrpc.inc" hash="5a74ea2a831648febc9b2c8f809b252c"/><file name="xmlrpc_wrappers.inc" hash="5aa00141ead09fc5498d9a3c9fcab888"/><file name="xmlrpcs.inc" hash="158b97bda79333e9b40793d876b6e98f"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="vaimo"><dir name="klarna"><dir name="css"><file name="admin.css" hash="ef4915be839e2039fb037f29c1506d30"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="vaimo"><dir name="klarna"><file name="checkout.css" hash="7d7fe12675f4ba51ad1fd608849f06ce"/><file name="checkout_osc.css" hash="126a8d2869872306ded4aef943db809c"/><file name="global.css" hash="22b6a446e6e874e6a95608f7046eac2a"/><file name="klarnacheckout.css" hash="00c9b9ec2e2458207a7e6a8fe061529a"/><file name="klarnadefault.css" hash="30bff2ef19a5a70b4ee9a458c504870c"/><file name="product.css" hash="ef6a838858ceb0c1ef6364bb089273c0"/><dir name="vendor"><file name="bootstrap-grid.css" hash="093d2cb25f2e4d0bc80233ed70cbcb9a"/><file name="bootstrap-grid.min.css" hash="9087d9a8c2457c96b6c216fea959b298"/><file name="fontawesome.css" hash="76ca4ed8592634fb5c421b4e19c35918"/><file name="fontawesome.min.css" hash="7b7b345da453c034563dd2ac7ca9666b"/><dir name="fonts"><file name="FontAwesome.otf" hash="19231917733e2bcdf257c9be99cdbaf1"/><file name="fontawesome-webfont.eot" hash="7149833697a959306ec3012a8588dcfa"/><file name="fontawesome-webfont.svg" hash="65bcbc899f379216109acd0b6c494618"/><file name="fontawesome-webfont.ttf" hash="c4668ed2440df82d3fd2f8be9d31d07d"/><file name="fontawesome-webfont.woff" hash="d95d6f5d5ab7cfefd09651800b69bd54"/></dir></dir></dir></dir></dir><dir name="images"><dir name="vaimo"><dir name="klarna"><file name="balk_afm3.jpg" hash="8855567960bff35b1e3ba486670b5878"/><file name="icons.png" hash="7f0808d4cf63c3d43637d40a703f30fe"/></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Vaimo"><dir name="Klarna"><dir name="Block"><dir name="Adminhtml"><dir name="Pclass"><file name="List.php" hash="7c68e3ec74e5cea1b62bb0218d297089"/><file name="Update.php" hash="fd444645b9f78fc4ea65c91ee3fc0044"/></dir><dir name="Sales"><dir name="Creditmemo"><dir name="Create"><file name="Adjustments.php" hash="12074f6aabbe90f14b8d30b7f65da9dc"/></dir><file name="Totals.php" hash="198afd117e90e17999f24c419a92b24b"/></dir><dir name="Invoice"><file name="Totals.php" hash="bc28f21c484fe2b4ca6d7a06da726fc3"/></dir><dir name="Order"><file name="Totals.php" hash="c80ca5283b0341964c36e70a850faaf6"/></dir></dir></dir><dir name="Catalog"><dir name="Product"><file name="Pricewidget.php" hash="a77d8ca953136f3fe9797166f8a51e93"/></dir></dir><dir name="Checkout"><file name="Fee.php" hash="1ffae1896b12e6d87fbbd2d3843fef75"/><file name="Top.php" hash="a8f9084322c1f924ef6fb4802908019d"/></dir><dir name="Form"><file name="Abstract.php" hash="da5fa0957ab2b1e3b57ca99a9323fadb"/><file name="Account.php" hash="f6bf008c1af0b93ead5b5a2577b59ea5"/><dir name="Address"><file name="Search.php" hash="439e9f9a5d9480a4356043bb73f9c9c7"/></dir><file name="Checkout.php" hash="a7e6876317a29184f07040b646b84ec7"/><file name="Invoice.php" hash="105a41b84e52b45f26f3c5de2d4bdd4a"/><dir name="Paymentplan"><file name="Information.php" hash="7c66acd887a1e3a165e3cd967d0f3331"/></dir><file name="Special.php" hash="8db5a5f33510cd32d724c6ecd6368aa2"/></dir><dir name="Info"><file name="Abstract.php" hash="b1f368a985cb611c2bb97385a313d6d7"/><file name="Account.php" hash="d302c2fc556e05858464fadd51cd4854"/><file name="Checkout.php" hash="df92291673e6bfe63ac968ad7297cca3"/><file name="Invoice.php" hash="f98adb5521f6c546c462f2e5bde31295"/><file name="Special.php" hash="e07662f39f0ff65505bfd627045c7766"/></dir><dir name="Invoice"><file name="Totals.php" hash="2437d7c7d7499d3ee2fcb7e0426ad64d"/></dir><dir name="Klarnacheckout"><file name="Autofill.php" hash="4fb4d1c806c2224d20a388b62f027e33"/><dir name="Customer"><file name="Balance.php" hash="e35153845d979d91ff79d0558e7b6c0b"/></dir><file name="Discount.php" hash="63bb0c1991030522371eb3b798055c39"/><file name="Ga.php" hash="e69dc6575162c137669bc6fba3d854cd"/><file name="Klarnacheckout.php" hash="adc7aa285e45b1198ba8cbe8542311c8"/><file name="Newsletter.php" hash="ce97e11c097b0cd9696919936fa59dc6"/><file name="Othermethod.php" hash="7af2512fb570dc467fd0d240c4963417"/><file name="Reward.php" hash="98d72b6cf65070dcb4cc87a303cd8b54"/><file name="Success.php" hash="88e538e4c165142c55d74a3efecebef6"/></dir><dir name="Order"><file name="Totals.php" hash="2e56335ff1b4a1d6752e7336b107bd13"/></dir><dir name="Page"><dir name="Html"><file name="Logo.php" hash="fda8fc32997328feb9c7ebf15c8a51fa"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><dir name="Position"><dir name="Attribute"><file name="Set.php" hash="b47d1dff880be4e0d22f8f169f180bc3"/></dir></dir><file name="Position.php" hash="469a02a99354ae219f5b744b248c76b8"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AddressController.php" hash="4ae9ea28491b66ca7a69c3bd0646cacb"/><dir name="Adminhtml"><dir name="Klarna"><file name="MassactionController.php" hash="a5679cee64b19d9742753f2b537cdaeb"/><file name="PclassController.php" hash="96836bd2a4ae7b145d9bedbbdf20e4f5"/></dir></dir><dir name="Checkout"><file name="KlarnaController.php" hash="a4e126b1d3761cb36e9ffbc08f62cd60"/></dir><file name="LoginController.php" hash="bc5e1832feaa3401f553c62d7473155b"/><file name="PaymentplanController.php" hash="fea9d33a5dbd5d4858ef174569dae636"/></dir><dir name="etc"><file name="config.xml" hash="f69ee5315880d4de0a86ff901aff9ddb"/><file name="system.xml" hash="d73e4cd2d7badf039f65eaec826fabb6"/></dir><dir name="Helper"><file name="Data.php" hash="de1634310e60e2149e3759f8b4d8e3b0"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Admin"><file name="Json.php" hash="e6413eca01dc9e4e6715e518ffa59eae"/></dir></dir></dir></dir></dir><dir name="Api"><file name="Abstract.php" hash="83e5d60fee0d104ef283a6abcba6d391"/><file name="Kco.php" hash="011b6b6f50ae224c897526a5c8615507"/><file name="Rest.php" hash="81397908626ca61e5fc99be224fb69dc"/><file name="Xmlrpc.php" hash="5f9ddd41ea5b1c7dc77e35f702700b9c"/></dir><file name="Api.php" hash="0c9a565b4909373b16c6701af7356186"/><dir name="Creditmemo"><file name="Tax.php" hash="c3d5162de38f5ef2075bca483085e5d0"/><file name="Total.php" hash="8da0e6596826ba5fc03695e7834734f0"/></dir><file name="Cron.php" hash="3c2aa833ce3e9220a4f11184ae4b9097"/><dir name="Invoice"><dir name="Pdf"><file name="Total.php" hash="06412f97df9ac6a1854978b61f68fb36"/></dir><file name="Tax.php" hash="b2203547b3f05d6179e7307d14b55c6d"/><file name="Total.php" hash="c2f4a2207550915e1aaa9868e6759f94"/></dir><dir name="Klarna"><file name="Abstract.php" hash="df64121d6fd494d631acc997b8d66f55"/></dir><file name="Klarna.php" hash="1352e5b163aa33f872c20981710d410d"/><dir name="Klarnacheckout"><file name="Abstract.php" hash="3cd1fd4a58d6b6b09b291df26b761f2a"/></dir><file name="Klarnacheckout.php" hash="f6423e3a3016470ed2268eba2e01ee6e"/><file name="Observer.php" hash="d24956bfb6fc0237a11285b9e8f432e6"/><dir name="Payment"><file name="Abstract.php" hash="89bd851e2c4b424d2fb702f16e438609"/><file name="Account.php" hash="95931980dba66fc274f3acfa4df2b91a"/><file name="Checkout.php" hash="d8fb8bbadb12a901f782ed7067d12bc2"/><file name="Invoice.php" hash="eef0e5ea5466469942a14d28e8507333"/><file name="Special.php" hash="53754f59a474e32f168220c795b80c2f"/></dir><file name="Pushqueue.php" hash="cb74fc4cd2e34077b8be5f45c49dac28"/><dir name="Quote"><file name="Tax.php" hash="b53f4a52d0f09afc7daeb094d6e30881"/><file name="Total.php" hash="a1442ecba3f2c49a42ff43e006057878"/></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="0a40d43403823a6053d74bd2d2f688e7"/></dir><dir name="Pushqueue"><file name="Collection.php" hash="cdbfe12d3f3d82c60c699e2e4700645b"/></dir><file name="Pushqueue.php" hash="0ccf2419c79a847f8095f9ef8ca349de"/></dir><dir name="Source"><file name="Abstract.php" hash="8d0d746d1cd2e5bc7d11350908a01585"/><file name="Allspecificcountries.php" hash="1a98316e25baeaba307b3be62364e1ca"/><file name="Apiversion.php" hash="a1be9e12b858927cbfa459509fff3647"/><file name="Capture.php" hash="c2d31ebb607202555e9905e439dbe86d"/><file name="Country.php" hash="2444140a6155e42d2e4909ae150037b7"/><file name="Customergroup.php" hash="01c6e41abac6e7105e4d290f53f68733"/><file name="Klarnalayout.php" hash="6c7b9d3a871d8cdb2a11a0cadde83f4a"/><file name="Language.php" hash="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="09816f0e578fc920293da4963eff48ea"/></dir></dir><dir name="sql"><dir name="klarna_setup"><file name="mysql4-install-0.1.0.php" hash="d36b51433fd28241386594f39def3080"/><file name="mysql4-upgrade-5.1.6-5.1.7.php" hash="014a7b827a8958a94c57a0229127a427"/><file name="mysql4-upgrade-5.2.5-5.2.6.php" hash="1dd874e1a94730ab976b6187a34e6c77"/><file name="mysql4-upgrade-5.3.4-5.3.5.php" hash="64ff4fc928b39153a89857169faa7c70"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name></name><channel>connect.magentocommerce.com/core</channel><min></min><max></max></package></required></dependencies>
18
  </package>