Skip to content

Commit

Permalink
fix settle_charge_and_transfers
Browse files Browse the repository at this point in the history
stop assuming that the charge has been successfully settled when a balance transaction exists
  • Loading branch information
Changaco committed Nov 2, 2024
1 parent 6449ec8 commit e769505
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions liberapay/payin/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def settle_charge_and_transfers(
ORDER BY pt.id
""", (payin.id,))
last = len(payin_transfers) - 1
if amount_settled is not None:
if charge.status == 'succeeded':
payer = db.Participant.from_id(payin.payer)
undeliverable_amount = amount_settled.zero()
for i, pt in enumerate(payin_transfers):
Expand Down Expand Up @@ -542,7 +542,8 @@ def settle_charge_and_transfers(
update_donor=(update_donor and i == last),
)

elif charge.status in ('failed', 'pending'):
else:
assert charge.status in ('failed', 'pending')
for i, pt in enumerate(payin_transfers):
update_payin_transfer(
db, pt.id, None, charge.status, error,
Expand Down

0 comments on commit e769505

Please sign in to comment.