Skip to main content

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!);

it worked thanks!!!


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


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 ?

 


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).


Reply