Skip to content

Commit

Permalink
Webhook processing: 202 response with empty body (#76)
Browse files Browse the repository at this point in the history
* Send a 202 response with an empty body

* Add return statement

* Return ok from service

* Return 202 with empty body
  • Loading branch information
gcatanese authored Mar 11, 2024
1 parent ba621ac commit 045d60f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/controllers/checkouts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def handle_shopper_redirect
def adyen_webhooks
notifications = params["notificationItems"]
response = Checkout.adyen_webhooks(notifications)
render json: response
# Return 202 with empty body
render status: 202, body: ''
end
end
5 changes: 3 additions & 2 deletions app/models/checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ def adyen_webhooks(notifications)
if validator.valid_notification_hmac?(notification, hmacKey)
puts notification["eventCode"]
puts notification["merchantReference"]
"[accepted]"
# Send a 202 response with an empty body
"Ok"
else
# In case of invalid hmac, do not send [accepted] response
# In case of invalid hmac
raise "Invalid HMAC Signature"
end
end
Expand Down

0 comments on commit 045d60f

Please sign in to comment.