3

有人可以指导我如何使用沙盒 URL 测试 iOS(自动更新 IAP)收据验证 API 吗?

我在下面的代码片段中试过这个。

public void validateReceiptData(VerifyReceiptRequestView requestview) {
        System.out.println("validateReceiptData ....................");
        String VERIFICATION_URL=" https://sandbox.itunes.apple.com/verifyReceipt";
        HttpClient httpClient = new DefaultHttpClient();
        try {
            HttpPost request = new HttpPost(VERIFICATION_URL);
            JSONObject requestData = new JSONObject();
            requestData.put("receipt-data", requestview.getReceiptdata());
            requestData.put("password", requestview.getPassword());
            StringEntity requestEntity = new StringEntity(requestData.toString());
            request.addHeader("content-type", "application/x-www-form-urlencoded");
            request.setEntity(requestEntity);
            HttpResponse response =httpClient.execute(request);
            String responseBody = EntityUtils.toString(response.getEntity());
            JSONObject responseJSON = new JSONObject(responseBody);
            System.out.println("responseJSON -------------->"+responseJSON);
        }catch(Exception e) {
            e.printStackTrace();
        }

    }

但我需要以下提到的字段的示例请求数据

requestData.put("receipt-data", requestview.getReceiptdata());
requestData.put("password", requestview.getPassword());

该字段是否requestview.getReceiptdata()需要任何 Valid Purchased 收据,或者 Apple 是否提供任何示例收据数据以在 SandBox 环境中测试此 API。

4

0 回答 0