-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
Prevent removing payment method from processing orders and return payment method info even if deleted #10073
base: main
Are you sure you want to change the base?
Conversation
@@ -202,7 +202,7 @@ export const GraphQLOrder = new GraphQLObjectType({ | |||
type: GraphQLPaymentMethod, | |||
resolve(order, _, req) { | |||
if (order.PaymentMethodId) { | |||
return req.loaders.PaymentMethod.byId.load(order.PaymentMethodId); | |||
return req.loaders.PaymentMethod.byIdIncludeDeleted.load(order.PaymentMethodId); |
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.
Do we really need to expose deleted assets? What is the use case?
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 looking at past contributions / transactions. If the user removes the payment method, we still want to show info about it in the contribution list/drawers.
context.loaders.PaymentMethod.byIdIncludeDeleted = new DataLoader(keys => { | ||
return models.PaymentMethod.findAll({ | ||
where: { | ||
id: keys, | ||
}, | ||
paranoid: false, | ||
}).then(results => sortResultsSimple(keys, results, pm => pm.id, [])); | ||
}); |
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.
Quick reminder: this is only safe because we use the primary key ID in this query.
Hypothetically, we should not implement stuff like byCollectiveIdIncludedDeleted
because our custom indexes exclude deleted records.
An order paid with a delayed payment method (SEPA, ACH, etc) can be processing, we prevent the payment method to be deleted in that case.
If a payment method is deleted, its info should not be missing from the order list.