2015-08-22 89 views
0

我已經查看了關於同樣問題的其他類似問題,並指出了相同的一點。檢查產品的ID。我正在首次實施應用內購買,並且我認爲我在代碼中使用了正確的產品ID。我正在關注TrivialDrive示例。Google Play應用程序內結算V3 - 錯誤 - 需要驗證

因此,錯誤如下:

enter image description here

從谷歌我的產品ID玩:

enter image description here

我的代碼如下:

package com.xx.xxx; 

import android.content.Intent; 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.util.Log; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView; 
import android.widget.Toast; 

import com.xx.xxx.util.IabHelper; 
import com.xx.xxx.util.IabResult; 
import com.xx.xxx.util.Inventory; 
import com.xx.xxx.util.Purchase; 

public class UpgradeDonateActivity extends AppCompatActivity { 

    private String base64EncodedPublicKey = "PUBLIC_KEY_REPLACED"; 
    private static final int PURCHASE_RESPONSE = 1; 
    private static final String PURCHASE_TOKEN = "purchase_token"; 


    private static final String SKU_UPGRADE_2 = "test"; 
    //private static final String SKU_UPGRADE = "Upgrade"; 
    private static final String SKU_DONATE_10 = "donate_10"; 
    private static final String SKU_DONATE_5 = "donate_5"; 
    private static final String SKU_DONATE_3 = "donate_3"; 
    private static final String SKU_DONATE_2 = "donate_2"; 

    private boolean mIsUpgraded = false; 

    private Toolbar toolbar; 
    private TextView title; 

    private IabHelper mIabHelper; 
    private Button btnUpgrade; 


    IabHelper.QueryInventoryFinishedListener mGotInventoryListener 
      = new IabHelper.QueryInventoryFinishedListener() { 
     public void onQueryInventoryFinished(IabResult result, 
              Inventory inventory) { 

      Log.d(Const.DEBUG, "Query inventory finished"); 

      if (mIabHelper == null) return; 

      if (result.isFailure()) { 
       // Handle failure 
       Toast.makeText(UpgradeDonateActivity.this, "onQueryInventoryFinished Failed", Toast.LENGTH_LONG).show(); 
       return; 
      } 

      Log.d(Const.DEBUG, "Query inventory successful"); 

      Purchase upgradePurchase = inventory.getPurchase(SKU_UPGRADE_2); 
      mIsUpgraded = (upgradePurchase != null && verifyDeveloperPayload(upgradePurchase)); 
      Log.d(Const.DEBUG, "User is " + (mIsUpgraded ? "Upgraded" : "Not Upgraded")); 
     } 
    }; 


    boolean verifyDeveloperPayload(Purchase p) { 
     String payload = p.getDeveloperPayload(); 
     return true; 
    } 


    IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener 
      = new IabHelper.OnIabPurchaseFinishedListener() { 
     public void onIabPurchaseFinished(IabResult result, 
              Purchase purchase) { 


      Log.d(Const.DEBUG, "Purchase finished: " + result + ", purchase: " + purchase); 

      if(mIabHelper == null) return; 

      if (result.isFailure()) { 
       // Handle error 
       Log.d(Const.DEBUG, "Error Purchasing: "+result); 
       return; 
      } 

      if(!verifyDeveloperPayload(purchase)) { 
       Log.d(Const.DEBUG, "Error purchasing. Authenticity verification failed."); 
       return; 
      } 

      Log.d(Const.DEBUG, "Purchase successful."); 

      if(purchase.getSku().equals(SKU_UPGRADE_2)) { 
       Log.d(Const.DEBUG, "Purchase is upgrade. Congratulating user."); 
       mIsUpgraded = true; 
      } 

     } 
    }; 


    IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = 
      new IabHelper.OnConsumeFinishedListener() { 
       public void onConsumeFinished(Purchase purchase, 
               IabResult result) { 

        if (result.isSuccess()) { 
         //clickButton.setEnabled(true); 
         Toast.makeText(UpgradeDonateActivity.this, "", Toast.LENGTH_LONG).show(); 
        } else { 
         // handle error 
         Toast.makeText(UpgradeDonateActivity.this, "Error", Toast.LENGTH_LONG).show(); 
        } 
       } 
      }; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_upgrade_donate); 

     toolbar = (Toolbar) findViewById(R.id.toolbar); 
     title = (TextView) toolbar.findViewById(R.id.toolbar_title); 
     title.setText(""); 

     setSupportActionBar(toolbar); 
     getSupportActionBar().setHomeButtonEnabled(true); 
     getSupportActionBar().setDisplayHomeAsUpEnabled(true); 


     btnUpgrade = (Button) findViewById(R.id.button_upgrade); 
     btnUpgrade.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 

       mIabHelper = new IabHelper(UpgradeDonateActivity.this, base64EncodedPublicKey); 
       mIabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { 
        @Override 
        public void onIabSetupFinished(IabResult result) { 
         if (!result.isSuccess()) { 
          Log.d(Const.DEBUG, "In-app Billing setup Failed"); 
         } else { 
          Log.d(Const.DEBUG, "In-app Billing setup OK"); 
          Toast.makeText(UpgradeDonateActivity.this, "In-app Billing setup OK", Toast.LENGTH_SHORT).show(); 

          mIabHelper.launchPurchaseFlow(UpgradeDonateActivity.this, SKU_UPGRADE_2, PURCHASE_RESPONSE, mPurchaseFinishedListener, PURCHASE_TOKEN); 
         } 
        } 
       }); 
      } 
     }); 
    } 


    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     Log.d(Const.DEBUG, "onActivityResult(" + requestCode + "," + resultCode + "," + data); 
     if (mIabHelper == null) return; 

     // Pass on the activity result to the helper for handling 
     if (!mIabHelper.handleActivityResult(requestCode, resultCode, data)) { 
      // not handled, so handle it ourselves (here's where you'd 
      // perform any handling of activity results not related to in-app 
      // billing... 
      super.onActivityResult(requestCode, resultCode, data); 
     } else { 
      Log.d(Const.DEBUG, "onActivityResult handled by IABUtil."); 
     } 
    } 


    public void consumeItem() { 
     mIabHelper.queryInventoryAsync(mGotInventoryListener); 
    } 


    @Override 
    public void onDestroy() { 
     super.onDestroy(); 
     if (mIabHelper != null) mIabHelper.dispose(); 
     mIabHelper = null; 
    } 
} 

誰能告訴我,我是什麼在這種情況下做錯了嗎?我應該如何解決它?

+0

你使用你的谷歌帳戶登錄設備 – meghraj27

+0

是的..我檢查並重新檢查它。我登錄了,我在playstore中提到了測試人員帳戶。 –

+0

我希望測試人員帳戶與用於開發人員控制檯的帳戶不同。 – meghraj27

回答

1

請確保您有到位計費(右權限)apk文件是發佈(無論是字母),並允許一段時間谷歌播放吸收新的apk文件,可能是幾個小時。

此外,請確保您當前開發版本中的應用程序版本代碼與已發佈的啓用結算啓用版本中的應用程序版本代碼相同。

+0

我有點困惑在這裏..我怎麼能發佈apk測試Alpha。我的意思是,我在Alpha測試部分上傳了簽名的版本,現在它說,「Alpha版本的草案」。我可以選擇「升級到Beta」和「促進產品」。我應該說「促進生產」並保存它嗎? –

+0

您必須發佈該應用程序,只要它在「草稿」中,Play服務甚至不會考慮它。在開發控制檯中查找「發佈」按鈕,不用擔心,構建不會從阿爾法到神奇地被提升,發佈之後,除alpha中的人員將無法看到它。 –

+0

Okie ..感謝您的幫助!會回到你身邊。 –