Using the UDP Sandbox [why, what and how]

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!

Troubleshooting
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.
2 Likes

@FlyingSquirrels_1

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.

1 Like


OK will do that. Thank you.

1 Like

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.

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?

2 Likes

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.

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.

Well @Nameless777 , it's quite simple with these steps :

- List your IAP products on the Console

- Implement Querying, Purchase and Consume
https://docs.unity3d.com/Packages/com.unity.purchasing.udp@2.1/manual/games-with-iap.html

- Implement Consume Logic if applicable
This must be implemented in your class that handles the consume. (For example if a user buys a product worth 100 coins, he must receive the 100 coins if the transaction is successful.)

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".

using UnityEngine;
using UnityEngine.UDP;
using TMPro;

public class UDPIAPManager : MonoBehaviour
{
    IInitListener initListener = new InitListener();
    PurchaseListener purchaseListener = new PurchaseListener();

    private MainMenuManager menuManager = null;

    public TextMeshProUGUI debugtext;
    public static TextMeshProUGUI Debugtext;

    public string WeaponsPackProductID;

    private void Awake()
    {
        menuManager = GetComponent<MainMenuManager>();

        Debugtext = debugtext;
    }

    private void Start() => StoreService.Initialize(initListener);

    public void PurchaseItem() => Purchase(WeaponsPackProductID, null);

    private void Purchase(string productID, string payload)
    {
        menuManager.placeholder.ClickSFX.Play();
        StoreService.Purchase(productID, payload, purchaseListener);
    }
}

public class InitListener : IInitListener
{
    //IPurchaseListener purchaseListener = new PurchaseListener();

    public void OnInitialized(UserInfo userInfo)
    {
        Debug.Log("Initialization succeeded");
        UDPIAPManager.Debugtext.SetText("Initialization succeeded");
        // You can call the QueryInventory method here
        // to check whether there are purchases that haven’t be consumed.


        //StoreService.QueryInventory(purchaseListener);
    }

    public void OnInitializeFailed(string message)
    {
        Debug.Log("Initialization failed: " + message);
        UDPIAPManager.Debugtext.SetText("Initialization failed: " + message);
    }
}

public class PurchaseListener : IPurchaseListener
{
    public void OnPurchase(PurchaseInfo purchaseInfo)
    {
        // The purchase has succeeded.
        // If the purchased product is consumable, you should consume it here.
        // Otherwise, deliver the product.

        //UDPIAPManager.PurchaseStatus(purchaseInfo, CurrentPurchaseStatus.Success);
        UDPIAPManager.Debugtext.SetText("Purchased: " + purchaseInfo.ProductId);
    }

    public void OnPurchaseFailed(string message, PurchaseInfo purchaseInfo)
    {
        Debug.Log("Purchase Failed: " + message);
        UDPIAPManager.Debugtext.SetText("Purchase Failed: " + message);

        //UDPIAPManager.PurchaseStatus(purchaseInfo, CurrentPurchaseStatus.Failed);
    }

    public void OnPurchaseRepeated(string productCode)
    {
        // Some stores don't support queryInventory.

    }

    public void OnPurchaseConsume(PurchaseInfo purchaseInfo)
    {
        // The consumption succeeded.
        // You should deliver the product here.       
    }

    public void OnPurchaseConsumeFailed(string message, PurchaseInfo purchaseInfo)
    {
        // The consumption failed.
    }

    public void OnQueryInventory(Inventory inventory)
    {
        // Querying inventory succeeded.
    }

    public void OnQueryInventoryFailed(string message)
    {
        // Querying inventory failed.
    }

    public void OnPurchasePending(string message, PurchaseInfo purchaseInfo)
    {
        // The Purchase is pending
    }
}

W


What I did to fix this was to uninstall In app purchasing from the package manager, and install UDP version 2.1.0

1 Like

7847664--995244--upload_2022-1-28_11-3-41.png

7847664--995241--upload_2022-1-28_11-2-51.png

why do IInitListener can't be created


Hi, you don't have to create IInitListener, please try the below codes.

https://docs.unity3d.com/Packages/com.unity.purchasing.udp@1.3/manual/games-with-iap.html

7881115--1002514--upload_2022-2-9_11-14-16.png

@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 ?