-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YEL-117 [develop] apple 결제 검증 배포
- Loading branch information
Showing
18 changed files
with
322 additions
and
134 deletions.
There are no files selected for viewing
This file contains 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 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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/yello/server/domain/purchase/dto/apple/AppleOrderResponse.java
This file contains 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,12 @@ | ||
package com.yello.server.domain.purchase.dto.apple; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record AppleOrderResponse( | ||
int appAppleId, | ||
String environment, | ||
String JWSTransaction | ||
) { | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/yello/server/domain/purchase/dto/apple/AppleTransaction.java
This file contains 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,13 @@ | ||
package com.yello.server.domain.purchase.dto.apple; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record AppleTransaction( | ||
|
||
String transactionId, | ||
String productId | ||
|
||
) { | ||
|
||
} |
14 changes: 0 additions & 14 deletions
14
src/main/java/com/yello/server/domain/purchase/dto/apple/AppleVerifyReceipt.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/main/java/com/yello/server/domain/purchase/dto/apple/AppleVerifyReceiptResponse.java
This file was deleted.
Oops, something went wrong.
This file contains 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 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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/yello/server/domain/purchase/exception/PurchaseException.java
This file contains 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,13 @@ | ||
package com.yello.server.domain.purchase.exception; | ||
|
||
import com.yello.server.global.common.ErrorCode; | ||
import com.yello.server.global.exception.CustomException; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class PurchaseException extends CustomException { | ||
|
||
public PurchaseException(ErrorCode error) { | ||
super(error, "[PurchaseException] " + error.getMessage()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/yello/server/domain/purchase/exception/PurchaseNotFoundException.java
This file contains 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,13 @@ | ||
package com.yello.server.domain.purchase.exception; | ||
|
||
import com.yello.server.global.common.ErrorCode; | ||
import com.yello.server.global.exception.CustomException; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class PurchaseNotFoundException extends CustomException { | ||
|
||
public PurchaseNotFoundException(ErrorCode error) { | ||
super(error, "[PurchaseNotFoundException] " + error.getMessage()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/yello/server/domain/purchase/exception/SubscriptionConflictException.java
This file contains 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,14 @@ | ||
package com.yello.server.domain.purchase.exception; | ||
|
||
import com.yello.server.global.common.ErrorCode; | ||
import com.yello.server.global.exception.CustomException; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class SubscriptionConflictException extends CustomException { | ||
|
||
public SubscriptionConflictException(ErrorCode error) { | ||
super(error, "[SubscriptionConflictException] " + error.getMessage()); | ||
} | ||
|
||
} |
This file contains 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 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 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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/yello/server/global/common/factory/TokenFactory.java
This file contains 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,49 @@ | ||
package com.yello.server.global.common.factory; | ||
|
||
import io.jsonwebtoken.Jwts; | ||
import io.jsonwebtoken.SignatureAlgorithm; | ||
import java.security.KeyFactory; | ||
import java.security.spec.PKCS8EncodedKeySpec; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
import lombok.SneakyThrows; | ||
import org.apache.commons.codec.binary.Base64; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class TokenFactory { | ||
|
||
@Value("${kid}") | ||
private String KID; | ||
@Value("${iss}") | ||
private String ISS; | ||
@Value("${aud}") | ||
private String AUD; | ||
@Value("${bid}") | ||
private String BID; | ||
@Value("${sig}") | ||
private String SIG; | ||
|
||
@SneakyThrows | ||
public String generateAppleToken() { | ||
String jws = Jwts.builder() | ||
// header | ||
.setHeaderParam("kid", KID) | ||
// payload | ||
.setIssuer(ISS) | ||
.setIssuedAt(new Date(Calendar.getInstance().getTimeInMillis())) // 발행 시간 - UNIX 시간 | ||
.setExpiration( | ||
new Date(Calendar.getInstance().getTimeInMillis() + (3 * 60 | ||
* 1000))) // 만료 시간 (발행 시간 + 3분) | ||
.setAudience(AUD) | ||
.claim("bid", BID) | ||
// sign | ||
.signWith(SignatureAlgorithm.ES256, | ||
KeyFactory.getInstance("EC").generatePrivate(new PKCS8EncodedKeySpec( | ||
Base64.decodeBase64(SIG)))) | ||
.compact(); | ||
|
||
return jws; | ||
} | ||
} |
Oops, something went wrong.