Almost all Unity IAP orders are canceled in some countries

44 Views Asked by At

I use the following script with Unity. I have no problems with Euro and Dollar exchange rates, but almost all of the exchange rates such as THB, IDR, MXN, PHP, MYR are first kept as pending and then cancelled. My success rate in sales in these countries is almost 3%. I wonder what could be the problem. The picture below shows only a small sample of the cancellations.

I reported the situation to the Developer Console support team, but there was no problem with my account. What can be problem here?

using System;
using UnityEngine;
using UnityEngine.Purchasing;
using UnityEngine.Purchasing.Extension;

public class IAPManager : MonoBehaviour, IDetailedStoreListener
{
    IStoreController m_StoreController; // The Unity Purchasing system.

    private string vehicle_type1 = "vehicletype1";
    private string vehicle_type2 = "vehicletype2";
    private string vehicle_type3 = "vehicletype3";
    private string vehicle_type4 = "vehicletype4";
    private string vehicle_type5 = "vehicletype5";
    ...
    ...
    ...

    private static IAPManager instance;
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }

    void Start()
    {
        InitializePurchasing();
    }

    void InitializePurchasing()
    {
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        //Add products that will be purchasable and indicate its type.

        builder.AddProduct(vehicle_type1, ProductType.NonConsumable);
        builder.AddProduct(vehicle_type2, ProductType.NonConsumable);
        builder.AddProduct(vehicle_type3, ProductType.NonConsumable);
        builder.AddProduct(vehicle_type4, ProductType.NonConsumable);
        builder.AddProduct(vehicle_type5, ProductType.NonConsumable);
        ...
        ...
        ...

        UnityPurchasing.Initialize(this, builder);
    }

    public void BuyProduct(string productId)
    {
        m_StoreController.InitiatePurchase(productId);
    }

    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        Debug.Log("In-App Purchasing successfully initialized");
        m_StoreController = controller;
    }

    public void OnInitializeFailed(InitializationFailureReason error)
    {
        OnInitializeFailed(error, null);
    }

    public void OnInitializeFailed(InitializationFailureReason error, string message)
    {
        var errorMessage = $"Purchasing failed to initialize. Reason: {error}.";

        if (message != null)
        {
            errorMessage += $" More details: {message}";
        }

        Debug.Log(errorMessage);
    }

    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    {
        //Retrieve the purchased product
        var product = args.purchasedProduct;

        AddProduct(product.definition.id.ToString());


        Debug.Log($"Purchase Complete - Product: {product.definition.id}");

        //We return Complete, informing IAP that the processing on our side is done and the transaction can be closed.
        return PurchaseProcessingResult.Complete;
    }

    public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
    {
        Debug.Log($"Purchase failed - Product: '{product.definition.id}', PurchaseFailureReason: {failureReason}");
    }

    public void OnPurchaseFailed(Product product, PurchaseFailureDescription failureDescription)
    {
        Debug.Log($"Purchase failed - Product: '{product.definition.id}'," +
            $" Purchase failure reason: {failureDescription.reason}," +
            $" Purchase failure details: {failureDescription.message}");
    }

    void AddProduct(string strProductId)
    {
        PlayerPrefs.SetString("PurchasedItemName", GetProductNameFromId(strProductId));

        GameObject obj = GameObject.FindGameObjectWithTag("TroopsMenuObject");
        if (obj != null)
        {
            obj.GetComponent<TroopsMenu>().BuyCompleted();
        }
    }

    private string GetProductNameFromId(string prodId)
    {
        switch (prodId)
        {
            case "vehicletype1": return "Vehicle_Type1";
            case "vehicletype2": return "Vehicle_Type2";
            case "vehicletype3": return "Vehicle_Type3";
            case "vehicletype4": return "Vehicle_Type4";
            case "vehicletype5": return "Vehicle_Type5";
            ...
            ...
            ...
            default: return "";
        }
    }
}

Order details as shown below.

IAP Details

0

There are 0 best solutions below