-
Notifications
You must be signed in to change notification settings - Fork 43
fix: handle PayPal transport errors and clear Express spinner #774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,12 +7,14 @@ | |
|
|
||
| namespace Swag\PayPal\RestApi\Client; | ||
|
|
||
| use Psr\Http\Client\ClientExceptionInterface; | ||
| use Psr\Http\Client\ClientInterface; | ||
| use Psr\Http\Message\MessageInterface; | ||
| use Psr\Http\Message\RequestInterface; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Psr\Log\LoggerInterface; | ||
| use Shopware\Core\Framework\Log\Package; | ||
| use Swag\PayPal\RestApi\Exception\PayPalApiException; | ||
| use Symfony\Component\HttpClient\Psr18Client; | ||
|
|
||
| #[Package('checkout')] | ||
|
|
@@ -33,9 +35,27 @@ public function __construct( | |
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * @throws PayPalApiException | ||
| */ | ||
| public function sendRequest(RequestInterface $request): ResponseInterface | ||
| { | ||
| $response = $this->client->sendRequest($request); | ||
| try { | ||
| $response = $this->client->sendRequest($request); | ||
| } catch (ClientExceptionInterface $e) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| $this->logger->error( | ||
| 'PayPal network error: {message}', | ||
| [ | ||
| 'message' => $e->getMessage(), | ||
| 'method' => \mb_strtoupper($request->getMethod()), | ||
| 'target' => (string) $request->getUri(), | ||
| 'requestId' => $request->getHeaderLine('paypal-request-id') ?: null, | ||
| 'error' => $e, | ||
| ], | ||
| ); | ||
|
|
||
| throw PayPalApiException::fromClientException($e); | ||
| } | ||
|
|
||
| if ($response->getStatusCode() >= 400) { | ||
| $this->logger->error( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the new backend path returns a 502
PayPalApiExceptionfrom/paypal/express/prepare-checkout, this condition still only parses 400 responses; the non-400 path falls through tothis.onError()without the response body. In the inspectedonApprove/handleErrorflow, that discards the ErrorResponseFactory code and storesSWAG_PAYPAL__EXPRESS_GENERIC_ERROR, so the transport-specific error added in this commit never reaches buyers for prepare-checkout failures. Pass the response payload toonErrorfor non-400 errors too.Useful? React with 👍 / 👎.