Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bp 3851 update test release v1.50.2 #1090

Merged
merged 16 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
0f588c5
Merge pull request #1056 from buckaroo-it/develop
vegimcarkaxhija Sep 17, 2024
44c1129
Merge pull request #1058 from buckaroo-it/develop
vegimcarkaxhija Sep 17, 2024
d0bf2ba
Merge pull request #1064 from buckaroo-it/develop
vegimcarkaxhija Sep 23, 2024
f4368a9
Update logo in README.md (#1076)
Buckaroo-Rene Oct 22, 2024
9ebe257
update ideal fast checkout email sender
vegimcarkaxhija Oct 22, 2024
698773e
Merge pull request #1071 from buckaroo-it/BP-3761-Adjustment-in-the-m…
vegimcarkaxhija Oct 15, 2024
867a4c4
Merge pull request #1075 from buckaroo-it/BP-3843-v1.50-breaks-Magent…
vegimcarkaxhija Oct 21, 2024
1e69ef1
Merge pull request #1073 from buckaroo-it/BP-3838-Refactor-Fast-Check…
vegimcarkaxhija Oct 16, 2024
67033db
Merge pull request #1078 from buckaroo-it/BP-3697-iDEAL-fast-checkout…
vegimcarkaxhija Oct 23, 2024
8935966
Merge pull request #1074 from buckaroo-it/BP-3663-Buckaroo-Payment-Fe…
SandervdHulst Oct 18, 2024
60566e3
change version number
vegimcarkaxhija Oct 23, 2024
5acc459
BP-3847-Tax percentage not send in request for Riverty/Klarna/Billink
SandervdHulst Oct 23, 2024
7fee500
BP-3847-Tax percentage not send in request for Riverty/Klarna/Billink
SandervdHulst Oct 23, 2024
6f53077
Merge pull request #1080 from buckaroo-it/BP-3856-Add-CSP-allow-list-…
vegimcarkaxhija Oct 24, 2024
385f7d1
Merge pull request #1082 from buckaroo-it/BP-3859-Check-settings-for-…
vegimcarkaxhija Oct 24, 2024
6d0cfbe
Merge pull request #1083 from buckaroo-it/BP-3856-Add-CSP-allow-list-…
vegimcarkaxhija Nov 5, 2024
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
4 changes: 1 addition & 3 deletions Api/Data/QuoteCreateResponseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
namespace Buckaroo\Magento2\Api\Data;

use Buckaroo\Magento2\Api\Data\BreakdownItemInterface;

interface QuoteCreateResponseInterface extends BreakdownItemInterface
{
/**
Expand All @@ -36,4 +34,4 @@ public function getBreakdown();
* @return string
*/
public function getCartId();
}
}
5 changes: 1 addition & 4 deletions Api/IdealQuoteCreateInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@

namespace Buckaroo\Magento2\Api;

use Buckaroo\Magento2\Api\Data\QuoteCreateResponseInterface;
use Buckaroo\Magento2\Api\Data\Ideal\ShippingAddressRequestInterface;

