Skip to content

Commit

Permalink
Merge pull request #1154 from buckaroo-it/develop
Browse files Browse the repository at this point in the history
Update, Test & Release (1.51.0)
  • Loading branch information
vegimcarkaxhija authored Jan 22, 2025
2 parents f0bbe9b + 10cef65 commit 75db780
Show file tree
Hide file tree
Showing 173 changed files with 4,095 additions and 4,482 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/icons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Copy payment method icons
run: |
cd "${{ github.workspace }}/Media/Payment methods/SVG/"
rm -f ideal-qr.svg knaken.svg paylink.svg paybybank.svg pos-nfc.svg
rm -f ideal-qr.svg knaken.svg paylink.svg paybybank.svg pos-nfc.svg giropay.svg sofort.svg
cd ${{ github.workspace }}/Media
cp -R "Payment methods/SVG/." ${{ github.workspace }}/view/base/web/images/svg/
- name: Copy creditcards icons
Expand All @@ -35,7 +35,7 @@ jobs:
rm -f vvvlekkerweg.svg vvvshopchill.svg
cd ${{ github.workspace }}/Media
cp -R "Giftcards/SVG/." ${{ github.workspace }}/view/base/web/images/giftcards/
- name: Copy payment issuers icons
run: |
cd Media
Expand Down
19 changes: 5 additions & 14 deletions Block/Adminhtml/Sales/Totals.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,9 @@ public function __construct(
public function initTotals()
{
$parent = $this->getParentBlock();
/**
* @noinspection PhpUndefinedMethodInspection
*/
$source = $parent->getSource();
$totals = $this->getTotalsForCreditmemo($source);
foreach ($totals as $total) {
/**
* @noinspection PhpUndefinedMethodInspection
*/
$this->getParentBlock()->addTotalBefore(new \Magento\Framework\DataObject($total), 'grand_total');
}
return $this;
Expand All @@ -72,12 +66,9 @@ public function initTotals()
public function getTotals()
{
$parent = $this->getParentBlock();
/**
* @noinspection PhpUndefinedMethodInspection
*/
$source = $parent->getSource();


return $this->getTotalsForCreditmemo($source);
}

Expand All @@ -92,7 +83,7 @@ public function getCurrentCurrencySymbol()
}

/**
* For credit memo display the fees from invoice/order,
* For credit memo display the fees from invoice/order,
* check if invoice has that fee and set selected
*
* @param mixed $source
Expand All @@ -107,7 +98,7 @@ protected function getTotalsForCreditmemo($source)
$invoice = $source->getInvoice();
$salesModel = ($invoice != null? $invoice : $order);
$saleTotals = $this->helper->getTotals($salesModel);

$saleTotals = array_map(function($saleTotal) use($creditTotals) {
if (in_array($saleTotal['code'],['buckaroo_fee', 'buckaroo_fee_excl'] )) {
$saleTotal['block_name'] = "buckaroo_fee";
Expand All @@ -116,12 +107,12 @@ protected function getTotalsForCreditmemo($source)
return $saleTotal;
}, $saleTotals);


return array_merge(
$this->getTotalsByCode($creditTotals, 'buckaroo_already_paid'),
$this->getTotalsExceptCode($saleTotals, 'buckaroo_already_paid')
);

}
return $this->helper->getTotals($source);
}
Expand Down
60 changes: 46 additions & 14 deletions Block/Cart/BuckarooConfig.php
Original file line number Diff line number Diff line change
@@ -1,37 +1,58 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to support@buckaroo.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact support@buckaroo.nl for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Buckaroo\Magento2\Block\Cart;

class BuckarooConfig extends \Magento\Backend\Block\Template
use Buckaroo\Magento2\Exception;
use Buckaroo\Magento2\Model\ConfigProvider\Factory;
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Serialize\Serializer\Json;

class BuckarooConfig extends Template
{
/**
* @var bool
*/
protected $_isScopePrivate = false;

/**
* @var \Buckaroo\Magento2\Model\ConfigProvider\Factory
* @var Factory
*/
protected $configProviderFactory;

/**
* @var \Magento\Framework\Json\Encoder
* @var Json
*/
protected $jsonEncoder;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Json\Encoder $jsonEncoder
* @param \Buckaroo\Magento2\Model\ConfigProvider\Factory $configProviderFactory
* @param array $data
* @param Context $context
* @param Json $jsonEncoder
* @param Factory $configProviderFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Json\Encoder $jsonEncoder,
\Buckaroo\Magento2\Model\ConfigProvider\Factory $configProviderFactory,
Context $context,
Json $jsonEncoder,
Factory $configProviderFactory,
array $data = []
) {
parent::__construct($context, $data);
Expand All @@ -42,11 +63,22 @@ public function __construct(
/**
* Retrieve buckaroo configuration
*
* @return array
* @return string
* @throws Exception
*/
public function getBuckarooConfigJson()
{
$configProvider = $this->configProviderFactory->get('buckaroo_fee');
return $this->jsonEncoder->encode($configProvider->getConfig());
return $this->jsonEncoder->serialize($configProvider->getConfig());
}

/**
* Get CSP nonce
*
* @return string
*/
public function getCspNonce()
{
return $this->getData('cspNonce') ?: '';
}
}
18 changes: 14 additions & 4 deletions Block/Catalog/Product/View/Applepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Magento\Checkout\Model\Cart;
use Magento\Checkout\Model\CompositeConfigProvider;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Buckaroo\Magento2\Model\ConfigProvider\Method\Applepay as ApplepayConfig;
Expand Down Expand Up @@ -58,13 +59,22 @@ public function __construct(
}

/**
* @param $page
* @return bool
* @throws NoSuchEntityException
*/
public function canShowButton($page)
public function canShowButton($page): bool
{
return $this->isModuleActive() &&
in_array($page, $this->applepayConfigProvider->getAvailableButtons()) &&
$this->applepayConfigProvider->isApplePayEnabled($this->_storeManager->getStore());
if (!$this->isModuleActive()) {
return false;
}

$availableButtons = $this->applepayConfigProvider->getAvailableButtons();
if (!in_array($page, $availableButtons, true)) {
return false;
}

return $this->applepayConfigProvider->isApplePayEnabled($this->_storeManager->getStore());
}

/**
Expand Down
12 changes: 11 additions & 1 deletion Block/Checkout/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Success extends \Magento\Checkout\Block\Onepage\Success
protected $currentCustomer;

/**
* @param Template\Context $context
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Sales\Model\Order\Config $orderConfig
* @param \Magento\Framework\App\Http\Context $httpContext
Expand All @@ -52,4 +52,14 @@ public function __construct(
);
$this->currentCustomer = $currentCustomer;
}

/**
* Get CSP nonce
*
* @return string
*/
public function getCspNonce()
{
return $this->getData('cspNonce') ?: '';
}
}
1 change: 0 additions & 1 deletion Block/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function getPaymentLogo(string $method): string
"mrcash" => "svg/bancontact.svg",
"p24" => "svg/przelewy24.svg",
"sepadirectdebit" => "svg/sepa-directdebit.svg",
"sofortbanking" => "svg/sofort.svg",
"emandate" => "emandate.png",
"pospayment" => "pos.png",
"transfer" => "svg/sepa-credittransfer.svg",
Expand Down
2 changes: 0 additions & 2 deletions Block/Widget/Button/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ class Toolbar
'buckaroo_magento2_paypal',
'buckaroo_magento2_payconiq',
'buckaroo_magento2_sepadirectdebit',
'buckaroo_magento2_sofortbanking',
'buckaroo_magento2_belfius',
'buckaroo_magento2_transfer',
'buckaroo_magento2_eps',
'buckaroo_magento2_giropay',
'buckaroo_magento2_kbc',
'buckaroo_magento2_klarna',
'buckaroo_magento2_klarnakp',
Expand Down
14 changes: 13 additions & 1 deletion Controller/Applepay/SaveOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
namespace Buckaroo\Magento2\Controller\Applepay;

