Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  3. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Xiaomi IAP FAQs

Discussion in 'Unity IAP' started by unityjingyao, Aug 8, 2017.

  1. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    38
    Unity partner page:
    https://unity3d.com/partners/xiaomi
    Xiaomi developer quick start guide:
    https://unity3d.com/partners/xiaomi/guide
    Unity IAP Xiaomi integration guide:
    https://docs.unity3d.com/Manual/UnityIAPXiaomi.html
    Unity Channel SDK and API extensions:
    https://docs.unity3d.com/Manual/UnityIAPXiaomiAPI.html


    1. How may I test Xiaomi Mi Game Pay for Unity IAP (Xiaomi IAP)?

    If you set appInfo.debug to true when initializing Xiaomi IAP, you'll be able to test Xiaomi IAP without real money.
    If you want to test real purchasing, you must set appInfo.debug to false. Please note that real purchasing requires a Xiaomi Mi Account and appropriate currency such as Chinese Yuan.
    You can create a Mi Account on a Xiaomi device or Xiaomi official page: https://account.xiaomi.com

    2. I found an "Unavailable product..." log message and OnInitializeFailed() was fired with an InitializationFailureReason.NoProductsAvailable reason.
    Xiaomi IAP needs an IAP Catalog for product metadata before purchase.
    Configure all your products in [Window > Unity IAP > IAP Catalog].
    And then export the products by clicking "App Store Export -> Xiaomi Mi Game Pay Catalog".
    This step will export all products to "Assets\Plugins\Android\assets\MiGameProductCatalog.prop" which will be read by the Xiaomi SDK.

    [​IMG]

    [​IMG]


    3. How can I see the Xiaomi IAP log?
    In Android Studio, you can filter log with "(/Unity)|(/MiGameSDK)".
    [​IMG]

    4. How to restore my products in Xiaomi store?
    Xiaomi IAP doesn't have "Restore" feature. If a user bought a non-consumable product and reinstalled your game, when he/she tries to buy again, OnPurchaseFailed() will be fired with a PurchaseFailureReason.DuplicateTransaction reason.
    More information can be found in the Xiaomi IAP doc.
    [​IMG]


    5. What version of Unity should I use if I want to integrate Xiaomi IAP?
    Xiaomi IAP supports 5.3+.

    6. I can't buy a product when I set appInfo.debug to true, I found a "3001" error code in logcat printed by Xiaomi SDK.
    [​IMG]
    "3001" means "product doesn't exist". Please contact with Xiaomi to check your product IDs.

    7. When should our game make the call to login into the StoreService? Just before the player makes a purchase or rather at game startup?
    [​IMG]
    (* Copied from IAPDemo.cs)
    You just need to make sure that players login successfully before you call InitiatePurchase(). So both before the player makes a purchase and game startup are OK. It's up to you.

    8. I tried to sign in with Mi Account on my device, I have an error in unityChannelLoginHandler.loginFailedAction with "User Login Failed:-400" in the log.
    Please contact with Xiaomi to confirm that your products have been configured.

    9. We need the link to redirect player to the review page of the store during the game.
    You can use "market://details?id=your package name" as an Intent to redirect player to the review page of Xiaomi store.


    Other Tips

    1. Google Play services are not allowed in Xiaomi store.

    2. Xiaomi IAP needs an extra login step which other app stores don't have. Please refer to Q7.

    3. App package name must end with ".mi".

    4. The prices must follow the tiers of Xiaomi IAP. All tiers can be found in "IAP Catalog" window. [Window -> Unity IAP -> IAP Catalog]
     
    Last edited: Dec 11, 2017
    ap-unity, rpistorello and nicholasr like this.
  2. pl_ayground

    pl_ayground

    Joined:
    Dec 17, 2015
    Posts:
    41
    Is there any chance this update makes some AliPay (or Xiaomi) related code get into the Xcode project? I got my app rejected by Apple stating AliPay is being used.
     
  3. hippogames

    hippogames

    Joined:
    Feb 5, 2015
    Posts:
    22
    Hi! I've got the following error when pressing "Generate Unity Client"
    How can I get error details?
     

    Attached Files:

  4. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    38
  5. hippogames

    hippogames

    Joined:
    Feb 5, 2015
    Posts:
    22
    Thanks! Seems I have no some kind of access to this project, and this is producing HTTP error. Anyway, I'll request all required perissions from my game publisher.
     
  6. hippogames

    hippogames

    Joined:
    Feb 5, 2015
    Posts:
    22
    And one more question. Can I add "Xiaomi Mi Game Center" from Build Settings instead of importing plugin? Because both they are producing conflicts. Are those plugins will be equal?
     
  7. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    38
    Hi @hippogames
    You might get a conflict in some versions of Unity if you add both "Xiaomi Mi Game Center" from Build Settings and Unity IAP plugin. This is a known issue and we'll fix it.
    "Xiaomi Mi Game Center" is different from Unity IAP plugin.
    Xiaomi requires that your game must have Xiaomi SDK integrated.
    "Xiaomi Mi Game Center" is used for a game that doesn't have IAP and it only has Xiaomi SDK.
    Unity IAP has already integrated "Xiaomi Mi Game Center"(or Xiaomi SDK).
    So if you have IAP in your game, please use Unity IAP.
     
  8. Klamore74

    Klamore74

    Joined:
    Jun 17, 2013
    Posts:
    19
    Hi,

    I try to integrate IAP for xiaomi but I have an error

    I fill up the "AppStoreSettings" create by "Asset/Create/App Store Settings" with all data and I try the class UnityChannelSample as descrive on google document "https://docs.google.com/document/d/1VjKatN5ZAn6xZ1KT_PIvgylmAKcXvKvf4jgJqi3OuuY/edit#" but I receive the following error, I'm missing somethings?

    Code (CSharp):
    1. Exception: JNI: Init'd AndroidJavaClass with null ptr!
    2. UnityEngine.AndroidJavaClass..ctor (IntPtr jclass) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:622)
    3. UnityEngine.AndroidJavaObject.get_JavaLangClass () (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:600)
    4. UnityEngine.AndroidJavaObject.FindClass (System.String name) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:591)
    5. UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:611)
    6. UnityEngine.AndroidJavaClass..ctor (System.String className) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/AndroidJavaBindings.gen.cs:92)
    7. UnityEngine.Store.StoreService..cctor ()
    8. Rethrow as TypeInitializationException: An exception was thrown by the type initializer for UnityEngine.Store.StoreService
    9. UnityChannelSample.Start () (at Assets/UnityChannelSample.cs:47)