Search code examples
androidin-app-purchasein-app-billingandroid-pendingintentsubscription

PendingIntent returned from getBuyIntent is always null


I'm trying to offer a subscription but the PendingIntent I get from getBuyIntent is always null. Although, requesting purchases and item details works.

I already tried with different accounts, signed, debuggable and non debuggable apks but still the same.

Bundle bundle = mService.getBuyIntent(3, getActivity().getPackageName(), sku, "subs", developerPayload);

for (String key : bundle.keySet()) {
    Log.d("SUBSCRIBE: " + key + " = \"" + bundle.get(key) + "\"");
}

PendingIntent pendingIntent = bundle.getParcelable("RESPONSE_BUY_INTENT");

if (bundle.getInt("RESPONSE_CODE") == BILLING_RESPONSE_RESULT_OK) {
    if (pendingIntent != null) {
        // Start purchase flow (this brings up the Google Play UI).
        // Result will be delivered through onActivityResult().
        getActivity().startIntentSenderForResult(pendingIntent.getIntentSender(), RC_BUY, new Intent(),
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
    } else {
        Log.e("Subscribe", "PendingIntent is null!");
    }
}

And this is the logcat output

: SUBSCRIBE: RESPONSE_CODE = "0"
: SUBSCRIBE: BUY_INTENT = "PendingIntent{b1c5591: android.os.BinderProxy@c48ccf6}"
: Subscribe: PendingIntent is null!

This (http://developer.android.com/google/play/billing/billing_integrate.html#Subs) is the implementation I followed with the small difference, that my code is placed in a fragment instead of an Activity


Solution

  • The zero reponse code indicates it is working, but your bundle key is wrong, I think, try

    bundle.getParcelable("BUY_INTENT");