You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity IAP多地区订单大量取消问题排查求助

Unity IAP多地区支付异常问题求助

欧元、美元地区支付无异常,但THB、IDR、MXN、PHP、MYR等地区的订单大多先处于待处理状态后被取消,这些地区的销售成功率仅约3%。已向开发者控制台支持反馈,确认账号无问题,附上相关IAPManager脚本及订单详情截图,恳请排查问题原因。

IAPManager脚本

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 "";
        }
    }
}

订单详情截图

IAP订单详情

内容的提问来源于stack exchange,提问作者Koray

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 14:19:50