refactor: replace switch statement with ugly a if statement (no go idiomatic btw)
All checks were successful
CI / Get Changed Files (pull_request) Successful in 6s
CI / eslint (pull_request) Has been skipped
CI / prettier (pull_request) Has been skipped
CI / test-build (pull_request) Has been skipped
CI / Checkstyle Main (pull_request) Successful in 37s

This commit is contained in:
Phan Huy Tran 2025-04-23 09:14:19 +02:00
parent 1fe3148019
commit 94ca93e510

View file

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