2014-08-13 13 views
5

Attualmente sto lavorando nell'acquisto di app nella mia applicazione, quando si avvia Ho sempre il codice di errore -1003 che interroga gli elementi di proprietà verifica della firma non riuscita quando arrivo nel metodo IabHelper.QueryInventoryFinishedListener.Implementazione della fatturazione in-app

Io attualmente utilizza la versione esempio di Google "Trivial Drive", immagino che la mia firma è corretto perché riesco a comprare molto quando utilizzo android.app.purchassed ...

La chiave sembra corretto per me perché quando clicco mi piace comprare un prodotto che mi dice che l'editore non può comprare il prodotto che è normale di per sé (se metto qualcosa ho un altro errore che dice che il prodotto non esiste). Per contro, ho lo stesso errore quando inserisco il prodotto di prova "android.test.purchasse", quindi dovrei essere in grado di testarlo.

Ho effettuato un acquisto con android.test.purchasse lì e non riesco a resettare se ci sei già riuscito sono interessato.

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    // load game data 
    loadData(); 

    String base64EncodedPublicKey = "MY_KEY_BASE64"; 

    PublicKey key = Security.generatePublicKey(base64EncodedPublicKey); 
    // Create the helper, passing it our context and the public key to verify signatures with 
    Log.d(TAG, "Creating IAB helper."); 
    mHelper = new IabHelper(this, base64EncodedPublicKey); 

    // enable debug logging (for a production application, you should set this to false). 
    mHelper.enableDebugLogging(true); 

    // Start setup. This is asynchronous and the specified listener 
    // will be called once setup completes. 
    Log.d(TAG, "Starting setup."); 
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { 
     public void onIabSetupFinished(IabResult result) { 
      Log.d(TAG, "Setup finished."); 

      if (!result.isSuccess()) { 
       // Oh noes, there was a problem. 
       complain("Problem setting up in-app billing: " + result); 
       return; 
      } 

      // Have we been disposed of in the meantime? If so, quit. 
      if (mHelper == null) return; 

      // IAB is fully set up. Now, let's get an inventory of stuff we own. 
      Log.d(TAG, "Setup successful. Querying inventory."); 
      mHelper.queryInventoryAsync(mGotInventoryListener); 
     } 
    }); 
} 


// Listener that's called when we finish querying the items and subscriptions we own 
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { 
    public void onQueryInventoryFinished(IabResult result, Inventory inventory) { 
     Log.d(TAG, "Query inventory finished."); 

     // Have we been disposed of in the meantime? If so, quit. 
     if (mHelper == null) return; 

     // Is it a failure? 
     if (result.isFailure()) { 
      complain("Failed to query inventory: " + result); 
      return; 
     } 

     Log.d(TAG, "Query inventory was successful."); 

     /* 
     * Check for items we own. Notice that for each purchase, we check 
     * the developer payload to see if it's correct! See 
     * verifyDeveloperPayload(). 
     */ 
     if(inventory.hasPurchase(SKU_GAS)) 
     { 
      Toast.makeText(getApplicationContext(),"PREMIUM",Toast.LENGTH_SHORT).show(); 
     }else{ 
      Toast.makeText(getApplicationContext(),"NOT PREMIUM", Toast.LENGTH_SHORT).show(); 
     } 


     // Do we have the premium upgrade? 
     Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM); 
     mIsPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase)); 
     Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM")); 

     // Do we have the infinite gas plan? 
     Purchase infiniteGasPurchase = inventory.getPurchase(SKU_INFINITE_GAS); 
     mSubscribedToInfiniteGas = (infiniteGasPurchase != null && verifyDeveloperPayload(infiniteGasPurchase)); 
     Log.d(TAG, "User " + (mSubscribedToInfiniteGas ? "HAS" : "DOES NOT HAVE") 
        + " infinite gas subscription."); 
     if (mSubscribedToInfiniteGas) mTank = TANK_MAX; 

     // Check for gas delivery -- if we own gas, we should fill up the tank immediately 
     Purchase gasPurchase = inventory.getPurchase(SKU_GAS); 
     if (gasPurchase != null && verifyDeveloperPayload(gasPurchase)) { 
      Log.d(TAG, "We have gas. Consuming it."); 
      mHelper.consumeAsync(inventory.getPurchase(SKU_GAS), mConsumeFinishedListener); 
      return; 
     } 

     updateUi(); 
     setWaitScreen(false); 
     Log.d(TAG, "Initial inventory query finished; enabling main UI."); 
    } 
}; 

Sei mai stato preoccupato? Non vedo alcuna via d'uscita per questo aiuto di bug da te apprezzato.

ringraziamento

risposta

2

È necessario creare un account di prova, e metterlo nella pagina playstore di amministrazione.

Problemi correlati