store_purchase_kit 1.0.0 copy "store_purchase_kit: ^1.0.0" to clipboard
store_purchase_kit: ^1.0.0 copied to clipboard

Enterprise Flutter Store Purchase Library using Native StoreKit2 and Google Billing with MethodChannel/EventChannel by IT36VN.com

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:store_purchase_kit/store_purchase_kit.dart';

import 'backend_client.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> implements PurchaseCallback {
  @override
  void initState() {
    super.initState();

    StorePurchase.instance.initialize(
      config: PurchaseConfig.production(
        backendVerificationClient: MyBackendClient(),
      ),
      callback: this,
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              StorePurchase.instance.purchase(
                productId: "vip_month",
                orderId: "ORDER_001",
                userId: "USER_001",
              );
            },
            child: const Text("Buy VIP"),
          ),
        ),
      ),
    );
  }

  @override
  void onCancelled() {
    debugPrint("cancelled");
  }

  @override
  void onCompleted(PurchaseResult result) {
    debugPrint("completed: ${result.transactionId}");
  }

  @override
  void onFailed(PurchaseError error) {
    debugPrint("failed: ${error.message}");
  }

  @override
  void onLoading() {}

  @override
  void onPending() {}

  @override
  void onPurchased(PurchaseResult result) {}

  @override
  void onRestored(List<PurchaseResult> result) {}

  @override
  void onVerifyWaiting() {}
}
0
likes
135
points
10
downloads

Documentation

API reference

Publisher

verified publisherit36vn.com

Weekly Downloads

Enterprise Flutter Store Purchase Library using Native StoreKit2 and Google Billing with MethodChannel/EventChannel by IT36VN.com

Homepage

Topics

#purchase #billing #storekit #google-play #payment

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on store_purchase_kit

Packages that implement store_purchase_kit