Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 30 additions & 32 deletions payment-service/build.gradle
Original file line number Diff line number Diff line change
@@ -1,53 +1,51 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.0'
id 'org.springframework.boot' version '3.5.4'
id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.synapse'
version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
sourceCompatibility = JavaVersion.VERSION_21
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}

dependencies {
// PortOne
implementation 'io.portone:server-sdk:0.19.0'
// Security
implementation 'org.springframework.boot:spring-boot-starter-security'
// Web
implementation 'org.springframework.boot:spring-boot-starter-web'
// JPA
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// PostgreSQL
runtimeOnly 'org.postgresql:postgresql'
// OAuth2 Resource Server
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
// WebFlux
implementation 'org.springframework.boot:spring-boot-starter-webflux'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
//H2 Database
implementation 'com.h2database:h2'
// Validation
implementation 'org.springframework.boot:spring-boot-starter-validation'
// Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
subprojects {
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'

repositories {
mavenCentral()
}

dependencies {
// Web
implementation 'org.springframework.boot:spring-boot-starter-web'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// Validation
implementation 'org.springframework.boot:spring-boot-starter-validation'
}
}

tasks.named('test') {
useJUnitPlatform()
}

bootJar {
enabled = false
}
37 changes: 37 additions & 0 deletions payment-service/payment-service-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
15 changes: 15 additions & 0 deletions payment-service/payment-service-api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repositories {
mavenCentral()
}

dependencies {

}

tasks.named('test') {
useJUnitPlatform()
}

bootJar {
enabled = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.synapse.payment_service_api.dto.request;

import jakarta.validation.constraints.NotBlank;

public record CancelSubscriptionRequest(
@NotBlank(message = "취소 사유는 필수입니다.")
String reason
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.synapse.payment_service_api.dto.request;

import jakarta.validation.constraints.NotBlank;

public record PaymentRequestDto(
@NotBlank(message = "구독 티어는 필수입니다")
String tier
) {

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.synapse.payment_service.dto.request;
package com.synapse.payment_service_api.dto.request;

import jakarta.validation.constraints.NotBlank;

public record PaymentVerificationRequest(
@NotBlank(message = "paymentId는 필수입니다")
String paymentId,
@NotBlank(message = "iamPortTransactionId는 필수입니다")
@NotBlank(message = "paymentId는 필수입니다")
String paymentId,

@NotBlank(message = "iamPortTransactionId는 필수입니다")
String iamPortTransactionId
) {

}
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
package com.synapse.payment_service.dto.request;
package com.synapse.payment_service_api.dto.request;

import java.io.IOException;
import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.Optional;

public record PaymentWebhookRequest(
@JsonProperty("type")
String type,
@JsonProperty("timestamp")
String timestamp,
@JsonProperty("data")
JsonNode data
@JsonProperty("type") String type,
@JsonProperty("timestamp") String timestamp,
@JsonProperty("data") JsonNode data
) {

public static PaymentWebhookRequest from(String requestBody, ObjectMapper objectMapper) throws IOException {
return objectMapper.readValue(requestBody, PaymentWebhookRequest.class);
}

public String getPaymentId() {
if (data == null) return null;
if (data == null)
return null;
return extractText(data, "paymentId");
}

public String getTransactionId() {
if (data == null) return null;
if (data == null)
return null;
return extractText(data, "transactionId");
}

public String getBillingKey() {
if (data == null) return null;
if (data == null)
return null;
return extractText(data, "billingKey");
}

private String extractText(JsonNode node, String fieldName) {
return Optional.ofNullable(node.get(fieldName))
.map(JsonNode::asText)
.orElse(null);
}

public boolean isTransactionWebhook() {
return type != null && type.startsWith("Transaction.");
}

public boolean isBillingKeyWebhook() {
return type != null && type.startsWith("BillingKey.");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.synapse.payment_service.dto.response;
package com.synapse.payment_service_api.dto.response;

import java.math.BigDecimal;

Expand All @@ -7,5 +7,5 @@ public record PaymentPreparationResponse(
String orderName,
BigDecimal amount
) {

}
39 changes: 39 additions & 0 deletions payment-service/payment-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

**/security/*
31 changes: 31 additions & 0 deletions payment-service/payment-service/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
repositories {
mavenCentral()
}

dependencies {
implementation project(":payment-service-api")
// PortOne
implementation 'io.portone:server-sdk:0.19.0'
// Security
implementation 'org.springframework.boot:spring-boot-starter-security'
// JPA
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// PostgreSQL
runtimeOnly 'org.postgresql:postgresql'
// OAuth2 Resource Server
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
// WebFlux
implementation 'org.springframework.boot:spring-boot-starter-webflux'
//H2 Database
implementation 'com.h2database:h2'
// Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@SpringBootApplication
public class PaymentServiceApplication {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.synapse.payment_service;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@ComponentScan
@EnableAutoConfiguration
@EnableJpaAuditing
public class PaymentServiceConfiguration {

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.synapse.payment_service.config;
package com.synapse.payment_service.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -8,7 +8,7 @@

@Configuration
public class ObjectMapperConfig {

@Bean
public ObjectMapper objectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.synapse.payment_service.config;
package com.synapse.payment_service.configuration;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.synapse.payment_service.config;
package com.synapse.payment_service.configuration;

import org.springframework.boot.context.properties.ConfigurationProperties;

Expand All @@ -10,5 +10,5 @@ public record PortOneClientProperties(
String webhookSecret,
String channelKey
) {

}
Loading
Loading