Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ jobs:
matrix:
include:
- php-version: '8.2'
typo3-version: '^13.4'
typo3-version: '^14.3'
- php-version: '8.3'
typo3-version: '^13.4'
typo3-version: '^14.3'
- php-version: '8.4'
typo3-version: '^13.4'
typo3-version: '^14.3'
- php-version: '8.5'
typo3-version: '^13.4'
typo3-version: '^14.3'
steps:
- uses: actions/checkout@v4

Expand Down
1 change: 1 addition & 0 deletions Classes/Checkout/Payment/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

use Extcode\Cart\Domain\Model\Order\Item;
use Extcode\Cart\OrderStatus\PaymentStatus;
use Extcode\CartPaypal\Api\ApiException;
use Extcode\CartPaypal\Api\PayPalClient;
use Extcode\CartPaypal\Checkout\CheckoutException;
Expand Down
26 changes: 0 additions & 26 deletions Classes/Checkout/Payment/PaymentStatus.php

This file was deleted.

81 changes: 0 additions & 81 deletions Classes/Checkout/Payment/PaymentStatusStore.php

This file was deleted.

57 changes: 38 additions & 19 deletions Classes/Checkout/Payment/PaymentStatusUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,66 @@
*/

use Extcode\Cart\Domain\Model\Order\Payment;
use Extcode\Cart\OrderHistory\OrderChangeSource;
use Extcode\Cart\OrderStatus\StatusChangeOutcome;
use Extcode\Cart\OrderStatus\StatusChangeService;
use Psr\Log\LoggerInterface;

