Class PaymentController
java.lang.Object
springboot.bg.harisauto.payment.controller.PaymentController
PaymentController acts as a proxy to the actual payment-gateway service.
- Author:
- Kristian Popov
-
Constructor Summary
ConstructorsConstructorDescriptionPaymentController(PaymentClient client, ShoppingCart shoppingCart, CheckoutService checkoutService, DevModeProperties devModeProperties, PaymentVerificationProperties verificationProperties) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.web.servlet.ModelAndViewprocessPayment(String status, String paymentIntentId, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, jakarta.servlet.http.HttpSession session) Handles the browser's return from the payment provider.proxyCreatePaymentIntent(PaymentRequest request, jakarta.servlet.http.HttpSession session) This endpoint is called by the checkout.html JavaScript.org.springframework.web.servlet.ModelAndViewshowCheckoutPage(jakarta.servlet.http.HttpSession session) Show checkout page.
-
Constructor Details
-
PaymentController
@Autowired public PaymentController(PaymentClient client, ShoppingCart shoppingCart, CheckoutService checkoutService, DevModeProperties devModeProperties, PaymentVerificationProperties verificationProperties)
-
-
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_statusparameter 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.
-