Windows 8 In-App Purchases problem

0 favourites
From the Asset Store
The internet is bombarded daily with new apps (app is the short term for application)
  • All,

    I have bit of an issue with my in app purchase.

    I have it configured and handled via Windows 8 component as follows:

    postimg.org/image/ftg858131

    And I did tested in VS2013 base on ALL 3 error returned and 1 OK message. All seems to be working as I want.

    BUT

    App is already in store and while user click to buy in-app and 'Confirm purchase' pops up with description and 'Buy' 'Cancel' buttons - once user click 'Cancel' it returns to app and behave like app was purchased do set varPaied to 1 !!?? I'm not sure what I'm doing wrong as I've tested it in VS and all looks ok in there.

    Any help much appreciated.

    Regards

    E

  • Have you done anything on the on purchase failed event? You may need to in order to make it work correctly.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I did that. It's there. Is 'cancel' different than failed purchase event ?

  • If you press cancel with S_OK selected in test mode, it still succeeds. You need to select a failure return code.

  • Yes I've tested all three failure return codes and in VS it is working while it is not in Store.

    This is the same case described in

    http://www.scirra.com/forum/topic82706_post504504.html#504504

    Looks like 'On successful purchase' and 'On failed purchase' needs to be implemented differently than I did.

    E

  • Help anyone ?

    TEsts in VS pass fine. My app handles all 4 codes one OK and three errors just fine but yet if user download my game and install and then try to buy IAP it triggers 'on successful purchase' even if user click Cancel on first screen

    Evo

  • I have the same problem with product purchase.

    It works fine when you are in test mode in Visual Studio, but in store version (test mode set to 'no' of course) it detects a successful purchase when you just cancel product purchase window (win8.1).

  • Ashley, I think the problem is that when you go into first function of requestProductPurchaseAsync promise, it doesn't mean that you successfully purchased the product. This is from c2runtime.js:

    		this.currentApp["requestProductPurchaseAsync"](productid_, false).then(
    			function () {
    				console.log("[Construct 2] Product '" + productid_ + "' purchased OK");
    				self.runtime.trigger(cr.plugins_.win8.prototype.cnds.OnPurchaseSuccess, self);
    			},
    			function (msg) {
    				console.log("[Construct 2] Product '" + productid_ + "' purchase failed: " + msg);
    				self.runtime.trigger(cr.plugins_.win8.prototype.cnds.OnPurchaseFail, self);
    			});[/code:78nu9hdd]
    
    But it should be checked if you got correct licence as described on msdn help:
    (article: Enable in-app purchases from your app (Windows Store apps using JavaScript and HTML))
    
    [code:78nu9hdd]function buyFeature1() {
        if (!licenseInformation.productLicenses.lookup("featureName").isActive)
        {
            // The customer doesn't own this feature, so 
            // show the purchase dialog.
    								
            // note: currentApp is a reference to CurrentAppSimulator from a previous declaration
            currentApp.requestProductPurchaseAsync("featureName", false).then(
                function () {
                    //Check the license state to determine if the in-app purchase was successful.
                }, 
                function () {
                    // The in-app purchase was not completed because 
                    // there was an error.
                });
        } [/code:78nu9hdd]
    
    I think as the first function is invoked when user presses Cancel on Purchase window (it is not an error) the app handles this as a successful purchase (we talk about in-store app not test mode).
    Could this be the reason behind that working we reported above?
  • I added product checking (Has purchased ...) to On successful purchase condition and now it works properly.

    But some very IMPORTANT thing if you test purchases in Visual Studio: in WindowsStoreProxy.xml you should set IsTrial tag to false and ExpirationDate to a future date. Otherwise as your app is handled as a trial version you cannot buy products, and Has purchased condition returns always with false, even after a successful purchase.

  • lipstick

    I did that too. But solution with (Has purchased ...) is just workaround as please note that:

    "Has product

    Test if a given product ID has been successfully purchased by the user. Note that in some cases this will be false for the first few seconds of the app running even if the user has purchased the item, and then later become true when the store finishes loading the store status in the background. Try to avoid using this condition before On store listing success triggers."

    Source: https://www.scirra.com/manual/173/iap

    Either way I still don't understand why 'On successful purchase' triggers when user hit Cancel while purchasing process in store !?

    On the other hand thehen in his Mortar Melon manage to implement it correct way. I've checked scenario we are facing on his game and it works correctly.

    https://www.scirra.com/tutorials/596/adding-in-app-purchases-to-your-windows-8-game

    Regards

    E

  • Perhaps contrary to 'test mode' it still fires the 'success' handler in the real store, but with 'Has product' returning false. This is at best confusing design on the part of Microsoft, and I'd consider it a bug... but we might be able to work around it.

    I presume it works fine if you add the 'Has product' condition under 'On successful purchase'? And if 'Has product' is false in that trigger, treat it also as a failed purchase.

    If that workaround works we can build it in to the plugin itself.

  • I'm having difficulty getting IAP to work as well. When I was running in test mode it said the product was no longer available. I added events to create graphics if an action completes since I was having difficulty verifying what was happening. Based on the results and the events you can see in the image it looks like Construct is only getting as far as seeing if the Windows Store is online.

    I had made a second in-app purchase offer on the Windows Dev Dashboard to see if my product really wasn't there, but it seems like construct is not even getting the product listing.

    Does anyone have any insight?

  • I think I may have resolved it, testing now, but the Visual Studio solution needed to be associated with an app in the store.

  • sbucci

    Have you resolved it? I can't get IAP to work on Microsoft Store UWP.

  • Associating the app with the Store in Visual Studio was the solution. I haven't gone through it in a while, though, so it may have changed.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)