wuvt / donormotor

WUVT's new donation management and donor-relations platform.
GNU Affero General Public License v3.0
5 stars 0 forks source link

Do not add failed stripe transactions to database #9

Open echarlie opened 3 years ago

echarlie commented 3 years ago

most of these are card testing that stripe blocks as fraud.

mutantmonkey commented 3 years ago

If the card is declined, we don't add the transaction to the database. My understanding is that Stripe can now let a transaction go through and then decline it as fraud later on. If that understanding is true, we're going to have to see how to add that integration.

echarlie commented 3 years ago

Large numbers of small-value online donations end up with "Payment method: None". Clearly Stripe declined these out-of-hand.

The stripe integration should allow more sophisticated removal, but these are cards where stripe does return a failure: we still add them. (this is implicitly the same issue as wuvt/donormotor#5)

mutantmonkey commented 3 years ago

Yeah, you're right. We add the transaction to the DB before we know whether or not the card was declined. We should probably delete such transactions in addition to displaying an error. Here's the relevant section of code: https://github.com/wuvt/donormotor/blob/main/donormotor/donate/views.py#L117

mutantmonkey commented 3 years ago

@echarlie suggested that I explain why we add the transaction to the DB before marking it as paid. The short answer is that the only reason is to be able to print out the ID if sending the receipt email fails. If whoever looks into this wants to refactor the payment process flow so that we don't do that, that would probably be a better solution.