@@ -52,4 +52,40 @@ public class PaymentController {
|
||||
log.error("Error processing payment notification", e);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/auto-renewal/disable")
|
||||
public ResponseEntity<?> disableAutoRenewal(@RequestParam String email) {
|
||||
try {
|
||||
paymentService.disableAutoRenewal(email);
|
||||
return ResponseEntity.ok(Map.of("message", "Auto-renewal disabled"));
|
||||
} catch (UserNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(Map.of("error", e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/methods/{paymentMethodId}")
|
||||
public ResponseEntity<?> deletePaymentMethod(@RequestParam String email,
|
||||
@PathVariable String paymentMethodId) {
|
||||
try {
|
||||
paymentService.deletePaymentMethod(email, paymentMethodId);
|
||||
return ResponseEntity.ok(Map.of("message", "Payment method deleted"));
|
||||
} catch (UserNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(Map.of("error", e.getMessage()));
|
||||
} catch (RuntimeException e) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body(Map.of("error", e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/methods")
|
||||
public ResponseEntity<?> getPaymentMethods(@RequestParam String email) {
|
||||
try {
|
||||
return ResponseEntity.ok(paymentService.getUserPaymentMethods(email));
|
||||
} catch (UserNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(Map.of("error", e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user