Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hdiniz
Copy link
Contributor

@hdiniz hdiniz commented Apr 29, 2024

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.

@hdiniz hdiniz self-assigned this Apr 29, 2024
@hdiniz hdiniz requested a review from a team May 2, 2024 13:27
@hdiniz hdiniz marked this pull request as ready for review May 3, 2024 16:50
@hdiniz hdiniz requested a review from kewitz May 6, 2024 12:22
server/graphql/v1/mutations/paymentMethods.js Outdated Show resolved Hide resolved
@@ -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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Comment on lines +713 to +720
context.loaders.PaymentMethod.byIdIncludeDeleted = new DataLoader(keys => {
return models.PaymentMethod.findAll({
where: {
id: keys,
},
paranoid: false,
}).then(results => sortResultsSimple(keys, results, pm => pm.id, []));
});
Copy link
Contributor

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.

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