Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Fixes an issue, where the shiiping callback required the store-api to be exposed.
- Fixes an issue, where PayPal order creation and express checkout flows did not use the taxed cart with tax provider processing
- Fixes an issue, where PayPal webhooks with a `custom_id` payload that does not contain an `orderTransactionId` could trigger an undefined array key warning
- Fixes an issue, where causes for validation errors were not logged correctly

# 8.10.0
- Added Austria to the countries where Pay Later is available
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Behebt ein Problem, bei dem der Versand-Callback die Offenlegung der Store-API erforderte
- Behebt ein Problem, bei dem die PayPal-Bestellerstellung und Express-Checkout-Flows nicht den besteuerten Warenkorb mit Tax-Provider-Verarbeitung verwendet haben
- Behebt ein Problem, bei dem PayPal-Webhooks mit einem `custom_id`-Payload ohne `orderTransactionId` eine Warnung wegen eines undefinierten Array-Keys ausloesen konnten
- Behebt ein Problem, bei dem Ursachen für Validierungsfehler nicht korrekt protokolliert wurden

# 8.10.0
- Fügt Österreich zu den Ländern hinzu, in denen „Später bezahlen“ verfügbar ist
Expand Down
19 changes: 13 additions & 6 deletions src/Util/IntrospectionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Shopware\Core\Framework\HttpException;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\ShopwareHttpException;
use Shopware\Core\Framework\Validation\Exception\ConstraintViolationException;
use Swag\PayPal\Pos\Api\Exception\PosException;
use Swag\PayPal\Pos\Client\AbstractClient as PosAbstractClient;
use Swag\PayPal\RestApi\Client\AbstractClient;
Expand Down Expand Up @@ -140,21 +141,27 @@
*/
private function exceptionToContext(\Throwable $exception): array
{
$context = [
'message' => $exception->getMessage(),
'class' => $this->traceToClassString($exception->getTrace()[0]),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
];
$context = ['message' => $exception->getMessage()];

if ($exception instanceof ShopwareHttpException) {
$context['parameters'] = $exception->getParameters();
}

if ($exception instanceof ConstraintViolationException) {
foreach ($exception->getViolations() as $violation) {
$context['parameters']['violations'][] = (string) $violation;

Check failure on line 152 in src/Util/IntrospectionProcessor.php

View workflow job for this annotation

GitHub Actions / phpstan (6.5.x)

Cannot cast Symfony\Component\Validator\ConstraintViolationInterface to string.

Check failure on line 152 in src/Util/IntrospectionProcessor.php

View workflow job for this annotation

GitHub Actions / phpstan (v6.5.5.1)

Cannot cast Symfony\Component\Validator\ConstraintViolationInterface to string.
}
}

if ($exception instanceof HttpException || $exception instanceof PosException) {
$context['errorCode'] = $exception->getErrorCode();
}

// Order class, file and line at the end to make the exception & the most important information more readable in logs
$context['class'] = $this->traceToClassString($exception->getTrace()[0]);
$context['file'] = $exception->getFile();
$context['line'] = $exception->getLine();

if ($exception->getPrevious()) {
$context['previous'] = $this->exceptionToContext($exception->getPrevious());
}
Expand Down
21 changes: 21 additions & 0 deletions tests/Util/IntrospectionProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Monolog\LogRecord;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Validation\Exception\ConstraintViolationException;
use Shopware\Core\Kernel;
use Swag\PayPal\Checkout\Payment\Handler\PayPalHandler;
use Swag\PayPal\Pos\Api\Exception\PosException;
Expand All @@ -21,6 +22,8 @@
use Swag\PayPal\RestApi\V2\Resource\OrderResource;
use Swag\PayPal\Storefront\Controller\PayPalController;
use Swag\PayPal\Util\IntrospectionProcessor;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationList;

/**
* @internal
Expand Down Expand Up @@ -270,5 +273,23 @@ public static function invokeWithExceptionDataProvider(): \Generator
'errorCode' => 'SWAG_PAYPAL__POS_EXCEPTION',
]],
];

yield 'ConstraintViolationException' => [
['exception' => new ConstraintViolationException(new ConstraintViolationList([new ConstraintViolation(
'test message',
'test message template with {{ type }}',
['{{ type }}' => 'testParameter'],
'/root',
'testProperty',
'VIOLATION_TESTPROPERTY_INVALID'
)]), [])],
['exception' => [
'message' => 'Caught 1 violation errors.',
'parameters' => [
'count' => 1,
'violations' => ["/root.testProperty:\n test message"],
],
]],
];
}
}
Loading