Skip to content

fix(auth-server): handle cancelled billing agreement NVP error - #21092

Open
david1alvarez wants to merge 1 commit into
mainfrom
PAY-3778
Open

fix(auth-server): handle cancelled billing agreement NVP error#21092
david1alvarez wants to merge 1 commit into
mainfrom
PAY-3778

Conversation

@david1alvarez

Copy link
Copy Markdown
Contributor

Because

  • Cancelled PayPal billing agreements make invoice.created webhooks return 500, so Stripe retries the delivery and Sentry reports every attempt (FXA-AUTH-2TC).
  • The handling added for this case in 2022 never runs, because PayPal reports a cancelled agreement as an API error rather than as a cancelled status.

This pull request

  • Translates PayPal NVP error 10201 in updateStripeNameFromBA into the internal validation error the webhook already handles.
  • Rethrows any other PayPal error unchanged.
  • Adds unit coverage for the cancelled-agreement branch and the rethrow path.

Issue that this pull request solves

Closes: PAY-3778

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on: the new catch in updateStripeNameFromBA.
  • Suggested review order: helper.ts, then the two new tests.
  • Risky or complex parts: the fix works via stripe-webhook.ts matching on errno, which this PR does not touch. That contract is now asserted in the helper spec.

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

The stale billing agreement is deliberately left on the Stripe customer. The ticket does not ask for it, and the IPN mpCancel path already owns clearing agreements.

No pre-merge review skill was run: the production change is 13 lines reusing an existing in-file idiom (processor.ts:243) and mutates no state.

Because:

- PayPal rejects the agreement lookup with NVP error 10201 instead of
  returning a cancelled status, so the guard added in 93f31f9 never runs.
- The unrecognized error escapes handleInvoiceCreatedEvent as a 500, which
  Stripe retries and Sentry reports.

This commit:

- Translates error 10201 in updateStripeNameFromBA into the internal
  validation error the webhook already handles.
- Covers the new branch and the rethrow path in helper.spec.ts.

Closes PAY-3778
@david1alvarez
david1alvarez marked this pull request as ready for review August 21, 2026 18:06
@david1alvarez
david1alvarez requested a review from a team as a code owner August 21, 2026 18:06
Copilot AI balanced review requested due to automatic review settings August 21, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Handles cancelled PayPal billing agreements without failing Stripe invoice.created webhooks.

Changes:

  • Maps PayPal NVP error 10201 to the existing internal validation error.
  • Adds tests for translation and passthrough of other PayPal errors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/fxa-auth-server/lib/payments/paypal/helper.ts Translates cancelled-agreement API errors.
packages/fxa-auth-server/lib/payments/paypal/helper.spec.ts Covers translation and rethrow behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants