fix(auth): resolve invoice subscriptions outside the list expand - #20966
Merged
Conversation
Because: * The Stripe SDK upgrade (35929f2, API 2026-06-24.dahlia) rewrote fetchOpenInvoices' expand to `data.parent.subscription_details.subscription`. Stripe rejects that path on the invoice list endpoint, so the PayPal processor 400s on its first page and no open invoices are retried or cancelled. It surfaces as `Cannot acquire lock to run` because the Stripe error is the `[cause]` thrown inside the Redlock block. This commit: * Drops the rejected expand and resolves each invoice's subscription via getInvoiceSubscription + expandResource(SUBSCRIPTIONS_RESOURCE), the pair invoicePayableWithPaypal already uses. The active-status filter is unchanged; invoices are now yielded with an unexpanded subscription. * Reads the subscription through getInvoiceSubscription in PaypalProcessor.cancelInvoiceSubscription, which had cast it to an expanded object to take `.id`. * Covers the new resolution path in the fetchOpenInvoices tests, including an unresolvable subscription. Closes #PAY-3890
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes PayPal invoice processing failures caused by Stripe rejecting the invoice-list expansion path data.parent.subscription_details.subscription after the Stripe SDK/API upgrade. The PR switches to resolving each invoice’s subscription separately (via getInvoiceSubscription + expandResource(SUBSCRIPTIONS_RESOURCE)) while keeping the existing “active subscription only” filter behavior.
Changes:
- Remove the rejected subscription expansion from the invoice list call and resolve subscriptions per-invoice when filtering open invoices.
- Update PayPal invoice-cancel flow to read subscription ids via
getInvoiceSubscription(handles both “basil” and legacy invoice shapes). - Extend unit tests to cover active/inactive/unresolvable subscription resolution in
fetchOpenInvoices.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/fxa-auth-server/lib/payments/stripe.ts | Drops the invalid invoice-list expand and resolves subscription per invoice for active-status filtering. |
| packages/fxa-auth-server/lib/payments/stripe.spec.ts | Updates/extends tests for the new per-invoice subscription resolution path (including unresolvable subscription). |
| packages/fxa-auth-server/lib/payments/paypal/processor.ts | Uses getInvoiceSubscription when canceling an invoice’s subscription to avoid assuming an expanded object. |
| packages/fxa-auth-server/lib/payments/paypal/processor.spec.ts | Updates the PayPal processor test fixture to match the new subscription shape. |
Comment on lines
+1009
to
+1012
| const subscription = await this.expandResource( | ||
| getInvoiceSubscription(invoice), | ||
| SUBSCRIPTIONS_RESOURCE | ||
| ); |
StaberindeZA
approved these changes
Aug 4, 2026
StaberindeZA
left a comment
Contributor
There was a problem hiding this comment.
r+. Ty for the quick fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because:
data.parent.subscription_details.subscription. Stripe rejects that path on the invoice list endpoint, so the PayPal processor 400s on its first page and no open invoices are retried or cancelled. It surfaces asCannot acquire lock to runbecause the Stripe error is the[cause]thrown inside the Redlock block.This commit:
.id.Closes #PAY-3890
Checklist
Put an
xin the boxes that apply