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"
|
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"
|
2019-10-21 07:05:40 +00:00
|
|
|
#include "shell/common/gin_helper/event_emitter.h"
|
2019-11-01 06:10:32 +00:00
|
|
|
#include "shell/common/gin_helper/promise.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 {
|
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
class InAppPurchase : public gin_helper::EventEmitter<InAppPurchase>,
|
|
|
|
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
|
|
|
|
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
2017-11-30 13:27:33 +00:00
|
|
|
|
2018-01-10 07:37:05 +00:00
|
|
|
protected:
|
|
|
|
explicit InAppPurchase(v8::Isolate* isolate);
|
|
|
|
~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;
|
2018-01-10 07:55:49 +00:00
|
|
|
|
2018-01-10 07:37:05 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(InAppPurchase);
|
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_
|