Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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



  • 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



  • @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?



  • @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?


Log in to reply