Files
Webflux-Payments/src/main/java/com/test/payment/controller/AirtelController.java
2026-07-02 16:45:48 +03:00

41 lines
1.5 KiB
Java

package com.test.payment.controller;
import com.test.payment.dto.AirtelCallbackPayload;
import com.test.payment.dto.CallbackAckDto;
import com.test.payment.dto.PaymentRequest;
import com.test.payment.dto.PaymentResultDto;
import com.test.payment.dto.TransactionStatusDto;
import com.test.payment.service.AirtelService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
@RestController
@RequestMapping("/api/airtel")
@RequiredArgsConstructor
public class AirtelController {
private final AirtelService airtelService;
@PostMapping("/pay")
public Mono<PaymentResultDto> pay(@Valid @RequestBody PaymentRequest request) {
return airtelService.initiatePayment(request);
}
@PostMapping("/callback")
public Mono<CallbackAckDto> callback(@RequestBody AirtelCallbackPayload payload) {
return airtelService.handleCallback(payload);
}
@GetMapping("/status/{transactionId}")
public Mono<TransactionStatusDto> status(@PathVariable String transactionId) {
return airtelService.checkStatus(transactionId);
}
}