interface IdealQuoteCreateInterface
{
/**
* Get order breakdown after shipping is applied
*
* @param string $page
* @param string|null $order_data
* @return QuoteCreateResponseInterface
* @return \Buckaroo\Magento2\Api\Data\QuoteCreateResponseInterface
*/
public function execute(
string $page,
Expand Down
5 changes: 2 additions & 3 deletions Api/PayWithGiftcardInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@

use Buckaroo\Magento2\Api\Data\Giftcard\PayRequestInterface;

interface PayWithGiftcardInterface
interface PayWithGiftcardInterface
{
/**
* Rest method for paying with giftcards
*
* @param string $cartId
* @param string $giftcardId
* @param \Buckaroo\Magento2\Api\Data\Giftcard\PayRequestInterface $requestBody
*
* @param \Buckaroo\Magento2\Api\Data\Giftcard\PayRequestInterface $payment
* @return \Buckaroo\Magento2\Api\Data\Giftcard\PayResponseInterface
*/
public function pay(string $cartId, string $giftcardId, PayRequestInterface $payment);
Expand Down
3 changes: 1 addition & 2 deletions Api/PaypalExpressQuoteCreateInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
namespace Buckaroo\Magento2\Api;

use Buckaroo\Magento2\Api\Data\PaypalExpress\ShippingAddressRequestInterface;
use Buckaroo\Magento2\Api\Data\QuoteCreateResponseInterface;

interface PaypalExpressQuoteCreateInterface
{
Expand All @@ -32,7 +31,7 @@ interface PaypalExpressQuoteCreateInterface
* @param \Buckaroo\Magento2\Api\Data\PaypalExpress\ShippingAddressRequestInterface $shipping_address
* @param string $page
* @param string|null $order_data
* @return QuoteCreateResponseInterface
* @return \Buckaroo\Magento2\Api\Data\QuoteCreateResponseInterface
*/
public function execute(
ShippingAddressRequestInterface $shipping_address,
Expand Down
41 changes: 9 additions & 32 deletions Block/Catalog/Product/View/Applepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,52 +60,29 @@ public function __construct(
/**
* @return bool
*/
public function canShowButton()
public function canShowButton($page)
{
$result = false;

if ($this->cart->getSummaryQty()
&&
($this->applepayConfigProvider->getActive() != 0)
&&
($this->applepayConfigProvider->getAvailableButtons())
&&
(in_array('Cart', $this->applepayConfigProvider->getAvailableButtons()))
) {
$result = true;
}

return $result;
return $this->isModuleActive() &&
in_array($page, $this->applepayConfigProvider->getAvailableButtons()) &&
$this->applepayConfigProvider->isApplePayEnabled($this->_storeManager->getStore());
}

/**
* Check if Buckaroo module is active
*
* @return bool
*/
public function canShowProductButton()
public function isModuleActive()
{
$result = false;

if (($this->applepayConfigProvider->getActive() != 0)
&&
($this->applepayConfigProvider->getAvailableButtons())
&&
(in_array('Product', $this->applepayConfigProvider->getAvailableButtons()))
) {
$result = true;
}

return $result;
$status = $this->applepayConfigProvider->getActive();
return $status == 1 || $status == 2;
}

/**
* @return false|string
*/
public function getCheckoutConfig()
{
if (!$this->canShowButton()) {
return null;
}

return json_encode($this->compositeConfigProvider->getConfig(), JSON_HEX_TAG);
}

Expand Down
42 changes: 5 additions & 37 deletions Block/Catalog/Product/View/IdealFastCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,12 @@ public function __construct(
*
* @return bool
*/
public function canShowProductButton()
public function canShowButton($page)
{
if ($this->isModuleActive() && $this->isButtonEnabled()){
return $this->idealConfig->canShowButtonForPage(
'Product',
$this->_storeManager->getStore()
);
}
return false;
}

/**
* Determine if the cart button can be shown
*
* @return bool
*/
public function canShowCartButton()
{
if ($this->isModuleActive() && $this->isButtonEnabled()){
return $this->idealConfig->canShowButtonForPage(
'Cart',
$this->_storeManager->getStore()
);
}
return false;
return ($this->isModuleActive() &&
$this->idealConfig->isFastCheckoutEnabled($this->_storeManager->getStore()) &&
$this->idealConfig->canShowButtonForPage($page, $this->_storeManager->getStore()) &&
$this->idealConfig->isIDealEnabled($this->_storeManager->getStore()));
}

/**
Expand All @@ -107,19 +88,6 @@ public function isModuleActive()
return $status == 1 || $status == 2;
}

/**
* Check if ideal fast checkout button is enabled
*
* @return mixed
*/
public function isButtonEnabled()
{
return $this->idealConfig->isFastCheckoutEnabled(
$this->_storeManager->getStore()
);
}


/**
* Get logo based on chosen color setting
*
Expand Down
24 changes: 5 additions & 19 deletions Block/Catalog/Product/View/PaypalExpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,11 @@ public function __construct(
$this->encryptor = $encryptor;
$this->paypalConfig = $paypalConfig;
}
public function canShowProductButton()
public function canShowButton($page)
{
if ($this->isModuleActive()){
return $this->paypalConfig->canShowButtonForPage(
'Product',
$this->_storeManager->getStore()
);
}
return false;
}

public function canShowCartButton()
{
if ($this->isModuleActive()){
return $this->paypalConfig->canShowButtonForPage(
'Cart',
$this->_storeManager->getStore()
);
}
return false;
return $this->isModuleActive() &&
$this->paypalConfig->canShowButtonForPage($page, $this->_storeManager->getStore()) &&
$this->paypalConfig->isPayPalEnabled($this->_storeManager->getStore());
}

/**
Expand All @@ -88,6 +73,7 @@ public function isModuleActive()
$status = $this->configProviderAccount->getActive();
return $status == 1 || $status == 2;
}

/**
* Get all data required
*
Expand Down
13 changes: 8 additions & 5 deletions Controller/Redirect/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,16 @@ private function redirectProcess() {
|| $paymentMethod->getConfigData('order_email', $store) === "1"
)
) {
if (!($this->hasPostData('add_initiated_by_magento', 1) &&
$this->hasPostData('brq_primary_service', 'KlarnaKp') &&
$this->hasPostData('add_service_action_from_magento', 'reserve') &&
!empty($this->response['brq_service_klarnakp_reservationnumber'])
if (!(
($this->hasPostData('add_initiated_by_magento', 1) &&
$this->hasPostData('brq_primary_service', 'KlarnaKp') &&
$this->hasPostData('add_service_action_from_magento', 'reserve') &&
!empty($this->response['brq_service_klarnakp_reservationnumber']))
||
$this->hasPostData('add_service_action_from_magento', 'payfastcheckout')
)) {
if ($statusCode == $this->helper->getStatusCode('BUCKAROO_MAGENTO2_STATUSCODE_SUCCESS')) {
$this->logger->addDebug(__METHOD__ . '|sendemail|');
$this->logger->addDebug(__METHOD__ . '|sendemail| |1|');
$this->orderSender->send($this->order, true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public function areEqualAmounts($amount1, $amount2)
if ($amount2 == 0) {
return $amount1 == $amount2;
} else {
return abs((floatval($amount1) - floatval($amount2)) / floatval($amount2)) < 0.00001;
return abs((floatval($amount1) - floatval($amount2)) / floatval($amount2)) <= 0.01;
}
}

Expand Down
4 changes: 4 additions & 0 deletions Model/ConfigProvider/Method/Applepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,8 @@ public function getBaseAllowedCurrencies()
];
}

public function isApplePayEnabled($store = null)
{
return $this->getConfigFromXpath(self::XPATH_APPLEPAY_ACTIVE, $store);
}
}
5 changes: 5 additions & 0 deletions Model/ConfigProvider/Method/Ideal.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public function isFastCheckoutEnabled($store = null)
return $this->getConfigFromXpath(self::XPATH_IDEAL_FAST_CHECKOUT_ENABLE, $store);
}

public function isIDealEnabled($store = null)
{
return $this->getConfigFromXpath(self::XPATH_IDEAL_ACTIVE, $store);
}

public function getLogoColor($store = null)
{
return $this->getConfigFromXpath(self::XPATH_IDEAL_FAST_CHECKOUT_LOGO, $store);
Expand Down
6 changes: 5 additions & 1 deletion Model/ConfigProvider/Method/Paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getExpressMerchantId($store = null)
return $this->getConfigFromXpath(self::XPATH_PAYPAL_EXPRESS_MERCHANT_ID, $store);
}
/**
* Test if express button is enabled for the $page
* Test if express button is enabled for the $page
*
* @param string $page
*
Expand All @@ -124,4 +124,8 @@ public function canShowButtonForPage($page, $store = null)
$pages = explode(",", $buttons);
return in_array($page, $pages);
}
public function isPayPalEnabled($store = null)
{
return $this->getConfigFromXpath(self::XPATH_PAYPAL_ACTIVE, $store);
}
}
19 changes: 15 additions & 4 deletions Model/Method/AbstractMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -2124,9 +2124,20 @@ public function getArticleArrayLine(

protected function getTaxCategory($order)
{
$request = $this->taxCalculation->getRateRequest(null, null, null, $order->getStore());
$taxClassId = $this->configProviderBuckarooFee->getTaxClass($order->getStore());
$percent = $this->taxCalculation->getRate($request->setProductClassId($taxClassId));
$shippingAddress = $order->getShippingAddress();
$billingAddress = $order->getBillingAddress();
$customerTaxClassId = $order->getCustomerTaxClassId();
$storeId = $order->getStoreId();
$taxClassId = $this->configProviderBuckarooFee->getTaxClass();

$request = $this->taxCalculation->getRateRequest(
$shippingAddress,
$billingAddress,
$customerTaxClassId,
$storeId
);
$request->setProductClassId($taxClassId);
$percent = $this->taxCalculation->getRate($request);
return $percent;
}

Expand Down Expand Up @@ -2725,7 +2736,7 @@ public function checkTotalGrossAmount($requestData, $payment)
}

//Add diff line
if (!$this->helper->areEqualAmounts($order->getGrandTotal(), $itemsTotalAmount) && !$this->payRemainder) {
if (abs($order->getGrandTotal() - $itemsTotalAmount) > 0.01) {
$diff = $order->getGrandTotal() - $itemsTotalAmount;
$diffLine = $this->getDiffLine($count, $diff);
$requestData = array_merge($requestData, $diffLine);
Expand Down
23 changes: 23 additions & 0 deletions Model/Method/Ideal.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public function assignData(\Magento\Framework\DataObject $data)
$this->getInfoInstance()->setAdditionalInformation('issuer', $data['additional_data']['issuer']);
}

$payment = $this->getInfoInstance();
$quote = $payment->getQuote();

if ($quote) {
$shippingCost = $quote->getShippingAddress()->getShippingAmount();
$this->getInfoInstance()->setAdditionalInformation('shippingCost', $shippingCost);
}

return $this;
}

Expand All @@ -67,6 +75,7 @@ public function getOrderTransactionBuilder($payment)
'Name' => 'ideal',
'Action' => $this->getPayRemainder($payment, $transactionBuilder,'PayFastCheckout'),
'Version' => 2,
'RequestParameter' => $this->getIdealFastCheckoutOrderRequestParameters($payment),
];

/**
Expand Down Expand Up @@ -110,6 +119,20 @@ private function getOrderRequestParameters($payment): array
return $parameters;
}

private function getIdealFastCheckoutOrderRequestParameters($payment): array
{
$parameters = [];

if ($this->isFastCheckout($payment) && $payment->getAdditionalInformation('shippingCost')) {
$parameters = [[
'_' => $payment->getAdditionalInformation('shippingCost'),
'Name' => 'shippingCost',
]];
}

return $parameters;
}

protected function getRefundTransactionBuilderVersion()
{
return null;
Expand Down
7 changes: 3 additions & 4 deletions Model/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ public function receivePush()
try {
$response = $this->pushProcess();

if ($this->isFastCheckout()) {
$this->updateOrderAddressesIfFastCheckout();
}

return $response;
} catch (\Throwable $e) {
$this->logging->addDebug(__METHOD__ . '|Exception|' . $e->getMessage());
Expand Down Expand Up @@ -597,6 +593,9 @@ private function pushProcess()
);
}

if ($this->isFastCheckout()) {
$this->updateOrderAddressesIfFastCheckout();
}

if (!$this->isGroupTransactionInfo()) {
$this->setTransactionKey();
Expand Down
Loading
Loading