public void LaunchWeb(APMidasBaseRequest req, MidasPayCallback callback) { if (!mHasInited) { Debug.LogError("you should call Initialize first"); return; } try { mMidasPayCallback = callback; // mAPMidasBasePayRequest = req; string reqString = req.ToString(); ULog.Log("LaunchWeb with json : " + reqString); #if UNITY_EDITOR ULog.Log("Simulator LaunchWeb"); #elif UNITY_ANDROID helper = new AndroidJavaClass(helperClass); if (helper == null) { ULog.Log("Cannot get Java helper class"); } else { helper.CallStatic("LaunchWeb", reqString); } #elif UNITY_IOS ULog.Log("IOS LaunchWeb does not support"); #endif } catch (System.Exception e) { ULog.LogError("catch exception : " + e.Message); } }
/// <summary> /// 拉起支付 /// </summary> /// /// <param name="req">Req.</param> /// <param name="callback">Callback.</param> public void Pay(APMidasBaseRequest req, MidasPayCallback callback) { if (!mHasInited) { Debug.LogError("you should call Initialize first"); return; } try { appExtend = req.appExtends; //保存回调的时候,回传给游戏 mMidasPayCallback = callback; // mAPMidasBasePayRequest = req; string bizType = req.GetType().Name; ULog.Log("PayType = " + bizType); string reqString = req.ToString(); ULog.Log("Pay with json : " + reqString); #if UNITY_EDITOR ULog.Log("Simulator Pay"); #elif UNITY_ANDROID helper = new AndroidJavaClass(helperClass); if (helper == null) { ULog.Log("Cannot get Java helper class"); } else { helper.CallStatic("Pay", bizType, reqString); } #elif UNITY_IOS midasSdkPay(bizType, reqString); #endif } catch (System.Exception e) { ULog.LogError("catch exception : " + e.Message); } }
public void MidasLoginExpiredCallback() { if (mMidasPayCallback != null) { mMidasPayCallback.OnMidasLoginExpired(); // 用完即废,防止影响后续逻辑 mMidasPayCallback = null; } }
// 接收到Java/OC发来的消息后,这个方法会被调用,用以回调C#层的游戏 public void MidasPayCallback(string result) { if (mMidasPayCallback != null) { APMidasResponse resp = new APMidasResponse(result); resp.appExtends = appExtend; mMidasPayCallback.OnMidasPayFinished(resp); // 用完即废,防止影响后续逻辑 mMidasPayCallback = null; } }