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