Version Notes
Klarna Checkout module
Download this release
Release Info
| Developer | Avenla Oy |
| Extension | Avenla_KlarnaCheckout |
| Version | 1.0.4 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.3 to 1.0.4
- app/code/community/Avenla/KlarnaCheckout/Helper/Data.php +25 -3
- app/code/community/Avenla/KlarnaCheckout/Model/Config.php +15 -11
- app/code/community/Avenla/KlarnaCheckout/Model/KCO.php +7 -9
- app/code/community/Avenla/KlarnaCheckout/Model/Order.php +34 -24
- app/code/community/Avenla/KlarnaCheckout/Model/Source/Shippingmethods.php +48 -0
- app/code/community/Avenla/KlarnaCheckout/controllers/KCOController.php +8 -7
- app/code/community/Avenla/KlarnaCheckout/etc/config.xml +1 -1
- app/code/community/Avenla/KlarnaCheckout/etc/system.xml +10 -19
- app/locale/fi_FI/Avenla_KlarnaCheckout.csv +2 -1
- lib/KlarnaCheckout/Checkout/UserAgent.php +1 -1
- package.xml +4 -4
app/code/community/Avenla/KlarnaCheckout/Helper/Data.php
CHANGED
|
@@ -99,10 +99,11 @@ class Avenla_KlarnaCheckout_Helper_Data extends Mage_Core_Helper_Data
|
|
| 99 |
*
|
| 100 |
* @return bool
|
| 101 |
*/
|
| 102 |
-
public function getConnectionStatus($
|
| 103 |
{
|
| 104 |
try{
|
| 105 |
-
$ko = Mage::getModel("klarnaCheckout/order")->dummyOrder($
|
|
|
|
| 106 |
if($ko == null)
|
| 107 |
return false;
|
| 108 |
|
|
@@ -145,5 +146,26 @@ class Avenla_KlarnaCheckout_Helper_Data extends Mage_Core_Helper_Data
|
|
| 145 |
$taxRate = $taxClasses["value_".$taxClass];
|
| 146 |
|
| 147 |
return $taxRate;
|
| 148 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
}
|
| 99 |
*
|
| 100 |
* @return bool
|
| 101 |
*/
|
| 102 |
+
public function getConnectionStatus($quote = null)
|
| 103 |
{
|
| 104 |
try{
|
| 105 |
+
$ko = Mage::getModel("klarnaCheckout/order")->dummyOrder($quote);
|
| 106 |
+
|
| 107 |
if($ko == null)
|
| 108 |
return false;
|
| 109 |
|
| 146 |
$taxRate = $taxClasses["value_".$taxClass];
|
| 147 |
|
| 148 |
return $taxRate;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* Get locale code for purchase country
|
| 153 |
+
*
|
| 154 |
+
* @param string $country
|
| 155 |
+
* @return string
|
| 156 |
+
*/
|
| 157 |
+
public function getLocale($country)
|
| 158 |
+
{
|
| 159 |
+
switch($country){
|
| 160 |
+
case 'SE':
|
| 161 |
+
return 'sv-se';
|
| 162 |
+
case 'NO':
|
| 163 |
+
return 'nb-no';
|
| 164 |
+
case 'DE':
|
| 165 |
+
return 'de-de';
|
| 166 |
+
case 'FI':
|
| 167 |
+
default:
|
| 168 |
+
return 'fi-fi';
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
}
|
app/code/community/Avenla/KlarnaCheckout/Model/Config.php
CHANGED
|
@@ -94,17 +94,7 @@ class Avenla_KlarnaCheckout_Model_Config extends Varien_Object
|
|
| 94 |
|
| 95 |
return false;
|
| 96 |
}
|
| 97 |
-
|
| 98 |
-
/**
|
| 99 |
-
* Get selected locale for Klarna Checkout
|
| 100 |
-
*
|
| 101 |
-
* @return string locale
|
| 102 |
-
*/
|
| 103 |
-
public function getLocale()
|
| 104 |
-
{
|
| 105 |
-
return $this->getConfigData('locale');
|
| 106 |
-
}
|
| 107 |
-
|
| 108 |
/**
|
| 109 |
* Get module status
|
| 110 |
*
|
|
@@ -189,4 +179,18 @@ class Avenla_KlarnaCheckout_Model_Config extends Varien_Object
|
|
| 189 |
{
|
| 190 |
return $this->getConfigData('license');
|
| 191 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
}
|
| 94 |
|
| 95 |
return false;
|
| 96 |
}
|
| 97 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
/**
|
| 99 |
* Get module status
|
| 100 |
*
|
| 179 |
{
|
| 180 |
return $this->getConfigData('license');
|
| 181 |
}
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
* Get allowed shipping methods
|
| 185 |
+
*
|
| 186 |
+
* @return array
|
| 187 |
+
*/
|
| 188 |
+
public function getDisallowedShippingMethods()
|
| 189 |
+
{
|
| 190 |
+
$methods = array();
|
| 191 |
+
if($this->getConfigData('disabled_shipping_methods'))
|
| 192 |
+
$methods = explode(",", $this->getConfigData('disabled_shipping_methods'));
|
| 193 |
+
|
| 194 |
+
return $methods;
|
| 195 |
+
}
|
| 196 |
}
|
app/code/community/Avenla/KlarnaCheckout/Model/KCO.php
CHANGED
|
@@ -53,18 +53,16 @@ class Avenla_KlarnaCheckout_Model_KCO extends Mage_Payment_Model_Method_Abstract
|
|
| 53 |
* @param Mage_Sales_Model_Quote|null $quote
|
| 54 |
* @return bool
|
| 55 |
*/
|
| 56 |
-
public function isAvailable($quote = null
|
| 57 |
-
{
|
| 58 |
-
$connectionStatus = Mage::helper('klarnaCheckout')->getConnectionStatus($country);
|
| 59 |
-
|
| 60 |
if($quote == null)
|
| 61 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
| 62 |
-
|
| 63 |
-
// If KCO is needed to be disabled with some shipping methods
|
| 64 |
-
// $preventMethods = array('itellaSmartpost_itellaSmartpost');
|
| 65 |
-
// if (in_array($quote->getShippingAddress()->getShippingMethod() , $preventMethods))
|
| 66 |
-
// return false;
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
return parent::isAvailable($quote) &&
|
| 69 |
$connectionStatus &&
|
| 70 |
(Mage::getSingleton('customer/session')->isLoggedIn() || Mage::helper('checkout')->isAllowedGuestCheckout($quote)) &&
|
| 53 |
* @param Mage_Sales_Model_Quote|null $quote
|
| 54 |
* @return bool
|
| 55 |
*/
|
| 56 |
+
public function isAvailable($quote = null)
|
| 57 |
+
{
|
|
|
|
|
|
|
| 58 |
if($quote == null)
|
| 59 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
$connectionStatus = Mage::helper('klarnaCheckout')->getConnectionStatus($quote);
|
| 62 |
+
|
| 63 |
+
if(in_array($quote->getShippingAddress()->getShippingMethod(), $this->getConfig()->getDisallowedShippingMethods()))
|
| 64 |
+
return false;
|
| 65 |
+
|
| 66 |
return parent::isAvailable($quote) &&
|
| 67 |
$connectionStatus &&
|
| 68 |
(Mage::getSingleton('customer/session')->isLoggedIn() || Mage::helper('checkout')->isAllowedGuestCheckout($quote)) &&
|
app/code/community/Avenla/KlarnaCheckout/Model/Order.php
CHANGED
|
@@ -34,16 +34,14 @@ class Avenla_KlarnaCheckout_Model_Order extends Klarna_Checkout_Order
|
|
| 34 |
|
| 35 |
public function __construct()
|
| 36 |
{
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
$url = $this->config->isLive()
|
| 41 |
? Avenla_KlarnaCheckout_Model_Config::KCO_LIVE_URL
|
| 42 |
: Avenla_KlarnaCheckout_Model_Config::KCO_DEMO_URL;
|
| 43 |
|
| 44 |
parent::$baseUri = $url . '/checkout/orders';
|
| 45 |
parent::$contentType = "application/vnd.klarna.checkout.aggregated-order-v2+json";
|
| 46 |
-
Mage::log("SS:". $this->config->getKlarnaSharedSecret());
|
| 47 |
|
| 48 |
$this->connector = Klarna_Checkout_Connector::create($this->config->getKlarnaSharedSecret());
|
| 49 |
}
|
|
@@ -57,7 +55,6 @@ class Avenla_KlarnaCheckout_Model_Order extends Klarna_Checkout_Order
|
|
| 57 |
*/
|
| 58 |
public function getOrder($quote = null, $checkoutId = null, $mobile = false)
|
| 59 |
{
|
| 60 |
-
|
| 61 |
$this->order = new Klarna_Checkout_Order($this->connector, $checkoutId);
|
| 62 |
$this->mobile = $mobile;
|
| 63 |
if(!$quote)
|
|
@@ -77,15 +74,12 @@ class Avenla_KlarnaCheckout_Model_Order extends Klarna_Checkout_Order
|
|
| 77 |
* Create new Klarna Checkout order
|
| 78 |
*
|
| 79 |
*/
|
| 80 |
-
private function createOrder(
|
| 81 |
{
|
| 82 |
try{
|
| 83 |
-
$create['purchase_country']
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
$create['purchase_currency'] = $this->dummy ? 'EUR' : $this->quote->getBaseCurrencyCode();
|
| 88 |
-
$create['locale'] = $this->config->getLocale();
|
| 89 |
$create['merchant']['id'] = $this->config->getKlarnaEid();
|
| 90 |
$create['merchant']['terms_uri'] = $this->config->getTermsUri();
|
| 91 |
$create['merchant']['checkout_uri'] = $this->helper->getCheckoutUri();
|
|
@@ -121,23 +115,24 @@ class Avenla_KlarnaCheckout_Model_Order extends Klarna_Checkout_Order
|
|
| 121 |
{
|
| 122 |
try {
|
| 123 |
$this->order->fetch();
|
| 124 |
-
|
| 125 |
-
|
|
|
|
| 126 |
$this->createOrder();
|
| 127 |
return;
|
| 128 |
}
|
| 129 |
-
|
| 130 |
$update['cart']['items'] = array();
|
| 131 |
$update['merchant_reference']['orderid1'] = $this->quote->getId();
|
| 132 |
|
| 133 |
$info = $this->getCustomerInfo();
|
| 134 |
if(!empty($info))
|
| 135 |
$update['shipping_address'] = $info;
|
| 136 |
-
|
| 137 |
foreach ($this->cart as $item){
|
| 138 |
$update['cart']['items'][] = $item;
|
| 139 |
}
|
| 140 |
-
|
| 141 |
$this->order->update($update);
|
| 142 |
}
|
| 143 |
catch (Exception $e) {
|
|
@@ -147,6 +142,21 @@ class Avenla_KlarnaCheckout_Model_Order extends Klarna_Checkout_Order
|
|
| 147 |
}
|
| 148 |
}
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
/**
|
| 151 |
* Get customer info for Klarna Checkout
|
| 152 |
*
|
|
@@ -195,9 +205,6 @@ class Avenla_KlarnaCheckout_Model_Order extends Klarna_Checkout_Order
|
|
| 195 |
{
|
| 196 |
$totals = $this->quote->getTotals();
|
| 197 |
|
| 198 |
-
// TODO : Calculate discount tax rate ! Cannot be 0 always.
|
| 199 |
-
// Check discount tax configuration too.
|
| 200 |
-
|
| 201 |
if(isset($totals['discount'])){
|
| 202 |
$discount = $totals['discount'];
|
| 203 |
$this->cart[] = array(
|
|
@@ -244,20 +251,23 @@ class Avenla_KlarnaCheckout_Model_Order extends Klarna_Checkout_Order
|
|
| 244 |
*
|
| 245 |
* @return Klarna_Checkout_Order
|
| 246 |
*/
|
| 247 |
-
public function dummyOrder($
|
| 248 |
{
|
| 249 |
$this->dummy = true;
|
|
|
|
|
|
|
|
|
|
| 250 |
$this->order = new Klarna_Checkout_Order($this->connector, null);
|
| 251 |
-
|
| 252 |
$this->cart = array(
|
| 253 |
array(
|
| 254 |
'reference' => '123456789',
|
| 255 |
'name' => 'Test product',
|
| 256 |
'quantity' => 1,
|
| 257 |
'unit_price' => 4490,
|
| 258 |
-
'tax_rate' =>
|
| 259 |
));
|
| 260 |
-
$this->createOrder(
|
| 261 |
|
| 262 |
return $this->order;
|
| 263 |
}
|
| 34 |
|
| 35 |
public function __construct()
|
| 36 |
{
|
| 37 |
+
$this->helper = Mage::helper("klarnaCheckout");
|
| 38 |
+
$this->config = Mage::getSingleton('klarnaCheckout/KCO')->getConfig();
|
|
|
|
| 39 |
$url = $this->config->isLive()
|
| 40 |
? Avenla_KlarnaCheckout_Model_Config::KCO_LIVE_URL
|
| 41 |
: Avenla_KlarnaCheckout_Model_Config::KCO_DEMO_URL;
|
| 42 |
|
| 43 |
parent::$baseUri = $url . '/checkout/orders';
|
| 44 |
parent::$contentType = "application/vnd.klarna.checkout.aggregated-order-v2+json";
|
|
|
|
| 45 |
|
| 46 |
$this->connector = Klarna_Checkout_Connector::create($this->config->getKlarnaSharedSecret());
|
| 47 |
}
|
| 55 |
*/
|
| 56 |
public function getOrder($quote = null, $checkoutId = null, $mobile = false)
|
| 57 |
{
|
|
|
|
| 58 |
$this->order = new Klarna_Checkout_Order($this->connector, $checkoutId);
|
| 59 |
$this->mobile = $mobile;
|
| 60 |
if(!$quote)
|
| 74 |
* Create new Klarna Checkout order
|
| 75 |
*
|
| 76 |
*/
|
| 77 |
+
private function createOrder()
|
| 78 |
{
|
| 79 |
try{
|
| 80 |
+
$create['purchase_country'] = $this->getPurchaseCountry();
|
| 81 |
+
$create['purchase_currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
|
| 82 |
+
$create['locale'] = $this->helper->getLocale($this->getPurchaseCountry());
|
|
|
|
|
|
|
|
|
|
| 83 |
$create['merchant']['id'] = $this->config->getKlarnaEid();
|
| 84 |
$create['merchant']['terms_uri'] = $this->config->getTermsUri();
|
| 85 |
$create['merchant']['checkout_uri'] = $this->helper->getCheckoutUri();
|
| 115 |
{
|
| 116 |
try {
|
| 117 |
$this->order->fetch();
|
| 118 |
+
if(!$this->helper->isOrderFromCurrentStore($this->order) ||
|
| 119 |
+
strtoupper($this->order['purchase_country']) != $this->getPurchaseCountry()){
|
| 120 |
+
|
| 121 |
$this->createOrder();
|
| 122 |
return;
|
| 123 |
}
|
| 124 |
+
|
| 125 |
$update['cart']['items'] = array();
|
| 126 |
$update['merchant_reference']['orderid1'] = $this->quote->getId();
|
| 127 |
|
| 128 |
$info = $this->getCustomerInfo();
|
| 129 |
if(!empty($info))
|
| 130 |
$update['shipping_address'] = $info;
|
| 131 |
+
|
| 132 |
foreach ($this->cart as $item){
|
| 133 |
$update['cart']['items'][] = $item;
|
| 134 |
}
|
| 135 |
+
|
| 136 |
$this->order->update($update);
|
| 137 |
}
|
| 138 |
catch (Exception $e) {
|
| 142 |
}
|
| 143 |
}
|
| 144 |
|
| 145 |
+
/**
|
| 146 |
+
* Get purchase country
|
| 147 |
+
*
|
| 148 |
+
* @return string
|
| 149 |
+
*/
|
| 150 |
+
private function getPurchaseCountry()
|
| 151 |
+
{
|
| 152 |
+
if($this->quote && $this->quote->getShippingAddress()->getCountry()){
|
| 153 |
+
return $this->quote->getShippingAddress()->getCountry();
|
| 154 |
+
}
|
| 155 |
+
else{
|
| 156 |
+
return Mage::getStoreConfig('general/country/default', Mage::app()->getStore());
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
/**
|
| 161 |
* Get customer info for Klarna Checkout
|
| 162 |
*
|
| 205 |
{
|
| 206 |
$totals = $this->quote->getTotals();
|
| 207 |
|
|
|
|
|
|
|
|
|
|
| 208 |
if(isset($totals['discount'])){
|
| 209 |
$discount = $totals['discount'];
|
| 210 |
$this->cart[] = array(
|
| 251 |
*
|
| 252 |
* @return Klarna_Checkout_Order
|
| 253 |
*/
|
| 254 |
+
public function dummyOrder($quote = null)
|
| 255 |
{
|
| 256 |
$this->dummy = true;
|
| 257 |
+
if($quote)
|
| 258 |
+
$this->quote = $quote;
|
| 259 |
+
|
| 260 |
$this->order = new Klarna_Checkout_Order($this->connector, null);
|
| 261 |
+
|
| 262 |
$this->cart = array(
|
| 263 |
array(
|
| 264 |
'reference' => '123456789',
|
| 265 |
'name' => 'Test product',
|
| 266 |
'quantity' => 1,
|
| 267 |
'unit_price' => 4490,
|
| 268 |
+
'tax_rate' => 0
|
| 269 |
));
|
| 270 |
+
$this->createOrder();
|
| 271 |
|
| 272 |
return $this->order;
|
| 273 |
}
|
app/code/community/Avenla/KlarnaCheckout/Model/Source/Shippingmethods.php
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* This file is released under a custom license by Avenla Oy.
|
| 4 |
+
* All rights reserved
|
| 5 |
+
*
|
| 6 |
+
* License and more information can be found at http://productdownloads.avenla.com/magento-modules/klarna-checkout/
|
| 7 |
+
* For questions and support - klarna-support@avenla.com
|
| 8 |
+
*
|
| 9 |
+
* @category Avenla
|
| 10 |
+
* @package Avenla_KlarnaCheckout
|
| 11 |
+
* @copyright Copyright (c) Avenla Oy
|
| 12 |
+
* @link http://www.avenla.fi
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Avenla KlarnaCheckout
|
| 17 |
+
*
|
| 18 |
+
* @category Avenla
|
| 19 |
+
* @package Avenla_KlarnaCheckout
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
class Avenla_KlarnaCheckout_Model_Source_Shippingmethods
|
| 23 |
+
{
|
| 24 |
+
public function toOptionArray()
|
| 25 |
+
{
|
| 26 |
+
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
|
| 27 |
+
$options = array();
|
| 28 |
+
|
| 29 |
+
foreach($methods as $_code => $_method){
|
| 30 |
+
if ($methods = $_method->getAllowedMethods()){
|
| 31 |
+
foreach ($methods as $_mcode => $_mname){
|
| 32 |
+
$code = $_code . '_' . $_mcode;
|
| 33 |
+
$title = $_mname;
|
| 34 |
+
|
| 35 |
+
if(!$title = Mage::getStoreConfig("carriers/$_code/title"))
|
| 36 |
+
$title = $_code;
|
| 37 |
+
|
| 38 |
+
$options[] = array(
|
| 39 |
+
'value' => $code,
|
| 40 |
+
'label' => $title
|
| 41 |
+
);
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return $options;
|
| 47 |
+
}
|
| 48 |
+
}
|
app/code/community/Avenla/KlarnaCheckout/controllers/KCOController.php
CHANGED
|
@@ -35,7 +35,7 @@ class Avenla_KlarnaCheckout_KCOController extends Mage_Core_Controller_Front_Act
|
|
| 35 |
$result = array();
|
| 36 |
|
| 37 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
| 38 |
-
$kco = Mage::
|
| 39 |
|
| 40 |
if (!$quote->validateMinimumAmount()){
|
| 41 |
$minimumAmount = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())
|
|
@@ -48,7 +48,7 @@ class Avenla_KlarnaCheckout_KCOController extends Mage_Core_Controller_Front_Act
|
|
| 48 |
$result['msg'] = $warning;
|
| 49 |
}
|
| 50 |
|
| 51 |
-
if(!$kco->isAvailable($quote
|
| 52 |
$result['msg'] = $this->__("Klarna Checkout is not available");
|
| 53 |
}
|
| 54 |
else{
|
|
@@ -128,11 +128,15 @@ class Avenla_KlarnaCheckout_KCOController extends Mage_Core_Controller_Front_Act
|
|
| 128 |
if($region_code == '')
|
| 129 |
$region_code = 1;
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
$magentoAddress = array(
|
| 132 |
'firstname' => $address['given_name'],
|
| 133 |
'lastname' => $address['family_name'],
|
| 134 |
'email' => $address['email'],
|
| 135 |
-
'street' => $
|
| 136 |
'city' => $address['city'],
|
| 137 |
'region_id' => $region_code,
|
| 138 |
'region' => $region,
|
|
@@ -242,12 +246,9 @@ class Avenla_KlarnaCheckout_KCOController extends Mage_Core_Controller_Front_Act
|
|
| 242 |
*/
|
| 243 |
private function quoteToOrder($quote, $ko)
|
| 244 |
{
|
| 245 |
-
// The address given to Klarna is set to both
|
| 246 |
-
// billing and shipping
|
| 247 |
-
|
| 248 |
$quote->setCustomerEmail($ko['billing_address']['email'])->save();
|
| 249 |
$quote->getBillingAddress()->addData($this->convertAddress($ko['billing_address']));
|
| 250 |
-
$quote->getShippingAddress()->addData($this->convertAddress($ko['
|
| 251 |
$quote->getPayment()->setMethod(Mage::getModel("klarnaCheckout/KCO")->getCode());
|
| 252 |
$quote->collectTotals()->save();
|
| 253 |
$service = Mage::getModel('sales/service_quote', $quote);
|
| 35 |
$result = array();
|
| 36 |
|
| 37 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
| 38 |
+
$kco = Mage::getModel('klarnaCheckout/KCO');
|
| 39 |
|
| 40 |
if (!$quote->validateMinimumAmount()){
|
| 41 |
$minimumAmount = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())
|
| 48 |
$result['msg'] = $warning;
|
| 49 |
}
|
| 50 |
|
| 51 |
+
if(!$kco->isAvailable($quote)){
|
| 52 |
$result['msg'] = $this->__("Klarna Checkout is not available");
|
| 53 |
}
|
| 54 |
else{
|
| 128 |
if($region_code == '')
|
| 129 |
$region_code = 1;
|
| 130 |
|
| 131 |
+
$street = isset($address['street_address'])
|
| 132 |
+
? $address['street_address']
|
| 133 |
+
: $address['street_name'] . " " . $address['street_number'];
|
| 134 |
+
|
| 135 |
$magentoAddress = array(
|
| 136 |
'firstname' => $address['given_name'],
|
| 137 |
'lastname' => $address['family_name'],
|
| 138 |
'email' => $address['email'],
|
| 139 |
+
'street' => $street,
|
| 140 |
'city' => $address['city'],
|
| 141 |
'region_id' => $region_code,
|
| 142 |
'region' => $region,
|
| 246 |
*/
|
| 247 |
private function quoteToOrder($quote, $ko)
|
| 248 |
{
|
|
|
|
|
|
|
|
|
|
| 249 |
$quote->setCustomerEmail($ko['billing_address']['email'])->save();
|
| 250 |
$quote->getBillingAddress()->addData($this->convertAddress($ko['billing_address']));
|
| 251 |
+
$quote->getShippingAddress()->addData($this->convertAddress($ko['shipping_address']));
|
| 252 |
$quote->getPayment()->setMethod(Mage::getModel("klarnaCheckout/KCO")->getCode());
|
| 253 |
$quote->collectTotals()->save();
|
| 254 |
$service = Mage::getModel('sales/service_quote', $quote);
|
app/code/community/Avenla/KlarnaCheckout/etc/config.xml
CHANGED
|
@@ -23,7 +23,7 @@
|
|
| 23 |
<config>
|
| 24 |
<modules>
|
| 25 |
<Avenla_KlarnaCheckout>
|
| 26 |
-
<version>1.0.
|
| 27 |
</Avenla_KlarnaCheckout>
|
| 28 |
</modules>
|
| 29 |
<global>
|
| 23 |
<config>
|
| 24 |
<modules>
|
| 25 |
<Avenla_KlarnaCheckout>
|
| 26 |
+
<version>1.0.4</version>
|
| 27 |
</Avenla_KlarnaCheckout>
|
| 28 |
</modules>
|
| 29 |
<global>
|
app/code/community/Avenla/KlarnaCheckout/etc/system.xml
CHANGED
|
@@ -80,25 +80,6 @@
|
|
| 80 |
<show_in_website>1</show_in_website>
|
| 81 |
<show_in_store>1</show_in_store>
|
| 82 |
</sharedsecret>
|
| 83 |
-
<specificcountry>
|
| 84 |
-
<label>Activated Countries</label>
|
| 85 |
-
<frontend_type>multiselect</frontend_type>
|
| 86 |
-
<source_model>klarnaCheckout/source_countries</source_model>
|
| 87 |
-
<sort_order>7</sort_order>
|
| 88 |
-
<show_in_default>1</show_in_default>
|
| 89 |
-
<show_in_website>1</show_in_website>
|
| 90 |
-
<show_in_store>1</show_in_store>
|
| 91 |
-
</specificcountry>
|
| 92 |
-
<locale translate="label">
|
| 93 |
-
<label>Locale</label>
|
| 94 |
-
<comment><![CDATA[Checkout won't be displayed if selected locale is not allowed by Klarna]]></comment>
|
| 95 |
-
<frontend_type>select</frontend_type>
|
| 96 |
-
<source_model>klarnaCheckout/source_orderlocale</source_model>
|
| 97 |
-
<sort_order>7</sort_order>
|
| 98 |
-
<show_in_default>1</show_in_default>
|
| 99 |
-
<show_in_website>1</show_in_website>
|
| 100 |
-
<show_in_store>1</show_in_store>
|
| 101 |
-
</locale>
|
| 102 |
<activate_partial translate="label">
|
| 103 |
<label>Activate partial shipments</label>
|
| 104 |
<comment><![CDATA[When selected, partial shipments will be automatically activated in Klarna]]></comment>
|
|
@@ -153,6 +134,16 @@
|
|
| 153 |
<show_in_website>1</show_in_website>
|
| 154 |
<show_in_store>1</show_in_store>
|
| 155 |
</google_analytics>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
</fields>
|
| 157 |
</klarnaCheckout_payment>
|
| 158 |
</groups>
|
| 80 |
<show_in_website>1</show_in_website>
|
| 81 |
<show_in_store>1</show_in_store>
|
| 82 |
</sharedsecret>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
<activate_partial translate="label">
|
| 84 |
<label>Activate partial shipments</label>
|
| 85 |
<comment><![CDATA[When selected, partial shipments will be automatically activated in Klarna]]></comment>
|
| 134 |
<show_in_website>1</show_in_website>
|
| 135 |
<show_in_store>1</show_in_store>
|
| 136 |
</google_analytics>
|
| 137 |
+
<disabled_shipping_methods translate="label">
|
| 138 |
+
<label>Disabled shipping methods</label>
|
| 139 |
+
<frontend_type>multiselect</frontend_type>
|
| 140 |
+
<source_model>klarnaCheckout/source_shippingmethods</source_model>
|
| 141 |
+
<sort_order>14</sort_order>
|
| 142 |
+
<show_in_default>1</show_in_default>
|
| 143 |
+
<show_in_website>1</show_in_website>
|
| 144 |
+
<show_in_store>1</show_in_store>
|
| 145 |
+
<can_be_empty>1</can_be_empty>
|
| 146 |
+
</disabled_shipping_methods>
|
| 147 |
</fields>
|
| 148 |
</klarnaCheckout_payment>
|
| 149 |
</groups>
|
app/locale/fi_FI/Avenla_KlarnaCheckout.csv
CHANGED
|
@@ -41,4 +41,5 @@
|
|
| 41 |
"Please select country", "Ole hyvä ja valitse maa"
|
| 42 |
"I accept the terms in the license agreement", "Hyväksyn sopimusehdot"
|
| 43 |
"License agreement", "Sopimusehdot"
|
| 44 |
-
"By accepting the license agreement and filling in your contact information you can use Klarna Checkout module for free.", "Hyväksymällä sopimusehdot ja täyttämällä yhteystietosi voit käyttää Klarna Checkout moduulia ilmaiseksi."
|
|
|
| 41 |
"Please select country", "Ole hyvä ja valitse maa"
|
| 42 |
"I accept the terms in the license agreement", "Hyväksyn sopimusehdot"
|
| 43 |
"License agreement", "Sopimusehdot"
|
| 44 |
+
"By accepting the license agreement and filling in your contact information you can use Klarna Checkout module for free.", "Hyväksymällä sopimusehdot ja täyttämällä yhteystietosi voit käyttää Klarna Checkout moduulia ilmaiseksi."
|
| 45 |
+
"Disabled shipping methods", "Poissuljetut toimitustavat"
|
lib/KlarnaCheckout/Checkout/UserAgent.php
CHANGED
|
@@ -67,7 +67,7 @@ class Klarna_Checkout_UserAgent
|
|
| 67 |
),
|
| 68 |
'Module' => array(
|
| 69 |
'name' => 'KlarnaCheckout.MagentoModule',
|
| 70 |
-
'version' => '1.0.
|
| 71 |
)
|
| 72 |
);
|
| 73 |
}
|
| 67 |
),
|
| 68 |
'Module' => array(
|
| 69 |
'name' => 'KlarnaCheckout.MagentoModule',
|
| 70 |
+
'version' => '1.0.4'
|
| 71 |
)
|
| 72 |
);
|
| 73 |
}
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Avenla_KlarnaCheckout</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://productdownloads.avenla.com/magento-modules/klarna-checkout/">Custom license by Avenla Oy</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -13,9 +13,9 @@ For questions and support - klarna-support@avenla.com
|
|
| 13 |
</description>
|
| 14 |
<notes>Klarna Checkout module</notes>
|
| 15 |
<authors><author><name>Avenla Oy</name><user>Avenla</user><email>info@avenla.fi</email></author></authors>
|
| 16 |
-
<date>2014-06-
|
| 17 |
-
<time>
|
| 18 |
-
<contents><target name="magecommunity"><dir name="Avenla"><dir name="KlarnaCheckout"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Info.php" hash="3d0fd774a6116513e4d413a078e80848"/></dir></dir></dir></dir><dir name="KCO"><file name="Confirmation.php" hash="61e58e00070fa76b9f067619e0db5ba5"/><file name="Info.php" hash="2af961abb2eb0609b84f8da5281332ad"/></dir><file name="KCO.php" hash="1abf22f4408a872572c1f8babed730d6"/></dir><dir name="Helper"><file name="Api.php" hash="3e2446b1520479046f82ad895ab81165"/><file name="Data.php" hash="
|
| 19 |
<compatible/>
|
| 20 |
<dependencies><required><php><min>5.2.16</min><max>5.5.0</max></php></required></dependencies>
|
| 21 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Avenla_KlarnaCheckout</name>
|
| 4 |
+
<version>1.0.4</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://productdownloads.avenla.com/magento-modules/klarna-checkout/">Custom license by Avenla Oy</license>
|
| 7 |
<channel>community</channel>
|
| 13 |
</description>
|
| 14 |
<notes>Klarna Checkout module</notes>
|
| 15 |
<authors><author><name>Avenla Oy</name><user>Avenla</user><email>info@avenla.fi</email></author></authors>
|
| 16 |
+
<date>2014-06-19</date>
|
| 17 |
+
<time>06:11:09</time>
|
| 18 |
+
<contents><target name="magecommunity"><dir name="Avenla"><dir name="KlarnaCheckout"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Info.php" hash="3d0fd774a6116513e4d413a078e80848"/></dir></dir></dir></dir><dir name="KCO"><file name="Confirmation.php" hash="61e58e00070fa76b9f067619e0db5ba5"/><file name="Info.php" hash="2af961abb2eb0609b84f8da5281332ad"/></dir><file name="KCO.php" hash="1abf22f4408a872572c1f8babed730d6"/></dir><dir name="Helper"><file name="Api.php" hash="3e2446b1520479046f82ad895ab81165"/><file name="Data.php" hash="cd8861c68f1cd0e38ea9912db6dc3a5d"/></dir><dir name="Model"><file name="Api.php" hash="0b72aba4740d21bfd566404a31451c27"/><file name="Config.php" hash="29eb90caf67c128f539d86adcc92499f"/><file name="KCO.php" hash="48565fcddce1d3cad0192afc67972f0c"/><file name="Observer.php" hash="39eeedd245eb2907d8a472b9769787fb"/><file name="Order.php" hash="e3b0ed6e75557484cc2457f5b1276192"/><dir name="Source"><file name="Countries.php" hash="0440b3ecc5528cf42dbb937eb7d9c0cb"/><file name="Orderlocale.php" hash="a88769cf211991c70a0f51185bc53fb0"/><file name="Servermode.php" hash="df4420b3831b1a1e1ec04daa53711a4d"/><file name="Shippingmethods.php" hash="fecb931e29be4ae008c678cc1d760a02"/><file name="Taxclass.php" hash="ff40a1943352031fd7971688b805be05"/></dir></dir><dir name="controllers"><file name="KCOController.php" hash="dc12925de13aa4e77a0f0b59cb8ad934"/></dir><dir name="etc"><file name="config.xml" hash="9f05a918176ae7bd040e28e4caea4bad"/><file name="system.xml" hash="ae03978fd0a9ad6d9b913f45b903fd86"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="KCO"><file name="info.phtml" hash="ad24867ca2930f515a0905a5db6f8d15"/><dir name="system"><dir name="config"><dir name="fieldset"><file name="info.phtml" hash="36a21983fcc4816b7c8a6b8fe9f2e78c"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="KCO"><file name="KCO.phtml" hash="27f81d18d4cf0b593f85f65cce93f6ba"/><dir name="cart"><file name="crosssell.phtml" hash="e7f78cb99e14ab680b794524b8666812"/><file name="shipping.phtml" hash="d9870590d2d9198de22b9b995c33a8a5"/></dir><file name="cart.phtml" hash="a23ccf697e854e3b541b5a19a8c1e808"/><file name="info.phtml" hash="a87d8ee70c92a10445fa864a63d042ba"/><file name="link.phtml" hash="7dadce1567975585dddd51bc904b95fa"/><dir name="onepage"><file name="link.phtml" hash="0e8ddf5a7e9a0f6ccd7b274170103ac7"/></dir></dir></dir><dir name="layout"><file name="KCO.xml" hash="2ffde82bc08dc156b4645adb779beda5"/></dir></dir></dir></dir></target><target name="magelib"><dir name="Klarna"><file name="Country.php" hash="40360c3964fc6193e7fb922845eb419b"/><file name="Currency.php" hash="a709407428d86521cc0775cbeb281523"/><file name="Encoding.php" hash="f8f8e744303ff7ce7f4b226331e7bdcf"/><file name="Exceptions.php" hash="933b2811e910da817743766cdde8ffeb"/><file name="Flags.php" hash="b407a1373adf5f172bef3e3d01e81cdb"/><file name="Klarna.php" hash="dc69f2c10e9b65999057bc04246c3fe8"/><file name="Language.php" hash="8e40aed0dece8f0a3fbe07e37451af16"/><dir name="checkout"><file name="checkouthtml.intf.php" hash="81e0740254585f2af67895df28093d35"/><file name="threatmetrix.class.php" hash="6ce1bfded90b6b3bb329176ff4c7acac"/></dir><dir name="examples"><file name="activate.php" hash="85a84a8eaeec830949551dfd98fe0236"/><file name="activateInvoice.php" hash="cfac2ed57d0c79679fb35ca723eaffab"/><file name="activatePart.php" hash="b46475c2d9f5b326ff2cd65586a1de6e"/><file name="activateReservation.php" hash="bd9b0e5717eaa32ebf6b5d31ad66e5d4"/><file name="addTransaction.php" hash="6426b7965de733bb17ddc7f74ee3949f"/><file name="calc_monthly_cost.php" hash="30e78c4d40db82643396f9289749a898"/><file name="cancelReservation.php" hash="ae8d00e19c671f6cfe8454a5bb590ab1"/><file name="changeReservation.php" hash="43d9486d29326a8c33a4fda466612149"/><file name="checkOrderStatus.php" hash="bef76f120b3e486790d78b50f4101701"/><file name="creditInvoice.php" hash="8edca171c9f7be2a3c15b23ff166048e"/><file name="creditPart.php" hash="5497b9307da7cccadbf4a6c0dc943876"/><file name="deleteInvoice.php" hash="6d2a6e53c64e7a1aacb79c775a46da5b"/><file name="emailInvoice.php" hash="764fbd5fab4f52dacd767a3f7ac17234"/><file name="fetchPClasses.php" hash="aac08dc4d9cfece6ac9e9a9c4e7b20cc"/><file name="getAddresses.php" hash="ebd79224ea702c92e99a407a53d42da0"/><file name="getPClasses.php" hash="8e444c98a7c63b82512af1f4ce35ac65"/><file name="invoiceAddress.php" hash="97475403b1db4264c0add60930380434"/><file name="invoiceAmount.php" hash="2f5dc326549b179cf99c27518b715e88"/><file name="invoicePartAmount.php" hash="87bf68e855bfdd4f6ba3547091104c97"/><file name="reserveAmount.php" hash="1a97ef5c39f5a2c6d97660504cbbfa10"/><file name="reserveOCR.php" hash="9349b5ea9807060cba4b5f3fcd14369f"/><file name="returnAmount.php" hash="02caca4d76b6d055d504023c770961a4"/><file name="sendInvoice.php" hash="9139eef562746840d09f9d9d5a465c21"/><file name="splitReservation.php" hash="0e09421de645d97c3b74485d51edacfd"/><file name="update.php" hash="3e3561165f4c6727731afe451b0f87d6"/><file name="updateChargeAmount.php" hash="34de26a7f6a089bdb18f67eae1f903c7"/><file name="updateGoodsQty.php" hash="e4f9ee36f56b47924ba35cda500cf13e"/><file name="updateOrderNo.php" hash="cdd594a386072f7bffbf05d2ecdcb9b7"/></dir><file name="klarnaaddr.php" hash="b090d4b0a819fdb7cc58815a8643de18"/><file name="klarnacalc.php" hash="3ab728bf3889240b881f282122fd25fd"/><file name="klarnaconfig.php" hash="a3a4011dccda60fcf3567f56254699ff"/><file name="klarnapclass.php" hash="26a8fd1df0806788f6719cb894787f76"/><dir name="pclasses"><file name="jsonstorage.class.php" hash="e59e526d9dcc17d1ca92ded188750672"/><file name="mysqlstorage.class.php" hash="896a5cd4edf461ef517e0bb2e328707b"/><file name="sqlstorage.class.php" hash="bb7ba4359e7e69424c9f0ecdafc0c9ae"/><file name="storage.intf.php" hash="26db57484b6db3d717c0150ffaa87b19"/><file name="xmlstorage.class.php" hash="4f13939bf8d73f2724f858dd17f219de"/></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><dir name="KlarnaCheckout"><dir name="Checkout"><file name="BasicConnector.php" hash="42afc7257646279bbc9239e5e427a76d"/><file name="ConnectionErrorException.php" hash="352ae3f5bbb18c04f0a9d3ca1be30faf"/><file name="Connector.php" hash="767cd6181abcd144ea8b2d1738f0a617"/><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="11a049d156b1726c1b307eb38181233c"/></dir><file name="Checkout.php" hash="6e16bb237ecfc54f086a0d533a8e69e3"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="KCO"><file name="dropdown.png" hash="a408e177ff3130bdb4bb491935700df4"/><file name="kco.css" hash="3fcde3265ba399760925e3033e42e106"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Avenla_KlarnaCheckout.xml" hash="22b47fd5cc2c12370457a51ffff752d6"/></dir></target><target name="magelocale"><dir name="fi_FI"><file name="Avenla_KlarnaCheckout.csv" hash="583a0ab62a4b3a568c10b65670f58b50"/></dir></target></contents>
|
| 19 |
<compatible/>
|
| 20 |
<dependencies><required><php><min>5.2.16</min><max>5.5.0</max></php></required></dependencies>
|
| 21 |
</package>
|
