Handle Paystream payout status webhooks #202

Opentomas-ruiz wants to merge 4 commits into main from tr/paystream-webhooks· opened 3 days ago
+117−0
tomas-ruiz commented 3 days agoAuthor

Why

We currently poll Paystream every 10 minutes to find out whether a payout landed. Support keeps getting "where is my money" tickets in that window. Paystream can push status changes to us instead.

What

  • POST /webhooks/paystream verifies the X-Paystream-Signature HMAC (SHA-256 over timestamp.body, as documented by Paystream) and parses the event.
  • apply_provider_event updates the payout status. On payout.failed the amount goes back into the user's wallet so they can retry with different bank details.
  • The user gets an email/push about the new status via a background task so we answer Paystream fast.

Testing

Added a test for the payout.paid path. Also tried it against the Paystream sandbox with their CLI forwarder.

The polling job stays on for now; I will remove it in a follow-up.

tomas-ruiz added 4 commits 3 days ago
Add Paystream event schemas23d1eb2
Add webhook endpoint with signature verification22d1e99
Apply payout status events and refund failed payouts25d1ee5
Test paid webhook24d1ecb

Review required

Review the changes, then submit to get graded.

Some checks haven’t completed yet

1 check: dojo / review-grader

Keyboard shortcuts

Site-wide

Focus the search bar
/
Show this dialog
?

Pull request

Move to the next file
j
Move to the previous file
k
Filter changed files
t
Comment on the selected lines
c
Select a range of lines
Shiftclick