String issuerId = "***";
String keyId = "***";
String bundleId = "***";
Path filePath = Path.of("/***/***.p8");
String encodedKey = Files.readString(filePath);
Environment environment = Environment.SANDBOX;
AppStoreServerAPIClient client = new AppStoreServerAPIClient(encodedKey, keyId, issuerId, bundleId, environment);
try {
ReceiptUtility receiptUtility = new ReceiptUtility();
//1.use serverVerificationData
String serverVerificationData = "***";
String str = receiptUtility.extractTransactionIdFromAppReceipt(serverVerificationData);
TransactionInfoResponse transactionInfo = client.getTransactionInfo(str);
//2. use purchaseID or transactionIdentifier
TransactionInfoResponse transactionInfo1 = client.getTransactionInfo("purchaseID");
// service
String signedTransactionInfo = transactionInfo.getSignedTransactionInfo();
JWSTransactionDecodedPayload jwsTransactionDecodedPayload = new JWSTransactionDecodedPayload();
Set<InputStream> rootCAs = Set.of(
new FileInputStream("/***/AppleComputerRootCertificate.cer"),
new FileInputStream("/***/AppleIncRootCertificate.cer"),
new FileInputStream("/***/AppleRootCA-G2.cer"),
new FileInputStream("/***/AppleRootCA-G3.cer")
);
SignedDataVerifier signedPayloadVerifier = new SignedDataVerifier(rootCAs, bundleId, "appID", environment, true);
JWSTransactionDecodedPayload jwsTransactionDecodedPayload = signedPayloadVerifier.verifyAndDecodeTransaction(signedTransactionInfo);
log.info("-----------------------------------------");
} catch (Exception e) {
log.error("Exception:", e);
}