summaryrefslogtreecommitdiffstats
path: root/examples/demos/hangman/doc/src/qtpurchasing-overview.qdoc
blob: 150c617b58196dcde1040fd4bfd343039503b890 (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
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
   \example demos/hangman
   \title In-App purchasing demo
   \brief A complete mobile application that demonstrates purchasing in-app products.
   \ingroup qtpurchasing-examples
   \ingroup android-examples


   \section1 What is this demo?
   \image qthangman-example.png

   This demo is a mobile game application based on the classic word guessing game
   Hangman, where vowels can be purchased through the demo's internal store. In the
   game you will be presented with a row of dashes, representing letters of the
   word to guess. By guessing a correct letter that occurs in the given word, the
   letter will be placed on the corresponding dash or dashes in the word. By
   guessing every letter of the word or just guessing the whole word correctly at
   any time the game is over and you heve won. If the guess is wrong, one element
   of a hanging stick figure is drawn. Once the figure is complete, you are out of
   guesses and you lose.

   The demo shows how it is possible to offer in-app products inside a Qt
   application, for the Android and iOS platforms. In order to test the in-app
   purchase functionality in the the demo, you must first register the application
   and its products in the external store. For an introduction on how to do this,
   see the guides for \l{Registering Products in Google Play}{Google Play} and \l{Registering Products in App Store}{App Store} respectively.

   \section1 3rd party app stores

   The in-app products must be registered in the target stores, before they
   can be queried or purchased in an application. We recommend using the same
   identifiers for the products in each store, as it simplifies the code to
   query and purchase the products.

   \list
   \li \l{Registering Products in Google Play}
   \li \l{Registering Products in App Store}
   \endlist

   \section1 How does the demo work
   The demo is a QML application that registers QML types to access information
   about in-app products, as well as to request purchases for those products.
   These are registered in the external store for the target platform

   In-app purchasing are added to application by first adding a Store object. In
   the demo the Store object is created by the MainView component that is loaded
   on application startup.
   \snippet demos/hangman/qml/MainView.qml 0

   The demo defines a component for displaying a store for purchasing in-app
   products made available. These products must be first registered with the
   store object we created above in MainView. There are two products available,
   the first being a consumable type.

   \snippet demos/hangman/qml/StoreView.qml 0

   This consumable product provides 100 additional vowels to be used when
   guessing words in the game. When it is successfully purchased, we update the
   state of the application to include 100 additional vowels. Then we call
   finalize() on the transaction object to confirm to the platform store that the
   consumable product has been provided.

   The second product is a non-consumable type that will unlock vowels permanently
   in the future. In addition to updating the application state on purchase, we
   must make sure to provide a way to restore this purchase on other devices used
   by the end user. In this case we create a signal handler for onPurchaseRestored.

   \snippet demos/hangman/qml/StoreView.qml 1

   \image qthangman-store-example.png

   In addition to registering the products, the demo also provide an interface to
   actually purchase the registered product. The demo defines a custom component
   called \c StoreItem to display and handle the purchasing interaction.

   \snippet demos/hangman/qml/StoreView.qml 1

   The StoreItem component will display the product data that is queried from the
   platform's store, and will call the purchase() method on the product when it is
   clicked by the user.

   \snippet demos/hangman/qml/StoreItem.qml 0

   If you are planning to use QML in your project with purchasing functionality,
   check out
   \l{Getting Started with Qt Purchasing in QML}.

   Android and iOS use the base classes. From base classes there are derivative
   classes for android and ios:

   \list
   \li \l{Base Classes}
   \li \l{Demo Android Classes}
   \li \l{Demo iOS Classes}
   \endlist

   \section1 In-App purchases

   In-app purchases are a way to monetize an application. These purchases are
   made from inside the application and can include anything from unlocking
   content to virtual items. The demo uses the system APIs
   for in-app purchases, which means the purchase process is more familiar to
   the user, and the information already stored by the platform (such as credit
   card information) can be used to simplify the purchase process.

   \section1 Licenses and attributions

   In regards to deploying the demo on Android see
   \l Android GNU C++ Run-time Licensing for more information.
*/