Skip to content

Commit

Permalink
YEL-176 [feat] noti 종류별 purchase 접근 로직 픽스
Browse files Browse the repository at this point in the history
YEL-176 [feat] noti 종류별 purchase 접근 로직 픽스
  • Loading branch information
euije authored Oct 15, 2023
2 parents a5d8b92 + 71a22a7 commit bacd658
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,22 +368,23 @@ public void googleNotification(GooglePubSubNotificationRequest request) {
);

final DeveloperNotification developerNotification = gson.fromJson(data, DeveloperNotification.class);

if (ObjectUtils.isEmpty(developerNotification.getProductType())) {
log.info("BAD REQUEST by wrong pub-sub name");
throw new GoogleBadRequestException(GOOGLE_NOTIFICATION_BAD_REQUEST_EXCEPTION);
}
log.info(String.format("notification product type is %s", developerNotification.getProductType().toString()));

final Optional<Purchase> purchase = purchaseRepository.findByPurchaseToken(
developerNotification.subscriptionNotification().purchaseToken());

switch (developerNotification.getProductType()) {

case TEST -> {
log.info("TEST notification is sent by Google Play Console");
return;
}
case YELLO_PLUS -> {
final Optional<Purchase> purchase = purchaseRepository.findByPurchaseToken(
developerNotification.subscriptionNotification().purchaseToken());

if (purchase.isEmpty()) {
log.info("notification is rejected by INVALID PurchaseToken");
throw new PurchaseNotFoundException(PURCHASE_TOKEN_NOT_FOUND_PURCHASE_EXCEPTION);
Expand Down Expand Up @@ -423,6 +424,9 @@ public void googleNotification(GooglePubSubNotificationRequest request) {
}
}
case ONE_TICKET, TWO_TICKET, FIVE_TICKET -> {
final Optional<Purchase> purchase = purchaseRepository.findByPurchaseToken(
developerNotification.oneTimeProductNotification().purchaseToken());

if (purchase.isEmpty()) {
log.info("notification is rejected by INVALID PurchaseToken");
throw new PurchaseNotFoundException(PURCHASE_TOKEN_NOT_FOUND_PURCHASE_EXCEPTION);
Expand Down

0 comments on commit bacd658

Please sign in to comment.