Skip to content

Commit

Permalink
Fix: #207 build.gradle 의존성 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeJae-H committed Dec 3, 2024
1 parent 3fe956c commit 2bf1294
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions genti-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ dependencies {
// redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

compileOnly("com.google.api-client:google-api-client:1.33.0")
implementation "com.google.api-client:google-api-client:1.33.0"
implementation 'com.google.auth:google-auth-library-oauth2-http:1.6.0'
compileOnly('com.google.apis:google-api-services-androidpublisher:v2-rev22-1.21.0')
implementation 'com.google.apis:google-api-services-androidpublisher:v2-rev22-1.21.0'

// test && test h2
testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,64 +33,64 @@ public Boolean validateReceipt(Long userId, PurchaseRequestDto purchaseRequestDt

// try {
// ================= Google Credential 생성 =================
JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();

AndroidPublisher.Builder builder;
try {
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

InputStream inputStream = new ClassPathResource(googleAccountFilePath).getInputStream();
GoogleCredentials credentials = GoogleCredentials
.fromStream(inputStream)
.createScoped(AndroidPublisherScopes.ANDROIDPUBLISHER);
builder = new AndroidPublisher.Builder(httpTransport, JSON_FACTORY, new HttpCredentialsAdapter(credentials));
} catch (IOException | GeneralSecurityException e){
throw ExpectedException.withLogging(ResponseCode.CashoutNotFound,
"---------------------------------------구매 에러 IOException, GeneralSecurityException 에러 1111111111: " + e + "-------------------------------------------------");
}
JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();

AndroidPublisher.Builder builder;
try {
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

InputStream inputStream = new ClassPathResource(googleAccountFilePath).getInputStream();
GoogleCredentials credentials = GoogleCredentials
.fromStream(inputStream)
.createScoped(AndroidPublisherScopes.ANDROIDPUBLISHER);
builder = new AndroidPublisher.Builder(httpTransport, JSON_FACTORY, new HttpCredentialsAdapter(credentials));
} catch (IOException | GeneralSecurityException e){
throw ExpectedException.withLogging(ResponseCode.CashoutNotFound,
"---------------------------------------구매 에러 IOException, GeneralSecurityException 에러 1111111111: " + e + "-------------------------------------------------");
}

AndroidPublisher publisher;
try {
// ======================== API 호출 ========================
publisher = builder.setApplicationName(googleApplicationPackageName).build();
AndroidPublisher.Purchases.Products.Get gas = publisher.purchases()
.products()
.get(
"packageName",
"productId",
"purchaseToken");
ProductPurchase purchase = gas.execute();
} catch (IOException e){
throw ExpectedException.withLogging(ResponseCode.HttpMessageNotReadable,
"---------------------------------------구매 에러 IOException 에러 2222222222: " + e + "-------------------------------------------------");
try {
// ======================== API 호출 ========================
publisher = builder.setApplicationName(googleApplicationPackageName).build();
AndroidPublisher.Purchases.Products.Get gas = publisher.purchases()
.products()
.get(
"packageName",
"productId",
"purchaseToken");
ProductPurchase purchase = gas.execute();
} catch (IOException e){
throw ExpectedException.withLogging(ResponseCode.HttpMessageNotReadable,
"---------------------------------------구매 에러 IOException 에러 2222222222: " + e + "-------------------------------------------------");
}


try{
AndroidPublisher.Purchases.Products.Get get = publisher.purchases().products()
.get(purchaseRequestDto.getPackageName(), purchaseRequestDto.getProductId(), purchaseRequestDto.getPurchaseToken()); //inapp 아이템의 구매 및 소모 상태 확인
ProductPurchase productPurchase = get.execute(); //검증 결과
System.out.println(productPurchase.toPrettyString());

// 인앱 상품의 소비 상태. 0 아직 소비 안됨(Yet to be consumed) / 1 소비됨(Consumed)
Integer consumptionState = productPurchase.getConsumptionState();

// 개발자가 지정한 임의 문자열 정보
String developerPayload = productPurchase.getDeveloperPayload();

// 구매 상태. 0 구매완료 / 1 취소됨
Integer purchaseState = productPurchase.getPurchaseState();
if(purchaseState == 1){
return false;
}

// 상품이 구매된 시각. 타임스탬프 형태
Long purchaseTimeMillis = productPurchase.getPurchaseTimeMillis();

try{
AndroidPublisher.Purchases.Products.Get get = publisher.purchases().products()
.get(purchaseRequestDto.getPackageName(), purchaseRequestDto.getProductId(), purchaseRequestDto.getPurchaseToken()); //inapp 아이템의 구매 및 소모 상태 확인
ProductPurchase productPurchase = get.execute(); //검증 결과
System.out.println(productPurchase.toPrettyString());

// 인앱 상품의 소비 상태. 0 아직 소비 안됨(Yet to be consumed) / 1 소비됨(Consumed)
Integer consumptionState = productPurchase.getConsumptionState();

// 개발자가 지정한 임의 문자열 정보
String developerPayload = productPurchase.getDeveloperPayload();

// 구매 상태. 0 구매완료 / 1 취소됨
Integer purchaseState = productPurchase.getPurchaseState();
if(purchaseState == 1){
return false;
}

// 상품이 구매된 시각. 타임스탬프 형태
Long purchaseTimeMillis = productPurchase.getPurchaseTimeMillis();

return true;
} catch (IOException e) {
throw ExpectedException.withLogging(ResponseCode.FileTypeNotProvided,
"---------------------------------------구매 에러 IOException 에러 333333333333: " + e + "-------------------------------------------------");
}
return true;
} catch (IOException e) {
throw ExpectedException.withLogging(ResponseCode.FileTypeNotProvided,
"---------------------------------------구매 에러 IOException 에러 333333333333: " + e + "-------------------------------------------------");
}
}
}

0 comments on commit 2bf1294

Please sign in to comment.