Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

android - In app billing v3 - BILLING_RESPONSE_RESULT_DEVELOPER_ERROR

I try to put in my app In app billing v3.

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

I uploaded my app to develepors console 3 days and set in app product.

i put my Base64-encoded RSA public key and my in app product id.

When i start the purchase i get error message. When i check my RESPONSE_CODE its 5 and by google

In-app Billing Reference (http://developer.android.com/google/play/billing/billing_reference.html#billing-codes)

Its seems that i have problem with my app set up.

When i try google test id like android.test.purchased i get good results.

this is my code, maybe im doing something wrong here:

some_id is my test in app product id.


protected void onCreate(Bundle savedInstanceState) {

..
..
..
Helper = new IabHelper(this, base64EncodedPublicKey);

         mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
               public void onIabSetupFinished(IabResult result) {
                  if (!result.isSuccess()) {                  
                     Toast.makeText(getApplicationContext(), "connection bad",Toast.LENGTH_SHORT).show();           
                  }
                     Toast.makeText(getApplicationContext(), "connection good",Toast.LENGTH_SHORT).show();
               }
            });

          mServiceConn = new ServiceConnection() {


           @Override
           public void onServiceDisconnected(ComponentName name) {
               mService = null;
           }

           @Override
           public void onServiceConnected(ComponentName name, 
              IBinder service) {
               mService = IInAppBillingService.Stub.asInterface(service);
           }
          };

          bindService(new 
                    Intent("com.android.vending.billing.InAppBillingService.BIND"),
                            mServiceConn, Context.BIND_AUTO_CREATE);

...
...
..

my buying code:

IabHelper.QueryInventoryFinishedListener 
       mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
       public void onQueryInventoryFinished(IabResult result, Inventory inventory)   
       {
          if (result.isFailure()) {
             // handle error
             return;
           }

           String applePrice =
              inventory.getSkuDetails("some_id").getPrice();


           // update the UI 
       }
    };

    ArrayList<String> skuList = new ArrayList<String>();
    skuList.add("some_id");
    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList("ITEM_ID_LIST", skuList);

    Bundle skuDetails = new Bundle();
    try {
        skuDetails = mService.getSkuDetails(3, getPackageName(), "inapp", querySkus);
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    String sku = "some_id";
    Bundle buyIntentBundle = new Bundle();

    try {
        buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp", "j");
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


    PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");

    try {
        startIntentSenderForResult(pendingIntent.getIntentSender(),1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
    } catch (SendIntentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can't use developer account to test In App Billing. That's because you can't by anything from yourself. You must create another account and give it tester privileges in developer console (but only if you haven't published application yet - anyone accept of app developer can make in app purchases). Also note that purchases must be activated in developer console.

Check out Setting Up for Test Purchases section (can't make this link refer to the section itself, so scroll to it manually).

P.S. Also note that tester account must be main account in the system - the one you set first after hard reset for example. Cause even if you are logging into play with another account purchases can be done only for the main account. But you can test this, maybe something changed for a past few months.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...