Note that there are some explanatory texts on larger screens.

plurals
  1. POprocess in-app apple receipt with java
    primarykey
    data
    text
    <p>I am using a java backend. After a user performs an in-app purchase, the front-end sends me the receipt. In turn, I am to send the receipt to apple for confirmation; then apple is to decode the receipt and send me back a JSON dictionary. My question is about sending the receipt back to apple so that I may get the json response. I am using the code below. But I keep getting {"status":21002} from apple and something about "Invalid cookie header". Any ideas how to solve this?</p> <pre><code> String url = "https://buy.itunes.apple.com/verifyReceipt"; DefaultHttpClient client = null; try { String input = IOUtils.toString(is); log.info("THE INPUTSTREAM: " + input); JSONObject receipt = new JSONObject(); receipt.put("receipt-data", input); client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); StringEntity entity = new StringEntity(receipt.toString()); entity.setContentType("application/json"); post.setEntity(entity); HttpClientParams.setRedirecting(post.getParams(), false); HttpResponse response = client.execute(post); if (300 &lt;= response.getStatusLine().getStatusCode()) { throw new RuntimeException("No response from iTune store. status code: " + response.getStatusLine().getStatusCode()); } if (null == response.getEntity()) { log.info("Response is null"); throw new Exception("Response is null"); } StringBuilder sb = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); for (String line; null != (line = reader.readLine());) { sb.append(line); } JSONObject json = new JSONObject(sb.toString()); log.info("THE JSON" + json); //Then work with json below } catch (Exception e) { throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build()); } finally { if (null != client) { client.getConnectionManager().shutdown(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload