-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/43 payments #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5f1edfe
feat: 토스 빌링키 발급 api 개발(card, authKey)
jiminnimij b4eec39
chore: 불필요 파일 삭제
jiminnimij 08581f1
test: 빌링키 테스트 코드 작성
jiminnimij 33b4e93
fix: 빌링키 관련 변수 수정
jiminnimij 1de9e0e
feat: 환율 스케줄링 구현
jiminnimij 08d3596
feat: 빌링 승인 및 스케줄링 구현
jiminnimij 2c4d6c3
feat: 유저 사용량 객체 초기화 추가
jiminnimij File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/net/studioxai/studioxBe/domain/payment/controller/BillingKeyController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package net.studioxai.studioxBe.domain.payment.controller; | ||
|
|
||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import lombok.RequiredArgsConstructor; | ||
| import net.studioxai.studioxBe.domain.payment.dto.request.BillingKeyAuthKeyCreateRequest; | ||
| import net.studioxai.studioxBe.domain.payment.dto.request.BillingKeyCardCreateRequest; | ||
| import net.studioxai.studioxBe.domain.payment.entity.enums.Plan; | ||
| import net.studioxai.studioxBe.domain.payment.service.BillingKeyService; | ||
| import net.studioxai.studioxBe.global.jwt.JwtUserPrincipal; | ||
| import net.studioxai.studioxBe.global.util.IpUtil; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api") | ||
| @RequiredArgsConstructor | ||
| public class BillingKeyController { | ||
| private final IpUtil ipUtil; | ||
| private final BillingKeyService billingKeyService; | ||
|
|
||
| @PostMapping("/v1/payment/billingKey/authKey") | ||
| public void createBillingKeyAuthKey( | ||
| @AuthenticationPrincipal JwtUserPrincipal principal, | ||
| @RequestParam Plan plan, | ||
| @RequestBody BillingKeyAuthKeyCreateRequest billingKeyCreateRequest, | ||
| HttpServletRequest request | ||
| ) throws IOException { | ||
| String clientIp = ipUtil.getClientIp(request); | ||
| billingKeyService.createBillingKeyWithAuthKey(principal.userId(), billingKeyCreateRequest, plan, clientIp); | ||
| } | ||
|
|
||
| @PostMapping("/v1/payment/billingKey/card") | ||
| public void createBillingKeyCard( | ||
| @AuthenticationPrincipal JwtUserPrincipal principal, | ||
| @RequestParam Plan plan, | ||
| @RequestBody BillingKeyCardCreateRequest billingKeyCreateRequest, | ||
| HttpServletRequest request | ||
| ) throws IOException { | ||
| String clientIp = ipUtil.getClientIp(request); | ||
| billingKeyService.createBillingKeyWithCard(principal.userId(), billingKeyCreateRequest, plan, clientIp); | ||
| } | ||
|
|
||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/net/studioxai/studioxBe/domain/payment/dto/CardDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto; | ||
|
|
||
| public record CardDto( | ||
| String issuerCode, | ||
| String acquirerCode, | ||
| String number, | ||
| String cardType, | ||
| String ownerType | ||
| ) { | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/net/studioxai/studioxBe/domain/payment/dto/FailureDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto; | ||
|
|
||
| public record FailureDto( | ||
| String code, | ||
| String message | ||
| ) { | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/net/studioxai/studioxBe/domain/payment/dto/ThreeDsValueDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto; | ||
|
|
||
| import jakarta.validation.constraints.Pattern; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| public record ThreeDsValueDto ( | ||
| @Size(max = 2048, message = "masking 값은 2048자 이하여야 합니다.") | ||
| @Pattern( | ||
| regexp = "^[A-Za-z0-9+/=_\\-.*]*$", | ||
| message = "masking 값에 허용되지 않는 문자가 포함되어 있습니다." | ||
| ) | ||
| String masking, | ||
|
|
||
| @Size(max = 2048, message = "plain 값은 2048자 이하여야 합니다.") | ||
| @Pattern( | ||
| regexp = "^[A-Za-z0-9+/=_\\-.*]*$", | ||
| message = "plain 값에 허용되지 않는 문자가 포함되어 있습니다." | ||
| ) | ||
| String plain | ||
| ) { | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/net/studioxai/studioxBe/domain/payment/dto/TransferDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto; | ||
|
|
||
| public record TransferDto( | ||
| String bankName, | ||
| String bankAccountNumber | ||
| ) { | ||
| } |
51 changes: 51 additions & 0 deletions
51
src/main/java/net/studioxai/studioxBe/domain/payment/dto/request/BillingApprovalRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import net.studioxai.studioxBe.domain.payment.entity.BillingKey; | ||
| import net.studioxai.studioxBe.domain.payment.entity.PaymentHistory; | ||
| import net.studioxai.studioxBe.domain.payment.entity.enums.Plan; | ||
| import net.studioxai.studioxBe.domain.user.entity.User; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| public record BillingApprovalRequest( | ||
| @NotBlank | ||
| String billingKey, | ||
| @NotBlank | ||
| long amount, | ||
| @NotBlank | ||
| String customerKey, | ||
| @NotBlank | ||
| String orderId, | ||
| @NotBlank | ||
| String orderName, | ||
| String customerEmail, | ||
| String customerName, | ||
| String customerIp, | ||
| int taxFreeAmount, | ||
| int taxExemptionAmount | ||
| ) { | ||
| public static BillingApprovalRequest of( | ||
| User user, | ||
| Plan plan, | ||
| long amount, | ||
| BillingKey billingKey, | ||
| PaymentHistory paymentHistory, | ||
| String customerIp, | ||
| int taxFreeAmount, | ||
| int taxExemptionAmount | ||
| ) { | ||
| return new BillingApprovalRequest( | ||
| billingKey.getBillingKey(), | ||
| amount, | ||
| user.getCustomerKey(), | ||
| paymentHistory.getOrderId(), | ||
| plan.name(), | ||
| user.getEmail(), | ||
| user.getUsername(), | ||
| customerIp, | ||
| taxFreeAmount, | ||
| taxExemptionAmount | ||
| ); | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
...va/net/studioxai/studioxBe/domain/payment/dto/request/BillingKeyAuthKeyCreateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Pattern; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| public record BillingKeyAuthKeyCreateRequest( | ||
| @NotBlank(message = "authKey는 필수입니다.") | ||
| @Size(max = 300, message = "authKey는 300자 이하여야 합니다.") | ||
| String authKey, | ||
|
|
||
| @NotBlank(message = "customerKey는 필수입니다.") | ||
| @Size(min = 2, max = 300, message = "customerKey는 2자 이상 300자 이하여야 합니다.") | ||
| @Pattern( | ||
| regexp = "^[A-Za-z0-9\\-_=\\.@]+$", | ||
| message = "customerKey는 영문, 숫자, -, _, =, ., @ 만 사용할 수 있습니다." | ||
| ) | ||
| String customerKey | ||
| ) { | ||
| } |
70 changes: 70 additions & 0 deletions
70
.../java/net/studioxai/studioxBe/domain/payment/dto/request/BillingKeyCardCreateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto.request; | ||
|
|
||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.Email; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Pattern; | ||
| import jakarta.validation.constraints.Size; | ||
| import net.studioxai.studioxBe.domain.payment.dto.ThreeDsValueDto; | ||
|
|
||
| public record BillingKeyCardCreateRequest ( | ||
| @NotBlank(message = "카드 만료 월은 필수입니다.") | ||
| @Pattern( | ||
| regexp = "^(0[1-9]|1[0-2])$", | ||
| message = "카드 만료 월은 01~12 형식이어야 합니다." | ||
| ) | ||
| String cardExpirationMonth, | ||
|
|
||
| @NotBlank(message = "카드 만료 연도는 필수입니다.") | ||
| @Pattern( | ||
| regexp = "^\\d{2}$", | ||
| message = "카드 만료 연도는 YY 형식의 숫자 2자리여야 합니다." | ||
| ) | ||
| String cardExpirationYear, | ||
|
|
||
| @NotBlank(message = "카드 번호는 필수입니다.") | ||
| @Pattern( | ||
| regexp = "^\\d{12,19}$", | ||
| message = "카드 번호는 숫자 12~19자리여야 합니다." | ||
| ) | ||
| String cardNumber, | ||
|
|
||
| @NotBlank(message = "카드 비밀번호 앞 2자리는 필수입니다.") | ||
| @Pattern( | ||
| regexp = "^\\d{2}$", | ||
| message = "카드 비밀번호는 숫자 2자리여야 합니다." | ||
| ) | ||
| String cardPassword, | ||
|
|
||
| @NotBlank(message = "고객 식별번호는 필수입니다.") | ||
| @Pattern( | ||
| regexp = "^(\\d{6}|\\d{10})$", | ||
| message = "고객 식별번호는 생년월일 6자리 또는 사업자등록번호 10자리여야 합니다." | ||
| ) | ||
| String customerIdentityNumber, | ||
|
|
||
| @NotBlank(message = "customerKey는 필수입니다.") | ||
| @Size(min = 2, max = 50, message = "customerKey는 2자 이상 50자 이하여야 합니다.") | ||
| @Pattern( | ||
| regexp = "^[A-Za-z0-9\\-_=\\.@]+$", | ||
| message = "customerKey는 영문, 숫자, -, _, =, ., @ 만 사용할 수 있습니다." | ||
| ) | ||
| String customerKey, | ||
|
|
||
| @Email(message = "이메일 형식이 올바르지 않습니다.") | ||
| @Size(max = 100, message = "이메일은 100자 이하여야 합니다.") | ||
| String customerEmail, | ||
|
|
||
| @Size(max = 100, message = "고객 이름은 100자 이하여야 합니다.") | ||
| String customerName, | ||
|
|
||
| @Valid | ||
| ThreeDsValueDto cavv, | ||
|
|
||
| @Valid | ||
| ThreeDsValueDto eci, | ||
|
|
||
| @Valid | ||
| ThreeDsValueDto xid | ||
| ) { | ||
| } |
35 changes: 35 additions & 0 deletions
35
...ain/java/net/studioxai/studioxBe/domain/payment/dto/response/BillingApprovalResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto.response; | ||
|
|
||
| import net.studioxai.studioxBe.domain.payment.dto.CardDto; | ||
| import net.studioxai.studioxBe.domain.payment.dto.FailureDto; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| public record BillingApprovalResponse ( | ||
| String version, | ||
| String paymentKey, | ||
| String type, | ||
| String orderId, | ||
| String orderName, | ||
| String mId, | ||
| String currency, | ||
| String method, | ||
| BigDecimal totalAmount, | ||
| String balanceAmount, | ||
| String status, | ||
| String requestedAt, | ||
| String approvedAt, | ||
| boolean useEscrow, | ||
| String lastTransactionKey, | ||
| int suppliedAmount, | ||
| int vat, | ||
| boolean cultureExpense, | ||
| int taxFreeAmount, | ||
| int taxExemptionAmount, | ||
| CardDto card, | ||
| boolean isPartialCancelable, | ||
| String country, | ||
| FailureDto failure | ||
| ) { | ||
|
|
||
| } |
26 changes: 26 additions & 0 deletions
26
src/main/java/net/studioxai/studioxBe/domain/payment/dto/response/BillingKeyResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto.response; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import net.studioxai.studioxBe.domain.payment.dto.CardDto; | ||
| import net.studioxai.studioxBe.domain.payment.dto.TransferDto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record BillingKeyResponse ( | ||
| @JsonProperty("mId") | ||
| String mId, | ||
|
|
||
| String customerKey, | ||
|
|
||
| String authenticatedAt, | ||
|
|
||
| String method, | ||
|
|
||
| String billingKey, | ||
|
|
||
| CardDto card, | ||
|
|
||
| List<TransferDto> transfers | ||
| ) { | ||
|
|
||
| } |
23 changes: 23 additions & 0 deletions
23
src/main/java/net/studioxai/studioxBe/domain/payment/dto/response/ExchangeRateResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package net.studioxai.studioxBe.domain.payment.dto.response; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.Map; | ||
|
|
||
| public record ExchangeRateResponse( | ||
| String result, | ||
|
|
||
| @JsonProperty("time_last_update_utc") | ||
| String timeLastUpdateUtc, | ||
|
|
||
| @JsonProperty("time_next_update_utc") | ||
| String timeNextUpdateUtc, | ||
|
|
||
| @JsonProperty("base_code") | ||
| String baseCode, | ||
|
|
||
| @JsonProperty("conversion_rates") | ||
| Map<String, BigDecimal> conversionRates | ||
| ) { | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json-simple은 다소 오래된 라이브러리이며, Spring Boot 프로젝트에서는 이미 Jackson(ObjectMapper)이 기본적으로 포함되어 있습니다. 별도의 의존성을 추가하기보다는 프로젝트에 이미 포함된 Jackson을 활용하는 것을 권장합니다.