Reputation: 2031
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();
}
Upvotes: 0
Views: 4498
Reputation: 5671
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.
Upvotes: 4