Skip to content

Commit

Permalink
fix notifications of payment disputes
Browse files Browse the repository at this point in the history
Stripe has sent us at least one callback erroneously containing `"status": "needs_response"` for an unchallengeable dispute.
  • Loading branch information
Changaco committed Feb 20, 2024
1 parent df8dbaa commit 408f26e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion www/callbacks/stripe.spt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ elif event_object_type == 'charge.dispute':
# Notify the person who initiated the payment
payer = Participant.from_id(payin.payer)
if dispute.status in ('needs_response', 'lost'):
try:
due_by = dispute.evidence_details.due_by
except AttributeError:
due_by = 0
try:
payer.notify(
'payin_disputed',
Expand All @@ -97,7 +101,10 @@ elif event_object_type == 'charge.dispute':
payin_amount=payin.amount,
payin_ctime=payin.ctime,
dispute_reason=dispute.reason,
dispute_can_be_withdrawn=dispute.status == 'needs_response',
dispute_can_be_withdrawn=(
dispute.status == 'needs_response' and
due_by > utcnow().timestamp()
),
mandate_url=route.get_mandate_url(),
)
except DuplicateNotification:
Expand Down

0 comments on commit 408f26e

Please sign in to comment.