InAppPurchase2: How to sell testperiod product (Offer / Discount)

I`m using In App Purchase in my Ionic App installed like described in

With this npm package

This works fine when purchasing products.

Now I want to add a test period for my product. User should be able to test for 7 days. So I created a offer in Play Console:

How to tell InAppPurchase2 to use the offer? store.order() only takes product_id and an additionalData object. How to pass the offer id? Is it possible in additional params?

No idea? I`m really suprised. How to you sell products in Capacitor? You don`t need offers and trial periods?

Maybe ask the maintainer in the plugin’s repo?

Ok, found the solution: "cordova-plugin-purchase": "^13.0.0" is needed. And "@awesome-cordova-plugins/in-app-purchase-2" which is kind of an interface for "cordova-plugin-purchase": "^11.0.0" is outdated.

When using version 13 of "cordova-plugin-purchase" with plain javascript (no other library), you get the offers in the product object and can order it with something like store.order(product.offers[0]).

What it the official best practise way of purchases in a Capacitor app? Why do I still have to use a cordova plugin?

CapGo has a Capacitor plugin - GitHub - Cap-go/capacitor-purchases: Capacitor in-app purchases and subscriptions made easy.

EDIT: Oh, just realized the CapGo plugin is using RevenueCat. I switched to RevenueCat after trying the plugin you are trying. RevenueCat provides a Cordova plugin which is working fine for me in Capacitor 4.

Also see How use in app puchase with ionic 6 & capacitor 4?

@twestrick Thank you. This Cap-go/Revenuecat way seems to be the best way for today. I would use it if I would start from the beginning. But it has drawbacks, too. Its another service in the chain of an app.

Yeah, I had everything developed with the plugin you are using but ended up ripping it all out and switching to RevenueCat. Sure it is another service, but from my standpoint, I’d rather focus on the core features of my app and not have to worry about maintaining all the intricacies of subscriptions.

To fix the current plugin you are using, someone probably needs to submit a PR to the @awesome-cordova-plugins/in-app-purchase-2 repo to support v13. There actually is already an open issue - in-app-purchase-2 isn't compatible with latest version of cordova-plugin-purchase. Docs should be updated at minimum. · Issue #4457 · danielsogl/awesome-cordova-plugins · GitHub