Subscriptions return the 'INAPP_PURCHASE_DATA' null using 'In-app Billing V3'

2

I'm implementing purchase of Signatures in an Android application.

So far, payment orders are already set up in the Developer Google Play Console and I can debit the amount set in each of the SKUs on the credit card.

At the end of this, I want to get the JSON data that should be "INAPP_PURCHASE_DATA" within onActivityResult of the application.

However, when calling in bundle , it does not return anything.

All places in the code where they should return the purchase data always return a Null value.

But even so the purchase is debited from my card. Which brings me to the process of running to the ' Google Wallet ' console and canceling the billing.

Here's what I'm doing right now:

  

Set the service before OnCreate.

ServiceConnection mServiceConn = new ServiceConnection() {

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

In 'OnCreate' I define the SKU that comes from another Activity,   IABHelper service and configuration.

@Override
    public void onCreate(Bundle savedInstanceState) {
        .
        .
        .
        skuSubs = getIntent().getExtras().getString("SKU_TYPE");

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

        mHelper = new IabHelper(this, base64EncodedPublicKey);
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
              public void onIabSetupFinished(IabResult result) {
                if (!result.isSuccess()) {
                    Log.d(TAG, "In-app Billing setup failed: " result);
                }else{             
                    Log.d(TAG, "In-app Billing is set up OK");
                }
              }
            });
    }
  

Here I define the method that will be used in onClick of my Activity   to open the Signature Dialog window. (developerPayload is   generated elsewhere in the code)

public void buyClick(View view) {
        mHelper.launchPurchaseFlow(this, skuSubs, 10001, mPurchaseFinishedListener, developerPayload);
    }
  

In the 'onActivityResult' method I capture the   'INAPP_PURCHASE_DATA' through the 'Bundle'.

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {     
            super.onActivityResult(requestCode, resultCode, data);
          }
          if(data.getExtras()!=null){
              Bundle bundle = data.getExtras();
              editText.setText(bundle.getString("INAPP_PURCHASE_DATA"));
          }else{
              editText.setText("null");
          }
    }
  

Here 'mPurchaseFinishedListener' treats the purchase data. In tests   I have tried to capture the data by the 'Purchase' class, but without   success.

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
    public void onIabPurchaseFinished(IabResult result, Purchase purchase) {

        if (result.isFailure()) {
            return;
        }else 
            if (purchase.getSku().equals(skuSubs)) {
                mHelper.queryInventoryAsync(mReceivedInventoryListener);
            }
        }
    };

IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
       public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
           StringBuffer sb = new StringBuffer();
           if (result.isFailure()) {
                // Handle failure
                return;
            } else {
              mHelper.consumeAsync(inventory.getPurchase(skuSubs), mConsumeFinishedListener);
          }
       }
};

IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
            public void onConsumeFinished(Purchase purchase, IabResult result) {
                if (result.isSuccess()) {
                    //ok msg
                 } else {
                     //fail msg
                 }
            }
        };
  

On 'onDestroy' I end with the 'Service' and the 'IABHelper'.

@Override
public void onDestroy() {
    super.onDestroy();
    if (mService != null) unbindService(mServiceConn);
    if (mHelper != null) {
        mHelper.dispose();
        mHelper = null;
    }       
}
  

In my 'AndroidManifest.xml' are defined:

   <uses-permission android:name="com.android.vending.BILLING" />
   ...
    <service android:name="com.android.vending.billing.IInAppBillingService" />

When I set this up, depending on the SKU that is sent in the previous Activity, I get the purchase data correctly.

When I make the purchase, it is determined to be complete and then I do not receive the purchase result.

I open the Developer Console and right after entering the Wallet to cancel the Subscription that was debited.

How do I make this request within the application? I can not get the return on my purchase by now.

    
asked by anonymous 17.02.2014 / 16:12

0 answers