Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to determine if a product is owned with QT Purchasing?
Forum Updated to NodeBB v4.3 + New Features

How to determine if a product is owned with QT Purchasing?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 2 Posters 250 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dmitriano
    wrote on last edited by Dmitriano
    #1

    What method or property should I use to determine if a product is owned?

    My first idea was that it is Product.status, but it only contains the information on if the product registered or not.

    My second idea was that I receive a callback like onPurchaseSucceeded when my app starts, but I does not, because it is called as the response to product.purchase() call. But it is not clear what to do if a product is bought outside of the app or is already owned (before the app is started first time on a device).

    Currently I am out of ideas :) and looks like I did not understood something well enough.

    My QML code:

    import QtPurchasing 1.14
    
    Store {
        Product {
            id: adfreeProduct
            type: Product.Unlockable
            identifier: "adfree"
    
            onPurchaseSucceeded: {
                console.log(identifier + " purchase successful");
                transaction.finalize();
            }
    
            onPurchaseFailed: {
                console.log(identifier + " purchase failed");
                console.log("reason: "+ transaction.failureReason === Transaction.CanceledByUser ? "Canceled" : transaction.errorString);
                transaction.finalize();
            }
    
            onPurchaseRestored: {
                console.log(identifier + "purchase restored");
                console.log("timestamp: " + transaction.timestamp);
                transaction.finalize();
            }
        }
    }
    

    QT version 5.14.1

    JonBJ 1 Reply Last reply
    0
    • D Dmitriano

      What method or property should I use to determine if a product is owned?

      My first idea was that it is Product.status, but it only contains the information on if the product registered or not.

      My second idea was that I receive a callback like onPurchaseSucceeded when my app starts, but I does not, because it is called as the response to product.purchase() call. But it is not clear what to do if a product is bought outside of the app or is already owned (before the app is started first time on a device).

      Currently I am out of ideas :) and looks like I did not understood something well enough.

      My QML code:

      import QtPurchasing 1.14
      
      Store {
          Product {
              id: adfreeProduct
              type: Product.Unlockable
              identifier: "adfree"
      
              onPurchaseSucceeded: {
                  console.log(identifier + " purchase successful");
                  transaction.finalize();
              }
      
              onPurchaseFailed: {
                  console.log(identifier + " purchase failed");
                  console.log("reason: "+ transaction.failureReason === Transaction.CanceledByUser ? "Canceled" : transaction.errorString);
                  transaction.finalize();
              }
      
              onPurchaseRestored: {
                  console.log(identifier + "purchase restored");
                  console.log("timestamp: " + transaction.timestamp);
                  transaction.finalize();
              }
          }
      }
      

      QT version 5.14.1

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @Dmitriano
      I truly know nothing about this, so there's no point asking me more about it, but: is https://doc.qt.io/qt-5/qtpurchasing-gettingstarted-cpp.html#restoring-previously-purchased-products to do with what you are looking for?

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved