atom_api_in_app_purchase.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_API_ATOM_API_IN_APP_PURCHASE_H_
  5. #define ATOM_BROWSER_API_ATOM_API_IN_APP_PURCHASE_H_
  6. #include <string>
  7. #include <vector>
  8. #include "atom/browser/api/event_emitter.h"
  9. #include "atom/browser/mac/in_app_purchase.h"
  10. #include "atom/browser/mac/in_app_purchase_observer.h"
  11. #include "atom/browser/mac/in_app_purchase_product.h"
  12. #include "native_mate/handle.h"
  13. namespace atom {
  14. namespace api {
  15. class InAppPurchase : public mate::EventEmitter<InAppPurchase>,
  16. public in_app_purchase::TransactionObserver {
  17. public:
  18. static mate::Handle<InAppPurchase> Create(v8::Isolate* isolate);
  19. static void BuildPrototype(v8::Isolate* isolate,
  20. v8::Local<v8::FunctionTemplate> prototype);
  21. protected:
  22. explicit InAppPurchase(v8::Isolate* isolate);
  23. ~InAppPurchase() override;
  24. void PurchaseProduct(const std::string& product_id, mate::Arguments* args);
  25. // TransactionObserver:
  26. void OnTransactionsUpdated(
  27. const std::vector<in_app_purchase::Transaction>& transactions) override;
  28. private:
  29. DISALLOW_COPY_AND_ASSIGN(InAppPurchase);
  30. };
  31. } // namespace api
  32. } // namespace atom
  33. #endif // ATOM_BROWSER_API_ATOM_API_IN_APP_PURCHASE_H_