13

I spent a week looking for solution to upgrade/downgrade subscriptions on Android InAppBilling.

There's a reference page about this function: http://developer.android.com/google/play/billing/billing_reference.html

Google said that we could use getBuyIntentToReplaceSkus() method, but I couldn't found any documentation about that in its signature. I can't also see it in IInAppBillingService.aidl file that Google provided.

Is there any one who may help me?

Anirudh Sharma
  • 7,968
  • 13
  • 40
  • 42
Tuan Nguyen
  • 131
  • 2
  • 6

5 Answers5

4

Just use my aidl file and be happy :)

It works perfectly!

https://gist.github.com/cre8ivejp/21b10fbbc7e500f99059

*Do not change the order of the methods inside aidl file or it will not work.

gaijinboy
  • 67
  • 3
  • 6
  • @Solidus0815 as described in the documentation, the error happens because the getBuyIntentToReplaceSkus was implemented on api version 5 and not 3. You just need to change the first parameter from **3** to **5** here `mService.getBuyIntentToReplaceSkus(5, "package", subs, key, "subs", getResources().getString(R.string.developer_payload));` – gaijinboy Aug 21 '15 at 06:32
  • @Solidus0815 I'm glad you made it :) – gaijinboy Aug 21 '15 at 12:26
  • I used same code as `getBuyIntent` from IabHelper like this: `Bundle buyIntentBundle = mService.getBuyIntentToReplaceSkus(5, mContext.getPackageName(), oldSkus, newSku, itemType, extraData);` However `PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);` pendingIntent is null. – Shark Aug 31 '15 at 10:12
  • @Shark are you using the aidl file that i post on gist?? If so, did you change something inside? – gaijinboy Sep 03 '15 at 10:47
  • actually no. I mean yes... I was commenting for a coleague here, and he just told me "yes I did change it, and that's why it didn't work. Once I copy/pasted his, everything worked alright". So, it's all working fine now (y) :) – Shark Sep 03 '15 at 12:41
1

at first thanks for aidl file.

But for me it is not working. I always get an error code 5:

Invalid arguments provided to the API. This error can also indicate that the application was not correctly signed or properly set up for In-app Billing in Google Play, or does not have the necessary permissions in its manifest

I don't think that the permissions are wrong or it is not correctly signed as all other payment requests work.

This is my code:

List<String> subs = new ArrayList<>();
subs.add(current_sub);
buyIntentBundle = mService.getBuyIntentToReplaceSkus(3, "package", subs,
       key, "subs", getResources().getString(R.string.developer_payload));

How do you execute an upgrade request or do you see any error in my request?

Thanks Solidus

Solidus0815
  • 129
  • 1
  • 1
  • 6
  • @gaijinboy thanks man, that was pretty stupid of me :D:D:D finally everything is working as expected – Solidus0815 Aug 21 '15 at 10:36
  • In case someone is looking for what @gaijinboy said, follow this https://stackoverflow.com/questions/29915035/how-to-upgrade-downgrade-subscriptions-in-android-inappbilling#comment52158082_31880778 – Heisenberg Jan 27 '17 at 07:11
1

You just have to update the 'aidl' file from the official gitHub, and clean-build the project:

https://github.com/googlesamples/android-play-billing/blob/master/TrivialDrive/app/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl

You'll be happy forever after.

nbtk
  • 3,039
  • 4
  • 21
  • 19
0

This seems to be a mistake/bug from google. They have not updated aidl file correctly. You can probably add this method to aidl file yourself (and figure out correct signature by try&error) but if you can you should wait a little while they get their act together.

Okas
  • 2,664
  • 1
  • 19
  • 26
0

I had the similar issue and found out that

  1. it is only supported in version 5
  2. the position of new sku (the array list) and old sku should be changed. Even though the methods shows first old and then new.. make the other way.