Respond to Stripe webhook with status of 204 if specified account is not found

This commit is contained in:
Rob Harrington
2017-09-22 17:32:31 +10:00
parent db5503dd80
commit e486dbd4f8
2 changed files with 4 additions and 4 deletions

View File

@@ -45,13 +45,13 @@ module Admin
def deauthorize
# TODO is there a sensible way to confirm this webhook call is actually from Stripe?
event = Stripe::Event.construct_from(params)
return render nothing: true, status: 400 unless event.type == "account.application.deauthorized"
return render nothing: true, status: 204 unless event.type == "account.application.deauthorized"
destroyed = StripeAccount.where(stripe_user_id: event.account).destroy_all
if destroyed.any?
render text: "Account #{event.account} deauthorized", status: 200
else
render nothing: true, status: 400
render nothing: true, status: 204
end
end