Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 5e2798961fe52ae2e6d5465624b36ff1 > files > 21

qtpurchasing5-doc-5.12.6-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qinappstore.cpp -->
  <title>QInAppStore Class | Qt Purchasing 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtpurchasing-index.html">Qt Purchasing</a></td><td ><a href="qtpurchasing-module.html">C++ Classes</a></td><td >QInAppStore</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtpurchasing-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#using-the-qinappstore">Using the QInAppStore</a></li>
<li class="level2"><a href="#types-of-purchases">Types of purchases</a></li>
<li class="level2"><a href="#restoring-purchases">Restoring purchases</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QInAppStore Class</h1>
<!-- $$$QInAppStore-brief -->
<p>The main entry point for managing in-app purchases. <a href="#details">More...</a></p>
<!-- @@@QInAppStore -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QInAppStore&gt;</span>
</td></tr></table></div><ul>
<li><a href="qinappstore-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#QInAppStore">QInAppStore</a></b>(QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#dtor.QInAppStore">~QInAppStore</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#registerProduct">registerProduct</a></b>(QInAppProduct::ProductType <i>productType</i>, const QString &amp;<i>identifier</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QInAppProduct *</td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#registeredProduct">registeredProduct</a></b>(const QString &amp;<i>identifier</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#restorePurchases">restorePurchases</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#setPlatformProperty">setPlatformProperty</a></b>(const QString &amp;<i>propertyName</i>, const QString &amp;<i>value</i>)</td></tr>
</table></div>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#productRegistered">productRegistered</a></b>(QInAppProduct *<i>product</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#productUnknown">productUnknown</a></b>(QInAppProduct::ProductType <i>productType</i>, const QString &amp;<i>identifier</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#transactionReady">transactionReady</a></b>(QInAppTransaction *<i>transaction</i>)</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qinappstore.html#staticMetaObject-var">staticMetaObject</a></b></td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QInAppStore-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The main entry point for managing in-app purchases.</p>
<p><a href="qinappstore.html">QInAppStore</a> is used for managing in-app purchases in your application in a cross-platform way.</p>
<a name="using-the-qinappstore"></a>
<h3 id="using-the-qinappstore">Using the QInAppStore</h3>
<p>In general there are two steps to completing an in-app purchase using the API:</p>
<a name="initialize-the-store"></a>
<h4 id="initialize-the-store">Initialize the store</h4>
<p>Upon start-up of your application, connect all signals in <a href="qinappstore.html">QInAppStore</a> to related slots in your own QObject. Then use the <a href="qinappstore.html#registerProduct">registerProduct</a>() function to register the ID of each product you expect to find registered in the external store, as well as its type.</p>
<p>Registering a product is asynchronous, and will at some point yield one of the following two signals: 1. <a href="qinappstore.html#productRegistered">productRegistered</a>() if the product was found in the external store with a matching type. 2. <a href="qinappstore.html#productUnknown">productUnknown</a>() if the product was not found in the external store with the type you specified.</p>
<p>In addition, a <a href="qinappstore.html#transactionReady">transactionReady</a>() signal may be emitted for any existing transaction which has not yet been finalized. At this point, you should check if the transaction has previously been registered. If it hasn't, register it right away. Finally, call <a href="qinapptransaction.html#finalize">QInAppTransaction::finalize</a>() on the transaction.</p>
<a name="complete-a-purchase"></a>
<h4 id="complete-a-purchase">Complete a purchase</h4>
<p>Once the items have been successfully registered in the store, you can purchase them. Get the previously registered <a href="qinappproduct.html">QInAppProduct</a> using <a href="qinappstore.html#registeredProduct">registeredProduct</a>() and call <a href="qinappproduct.html#purchase">QInAppProduct::purchase</a>(). This call is also asynchronous.</p>
<p>At some point later on, the <a href="qinappstore.html#transactionReady">transactionReady</a>() signal will be emitted for the purchase. Check <a href="qinapptransaction.html#status-prop">QInAppTransaction::status</a>() to see if the purchase was completed successfully. If it was, then you must save the information about the purchase in a safe way, so that the application can restore it later.</p>
<p>When you are done, call <a href="qinapptransaction.html#finalize">QInAppTransaction::finalize</a>(), regardless of its status. Transactions which are not finalized will be emitted again the next time your application calls <a href="qinappstore.html#registerProduct">registerProduct</a>() for the same product.</p>
<p><b>Note: </b>Please mind that <a href="qinappstore.html">QInAppStore</a> does not save the purchased state of items in the store for you. The application should store this information in a safe way upon receiving the <a href="qinappstore.html#transactionReady">transactionReady</a>() signal, before calling <a href="qinapptransaction.html#finalize">QInAppTransaction::finalize</a>().</p><a name="types-of-purchases"></a>
<h3 id="types-of-purchases">Types of purchases</h3>
<p>There are two types of purchases supported by <a href="qinappstore.html">QInAppStore</a>: <a href="qinappproduct.html#ProductType-enum">QInAppProduct::Consumable</a> and <a href="qinappproduct.html#ProductType-enum">QInAppProduct::Unlockable</a>. The former will be consumed when the transaction is completed and <a href="qinapptransaction.html#finalize">QInAppTransaction::finalize</a>() is called, meaning that it can be purchased again, any number of times. Unlockable items can only be purchased once.</p>
<p>Consumable products are temporary and can be purchased multiple times. Examples could be a day-ticket on the bus or a magic sword in a computer game. Note that when purchasing the same product multiple times, you should call <a href="qinapptransaction.html#finalize">QInAppTransaction::finalize</a>() on each transaction before you can purchase the same product again.</p>
<p>Unlockable products are products that a user will buy once, and the purchase of these items will be persistent. It can typically be used for things like unlocking content or functionality in the application.</p>
<a name="restoring-purchases"></a>
<h3 id="restoring-purchases">Restoring purchases</h3>
<p>If your application has unlockable products, and does not store the purchase states of these products in a way which makes it possible to restore them when the user reinstalls the application, you should provide a way for the user to restore the purchases manually.</p>
<p>Call the <a href="qinappstore.html#restorePurchases">restorePurchases</a>() function to begin this process. Granted that the remote store supports it, you will then at some point get <a href="qinappstore.html#transactionReady">transactionReady</a>() for each unlockable item which has previously been purchased by the current user.</p>
<p>Save the purchase state of each product and call <a href="qinapptransaction.html#finalize">QInAppTransaction::finalize</a>() as you would for a regular purchase.</p>
<p>Since <a href="qinappstore.html#restorePurchases">restorePurchases</a>() may, on some platforms, cause the user to be prompted for their password, it should usually be called as a reaction to user input. For instance applications can have a button in the UI which will trigger <a href="qinappstore.html#restorePurchases">restorePurchases</a>() and which users can hit manually if they have reinstalled the application (or installed it on a new device) and need to unlock the features that they have previously paid for.</p>
<p><b>Note: </b>This depends on support for this functionality in the remote store. If the remote store does not save the purchase state of unlockable products for you, the call will yield no <a href="qinappstore.html#transactionReady">transactionReady</a>() signals, as if no products have been purchased. Both the Android and OS X / iOS backends support restoring unlockable products.</p></div>
<!-- @@@QInAppStore -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QInAppStore[overload1]$$$QInAppStoreQObject* -->
<h3 class="fn" id="QInAppStore"><a name="QInAppStore"></a>QInAppStore::<span class="name">QInAppStore</span>(<span class="type">QObject</span> *<i>parent</i> = nullptr)</h3>
<p>Constructs a <a href="qinappstore.html">QInAppStore</a> with the given <i>parent</i>.</p>
<!-- @@@QInAppStore -->
<!-- $$$~QInAppStore[overload1]$$$~QInAppStore -->
<h3 class="fn" id="dtor.QInAppStore"><a name="dtor.QInAppStore"></a><code>[virtual] </code>QInAppStore::<span class="name">~QInAppStore</span>()</h3>
<p>Destroys the <a href="qinappstore.html">QInAppStore</a>.</p>
<!-- @@@~QInAppStore -->
<!-- $$$productRegistered[overload1]$$$productRegisteredQInAppProduct* -->
<h3 class="fn" id="productRegistered"><a name="productRegistered"></a><code>[signal] </code><span class="type">void</span> QInAppStore::<span class="name">productRegistered</span>(<span class="type"><a href="qinappproduct.html">QInAppProduct</a></span> *<i>product</i>)</h3>
<p>This signal is emitted when information about a <i>product</i> has been collected from the remote store. It is emitted as a reaction to a <a href="qinappstore.html#registerProduct">registerProduct</a>() call for the same product.</p>
<p><b>See also </b><a href="qinappstore.html#productUnknown">productUnknown</a>().</p>
<!-- @@@productRegistered -->
<!-- $$$productUnknown[overload1]$$$productUnknownQInAppProduct::ProductTypeconstQString& -->
<h3 class="fn" id="productUnknown"><a name="productUnknown"></a><code>[signal] </code><span class="type">void</span> QInAppStore::<span class="name">productUnknown</span>(<span class="type"><a href="qinappproduct.html#ProductType-enum">QInAppProduct::ProductType</a></span> <i>productType</i>, const <span class="type">QString</span> &amp;<i>identifier</i>)</h3>
<p>This signal is emitted when the product named <i>identifier</i> was registered using <a href="qinappstore.html#registerProduct">registerProduct</a>() and matching information could not be provided by the remote store. The <i>productType</i> matches the product type which was originally passed to <a href="qinappstore.html#registerProduct">registerProduct</a>().</p>
<p><b>See also </b><a href="qinappstore.html#productRegistered">productRegistered</a>().</p>
<!-- @@@productUnknown -->
<!-- $$$registerProduct[overload1]$$$registerProductQInAppProduct::ProductTypeconstQString& -->
<h3 class="fn" id="registerProduct"><a name="registerProduct"></a><span class="type">void</span> QInAppStore::<span class="name">registerProduct</span>(<span class="type"><a href="qinappproduct.html#ProductType-enum">QInAppProduct::ProductType</a></span> <i>productType</i>, const <span class="type">QString</span> &amp;<i>identifier</i>)</h3>
<p>Registers a product identified by <i>identifier</i> and with the given <i>productType</i>. The <i>identifier</i> must match the identifier of the product in the remote store. If the remote store differentiates between consumable and unlockable products, the <i>productType</i> must also match this.</p>
<p>Calling this function will asynchronously yield either a <a href="qinappstore.html#productRegistered">productRegistered</a>() or a <a href="qinappstore.html#productUnknown">productUnknown</a>() signal. It may also yield a <a href="qinappstore.html#transactionReady">transactionReady</a>() signal if there is a pending transaction for the product which has not yet been finalized.</p>
<p><b>Note: </b>This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.</p>
<!-- @@@registerProduct -->
<!-- $$$registeredProduct[overload1]$$$registeredProductconstQString& -->
<h3 class="fn" id="registeredProduct"><a name="registeredProduct"></a><span class="type"><a href="qinappproduct.html">QInAppProduct</a></span> *QInAppStore::<span class="name">registeredProduct</span>(const <span class="type">QString</span> &amp;<i>identifier</i>) const</h3>
<p>Returns the previously registered product uniquely known by the <i>identifier</i>.</p>
<p><b>Note: </b>This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.</p>
<!-- @@@registeredProduct -->
<!-- $$$restorePurchases[overload1]$$$restorePurchases -->
<h3 class="fn" id="restorePurchases"><a name="restorePurchases"></a><span class="type">void</span> QInAppStore::<span class="name">restorePurchases</span>()</h3>
<p>Requests existing purchases of unlockable items and will yield a <a href="qinappstore.html#transactionReady">transactionReady</a>() signal for each unlockable product that the remote store confirms have previously been purchased by the current user.</p>
<p>This function can typically be used for restoring unlockable products when the application has been reinstalled and lost the saved purchase states.</p>
<p><b>Note: </b>Calling this function may prompt the user for their password on some platforms.</p><p><b>Note: </b>This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.</p>
<!-- @@@restorePurchases -->
<!-- $$$setPlatformProperty[overload1]$$$setPlatformPropertyconstQString&constQString& -->
<h3 class="fn" id="setPlatformProperty"><a name="setPlatformProperty"></a><span class="type">void</span> QInAppStore::<span class="name">setPlatformProperty</span>(const <span class="type">QString</span> &amp;<i>propertyName</i>, const <span class="type">QString</span> &amp;<i>value</i>)</h3>
<p>Sets the platform specific property given by <i>propertyName</i> to <i>value</i>. This can be used to pass information to the platform implementation. The properties will be silently ignored on other platforms.</p>
<p>Currently, the only supported platform property is &quot;AndroidPublicKey&quot; which is used by the Android backend to verify purchases. If it is not set, purchases will be accepted with no verification. (You can also do the verification manually by getting the signature from the <a href="qinapptransaction.html">QInAppTransaction</a> object for the purchase.) For more information, see <a href="http://developer.android.com/google/play/billing/billing_integrate.html#billing-security">the Android documentation for billing security</a>.</p>
<p><b>Note: </b>This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.</p>
<!-- @@@setPlatformProperty -->
<!-- $$$transactionReady[overload1]$$$transactionReadyQInAppTransaction* -->
<h3 class="fn" id="transactionReady"><a name="transactionReady"></a><code>[signal] </code><span class="type">void</span> QInAppStore::<span class="name">transactionReady</span>(<span class="type"><a href="qinapptransaction.html">QInAppTransaction</a></span> *<i>transaction</i>)</h3>
<p>This signal is emitted whenever there is a <i>transaction</i> which needs to be finalized. It is emitted either when a purchase request has been made for a product, when <a href="qinappstore.html#restorePurchases">restorePurchases</a>() has been called and the product was previously purchased, or when <a href="qinappstore.html#registerProduct">registerProduct</a>() was called for a product and there was a pending transaction for the product which had not yet been finalized.</p>
<!-- @@@transactionReady -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>