reportPurchase method

Future<bool> reportPurchase({
  1. required String platform,
  2. required String storeProductId,
  3. String? transactionId,
  4. num? amount,
  5. String? currency,
  6. String? signedTransaction,
  7. String? purchaseToken,
  8. String? productType,
  9. String? kind,
})

Reports a finished store purchase: with the store's proof (signedTransaction on iOS, purchaseToken + productType on Android) Hatang verifies it and records it for this person; the team also gets an internal note. false without a session, on an older gateway, or when the store refuses it.

Implementation

Future<bool> reportPurchase({
  required String platform,
  required String storeProductId,
  String? transactionId,
  num? amount,
  String? currency,
  String? signedTransaction,
  String? purchaseToken,
  String? productType,
  String? kind,
}) async {
  await _ensureLoaded();
  final token = _token;
  if (token == null) return false;
  try {
    return await _api.postPurchase(
      token: token,
      platform: platform,
      storeProductId: storeProductId,
      transactionId: transactionId,
      conversationId: _state.conversation?.id,
      amount: amount,
      currency: currency,
      signedTransaction: signedTransaction,
      purchaseToken: purchaseToken,
      productType: productType,
      kind: kind,
    );
  } on HatangException catch (e) {
    _log.warn('purchase report failed: $e');
    return false;
  }
}