adding files 2

This commit is contained in:
Oracle Public Cloud User
2026-09-04 13:54:16 +00:00
parent b7ec9db2bc
commit 8b3cc8dd10
83 changed files with 5045 additions and 0 deletions

40
payment-service/pom.xml Normal file
View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.oracle.demo</groupId>
<artifactId>kagent-oci-devops-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>payment-service</artifactId>
<name>payment-service</name>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,13 @@
package com.oracle.demo.payment;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class PaymentServiceApplication {
public static void main(String[] args) {
SpringApplication.run(PaymentServiceApplication.class, args);
}
}

View File

@@ -0,0 +1,44 @@
package com.oracle.demo.payment.api;
import com.oracle.demo.payment.model.PaymentAuthorizationRequest;
import com.oracle.demo.payment.model.PaymentAuthorizationResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
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;
@RestController
@RequestMapping("/api/payments")
public class PaymentController {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentController.class);
private final String manualReviewCardPrefix;
private final boolean forceTimeout;
public PaymentController(
@Value("${demo.payment.manual-review-card-prefix:9999}") String manualReviewCardPrefix,
@Value("${demo.payment.force-timeout:false}") boolean forceTimeout) {
this.manualReviewCardPrefix = manualReviewCardPrefix;
this.forceTimeout = forceTimeout;
}
@PostMapping("/authorize")
public PaymentAuthorizationResponse authorize(@RequestBody PaymentAuthorizationRequest request) throws InterruptedException {
if (forceTimeout) {
LOGGER.warn("Payment timeout mode enabled for order {}", request.orderId());
Thread.sleep(15000L);
}
if (request.cardToken() != null && request.cardToken().startsWith(manualReviewCardPrefix)) {
LOGGER.warn("Payment requires manual review for order {}", request.orderId());
return new PaymentAuthorizationResponse(false, "REVIEW_REQUIRED", "Card flagged for manual review.");
}
return new PaymentAuthorizationResponse(true, "APPROVED", "Payment approved.");
}
}

View File

@@ -0,0 +1,5 @@
package com.oracle.demo.payment.model;
public record PaymentAuthorizationRequest(String orderId, String cardToken, double amount) {
}

View File

@@ -0,0 +1,5 @@
package com.oracle.demo.payment.model;
public record PaymentAuthorizationResponse(boolean approved, String status, String message) {
}

View File

@@ -0,0 +1,21 @@
spring:
application:
name: payment-service
server:
port: 8082
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus
endpoint:
health:
probes:
enabled: true
demo:
payment:
manual-review-card-prefix: "9999"
force-timeout: false