Exemplo n.º 1
0
    /// <summary>
    /// 选择支付方式
    /// </summary>
    /// <param name="goodsInfo"></param>
    private static void SelectPayPlatform(LocalizedGoodsInfo goodsInfo)
    {
        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor)
        {
            List <PayPlatformInfo> allPayPlatformInfos = SDKManager.GetAllPayPlatformInfos();

            //无支付方式- 错误
            if (allPayPlatformInfos.Count == 0)
            {
                OnVerificationResultCallBack(new PayResult(-9, goodsInfo.goodsID, "No Pay Platform"));
                Debug.LogError("SelectPayPlatform error: no Pay Platform ->" + SDKManager.GetProperties(SDKInterfaceDefine.PropertiesKey_StoreName, "--"));
            }
            else if (allPayPlatformInfos.Count == 1)
            {
                //单一支付方式,直接调用
                OnOnSelectPayPlatform(goodsInfo, allPayPlatformInfos[0]);
            }
            else
            {
                //多种支付方式,派发事件
                if (NeedSelectPayPlatformCallBack != null)
                {
                    NeedSelectPayPlatformCallBack(goodsInfo, allPayPlatformInfos);
                }
                else
                {
                    Debug.LogError("请监听 StorePayController.NeedSelectPayPlatformCallBack , 并在回调时打开选择支付方式的界面。 玩家选择支付方式后, 再调用StorePayController.OnSelectPayPlatformCallBack 通知框架");
                    Debug.LogError("为了不卡住流程, 暂时默认调用第一个支付方式");
                    if (OnSelectPayPlatformCallBack != null)
                    {
                        OnSelectPayPlatformCallBack(goodsInfo, allPayPlatformInfos[0]);
                    }
                    else
                    {
                        OnVerificationResultCallBack(new PayResult(-11, goodsInfo.goodsID, "Pay Platform CallBack Null"));
                        Debug.LogError("OnSelectPayPlatformCallBack error: null");
                    }
                }
            }
        }
        else
        {
            //ios,暂时没有选择支付方式 这一步骤
            OnOnSelectPayPlatform(goodsInfo, new PayPlatformInfo());
        }
    }