Google Play订阅支付成功却未返回购买数据与签名的调试求助
Hey there, let's break down why you're seeing "Payment successful" but not getting the purchase data and signature in your app. Based on the code snippets you shared, here are the key areas to check and fix:
1. Critical: Wrong Item Type for Subscriptions
Looking at your custom launchPurchaseFlow method, you're using ITEM_TYPE_INAPP when calling getBuyIntent:
Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, ITEM_TYPE_INAPP, extraData);
But your SKU zoomlee_family_y looks like a yearly subscription (the _y suffix). Subscriptions require ITEM_TYPE_SUBS instead of ITEM_TYPE_INAPP. Using the wrong type can cause the purchase flow to complete but fail to return valid purchase data/signature.
Fix this line to:
Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, ITEM_TYPE_SUBS, extraData);
2. Ensure onActivityResult Forwards to IabHelper
The IabHelper relies on onActivityResult to receive the purchase result from Google Play. If you haven't implemented this, the callback won't fire properly. Add this to your Activity:
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Let IabHelper handle the result first if (!billingHelper.handleActivityResult(requestCode, resultCode, data)) { // If not handled, pass to super class super.onActivityResult(requestCode, resultCode, data); } }
3. Verify Your OnIabPurchaseFinishedListener Implementation
You're passing this as the listener to launchPurchaseFlow, so your Activity should implement OnIabPurchaseFinishedListener. Make sure your onIabPurchaseFinished method properly captures the purchase data:
@Override public void onIabPurchaseFinished(IabResult result, Purchase purchase) { if (result.isFailure()) { Log.e("IAB_DEBUG", "Purchase failed: " + result.getMessage()); return; } // Check if the purchase matches your subscription SKU if (PRO_MONTH_SKU.equals(purchase.getSku())) { // Extract purchase data and signature here String purchaseJson = purchase.getOriginalJson(); String purchaseSignature = purchase.getSignature(); Log.d("IAB_DEBUG", "Purchase Data: " + purchaseJson); Log.d("IAB_DEBUG", "Purchase Signature: " + purchaseSignature); // Add your validation logic (local or server-side) here applySubscriptionState(); // Update your app's subscription state } }
4. Check RSA Key Validity
Ensure the rsa_key you're using is the public key copied directly from your Google Play Console (under Monetization > Products > Subscriptions > App signing). Double-check for extra spaces, line breaks, or missing characters—even a tiny typo can break signature verification and data retrieval.
5. Validate Beta Test Setup
- Make sure your test account is added to the Beta testers list in Google Play Console, and you've accepted the test invitation via the opt-in link.
- If you're using a closed Beta, unlisted accounts won't get proper purchase callbacks even if payment goes through.
6. Avoid Prematurely Disposing IabHelper
Your disposeBillingHelper method should only be called when your Activity is being destroyed (in onDestroy), not in onResume or other lifecycle methods that might run before the purchase callback fires. Add this to your Activity:
@Override protected void onDestroy() { super.onDestroy(); disposeBillingHelper(); EventBus.getDefault().unregister(this); // Don't forget to unregister EventBus! }
7. Dig Into Logs
Filter your Logcat for tags like IAB_DEBUG, Loadsuccess, and whichfirst to check:
- Is
onIabSetupFinishedactually firing with a success result? - Is
onIabPurchaseFinishedbeing called at all? If yes, what does theresultmessage say? - Are there any error messages from the IabHelper about failed intent retrieval or response codes?
内容的提问来源于stack exchange,提问作者Nanthu

