Skip to content

Commit

Permalink
YEL-177 [hotfix] apple pay column fix
Browse files Browse the repository at this point in the history
YEL-177 [hotfix] apple pay column fix
  • Loading branch information
hyeonjeongs authored Oct 22, 2023
2 parents 119b9fb + 749e53e commit 187a362
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class Purchase extends AuditingTimeEntity {
@Convert(converter = PurchaseStateConverter.class)
private PurchaseState state;

@Column
@Column(length = 15000)
private String rawData;

@Column(nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.yello.server.global.common.util.ConstantUtil;
import com.yello.server.infrastructure.slack.dto.response.SlackAppleNotificationResponse;
import java.util.Map;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -112,35 +113,47 @@ public Purchase decodeAppleNotificationData(String signedTransactionInfo) {
public void changeSubscriptionStatus(AppleNotificationPayloadVO payloadVO) {

ApplePurchaseVO purchaseData = getPurchaseData(payloadVO);
Purchase purchase =
purchaseRepository.findByTransactionId(purchaseData.transactionId())
.orElseThrow(() -> new PurchaseNotFoundException(NOT_FOUND_TRANSACTION_EXCEPTION));
User user = purchaseData.purchase().getUser();

if (payloadVO.subtype().equals(ConstantUtil.APPLE_SUBTYPE_AUTO_RENEW_DISABLED)
&& !user.getSubscribe().equals(Subscribe.NORMAL)) {
user.setSubscribe(Subscribe.CANCELED);
purchase.setPurchaseState(PurchaseState.CANCELED);
}

if (payloadVO.subtype().equals(ConstantUtil.APPLE_SUBTYPE_VOLUNTARY)) {
user.setSubscribe(Subscribe.NORMAL);
purchase.setPurchaseState(PurchaseState.PAUSED);
}
}

@Override
public void refundAppleInApp(AppleNotificationPayloadVO payloadVO) {
ApplePurchaseVO purchaseData = getPurchaseData(payloadVO);
Purchase purchase =
purchaseRepository.findByTransactionId(purchaseData.transactionId())
.orElseThrow(() -> new PurchaseNotFoundException(NOT_FOUND_TRANSACTION_EXCEPTION));
User user = purchaseData.purchase().getUser();

switch (purchaseData.purchase().getProductType()) {
case YELLO_PLUS -> {
user.setSubscribe(Subscribe.NORMAL);
purchase.setPurchaseState(PurchaseState.INACTIVE);
}
case ONE_TICKET -> {
validateTicketCount(REFUND_ONE_TICKET, user);
purchase.setPurchaseState(PurchaseState.INACTIVE);
}
case TWO_TICKET -> {
validateTicketCount(REFUND_TWO_TICKET, user);
purchase.setPurchaseState(PurchaseState.INACTIVE);
}
case FIVE_TICKET -> {
validateTicketCount(REFUND_FIVE_TICKET, user);
purchase.setPurchaseState(PurchaseState.INACTIVE);
}
}
}
Expand Down Expand Up @@ -171,6 +184,9 @@ public void reSubscribeApple(AppleNotificationPayloadVO payloadVO) {
createSubscribe(purchase.getUser(), Gateway.APPLE, appleJwtDecode.transactionId(), null,
PurchaseState.ACTIVE, appleJwtDecode.toString());

purchase.setPurchaseState(PurchaseState.INACTIVE);
reSubscribePurchase.setPurchaseState(PurchaseState.ACTIVE);

purchaseRepository.save(reSubscribePurchase);
}

Expand Down

0 comments on commit 187a362

Please sign in to comment.