Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
in-app-purchase example — Gideros Forum

in-app-purchase example

unlyingunlying Guru
edited August 2012 in General questions
I'm really-really bad in reading manuals. I know that it is only my problem, but if anybody can share a simple sample with in-app-purchase it will be great.
Just an image that can be purchased and variable become 1 from 0.
I saw code in reference manual, but...
Sorry for my question, but i'm stuck on it and can't go throught.

Likes: krisis

Dislikes: zehreken

+1 -1 (+1 / -1 )Share on Facebook
«1

Comments

  • Game finished, but i stuck on this:(
  • atilimatilim Maintainer
    Accepted Answer
    1. Set up your iTunes connect. You can follow any tutorial. I think Ray Wenderlich's tutorial is really good: http://www.raywenderlich.com/2797/introduction-to-in-app-purchases

    2. In this tutorial, you set a bundle identifier. Change the Gideros Player's bunde id to it and redeploy to your device so that you can do tests with Gideros Player.

    3. Try to retrieve your product list with this code (don't forget to change your product identifiers)
    local function onRequestProductsComplete(event)
        if event.errorCode ~= nil then
            print("error", event.errorCode, event.errorDescription)
            return
        end
     
        print("products:")
        for i=1,#event.products do
            print("title", event.products[i].title)
            print("description", event.products[i].description)
            print("price", event.products[i].price)
            print("productIdentifier", event.products[i].productIdentifier)
        end
     
        print("invalidProductIdentifiers:")
        for i=1,#event.invalidProductIdentifiers do
            print(event.invalidProductIdentifiers[i])
        end
    end
     
    storekit:addEventListener(Event.REQUEST_PRODUCTS_COMPLETE, onRequestProductsComplete)
     
    storekit:requestProducts({
            "com.raywenderlich.inapprage.drummerrage",
            "com.raywenderlich.inapprage.itunesconnectrage", 
            "com.raywenderlich.inapprage.nightlyrage",
            "com.raywenderlich.inapprage.studylikeaboss",
            "com.raywenderlich.inapprage.updogsadness"})
    After you complete these steps, then ask here again for further ones :)

    Likes: mertocan, boriskey

    +1 -1 (+2 / -0 )Share on Facebook
  • I couldnt understand how can we upload items that we will sell ?
  • IAP is only used to sells content, verify a purchase and deal with the monetary transaction. HOW the user gets the purchased content is totally the responsibility of yourself. You either ship it with the app directly and then activate it (this is the usual way I think) OR you load it up to a webspace of your own and then download it to the device via the internet. At no point you can upload your content that you want to sell to apple.
  • phongttphongtt Guru
    edited September 2012
    Afaik, Apple has recently supported hosting contents on their server.
    (But I haven't tried it yet)
  • Afaik, Apple has recently supported hosting contents on their server.
    (But I haven't tried it yet)
    I haven't tried it either, but it's new for iOS 6, so I think if you want to support devices that aren't upgraded to iOS 6, then you won't be able to take advantage of it.

  • I not understant de setp 2

    2. In this tutorial, you set a bundle identifier. Change the Gideros Player's bunde id to it and redeploy to your device so that you can do tests with Gideros Player.

    where i change the bundle id of gideros player?

    Another question..

    I creating a new IAP for my game. a need publish this on app store to test on my divice?

    tks
  • @pedroluis5

    you can change bundle identifier from xcode [summary or info tab] you don't need to publish the app but you have to setup you iap products in itunes also the bundleidentifier must have to be same in both in your xcode and in itunes

    you can take a look at
    http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial

    there is no need to understand coding part as you are using gideros but still worth to look at this

    :)
  • Tks @hgvyas123

    How can i test IAP on gideros player run on iphone?

    This a code:

    require("storekit")

    local function onRequestProductsComplete(event)
    if event.errorCode ~= nil then
    print("error", event.errorCode, event.errorDescription)
    return
    end

    print("products:")
    for i=1,#event.products do
    print("title", event.products[i].title)
    print("description", event.products[i].description)
    print("price", event.products[i].price)
    print("productIdentifier", event.products[i].productIdentifier)
    end

    print("invalidProductIdentifiers:")
    for i=1,#event.invalidProductIdentifiers do
    print(event.invalidProductIdentifiers[i])
    end
    end

    storekit:addEventListener(Event.REQUEST_PRODUCTS_COMPLETE, onRequestProductsComplete)

    storekit:requestProducts({"com.FlipFlopLab.NewSlidePuzzle.UnlockLevels"})


    it always return erro invalidProductIdentifiers.

    On itunes connect the IAD status is ready to submit

    I confuse :)
  • pedroluis5pedroluis5 Member
    edited March 2013
    Now a understand the step 2..i change bundle identifier of gideros player project on xcode. and now work the IAP...tks people :)
  • I have same message:"invalidProductIdentifiers"
    But for me it looks like bundle identifier is ok.
    image
    image
    image
    But
    image
    image
    Снимок экрана 2013-05-24 в 22.11.12.png
    233 x 38 - 11K
    Снимок экрана 2013-05-24 в 22.12.03.png
    472 x 30 - 11K
    Снимок экрана 2013-05-24 в 22.12.19.png
    550 x 31 - 19K
    Снимок экрана 2013-05-24 в 22.13.04.png
    274 x 93 - 14K
    Снимок экрана 2013-05-24 в 22.15.09.png
    432 x 131 - 17K
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2013
    @unlying just to make sure
    your app bundle ID is the same as in-app purchase ID?

    Bundle ID should be the same, as the Id of the app you created your purchase for. So just checking, if it is true? :)

  • unlyingunlying Guru
    edited May 2013
    Yes, i have same id for app and for purchase.

    I know that there is my fault. I just can't understand where it is.
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2013
    I don't know how did you create it.
    If I for example have an app with bundle ID: com.test.mytestapp
    And I create MyTestInApp in-app purchase for it, it's ID will be
    com.test.mytestapp.mytestinapp

    Unfortunately I have no access to IOS account right now, so can't check it.
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2013
    Ahh, silly me.
    It actually means you are ok.
    first it lists the products:
    which you have listed

    then it lists invalid product identifiers, which you don't have:
    print("products:")
    for i=1,#event.products do
        print("title", event.products[i].title)
        print("description", event.products[i].description)
        print("price", event.products[i].price)
        print("productIdentifier", event.products[i].productIdentifier)
    end
     
    print("invalidProductIdentifiers:")
    for i=1,#event.invalidProductIdentifiers do
        print(event.invalidProductIdentifiers[i])
    end
  • Looks like it silly me.
    Thanks @ar2rsawseen
    Where should i put code for successfull purchase?
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2013
    Well, we both missed it :)
    local function onTransaction(event)
     
        if event.transaction.state == StoreKit.FAILED then
    		AlertDialog.new("Error occured", event.errorDescription, "Ok"):show()
        else        
            if event.transaction.state == StoreKit.PURCHASED then
                	--unlock content here
                	AlertDialog.new("Purchase Completed", "Purchase successfully completed", "Ok"):show()
            end
     
            if event.transaction.state == StoreKit.RESTORED then
    	--restore purchase here
            end
     
            -- or you can do it here if purchase and restore is the same for you
        end
     
        storekit:finishTransaction(event.transaction)
    end
    storekit:addEventListener(Event.TRANSACTION, onTransaction)
  • And i have to use call storekit:purchase("com.debia.rebusisto",1), yes?
    I have error:"Can't connect to the iTunes Store".
    App Store works ok.
    Can it be because i don't have a credit card submitted in my Apple ID?
  • ar2rsawseenar2rsawseen Maintainer
    So it can retrieve the list of products, but can't make purchase?

    If list is retrieved it's definitely can connect to iTunes, so the error should be somewhere else. I think it would have brought up the dialog or something to enter credit card information.

    Unfortunately right now I have no idea
  • krisiskrisis Member
    @unlying - are you using an iTunes Test Account and following Apple's guidelines for testing?
    http://developer.apple.com/library/mac/#documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/13_ManagingIn-AppPurchases/ManagingIn-AppPurchases.html#//apple_ref/doc/uid/TP40011225-CH4-SW3

    i.e.
    1) logout of App Store under device settings
    2) build app to device through XCode
    3) when trying to make a purchase it'll specify it's a sandbox environment, then you can use the iTunes Test Account details to complete the purchase.
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • alexzhengalexzheng Guru
    edited June 2013
    And i have to use call storekit:purchase("com.debia.rebusisto",1), yes?
    I have error:"Can't connect to the iTunes Store".
    App Store works ok.
    Can it be because i don't have a credit card submitted in my Apple ID?
    I have the same problem as you when I login with a normal account, but it's ok to purchase when login in with a test account. Maybe it's just because the status is still Waiting for Screenshot.

  • unlyingunlying Guru
    edited August 2013
    I have a problem with my games now. Sometime user pay for in-app, but get nothing. I have same problem in Google Play, but there it isn't so critical( 1)appstore has more payments 2) In google play developer can refund any payments).
    I have about 900 payments for in-app and about 10 reviews+mails about "money left, but no in-game coins".
  • @unlying well apple have huge problems with the servers lately, so there may be lots of problems on the way.

    I remember someone posted on the forum that Apple now requires to put a Restore transactions button somewhere in the app. Most probably just for situations like that, so if user would buy something and not get it, they could try to restore transaction and you could handle it. But that is just a guess.
  • It is consumable. Consumable can't be restored.
    I'm not sure that this problem is on apple side.
    You can read reviews for app here: http://www.appannie.com/app/ios/sostav-slova/reviews/?account_id=67087&page=2
    Many people angry about payments.
  • I don't think that Google In-App Billing will help us with iOS payments.
  • @phongtt @Nascode and anyone else using IOS in-apps experience anything similar?
    Unfortunately I don't have access to IOS dev account right now.
    But if it is a common bug, we need to fix it.
    If for anyone else everything works ok, then we could help @unlying determine where could be a problem
  • People says that after that transaction phone always request password for account on start.
Sign In or Register to comment.