1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Purchasing module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3-COMM$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#include "qinappproduct.h"
30
31QT_BEGIN_NAMESPACE
32
33class QInAppProductPrivate
34{
35public:
36 QInAppProductPrivate(const QString &price, const QString &title, const QString &description, QInAppProduct::ProductType type, const QString &id)
37 : localPrice(price)
38 , localTitle(title)
39 , localDescription(description)
40 , productType(type)
41 , identifier(id)
42 {
43 }
44
45 QString localPrice;
46 QString localTitle;
47 QString localDescription;
48 QInAppProduct::ProductType productType;
49 QString identifier;
50};
51
52/*!
53 \class QInAppProduct
54 \inmodule QtPurchasing
55 \brief A product registered in the store.
56
57 QInAppProduct encapsulates a product in the external store after it has been registered in \c QInAppStore
58 and confirmed to exist. It has an identifier which matches the identifier of the product in the external
59 store, it has a price which is retrieved from the external store, and it has a product type.
60
61 The product type can be either \c Consumable or \c Unlockable. The former type of products can be purchased
62 any number of times as long as each transaction is finalized explicitly by the application. The latter type
63 can only be purchased once.
64 */
65
66/*!
67 * \internal
68 */\
69QInAppProduct::QInAppProduct(const QString &price, const QString &title, const QString &description, ProductType productType, const QString &identifier, QObject *parent)
70 : QObject(parent)
71{
72 d = QSharedPointer<QInAppProductPrivate>(new QInAppProductPrivate(price, title, description, productType, identifier));
73}
74
75/*!
76 * \internal
77 */\
78QInAppProduct::~QInAppProduct()
79{
80}
81
82/*!
83 \property QInAppProduct::price
84
85 This property holds the price of the product as reported by the external store. This is the full
86 price including currency, usually in the locale of the current user.
87*/
88QString QInAppProduct::price() const
89{
90 return d->localPrice;
91}
92
93/*!
94 * \property QInAppProduct::title
95 *
96 * This property holds the title of the product as reported by the external store. This title is returned from the
97 * store in the locale language if available.
98 */
99QString QInAppProduct::title() const
100{
101 return d->localTitle;
102}
103
104/*!
105 * \property QInAppProduct::description
106 *
107 * This property holds the description of the product as reported by the external store. This description is returned
108 * from the store in the locale language if available.
109 */
110QString QInAppProduct::description() const
111{
112 return d->localDescription;
113}
114
115/*!
116 \property QInAppProduct::identifier
117
118 This property holds the identifier of the product. It matches the identifier which is registered in
119 the external store.
120*/
121QString QInAppProduct::identifier() const
122{
123 return d->identifier;
124}
125
126/*!
127 \enum QInAppProduct::ProductType
128
129 This enum type is used to specify the product type when registering the product.
130
131 \value Consumable The product is consumable, meaning that once the transaction for a purchase of
132 the product has been finalized, it can be purchased again.
133 \value Unlockable The product is unlockable, meaning that it can only be purchased once per
134 user. Purchases of unlockable products can be restored using the \l{QInAppStore::restorePurchases()}.
135*/
136
137/*!
138 \property QInAppProduct::productType
139
140 This property holds the type of the product. This can either be \c Consumable or \c Unlockable. The
141 former are products which can be purchased any number of times (granted that each transaction is
142 explicitly finalized by the application first) and the latter are products which can only be purchased
143 once per user.
144 */
145QInAppProduct::ProductType QInAppProduct::productType() const
146{
147 return d->productType;
148}
149
150/*!
151 * \fn void QInAppProduct::purchase()
152 *
153 * Launches the purchase flow for this product. The purchase is done asynchronously. When the purchase has
154 * either been completed successfully or failed for some reason, the QInAppStore instance containing
155 * this product will emit a QInAppStore::transactionReady() signal with information about the transaction.
156 *
157 * \sa QInAppTransaction
158 */
159
160QT_END_NAMESPACE
161

source code of qtpurchasing/src/purchasing/inapppurchase/qinappproduct.cpp