Skip to content

Commit

Permalink
NTR: Merge branch 'master' into users/vm/PISHPS-397-unconfirmed
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Components/OrderExpiration/ExpireAction.php
  • Loading branch information
Vitalij Mik committed Dec 2, 2024
2 parents 068d833 + 030266f commit 570428c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

namespace Kiener\MolliePayments\Components\Subscription\Services\PaymentMethodRemover;

use Kiener\MolliePayments\Handler\Method\BanContactPayment;
use Kiener\MolliePayments\Handler\Method\BelfiusPayment;
use Kiener\MolliePayments\Handler\Method\CreditCardPayment;
use Kiener\MolliePayments\Handler\Method\DirectDebitPayment;
use Kiener\MolliePayments\Handler\Method\EpsPayment;
use Kiener\MolliePayments\Handler\Method\GiroPayPayment;
use Kiener\MolliePayments\Handler\Method\iDealPayment;
use Kiener\MolliePayments\Handler\Method\PayPalPayment;
use Kiener\MolliePayments\Handler\Method\SofortPayment;
use Kiener\MolliePayments\Handler\Method\TrustlyPayment;
use Kiener\MolliePayments\Service\MollieApi\OrderItemsExtractor;
use Kiener\MolliePayments\Service\OrderService;
use Kiener\MolliePayments\Service\Payment\Remover\PaymentMethodRemover;
Expand All @@ -16,15 +26,16 @@
class SubscriptionRemover extends PaymentMethodRemover
{
public const ALLOWED_METHODS = [
'ideal',
'bancontact',
'sofort',
'eps',
'giropay',
'belfius',
'creditcard',
'paypal',
'directdebit',
iDealPayment::PAYMENT_METHOD_NAME,
BanContactPayment::PAYMENT_METHOD_NAME,
SofortPayment::PAYMENT_METHOD_NAME,
EpsPayment::PAYMENT_METHOD_NAME,
GiroPayPayment::PAYMENT_METHOD_NAME,
BelfiusPayment::PAYMENT_METHOD_NAME,
CreditCardPayment::PAYMENT_METHOD_NAME,
PaypalPayment::PAYMENT_METHOD_NAME,
DirectDebitPayment::PAYMENT_METHOD_NAME,
TrustlyPayment::PAYMENT_METHOD_NAME
];

/**
Expand Down
17 changes: 16 additions & 1 deletion src/Service/Order/OrderExpireService.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,27 @@ public function cancelExpiredOrders(OrderCollection $orders, Context $context):
}

$transactions->sort(function (OrderTransactionEntity $a, OrderTransactionEntity $b) {
return $a->getCreatedAt() <=> $b->getCreatedAt();
if ($a->getCreatedAt() === null || $b->getCreatedAt() === null) {
return -1;
}
return $a->getCreatedAt()->getTimestamp() <=> $b->getCreatedAt()->getTimestamp();
});

/** @var OrderTransactionEntity $lastTransaction */
$lastTransaction = $transactions->last();

$paymentMethod = $lastTransaction->getPaymentMethod();
if ($paymentMethod === null) {
$this->logger->warning('Transaction has no payment method', ['orderNumber'=>$order->getOrderNumber(),'transactionId'=>$lastTransaction->getId()]);
continue;
}
$paymentMethodIdentifier = $paymentMethod->getHandlerIdentifier();

if (strpos($paymentMethodIdentifier, 'Mollie') === false) {
$this->logger->debug('Payment method is not a mollie payment, dont touch it', ['identifier'=>$paymentMethodIdentifier]);
continue;
}

$stateMachineState = $lastTransaction->getStateMachineState();
if ($stateMachineState === null) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function testAllowedPaymentMethods()
'creditcard',
'paypal',
'directdebit',
'trustly'
];

$this->assertEquals($expected, SubscriptionRemover::ALLOWED_METHODS);
Expand Down

0 comments on commit 570428c

Please sign in to comment.