Google Play应用内结算v3,签名为空白

时间:2013-11-04 12:36:07

标签: android in-app-purchase google-play in-app-billing signature

我的应用使用应用内结算v3(UNMANAGED PRODUCT)并使用已签名的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为空。谁有人可以帮忙?在什么情况下会导致这个问题?

1 个答案:

答案 0 :(得分: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);

<强> onActivityResult:

@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();
            }

        }

    }

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

希望它能解决你的问题。