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.Purchases is 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 notAfter a 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 product where 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 product on Billing's gateway, for customer.
entitled(Object customer, Entitlement entitlement) → Future<bool>
Whether customer holds entitlement now, from the ledger.
holds(Entitlement entitlement) → bool
Whether the signed-in person holds entitlement now, from the last snapshots the backend sent. Synchronous, so a build method can read it; see DV.Purchases.watch(context, ...) in dartvel_flutter.
invoice(DVPurchaseProduct product, {required Object customer}) → Future<DVStoreInvoice>
A Telegram Stars invoice for product, written for customer.
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 receipts with store for customer.
route(DVPurchaseProduct product, {required DVPurchaseChannel channel, String? jurisdiction}) → DVPurchaseRoute
Where product is bought on channel, as the configured policy says.
signOffer(DVPurchaseProduct product, String offerId, {required Object customer}) → Future<DVStoreOfferSignature>
The signature for App Store promotional offer offerId on product, bound to customer'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 receipt with store and grants what it bought to customer.
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.Purchases answers with.
unconfigure() → void