Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FatchipRobert committed Nov 2, 2021
2 parents 30ce4b9 + b249625 commit 9aea22d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Model/Api/SendConfirmationDeliver.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function sendRatepayDeliverCall($order, $paymentMethod, $inv = null)
$inv = $order;
}

$sandbox = (bool)$this->rpDataHelper->getRpConfigData($paymentMethod, 'sandbox', $this->storeManager->getStore()->getId());
$sandbox = (bool)$this->rpDataHelper->getRpConfigData($paymentMethod, 'sandbox', $order->getStore()->getId());
$head = $this->rpLibraryModel->getRequestHead($order, 'CONFIRMATION_DELIVER', null, null, null, null, $this->getTrackingInfo($order));
$content = $this->rpLibraryModel->getRequestContent($inv, 'CONFIRMATION_DELIVER');

Expand Down
2 changes: 1 addition & 1 deletion Model/Handler/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function addAdjustmentsToDb($order, $creditMemo)
if ($creditMemo->getAdjustmentPositive() > 0) {
$this->artNumRefund = 'adj-ref'.$this->orderAdjustment->getNextArticleNumberCounter($order->getId(), 'positive');
$is_specialitem = false;
if ($this->rpDataHelper->getRpConfigData('ratepay_general', 'creditmemo_discount_type') == CreditmemoDiscountType::SPECIAL_ITEM) {
if ($this->rpDataHelper->getRpConfigData('ratepay_general', 'creditmemo_discount_type', $order->getStore()->getId()) == CreditmemoDiscountType::SPECIAL_ITEM) {
$is_specialitem = true;
}
$this->orderAdjustment->addOrderAdjustment($order->getId(), 'positive', $this->artNumRefund, $creditMemo->getAdjustmentPositive(), $creditMemo->getBaseAdjustmentPositive(), $is_specialitem);
Expand Down
2 changes: 1 addition & 1 deletion Model/LibraryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function addAdjustments($creditmemo, $artNumRefund, $artNumFee)
$content = [];

if ($creditmemo->getAdjustmentPositive() > 0) {
if ($this->rpDataHelper->getRpConfigData('ratepay_general', 'creditmemo_discount_type') == CreditmemoDiscountType::SPECIAL_ITEM) {
if ($this->rpDataHelper->getRpConfigData('ratepay_general', 'creditmemo_discount_type', $creditmemo->getOrder()->getStore()->getId()) == CreditmemoDiscountType::SPECIAL_ITEM) {
$content['Discount'] = $this->rpContentBasketDiscountHelper->setDiscount((float) $creditmemo->getAdjustmentPositive() * -1, 'Adjustment Refund');
} else {
$content['Items'][] = ['Item' => $this->addAdjustment((float) $creditmemo->getAdjustmentPositive() * -1, 'Adjustment Refund', $artNumRefund)];
Expand Down
16 changes: 8 additions & 8 deletions Model/Method/AbstractMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,18 @@ public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount
$order = $this->getQuoteOrOrder();

$head = $this->_rpLibraryModel->getRequestHead($order);
$sandbox = (bool)$this->rpDataHelper->getRpConfigData($this->_code, 'sandbox');
$sandbox = (bool)$this->rpDataHelper->getRpConfigData($this->_code, 'sandbox', $order->getStore()->getId());
$company = $order->getBillingAddress()->getCompany();

if (!$this->rpDataHelper->getRpConfigData($this->_code, 'b2b') && !empty($company)) {
if (!$this->rpDataHelper->getRpConfigData($this->_code, 'b2b', $order->getStore()->getId()) && !empty($company)) {
throw new PaymentException(__('b2b not allowed'));
}

$billingAddress = $order->getBillingAddress();
$shippingAddress = $order->getShippingAddress();
$diff = array_diff($this->rpDataHelper->getImportantAddressData($shippingAddress), $this->rpDataHelper->getImportantAddressData($billingAddress));

if (!$this->rpDataHelper->getRpConfigData($this->_code, 'delivery_address') && count($diff)) {
if (!$this->rpDataHelper->getRpConfigData($this->_code, 'delivery_address', $order->getStore()->getId()) && count($diff)) {
throw new PaymentException(__('ala not allowed'));
}

Expand Down Expand Up @@ -446,8 +446,8 @@ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
$minAmount = $this->rpDataHelper->getRpConfigDataForQuote($this->_code, 'min_order_total', $quote);
$maxAmount = $this->rpDataHelper->getRpConfigDataForQuote($this->_code, 'max_order_total', $quote);

if (!empty($quote->getBillingAddress()->getCompany()) && $this->getIsB2BModeEnabled($totalAmount)) {
$maxAmount = $this->rpDataHelper->getRpConfigData($this->_code, 'limit_max_b2b');
if (!empty($quote->getBillingAddress()->getCompany()) && $this->getIsB2BModeEnabled($totalAmount, $quote)) {
$maxAmount = $this->rpDataHelper->getRpConfigDataForQuote($this->_code, 'limit_max_b2b', $quote);
}

if ($totalAmount < $minAmount || $totalAmount > $maxAmount) {
Expand Down Expand Up @@ -598,10 +598,10 @@ public function formatMessage($message)
return strip_tags($message);
}

public function getIsB2BModeEnabled($grandTotal = null)
public function getIsB2BModeEnabled($grandTotal = null, $quote = null)
{
$blB2BEnabled = (bool)$this->rpDataHelper->getRpConfigData($this->_code, 'b2b');
$dB2BMax = $this->rpDataHelper->getRpConfigData($this->_code, 'limit_max_b2b');
$blB2BEnabled = (bool)$this->rpDataHelper->getRpConfigDataForQuote($this->_code, 'b2b', $quote);
$dB2BMax = $this->rpDataHelper->getRpConfigDataForQuote($this->_code, 'limit_max_b2b', $quote);
if ($blB2BEnabled === true && ($grandTotal === null || ($grandTotal <= $dB2BMax))) {
return true;
}
Expand Down
27 changes: 27 additions & 0 deletions Plugin/EscapeRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace RatePAY\Payment\Plugin;

use Magento\Framework\View\Element\Message\Renderer\EscapeRenderer as OrigEscapeRenderer;
use Magento\Framework\Message\MessageInterface;

class EscapeRenderer
{
/**
* Renders complex message
*
* @param OrigEscapeRenderer $subject
* @param \Closure $proceed
* @param MessageInterface $message
* @param array $initializationData
* @return string
*/
public function aroundRender(OrigEscapeRenderer $subject, \Closure $proceed, MessageInterface $message, array $initializationData)
{
$text = $message->getText();
if (stripos($text, "Ratepay") !== false && stripos($text, "href") !== false) {
return $text;
}
return $proceed($message, $initializationData);
}
}
3 changes: 3 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@
<type name="Magento\Payment\Model\Checks\TotalMinMax">
<plugin name="RatePAY_Payment_Plugin_TotalMixMax" type="RatePAY\Payment\Plugin\TotalMinMax" sortOrder="10" />
</type>
<type name="Magento\Framework\View\Element\Message\Renderer\EscapeRenderer">
<plugin name="RatePAY_Payment_Plugin_EscapeRenderer" type="RatePAY\Payment\Plugin\EscapeRenderer" sortOrder="10" />
</type>
</config>

0 comments on commit 9aea22d

Please sign in to comment.