use Buckaroo\Magento2\Logging\Log;
use Buckaroo\Magento2\Model\Config\Source\InvoiceHandlingOptions;
use Buckaroo\Magento2\Model\ConfigProvider\Account;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\Page;
Expand All @@ -35,6 +37,7 @@ class SaveOrder extends Common
protected $order;
protected $checkoutSession;
protected $accountConfig;
private $configAccount;

/**
* @param Context $context
Expand All @@ -47,6 +50,7 @@ public function __construct(
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
Log $logger,
\Magento\Checkout\Model\Cart $cart,
Account $configAccount,
\Magento\Quote\Model\QuoteManagement $quoteManagement,
\Magento\Customer\Model\Session $customer,
\Magento\Framework\DataObjectFactory $objectFactory,
Expand All @@ -69,7 +73,7 @@ public function __construct(
$converter,
$customerSession
);

$this->configAccount = $configAccount;
$this->quoteManagement = $quoteManagement;
$this->customer = $customer;
$this->objectFactory = $objectFactory;
Expand Down Expand Up @@ -126,6 +130,14 @@ public function execute()
$payment->setMethod(Applepay::PAYMENT_METHOD_CODE);
$quote->setPayment($payment);


$invoiceHandlingConfig = $this->configAccount->getInvoiceHandling($this->order->getStore());

if ($invoiceHandlingConfig == InvoiceHandlingOptions::SHIPMENT) {
$payment->setAdditionalInformation(InvoiceHandlingOptions::INVOICE_HANDLING, $invoiceHandlingConfig);
$payment->save();
$quote->setPayment($payment);
}
$quote->collectTotals()->save();

$obj = $this->objectFactory->create();
Expand Down
Loading

0 comments on commit 75db780

Please sign in to comment.