Class PaymentController

java.lang.Object
springboot.bg.harisauto.payment.controller.PaymentController

@RestController public class PaymentController extends Object
PaymentController acts as a proxy to the actual payment-gateway service.
Author:
Kristian Popov
  • Constructor Details

  • Method Details

    • proxyCreatePaymentIntent

      @PostMapping("/payment/api/create-payment-intent") public PaymentResponse proxyCreatePaymentIntent(@RequestBody PaymentRequest request, jakarta.servlet.http.HttpSession session)
      This endpoint is called by the checkout.html JavaScript. It uses Feign to call the *actual* payment-gateway app.
    • showCheckoutPage

      @GetMapping("/checkout") public org.springframework.web.servlet.ModelAndView showCheckoutPage(jakarta.servlet.http.HttpSession session)
      Show checkout page.
    • processPayment

      @GetMapping("/process-payment") public org.springframework.web.servlet.ModelAndView processPayment(@RequestParam(name="redirect_status",required=false) String status, @RequestParam(name="payment_intent",required=false) String paymentIntentId, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, jakarta.servlet.http.HttpSession session)
      Handles the browser's return from the payment provider.

      The redirect_status parameter is supplied by the user agent and is treated only as "the customer came back" - never as proof that money moved. Whether the invoice is PAID is decided by reading the intent back from payment-service.

      Parameters:
      status - The provider's redirect status.
      paymentIntentId - The intent the provider redirected with.
      redirectAttributes - Flash attributes for the redirect.
      session - The session holding the pending booking.
      Returns:
      Redirect to the invoices page, or back to checkout on failure.