Merge pull request 'refactor: replace switch statement with if statement' (!132) from refactor-webhook into main
Some checks are pending
Release / Release (push) Waiting to run

Reviewed-on: #132
Reviewed-by: Constantin Simonis <constantin@simonis.lol>
This commit is contained in:
Phan Huy Tran 2025-04-23 07:16:24 +00:00
commit eda1fc8417
No known key found for this signature in database
GPG key ID: 944223E4D46B7412

View file

@ -46,14 +46,10 @@ public class WebhookController {
public ResponseEntity<String> webhook(@RequestBody String payload, @RequestHeader("Stripe-Signature") String sigHeader) throws StripeException {
Event event = Webhook.constructEvent(payload, sigHeader, webhookSecret);
switch (event.getType()) {
case "checkout.session.completed":
case "checkout.session.async_payment_succeeded":
if (Objects.equals(event.getType(), "checkout.session.completed") || Objects.equals(event.getType(), "checkout.session.async_payment_succeeded")) {
Session session = (Session) event.getData().getObject();
this.transactionService.fulfillCheckout(session.getId());
break;
default:
}
return ResponseEntity.ok().body(null);