-
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 #772 from mollie/release/2.37.0
Release/2.37.0
- Loading branch information
Showing
46 changed files
with
764 additions
and
44 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,24 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Model\Methods; | ||
|
||
use Mollie\Payment\Model\Mollie; | ||
|
||
/** | ||
* Class Alma | ||
* | ||
* @package Mollie\Payment\Model\Methods | ||
*/ | ||
class Alma extends Mollie | ||
{ | ||
/** | ||
* Payment method code | ||
* | ||
* @var string | ||
*/ | ||
const CODE = 'mollie_methods_alma'; | ||
} |
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
64 changes: 64 additions & 0 deletions
64
Observer/AdminhtmlSalesOrderCreateProcessItemBefore/SetPurchaseTypeOnCreateOrderItem.php
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,64 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mollie\Payment\Observer\AdminhtmlSalesOrderCreateProcessItemBefore; | ||
|
||
use Magento\Catalog\Api\ProductRepositoryInterface; | ||
use Magento\Framework\App\RequestInterface; | ||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\Event\ObserverInterface; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
|
||
class SetPurchaseTypeOnCreateOrderItem implements ObserverInterface | ||
{ | ||
/** | ||
* @var ProductRepositoryInterface | ||
*/ | ||
private $productRepository; | ||
|
||
public function __construct( | ||
ProductRepositoryInterface $productRepository | ||
) { | ||
$this->productRepository = $productRepository; | ||
} | ||
|
||
public function execute(Observer $observer) | ||
{ | ||
/** @var RequestInterface $request */ | ||
$request = $observer->getData('request_model'); | ||
|
||
if ($request->has('item') && !$request->getPost('update_items') | ||
) { | ||
$itemsChanged = false; | ||
$items = $request->getPost('item'); | ||
foreach ($items as $item => $requestData) { | ||
if (!$this->productAllowsOneTimePurchase($item)) { | ||
continue; | ||
} | ||
|
||
$itemsChanged = true; | ||
$items[$item]['purchase'] = 'onetime'; | ||
} | ||
|
||
if ($itemsChanged) { | ||
$request->setPostValue('item', $items); | ||
} | ||
} | ||
} | ||
|
||
private function productAllowsOneTimePurchase(int $productId): bool | ||
{ | ||
try { | ||
$product = $this->productRepository->getById($productId); | ||
} catch (NoSuchEntityException $e) { | ||
return false; | ||
} | ||
|
||
return !!$product->getData('mollie_subscription_product'); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Plugin/CustomerBalance/Observer/PreventDoubleCreditRevert.php
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mollie\Payment\Plugin\CustomerBalance\Observer; | ||
|
||
use Magento\Framework\Event\Observer; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
|
||
class PreventDoubleCreditRevert | ||
{ | ||
public function aroundExecute($subject, callable $proceed, Observer $observer) | ||
{ | ||
$order = $observer->getData('order'); | ||
if (!$order || | ||
!$order instanceof OrderInterface || | ||
!$order->getPayment() | ||
) { | ||
return $proceed($observer); | ||
} | ||
|
||
if ($observer->getEvent()->getName() == 'restore_quote' && | ||
$this->isMollieOrder($order) | ||
) { | ||
return $subject; | ||
} | ||
|
||
return $proceed($observer); | ||
} | ||
|
||
private function isMollieOrder(OrderInterface $order): bool | ||
{ | ||
$payment = $order->getPayment(); | ||
|
||
return strstr($payment->getMethod(), 'mollie_methods_') !== false; | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mollie\Payment\Service\Magento; | ||
|
||
use Magento\Checkout\Api\Data\ShippingInformationInterface; | ||
use Magento\Checkout\Api\Data\ShippingInformationInterfaceFactory; | ||
use Magento\Checkout\Api\ShippingInformationManagementInterface; | ||
use Magento\Quote\Api\Data\AddressInterface; | ||
|
||
class ChangeShippingMethodForQuote | ||
{ | ||
/** | ||
* @var ShippingInformationManagementInterface | ||
*/ | ||
private $shippingInformationManagement; | ||
/** | ||
* @var ShippingInformationInterfaceFactory | ||
*/ | ||
private $shippingInformationFactory; | ||
|
||
public function __construct( | ||
ShippingInformationManagementInterface $shippingInformationManagement, | ||
ShippingInformationInterfaceFactory $shippingInformationFactory | ||
) { | ||
$this->shippingInformationManagement = $shippingInformationManagement; | ||
$this->shippingInformationFactory = $shippingInformationFactory; | ||
} | ||
|
||
public function execute(AddressInterface $address, string $identifier): void | ||
{ | ||
$address->setCollectShippingRates(true); | ||
$address->setShippingMethod($identifier); | ||
|
||
[$carrierCode, $methodCode] = explode('_', $identifier); | ||
$shippingInformation = $this->shippingInformationFactory->create([ | ||
'data' => [ | ||
ShippingInformationInterface::SHIPPING_ADDRESS => $address, | ||
ShippingInformationInterface::SHIPPING_CARRIER_CODE => $carrierCode, | ||
ShippingInformationInterface::SHIPPING_METHOD_CODE => $methodCode, | ||
], | ||
]); | ||
|
||
$this->shippingInformationManagement->saveAddressInformation($address->getQuoteId(), $shippingInformation); | ||
} | ||
} |
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
Oops, something went wrong.