Skip to content

fix: handle PayPal transport errors and clear Express spinner - #774

Open
Ali Ghanei (Aliaaaam) wants to merge 3 commits into
trunkfrom
fix/express-checkout-transport-errors
Open

fix: handle PayPal transport errors and clear Express spinner#774
Ali Ghanei (Aliaaaam) wants to merge 3 commits into
trunkfrom
fix/express-checkout-transport-errors

Conversation

@Aliaaaam

Copy link
Copy Markdown
Contributor

1. Why is this change necessary?

Transient PayPal API transport failures (e.g. short DNS outages) during Express prepare-checkout currently surface as HTTP 500, and the Express loading spinner is never cleared on the error path, leaving buyers stuck with no recovery.

2. What does this change do, exactly?

  • Maps ClientExceptionInterface to a customer-facing PayPalApiException (502 / NETWORK_ERROR) instead of an unhandled 500
  • Enables method-restricted HTTP retries on paypal.base-client for idempotent GETs
  • Removes the Express body loading spinner on onApprove / error handling failure paths

3. Describe each step to reproduce the issue or behaviour.

  1. Product page -> Express -> approve in PayPal
  2. Force POST /paypal/express/prepare-checkout to 500 (DevTools)
  3. Page stays blocked with spinner

Same flow with DNS/connect failure to api-m.paypal.com -> unhandled 500 from Client.php.

4. Please link to the relevant issues (if any).

5. Checklist

  • I have written tests and verified that they fail without my change
  • I have created an entry in the CHANGELOG.md files with all necessary user information about my changes
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I have read the contribution requirements and fulfill them.

@Aliaaaam Ali Ghanei (Aliaaaam) self-assigned this Aug 6, 2026
@Aliaaaam
Ali Ghanei (Aliaaaam) requested a review from a team August 6, 2026 18:08
@Aliaaaam
Ali Ghanei (Aliaaaam) marked this pull request as ready for review August 6, 2026 18:08

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2267c8b436

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".


ElementLoadingIndicatorUtil.remove(document.body);

if (request.status === 400) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass non-400 prepare-checkout errors to onError

When the new backend path returns a 502 PayPalApiException from /paypal/express/prepare-checkout, this condition still only parses 400 responses; the non-400 path falls through to this.onError() without the response body. In the inspected onApprove/handleError flow, that discards the ErrorResponseFactory code and stores SWAG_PAYPAL__EXPRESS_GENERIC_ERROR, so the transport-specific error added in this commit never reaches buyers for prepare-checkout failures. Pass the response payload to onError for non-400 errors too.

Useful? React with 👍 / 👎.

$response = $this->client->sendRequest($request);
try {
$response = $this->client->sendRequest($request);
} catch (ClientExceptionInterface $e) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Catch only transport exceptions as network failures

RequestExceptionInterface failures from the underlying PSR client also extend ClientExceptionInterface, so this catch now classifies malformed request/stream problems as PayPal network outages and turns them into a 502 NETWORK_ERROR. In contexts where the SDK or plugin builds an invalid request, that hides the real defect from callers and customer-facing errors; catch NetworkExceptionInterface for transport failures and let request exceptions surface separately.

Useful? React with 👍 / 👎.

Comment thread src/Resources/config/packages/framework.yaml Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Express Checkout: transport errors return 500 and leave loading spinner stuck

3 participants