RVS Production Setup for Appstore SDK IAP
After you publish your app, you can set up your app server to communicate with the RVS production server. HAQM 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 Cloud Sandbox, you need to remove "sandbox" from the URL, changing the host from "http://appstore-sdk.haqm.com/sandbox
" to "http://appstore-sdk.haqm.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 HAQM Appstore:
http://developer.haqm.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:
- Create a URL string with the appropriate developer and transaction information.
- Connect to the HAQM RVS server and passes the transaction URL to the server.
- Retrieve the response from the HAQM RVS server.
- 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 = "http://appstore-sdk.haqm.com/version/1.0/verifyReceiptId/developer/" + developerSecret + "/user/" + userId + "/receiptId/" + receiptId;
System.out.println("HAQM Receipt Validation URL: " + url);
try {
System.out.println("Open HTTP connection to HAQM RVS");
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
int responseCode = con.getResponseCode();
System.out.println("HAQM RVS Response Code: " + responseCode);
switch (responseCode)
{
case 400:
System.out.println("HAQM RVS Error: Invalid receiptID");
// Process Response Data locally
// Respond to app
break;
case 496:
System.out.println("HAQM RVS Error: Invalid developerSecret");
// Process Response Data locally
// Respond to app
break;
case 497:
System.out.println("HAQM RVS Error: Invalid userId");
// Process Response Data locally
// Respond to app
break;
case 500:
System.out.println("HAQM RVS Error: Internal Server Error");
// Process Response Data locally
// Respond to app
break;
case 200:
//Retrieve HAQM 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 HAQM RVS Response
System.out.println("HAQM 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");
String countryCode = responseJson.getString("countryCode");
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("HAQM RVS Error: Undefined Response Code From HAQM 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("HAQM 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("HAQM RVS IOException");
e.printStackTrace();
// Process Response Data locally
// Respond to app
}
}
Last updated: Apr 07, 2025