Issues deleting an expired payment method

While trying to delete a payment method we found a message saying it still had active payments and it would be deleted after completing them. After looking into the code a bit we found there are two payments that were declined. What is the reasoning behind declined payments impeding the deletion of a payment method?

It’ll be because of foreign keys referencing the PaymentMethod record in entities like Payment, PaymentGatewayResponse, etc.

By design, I believe the correct way to make a payment method inactive is by using the fromDate and thruDate fields.

If you really want to delete the payment method, you will have to delete all the related records and this will get messy, so I personally would recommend setting a thruDate on it.


PaymentMethod, like ContactMech, is generally immutable with the exception of a few fields. See the related services for more details, they handle the data model in the way it is intended. See the services in the PaymentMethodServices.xml file.

There is a delete#PaymentMethod service that sets the thruDate (ie expire or soft delete) and an expunge#PaymentMethod that deletes a bunch of other records… EXCEPT if you have Payment or other records that service will, as intended, result in an error. In general in Moqui transactional records are retained, this is very important for most businesses nearly all of the time (unless there are errors, etc and the data for those are best kept as auditable errors).

1 Like

David, I understand the need to keep transactional data, however, in this instance the CC was already expired and had been for almost a year. Preventing the “deletion” of this card from the party/customer screen due to decline transactions that were a year old seems a bit much.

I manually changed these transactions to “canceled” instead of “declined” and the CC was deleted. I don’t like to do that, because then you loose the audit trail. I’d rather be able to just delete the CC and not have to change transaction statuses.

1 Like

As usual, DWYW and all that…

If you delete the PaymentMethod you’re losing audit trail, not sure why that would be a concern for other things but not that.

What is the problem you’re trying to solve? It seems odd that a PaymentMethod record would be so abhorrent or cause so many problems that it would be worth attention… and to your point about audit trails, it’s helpful if they are as complete as possible just in case something comes up, even years later.

1 Like