in_app_purchase_observer.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (c) 2017 Amaplex Software, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_MAC_IN_APP_PURCHASE_OBSERVER_H_
  5. #define ATOM_BROWSER_MAC_IN_APP_PURCHASE_OBSERVER_H_
  6. #include <string>
  7. #include <vector>
  8. #include "base/callback.h"
  9. #include "base/memory/weak_ptr.h"
  10. #if defined(__OBJC__)
  11. @class InAppTransactionObserver;
  12. #else // __OBJC__
  13. class InAppTransactionObserver;
  14. #endif // __OBJC__
  15. namespace in_app_purchase {
  16. // --------------------------- Structures ---------------------------
  17. struct Payment {
  18. std::string productIdentifier = "";
  19. int quantity = 1;
  20. };
  21. struct Transaction {
  22. std::string transactionIdentifier = "";
  23. std::string transactionDate = "";
  24. std::string originalTransactionIdentifier = "";
  25. int errorCode = 0;
  26. std::string errorMessage = "";
  27. std::string transactionState = "";
  28. Payment payment;
  29. Transaction();
  30. Transaction(const Transaction&);
  31. ~Transaction();
  32. };
  33. // --------------------------- Classes ---------------------------
  34. class TransactionObserver {
  35. public:
  36. TransactionObserver();
  37. virtual ~TransactionObserver();
  38. virtual void OnTransactionsUpdated(
  39. const std::vector<Transaction>& transactions) = 0;
  40. private:
  41. InAppTransactionObserver* obeserver_;
  42. base::WeakPtrFactory<TransactionObserver> weak_ptr_factory_;
  43. DISALLOW_COPY_AND_ASSIGN(TransactionObserver);
  44. };
  45. } // namespace in_app_purchase
  46. #endif // ATOM_BROWSER_MAC_IN_APP_PURCHASE_OBSERVER_H_