Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9f70732
refactor: order 테이블 pk 변경 (#80)
Soundbar91 Aug 27, 2025
8cd7ff4
refactor: 외부 연동 계층 추가 (#82)
Soundbar91 Aug 27, 2025
2bec7d9
fix: PaymentService 인터페이스 삭제
Soundbar91 Aug 27, 2025
5aa8e4a
fix: DTO 변환 로직 이동
Soundbar91 Aug 27, 2025
9f01554
fix: PaymentRollBackService 인터페이스 삭제
Soundbar91 Aug 27, 2025
0b58bd9
chore: TossPaymentRollBackService -> PaymentRollBackService 으로 리네이밍
Soundbar91 Aug 27, 2025
feff570
feat: TemporaryPaymentService 추가
Soundbar91 Aug 28, 2025
7ea0b56
fix: pgOrderId 생성 책임 PaymentGatewayService으로 위임
Soundbar91 Aug 28, 2025
022c4d9
refactor: PaymentService 임시 결제 생성 로직 리펙토링
Soundbar91 Aug 28, 2025
f7581d1
feat: PaymentConfirmService 추가
Soundbar91 Aug 28, 2025
2a21e94
refactor: PaymentService 결제 승인 로직 리펙토링
Soundbar91 Aug 28, 2025
321114a
feat: PaymentCancelService 추가
Soundbar91 Aug 28, 2025
384c9c4
refactor: PaymentService 결제 취소 로직 리펙토링
Soundbar91 Aug 28, 2025
3a6f092
feat: PaymentQueryService 추가
Soundbar91 Aug 28, 2025
75f94f9
refactor: PaymentService 결제 조회 로직 리펙토링
Soundbar91 Aug 28, 2025
903de9c
fix: PaymentService 메소드 시그니처 변경
Soundbar91 Aug 28, 2025
e073c38
feat: 비즈니스 서비스 로직 도메인 객체 추가
Soundbar91 Aug 28, 2025
5ed16d4
chore: PaymentGateway dto 변수 네이밍 수정
Soundbar91 Sep 1, 2025
386f6a8
fix: 기존 PgOrderIdGenerator 삭제
Soundbar91 Sep 1, 2025
0519681
refactor: 임시 결제 정보 생성 로직 이동
Soundbar91 Sep 1, 2025
856fc8e
feat: TemporaryMenuItemsMapper 추가
Soundbar91 Sep 1, 2025
b6a999b
fix: 결제 롤백 로직 삭제
Soundbar91 Sep 1, 2025
ee2234e
fix: 트랜잭션 어노테이션 수정
Soundbar91 Sep 1, 2025
9878f8b
feat: 멀티 데이터 소스 추가
Soundbar91 Sep 1, 2025
6690410
chore: 결제 관련 엔티티 클래스 패키지 이동
Soundbar91 Sep 1, 2025
39a14d2
feat: 트랜잭션 매니져 설정
Soundbar91 Sep 1, 2025
87ad259
build: flyway 추가
Soundbar91 Sep 1, 2025
eb4ee5a
feat: flyway 적용
Soundbar91 Sep 1, 2025
e769583
chore: 스키마 설정 삭제
Soundbar91 Sep 1, 2025
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
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ dependencies {
// slack Notification
implementation 'com.github.maricn:logback-slack-appender:1.4.0'

// flyway
implementation 'org.flywaydb:flyway-mysql'

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.squareup.okhttp3:mockwebserver'
Expand Down

This file was deleted.

15 changes: 1 addition & 14 deletions src/main/java/in/koreatech/payment/KoinPaymentApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@ConfigurationPropertiesScan
@SpringBootApplication(
scanBasePackages = {
"in.koreatech.payment",
"in.koreatech.koin"
}
)
@EnableJpaRepositories(basePackages = {
"in.koreatech.payment",
"in.koreatech.koin"
})
@EntityScan(basePackages = {
"in.koreatech.payment",
"in.koreatech.koin"
})
@SpringBootApplication
public class KoinPaymentApplication {

public static void main(String[] args) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package in.koreatech.payment.common.config.datasource;

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

@ConfigurationProperties(prefix = "spring.datasource.koin.hibernate")
public record KoinDBProperties(
String ddlAuto,
Boolean showSql,
String packagesToScan,
String formatSql
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package in.koreatech.payment.common.config.datasource;

import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import jakarta.persistence.EntityManagerFactory;
import lombok.RequiredArgsConstructor;

@Configuration
@RequiredArgsConstructor
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "in.koreatech.koin",
entityManagerFactoryRef = "koinEntityManagerFactory",
transactionManagerRef = "koinTransactionManager"
)
public class KoinDataSourceConfig {

private final KoinDBProperties koinDBProperties;

@Bean(name = "koinDataSource")
@ConfigurationProperties("spring.datasource.koin")
public DataSource koinDataSource() {
return DataSourceBuilder.create().build();
}

@Bean(name = "koinEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean koinEntityManagerFactory(
@Qualifier(value = "koinDataSource") DataSource dataSource
) {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setPackagesToScan(koinDBProperties.packagesToScan());
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaPropertyMap(createJpaVendorProperties());
return em;
}

private Map<String, Object> createJpaVendorProperties() {
Map<String, Object> properties = new HashMap<>();
properties.put("hibernate.show_sql", koinDBProperties.showSql());
properties.put("hibernate.hbm2ddl.auto", koinDBProperties.ddlAuto());
properties.put("hibernate.format_sql", koinDBProperties.formatSql());
return properties;
}

@Bean(name = "koinTransactionManager")
public PlatformTransactionManager koinTransactionManager(
@Qualifier(value = "koinEntityManagerFactory") EntityManagerFactory entityManagerFactory
) {
return new JpaTransactionManager(entityManagerFactory);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package in.koreatech.payment.common.config.datasource;

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

@ConfigurationProperties(prefix = "spring.datasource.koin-payment.hibernate")
public record KoinPaymentDBProperties(
String ddlAuto,
Boolean showSql,
String packagesToScan,
String formatSql
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package in.koreatech.payment.common.config.datasource;

import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import jakarta.persistence.EntityManagerFactory;
import lombok.RequiredArgsConstructor;

@Configuration
@RequiredArgsConstructor
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "in.koreatech.payment",
entityManagerFactoryRef = "koinPaymentEntityManagerFactory",
transactionManagerRef = "koinPaymentTransactionManager"
)
public class KoinPaymentDataSourceConfig {

private final KoinPaymentDBProperties koinPaymentDBProperties;

@Bean(name = "koinPaymentDataSource")
@ConfigurationProperties("spring.datasource.koin-payment")
public DataSource koinPaymentDataSource() {
return DataSourceBuilder.create().build();
}

@Primary
@Bean(name = "koinPaymentEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean koinPaymentEntityManagerFactory(
@Qualifier(value = "koinPaymentDataSource") DataSource dataSource
) {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setPackagesToScan(koinPaymentDBProperties.packagesToScan());
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaPropertyMap(createJpaVendorProperties());
return em;
}

private Map<String, Object> createJpaVendorProperties() {
Map<String, Object> properties = new HashMap<>();
properties.put("hibernate.show_sql", koinPaymentDBProperties.showSql());
properties.put("hibernate.hbm2ddl.auto", koinPaymentDBProperties.ddlAuto());
properties.put("hibernate.format_sql", koinPaymentDBProperties.formatSql());
return properties;
}

@Primary
@Bean(name = "koinPaymentTransactionManager")
public PlatformTransactionManager koinPaymentTransactionManager(
@Qualifier(value = "koinPaymentEntityManagerFactory") EntityManagerFactory entityManagerFactory
) {
return new JpaTransactionManager(entityManagerFactory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.web.util.ContentCachingRequestWrapper;
import org.springframework.web.util.WebUtils;

import in.koreatech.payment.client.exception.TossPaymentException;
import in.koreatech.payment.gateway.toss.exception.TossPaymentException;
import in.koreatech.payment.common.exception.custom.AuthenticationException;
import in.koreatech.payment.common.exception.custom.AuthorizationException;
import in.koreatech.payment.common.exception.custom.DataNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package in.koreatech.payment.controller;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -10,7 +8,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import in.koreatech.koin.domain.order.model.PaymentCancel;
import in.koreatech.payment.common.auth.AccessToken;
import in.koreatech.payment.dto.request.PaymentCancelRequest;
import in.koreatech.payment.dto.request.PaymentConfirmRequest;
Expand All @@ -36,8 +33,7 @@ public ResponseEntity<TemporaryPaymentResponse> createTemporaryDeliveryPayment(
@RequestBody @Valid final TemporaryDeliveryPaymentSaveRequest request,
@AccessToken final String accessToken
) {
String orderId = paymentService.createTemporaryDeliveryPayment(accessToken, request);
TemporaryPaymentResponse response = TemporaryPaymentResponse.of(orderId);
TemporaryPaymentResponse response = paymentService.createTemporaryDeliveryPayment(accessToken, request);
return ResponseEntity.ok(response);
}

Expand All @@ -46,8 +42,7 @@ public ResponseEntity<TemporaryPaymentResponse> createTemporaryTakeoutPayment(
@RequestBody @Valid final TemporaryTakeoutPaymentSaveRequest request,
@AccessToken final String accessToken
) {
String orderId = paymentService.createTemporaryTakeoutPayment(accessToken, request);
TemporaryPaymentResponse response = TemporaryPaymentResponse.of(orderId);
TemporaryPaymentResponse response = paymentService.createTemporaryTakeoutPayment(accessToken, request);
return ResponseEntity.ok(response);
}

Expand All @@ -56,8 +51,7 @@ public ResponseEntity<PaymentConfirmResponse> confirmPayment(
@RequestBody @Valid final PaymentConfirmRequest request,
@AccessToken final String accessToken
) {
PaymentConfirmResponse response = paymentService.confirmPayment(accessToken, request.paymentKey(), request.orderId(),
request.amount());
PaymentConfirmResponse response = paymentService.confirmPayment(accessToken, request);
return ResponseEntity.ok(response);
}

Expand All @@ -67,9 +61,7 @@ public ResponseEntity<PaymentCancelResponse> cancelPayment(
@RequestBody @Valid final PaymentCancelRequest request,
@AccessToken final String accessToken
) {
List<PaymentCancel> paymentCancels = paymentService.cancelPayment(accessToken, paymentId,
request.cancelReason());
PaymentCancelResponse response = PaymentCancelResponse.from(paymentCancels);
PaymentCancelResponse response = paymentService.cancelPayment(accessToken, paymentId, request);
return ResponseEntity.ok(response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import in.koreatech.koin.domain.order.model.PaymentCancel;
import in.koreatech.payment.model.entity.PaymentCancel;
import io.swagger.v3.oas.annotations.media.Schema;

@JsonNaming(value = SnakeCaseStrategy.class)
Expand Down
Loading
Loading