Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Official Using the UDP Sandbox [why, what and how]

Discussion in 'Unity Distribution Portal (UDP)' started by stevetaylor74, Dec 15, 2020.

  1. stevetaylor74


    Unity Technologies

    Aug 13, 2020
    Hello everyone -

    Since we made sandbox testing a mandatory step to release your game on UDP, a mounting number of questions around the UDP Sandbox began to arise. This is why we improved the sandbox environment in the latest package, added more guidance directly in the UDP Console (look under the “Sandbox Testing” section), and created this forum post to shed light on what needs to be done and why.

    Update: we created a short tutorial video about the UDP Sandbox. Give it a look and post any question you'd have in this thread.

    (Latest UDP Package is version 2.1.4 available from the Package Manager and the Asset Store, and comes with updated documentation)

    What is the UDP Sandbox for?
    The sandbox environment is essentially a “test store” for your IAPs.

    When you directly implement an app store’s IAP SDK in a game, it ensures IAP transactions work with that store’s payment system. When you implement the UDP SDK in your game, your UDP build will have its IAP transactions take place in its test environment: the UDP Sandbox.

    Later on, your UDP build will be repacked for the “real” app stores (Samsung Galaxy Store, Huawei AppGallery, etc). This will remove the sandbox environment and patch in the store-specific SDK, so that each store-specific build repacked by UDP can work directly with that store’s respective payment system.

    What happens without sandbox testing?
    Sandbox testing ensures your UDP implementation operates correctly before you progress to the next step (repacking for the stores).

    Without it, you can’t find and resolve any issues that arise during your initial UDP implementation. If it turns out something isn’t working as you move closer to store submissions, either your game will fail to repack, or it will repack and remain faulty. This will result in game rejections, and even worse, players not being able to complete transactions in your game.

    When to test in the UDP Sandbox?
    You need to have gone this far in your UDP project:
    • You’ve installed and set up UDP.
    • You’ve implemented the Initialize() method. More info here.
    • If your game has IAPs you’ve also:
      • Implemented the QueryInventory(), Purchase(), Consume() methods. More info here.
      • Added IAP products in your IAP catalog. You don't need to localize IAP prices and descriptions yet, as the sandbox will only use English and USD. But the IAP products must show on the UDP console.
    • You’ve built your APK.
    • You’ve created UDP Sandbox test accounts, either in the Unity Editor (UDP Settings) or in the UDP Console (section “Sandbox Testing” of the Game Info page). Note that there is no need to rebuild your APK if you add or modify test accounts.
    In short, it’s when you’d expect your UDP implementation to be complete, and prepare to test it ahead of creating your first release on UDP.

    What to test in the UDP Sandbox?
    Before a game can be released for the first time, UDP makes it a requirement to:
    • Initialize UDP in the sandbox at least once
    • Complete an IAP purchase in the sandbox at least once (if your game has IAPs)
    This is to ensure that the UDP implementation works for a simple and nominal case, though we encourage you to test your UDP methods more extensively.

    The UDP Sandbox is connected to the larger UDP ecosystem, so your UDP Console knows if / when you’ve cleared these steps for your game. This is how (and why) UDP halts your game’s first release if this step is not completed.

    Note that after your first release, you will not need to repeat the sandbox testing to release new revisions of your game on UDP.

    How to test in the UDP Sandbox?
    Launch your UDP APK in an Android emulator or on a real Android device.

    When your game launches it should call the Initialize() method, which invokes the login screen in the sandbox environment.

    Log in using your sandbox test account. The initialization will only complete after you log in successfully, after which you will see a toast notification appear. Back in the UDP Console, in the section “Sandbox Testing”, the UDP Initialization label will turn to a green “Tested” status.

    If your game has IAPs, make and complete one IAP transaction. Since this is a test environment, no real money will be used. If the purchase is successful a toast notification will appear, and back in the “Sandbox Testing” section of the UDP Console, the IAP Transaction label will turn to a green “Tested” status.

    Once you have your “Tested” status(es) you’ll see a green tick appear in the left panel of the Game Info page to confirm you’ve cleared sandbox testing. Now, you’re clear to complete any remaining steps on your Game Info page to release your first revision and submit it to stores!

    Be sure to check your UDP implementation if any IAP-related issues arise, such as:
    • No login screen appearing
    • No IAP products retrieved
    • Unresponsive purchase buttons
    • Inability to complete a purchase
    For further troubleshooting information, check the UDP Package documentation. The UDP support team is also reachable via the “Contact Support” link on the UDP Console.

    Why do we need sandbox test accounts?
    Sandbox test accounts protect access to the generic UDP build. After all, you wouldn't want players to access it and pass it around, letting anyone get a hold of your IAP products for free.

    Also, rest assured that the sandbox login page only appears in the generic UDP build. Repacked builds (the ones submitted to the stores) will never show this login page to players. When UDP repacks your game, the sandbox environment is stripped out, along with the login page, and it is replaced by the store-specific implementation.

    Wrapping up
    We really hope this post will help you navigate and clear the sandbox testing requirement. Let us know how it goes.

    Remember that:
    • All games must clear the Initialization (whether they have IAPs or not),
    • Only games with IAPs need to clear a Purchase,
    • You can only release your game on UDP once the sandbox testing is cleared.
    Last edited: May 28, 2021
    FlyingSquirrels and phuong_unity like this.
  2. FlyingSquirrels


    Sep 18, 2015
  3. phuong_unity


    Apr 25, 2018
    Our apologies for any questions on the UDP forum that are taking a long time to get answers. This is an area where we are working toward improving but in the meantime, if you need immediate help, please consider opening a support ticket through the UDP dashboard so our support team can work directly with you to address any issues or questions that you may have.
    FlyingSquirrels likes this.
  4. FlyingSquirrels


    Sep 18, 2015
    OK will do that. Thank you.
    phuong_unity likes this.
  5. DucaDiMonteSberna


    Jan 18, 2018
    So I've completed every step except one: upload apk, the console gives a generic " failed to upload file" error end nothing else. I cannot figure out what theerror is.
  6. Blackdisney


    Jun 4, 2014
    Thats all great and everything. I just wasted a whole weekend trying to get this to work. Why to i have to test anything when i don't have IAP in my apps and most don't have a price. You say build once and deploy everywhere but thats not true cause you have to jump through all these hoops just to get it to the point where you can get it into the stores. This was alot easier when the stupid sandbox wasn't mandatory. Guess ill be submitting individually to each store cause UDP became too complex and difficult to use. Bravo to the expert teams and coders who can make this work but what about the artist, designers and noob coders? what about us? do we count?
    Biltekin and FreeLearning like this.
  7. stevetaylor74


    Unity Technologies

    Aug 13, 2020
    Hello all, so we now have 2 tutorial videos covering UDP Initialization and UDP Sandbox Testing. They're in this section of the UDP Console. We're also holding an AMA session on these two topics on June 4th - register here.
  8. Nameless777


    Jan 4, 2019
    Hello i managed the process of the UDP initialization without IAP successfully.but now i want to add iap in my project without using of unity IAP(With using UDP only).
    so how can i write code for purchase the products.
    can please somebody tell me.
  9. sharatchandra_unity


    Unity Technologies

    Jan 21, 2019
  10. IAmChiagozie


    Jun 26, 2017
    Can anyone take a look at my code and see if I'm doing anything wrong? I've been watching tutorials to implement UDP, and it is not being initialized and the IAP doesn't work either. Yet, I'm getting debug calls on a debug text on my game saying "Initialization succeeded".

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UDP;
    3. using TMPro;
    5. public class UDPIAPManager : MonoBehaviour
    6. {
    7.     IInitListener initListener = new InitListener();
    8.     PurchaseListener purchaseListener = new PurchaseListener();
    10.     private MainMenuManager menuManager = null;
    12.     public TextMeshProUGUI debugtext;
    13.     public static TextMeshProUGUI Debugtext;
    15.     public string WeaponsPackProductID;
    17.     private void Awake()
    18.     {
    19.         menuManager = GetComponent<MainMenuManager>();
    21.         Debugtext = debugtext;
    22.     }
    24.     private void Start() => StoreService.Initialize(initListener);
    26.     public void PurchaseItem() => Purchase(WeaponsPackProductID, null);
    28.     private void Purchase(string productID, string payload)
    29.     {
    30.         menuManager.placeholder.ClickSFX.Play();
    31.         StoreService.Purchase(productID, payload, purchaseListener);
    32.     }
    33. }
    35. public class InitListener : IInitListener
    36. {
    37.     //IPurchaseListener purchaseListener = new PurchaseListener();
    39.     public void OnInitialized(UserInfo userInfo)
    40.     {
    41.         Debug.Log("Initialization succeeded");
    42.         UDPIAPManager.Debugtext.SetText("Initialization succeeded");
    43.         // You can call the QueryInventory method here
    44.         // to check whether there are purchases that haven’t be consumed.
    47.         //StoreService.QueryInventory(purchaseListener);
    48.     }
    50.     public void OnInitializeFailed(string message)
    51.     {
    52.         Debug.Log("Initialization failed: " + message);
    53.         UDPIAPManager.Debugtext.SetText("Initialization failed: " + message);
    54.     }
    55. }
    57. public class PurchaseListener : IPurchaseListener
    58. {
    59.     public void OnPurchase(PurchaseInfo purchaseInfo)
    60.     {
    61.         // The purchase has succeeded.
    62.         // If the purchased product is consumable, you should consume it here.
    63.         // Otherwise, deliver the product.
    65.         //UDPIAPManager.PurchaseStatus(purchaseInfo, CurrentPurchaseStatus.Success);
    66.         UDPIAPManager.Debugtext.SetText("Purchased: " + purchaseInfo.ProductId);
    67.     }
    69.     public void OnPurchaseFailed(string message, PurchaseInfo purchaseInfo)
    70.     {
    71.         Debug.Log("Purchase Failed: " + message);
    72.         UDPIAPManager.Debugtext.SetText("Purchase Failed: " + message);
    74.         //UDPIAPManager.PurchaseStatus(purchaseInfo, CurrentPurchaseStatus.Failed);
    75.     }
    77.     public void OnPurchaseRepeated(string productCode)
    78.     {
    79.         // Some stores don't support queryInventory.
    81.     }
    83.     public void OnPurchaseConsume(PurchaseInfo purchaseInfo)
    84.     {
    85.         // The consumption succeeded.
    86.         // You should deliver the product here.      
    87.     }
    89.     public void OnPurchaseConsumeFailed(string message, PurchaseInfo purchaseInfo)
    90.     {
    91.         // The consumption failed.
    92.     }
    94.     public void OnQueryInventory(Inventory inventory)
    95.     {
    96.         // Querying inventory succeeded.
    97.     }
    99.     public void OnQueryInventoryFailed(string message)
    100.     {
    101.         // Querying inventory failed.
    102.     }
    104.     public void OnPurchasePending(string message, PurchaseInfo purchaseInfo)
    105.     {
    106.         // The Purchase is pending
    107.     }
    108. }
  11. IAmChiagozie


    Jun 26, 2017
    What I did to fix this was to uninstall In app purchasing from the package manager, and install UDP version 2.1.0
    sharatchandra_unity likes this.
  12. rose1233


    Mar 8, 2018

    Attached Files:

  13. rose1233


    Mar 8, 2018
    why do IInitListener can't be created
  14. SamOYUnity3D


    Unity Technologies

    May 12, 2019
  15. Blitzkreig95


    Jul 21, 2021
    @SamOYUnity3D We are a small startup with a storefront for small apps that cater to a niche market. What is the standard procedure to apply for UDP Partner status ?