Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,20 +463,8 @@ public function checkCustomerGroup(string $paymentMethod, bool $forceB2C = false
$configProvider = $this->configProviderMethodFactory->get($paymentMethodCode);
$configCustomerGroup = $configProvider->getSpecificCustomerGroup();

if (!$forceB2C
&& (
($paymentMethodCode == 'billink')
|| (
(($paymentMethodCode == 'afterpay') || ($paymentMethodCode == 'afterpay2'))
&& ($configProvider->getBusiness() == Business::BUSINESS_B2B)
)
|| (
($paymentMethodCode == 'payperemail') && ($configProvider->getEnabledB2B())
)
)
) {
if (!$forceB2C && $this->isBusinessCustomer($paymentMethodCode, $configProvider)) {
$configCustomerGroup = $configProvider->getSpecificCustomerGroupB2B();

}

if ($configCustomerGroup === null) {
Expand All @@ -503,6 +491,20 @@ public function checkCustomerGroup(string $paymentMethod, bool $forceB2C = false
return true;
}

private function isBusinessCustomer(string $paymentMethodCode, $configProvider): bool
{
return (
($paymentMethodCode == 'billink') ||
(
(($paymentMethodCode == 'afterpay') || ($paymentMethodCode == 'afterpay2')) &&
($configProvider->getBusiness() == Business::BUSINESS_B2B)
) ||
(
($paymentMethodCode == 'payperemail') && ($configProvider->getEnabledB2B())
)
);
}

private function checkCustomerGroupAdminArea(array $configCustomerGroupArr): bool
{
if (($customerId = $this->_getRequest()->getParam('customer_id')) && ($customerId > 0)) {
Expand Down
16 changes: 8 additions & 8 deletions Model/Method/Billink.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ public function assignData(\Magento\Framework\DataObject $data)

$additionalData = $data['additional_data'];

if (isset($additionalData['customer_billingName'])) {
$this->getInfoInstance()->setAdditionalInformation(
'customer_billingName',
$additionalData['customer_billingName']
);
}
// if (isset($additionalData['customer_billingName'])) {
// $this->getInfoInstance()->setAdditionalInformation(
// 'customer_billingName',
// $additionalData['customer_billingName']
// );
// }

if (isset($additionalData['customer_gender'])) {
$this->getInfoInstance()->setAdditionalInformation('customer_gender', $additionalData['customer_gender']);
}

if (isset($additionalData['customer_chamberOfCommerce'])) {
if (isset($additionalData['customer_chamberOfCommerce']) && !empty($additionalData['customer_chamberOfCommerce'])) {
$this->getInfoInstance()->setAdditionalInformation(
'customer_chamberOfCommerce',
$additionalData['customer_chamberOfCommerce']
Expand Down Expand Up @@ -681,7 +681,7 @@ public function getRequestBillingData($payment)
$telephone = $payment->getAdditionalInformation('customer_telephone');
$telephone = (empty($telephone) ? $billingAddress->getTelephone() : $telephone);

$category = $this->helper->checkCustomerGroup('buckaroo_magento2_billink') ? 'B2B' : 'B2C'; //1
$category = !empty($billingAddress->getCompany()) ? 'B2B' : 'B2C';

switch ($payment->getAdditionalInformation('customer_gender')) {
case 'male':
Expand Down
17 changes: 7 additions & 10 deletions Model/Method/Capayable/In3V3Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,22 @@ protected function getArticles($payment) {
$order = $payment->getOrder();
$products = $this->getProducts($order->getAllItems());

$costs = array_merge(
$costs = array_merge(
$this->getDiscountLine($order),
$this->getFeeLine($order),
$this->getShippingCostsLine($order)
);

$articles = array_merge(
$products,
count($costs) ? $costs: []
count($costs) ? $costs : []
);

$roundingErrors = $this->getRoundingErrors($payment, $articles);
if(is_array($roundingErrors)) {
$articles = array_merge(
$articles,
[$roundingErrors]
);
if ($roundingErrors !== null) {
$articles[] = $roundingErrors;
}

return $this->formatArticle($articles);
}

Expand Down Expand Up @@ -236,13 +233,13 @@ protected function getRoundingErrors($payment, array $articles)
return null;
}

return [[
return [
'id' => 'rounding_errors',
'description'=> 'Rounding Errors',
'qty' => 1,
'price' => $amount,
'vat' => 0,
]];
];
}

/**
Expand Down
7 changes: 6 additions & 1 deletion Model/Method/Knaken.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public function getVoidTransactionBuilder($payment)
*/
public function getPaymentMethodName($payment)
{
return 'Knaken Settle';
return $this->buckarooPaymentMethodCode;
}

protected function getRefundTransactionBuilderChannel()
{
return 'Web';
}
}
2 changes: 1 addition & 1 deletion Model/Method/SepaDirectDebit.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function validateAdditionalData() {
$billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
}

$ibanValidator = $this->objectManager->create(\Zend\Validator\Iban::class);
$ibanValidator = $this->objectManager->create(\Laminas\Validator\Iban::class);
if (empty($customerIban) || !$ibanValidator->isValid($customerIban)) {
throw new \Buckaroo\Magento2\Exception(__('Please enter a valid bank account number'));
}
Expand Down
6 changes: 6 additions & 0 deletions Model/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,12 @@ protected function saveInvoice()
if ($invoiceHandlingConfig == InvoiceHandlingOptions::SHIPMENT) {
$payment->setAdditionalInformation(InvoiceHandlingOptions::INVOICE_HANDLING, $invoiceHandlingConfig);
$payment->save();

if($this->hasPostData('brq_transaction_method', 'transfer')){
$this->order->setIsInProcess(true);
$this->order->save();
}

return true;
}

Expand Down
34 changes: 34 additions & 0 deletions Observer/AddCspNonce.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php declare(strict_types=1);

namespace Buckaroo\Magento2\Observer;

use Magento\Csp\Helper\CspNonceProvider;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\View\Element\Template;

class AddCspNonce implements ObserverInterface
{
private CspNonceProvider $cspNonceProvider;

public function __construct(
CspNonceProvider $cspNonceProvider
) {
$this->cspNonceProvider = $cspNonceProvider;
}

public function execute(Observer $observer)
{
/** @var Template $block */
$block = $observer->getEvent()->getBlock();
if (false === $block instanceof Template) {
return;
}

if (false === strstr($block->getNameInLayout(), 'buckaroo_magento2')) {
return;
}

$block->assign('cspNonce', $this->cspNonceProvider->generateNonce());
}
}
2 changes: 1 addition & 1 deletion Test/Unit/Model/Method/SepaDirectDebitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use Buckaroo\Magento2\Gateway\Http\TransactionBuilderFactory;
use Buckaroo\Magento2\Model\Method\SepaDirectDebit;
use Buckaroo\Magento2\Service\CreditManagement\ServiceParameters;
use Zend\Validator\Iban;
use Laminas\Validator\Iban;

class SepaDirectDebitTest extends \Buckaroo\Magento2\Test\BaseTest
{
Expand Down
26 changes: 26 additions & 0 deletions etc/frontend/events.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<!--
/**
* 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
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="view_block_abstract_to_html_before">
<observer name="buckaroo_magento2_update_order_status" instance="Buckaroo\Magento2\Observer\AddCspNonce" />
</event>
</config>
6 changes: 4 additions & 2 deletions view/frontend/templates/catalog/product/view/applepay.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

/** @var string $cspNonce */
?>
<?php if ($block->canShowProductButton()): ?>
<div id="apple-pay-catalog-product-view-component" data-bind="scope:'applepayproductcomponent'">
<!-- ko template: getTemplate() --><!-- /ko -->

<script>
<script nonce="<?= $cspNonce ?>">
if ('undefined' === typeof window.checkoutConfig) {
window.checkoutConfig = <?= /* @noEscape */ ($block->getApplepayConfig()); ?>;
window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
Expand All @@ -47,4 +49,4 @@
}
</script>
</div>
<?php endif; ?>
<?php endif; ?>
Loading