summaryrefslogtreecommitdiffstats
path: root/src/purchasing/inapppurchase/qinappproduct.cpp
blob: 4556d240cdfc2d85ebdac532772ff303604fceff (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Purchasing module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3-COMM$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qinappproduct.h"

QT_BEGIN_NAMESPACE

class QInAppProductPrivate
{
public:
    QInAppProductPrivate(const QString &price, const QString &title, const QString &description, QInAppProduct::ProductType type, const QString &id)
        : localPrice(price)
        , localTitle(title)
        , localDescription(description)
        , productType(type)
        , identifier(id)
    {
    }

    QString localPrice;
    QString localTitle;
    QString localDescription;
    QInAppProduct::ProductType productType;
    QString identifier;
};

/*!
   \class QInAppProduct
   \inmodule QtPurchasing
   \brief A product registered in the store

   QInAppProduct encapsulates a product in the external store after it has been registered in \c QInAppStore
   and confirmed to exist. It has an identifier which matches the identifier of the product in the external
   store, it has a price which is retrieved from the external store, and it has a product type.

   The product type can be either \c Consumable or \c Unlockable. The former type of products can be purchased
   any number of times as long as each transaction is finalized explicitly by the application. The latter type
   can only be purchased once.
 */

/*!
 * \internal
 */\
QInAppProduct::QInAppProduct(const QString &price, const QString &title, const QString &description, ProductType productType, const QString &identifier, QObject *parent)
    : QObject(parent)
{
    d = QSharedPointer<QInAppProductPrivate>(new QInAppProductPrivate(price, title, description, productType, identifier));
}

/*!
 * \internal
 */\
QInAppProduct::~QInAppProduct()
{
}

/*!
  \property QInAppProduct::price

  This property holds the price of the product as reported by the external store. This is the full
  price including currency, usually in the locale of the current user.
*/
QString QInAppProduct::price() const
{
    return d->localPrice;
}

/*!
 * \property QInAppProduct::title
 *
 * This property holds the title of the product as reported by the external store.  This title is returned from the
 * store in the locale language if available.
 */
QString QInAppProduct::title() const
{
    return d->localTitle;
}

/*!
 * \property QInAppProduct::description
 *
 * This property holds the description of the product as reported by the external store.  This description is returned
 * from the store in the locale language if available.
 */
QString QInAppProduct::description() const
{
    return d->localDescription;
}

/*!
  \property QInAppProduct::identifier

  This property holds the identifier of the product. It matches the identifier which is registered in
  the external store.
*/
QString QInAppProduct::identifier() const
{
    return d->identifier;
}

/*!
  \enum QInAppProduct::ProductType

  This enum type is used to specify the product type when registering the product.

  \value Consumable The product is consumable, meaning that once the transaction for a purchase of
  the product has been finalized, it can be purchased again.
  \value Unlockable The product is unlockable, meaning that it can only be purchased once per
  user. Purchases of unlockable products can be restored using the \l{QInAppStore::restorePurchases()}.
*/

/*!
 \property QInAppProduct::productType

 This property holds the type of the product. This can either be \c Consumable or \c Unlockable. The
 former are products which can be purchased any number of times (granted that each transaction is
 explicitly finalized by the application first) and the latter are products which can only be purchased
 once per user.
 */
QInAppProduct::ProductType QInAppProduct::productType() const
{
    return d->productType;
}

/*!
 * \fn void QInAppProduct::purchase()
 *
 * Launches the purchase flow for this product. The purchase is done asynchronously. When the purchase has
 * either been completed successfully or failed for some reason, the QInAppStore instance containing
 * this product will emit a QInAppStore::transactionReady() signal with information about the transaction.
 *
 * \sa QInAppTransaction
 */

QT_END_NAMESPACE