/**
* Changes the status of a payment only if it has not been changed by another
* request in the meantime.
* Changes the status of a payment with the StatusChangeService of cart, which
* changes it only if it has not been changed by another request in the
* meantime. The change is stored in the order history.
*/
final class PaymentStatusUpdater
{
public const INITIATOR = 'cart_paypal';

public function __construct(
private readonly PaymentStatusStore $paymentStatusStore,
private readonly StatusChangeService $statusChangeService,
private readonly LoggerInterface $logger,
) {}

/**
* Returns true if this call changed the status. Only the request that
* changed it may dispatch the events of the change.
*
* @param bool $byPayPal the change is caused by PayPal, e.g. a webhook, not by the customer; not stored with cart 11
* @param bool $byPayPal the change is caused by PayPal, e.g. a webhook, not by the customer
*/
public function change(Payment $payment, string $toStatus, bool $byPayPal = false): bool
{
$changed = $this->paymentStatusStore->updateIfStatus($payment, $payment->getStatus(), $toStatus);
$source = $byPayPal ? OrderChangeSource::Api : null;

$result = $this->statusChangeService->change(
$payment,
$toStatus,
$payment->getStatus(),
self::INITIATOR,
null,
$source
);

if (!$changed) {
if ($result->outcome === StatusChangeOutcome::Stale && $result->storedStatus !== null) {
// changed by another request since the payment was loaded, try again with the stored status
$storedStatus = $this->paymentStatusStore->getStoredStatus($payment);
$payment->setStatus($storedStatus);
$changed = $this->paymentStatusStore->updateIfStatus($payment, $storedStatus, $toStatus);

if (!$changed && $storedStatus !== $toStatus) {
$this->logger->error('The status of a payment paid with PayPal could not be changed.', [
'payment' => $payment->getUid(),
'toStatus' => $toStatus,
]);
}
$payment->setStatus($result->storedStatus);
$result = $this->statusChangeService->change(
$payment,
$toStatus,
$result->storedStatus,
self::INITIATOR,
null,
$source
);
}

if ($changed) {
$payment->setStatus($toStatus);
if (!$result->isChanged() && $result->outcome !== StatusChangeOutcome::Unchanged) {
$this->logger->error('The status of a payment paid with PayPal could not be changed.', [
'payment' => $payment->getUid(),
'toStatus' => $toStatus,
'outcome' => $result->outcome->name,
'vetoReason' => $result->vetoReason,
]);
}

return $changed;
return $result->isChanged();
}
}
6 changes: 3 additions & 3 deletions Classes/EventListener/Order/Payment/ClearCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
* LICENSE file that was distributed with this source code.
*/

use Extcode\Cart\Configuration\Loader\PaymentMethodsLoaderInterface;
use Extcode\Cart\Domain\Model\Order\BillingAddress;
use Extcode\Cart\Domain\Model\Order\ShippingAddress;
use Extcode\Cart\Event\Order\PaymentEvent;
use Extcode\Cart\Service\PaymentMethodsServiceInterface;
use Extcode\Cart\Service\SessionHandler;
use Extcode\Cart\Utility\CartUtility;
use Extcode\CartPaypal\Checkout\Payment\PaymentProvider;
Expand All @@ -24,7 +24,7 @@ final class ClearCart
{
public function __construct(
private readonly CartUtility $cartUtility,
private readonly PaymentMethodsServiceInterface $paymentMethodsService,
private readonly PaymentMethodsLoaderInterface $paymentMethodsLoader,
private readonly SessionHandler $sessionHandler
) {}

Expand All @@ -40,7 +40,7 @@ public function __invoke(PaymentEvent $event): void

$paymentId = $cart->getPayment()->getId();

$paymentMethod = $this->paymentMethodsService->getPaymentMethods($cart)[$paymentId] ?? null;
$paymentMethod = $this->paymentMethodsLoader->getPaymentMethods($cart)[$paymentId] ?? null;

if ((int)($paymentMethod?->getConfig()['preventClearCart'] ?? 0) !== 1) {
$cartPid = $settings['settings']['cart']['pid'];
Expand Down
18 changes: 18 additions & 0 deletions Documentation/Administrator/Configuration/PaymentMethod/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ them in the cart, e.g. "PayPal" and "Credit card".
}
}

If Cart reads the payment methods from the site settings (site set loader of
Cart), the option is added to `extcode.cart-payments` in the same way:

.. code-block:: yaml
:caption: config/sites/<site>/settings.yaml

extcode:
cart-payments:
countries:
de:
options:
2:
provider: PAYPAL
title: PayPal
extra: 0.0
taxClassId: 1
status: open

|

.. container:: table-row
Expand Down
16 changes: 16 additions & 0 deletions Documentation/Changelog/9.0/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. include:: ../../Includes.rst.txt

===========
9.0 Changes
===========

The version 9.x is a release for TYPO3 v14.3 and extcode/cart 12.x. It
provides the features of version 8.x.

Features
========

* The status of the payment is changed with the `StatusChangeService` of Cart.
The changes are stored in the order history with the initiator
`cart_paypal`, the `BeforeStatusChangeEvent` and `AfterStatusChangeEvent` of
Cart are dispatched.
1 change: 1 addition & 0 deletions Documentation/Changelog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ChangeLog
:maxdepth: 3
:titlesonly:

9.0/Index
8.0/Index
6.0/Index
5.0/Index
Expand Down
4 changes: 4 additions & 0 deletions Documentation/Developer/Events/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ Cart PayPal dispatches its own events after the payment.
`\Extcode\CartPaypal\Event\Order\CancelEvent`
Dispatched once when the customer cancels the payment and returns to the
cart.

The status of the payment is changed with the `StatusChangeService` of Cart,
its `BeforeStatusChangeEvent` and `AfterStatusChangeEvent` are dispatched as
well, with the initiator `cart_paypal`.
1 change: 1 addition & 0 deletions Documentation/Introduction/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ The emails of Cart are sent after the payment is completed.
:maxdepth: 2
:titlesonly:

SupportedVersions/Index
Support/Index
Sponsoring/Index
33 changes: 33 additions & 0 deletions Documentation/Introduction/SupportedVersions/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. include:: ../../Includes.rst.txt

.. _supported-versions:

==================
Supported versions
==================

The table lists the compatibility of all versions with TYPO3 and PHP and which
versions are still supported.

=========== ========== ========= ====================================
Cart PayPal TYPO3 PHP Support/Development
=========== ========== ========= ====================================
9.x.x 14.3 8.2 - 8.5 Features, Bugfixes, Security Updates
8.x.x 13.4 8.2 - 8.5 Bugfixes, Security Updates
6.x.x 10.4, 11.5 7.2+
5.x.x 10.4 7.2 - 7.4
4.x.x 9.5 7.2 - 7.4
3.x.x 8.7 7.0 - 7.4
2.x.x 6.2 - 8.7 5.6 - 7.0
1.x.x
=========== ========== ========= ====================================

If you need extended support for features and bug fixes outside of the
currently supported versions, we are happy to offer paid services.

Security
========

Security updates are only provided for supported versions. Please do not report
security issues in public GitHub issues or pull requests. Report them to the
TYPO3 Security Team via security@typo3.org instead.
4 changes: 2 additions & 2 deletions Documentation/guides.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
interlink-shortcode="extcode/cart-paypal"
/>
<project title="Cart PayPal"
release="8.0.0"
version="8.0"
release="9.0.0"
version="9.0"
copyright="2016 - 2026"
/>
<inventory id="t3tsref" url="https://docs.typo3.org/typo3cms/TyposcriptReference/"/>
Expand Down
15 changes: 15 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Security Policy

## Supported Versions

Security updates are only provided for supported versions. The support status
of all versions is listed in the
[official extension documentation in chapter supported versions](https://docs.typo3.org/p/extcode/cart-paypal/main/en-us/Introduction/SupportedVersions/Index.html).

## Reporting a Vulnerability

Please do not report security issues in public GitHub issues or pull requests.

Report them to the TYPO3 Security Team via security@typo3.org. The team
coordinates the fix and the publication of a security advisory with the
maintainers.
6 changes: 6 additions & 0 deletions Tests/Functional/AbstractPayPalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ abstract class AbstractPayPalTestCase extends FunctionalTestCase
'MAIL' => [
'transport' => 'null',
],
'SYS' => [
'features' => [
// the MailHandler of cart is deprecated since cart 12.4
'cart.useNewOrderMailSender' => true,
],
],
];

protected function setUp(): void
Expand Down
Loading
Loading