Windows 8 In-App Purchases problem

Get help using Construct 2

Post » Tue Feb 18, 2014 2:40 pm

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

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

http://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
B
6
S
1
G
1
Posts: 20
Reputation: 780

Post » Tue Feb 18, 2014 5:10 pm

Have you done anything on the on purchase failed event? You may need to in order to make it work correctly.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,603

Post » Tue Feb 18, 2014 6:04 pm

I did that. It's there. Is 'cancel' different than failed purchase event ?
B
6
S
1
G
1
Posts: 20
Reputation: 780

Post » Wed Feb 19, 2014 12:37 am

If you press cancel with S_OK selected in test mode, it still succeeds. You need to select a failure return code.
Scirra Founder
B
399
S
236
G
89
Posts: 24,541
Reputation: 195,426

Post » Wed Feb 19, 2014 7:09 am

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
B
6
S
1
G
1
Posts: 20
Reputation: 780

Post » Wed Feb 26, 2014 7:19 pm

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
B
6
S
1
G
1
Posts: 20
Reputation: 780

Post » Sun Mar 02, 2014 7:26 am

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).
Last edited by lipstick on Sun Mar 02, 2014 3:34 pm, edited 1 time in total.
B
7
S
1
Posts: 9
Reputation: 448

Post » Sun Mar 02, 2014 8:30 am

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:

Code: Select all
      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);
         });


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: Select all
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.
            });
    }


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? :roll:
Last edited by lipstick on Sun Mar 02, 2014 3:30 pm, edited 2 times in total.
B
7
S
1
Posts: 9
Reputation: 448

Post » Sun Mar 02, 2014 3:27 pm

I added product checking (Has purchased ...) to On successful purchase condition and now it works properly.

But some very IMPORTANT :idea: 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.
B
7
S
1
Posts: 9
Reputation: 448

Post » Mon Mar 03, 2014 12:54 pm

@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
B
6
S
1
G
1
Posts: 20
Reputation: 780

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Cubeeo, jezjones24 and 13 guests