/flutter-in-app-purchase

A Flutter app to show how to implement in-app purchase using the in-app-purchase package

Primary LanguageC++MIT LicenseMIT

Flutter in-app purchase

A Flutter project to show to implement in-app purchase using the in_app_purchase package

Simple UI but it's okay 🥲😉

WhatsApp.Video.2022-07-24.at.11.04.51.PM.mp4

Getting Started

To getting start with this project please make sure to take those steps done:

  • Flutter 3.0.0 or higher installed

  • Have your app bundle sent to stores for production to activate in-app purchase, see here steps to release flutter apps

  • Create product and subscription on stores. we'll use product with ID in.app.purchase.testeproduct and subscription in.app.purchase.testesubscription. See here how to do it for Android and IOS

We'll use in_app_purchase package. This plugin supports in-app purchases (IAP) through an underlying store, which can be the App Store (on iOS) or Google Play (on Android)

This project has examples of code for the following tasks:

  • Listening to purchase updates

  • Connecting to the underlying store

  • Loading products for sale

  • Restoring previous purchases

  • Making a purchase

  • Upgrading or downgrading an existing in-app subscription

  • Accessing platform specific product or purchase properties (for purchase validation purposes)

NOTE: Please remember to always verify purchase on backend side before delivery it to user. Did add code section where you can see how to extract those data to send to your own backend

NOTE: This project was written using riverpod as state management but you can apply the same logic for others of your preference, feel free to change 😏

Packages

in_app_purchase ^3.0.6

hooks_riverpod ^1.0.4

flutter_hooks ^0.18.5+1

Contribuition

If you notice an expected behavior or would like to have any feature related in-app purchase implemented, then feel free to report or contribute with your pull request

Linkedin LinkedIn