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
    @Saxi For sure if you're serving downloadable content or modelling an online virtual economy you should call the RVS web services from your servers since you will get an up to date purchase status that includes events like refunds or chargebacks.

    However having code like

    if (remote validation routine succeeds)

    in your client is no more secure than

    if (local validation routine succeeds)

    since, as you say, your if statement is liable to be patched on your insecure client.
     
  2. Saxi

    Saxi

    Joined:
    Jun 28, 2013
    Posts:
    381
    Likelihood of them forging Apple servers (which is easy to do with downloadable software and network hacks is much easier, more common, and more likely than them modifying binaries.
     
  3. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @Saxi Right, in which case you're better off writing your own local validation routine with Open SSL which will be faster and won't go wrong when your network drops in between getting the response from Apple and forwarding it on to your own validation server.
     
  4. BeardOfFury

    BeardOfFury

    Joined:
    Sep 4, 2012
    Posts:
    18
    Has anyone had any difficulties with Unibill/Prime31? I'm using Prime31 Chartboost, Admob, and Social. For some reason I'm able to initiate purchases in Unibill but the purchase complete events aren't firing.

    Edit: This is only occurring on Android as far as I can tell
     
  5. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @BeardOfFury You'll want to look at the trace from the device using adb.
     
  6. BeardOfFury

    BeardOfFury

    Joined:
    Sep 4, 2012
    Posts:
    18
    @Banderous

    That seems to be as far as it gets. The java side is getting the callback, but returning that to Unity looks to be where it fails. Seems like Prime31 may be interfering with the onActivityResult call.
     
    Last edited: Jan 19, 2015
  7. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @BeardOfFury Check that Unibill's game object is not being destroyed along the way somewhere.
     
  8. JLITTLEOFFICIAL

    JLITTLEOFFICIAL

    Joined:
    Oct 13, 2012
    Posts:
    8
    Hey Banderous, I'm having issues with getting the products to be in my game. I'm getting the no products returned error, which I looked at, at the documentation for GOOGLE_PLAY_NO_PRODUCTS_RETURNED. I have my game as a production ready to be publish state, google play is updated to its latest, bundle app id and google service id is the same, as well as the version code. I made sure the id string for the purchaseditem was the same. At this point, I'm not sure what else to do. I'm not sure if I'm missing anything else unless I have to wait like most who had this problem.
     
  9. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
  10. JLITTLEOFFICIAL

    JLITTLEOFFICIAL

    Joined:
    Oct 13, 2012
    Posts:
    8
    oh ok, so it cant be published to a production apk? (Which would have the status be ready to publish)

    I figured that would be okay, considering its the final step. Okay, thanks.

    I'm going to check and test this out.
     
  11. JLITTLEOFFICIAL

    JLITTLEOFFICIAL

    Joined:
    Oct 13, 2012
    Posts:
    8
    Yeah, no matter what, I get the same thing, when I login, the logcat returns NO PRODUCTS RETURNED with the OnSetupComplete(False). I'm pretty sure I'm doing everything.
     
  12. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @JLITTLEOFFICIAL It needs to be published, that doesn't mean it will be visible if it's alpha/beta. It can take 24 hours to start working from that point.
     
  13. JLITTLEOFFICIAL

    JLITTLEOFFICIAL

    Joined:
    Oct 13, 2012
    Posts:
    8
    Oh okay, yeah I published the google play services beta and I'll wait to see if it works.
     
  14. JLITTLEOFFICIAL

    JLITTLEOFFICIAL

    Joined:
    Oct 13, 2012
    Posts:
    8
    Hey Banderous, Good news, yeah I just had to publish the apk to beta and wait. You were great help man. If I have anything else, I'll ask.
     
  15. BeardOfFury

    BeardOfFury

    Joined:
    Sep 4, 2012
    Posts:
    18
    @Banderous Ok figured out what it was. The Prime31 Etcetera plugin has a method for showing a native progress dialog. This seems to be putting the app into background state and the callbacks aren't getting through. I'll just have to make our own progress dialog. Thanks for the help!
     
  16. jofa

    jofa

    Joined:
    Jan 11, 2013
    Posts:
    6
    This works for me:

    Code (CSharp):
    1.     /**
    2.      * GooglePlay receipt looks like: {"json":"{\"orderId\":\"129xxxx.yyyy\",\"packageName\":\"com.my.game\",\"productId\":\"coins\",\"purchaseTime\":142,\"purchaseState\":0,\"purchaseToken\":\"aaa\"}","developerPayload":"","signature":"..=="}
    3.      */
    4.     public string getOrderId(string receipt) {
    5.  
    6.         Dictionary<string, object> dic = (Dictionary<string, object>) Unibill.Impl.MiniJSON.jsonDecode(receipt);
    7.  
    8.         string jsonKey = "json";
    9.         if (!dic.ContainsKey(jsonKey)) {
    10.             return string.Empty;
    11.         }
    12.  
    13.         string orderJson = dic[jsonKey].ToString();
    14.         Dictionary<string, object> vals = (Dictionary<string, object>) Unibill.Impl.MiniJSON.jsonDecode(orderJson);
    15.  
    16.         string orderKey = "orderId";
    17.         if (vals.ContainsKey(orderKey)) {
    18.             return vals[orderKey].ToString();
    19.         }
    20.  
    21.         return string.Empty;
    22.     }
    23.  
     
  17. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    I'm having a problem overriding my purchasableItems ID. In the Unibill Inventory Editor. I define The main purchasable item's Id as "IAP_ipad". Then under the AppleAppStore and MacAppStore I Check "Override" and I define the ids as "IAP_mac". But those overrides are never used and Unibill only looks for "IAP_ipad"

    I call Unibiller.Initialise(); but it seems like in onBillerReady(), Unibiller.GetPurchaseCount() is returning a product count of 0.

    Also what is the difference between "AppleAppStore" and "MacAppStore"?

    Code (JSON):
    1. {
    2.  
    3.   "*******": "*******",
    4.   "macAppStoreSKU": "************",
    5.   "androidBillingPlatform": "GooglePlay",
    6.   "GooglePlayPublicKey": "[Your key]",
    7.   "useAmazonSandbox": false,
    8.   "UseWP8MockingFramework": false,
    9.   "useHostedConfig": false,
    10.   "hostedConfigUrl": null,
    11.   "UseWin8_1Sandbox": false,
    12.   "samsungAppsMode": "PRODUCTION",
    13.   "samsungAppsItemGroupId": "",
    14.   "unibillAnalyticsAppId": "",
    15.   "unibillAnalyticsAppSecret": "",
    16.   "purchasableItems": {
    17.     "IAP_ipad": {
    18.       "@id": "IAP_ipad",
    19.       "@purchaseType": "Subscription",
    20.       "name": "Online Multiplayer Service",
    21.       "description": "Play online cross-platform games for two months. Includes the use of three additional multiplayer only boards.",
    22.       "downloadableContentId": null,
    23.       "platforms": {
    24.         "GooglePlay": {},
    25.         "AmazonAppstore": {},
    26.         "SamsungApps": {},
    27.         "AppleAppStore": {
    28.           "appleAppStorePriceTier": 1.0,
    29.           "screenshotPath": "",
    30.           "AppleAppStore.Id": "IAP_mac"
    31.         },
    32.         "MacAppStore": {
    33.           "MacAppStore.Id": "IAP_mac"
    34.         },
    35.         "WindowsPhone8": {},
    36.         "Windows8_1": {},
    37.         "UnityEditor": {}
    38.       }
    39.     }
    40.   },
    41.   "currencies": {}
    42. }
     
  18. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan The Apple app store is for iOS, the Mac app store is for OSX.

    You have overridden both stores to have the same identifier which is not possible; Apple does not allow reuse between the stores.

    I suggest you upgrade Unibill if you're not on the latest version, there was once an override related bug that affected the mac app store.
     
  19. NoseKills

    NoseKills

    Joined:
    Jun 4, 2013
    Posts:
    25
    A quick question that has probably been asked before but I couldn't find it with search...

    @Banderous is it OK to Debit and Credit Virtual currencies when Unibill initialized with state UnibillState.SUCCESS_WITH_ERRORS or UnibillState.CRITICAL_ERROR ?

    The DOCs only talk about "purchases" which might be misleading since some devs consider using Virtual Currencies to buy game items (debit) to be "purchases" as well. Might be useful to clarify this in the docs under initialisation perhaps.
     
  20. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @NoseKills It's fine to call the currency related methods as soon as you have called initialise and regardless of Unibill's state, the docs should indeed be clearer here.
     
  21. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    I just upgraded but the mac store override still doesn't work.

    The main purchasable item's Id as "MPservice". Then under the MacAppStore I Check "Override" and I define the id as "MPservice_mac". But that override is never used and Unibill only looks for "MPservice"

    But no biggie, as I'm using Prime31 Storekit for iOS App Store and Unibill for Mac Store, So I just set the main purchasable item's Id as "MPservice_mac" and don't use any overrides and everything works fine.
     
  22. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    I just upgraded to the latest version. Has onPurchaseCompleteEvent been removed from the latest version? I need onPurchaseCompleteEvent because in my onPurchaseComplete callback I finish up my IAP internally by calling another routine:

    Code (CSharp):
    1. private void onPurchaseComplete(PurchaseEvent e)
    2.     {
    3.         registerServiceAsBought(e.PurchasedItem.Id);
    4.     }
    If onPurchaseCompleteEvent no longer exists how can I call my registerServiceAsBought routine when the purchase completes?


     
  23. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    For a Mac build, when I run Unibill in the editor calling Unibiller.Initialise() successfully initializes, but when in a built Mac app it gives a CRITICAL_ERROR. What could be causing that?

    note: ‘Mac App Store validation’ within Unity’s build settings is selected.
     
  24. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @TokyoDan onPurchaseCompleteEvent is the new event.

    There are extensive steps for testing on the Mac App store, you can also check the Unity player log for diagnostics.
     
  25. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Thank you. I got it working. I was using the Mac App Store asset to automate those steps for me.
     
    Last edited: Jan 31, 2015
  26. plokkum

    plokkum

    Joined:
    May 28, 2013
    Posts:
    90
    I have been using Unibill for over a year now and am super happy with it.
    I do have a question though, that I can't really seem to get solved :)

    What would be the procedure to validate restored purchases?

    If someone buys a non-consumable item, uninstall/reinstall the app and restores their purchase, is there any way to check for its validity? Since there is no trace of a transaction ID or anything, I'm thinking it is impossible, am I right? Of course you could create a user account and store their information online, but I don't want any of my paying consumers having to deal with any hassle at all.
     
  27. plokkum

    plokkum

    Joined:
    May 28, 2013
    Posts:
    90
    Another quick question, I'm trying to wrap my head around this.
    I'm using Unibiller.InitiatePurchase(itemID) to purchase an item. Once purchased, I verify the receipt on my web server and Unibiller.purchaseCount(itemID) shows 1.

    However, when I restart my app and check the purchaseCount again, Unibiller returns 0. I'm not using Unibiller.clearTransactions() anywhere. What could be the reason for this?

    Edit: After fiddling around with this for a while, it seems to be working on the device, just not in the editor. Is this normal behavior? In the editor it is only keeping track of the purchaseCount in the sessions where the purchase was made.
     
    Last edited: Feb 1, 2015
  28. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    329
    Anyone using Unibill on Unity 5 beta, I seem to be getting some manifest errors.

    Error: [AndroidManifest.xml] Failed to write XML file: javax.xml.transform.TransformerException: java.io.FileNotFoundException: C:\ (The system cannot find the path specified)
     
  29. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @plokkum Unibiller.restoreTransactions() will replay purchase history, including receipts.

    Re: purchaseCount, the demo scene uses that API and is working fine, I suggest you test it and verify that purchase counts as displayed are tracked correctly.

    @Zilk at what point does that error occur? Is there a stack trace?
     
  30. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    329
    @Banderous These are the errors I get when building Android apk with Unity 5 b21.

    Error: [AndroidManifest.xml] Failed to write XML file: javax.xml.transform.TransformerException: java.io.FileNotFoundException: C:\ (The system cannot find the path specified)

    Error: [C:\#Workfolders\Privat\Unity\Pull My Tongue\Temp\StagingArea\AndroidManifest.xml] Failed to write manifest file.

    CommandInvokationFailure: Unable to merge android manifests. See the Console for more details.
    C:\Program Files\Java\jdk1.7.0_71\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Users/VisualDreams 3/AppData/Local/Android/android-sdk\tools" -Dfile.encoding=UTF8 -jar "C:/Program Files/Unity 5.0.0b21/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -

    stderr[
    Error: [AndroidManifest.xml] Failed to write XML file: javax.xml.transform.TransformerException: java.io.FileNotFoundException: C:\ (The system cannot find the path specified)
    Error: [C:\#Workfolders\Privat\Unity\Pull My Tongue\Temp\StagingArea\AndroidManifest.xml] Failed to write manifest file.
    ]
    stdout[

    ]
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommand (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
     
  31. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @Zilk are you sure that error is Unibill related? It looks like a problem with one of Unity's build steps.
     
  32. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    329
    @Banderous I had it building before I added the Unibill SDK. Although now I see that there is a warning before the errors that might be related.

    OBSOLETE - Providing Android resources in Assets/Plugins/Android/res is deprecated, please move your resources to an Android Library. See "Building Plugins for Android" section of the Manual.
     
  33. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @Zilk There are no manifests in the res folder; Unibill doesn't provide manifests for merging but modifies your main manifest directly. Are you using other plugins? You might try importing Unibill into a blank project.
     
  34. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    329
    @Banderous Tried it on a clean project but get the same error when building. Have you tried Unibill on Unity 5 Beta 21?
     
  35. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @Zilk not yet, we don't currently have access to it. Try taking a look at the editor log.
     
  36. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    329
    @Banderous I've tried to figure out what goes wrong from the info I get from the log but I'm at a total loss here. Here is a screenshot from the full log when building.

    Capture.PNG
     
  37. plokkum

    plokkum

    Joined:
    May 28, 2013
    Posts:
    90
  38. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Dose Unibill run when testing in the Unity Editor?
     
  39. Banderous

    Banderous

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

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Yes. I have. Hundreds of times. But is is so fats that I can't tell if it is really working of spoofing. I read your email. Thanks.
     
  41. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    329
    @Banderous Found the issue, it was nothing Unibill related (I think). I had the project in c:\#Workfolders\Project and the merger didn't like the #. Stupid issue :p
     
  42. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    I just installed Unibill for the first time but I got these errors :

    Assets/script/UnibillDemo.cs(126,29): error CS1729: The type `ComboBox' does not contain a constructor that takes `0' arguments
    Assets/script/UnibillDemo.cs(151,33): error CS1061: Type `ComboBox' does not contain a definition for `GetSelectedItemIndex' and no extension method `GetSelectedItemIndex' of type `ComboBox' could be found (are you missing a using directive or an assembly reference?)
    Assets/script/UnibillDemo.cs(153,33): error CS1061: Type `ComboBox' does not contain a definition for `List' and no extension method `List' of type `ComboBox' could be found (are you missing a using directive or an assembly reference?)

    Any idea?
     
    Last edited: Feb 4, 2015
  43. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    I found the problem! I have another component which have a ComboBox!

    Changed all ComboBox references to Unibill.Demo.ComboBox and now it works!
     
  44. NateJC

    NateJC

    Joined:
    Apr 10, 2012
    Posts:
    58
    I just bought Unibill from the Unity Asset Store. I tried importing it into my pre-existing Unity 4.6.2 project, but I'm getting numerous errors similar to this one:
    Assets/Plugins/unibill/src/impl/Biller.cs(64,20): error CS1061: Type `ILogger' does not contain a definition for `prefix' and no extension method `prefix' of type `ILogger' could be found (are you missing a using directive or an assembly reference?)

    I looked at the ILogger interface and indeed, it does not include a definition for "prefix". However, I see that UnityLogger (which implements ILogger) does. Is there a reason why this definition isn't in the interface? I'm surprised I am getting these errors on a fresh import of the Unibill project. Am I missing something? Thanks in advance.
     
  45. NateJC

    NateJC

    Joined:
    Apr 10, 2012
    Posts:
    58
    I turns out we had two ILogger.cs files (there was another one in Plugins > com > fu > interface). There were a couple of places where "using Uniject;" was missing so they weren't playing nice. All is well now.
     
  46. Saxi

    Saxi

    Joined:
    Jun 28, 2013
    Posts:
    381
    I just started using Unibill, and one thing I find very frustrating and how it scatters all over the place in the file system.

    It would be really great if you can use a parent folder Unibill and put everything there. You can have your Editor scripts in there as well, it becomes very difficult to update and remove if removing Unibill from a project and make sense of it since it scatters like 10 folders all over the project.
     
  47. s2quinnh

    s2quinnh

    Joined:
    Sep 16, 2014
    Posts:
    10
    I imported a fresh install into an empty Unity Project in Unity 4.6.0 just to test the Demo Scene and for some reason when it loaded on the Amazon Fire HD it would keep crashing and loading repeatedly. I found out that there was 2 <receiver> blocks in the Plugins/Android/AndroidManifest.xml file, the 1.0 and 2.0 versions. I removed the 1.0 version which has "com.amazon.inapp.purchasing.ResponseReceiver" in it and it worked!

    Hopefully that helps other lost souls.

    EDIT: Here's the Amazon v1.0 to v2.0 transitioning documentation that helped me figure out what was happening: https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs-v2/migrate-iapv1-apps-to-iapv2
     
    Last edited: Feb 6, 2015
  48. NateJC

    NateJC

    Joined:
    Apr 10, 2012
    Posts:
    58
    Is there a way to overwrite a product id at runtime through code (rather then using the inventory window)?
    I want to use a compiler flag to change it.
     
  49. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @NateJC You can modify the inventory json file programmatically.
     
  50. s2quinnh

    s2quinnh

    Joined:
    Sep 16, 2014
    Posts:
    10
    This is a small thing, but I noticed there's a "Unibill DLC id" in the Inventory Editor, but is not explained in the documentation at all. It's found in a Purchasable Item.

    Would be nice to be fully documented: http://outlinegames.com/documentation.html

    Thanks!