I am verifying the receipt server side and today I noticed that the latest_receipt_info field in the verify response is null, which means I can't verify the receipt and process the transaction. This happened in the TestFlight environment, I am afraid that it could happen on PROD.
Do you know why this might have happened and how do you verify your receipts?
I am using Java and this is my code for verification:
IosVerifyReceiptResponseDTO response = restTemplate
.postForObject(iosLiveVerifyUrl, request, IosVerifyReceiptResponseDTO.class);
if (response != null) {
if ("21007".equals(response.getStatus())) {
log.info("Sandbox is on");
response = restTemplate
.postForObject(iosSandboxVerifyUrl, request, IosVerifyReceiptResponseDTO.class);
}
}
if (response != null && response.getLatest_receipt_info() != null) {
log.info("Processing subscription");
LatestReceiptInfoDTO latestReceiptInfoDTO = response.getLatest_receipt_info().get(0);
long expireDateMs = Long.parseLong(latestReceiptInfoDTO.getExpires_date_ms());
if (System.currentTimeMillis() < expireDateMs) {
user.setSubscribedProductId(latestReceiptInfoDTO.getProduct_id());
user.setPurchaseDateMs(Long.parseLong(latestReceiptInfoDTO.getPurchase_date_ms()));
user.setExpiresDateMs(Long.parseLong(latestReceiptInfoDTO.getExpires_date_ms()));
user.setAppleOrderId(latestReceiptInfoDTO.getTransaction_id());
userRepository.save(user);
log.info("Subscription processed for user: " + user.getEmail());
return new UserDTO(user);
} else {
log.info("Subscription is already expired, DB was not updated");
return new UserDTO(user);
}
} else {
log.info("Apple API response is null");
return new UserDTO(user);
}