2017-11-30 13:27:33 +00:00
|
|
|
// Copyright (c) 2017 Amaplex Software, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#ifndef SHELL_BROWSER_API_ELECTRON_API_IN_APP_PURCHASE_H_
|
|
|
|
#define SHELL_BROWSER_API_ELECTRON_API_IN_APP_PURCHASE_H_
|
2017-11-30 13:27:33 +00:00
|
|
|
|
|
|
|
#include <string>
|
2018-01-10 08:18:23 +00:00
|
|
|
#include <vector>
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2019-10-21 07:05:40 +00:00
|
|
|
#include "gin/handle.h"
|
2020-07-23 21:55:41 +00:00
|
|
|
#include "gin/wrappable.h"
|
|
|
|
#include "shell/browser/event_emitter_mixin.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/mac/in_app_purchase.h"
|
|
|
|
#include "shell/browser/mac/in_app_purchase_observer.h"
|
|
|
|
#include "shell/browser/mac/in_app_purchase_product.h"
|
2020-07-23 21:55:41 +00:00
|
|
|
#include "v8/include/v8.h"
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2018-01-10 07:37:05 +00:00
|
|
|
namespace api {
|
|
|
|
|
2020-07-23 21:55:41 +00:00
|
|
|
class InAppPurchase : public gin::Wrappable<InAppPurchase>,
|
|
|
|
public gin_helper::EventEmitterMixin<InAppPurchase>,
|
2019-10-25 13:03:28 +00:00
|
|
|
public in_app_purchase::TransactionObserver {
|
2018-01-10 07:37:05 +00:00
|
|
|
public:
|
2019-10-21 07:05:40 +00:00
|
|
|
static gin::Handle<InAppPurchase> Create(v8::Isolate* isolate);
|
2018-01-10 07:37:05 +00:00
|
|
|
|
2020-07-23 21:55:41 +00:00
|
|
|
// gin::Wrappable
|
|
|
|
static gin::WrapperInfo kWrapperInfo;
|
|
|
|
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
|
|
|
v8::Isolate* isolate) override;
|
|
|
|
const char* GetTypeName() override;
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
InAppPurchase(const InAppPurchase&) = delete;
|
|
|
|
InAppPurchase& operator=(const InAppPurchase&) = delete;
|
|
|
|
|
2018-01-10 07:37:05 +00:00
|
|
|
protected:
|
2020-07-23 21:55:41 +00:00
|
|
|
InAppPurchase();
|
2018-01-10 07:37:05 +00:00
|
|
|
~InAppPurchase() override;
|
|
|
|
|
2019-03-13 20:56:01 +00:00
|
|
|
v8::Local<v8::Promise> PurchaseProduct(const std::string& product_id,
|
2019-10-21 07:05:40 +00:00
|
|
|
gin::Arguments* args);
|
2019-03-13 20:56:01 +00:00
|
|
|
|
|
|
|
v8::Local<v8::Promise> GetProducts(const std::vector<std::string>& productIDs,
|
2019-10-21 07:05:40 +00:00
|
|
|
gin::Arguments* args);
|
2018-01-10 07:37:05 +00:00
|
|
|
|
2018-01-10 07:55:49 +00:00
|
|
|
// TransactionObserver:
|
2018-01-10 08:18:23 +00:00
|
|
|
void OnTransactionsUpdated(
|
|
|
|
const std::vector<in_app_purchase::Transaction>& transactions) override;
|
2017-11-30 13:27:33 +00:00
|
|
|
};
|
|
|
|
|
2018-01-10 07:37:05 +00:00
|
|
|
} // namespace api
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#endif // SHELL_BROWSER_API_ELECTRON_API_IN_APP_PURCHASE_H_
|