@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | protected $transactionId = null; |
39 | 39 | |
40 | - protected $apiUrl = array('live'=>'https://api.klarna.com/','test'=>'https://api.playground.klarna.com/'); |
|
40 | + protected $apiUrl = array('live'=>'https://api.klarna.com/', 'test'=>'https://api.playground.klarna.com/'); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Creates an instance of light connector |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | |
401 | 401 | $klarnaService = $this->getService(); |
402 | 402 | |
403 | - $klarnaAddrBilling = $this->getKlarnaAddrByRawOrderData($orderDataRaw,'billing'); |
|
404 | - $klarnaAddrShipping = $this->getKlarnaAddrByRawOrderData($orderDataRaw,'shipping'); |
|
403 | + $klarnaAddrBilling = $this->getKlarnaAddrByRawOrderData($orderDataRaw, 'billing'); |
|
404 | + $klarnaAddrShipping = $this->getKlarnaAddrByRawOrderData($orderDataRaw, 'shipping'); |
|
405 | 405 | |
406 | 406 | $transactionId = $orderDataRaw['transactionId']; |
407 | 407 | |
@@ -509,27 +509,27 @@ discard block |
||
509 | 509 | * @param mixed $mPrintableElement |
510 | 510 | * @return void |
511 | 511 | */ |
512 | - public function klarnaLog($message, $logLevelMessage=1, $mPrintableElement=null) { |
|
512 | + public function klarnaLog($message, $logLevelMessage = 1, $mPrintableElement = null) { |
|
513 | 513 | $configname = 'klarnaLogLevel'; |
514 | 514 | $elementId = Shopware()->Db()->fetchOne('SELECT id FROM s_core_config_elements WHERE name = ?', [$configname]); |
515 | 515 | $logLevelConfigSetting = Shopware()->Db()->fetchOne('SELECT value FROM s_core_config_values WHERE element_id = ?', [$elementId]); |
516 | 516 | $logLevelConfigSetting = unserialize($logLevelConfigSetting); |
517 | - $logLevelSetting = (is_numeric($logLevelConfigSetting) && $logLevelConfigSetting >=0 && $logLevelConfigSetting <=4) ? (int)$logLevelConfigSetting : 1; |
|
517 | + $logLevelSetting = (is_numeric($logLevelConfigSetting) && $logLevelConfigSetting >= 0 && $logLevelConfigSetting <= 4) ? (int) $logLevelConfigSetting : 1; |
|
518 | 518 | |
519 | 519 | if ($logLevelMessage <= $logLevelSetting) { |
520 | - $prefix = "[".date('Y-m-d H:i:s')."] "; |
|
520 | + $prefix = "[" . date('Y-m-d H:i:s') . "] "; |
|
521 | 521 | $debugBacktrace = ''; |
522 | 522 | if ($logLevelSetting >= 4) { |
523 | - $debugBacktrace = print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),true); |
|
523 | + $debugBacktrace = print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), true); |
|
524 | 524 | } |
525 | 525 | $sPrintableElementMessage = ''; |
526 | 526 | if ($mPrintableElement !== null) { |
527 | - $sPrintableElementMessage = print_r($mPrintableElement,true); |
|
527 | + $sPrintableElementMessage = print_r($mPrintableElement, true); |
|
528 | 528 | } |
529 | - $fullMessage = $prefix.$message."\n".$sPrintableElementMessage.$debugBacktrace; |
|
529 | + $fullMessage = $prefix . $message . "\n" . $sPrintableElementMessage . $debugBacktrace; |
|
530 | 530 | $shopPath = Shopware()->DocPath(); |
531 | - $logfilePath = $shopPath.'/var/log/klarnaTrace.log'; |
|
532 | - $fileHandler = fopen($logfilePath,'a'); |
|
531 | + $logfilePath = $shopPath . '/var/log/klarnaTrace.log'; |
|
532 | + $fileHandler = fopen($logfilePath, 'a'); |
|
533 | 533 | fwrite($fileHandler, $fullMessage); |
534 | 534 | fclose($fileHandler); |
535 | 535 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | $country = $repository->findOneBy(array('id' => $baseData['countryId'])); |
556 | 556 | $countryiso = $country->getIso(); |
557 | 557 | |
558 | - $klarnaAddr = new KlarnaAddr(); |
|
558 | + $klarnaAddr = new KlarnaAddr(); |
|
559 | 559 | $klarnaAddr->setEmail($orderDataRaw['customerEmail']); |
560 | 560 | $klarnaAddr->setFirstName($baseData['firstName']); |
561 | 561 | $klarnaAddr->setLastName($baseData['lastName']); |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | $klarnaAddr->setCountry($countryiso); |
571 | 571 | } |
572 | 572 | |
573 | - $this->klarnaLog('Update order address from backend with following address data:',3,$klarnaAddr); |
|
573 | + $this->klarnaLog('Update order address from backend with following address data:', 3, $klarnaAddr); |
|
574 | 574 | return $klarnaAddr; |
575 | 575 | } |
576 | 576 | |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | if ($index == count($addressParts) || $houseNumberFound) { |
599 | 599 | // at least last element should be streetnr |
600 | 600 | if (!empty($streetnr)) $streetnr .= ' '; |
601 | - $streetnr .= (string)$addressPart; |
|
601 | + $streetnr .= (string) $addressPart; |
|
602 | 602 | } |
603 | - else { |
|
604 | - $street .= (string)' '.$addressPart; |
|
603 | + else { |
|
604 | + $street .= (string) ' ' . $addressPart; |
|
605 | 605 | } |
606 | 606 | } |
607 | 607 | |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | $streetnr_extension .= $baseData['additionalAddressLine1']; |
611 | 611 | } |
612 | 612 | if (!empty($baseData['additionalAddressLine2'])) { |
613 | - $streetnr_extension .= "\n".$baseData['additionalAddressLine2']; |
|
613 | + $streetnr_extension .= "\n" . $baseData['additionalAddressLine2']; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | $return = array( |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | |
1290 | 1290 | // just return in case kco payment is deactivated in backend |
1291 | 1291 | |
1292 | - if (!$this->isKcoPaymentActive()){ |
|
1292 | + if (!$this->isKcoPaymentActive()) { |
|
1293 | 1293 | return; |
1294 | 1294 | } |
1295 | 1295 | $user = $view->getAssign('sUserData'); |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | && ($request->getActionName() == 'cart' || $request->getActionName() == 'ajaxCart') |
1301 | 1301 | ) { |
1302 | 1302 | $this->registerMyTemplateDir(); |
1303 | - $view->assign('KlarnaEnableButton', (bool)$config->get('showKlarnaButton')); |
|
1303 | + $view->assign('KlarnaEnableButton', (bool) $config->get('showKlarnaButton')); |
|
1304 | 1304 | $view->assign('KlarnaShowCheckoutButton', $this->getShowCheckoutButton($user)); |
1305 | 1305 | $view->assign('klarnaKcoPaymentActive', $this->isKlarnaKcoPaymentActive($user)); |
1306 | 1306 | $view->assign('KlarnaPaymentDescription', $this->getPayment()->getDescription()); |
@@ -1329,7 +1329,7 @@ discard block |
||
1329 | 1329 | $view->assign('KlarnaMerchantId', $config->get('merchantId')); |
1330 | 1330 | $view->assign('KlarnaHideCheckoutSteps', true); |
1331 | 1331 | |
1332 | - if (version_compare(Shopware::VERSION, '5.2.0', '<')){ |
|
1332 | + if (version_compare(Shopware::VERSION, '5.2.0', '<')) { |
|
1333 | 1333 | $view->assign('KlarnaSkipLoginFix', true); |
1334 | 1334 | } |
1335 | 1335 | if (!$this->isTemplateResponsive()) { |
@@ -1449,15 +1449,15 @@ discard block |
||
1449 | 1449 | $userData['additional'] |
1450 | 1450 | ); |
1451 | 1451 | |
1452 | - if (isset($session['sChangedCountry'])){ |
|
1452 | + if (isset($session['sChangedCountry'])) { |
|
1453 | 1453 | |
1454 | 1454 | /** @var \Shopware\Components\Model\ModelManager $em */ |
1455 | 1455 | $em = $this->get('models'); |
1456 | 1456 | |
1457 | 1457 | /** @var \Shopware\Models\Customer\Customer $customer */ |
1458 | 1458 | $country = $em->getRepository('Shopware\Models\Country\Country')->findOneBy(array('id' => $session['sChangedCountry'])); |
1459 | - $userData['shippingaddress']['country'] =$country; |
|
1460 | - $userData['billingaddress']['country'] =$country; |
|
1459 | + $userData['shippingaddress']['country'] = $country; |
|
1460 | + $userData['billingaddress']['country'] = $country; |
|
1461 | 1461 | $userData['shippingaddress']['countryID'] = $session['sChangedCountry']; |
1462 | 1462 | $userData['billingaddress']['countryID'] = $session['sChangedCountry']; |
1463 | 1463 | } |
@@ -1477,10 +1477,10 @@ discard block |
||
1477 | 1477 | $this->klarnaLog("Entering Bootstrap::getCountryByShop", 3); |
1478 | 1478 | $locale = explode('_', $locale); |
1479 | 1479 | $locale = isset($locale[1]) ? $locale[1] : $locale[0]; |
1480 | - $this->klarnaLog("Bootstrap::getCountryByShop locale to request for:".$locale,3); |
|
1480 | + $this->klarnaLog("Bootstrap::getCountryByShop locale to request for:" . $locale, 3); |
|
1481 | 1481 | $sql = 'SELECT id FROM s_core_countries WHERE countryiso=?'; |
1482 | 1482 | $countryId = Shopware()->Db()->fetchOne($sql, array($locale)); |
1483 | - $countryId = ($countryId) ? (int)$countryId : null; |
|
1483 | + $countryId = ($countryId) ? (int) $countryId : null; |
|
1484 | 1484 | |
1485 | 1485 | return $countryId; |
1486 | 1486 | } |
@@ -1511,7 +1511,7 @@ discard block |
||
1511 | 1511 | $locale = $locale == 'nn-no' ? 'nb-no' : $locale; |
1512 | 1512 | |
1513 | 1513 | if ($locale == 'de-de') { |
1514 | - if($countryIso == 'CH') { |
|
1514 | + if ($countryIso == 'CH') { |
|
1515 | 1515 | $locale = 'de-ch'; |
1516 | 1516 | } elseif ($countryIso == 'AT') { |
1517 | 1517 | $locale = 'de-at'; |
@@ -1526,10 +1526,10 @@ discard block |
||
1526 | 1526 | $config = $this->Config(); |
1527 | 1527 | $options = $this->getColorConfigOptions($config); |
1528 | 1528 | |
1529 | - $options['allow_separate_shipping_address'] = (bool)$config->get('allowSeparateShippingAddress'); |
|
1530 | - $options['packstation_enabled'] = (bool)$config->get('supportPackstation') && $allowPackstation; |
|
1531 | - $options['phone_mandatory'] = (bool)$config->get('mandatoryPhone'); |
|
1532 | - $options['date_of_birth_mandatory'] = (bool)$config->get('mandatoryBirthday'); |
|
1529 | + $options['allow_separate_shipping_address'] = (bool) $config->get('allowSeparateShippingAddress'); |
|
1530 | + $options['packstation_enabled'] = (bool) $config->get('supportPackstation') && $allowPackstation; |
|
1531 | + $options['phone_mandatory'] = (bool) $config->get('mandatoryPhone'); |
|
1532 | + $options['date_of_birth_mandatory'] = (bool) $config->get('mandatoryBirthday'); |
|
1533 | 1533 | |
1534 | 1534 | if (!empty($dispatch)) { |
1535 | 1535 | $options['shipping_details'] = $dispatch['description']; |
@@ -1544,19 +1544,19 @@ discard block |
||
1544 | 1544 | foreach ($basket['content'] as $index=>$basketItem) { |
1545 | 1545 | // compatibility to shopware plugin custom products |
1546 | 1546 | if (isset($basketItem['custom_product_prices'])) { |
1547 | - $basketItemPrice = (double)$basketItem['custom_product_prices']['total']; |
|
1547 | + $basketItemPrice = (double) $basketItem['custom_product_prices']['total']; |
|
1548 | 1548 | } |
1549 | 1549 | else { |
1550 | - $basketItemPrice = (double)str_replace(',', '.', $basketItem['price']); |
|
1550 | + $basketItemPrice = (double) str_replace(',', '.', $basketItem['price']); |
|
1551 | 1551 | } |
1552 | 1552 | $unitPrice = round($basketItemPrice * 100); |
1553 | 1553 | $cart[] = array( |
1554 | 1554 | 'type' => $unitPrice >= 0 ? 'physical' : 'discount', |
1555 | 1555 | 'reference' => $basketItem['ordernumber'], |
1556 | 1556 | 'name' => $basketItem['articlename'], |
1557 | - 'quantity' => (int)$basketItem['quantity'], |
|
1558 | - 'unit_price' => (int)$unitPrice, |
|
1559 | - 'tax_rate' => (int)round($basketItem['tax_rate'] * 100) |
|
1557 | + 'quantity' => (int) $basketItem['quantity'], |
|
1558 | + 'unit_price' => (int) $unitPrice, |
|
1559 | + 'tax_rate' => (int) round($basketItem['tax_rate'] * 100) |
|
1560 | 1560 | ); |
1561 | 1561 | } |
1562 | 1562 | if (!empty($basket['sShippingcosts'])) { |
@@ -1567,8 +1567,8 @@ discard block |
||
1567 | 1567 | 'reference' => 'SHIPPING', |
1568 | 1568 | 'name' => 'Shipping Fee', |
1569 | 1569 | 'quantity' => 1, |
1570 | - 'unit_price' => (int)round($shippingAmount * 100), |
|
1571 | - 'tax_rate' => (int)round($basket['sShippingcostsTax'] * 100), |
|
1570 | + 'unit_price' => (int) round($shippingAmount * 100), |
|
1571 | + 'tax_rate' => (int) round($basket['sShippingcostsTax'] * 100), |
|
1572 | 1572 | ); |
1573 | 1573 | } |
1574 | 1574 | |
@@ -1654,7 +1654,7 @@ discard block |
||
1654 | 1654 | } |
1655 | 1655 | |
1656 | 1656 | // Make sure phone number is unset if empty |
1657 | - if ($address['phone'] === null){ |
|
1657 | + if ($address['phone'] === null) { |
|
1658 | 1658 | unset($address['phone']); |
1659 | 1659 | } |
1660 | 1660 | return $address; |
@@ -1824,7 +1824,7 @@ discard block |
||
1824 | 1824 | |
1825 | 1825 | $salutation = $form['register']['personal']['salutation']; |
1826 | 1826 | if (!empty($salutation) && ($countryIso == 'DE' || $countryIso == 'NL')) { |
1827 | - $create['shipping_address']['title'] = ($salutation == 'ms' ? 'Frau' : 'Herr');//German names |
|
1827 | + $create['shipping_address']['title'] = ($salutation == 'ms' ? 'Frau' : 'Herr'); //German names |
|
1828 | 1828 | } |
1829 | 1829 | |
1830 | 1830 | $billingStreet = $form['register']['billing']['street']; |
@@ -1900,9 +1900,9 @@ discard block |
||
1900 | 1900 | $view->assign('sPayments', $this->filterPayments($adminModule->sGetPaymentMeans())); |
1901 | 1901 | $view->assign('sCountryList', $adminModule->sGetCountryList()); |
1902 | 1902 | $view->assign('KlarnaHideCheckoutSteps', true); |
1903 | - $view->assign('KlarnaShowB2bSelect', (bool)$config->get('showB2bSelect')); |
|
1904 | - $view->assign('KlarnaShowBasket', (bool)$config->get('showMiniBasket')); |
|
1905 | - $view->assign('KlarnaShowDispatch', (bool)$config->get('showDispatch')); |
|
1903 | + $view->assign('KlarnaShowB2bSelect', (bool) $config->get('showB2bSelect')); |
|
1904 | + $view->assign('KlarnaShowBasket', (bool) $config->get('showMiniBasket')); |
|
1905 | + $view->assign('KlarnaShowDispatch', (bool) $config->get('showDispatch')); |
|
1906 | 1906 | $view->assign( |
1907 | 1907 | 'KlarnaCDNLink', |
1908 | 1908 | $this->buildCDNLink() |
@@ -1912,7 +1912,7 @@ discard block |
||
1912 | 1912 | $view->sUserData['billingaddress']['lastname'] == 'Klarna Checkout' |
1913 | 1913 | ); |
1914 | 1914 | $debugShowLogin = !empty($session->sUserId); |
1915 | - $debugShowLogin2 = $this->getShowLoginConfig($config,!empty($session->sUserId)); |
|
1915 | + $debugShowLogin2 = $this->getShowLoginConfig($config, !empty($session->sUserId)); |
|
1916 | 1916 | $view->assign( |
1917 | 1917 | 'KlarnaShowLogin', |
1918 | 1918 | $this->getShowLoginConfig($config, !empty($session->sUserId)) |
@@ -1936,7 +1936,7 @@ discard block |
||
1936 | 1936 | */ |
1937 | 1937 | private function getShowLoginConfig($config, $userLoggedIn) |
1938 | 1938 | { |
1939 | - return (bool)$config->get('showLoginPanel') && !($userLoggedIn); |
|
1939 | + return (bool) $config->get('showLoginPanel') && !($userLoggedIn); |
|
1940 | 1940 | } |
1941 | 1941 | |
1942 | 1942 | /**demo |
@@ -2295,13 +2295,13 @@ discard block |
||
2295 | 2295 | /** @var Shopware\Models\Attribute\Payment $payment */ |
2296 | 2296 | foreach ($payments as $payment) { |
2297 | 2297 | $paymentObj = $payment->getPayment(); |
2298 | - if (is_null($paymentObj)){ |
|
2298 | + if (is_null($paymentObj)) { |
|
2299 | 2299 | $paymentName = false; |
2300 | 2300 | } else { |
2301 | 2301 | $paymentName = $paymentObj->getName(); |
2302 | 2302 | } |
2303 | 2303 | |
2304 | - if(!$paymentName){ |
|
2304 | + if (!$paymentName) { |
|
2305 | 2305 | continue; |
2306 | 2306 | } |
2307 | 2307 | |
@@ -2379,7 +2379,7 @@ discard block |
||
2379 | 2379 | { |
2380 | 2380 | $media = $payment->getSwagKlarnaKlarnaMedia(); |
2381 | 2381 | if (!$payment->getSwagKlarnaShowInKlarnaIframe() || !empty($media)) { |
2382 | - if ($this->assertMinimumVersion('5.1') && version_compare(Shopware::VERSION, '5.2.0', '<=') ) { |
|
2382 | + if ($this->assertMinimumVersion('5.1') && version_compare(Shopware::VERSION, '5.2.0', '<=')) { |
|
2383 | 2383 | $media = $this->get('shopware_media.media_service')->getUrl($media); |
2384 | 2384 | } else { |
2385 | 2385 | /** @var Enlight_Controller_Front $front */ |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | if ($this->Request()->getPost('sCountry')) { |
115 | - $this->session['sCountry'] = (int)$this->Request()->getPost('sCountry'); |
|
115 | + $this->session['sCountry'] = (int) $this->Request()->getPost('sCountry'); |
|
116 | 116 | $this->session["sState"] = 0; |
117 | 117 | $this->session["sArea"] = Shopware()->Db()->fetchOne(" |
118 | 118 | SELECT areaID FROM s_core_countries WHERE id = ? |
119 | 119 | ", [$this->session['sCountry']]); |
120 | 120 | unset($this->session->KlarnaOrder); |
121 | - $this->session['sChangedCountry'] = (int)$this->Request()->getPost('sCountry'); |
|
121 | + $this->session['sChangedCountry'] = (int) $this->Request()->getPost('sCountry'); |
|
122 | 122 | } |
123 | 123 | $this->forward('index'); |
124 | 124 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $this->redirect(['controller' => 'payment_klarna', 'action' => 'otherPayment']); |
159 | 159 | return; |
160 | 160 | } |
161 | - $shopCountryId = (string)$shopCountryId; |
|
161 | + $shopCountryId = (string) $shopCountryId; |
|
162 | 162 | if ($shopCountryId != $postedCountry) { |
163 | 163 | $this->session['sCountry'] = $postedCountry; |
164 | 164 | // unset klarnaOrder so it will be created with new countryID |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | |
314 | 314 | $this->basket['sAmountTax'] = 1.9; |
315 | 315 | $this->View()->sShippingcosts = $debugShipping['brutto']; |
316 | - $this->View()->sShippingcostsWithTax = $debugShipping['brutto']; |
|
316 | + $this->View()->sShippingcostsWithTax = $debugShipping['brutto']; |
|
317 | 317 | $this->View()->sShippingcostsNet = $debugShipping['netto']; |
318 | 318 | $this->View()->sShippingcostsTax = $debugShipping['tax']; |
319 | - $this->View()->sAmount = $this->basket['AmountWithTaxNumeric'] ; |
|
319 | + $this->View()->sAmount = $this->basket['AmountWithTaxNumeric']; |
|
320 | 320 | |
321 | 321 | $this->View()->sAmountNet = $this->basket['sAmountNet']; |
322 | 322 | $this->View()->sAmountTax = $this->basket['sAmountTax']; |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | ); |
791 | 791 | } |
792 | 792 | } catch (\Exception $ex) { /* do nothing */ |
793 | - $this->plugin->klarnaLog("ERROR while creating User. Exception information:". $ex->getMessage(), 1); |
|
793 | + $this->plugin->klarnaLog("ERROR while creating User. Exception information:" . $ex->getMessage(), 1); |
|
794 | 794 | } |
795 | 795 | } |
796 | 796 | } |
@@ -1036,8 +1036,8 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | $update['status'] = 'created'; |
1038 | 1038 | $update['merchant_reference'] = [ |
1039 | - 'orderid1' => (string)$orderNumber, |
|
1040 | - 'orderid2' => (string)$order['reference'] |
|
1039 | + 'orderid1' => (string) $orderNumber, |
|
1040 | + 'orderid2' => (string) $order['reference'] |
|
1041 | 1041 | ]; |
1042 | 1042 | $order->update($update); |
1043 | 1043 | } |
@@ -1366,8 +1366,8 @@ discard block |
||
1366 | 1366 | |
1367 | 1367 | $update['status'] = 'created'; |
1368 | 1368 | $update['merchant_reference'] = [ |
1369 | - 'orderid1' => (string)$orderNumber, |
|
1370 | - 'orderid2' => (string)$order['reference'] |
|
1369 | + 'orderid1' => (string) $orderNumber, |
|
1370 | + 'orderid2' => (string) $order['reference'] |
|
1371 | 1371 | ]; |
1372 | 1372 | $order->update($update); |
1373 | 1373 | } |
@@ -449,7 +449,7 @@ |
||
449 | 449 | $orderId = $this->Request()->getParam('orderId'); |
450 | 450 | $this->registerShopByOrderId($orderId); |
451 | 451 | $order = $this->getOrderById($orderId); |
452 | - $value = (float)str_replace(',', '.', $this->Request()->getParam('value')); |
|
452 | + $value = (float) str_replace(',', '.', $this->Request()->getParam('value')); |
|
453 | 453 | $service = $this->getService($order); |
454 | 454 | |
455 | 455 | /** @noinspection PhpUndefinedMethodInspection */ |