summaryrefslogtreecommitdiffstats
path: root/examples/demos/hangman/purchasing/inapp/inapppurchasebackend.h
blob: c0766bec7544604c33964cd47e2e4cc47e7f0f2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef INAPPPURCHASEBACKEND_H
#define INAPPPURCHASEBACKEND_H

#include <QObject>

#include "inappproduct.h"

QT_BEGIN_NAMESPACE

class InAppProduct;
class InAppTransaction;
class InAppStore;
class InAppPurchaseBackend : public QObject
{
    Q_OBJECT
public:
    struct Product
    {
        Product(InAppProduct::ProductType type, const QString &id)
            : productType(type), identifier(id)
        {
        }

        InAppProduct::ProductType productType;
        QString identifier;
    };

    explicit InAppPurchaseBackend(QObject *parent = 0);

    virtual void initialize();
    virtual bool isReady() const;

    virtual void queryProducts(const QList<Product> &products);
    virtual void queryProduct(InAppProduct::ProductType productType, const QString &identifier);
    virtual void restorePurchases();

    virtual void setPlatformProperty(const QString &propertyName, const QString &value);

    void setStore(InAppStore *store) { m_store = store; }
    InAppStore *store() const { return m_store; }

Q_SIGNALS:
    void ready();
    void transactionReady(InAppTransaction *transaction);
    void productQueryFailed(InAppProduct::ProductType productType, const QString &identifier);
    void productQueryDone(InAppProduct *product);

private:
    InAppStore *m_store;
};

#endif // INAPPPURCHASEBACKEND_H