### Get Introductory Price Period on Android Source: https://pub.dev/packages/in_app_purchase Accesses the introductory price period for a product on Android using GooglePlayProductDetails and SkuDetailsWrapper. Requires importing 'package:in_app_purchase_android/in_app_purchase_android.dart' and 'package:in_app_purchase_android/billing_client_wrappers.dart'. ```dart //import for GooglePlayProductDetails import 'package:in_app_purchase_android/in_app_purchase_android.dart'; //import for SkuDetailsWrapper import 'package:in_app_purchase_android/billing_client_wrappers.dart'; if (productDetails is GooglePlayProductDetails) { SkuDetailsWrapper skuDetails = (productDetails as GooglePlayProductDetails).skuDetails; print(skuDetails.introductoryPricePeriod); } ``` -------------------------------- ### Get Platform Addition Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/getPlatformAddition.html Retrieves the platform-specific implementation of the InAppPurchasePlatformAddition class. ```APIDOC ## GET /websites/pub_dev_in_app_purchase/getPlatformAddition ### Description Provides a platform-specific implementation of the `InAppPurchasePlatformAddition` class. ### Method GET ### Endpoint `/websites/pub_dev_in_app_purchase/getPlatformAddition` ### Parameters #### Query Parameters - **T** (Type) - Required - The generic type parameter for `InAppPurchasePlatformAddition`. ### Response #### Success Response (200) - **instance** (InAppPurchasePlatformAddition) - The platform-specific instance of `InAppPurchasePlatformAddition`. ``` -------------------------------- ### Get Platform-Specific Addition Implementation Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/getPlatformAddition.html Provides a platform-specific implementation of the InAppPurchasePlatformAddition class. Use this method to retrieve the instance tailored to the current platform. ```dart @override T getPlatformAddition() { return InAppPurchasePlatformAddition.instance as T; } ``` -------------------------------- ### GET /isAvailable Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/isAvailable.html Checks the availability status of the payment platform. ```APIDOC ## GET /isAvailable ### Description Returns a boolean indicating whether the payment platform is ready and available for transactions. ### Method GET ### Endpoint isAvailable() ### Response #### Success Response (200) - **isAvailable** (bool) - Returns true if the platform is ready, false otherwise. ``` -------------------------------- ### Get Transaction State on iOS (StoreKit 1) Source: https://pub.dev/packages/in_app_purchase Fetches the transaction state of a purchase on iOS using AppStorePurchaseDetails and SKPaymentTransactionWrapper. Requires importing 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart' and 'package:in_app_purchase_storekit/store_kit_wrappers.dart'. ```dart //import for AppStorePurchaseDetails import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart'; //import for SKProductWrapper import 'package:in_app_purchase_storekit/store_kit_wrappers.dart'; if (purchaseDetails is AppStorePurchaseDetails) { SKPaymentTransactionWrapper skProduct = (purchaseDetails as AppStorePurchaseDetails).skPaymentTransaction; print(skProduct.transactionState); } ``` -------------------------------- ### Implement toString Method Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/IAPError/toString.html Override the toString method to provide a custom string representation for debugging or logging purposes. This example shows how to include specific object properties in the output. ```dart @override String toString() { return 'IAPError(code: $code, source: $source, message: $message, details: $details)'; } ``` -------------------------------- ### Get Original JSON on Android Source: https://pub.dev/packages/in_app_purchase Retrieves the original JSON representation of a purchase on Android using GooglePlayPurchaseDetails and PurchaseWrapper. Requires importing 'package:in_app_purchase_android/in_app_purchase_android.dart' and 'package:in_app_purchase_android/billing_client_wrappers.dart'. ```dart //import for GooglePlayPurchaseDetails import 'package:in_app_purchase_android/in_app_purchase_android.dart'; //import for PurchaseWrapper import 'package:in_app_purchase_android/billing_client_wrappers.dart'; if (purchaseDetails is GooglePlayPurchaseDetails) { PurchaseWrapper billingClientPurchase = (purchaseDetails as GooglePlayPurchaseDetails).billingClientPurchase; print(billingClientPurchase.originalJson); } ``` -------------------------------- ### Get JSON Representation on iOS (StoreKit 2) Source: https://pub.dev/packages/in_app_purchase Retrieves the JSON representation of a transaction on iOS using SK2TransactionWrapper. Requires importing 'package:in_app_purchase_storekit/store_kit_2_wrappers.dart'. ```dart //import for SK2TransactionWrapper import 'package:in_app_purchase_storekit/store_kit_2_wrappers.dart'; List transactions = await SK2Transaction.transactions(); print(transactions[0].jsonRepresentation); ``` -------------------------------- ### Get Subscription Group Identifier on iOS (StoreKit 2) Source: https://pub.dev/packages/in_app_purchase Fetches the subscription group identifier for a subscription on iOS using AppStoreProduct2Details and SK2Product. Requires importing 'package:in_app_purchase_storekit/store_kit_2_wrappers.dart'. ```dart // With StoreKit 2 import 'package:in_app_purchase_storekit/store_kit_2_wrappers.dart'; if (productDetails is AppStoreProduct2Details) { SK2Product product = (productDetails as AppStoreProduct2Details).sk2Product; print(product.subscription?.subscriptionGroupID); } ``` -------------------------------- ### Get Subscription Group Identifier on iOS (StoreKit 1) Source: https://pub.dev/packages/in_app_purchase Retrieves the subscription group identifier for a subscription on iOS using AppStoreProductDetails and SKProductWrapper. Requires importing 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart' and 'package:in_app_purchase_storekit/store_kit_wrappers.dart'. ```dart //import for AppStoreProductDetails import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart'; //import for SKProductWrapper import 'package:in_app_purchase_storekit/store_kit_wrappers.dart'; if (productDetails is AppStoreProductDetails) { SKProductWrapper skProduct = (productDetails as AppStoreProductDetails).skProduct; print(skProduct.subscriptionGroupIdentifier); } ``` -------------------------------- ### Purchase Stream API Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/purchaseStream.html The purchaseStream provides real-time updates for all purchase-related events. It's crucial to subscribe to this stream early in your application's lifecycle to avoid missing any updates. Each subscription receives all events from the point it starts listening. ```APIDOC ## GET /purchaseStream ### Description Listens to a broadcast stream for real-time updates on purchases. This stream remains active as long as the app is running and provides updates for various purchase scenarios, including user-initiated purchases, platform store purchases, purchase restorations, and uncompleted purchases from previous sessions. ### Method GET ### Endpoint /purchaseStream ### Parameters This endpoint does not accept any path, query, or request body parameters. ### Response #### Success Response (200) - **purchaseStream** (Stream>) - A stream that emits lists of PurchaseDetails objects, representing real-time purchase updates. #### Response Example ```dart Stream> get purchaseStream => InAppPurchasePlatform.instance.purchaseStream; ``` ### Important Notes - Subscribe to this stream as early as possible in your app's lifecycle, preferably before returning your main App Widget. - It is recommended to listen to the stream with only one subscription at a time. Multiple subscriptions will receive all events from their respective start times. ``` -------------------------------- ### ProductDetailsResponse Constructor Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetailsResponse/ProductDetailsResponse.html Initializes a new instance of ProductDetailsResponse with product details, missing IDs, and optional error information. ```APIDOC ## Constructor ProductDetailsResponse ### Description Creates a new ProductDetailsResponse instance to handle the results of an in-app purchase product lookup. ### Parameters - **productDetails** (List) - Required - A list of successfully retrieved product details. - **notFoundIDs** (List) - Required - A list of product IDs that could not be found. - **error** (IAPError?) - Optional - An error object if the request failed. ### Implementation ```dart ProductDetailsResponse({required this.productDetails, required this.notFoundIDs, this.error}); ``` ``` -------------------------------- ### Initialize ProductDetails Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetails/ProductDetails.html Use this constructor to create a new product details object with required fields for identification and pricing. ```dart ProductDetails({ required this.id, required this.title, required this.description, required this.price, required this.rawPrice, required this.currencyCode, this.currencySymbol = '', }); ``` -------------------------------- ### Get Country Code Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/countryCode.html Retrieves the user's country code, which is based on ISO-3166-1 alpha2 format for Android and from SKStoreFrontWrapper for iOS. ```APIDOC ## GET /countryCode ### Description Returns the user's country code. ### Method GET ### Endpoint /countryCode ### Parameters This method does not accept any parameters. ### Response #### Success Response (200) - **countryCode** (String) - The ISO-3166-1 alpha-2 country code. #### Response Example ```json { "countryCode": "US" } ``` ``` -------------------------------- ### Initialize ProductDetailsResponse Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetailsResponse/ProductDetailsResponse.html Constructor used to create a response object containing product details, a list of IDs that were not found, and an optional error. ```dart ProductDetailsResponse( {required this.productDetails, required this.notFoundIDs, this.error}); ``` -------------------------------- ### ProductDetails Constructor Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetails/ProductDetails.html Creates a new product details object with the provided product information. ```APIDOC ## Constructor: ProductDetails ### Description Creates a new product details object with the provided details. ### Parameters - **id** (String) - Required - The unique identifier for the product. - **title** (String) - Required - The title of the product. - **description** (String) - Required - A description of the product. - **price** (String) - Required - The formatted price string. - **rawPrice** (double) - Required - The raw numerical price value. - **currencyCode** (String) - Required - The ISO currency code. - **currencySymbol** (String) - Optional - The currency symbol, defaults to an empty string. ``` -------------------------------- ### Initialize PurchaseVerificationData Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseVerificationData/PurchaseVerificationData.html Use this constructor to create a new instance of PurchaseVerificationData with the required verification and source information. ```dart PurchaseVerificationData({ required this.localVerificationData, required this.serverVerificationData, required this.source, }); ``` -------------------------------- ### PurchaseParam Constructor Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseParam/PurchaseParam.html Initializes a new instance of the PurchaseParam class with required product details and an optional application user name. ```APIDOC ## Constructor PurchaseParam ### Description Creates a new purchase parameter object with the given data. ### Parameters #### Request Body - **productDetails** (ProductDetails) - Required - The product details associated with the purchase. - **applicationUserName** (String) - Optional - An optional identifier for the application user. ### Request Example { "productDetails": { "id": "product_123" }, "applicationUserName": "user_abc" } ``` -------------------------------- ### ProductDetailsResponse Class Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html The response returned by `InAppPurchasePlatform.queryProductDetails`. ```APIDOC ## ProductDetailsResponse ### Description The response returned by `InAppPurchasePlatform.queryProductDetails`. ### Class `ProductDetailsResponse` ``` -------------------------------- ### Load Product Details Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Queries the store for details about products available for sale. Ensure that the product IDs are correctly formatted and exist in your store listing. Handles cases where some product IDs are not found. ```dart // Set literals require Dart 2.2. Alternatively, use // `Set _kIds = ['product1', 'product2'].toSet()`. const Set _kIds = {'product1', 'product2'}; final ProductDetailsResponse response = await InAppPurchase.instance.queryProductDetails(_kIds); if (response.notFoundIDs.isNotEmpty) { // Handle the error. } List products = response.productDetails; ``` -------------------------------- ### Initialize PurchaseParam Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseParam/PurchaseParam.html Constructor for creating a new purchase parameter object. ```dart PurchaseParam({ required this.productDetails, this.applicationUserName, }); ``` -------------------------------- ### Implement completePurchase Method Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/completePurchase.html This method marks purchased content as delivered. Ensure you call this for `PurchaseStatus.purchased` or `PurchaseStatus.restored` statuses. Completing a pending purchase will throw an exception. ```dart Future completePurchase(PurchaseDetails purchase) => InAppPurchasePlatform.instance.completePurchase(purchase); ``` -------------------------------- ### ProductDetails Class Definition Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetails-class.html Details regarding the ProductDetails class structure, properties, and constructor. ```APIDOC ## ProductDetails Class ### Description The ProductDetails class represents the information of a product available for purchase. ### Constructor ProductDetails({required String id, required String title, required String description, required String price, required double rawPrice, required String currencyCode, String currencySymbol = ''}) ### Properties - **id** (String) - The identifier of the product. - **title** (String) - The title of the product. - **description** (String) - The description of the product. - **price** (String) - The price of the product, formatted with currency symbol (e.g., "$0.99"). - **rawPrice** (double) - The unformatted price of the product. - **currencyCode** (String) - The currency code for the price of the product. - **currencySymbol** (String) - The currency symbol for the locale (e.g., $). ``` -------------------------------- ### InAppPurchase API Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase Overview of the core classes and structures used for managing in-app purchases. ```APIDOC ## InAppPurchase API ### Description The InAppPurchase class serves as the primary entry point for making in-app purchases across multiple platforms. ### Key Classes - **InAppPurchase**: The main API for managing purchase flows. - **ProductDetails**: Represents information about a specific product. - **PurchaseDetails**: Contains transaction details for a completed purchase. - **PurchaseParam**: Parameter object required to initiate a purchase. - **PurchaseVerificationData**: Data used for verifying the authenticity of a purchase. - **IAPError**: Captures errors returned by the underlying platform. ### Enums - **PurchaseStatus**: Represents the current state of a PurchaseDetails object. ``` -------------------------------- ### Query Product Details Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/queryProductDetails.html Use this method to query product details for a given set of identifiers. These identifiers correspond to product IDs in platforms like App Store Connect or Google Play Console. Ensure the `InAppPurchasePlatform.instance` is initialized before calling this method. ```dart Future queryProductDetails(Set identifiers) => InAppPurchasePlatform.instance.queryProductDetails(identifiers); ``` -------------------------------- ### Initialize InAppPurchaseException Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchaseException/InAppPurchaseException.html Use this constructor to create an exception instance by providing the required source and error code, with an optional message. ```dart InAppPurchaseException({ required this.source, required this.code, this.message, }); ``` -------------------------------- ### Initialize StoreKit Delegate for iOS Source: https://pub.dev/packages/in_app_purchase Initializes the StoreKit platform addition and sets a delegate to handle payment queue events on iOS. This is typically called during app startup. ```dart import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart'; import 'dart:io' show Platform; // Assuming _inAppPurchase is an instance of InAppPurchase // Example usage within a class or function: // final InAppPurchase _inAppPurchase = InAppPurchase.instance; Future initStoreInfo() async { if (Platform.isIOS) { var iosPlatformAddition = _inAppPurchase .getPlatformAddition(); await iosPlatformAddition.setDelegate(ExamplePaymentQueueDelegate()); } } ``` -------------------------------- ### PurchaseVerificationData Constructor Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseVerificationData/PurchaseVerificationData.html Creates a PurchaseVerificationData object with the provided information. ```APIDOC ## PurchaseVerificationData Constructor ### Description Creates a PurchaseVerificationData object with the provided information. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **localVerificationData** (String) - Required - The local verification data. - **serverVerificationData** (String) - Required - The server verification data. - **source** (String) - Required - The source of the verification. ### Request Example ```json { "localVerificationData": "example_local_data", "serverVerificationData": "example_server_data", "source": "example_source" } ``` ### Response #### Success Response (200) - **PurchaseVerificationData** (Object) - An instance of the PurchaseVerificationData class. #### Response Example ```json { "localVerificationData": "example_local_data", "serverVerificationData": "example_server_data", "source": "example_source" } ``` ``` -------------------------------- ### ProductDetails Class Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html Represents the information of a product available for purchase. ```APIDOC ## ProductDetails ### Description The class represents the information of a product. ### Class `ProductDetails` ``` -------------------------------- ### InAppPurchaseException Constructor Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchaseException/InAppPurchaseException.html Creates a new instance of InAppPurchaseException with required source and code fields, and an optional message. ```APIDOC ## InAppPurchaseException Constructor ### Description Creates a InAppPurchaseException with the specified source and error code and optional message. ### Parameters #### Request Body - **source** (String) - Required - The source of the exception. - **code** (String) - Required - The error code associated with the exception. - **message** (String) - Optional - An optional descriptive message for the exception. ### Request Example { "source": "billing_service", "code": "PURCHASE_FAILED", "message": "The transaction could not be completed." } ``` -------------------------------- ### buyConsumable Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase-class.html Initiates the purchase process for a consumable product. ```APIDOC ## buyConsumable ### Description Buy a consumable product. ### Parameters - **purchaseParam** (PurchaseParam) - Required - The parameters for the purchase. - **autoConsume** (bool) - Optional - Whether to automatically consume the product after purchase. Defaults to true. ### Response - **Future** - Returns true if the purchase process was initiated successfully. ``` -------------------------------- ### Implement buyNonConsumable Method Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/buyNonConsumable.html This method is used to initiate the purchase of a non-consumable product or subscription. It does not return the purchase result directly; instead, updates are sent to the purchaseStream. Ensure you listen to this stream to handle purchase statuses and deliver content. This implementation calls the underlying platform's buyNonConsumable method. ```dart Future buyNonConsumable({required PurchaseParam purchaseParam}) => InAppPurchasePlatform.instance.buyNonConsumable( purchaseParam: purchaseParam, ); ``` -------------------------------- ### Make a Purchase Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Initiates the purchase flow for a product. Differentiates between consumable and non-consumable products by calling the appropriate method. The purchase flow is then handled by the underlying store, with updates sent to the `purchaseStream`. ```dart final ProductDetails productDetails = ... // Saved earlier from queryProductDetails(). final PurchaseParam purchaseParam = PurchaseParam(productDetails: productDetails); if (_isConsumable(productDetails)) { InAppPurchase.instance.buyConsumable(purchaseParam: purchaseParam); } else { InAppPurchase.instance.buyNonConsumable(purchaseParam: purchaseParam); } // From here the purchase flow will be handled by the underlying store. // Updates will be delivered to the `InAppPurchase.instance.purchaseStream`. ``` -------------------------------- ### Check payment platform availability Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/isAvailable.html Returns true if the payment platform is ready and available for transactions. ```dart Future isAvailable() => InAppPurchasePlatform.instance.isAvailable(); ``` -------------------------------- ### buyConsumable implementation Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/buyConsumable.html The implementation of the buyConsumable method, which delegates the call to the InAppPurchasePlatform instance. ```dart Future buyConsumable({ required PurchaseParam purchaseParam, bool autoConsume = true, }) => InAppPurchasePlatform.instance.buyConsumable( purchaseParam: purchaseParam, autoConsume: autoConsume, ); ``` -------------------------------- ### Listen to Purchase Updates in initState Source: https://pub.dev/packages/in_app_purchase Subscribe to the purchase stream in your app's initState method to receive all purchase-related updates. This should be done as early as possible to catch all events, including those from previous app sessions. ```dart class _MyAppState extends State { StreamSubscription> _subscription; @override void initState() { final Stream purchaseUpdated = InAppPurchase.instance.purchaseStream; _subscription = purchaseUpdated.listen((purchaseDetailsList) { _listenToPurchaseUpdated(purchaseDetailsList); }, onDone: () { _subscription.cancel(); }, onError: (error) { // handle error here. }); super.initState(); } @override void dispose() { _subscription.cancel(); super.dispose(); } } ``` -------------------------------- ### InAppPurchase Instance Property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/instance.html Access the singleton instance of the InAppPurchase class. ```APIDOC ## Property: InAppPurchase.instance ### Description Returns the singleton instance of the InAppPurchase class to be used for in-app purchase operations. ### Implementation ```dart static InAppPurchase get instance => _getOrCreateInstance(); ``` ``` -------------------------------- ### Implement SKPaymentQueueDelegateWrapper Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Defines a custom delegate to control transaction continuation and price consent display behavior. ```dart // import for SKPaymentQueueDelegateWrapper import 'package:in_app_purchase_storekit/store_kit_wrappers.dart'; class ExamplePaymentQueueDelegate implements SKPaymentQueueDelegateWrapper { @override bool shouldContinueTransaction( SKPaymentTransactionWrapper transaction, SKStorefrontWrapper storefront) { return true; } @override bool shouldShowPriceConsent() { return false; } } ``` -------------------------------- ### Listen to purchase updates Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Subscribe to the purchase stream in initState to handle incoming purchase events from the underlying store. Ensure the subscription is cancelled in the dispose method to prevent memory leaks. ```dart class _MyAppState extends State { StreamSubscription> _subscription; @override void initState() { final Stream purchaseUpdated = InAppPurchase.instance.purchaseStream; _subscription = purchaseUpdated.listen((purchaseDetailsList) { _listenToPurchaseUpdated(purchaseDetailsList); }, onDone: () { _subscription.cancel(); }, onError: (error) { // handle error here. }); super.initState(); } @override void dispose() { _subscription.cancel(); super.dispose(); } ``` -------------------------------- ### IAPError Constructor Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/IAPError-class.html Details for creating a new IAPError instance. ```APIDOC ## Constructor: IAPError ### Description Creates a new IAP error object with the given error details. ### Parameters - **source** (String) - Required - Which source is the error on. - **code** (String) - Required - The error code. - **message** (String) - Required - A human-readable error message. - **details** (dynamic) - Optional - Error details, possibly null. ``` -------------------------------- ### queryProductDetails Method Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/queryProductDetails.html Retrieves product details for a specific set of identifiers from the configured payment platform. ```APIDOC ## queryProductDetails ### Description Query product details for the given set of IDs from the underlying payment platform (e.g., App Store Connect or Google Play Console). ### Parameters #### Arguments - **identifiers** (Set) - Required - A set of product identifiers to query. ### Response - **ProductDetailsResponse** - Returns a Future containing the product details response. ``` -------------------------------- ### Check store availability Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Verify if the underlying store is reachable before attempting to load products or initiate purchases. ```dart final bool available = await InAppPurchase.instance.isAvailable(); if (!available) { // The store cannot be reached or accessed. Update the UI accordingly. } ``` -------------------------------- ### Handle Incoming Purchase Updates Source: https://pub.dev/packages/in_app_purchase Process a list of purchase details to manage different purchase statuses like pending, error, purchased, or restored. It includes verifying the purchase and delivering the product, ensuring to complete the purchase if pending. ```dart void _listenToPurchaseUpdated(List purchaseDetailsList) { purchaseDetailsList.forEach((PurchaseDetails purchaseDetails) async { if (purchaseDetails.status == PurchaseStatus.pending) { _showPendingUI(); } else { if (purchaseDetails.status == PurchaseStatus.error) { _handleError(purchaseDetails.error!); } else if (purchaseDetails.status == PurchaseStatus.purchased || purchaseDetails.status == PurchaseStatus.restored) { bool valid = await _verifyPurchase(purchaseDetails); if (valid) { _deliverProduct(purchaseDetails); } else { _handleInvalidPurchase(purchaseDetails); } } if (purchaseDetails.pendingCompletePurchase) { await InAppPurchase.instance .completePurchase(purchaseDetails); } } }); } ``` -------------------------------- ### Implement countryCode method Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/countryCode.html Retrieves the user's country code by delegating to the current InAppPurchasePlatform instance. ```dart Future countryCode() => InAppPurchasePlatform.instance.countryCode(); ``` -------------------------------- ### POST buyConsumable Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/buyConsumable.html Initiates the purchase process for a consumable product. Consumable items can be purchased multiple times after being consumed. ```APIDOC ## POST buyConsumable ### Description Initiates a purchase request for a consumable product. Consumable items are marked as used and can be bought again. Purchase updates are delivered via the purchaseStream. ### Method POST ### Parameters #### Request Body - **purchaseParam** (PurchaseParam) - Required - The parameters required to initiate the purchase. - **autoConsume** (bool) - Optional - Defaults to true. If true, the plugin automatically consumes the product after a successful purchase. ### Response #### Success Response (200) - **result** (bool) - Returns true if the purchase request was initially sent successfully. ``` -------------------------------- ### PurchaseParam Class Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html The parameter object for generating a purchase. ```APIDOC ## PurchaseParam ### Description The parameter object for generating a purchase. ### Class `PurchaseParam` ``` -------------------------------- ### Restore Purchases Method Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/restorePurchases.html Call this method to restore all previous purchases. The `applicationUserName` should match the one provided during the initial purchase. Restored purchases are delivered via the `purchaseStream` with a status of `PurchaseStatus.restored`. ```dart Future restorePurchases({String? applicationUserName}) => InAppPurchasePlatform.instance.restorePurchases( applicationUserName: applicationUserName, ); ``` -------------------------------- ### completePurchase Method Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/completePurchase.html Marks purchased content as delivered to the user. This method should be called for `PurchaseDetails` with `PurchaseStatus.purchased` or `PurchaseStatus.restored`. It throws a `PurchaseException` if the purchase cannot be completed. ```APIDOC ## POST /websites/pub_dev_in_app_purchase/completePurchase ### Description Marks purchased content as delivered to the user. This method is responsible for completing every `PurchaseDetails` whose `PurchaseDetails.status` is `PurchaseStatus.purchased` or `PurchaseStatus.restored`. Completing a `PurchaseStatus.pending` purchase will cause an exception. For convenience, `PurchaseDetails.pendingCompletePurchase` indicates if a purchase is pending for completion. The method will throw a `PurchaseException` when the purchase could not be finished. Depending on the `PurchaseException.errorCode` the developer should try to complete the purchase via this method again, or retry the `completePurchase` method at a later time. If the `PurchaseException.errorCode` indicates you should not retry there might be some issue with the app's code or the configuration of the app in the respective store. The developer is responsible to fix this issue. The `PurchaseException.message` field might provide more information on what went wrong. ### Method POST ### Endpoint /websites/pub_dev_in_app_purchase/completePurchase ### Parameters #### Request Body - **purchase** (PurchaseDetails) - Required - Details of the purchase to complete. ### Request Example ```json { "purchase": { "purchaseId": "12345-67890", "productID": "com.example.consumable", "purchaseTime": 1678886400000, "purchaseState": "purchased", "skus": ["com.example.consumable"], "transactionDate": 1678886400000, "originalTransactionDate": 1678886400000, "localPurchaseTime": 1678886400000, "pendingCompletePurchase": false, "userId": "user123" } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` #### Error Response (400) - **error** (string) - Description of the error. #### Error Response Example ```json { "error": "PurchaseException: Could not complete purchase. Error code: 1." } ``` ``` -------------------------------- ### InAppPurchase Class Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html Provides a basic API for making in-app purchases across multiple platforms. ```APIDOC ## InAppPurchase ### Description Basic API for making in app purchases across multiple platforms. ### Class `InAppPurchase` ``` -------------------------------- ### PurchaseDetails Constructor Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseDetails/PurchaseDetails.html Creates a new PurchaseDetails object. Requires productID, verificationData, transactionDate, and status. purchaseID and transactionDate are optional. ```dart PurchaseDetails({ this.purchaseID, required this.productID, required this.verificationData, required this.transactionDate, required this.status, }); ``` -------------------------------- ### ProductDetailsResponse Class Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetailsResponse-class.html The ProductDetailsResponse class encapsulates the results of a product details query, including successfully retrieved product details, identifiers that were not found, and any potential errors. ```APIDOC ## ProductDetailsResponse Class The response returned by `InAppPurchasePlatform.queryProductDetails`. A list of ProductDetails can be obtained from this response. ### Constructors * **ProductDetailsResponse**({required List productDetails, required List notFoundIDs, IAPError? error}) Creates a new ProductDetailsResponse with the provided response details. ### Properties * **error** → IAPError? A caught platform exception thrown while querying the purchases. final * **hashCode** → int The hash code for this object. no setter inherited * **notFoundIDs** → List The list of identifiers that are in the `identifiers` of `InAppPurchasePlatform.queryProductDetails` but failed to be fetched. final * **productDetails** → List Each ProductDetails uniquely matches one valid identifier in `identifiers` of `InAppPurchasePlatform.queryProductDetails`. final * **runtimeType** → Type A representation of the runtime type of the object. no setter inherited ### Methods * **noSuchMethod**(Invocation invocation) → dynamic Invoked when a nonexistent method or property is accessed. inherited * **toString**() → String A string representation of this object. inherited ### Operators * **operator ==**(Object other) → bool The equality operator. inherited ``` -------------------------------- ### Product Description Property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetails/description.html The 'description' property represents the textual description of a product, which is displayed to users during the purchase process. It is configured separately for iOS (App Store Connect) and Android (Google Play Console). ```APIDOC ## Product Description Property ### Description The description of the product. For example, on iOS it is specified in App Store Connect; on Android, it is specified in Google Play Console. ### Implementation ```dart final String description; ``` ``` -------------------------------- ### buyNonConsumable method Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/buyNonConsumable.html Initiates a purchase request for a non-consumable product or subscription. ```APIDOC ## buyNonConsumable ### Description Buy a non-consumable product or subscription. Non-consumable items can only be bought once. This method does not return the result of the purchase; instead, updates are sent to the purchaseStream. ### Parameters #### Request Body - **purchaseParam** (PurchaseParam) - Required - The parameters required to initiate the purchase. ### Request Example { "purchaseParam": "PurchaseParam object" } ### Response #### Success Response (200) - **bool** - Returns true if the purchase request was initially sent successfully. ``` -------------------------------- ### PurchaseStatus Enum Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html Status for a PurchaseDetails. ```APIDOC ## PurchaseStatus ### Description Status for a PurchaseDetails. ### Enum `PurchaseStatus` ``` -------------------------------- ### queryProductDetails Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase-class.html Retrieves product details for a specific set of product identifiers. ```APIDOC ## queryProductDetails ### Description Query product details for the given set of IDs. ### Parameters - **identifiers** (Set) - Required - The set of product IDs to query. ### Response - **Future** - The response containing product details. ``` -------------------------------- ### Define productDetails property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetailsResponse/productDetails.html Declaration of the productDetails list containing ProductDetails objects. ```dart final List productDetails; ``` -------------------------------- ### PurchaseParam Class Definition Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseParam-class.html Details regarding the constructor and properties of the PurchaseParam class. ```APIDOC ## PurchaseParam Class ### Description The parameter object for generating a purchase. ### Constructors - **PurchaseParam({required ProductDetails productDetails, String? applicationUserName})** - Creates a new purchase parameter object with the given data. ### Properties - **applicationUserName** (String?) - Optional - An opaque id for the user's account that's unique to your app. - **productDetails** (ProductDetails) - Required - The product to create payment for. ``` -------------------------------- ### Initialize IAPError Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/IAPError/IAPError.html Constructs an IAPError instance with mandatory source, code, and message fields, and an optional details field. ```dart IAPError( {required this.source, required this.code, required this.message, this.details}); ``` -------------------------------- ### PurchaseDetails Constructor Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseDetails/PurchaseDetails.html Creates a new PurchaseDetails object with the provided transaction data. ```APIDOC ## Constructor: PurchaseDetails ### Description Creates a new PurchaseDetails object with the provided data. ### Parameters - **purchaseID** (String?) - Optional - The unique identifier for the purchase. - **productID** (String) - Required - The unique identifier for the product. - **verificationData** (PurchaseVerificationData) - Required - The verification data for the purchase. - **transactionDate** (String?) - Required - The date the transaction occurred. - **status** (PurchaseStatus) - Required - The current status of the purchase. ### Implementation ```dart PurchaseDetails({ this.purchaseID, required this.productID, required this.verificationData, required this.transactionDate, required this.status, }); ``` ``` -------------------------------- ### buyNonConsumable Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase-class.html Initiates the purchase process for a non-consumable product or subscription. ```APIDOC ## buyNonConsumable ### Description Buy a non consumable product or subscription. ### Parameters - **purchaseParam** (PurchaseParam) - Required - The parameters for the purchase. ### Response - **Future** - Returns true if the purchase process was initiated successfully. ``` -------------------------------- ### Access Android Product Details Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Cast ProductDetails to GooglePlayProductDetails to access SkuDetailsWrapper properties. ```dart //import for GooglePlayProductDetails import 'package:in_app_purchase_android/in_app_purchase_android.dart'; //import for SkuDetailsWrapper import 'package:in_app_purchase_android/billing_client_wrappers.dart'; if (productDetails is GooglePlayProductDetails) { SkuDetailsWrapper skuDetails = (productDetails as GooglePlayProductDetails).skuDetails; print(skuDetails.introductoryPricePeriod); } ``` -------------------------------- ### Handle purchase updates Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Process a list of purchase details, verifying the status and completing the purchase if required by the store. ```dart void _listenToPurchaseUpdated(List purchaseDetailsList) { purchaseDetailsList.forEach((PurchaseDetails purchaseDetails) async { if (purchaseDetails.status == PurchaseStatus.pending) { _showPendingUI(); } else { if (purchaseDetails.status == PurchaseStatus.error) { _handleError(purchaseDetails.error!); } else if (purchaseDetails.status == PurchaseStatus.purchased || purchaseDetails.status == PurchaseStatus.restored) { bool valid = await _verifyPurchase(purchaseDetails); if (valid) { _deliverProduct(purchaseDetails); } else { _handleInvalidPurchase(purchaseDetails); } } if (purchaseDetails.pendingCompletePurchase) { await InAppPurchase.instance .completePurchase(purchaseDetails); } } }); } ``` -------------------------------- ### Product Title Property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetails/title.html Defines the string property used for product titles in the in-app purchase implementation. ```APIDOC ## Product Title Property ### Description The title of the product. This value is retrieved from the respective platform's store console (App Store Connect for iOS, Google Play Console for Android). ### Property Details - **title** (String) - Final - The display name of the product. ### Implementation ```dart final String title; ``` ``` -------------------------------- ### Property: source Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseVerificationData/source.html Defines the source property used to indicate the origin of an in-app purchase. ```APIDOC ## Property: source ### Description Indicates the source of the purchase. ### Implementation ```dart final String source; ``` ``` -------------------------------- ### Accessing the InAppPurchase instance Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/instance.html Use this static getter to retrieve the singleton instance of the InAppPurchase class. ```dart static InAppPurchase get instance => _getOrCreateInstance(); ``` -------------------------------- ### Initialize pendingCompletePurchase Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseDetails/pendingCompletePurchase.html The initial value of pendingCompletePurchase is false. Developers must call InAppPurchasePlatform.completePurchase if this property becomes true and the product has been delivered. ```dart bool pendingCompletePurchase = false; ``` -------------------------------- ### PurchaseVerificationData Class Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html Represents the data that is used to verify purchases. ```APIDOC ## PurchaseVerificationData ### Description Represents the data that is used to verify purchases. ### Class `PurchaseVerificationData` ``` -------------------------------- ### completePurchase Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase-class.html Marks a purchase as delivered to the user. ```APIDOC ## completePurchase ### Description Mark that purchased content has been delivered to the user. ### Parameters - **purchase** (PurchaseDetails) - Required - The purchase details to mark as complete. ### Response - **Future** ``` -------------------------------- ### ProductDetails Property Definition Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseParam/productDetails.html Details regarding the productDetails property used to specify the product for payment. ```APIDOC ## ProductDetails Property ### Description The productDetails property represents the product for which a payment is being created. It must correspond to a valid ProductDetails object retrieved via the `InAppPurchasePlatform.queryProductDetails` method. ### Implementation ```dart final ProductDetails productDetails; ``` ``` -------------------------------- ### Access iOS Product Details Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Cast ProductDetails to AppStoreProductDetails or AppStoreProduct2Details to access native StoreKit properties. ```dart //import for AppStoreProductDetails import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart'; //import for SKProductWrapper import 'package:in_app_purchase_storekit/store_kit_wrappers.dart'; if (productDetails is AppStoreProductDetails) { SKProductWrapper skProduct = (productDetails as AppStoreProductDetails).skProduct; print(skProduct.subscriptionGroupIdentifier); } // With StoreKit 2 import 'package:in_app_purchase_storekit/store_kit_2_wrappers.dart'; if (productDetails is AppStoreProduct2Details) { SK2Product product = (productDetails as AppStoreProduct2Details).sk2Product; print(product.subscription?.subscriptionGroupID); } ``` -------------------------------- ### Define ProductDetails property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseParam/productDetails.html Declaration of the productDetails property used to identify the target product for a purchase. ```dart final ProductDetails productDetails; ``` -------------------------------- ### Restore Previous Purchases Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Initiates the process of restoring previous purchases for the user. Restored purchases are delivered via the `purchaseStream`. It's crucial to validate these restored purchases according to store best practices. ```dart await InAppPurchase.instance.restorePurchases(); ``` -------------------------------- ### Complete a Purchase Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Marks a purchase as complete after verifying the receipt and delivering content. Failure to call this within 3 days may result in a refund. This informs the store to finalize the transaction. ```dart InAppPurchase.completePurchase(purchaseDetails); ``` -------------------------------- ### Import InAppPurchaseStoreKitPlatformAddition Source: https://pub.dev/packages/in_app_purchase This import statement is required when using InAppPurchaseStoreKitPlatformAddition, such as for presenting the code redemption sheet. ```dart import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart'; ``` -------------------------------- ### Define productID property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseDetails/productID.html The product identifier is defined as a final string property. ```dart final String productID; ``` -------------------------------- ### details property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/IAPError/details.html Documentation for the dynamic details property used for error reporting. ```APIDOC ## details property ### Description The details property is a dynamic field used to store error information. It may be null if no error is present. ### Implementation ```dart final dynamic details; ``` ``` -------------------------------- ### PurchaseDetails Class Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html Represents the transaction details of a purchase. ```APIDOC ## PurchaseDetails ### Description Represents the transaction details of a purchase. ### Class `PurchaseDetails` ``` -------------------------------- ### InAppPurchaseException Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html Thrown to indicate that an action failed while interacting with the in_app_purchase plugin. ```APIDOC ## InAppPurchaseException ### Description Thrown to indicate that an action failed while interacting with the in_app_purchase plugin. ### Exception `InAppPurchaseException` ``` -------------------------------- ### Define title property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetails/title.html The title property is a final string representing the product name configured in App Store Connect or Google Play Console. ```dart final String title; ``` -------------------------------- ### Register and Dispose StoreKit Delegate Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Registers a delegate to intercept StoreKit payment queue events and removes it during disposal. ```dart //import for InAppPurchaseStoreKitPlatformAddition import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart'; Future initStoreInfo() async { if (Platform.isIOS) { var iosPlatformAddition = _inAppPurchase .getPlatformAddition(); await iosPlatformAddition.setDelegate(ExamplePaymentQueueDelegate()); } } @override Future disposeStore() { if (Platform.isIOS) { var iosPlatformAddition = _inAppPurchase .getPlatformAddition(); await iosPlatformAddition.setDelegate(null); } } ``` -------------------------------- ### Declare Product Description Property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetails/description.html This Dart code declares a final String variable named 'description' to hold the product's description. This property is typically set during object initialization. ```dart final String description; ``` -------------------------------- ### IAPError Class Overview Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html Captures an error from the underlying purchase platform. ```APIDOC ## IAPError ### Description Captures an error from the underlying purchase platform. ### Class `IAPError` ``` -------------------------------- ### IAPError Constructor Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/IAPError/IAPError.html Creates a new IAP error object with the provided error details. ```APIDOC ## IAPError Constructor ### Description Creates a new IAP error object with the given error details. ### Parameters - **source** (String) - Required - The source of the error. - **code** (String) - Required - The error code. - **message** (String) - Required - The error message. - **details** (dynamic) - Optional - Additional error details. ### Implementation ```dart IAPError( {required this.source, required this.code, required this.message, this.details}); ``` ``` -------------------------------- ### buyConsumable method signature Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/buyConsumable.html The signature for the buyConsumable method, which requires a PurchaseParam and an optional autoConsume boolean. ```dart Future buyConsumable({ 1. required PurchaseParam purchaseParam, 2. bool autoConsume = true, }) ``` -------------------------------- ### Price Property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/ProductDetails/price.html The 'price' property represents the cost of the product, formatted with a currency symbol. This value is configured in the respective app store consoles (App Store Connect for iOS, Google Play Console for Android). ```APIDOC ## Price Property ### Description The price of the product, formatted with currency symbol (e.g., "$0.99"). ### Type String ### Example "$0.99" ### Implementation ```dart final String price; ``` ``` -------------------------------- ### PurchaseStatus Enum Values Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseStatus/values-constant.html Provides access to the constant list of all possible PurchaseStatus values. ```APIDOC ## PurchaseStatus Enum ### Description An enum representing the status of a purchase. ### Values Constant #### `values` (List) A constant List of the values in this enum, in order of their declaration. ``` -------------------------------- ### Accessing the purchaseStream Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchase/purchaseStream.html This code snippet shows how to access the `purchaseStream` property from the `InAppPurchasePlatform` instance. Subscribe to this stream to receive real-time purchase updates. ```dart Stream> get purchaseStream => InAppPurchasePlatform.instance.purchaseStream; ``` -------------------------------- ### Upgrade/Downgrade Subscription (Google Play) Source: https://pub.dev/documentation/in_app_purchase/latest/index.html Handles upgrading or downgrading an existing in-app subscription on Google Play. Requires providing the old purchase details and an optional replacement mode. The App Store handles this differently via subscription grouping. ```dart final PurchaseDetails oldPurchaseDetails = ...; PurchaseParam purchaseParam = GooglePlayPurchaseParam( productDetails: productDetails, changeSubscriptionParam: ChangeSubscriptionParam( oldPurchaseDetails: oldPurchaseDetails, replacementMode: ReplacementMode.withTimeProration)); InAppPurchase.instance .buyNonConsumable(purchaseParam: purchaseParam); ``` -------------------------------- ### Define applicationUserName property Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseParam/applicationUserName.html Declaration of the applicationUserName property as a nullable string. ```dart final String? applicationUserName; ``` -------------------------------- ### productID Property Definition Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/PurchaseDetails/productID.html Details regarding the productID property used in the in-app purchase implementation. ```APIDOC ## Property: productID ### Description The product identifier of the purchase. ### Type String ### Implementation ```dart final String productID; ``` ``` -------------------------------- ### InAppPurchaseException Class Source: https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/InAppPurchaseException-class.html The InAppPurchaseException class is thrown to indicate that an action failed while interacting with the in_app_purchase plugin. ```APIDOC ## InAppPurchaseException Class Thrown to indicate that an action failed while interacting with the in_app_purchase plugin. ### Implemented types * Exception ### Constructors #### InAppPurchaseException({required String source, required String code, String? message}) Creates a InAppPurchaseException with the specified source and error `code` and optional `message`. ### Properties * **code** → String - An error code. (final) * **hashCode** → int - The hash code for this object. (inherited) * **message** → String? - A human-readable error message, possibly null. (final) * **runtimeType** → Type - A representation of the runtime type of the object. (inherited) * **source** → String - Which source is the error on. (final) ### Methods * **noSuchMethod**(Invocation invocation) → dynamic - Invoked when a nonexistent method or property is accessed. (inherited) * **toString**() → String - A string representation of this object. (override) ### Operators * **operator ==**(Object other) → bool - The equality operator. (inherited) ```