DVPurchases class
DV.Purchases: store purchases, verified on the server, written to the
ledger entitlements are read from.
- Available extensions
Constructors
-
DVPurchases({required List<
DVPurchaseProduct> products, required List<DVStoreAdapter> stores, required DVPurchaseLedger ledger, DVStorePolicy? policy, DateTime clock()?, DVLogger? logger, void onChange(DVPurchaseChange change)?, Duration perpetualSnapshotLifetime = const Duration(days: 7), DVBillingProvider? gateway, Map<String, BillingPlan> gatewayPlans = const <String, BillingPlan>{}}) -
DVPurchases.device({required List<
DVPurchaseProduct> products, DVStoreClient? store, DVPurchaseBackend? backend, DVPurchaseChannel? channel, DVStorePolicy? policy, DateTime clock()?, DVLogger? logger, Future<void> openUrl(Uri url)?, Future<String> openInvoice(Uri url)?}) -
The device half: what
DV.Purchasesis inside an application.
Properties
- device → DVPurchaseDevice?
-
The device half, or null on the server.
final
-
entitlementChanges
→ Stream<
void> -
Each time what the device holds changes.
no setter
- gateway → DVBillingProvider?
-
Billing's payment gateway, for what a web or desktop build sells, or
null when the backend has none.
final
-
gatewayPlans
→ Map<
String, BillingPlan> -
The gateway plan each product id is sold as on the web and desktop.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- ledger → DVPurchaseLedger
-
final
- perpetualSnapshotLifetime → Duration
-
The
notAftera snapshot of a purchase that never expires carries.final - policy → DVStorePolicy
-
final
-
products
→ List<
DVPurchaseProduct> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
acceptNotification(
DVContext context, DVStore store, {required String body, required Map< String, String> headers}) → Future<DVPurchaseResult> -
Applies a store server notification delivered to
store's endpoint. -
buy(
DVPurchaseProduct product, {DVStoreOffer? offer, int quantity = 1}) → Future< DVPurchaseOutcome> -
Buys
productwhere this build sells it: the platform's store, the gateway's checkout on the web and desktop, Stars in a Telegram Mini App. -
checkAcknowledgements(
) → Future< List< DVPurchaseGrant> > -
Retries acknowledgements still missing inside their store's window, and
reports each past it as
DV-PURCHASE-006, returning those. -
checkout(
DVPurchaseProduct product, {required Object customer}) → Future< Uri> -
A checkout page for
producton Billing's gateway, forcustomer. -
entitled(
Object customer, Entitlement entitlement) → Future< bool> -
Whether
customerholdsentitlementnow, from the ledger. -
holds(
Entitlement entitlement) → bool -
Whether the signed-in person holds
entitlementnow, from the last snapshots the backend sent. Synchronous, so a build method can read it; seeDV.Purchases.watch(context, ...)in dartvel_flutter. -
invoice(
DVPurchaseProduct product, {required Object customer}) → Future< DVStoreInvoice> -
A Telegram Stars invoice for
product, written forcustomer. -
listings(
) → Future< List< DVStoreListing> > - The declared products as this device's store lists them, with prices in the customer's own currency and the offers they are eligible for.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
productById(
String id) → DVPurchaseProduct? -
The product the application declares as
id, or null. -
refreshEntitlements(
) → Future< void> - Asks the backend again what the signed-in person holds.
-
restore(
{Object? customer, DVStore? store, List< String> ? receipts}) → Future<List< DVPurchaseResult> > -
Revalidates each of
receiptswithstoreforcustomer. -
route(
DVPurchaseProduct product, {required DVPurchaseChannel channel, String? jurisdiction}) → DVPurchaseRoute -
Where
productis bought onchannel, as the configured policy says. -
signOffer(
DVPurchaseProduct product, String offerId, {required Object customer}) → Future< DVStoreOfferSignature> -
The signature for App Store promotional offer
offerIdonproduct, bound tocustomer's account token. -
snapshots(
Object customer) → Future< List< DVEntitlementSnapshot> > -
What a device may hold for
customer: each entitlement in force, with the moment it stops without a fresh sync. -
toString(
) → String -
A string representation of this object.
inherited
-
verifyPurchase(
DVStore store, String receipt, {required Object customer}) → Future< DVPurchaseResult> -
Verifies
receiptwithstoreand grants what it bought tocustomer. -
watch(
BuildContext context, Entitlement entitlement) → bool -
Available on DVPurchases, provided by the DVPurchasesWatch extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- configuredOrNull → DVPurchases?
-
The configured purchases, or null: for the generated endpoints, which
answer 404 rather than throw in an application that sells nothing.
no setter
- current → DVPurchases
-
no setter
Static Methods
-
accountTokenFor(
Object customer) → String -
The account token a client passes to the store when it opens the
purchase sheet for
customer. -
configure(
DVPurchases purchases) → void -
Sets what
DV.Purchasesanswers with. -
unconfigure(
) → void