complete method
Acknowledges or completes provider delivery after Worker verification.
Implementations must be able to complete a reconstructed update from its durable evidence; retaining only an in-memory SDK object is insufficient. This method is never called for pending, cancelled, failed, or unverified updates.
Implementation
@override
Future<void> complete(PurchaseUpdate update) async {
final token = update.evidence?['purchaseToken'];
if (token is! String || token.isEmpty) {
throw StateError(
'A Play delivery cannot be settled without its purchase token.',
);
}
// The live object when this run has seen it, and otherwise one rebuilt from
// the token alone: an outbox entry written before a crash must still be
// settleable, and Play's three-day refund does not wait for the stream to
// re-deliver.
await _billing.completePurchase(
_live[token] ?? _reconstruct(update, token),
);
_live.remove(token);
}