Able to show the promotional offer thanks to support here, but after going through the payment process, inputting my password, and confirming the purchase, I get an error popup that says "Unable to Purchase. Contact the developer for more information."
In the logs, I get the following errors:
Here are the example parameter values I am passing to the combined string appBundleId + '\u2063' + keyIdentifier + '\u2063' + productIdentifier + '\u2063' + offerIdentifier + '\u2063' + appAccountToken + '\u2063' + nonce + '\u2063' + timestamp
How I'm generating the signature (Java)
/* promotionalOfferKey = value between "-----BEGIN PRIVATE KEY-----" and "-----END PRIVATE KEY-----" from the downloaded p8 file from App Store Connect associated with the keyIdentifier parameter above */
// stringToSign = the combined string above
byte[] encoded = Base64.getDecoder().decode(promotionalOfferKey);
KeyFactory keyFactory = KeyFactory.getInstance("EC");
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
Signature ecdsaSign = Signature.getInstance("SHA256withECDSA");
ecdsaSign.initSign(keyFactory.generatePrivate(keySpec));
ecdsaSign.update(stringToSign.getBytes(StandardCharsets.UTF_8));
byte[] signature = ecdsaSign.sign();
signatureToReturn = Base64.getEncoder().encodeToString(signature);
What am I doing wrong? Thank you in advance.
We had the same issue in one of our projects. The problem was that our backend used a production key to sign the payload. But for StoreKit testing, you have to use the test key.
To retrieve that key:
.storekit file in XcodeEditor > Subscription Offers KeyUse that key to sign your offers for the sandbox environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With