in_app_purchase_utils 0.0.1 copy "in_app_purchase_utils: ^0.0.1" to clipboard
in_app_purchase_utils: ^0.0.1 copied to clipboard

This Flutter plugin simplifies in-app purchases by wrapping the in_app_purchase plugin with easy-to-understand methods and a streamlined integration flow, making it more accessible for developers.

InApp Purchase Utils #

A simple and easy-to-use wrapper for the in_app_purchase plugin in Flutter, providing a streamlined integration process for handling in-app purchases.

Features #

  • Simplified methods for purchasing and managing subscriptions.
  • Easy-to-follow integration flow.
  • Supports both Android and iOS platforms.
  • Fetch available products and subscriptions effortlessly.
  • Handles purchase validation and transaction restoration.

Installation #

Add the dependency to your pubspec.yaml:

$ flutter pub add in_app_purchase_utils

This will add a line in your pubspec.yaml file under dependencies block.

dependencies:
  in_app_purchase_utils:

Usage #

Import the package #

import 'package:your_plugin_name/your_plugin_name.dart';

Add in_app_purchase plugin: #

You need to add in_app_purchase plugin in your project so that you can access some default classes like ProductDetails. To add the dependency in your pubspec.yaml, use the flutter command mentioned below.

$ flutter pub add in_app_purchase

Initialize the plugin #

To initialize the plugin, you need to call InAppPurchaseService.instance.initialize() method. There are 2 required params in this method.

1. validationAPI - Pass default iTunes or SandBox API according to your flavor / mode
2. secretKey - Pass your InApp purchase secret key
await InAppPurchaseService.instance
    .initialize(
      validationAPI: "<receipt_validation_API>", 
      secretKey: "<secret_key>"
    );

Fetch available products #

Pass the list of your products as List

List<ProductDetails> products = await InAppPurchaseService.instance
    .fetchProducts(["<product_id_1>", "<product_id_2>", "<product_id_n>"]);

Purchase a product #

bool success = await iapWrapper.purchaseProduct('product_id_1');
if (success) {
  print("Purchase successful");
}

Restore purchases #

await iapWrapper.restorePurchases();

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Contributions #

Contributions are welcome! Feel free to open issues or submit pull requests to improve the plugin.

Support #

For any issues or feature requests, please open an issue on GitHub.

2
likes
0
points
80
downloads

Publisher

unverified uploader

Weekly Downloads

This Flutter plugin simplifies in-app purchases by wrapping the in_app_purchase plugin with easy-to-understand methods and a streamlined integration flow, making it more accessible for developers.

Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, in_app_purchase, plugin_platform_interface

More

Packages that depend on in_app_purchase_utils

Packages that implement in_app_purchase_utils