1

我的应用程序使用应用内计费 v3(非托管产品)并使用签名的 apk 进行了全面测试,它在我的 android 手机上完美运行。我发布生产后,今天购买了一个,这是我的第一次购买,但没有收到签名!我又用我的测试账户购买,得到了签名,但是这个买家设备怎么给我提交空白签名?!诡异的!

我查看了我的 Google 电子钱包记录,它的绿色图标表示“客户的信用卡已成功扣款”!我遵循以下实现:

http://developer.android.com/google/play/billing/billing_integrate.html

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
   if (requestCode == 1001) {           
      int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
      String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
      String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");

      if (resultCode == RESULT_OK) {
         try {
            //JSONObject jo = new JSONObject(purchaseData);
            //String sku = jo.getString("productId");
            //alert("You have bought the " + sku + ". Excellent choice, adventurer!");

            /////////////////////////////////////////////////////////
            // submit 'purchaseData' and 'dataSignature' to my server 
            /////////////////////////////////////////////////////////


          }
          catch (JSONException e) {
             //alert("Failed to parse purchase data.");
             e.printStackTrace();
          }
      }
   }
}

我的服务器只接收 purchaseData 但 dataSignature 为空白。任何人都可以帮忙吗?在什么情况下会导致这个问题?

4

1 回答 1

0

确保如果您没有更改 RC_REQUEST 常量,那么它应该是 10001 而不是 1001,如果您手动更改了它,那么您必须更改这三个代码的常量。

常数:

// (arbitrary) request code for the purchase flow   
static final int RC_REQUEST = 10001;

采购申请:

mHelper.launchPurchaseFlow(this, SKU_GAS, RC_REQUEST,
                    mPurchaseFinishedListener, payload_consumeItem);

活动结果:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + ","
                + data);

        if (mHelper == null)
            return;

        if (requestCode == 10001) {

            int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
            String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
            Log.d("INAPP_PURCHASE_DATA", ">>>" + purchaseData);
            String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
            Log.d("INAPP_DATA_SIGNATURE", ">>>" + dataSignature);
            String continuationToken = data
                    .getStringExtra("INAPP_CONTINUATION_TOKEN");
            Log.d("INAPP_CONTINUATION_TOKEN", ">>>" + continuationToken);

            if (resultCode == RESULT_OK) {
                try {
                    Log.d("purchaseData", ">>>" + purchaseData);
                    JSONObject jo = new JSONObject(purchaseData);
                    String sku = jo.getString("productId");
                    alert("You have bought the " + sku
                            + ". Excellent choice, adventurer!");
                } catch (JSONException e) {
                    alert("Failed to parse purchase data.");
                    e.printStackTrace();
                }
            } else if (resultCode == RESULT_CANCELED) {

                // } else if (resultCode == RESULT_CANCELED) {

                Toast.makeText(AppMainTest.this,
                        "Sorry, you have canceled purchase Subscription.",
                        Toast.LENGTH_SHORT).show();

            } else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
                Toast.makeText(AppMainTest.this, "Item already owned",
                        Toast.LENGTH_SHORT).show();
            }

        }

    }

让我知道它是否会解决您的问题。

希望它能解决你的问题。

于 2013-11-06T07:42:39.260 回答