Grato por sua visita. Neste momento esta página está apenas disponível em inglês.

Instructions for RVS Production Environment

After you publish your app, you can set up your app server to communicate with the RVS production server. Amazon recommends calling RVS from a secure server because it hosts the shared secret. Do not call the RVS service from your app.

If you have already set up your app server to use the RVS Sandbox, you need to change the host from "http://localhost:8080/RVSSandbox" to "https://appstore-sdk.amazon.com".

Additionally, verify that you are using your real shared secret at this point. The RVS Sandbox ignores the Shared Secret, but the RVS production server will reject requests with an invalid shared secret. The shared secret can be found on the Shared Key page for your developer account with the Amazon Appstore:

https://developer.amazon.com/sdk/shared-key.html

You can set up your app server to your own language and technology preferences. The server needs to communicate securely with RVS via a secure protocol such as HTTPS. Your server sends validation requests to RVS and processes the responses.

As a prerequisite, you will need to add a JSON parsing library to your project, such as Jackson, to parse the JSON responses.

The following sample code is for a generic Java server. This code calls verifyReceipt() to perform the following tasks:

  1. Create a URL string with the appropriate developer and transaction information.
  2. Connect to the Amazon RVS server and passes the transaction URL to the server.
  3. Retrieve the response from the Amazon RVS server.
  4. Pass the response to the app.
  public static void verifyReceipt(final String developerSecret, final String userId, final String receiptId) {
    System.out.println("Start Receipt Validation");

    String url = "https://appstore-sdk.amazon.com/version/1.0/verifyReceiptId/developer/" + developerSecret + "/user/" + userId + "/receiptId/" + receiptId;

    System.out.println("Amazon Receipt Validation URL: " + url);

    try {
        System.out.println("Open HTTP connection to Amazon RVS");

        URL obj = new URL(url);
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();

        int responseCode = con.getResponseCode();

        System.out.println("Amazon RVS Response Code: " + responseCode);

        switch (responseCode)
        {
            case 400:
                System.out.println("Amazon RVS Error: Invalid receiptID");
                // Process Response Data locally
                // Respond to app
                break;

            case 496:
                System.out.println("Amazon RVS Error: Invalid developerSecret");
                // Process Response Data locally
                // Respond to app
                break;

            case 497:
                System.out.println("Amazon RVS Error: Invalid userId");
                // Process Response Data locally
                // Respond to app
                break;

            case 500:
                System.out.println("Amazon RVS Error: Internal Server Error");
                // Process Response Data locally
                // Respond to app
                break;

            case 200:

                //Retrieve Amazon RVS Response
                BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream()));

                String inputLine;
                StringBuffer response = new StringBuffer();

                while ((inputLine = in.readLine()) != null) {
                    response.append(inputLine);
                }
                in.close();

                //Log Amazon RVS Response
                System.out.println("Amazon RVS Response: " + response.toString()());

                //Create JSONObject for RVS Response
                JSONObject responseJson = new JSONObject(response.toString());

                //Parse RVS Response
                JSONObject responseJson = new JSONObject(response.toString());
                String receiptId = responseJson.getString("receiptId");
                String productType = responseJson.getString("productType");
                String productId = responseJson.getString("productId");
                long purchaseDate = responseJson.optLong("purchaseDate");
                long cancelDate = responseJson.optLong("cancelDate");
                boolean testTransaction = responseJson.optBoolean("testTransaction");

                // Process Response Data locally
                // Respond to app

                break;

            default:
                System.out.println("Amazon RVS Error: Undefined Response Code From Amazon RVS");
                // Process Response Data locally
                // Respond to app
                break;
        }

    } catch (MalformedURLException e) {

        // As a best practice, replace the following logic with logic for logging.
        System.out.println("Amazon RVS MalformedURLException");
        e.printStackTrace();
        // Process Response Data locally
        // Respond to app
    } catch (IOException e) {

        // As a best practice, replace the following logic with logic for logging.
        System.out.println("Amazon RVS IOException");
        e.printStackTrace();
        // Process Response Data locally
        // Respond to app
    }
  }