Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Introducing Unibill - the cross platform In App purchase plugin!

Discussion in 'Assets and Asset Store' started by Banderous, Jan 16, 2013.

  1. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @Drowning Monkeys yes it need to be installed. It's that app that your app talks to; follow the steps in the unibill docs.
     
  2. digO

    digO

    Joined:
    Mar 20, 2014
    Posts:
    23
    How can i create a pop up dialog like "Do you want to purchase 100 Gold for $0.99?", something like that.

    I just bought unibill a few days ago, when i use the unibillDemo scene and i click to buy its automatically don't show any pop up dialog.
     
  3. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @digO That only shows up on device. The editor uses a fake billing implementation.
     
  4. digO

    digO

    Joined:
    Mar 20, 2014
    Posts:
    23
    @Banderous thanks man, but if i run the scene on my device it doesn't appear too, i need to upload the metadata do itunes connect and it will start appear?
     
  5. WPCJack

    WPCJack

    Joined:
    Mar 15, 2013
    Posts:
    26
    @Banderous

    Hey I got this email from google -
    Beginning January 2015, we will end support for the In-app Billing Version 2 API. After this date, users will no longer be able to make in-app purchases using your app until you upgrade your app to use the Version 3 API.

    Not exactly a huge rush I know, just wondering what version of the API is currently in use, and when it might be updated if it is v2.

    Cheers,
     
  6. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @digO if you look at the trace from the device then Unibill will not be fully initialised. Yes you need to upload your data as per the instructions.

    @WPCJack this appears to be an error on Google's part. We received the same email for our test app, Unibill has not used the V2 API in a year or so.
     
  7. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    The last update I made to my app on Amazon I used their live app testing environment and it works well (essentially it is like the beta releases on google play or windows phone). Just wanted to mention this because the tester app crashes on some of my dev kindles so it was never ideal for me in the first place. Obviously this feature is relatively new for Amazon but is worth checking out. It's always good testing against the production infrastructure for IAP before releasing and I'm glad they've added beta distributions makes it easier to test.
     
  8. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @greggtwep16 yes that does sound good. The inability to test as live on amazon was a real pain.
     
  9. KonstantinBotnar

    KonstantinBotnar

    Joined:
    Sep 19, 2014
    Posts:
    2
    HI, guys.
    Could you tell me please, if I can get the reason of purchase failing that does not concern wrong product id (i.e. if user has not input credit card number in AppStore settings)?
     
  10. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
  11. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    For Mac App Store purchases how does Unibill handle Receipt verification? Prime31 has:
    // Validates the Mac App Store receipt
    public static bool validateMacAppStoreReceipt()
     
  12. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan Unibill does not provide a routine for receipt validation. It will provide the latest app receipt with each purchase event, however, if you wish to validate it yourself.
     
  13. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    @Banderous Doe it have something to do with the "Mac App Store Validation" in the Player Settings of the Mac Standalone build?
     
  14. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan That is required for the Mac App Store. When enabled, Unity does a check for a valid store receipt and terminates the process with a specific error code if it is not found. This error code is a signal for the Mac App store to prompt the user to sign in.

    It's all you need to get an app into the mac app store.
     
  15. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    @Banderous So just checking that is enough for handling purchase receipt validation for the Mac App Store?

    For iOS (with Prime 31 Storekit) I had to buy the Simple IAP System, customize the heck out of it to work with how I implemented Prime31 Storekit, upload a PHP file to Google App Engine, and go through all kinds of changes to find the Receipt and have it properly relayed via that PHP file on GAE to Apple's verification servers. What a pain that was.
     
  16. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan It depends what you're trying to do. If you need server side verification of receipts then that's what you should continue to do.

    As far as Apple's store policy goes, the validation routine built into unity is sufficient to get your app working.
     
  17. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    @Banderous I am just wondering why Unibill has fewer callbacks than Prime31 Storekit has, and how Unibill handles the ones that it does not implement:

    --- These have Unibill equivalents:
    StoreKitManager.purchaseSuccessfulEvent Unibiller.onPurchaseCompleteEvent
    StoreKitManager.purchaseCancelledEvent Unibiller.onPurchaseCancelled
    StoreKitManager.purchaseFailedEvent Unibiller.onPurchaseFailed
    StoreKitManager.restoreTransactionsFailedEvent Unibiller.onTransactionsRestored
    StoreKitManager.restoreTransactionsFinishedEvent Unibiller.onTransactionsRestored

    --- below here there are no Unibill equivalents:

    StoreKitManager.transactionUpdatedEvent
    StoreKitManager.productPurchaseAwaitingConfirmationEvent
    StoreKitManager.paymentQueueUpdatedDownloadsEvent

    StoreKitManager.productListReceivedEvent
    StoreKitManager.productListRequestFailedEvent
    -------------------------------------------------------------------------------------------------
    Not having the last two makes me a bit concerned.
    Also what is the difference between 'onPurchaseCompleteEvent' and 'onPurchaseComplete'?
     
  18. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    This is stated in the documentation:
    --------------------------------------------------------
    "The following snippet initialises Unibill, makes a purchase and works across all seven platforms."
    Unibiller.onBillerReady += (state) => {
    if (UnibillState.SUCCESS == state) {
    Unibiller.initiatePurchase(Unibiller.AllPurchasableItems[0]);
    }
    };
    -------------------------------------------------------
    Is that statement correct? Isn't this code snippet setting up the callback for 'Unibiller.Initialise()'?
    And am I correct in thinking that 'onBillerReady()' won't be called until 'Unibiller.Initialise()' is executed?
     
  19. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    Hi - been building my game using Unity 4.6 Beta 19 and been getting a strange issue. When I'm building for iOS or Android, the ICSharpCode.SharpZipLib.dll keeps getting renamed to ICSharpCode.SharpZipLib.dll.rename without creating a new one (which I'm guessing its meant to do?)

    I can get around it by reimporting Unibill, but its quite annoying and breaks when my team pulls the code as as soon as they open Unity, the file is renamed.

    Just thought I'd highlight it - I know we're in beta and things may go wrong, so if there is no fix for now, thats fine.
     
  20. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan Unibill handles the product list retrieval for you. It will update your inventory with localised price, title etc. If any of your products are unavailable, it will generate an error to warn you.

    onPurchaseComplete is deprecated and will be removed.

    Re: code snippet, yes a line was missing. Now fixed - thanks.

    @kujo the rename should only happen if you publish to windows platforms. What platform are you targeting?
     
  21. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Where can I see that error? What function returns the error? In Unibiller.onBillerReady() ?
     
  22. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan Any errors are printed to the console. They can also be inspected with the Unibiller.Errors property.
     
  23. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Thanks. I'm more concerned about how to handle it in code than seeing it in the console.
     
  24. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    Those errors indicate configuration errors; you'd fix them during development rather than handle them in the field.
     
  25. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    @Banderous I got everything working except for one hitch:

    I have set up a Subscription type IAP (in iTunes Connect and in Unibill Inventory Editor).

    The problem is that Unibill seems to handle the Subscription Purchase Type as an Auto-Renewable Subscription (and you correctly treat this in your code as a consumable). How do I know this? Well, it is because my IAP is a Non-Renewing Subscription which has an expiration date. I keep track of this expiration date internally and if the subscription has expired I give the user another chance to purchase this IAP. When my code tries to re-purchase this via Unibill, I get "ignoring multi-purchase of non consumable".

    This happens both when testing in Unity editor and with a fully signed and packaged app going to Mac App Store Sandbox.

    This is a problem because Non-Renewing Subscriptions are treated by apple the same as a consumables.

    Therefore, If the subscription has indeed expired the user should be allowed to purchase it again. And even if the subscription HAS NOT expired the user should be allowed (as fas as Apple is concerned) to purchase it. It's up to me, the developer, to keep track of that: i.e. If a user buys a new (or expired) one-month subscription, the one month period starts from the purchase date. If the user buys (accidentally or on purpose) an UNEXPIRED one-month subscription, it is up to me to warn the user, and if he chooses to buy it I just have to extend the expiration date by adding one month to the expiration date of his currently valid subscription.

    Simply put. I really need another selection and handling in Unibill: The ability to set the IAP Purchase Type to NON-RENEWING SUBSCRIPTION and for it to be handled like a consumable. If this can't be done I am afraid that I can't use Unibill.
     
    Last edited: Sep 28, 2014
  26. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan this is fixed in 1.7.3 which I'll send to you.
     
  27. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Great. Thanks!
     
  28. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    @Banderous - Yes, I'm targeting Windows Phone.
     
  29. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @kujo the rename should happen when building for windows platforms, and rename back on other platforms. If you have both the rename and .dll files it could cause an issue, fixable by deleting one.
     
  30. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    @Banderous - when I build with windows, it renames the file, but I get a FileNotFoundException which ends up spamming the console window every time a script recompiles. As I say, this may be a beta issue - if it is, don't worry about it, just highlighting a potential problem
     
  31. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @kujo I think I've fixed the cause of the FileNotFoundException.
     
  32. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    @Banderous - awesome. If its a script change, I can test it out for you if you want?
     
  33. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
  34. guylenats

    guylenats

    Joined:
    Jun 4, 2014
    Posts:
    2
    hi,

    we are using your unibill library but alot of things are not clear or cant find anywhere in your documentation

    Question:
    will the response from play store, apple store and the other supported stores will return the same datastructure?

    if not, do you have info on what they will return?
    if yes, do you have info what is the data structure?

    we are designing our database to store this data
    right now we cant find any info on this

    do we need to capture and separate the data for each of the stores ourselves
    or unibill already doing this and giving us something more consistent

    please help

    thanks
     
  35. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Does anyone know how to get around this?

    I am using Unibill for OSX Standalone builds, and Prime31 Storekit for iOS builds...in the same project.
    Of course I am using platform dependent compilation directives in my source code to include/exclude the corresponding function calls to the corresponding libraries. But I still get this error when I build to iOS.

    "Error building Player: SystemException: Duplicate native method found : _storeKitRequestProductData. Please check your source carefully."

    I think this is due to both the Unibill and Prime31 libraries being in the project at the same time. When I call StoreKitBinding.requestProductData(), Unity doesn't know which _storeKitRequestProductData to link in.

    Is there a solution to this without having to make two unique projects? (Maybe there is a way to have Unity, at build time, exclude the Unibill assets in my Project.)
     
  36. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
  37. Afroman

    Afroman

    Joined:
    Aug 17, 2013
    Posts:
    43
    Apple Pay just came out. Any chance your going to implement it?
     
  38. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @Afroman Apple Pay is for physical goods, not In App Purchases.
     
  39. Bentlman1981

    Bentlman1981

    Joined:
    Jun 24, 2014
    Posts:
    9
    Hello, could someone show me how I would update something after purchase?

    1. Unibiller.getPurchasableItemById("unibill item id").PurchaseCount
    I understand I initialize in first scene and then I use the initiate purchase method. After that do I call this? And if so how do I check it so that I can do something like if (purchased) update this playerpref?

    I apologize i feel like once I get this I will feel so stupid. Maybe its simplicity is confusing me.

    New to coding here and maybe that is it. I appreciate any help.

    EDIT : Looking back on this question is quit humorous now. Unibill is the best. In app purchases are trivial now.
     
    Last edited: Nov 5, 2014
  40. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @Bentlman1981

    if (Unibiller.getPurchasableItemById("unibill item id").PurchaseCount > 0) {
    // item is owned
    }

    You don't need to update another playerpref, just ask unibill every time.
     
  41. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Dynamic inventory

    Can I use this new Dynamic Inventory function of Unibill 1.7.5 for my In-App-Purchase (in Mac App Store) without having to add my IAP to the unibillInventory.json file via the Inventory Editor?
     
  42. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan Yes, that's the purpose of the dynamic inventory. It works across all platforms.
     
  43. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    It doesn't work. I get a Unibill not initialized error.
    So I don't need to set ANYTHING in the Inventory Editor? Not even the Mac App Store SKU?

    This is the only thing I'm doing:

    var prods = newList<ProductDefinition>()
    {
    newProductDefinition(
    "TOTonlineMpService17",
    PurchaseType.Subscription
    )
    };
    Unibiller.Initialise(prods);
     
  44. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    If Unibill initialization state != SUCCESS how can i manually get the error information?

    CRITICAL_ERROR

    Unibill was unable to initialise. Details of the error will have been printed to the console, or you can retrieve them manually. You should not attempt to make any purchases.
     
  45. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan Unibiller.Errors gives you the details.

    You still need to define your application configuration, such as SKU, this feature is just to allow you to have a dynamic list of saleable products.

    Note there is a bug in the current Unibill version that will throw an exception if you attempt to supply runtime products that you have already defined in the inventory editor. This will be fixed in the next update.
     
  46. TegTap-In

    TegTap-In

    Joined:
    Apr 23, 2013
    Posts:
    5
    I'm having a hard time understanding this:

    "As of Unibill 1.1.4, Unibill uses Google Play billing V3. With Google Play Billing V3, all the products that you create should be of type ‘managed’. Unibill will manage consumption of items for you; if you designate an item as being of type ‘Consumable’ within the inventory editor, Unibill will automatically consume the item before registering the purchase. For details of how to manually define your purchases follow Google’s guide."​

    I have a couple apps that need to be updated for billing v3. For my consumable items, do I change the type to "managed" in the inventory editor only?

    I can't change them from "unmanaged" to "managed" in the Google Play Developer Console, so what would happen if I change them to "managed" in the inventory editor only?

    If I leave them "consumable" in the inventory editor, does that mean as of Unibill v1.1.4 the user could get the items even if the purchase failed?

    In short, I need to update to Play Billing v3, and I don't know how to do it.
     
  47. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TegTap In you should find that unibill works as before when you update it. Google play will treat your unmanaged product as managed when used from the v3 API.
     
  48. TegTap-In

    TegTap-In

    Joined:
    Apr 23, 2013
    Posts:
    5
    Thanks. Just to be clear: I change my consumable products to "managed" in the inventory editor, but (out of necessity) leave my product as "unmanaged" in the Google Play Developer console. Correct?
     
  49. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TegTap In Your products should still be marked as 'consumable' in the inventory editor; there is no 'managed' option. You can leave them as 'unmanaged' and in fact have no option to change them to managed, as you state.

    In short, to upgrade to V3 you simply need to import the latest version of Unibill into your project, no other changes are necessary.
     
    TegTap-In likes this.
  50. silviobadseed

    silviobadseed

    Joined:
    Nov 28, 2013
    Posts:
    32
    Hi Banderous,

    I recently updated Unibill and I'm having some issues with Google IAP.
    First I got this log error:

    Code (CSharp):
    1. 11-13 14:19:06.603: I/Unity(21488): UnibillBiller: Finished poll for consumables, completing init.
    2. 11-13 14:19:06.603: I/Unity(21488):
    3. 11-13 14:19:06.603: I/Unity(21488): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 49)
    4. 11-13 14:19:06.653: I/Unity(21488): KeyNotFoundException: The given key was not present in the dictionary.
    5. 11-13 14:19:06.653: I/Unity(21488):   at System.Collections.Generic.Dictionary`2[System.String,System.Object].get_Item (System.String key) [0x00000] in <filename unknown>:0
    6. 11-13 14:19:06.653: I/Unity(21488):   at Unibill.Impl.MiniJsonExtensions.getHash (System.Collections.Generic.Dictionary`2 dic, System.String key) [0x00000] in <filename unknown>:0
    7. 11-13 14:19:06.653: I/Unity(21488):   at Unibill.Impl.GooglePlayBillingService.onPollForConsumablesFinished (System.String json) [0x00000] in <filename unknown>:0
    8. 11-13 14:19:06.653: I/Unity(21488):   at GooglePlayCallbackMonoBehaviour.onPollForConsumablesFinished (System.String result) [0x00000] in <filename unknown>:0
    I found that the following line of code in GooglePlayBillingServices.cs

    Code (CSharp):
    1. var ownedItems = response.getHash ("ownedItems");
    uses a method
    Code (CSharp):
    1. getHash
    that doesn't check if the dictionary contains the key.
    I fixed it but I'm having an other log error when I try to purchase a product:

    Code (CSharp):
    1. 11-13 15:29:54.643: I/Unity(28296): AndroidJavaException: java.lang.NullPointerException
    2. 11-13 15:29:54.643: I/Unity(28296):   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0
    3. 11-13 15:29:54.643: I/Unity(28296):   at UnityEngine.AndroidJNISafe.CallVoidMethod (IntPtr obj, IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <filename unknown>:0
    4. 11-13 15:29:54.643: I/Unity(28296):   at UnityEngine.AndroidJavaObject._Call (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
    5. 11-13 15:29:54.643: I/Unity(28296):   at UnityEngine.AndroidJavaObject.Call (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
    6. 11-13 15:29:54.643: I/Unity(28296):   at Unibill.Impl.RawGooglePlayInterface.purchase (System.String json) [0x00000] in <filename unknown>:0
    7. 11-13 15:29:54.643: I/Unity(28296):   at Unibill.Impl.GooglePlayBillingService.purchase (System.String item, System.String developerPayload) [0x00000] in <filename unknown>:0
    8. 11-13 15:29:54.643: I/Unity(28296):   at Unibill.Biller.purchase (.PurchasableItem item, System.String developerPayload) [0x00000] in <filename unknown>:0
    9. 11-13 15:29:54.643: I/Unity(28296):   at Unibiller.initiatePurchase (.PurchasableItem purchasable, System.String developerPayload) [0x00000] in <filename unknown>:0
    I set the Unibill Inventory editor correctly and I double checked with Debug.Log if it's all right till the
    Code (CSharp):
    1. RawGooglePlayInterface.purchase
    . There's nothing wrong but in the native code as you can see from the log there's a NullPointerExcetion thrown.

    Is there anything I can do to fix this issue?

    Thank you in advance!