Skip to main content
Solved

Google play subscription offer with Flutter


Forum|alt.badge.img+1
  • Active Member
  • 14 replies

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

Best answer by MarcosC

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

View original
Did this post help you find an answer to your question?

4 replies

Ryan Glanz
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 364 replies
  • May 30, 2023

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


Forum|alt.badge.img+1
  • Author
  • Active Member
  • 14 replies
  • June 25, 2023

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 ?

 


MarcosC
RevenueCat Staff
Forum|alt.badge.img+7
  • RevenueCat Staff
  • 161 replies
  • Answer
  • June 27, 2023

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


Forum|alt.badge.img+1
  • Author
  • Active Member
  • 14 replies
  • July 20, 2023

it worked thanks!!!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings