Solved

Google play subscription offer with Flutter


Userlevel 1
Badge +1

I created a subscription offer that the developer decides when to apply it. In the docs on how to use it there is this Kotlin example PurchaseWith(offer) and then you can do it like that. I am looking in the Flutter SDK and I can’t find a way to do it. purchaseDiscountedPackage() and other functions say “iOS only”. 

I want to apply a discount named x to this line:

Purchases.purchasePackage(offerings!.current!.monthly!);

icon

Best answer by MarcosC 27 June 2023, 09:35

View original

4 replies

Userlevel 1
Badge +1

it worked thanks!!!

Userlevel 1
Badge +1

HI @Ryan Glanz I appreciate the answer. There is very little documentation for this function and too many arguments. I tried to use it like this: 

 

SubscriptionOption subscriptionOption = new SubscriptionOption(

            'monthly:2p2',

            'notes_29_monthly:monthly-29',

            'notes_29_monthly',

            [],

            ['twoplus'],

            false,

            null,

            null,

            null,

            null,

            null);

 

and I get the following error: ErrorCode: DEVELOPER_ERROR., message='One or more of the arguments provided are invalid.'

 

I would appreciate some help. I don't have phases it's a straightforward discount. Could you provide with an example ?

 

Userlevel 4
Badge +8

Hi aris,

In our (beta) version of the SDK with Billing Client 5, we do have a google specific method called purchaseSubscriptionOption. You can pass the specific option (offer) that you want to buy.

Use purchaseStoreProduct and pass the corresponding store product and it will use the defaultOption (offer).

Userlevel 3
Badge +6

Hi @aris 

My suggestion is not to build the subscription option on your own (and I’m not sure you can). The idea is that you can use one of the subscriptionOptions that are part of a given store product.

 

Let’s assume you are using getOfferings to load all store products (you could use getProducts too), then you can use storeProduct.subscriptionOptions to decide which one to purchase (https://sdk.revenuecat.com/android/6.5.2/public/com.revenuecat.purchases.models/-store-product/index.html#197138075%2FProperties%2F298774922)

 

Check this last section of this doc to see if it helps - https://www.revenuecat.com/docs/android-native-5x-to-6x-migration#migration-implementation-steps

 

Edit: I’m showing native examples, but the same applies to flutter

Reply