I'm testing aut-renewable subscription but apple's sandbox server always returns status=21004, which means 'The shared secret you provided does not match the shared secret on file for your account.'. I test with a java server, which does mostly this:
String receiptData = "theReceiptDataBytesBase64encoded";
String sharedSecret = "theSharedSecretAsPureStringProvidedByItunesconnect";
String jsonData = "{" +
"\"receipt-data\" : \"" + receiptData + "\"," +
"\"passsword\" : \"" + sharedSecret + "\"" +
"}";
URL url = new URL("https://sandbox.itunes.apple.com/verifyReceipt");
HttpURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(jsonData);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while((line = rd.readLine()) != null)
{
System.out.println(line);
}
wr.close();
rd.close();
As I tried to clear up by variable values in code sample above, I didn't encode the shared secret, using it as a plain string. Is this the problem?
Those are days that make you feel so great to be a developer ...
Looking carefully at my question above you'll see that I used the JSON key passsword with 3 friggin' s characters !!! That was the reason for a 5 hour try-and-error experience with several test products and test users and new shared secrets in the app store sandbox.
Special thanks to the iTunes team for giving the 'wrong shared secret'-message instead of the 'what the heck is the passsword key'-message.
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