gemicore_flutter library

Gemicore purchases for Flutter: App Store and Google Play subscriptions and one-time purchases, offerings and paywalls, promotional offers, one-time card, Apple Pay and Google Pay payments, and entitlements, configured with one key.

Classes

CancelSurvey
CancelSurveyOption
One answer of the cancel survey.
CardPrice
A price for paying by card, Apple Pay or Google Pay, in minor units (cents).
CheckoutOpener
Opens the hosted checkout. An in-app browser view (SFSafariViewController, Custom Tabs) is used because both support Apple Pay and Google Pay on the gateway's page, which a web view does not.
ConsumptionConsent
Whether the customer lets the app share usage data with Apple when a refund is requested.
CustomerCenterConfig
What the dashboard configured for the Customer Center. Every field has a safe default, so a config from a newer server never fails to parse.
CustomerCenterStringKey
The keys of the screen's text. A config's strings may define any of them per locale; the ones it leaves out use customerCenterEnglish. survey_option.<key> translates a survey option's label.
CustomerCenterStrings
Looks up the screen's text: the device language's table in the config (the full tag, then the language), then the config's English table, then the built in English, key by key.
CustomerCenterView
What Gemicore.getCustomerCenter answers.
CustomerInfo
Everything the app needs to decide what the current customer may use.
DividerNode
EntitlementInfo
Access to one entitlement, and what grants it.
ExperimentAssignment
The experiment a customer is enrolled in for a placement, and the variant they were given.
ExternalUrlOpener
An opener that can also hand a page to the system: the browser app, the App Store or Play Store app, the mail app. The Customer Center uses it for store pages and mailto links when the opener passed to configure implements it; otherwise it falls back to CheckoutOpener.open.
Gemicore
The Gemicore purchases SDK. Configure once with the app's publishable key; the dashboard holds the store credentials and the product catalog, so nothing else is set in code.
GemicoreCustomerCenter
The Customer Center drawn inline: a summary of the active entitlements and subscriptions, Manage subscription, Restore purchases, Get help with a purchase, Contact support and the cancel flow, each shown as the dashboard configured. Use presentCustomerCenter to show it full screen.
GemicoreErrorCode
Error codes the purchases API answers with, from packages/contracts/src/purchases.ts.
GemicorePaywall
Renders the paywall the dashboard designed for offering. Prices, periods and trials come from the store details of the selected package; nothing in the config is code, and a node that is unknown or unusable is left out.
GemicoreProduct
A product ready to show and sell: the server catalog entry merged with the store's localized price.
GemicoreStorage
Where the SDK keeps the customer token and the cached customer info between launches.
GemicoreStripePaySheet
Apple Pay and Google Pay inside the app, on the Stripe payment sheet. It is the default for Gemicore.payWithSheet; pass your own nativePaySheet to Gemicore.configure to replace it.
GemicoreTransport
The smallest HTTP surface the SDK needs, so tests can answer without a server.
HttpTransport
ImageNode
InAppBrowserCheckoutOpener
InAppPurchaseStoreBridge
The real store, through the official in_app_purchase plugin.
LegalLinksNode
MemoryGemicoreStorage
NativePayRequest
What the sheet needs, all from the server except testEnvironment, which follows the API key.
NativePayResult
NativePaySheet
Shows the Apple Pay or Google Pay sheet for a card payment. GemicoreStripePaySheet implements it on the Stripe payment sheet and is the default; implement it to use another sheet.
Offering
A set of packages to show together, for example the default paywall or a promotion.
Offerings
Package
One thing an offering sells: a catalog product with a label and a type such as monthly.
PackageListNode
PaywallConfig
PaywallNode
PaywallResult
PaywallTheme
PaywallView
The published paywall of an offering. config is null when the server sent one this SDK cannot show.
PlacementResolution
Why a placement answered with the offering it did: a running experiment, a targeting rule, the placement's default offering, or the app's current offering.
ProductOffer
A discount the customer can use on one product, from Gemicore.getEligibleOffers. Pass it to Gemicore.purchase to apply it.
PurchaseButtonNode
PurchaseInfo
One purchase on the customer's record.
PurchaseResult
The outcome of Gemicore.purchase or Gemicore.payWithCard.
RestoreButtonNode
RetentionRule
A catalog offer shown first to a customer who holds productIdentifier and tries to cancel it.
SecureGemicoreStorage
Keychain on iOS, encrypted storage on Android, so the customer token never sits in plain prefs.
SpacerNode
StackNode
StoreBridge
The App Store or Google Play, behind a small surface.
StoreProductDetails
A store product as the SDK needs it, independent of the plugin types so tests can fake the store.
StorePromotionalOffer
A signed App Store promotional offer, in the fields StoreKit takes.
StorePurchaseOffer
What to attach to an App Store purchase. On Google Play an offer is chosen by passing the product details of that offer to StoreBridge.buy, so none of this applies there.
StorePurchaseUpdate
One event from the store's purchase stream.
StripePaymentSheetApi
The few Stripe calls the sheet makes, behind an interface so tests run without the platform channel that the static Stripe API needs.
StripeStaticApi
The real thing, on the static Stripe API.
SubscriptionPeriod
How long a subscription renews for or a trial lasts, as the store reports it.
TextNode
TransportResponse
UnknownNode
A node type this SDK version does not know, or one whose fields are unusable. Renders nothing.

Constants

customerCenterEnglish → const Map<String, String>
The built in English text of every label. Nothing in the screen is hard coded outside this table.

Functions

defaultPeriodLabel(SubscriptionPeriod period, Locale locale, {required bool alwaysCount}) → String?
parseHexColor(Object? value) → Color?
Reads "#rrggbb" or "#rrggbbaa" (alpha last, as on the web). Anything else is null.
presentCustomerCenter(BuildContext context, {Gemicore? sdk, Locale? locale, CheckoutOpener? urlOpener, bool useRootNavigator = true}) → Future<bool>
Shows the Customer Center full screen and completes when the customer closes it. Returns false, without showing anything, when the dashboard has not switched the Customer Center on. A failed load (network, an unconfigured SDK) throws a GemicoreException, like the other reads.
presentPaywall(BuildContext context, {String? placement, Offering? offering, Gemicore? sdk, Locale? locale, CheckoutOpener? urlOpener, PaywallPeriodLabeler? periodLabeler, bool useRootNavigator = true}) → Future<PaywallResult>
Shows the paywall of offering full screen and completes when the customer has bought, restored or closed it. Needs a configured SDK, or pass sdk.

Typedefs

AppVersionProvider = Future<String?> Function()
Returns the host app's version name, for example "2.3.1". The SDK sends it so placements can target by app version. By default it is read with package_info_plus.
PaywallPeriodLabeler = String? Function(SubscriptionPeriod period, Locale locale, {required bool alwaysCount})
Turns a period into words for a paywall line, in the language of the paywall's strings. Return null to say the period cannot be written, which hides the line. alwaysCount is set for trials, where "1 week" reads better than "week".
UserTokenProvider = Future<String?> Function()
Returns the signed in app user's Gemicore access token, or null when there is none. Needed only when the app's identity mode is "verified" in the dashboard, where linking a customer to an app user id has to be proven. The SDK calls it just before a request that names a user.

Exceptions / Errors

GemicoreException
Every failure the SDK reports. code is the API's error code, or an SDK_ code for local failures.