Failed to call API with error="Transaction id not found."

when i use app-store-server-library-java in sandbox

AppStoreServerAPIClient client = new AppStoreServerAPIClient(encodedKey, keyId, issuerId, bundleId, environment);

        TransactionInfoResponse transactionInfo = client.getTransactionInfo("***");
        String signedTransactionInfo = transactionInfo.getSignedTransactionInfo();

then i got Failed to call API with error="Transaction id not found."

howerver when i use https://sandbox.itunes.apple.com/verifyReceipt then i got success

Answered by song2024 in 776445022

all get Failed to call API with error="Transaction id not found."

For AppStoreServerAPIClient, was the environment Sandbox? Additionally, what was the transactionId you used

    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);
    }
Accepted Answer

all get Failed to call API with error="Transaction id not found."

Failed to call API with error="Transaction id not found."
 
 
Q