зеркало из https://github.com/mozilla/fxa.git
fix(auth): firestore processor didnt ignore proper errors
Because: * The firestore processor failed to find existing records for deleted customers nor could it create them as we don't store deleted customers. This commit: * Catches both the stripe customer deleted error and the lack of a firestore record from the same error case. Closes #13591
This commit is contained in:
Родитель
ab86475903
Коммит
718b9a04e6
|
@ -3014,7 +3014,12 @@ export class StripeHelper extends StripeHelperBase {
|
|||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.name === FirestoreStripeError.STRIPE_CUSTOMER_DELETED) {
|
||||
if (
|
||||
[
|
||||
FirestoreStripeError.STRIPE_CUSTOMER_DELETED,
|
||||
FirestoreStripeError.FIRESTORE_CUSTOMER_NOT_FOUND,
|
||||
].includes(err.name)
|
||||
) {
|
||||
// We cannot back-fill Firestore with records for deleted customers
|
||||
// as they're missing necessary metadata for us to know which user
|
||||
// the customer belongs to.
|
||||
|
|
|
@ -5916,7 +5916,7 @@ describe('StripeHelper', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('ignores the deleted customer error when handling a payment method update event', async () => {
|
||||
it('ignores the deleted stripe customer error when handling a payment method update event', async () => {
|
||||
const event = deepCopy(eventPaymentMethodAttached);
|
||||
event.type = 'payment_method.card_automatically_updated';
|
||||
stripeHelper.stripe.paymentMethods.retrieve = sandbox
|
||||
|
@ -5937,6 +5937,27 @@ describe('StripeHelper', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('ignores the firestore record not found error when handling a payment method update event', async () => {
|
||||
const event = deepCopy(eventPaymentMethodAttached);
|
||||
event.type = 'payment_method.card_automatically_updated';
|
||||
stripeHelper.stripe.paymentMethods.retrieve = sandbox
|
||||
.stub()
|
||||
.resolves(event.data.object);
|
||||
stripeFirestore.insertPaymentMethodRecordWithBackfill = sandbox
|
||||
.stub()
|
||||
.throws(
|
||||
newFirestoreStripeError(
|
||||
'Customer deleted.',
|
||||
FirestoreStripeError.FIRESTORE_CUSTOMER_NOT_FOUND
|
||||
)
|
||||
);
|
||||
await stripeHelper.processWebhookEventToFirestore(event);
|
||||
sinon.assert.calledOnceWithExactly(
|
||||
stripeFirestore.insertPaymentMethodRecordWithBackfill,
|
||||
event.data.object
|
||||
);
|
||||
});
|
||||
|
||||
it('does not handle wibble events', async () => {
|
||||
const event = deepCopy(eventSubscriptionUpdated);
|
||||
event.type = 'wibble';
|
||||
|
|
Загрузка…
Ссылка в новой задаче