-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #654 from mollie/release/2.27.0
Release/2.27.0
- Loading branch information
Showing
11 changed files
with
76 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Mollie\Payment\Service\Order\Lines\Generator; | ||
|
||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Mollie\Api\Types\OrderLineType; | ||
use Mollie\Payment\Helper\General; | ||
|
||
class ShippingDiscount implements GeneratorInterface | ||
{ | ||
/** | ||
* @var General | ||
*/ | ||
private $mollieHelper; | ||
|
||
public function __construct( | ||
General $mollieHelper | ||
) { | ||
$this->mollieHelper = $mollieHelper; | ||
} | ||
|
||
public function process(OrderInterface $order, array $orderLines): array | ||
{ | ||
if (!$order->getShippingDiscountAmount()) { | ||
return $orderLines; | ||
} | ||
|
||
$forceBaseCurrency = (bool)$this->mollieHelper->useBaseCurrency($order->getStoreId()); | ||
$currency = $forceBaseCurrency ? $order->getBaseCurrencyCode() : $order->getOrderCurrencyCode(); | ||
$amount = abs($order->getData(($forceBaseCurrency ? 'base_' : '') . 'shipping_discount_amount')); | ||
|
||
$orderLines[] = [ | ||
'type' => OrderLineType::TYPE_DISCOUNT, | ||
'name' => __('Magento Discount'), | ||
'quantity' => 1, | ||
'unitPrice' => $this->mollieHelper->getAmountArray($currency, -$amount), | ||
'totalAmount' => $this->mollieHelper->getAmountArray($currency, -$amount), | ||
'vatRate' => '0.00', | ||
'vatAmount' => $this->mollieHelper->getAmountArray($currency, '0.00'), | ||
]; | ||
|
||
return $orderLines; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters