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.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_IN_APP_PURCHASE_H_
|
|
|
|
#define ELECTRON_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
|
|
|
|
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"
|
2024-07-29 17:42:57 +00:00
|
|
|
#include "v8/include/v8-forward.h"
|
|
|
|
|
|
|
|
namespace gin {
|
|
|
|
template <typename T>
|
|
|
|
class Handle;
|
|
|
|
} // namespace gin
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
namespace electron::api {
|
2018-01-10 07:37:05 +00:00
|
|
|
|
2024-09-05 02:26:25 +00:00
|
|
|
class InAppPurchase final : public gin::Wrappable<InAppPurchase>,
|
|
|
|
public gin_helper::EventEmitterMixin<InAppPurchase>,
|
|
|
|
private 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
|
|
|
};
|
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
} // namespace electron::api
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_IN_APP_PURCHASE_H_
|