Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify Base Plan ID when making Subscription Purchase - Android Billing #651

Open
DanCodes1414 opened this issue Nov 21, 2024 · 7 comments · May be fixed by #657
Open

Specify Base Plan ID when making Subscription Purchase - Android Billing #651

DanCodes1414 opened this issue Nov 21, 2024 · 7 comments · May be fixed by #657

Comments

@DanCodes1414
Copy link

When making a purchase, there is only the option to provide the Subscription ID, and not the Base Plan ID.
var purchase = await CrossInAppBilling.Current.PurchaseAsync(request.PlanId, ItemType.Subscription);
Screenshot 2024-11-21 at 11 27 33 AM

@rezamohamed
Copy link

I had the same question myself, maybe @jamesmontemagno can shed some light.

The way I understand how this API works is actually by the Product ID. I don't think it looks at the base_plan_id. So in a sense, I have simply created multiple subscriptions with Product ID's associated to the In App Subscription.

IOS works by creating a Subscription Group, which I think would be the equivalent of the Product ID here. But the behavior in Android seems to be slightly different.

@DanCodes1414
Copy link
Author

I have simply created multiple subscriptions with Product ID's associated to the In App Subscription.

This is the approach I have taken so far as well, but it means I have to manually handle proration between monthly, quarterly and yearly plans.

It seems like I can set the subOfferToken to the Base Plan ID and this will work, as a default (hidden) offer token is created for each base plan. I haven't had a chance to test it yet, but will update as soon as I can.

@DanCodes1414
Copy link
Author

I tried setting the subOfferToken to my subscription's Base Plan ID, but it didn't work.
Seems like I will just have to continue with creating multiple subscriptions for now.

@jamesmontemagno
Copy link
Owner

the offer token is if you have an offer available for a subscription.... for example 5 day free trial.

I am pretty sure you query your subscription as normal with an id and purchase that id.... i don't use base plans yet and their documentation is confusing. https://developer.android.com/google/play/billing/integrate#launch

i am pretty sure when you query your base plan it will return back to you a list of all of offers under it.

Having a hard time finding a kotlin flow from querying to purchasing

@DanCodes1414
Copy link
Author

@jamesmontemagno Thank you for the reply!

I also tried finding anything in the android BillingClient docs on specifying the Base Plan ID, but couldn't find anything.

@fooberichu150
Copy link

@DanCodes1414 - how do you handle upgrades/downgrades with each plan as a completely distinct plan? I've got everything working smoothly with iOS, but when I test trying to upgrade/downgrade Android plans, it doesn't seem to cancel the previous plan. Could be I'm doing something wrong for sure. I just started down the path of trying the base plans, and came across this thread and learned that isn't going to work either.

@fooberichu150
Copy link

@jamesmontemagno @DanCodes1414

I FIGURED IT OUT! Ok, like seriously... damn documentation does nothing for you. But I'm a stubborn SOB and I plinked around until I figured something out. It is a HUGE pita, seriously. But here goes:

If you use the GetProductInfoAsync endpoint you get a bunch of interesting information back about your subscription plans. If you drill into them, you eventually get to the AndroidExtras for each entry that comes back. Drill into that and you'll have the SubscriptionOfferDetails array that has n entries for each base plan on your subscription level. Now here's where it gets interesting. If you don't specifically have an offer, you still have an entry for the base plan and it has an OfferToken. This is the property you need to pass along as the subOfferToken when making the purchase. Passing it for Android will now correctly show you which base plan you selected.

The upgrade method doesn't currently show it (have no idea if it supports it?), so you can't upgrade that way in the current code form. @jamesmontemagno - does it allow it under the hood but not currently exposed?

@fooberichu150 fooberichu150 linked a pull request Dec 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants