public virtual string PayItem(SDKData.PayOrderData orderData) { OrderInfo orderInfo = new OrderInfo(); GameRoleInfo gameRoleInfo = new GameRoleInfo(); orderInfo.goodsID = orderData.productId; orderInfo.goodsName = orderData.productName; orderInfo.goodsDesc = orderData.productDesc; //停用 orderInfo.quantifier = "个"; //停用 orderInfo.extrasParams = orderData.extra; orderInfo.count = orderData.productCount; orderInfo.amount = orderData.amount; //金额 元 orderInfo.price = 0.1f; //停用 orderInfo.callbackUrl = ""; orderInfo.cpOrderID = orderData.orderId; gameRoleInfo.gameRoleBalance = "0"; gameRoleInfo.gameRoleID = orderData.roleID; gameRoleInfo.gameRoleLevel = "1"; gameRoleInfo.gameRoleName = orderData.roleName; gameRoleInfo.partyName = "同济会"; gameRoleInfo.serverID = orderData.zoneID.ToString(); gameRoleInfo.serverName = orderData.zoneName; gameRoleInfo.vipLevel = "1"; gameRoleInfo.roleCreateTime = "roleCreateTime"; QuickSDK.getInstance().pay(orderInfo, gameRoleInfo); return(null); }
/// <summary> /// 申请支付订单 /// </summary> public void PayOrder(SDKData.PayOrderData arg) { #if UNITY_EDITOR #elif UNITY_ANDROID AndroidPlatSDKManager.Instance.PayOrder(arg); #elif UNITY_IPHONE #endif }
public virtual string PayItem(SDKData.PayOrderData orderData) { SDKLogManager.DebugLog("PayItem"); #if UNITY_EDITOR #elif UNITY_ANDROID #elif UNITY_PHONE #endif return(null); }
public override string PayItem(SDKData.PayOrderData orderData) { using (AndroidJavaObject curActivity = CallAndroidFuncGetResult <AndroidJavaObject>("GetGameMainActivity")) { SDKLogManager.DebugLog("pay"); pay(curActivity.GetRawObject(), gameObject.name, (int)(orderData.amount * 100), orderData.productName, 1, orderData.extra, orderData.callbackUrl, "PayResultCallBack"); return(null); } }
public string PayItem(SDKData.PayOrderData orderData) { if (string.IsNullOrEmpty(orderData.orderTime)) { orderData.orderTime = System.DateTime.Now.Ticks.ToString(); } var payModel = new YaoLingSDKCallBackManager.YX116PayParamsModel() { userid = orderData.userid, username = SDK_UserName,//只能填sdk的用户名 amount = double.Parse(string.Format("{0:F2}", orderData.amount)), orderid = orderData.orderId, rolenid = orderData.roleID.ToString(), rolename = orderData.roleName, gameServerId = orderData.zoneID.ToString(), gameServerName = orderData.zoneName, productname = orderData.productName, productDesc = orderData.productDesc, orderTime = orderData.orderTime,//116 22222 22222 => 22222 22222 extra = orderData.extra, productId = orderData.productId, gamename = orderData.gamename, }; #region 2018年8月17日14:18:09 qiubin添加 曜灵 116 聚合 SDK #if UNITY_ANDROID YaoLingSDKCallBackManager.Instance.CallAndroidFunc(YaoLingSDKCallBackManager.YaoLinAndroidSDKNameType.StartSDKPay, LitJson.JsonMapper.ToJson(payModel)); #elif UNITY_IOS SDKIOSFunction.sdkmanagerpayorder(payModel.orderid, payModel.rolename, payModel.gameServerId, payModel.amount.ToString() , payModel.productId, payModel.productname, payModel.extra, payModel.gamename, payModel.gameServerName, "1"); #endif #endregion return(null); }
// Use this for initialization void Start() { InitButton = transform.Find("InitButton").GetComponent <Button>(); LoginButton = transform.Find("LoginButton").GetComponent <Button>(); PayOrderButton = transform.Find("PayOrderButton").GetComponent <Button>(); SaveRoleButton = transform.Find("SaveRoleButton").GetComponent <Button>(); LogoutButton = transform.Find("LogoutButton").GetComponent <Button>(); OnGameExitButton = transform.Find("OnGameExitButton").GetComponent <Button>(); SaveUMengLevelButton = transform.Find("SaveUMengLevelButton").GetComponent <Button>(); SaveUMengCountButton = transform.Find("SaveUMengCountButton").GetComponent <Button>(); SaveUMengLevelButton.gameObject.SetActive(false); SaveUMengCountButton.gameObject.SetActive(false); SetGameGoState(false); LoginButton.gameObject.SetActive(false); InitButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在初始化sdk!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.Init(); U3DTypeSDK.Instance.InitSDK(() => { SDKLogManager.DebugLog("初始化成功!", SDKLogManager.DebugType.LogWarning); InitButton.gameObject.SetActive(false); LoginButton.gameObject.SetActive(true); }, (state) => { if (state) { SDKLogManager.DebugLog("注销成功!", SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(true); SetGameGoState(false); } else { SDKLogManager.DebugLog("注销失败!", SDKLogManager.DebugType.LogError); } }); }); LoginButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在登录!", SDKLogManager.DebugType.LogWarning); // SDKManager.Instance.Login((a) => { }); U3DTypeSDK.Instance.Login(() => { SDKLogManager.DebugLog("登入成功!", SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(false); SetGameGoState(true); }); }); PayOrderButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在支付订单!!", SDKLogManager.DebugType.LogWarning); var payOrderData = new SDKData.PayOrderData() { orderId = SDKData.PayOrderData.GetCurrentTimeMiss(), userid = U3DTypeSDK.Instance.Game_UserId, amount = 6, productId = "10001", productName = "钻石", productDesc = "钻石", callbackMessage = "回调给服务器时的附加消息", productCount = 1, callbackUrl = "http://112.345.678.1/payresult.php", roleID = "roleiid", roleName = "roleiid", //角色名字 zoneID = 1, //区id zoneName = "1区", //区名字 orderTime = SDKData.PayOrderData.GetCurrentTimeMiss(), extra = "附加参数不得为空", gamename = N3DClient.GameConfig.GetClientConfig("GameName", "yyty"), }; U3DTypeSDK.Instance.PayItem(payOrderData); // SDKManager.Instance.PayOrder(payOrderData); }); SaveRoleButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在保存角色信息!!", SDKLogManager.DebugType.LogWarning); var roleData = new SDKData.RoleData() { roleId = "123456", roleLevel = "22", roleName = "测试角色", createTime = System.DateTime.Now.Millisecond.ToString(), realmId = "1", realmName = "1区测试服", chapter = "1-1", arg = "这是一条保存角色信息的附加信息!", }; // SDKManager.Instance.SavePlayerInfo(roleData); U3DTypeSDK.Instance.UpdatePlayerInfo(roleData, SDKData.UpdatePlayerInfoType.levelUp); }); LogoutButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在登出账号!!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.Logout(); U3DTypeSDK.Instance.Logout(); }); OnGameExitButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在退出sdk!!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.OnGameExit(() => //{ // Debug.LogWarning("SDK 已经退出!"); //}); U3DTypeSDK.Instance.ExitGame(); #if UNITY_EDITOR SetGameGoState(false); LoginButton.gameObject.SetActive(false); InitButton.gameObject.SetActive(true); #endif }); SaveUMengLevelButton.onClick.AddListener(() => { UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestEventID); }); SaveUMengCountButton.onClick.AddListener(() => { var data = new System.Collections.Generic.Dictionary <string, string>() { { "test1", "1" }, { "test2", "4" }, { "test3", "8" }, { "test4", "16" }, }; UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestComputingEvent, data); }); }
/** * eg: * payData.SetData(U3DTypeAttName.REAL_PRICE,"100"); * payData.SetData(U3DTypeAttName.ITEM_NAME,"sk bi"); * payData.SetData(U3DTypeAttName.ITEM_DESC,"desc"); * payData.SetData(U3DTypeAttName.ITEM_COUNT,"1"); * payData.SetData(U3DTypeAttName.ITEM_SEVER_ID,"id"); * payData.SetData(U3DTypeAttName.SEVER_ID,"1"); * payData.SetData(U3DTypeAttName.EXTRA,"extra"); * * 支付函数 * @param _in_pay pay object 支付对象的结构体 若至少传入 一个 价格 * 参数1:商品信息 参数2:订单id(由服务器生成) * @return bill number */ public string PayItem(SDKData.PayOrderData orderData, string orderId) { #if YaoLing Debug.LogWarning("调用曜灵116sdk 支付!"); #region 2018年8月17日14:18:09 qiubin添加 曜灵 116 聚合 SDK var payModel = new YaoLingSDKCallBackManager.YX116PayParamsModel() { userid = Id, username = UserName, amount = double.Parse(string.Format("{0:F2}", orderData.amount)), orderid = orderId, rolenid = orderData.roleID.ToString(), rolename = orderData.roleName, gameServerId = orderData.zoneID.ToString(), gameServerName = orderData.zoneName, productname = orderData.productName, productDesc = orderData.productDesc, orderTime = orderId.Substring(orderId.Length - 10, 10),//116 22222 22222 => 22222 22222 extra = orderData.roleID + "|" + orderData.zoneID, }; YaoLingSDKCallBackManager.Instance.CallAndroidFunc(YaoLingSDKCallBackManager.YaoLinAndroidSDKNameType.StartSDKPay, LitJson.JsonMapper.ToJson(payModel)); return(null); #endregion #else //创建一个订单信息 U3DTypeBaseData payData = new U3DTypeBaseData(); //用户ID,渠道返回,没有填空字符串 payData.SetData(U3DTypeAttName.USER_ID, Id); //用户token,登录验签完成后由游戏服务端返回,没有填空字符串 payData.SetData(U3DTypeAttName.USER_TOKEN, Token); //商品支付价格(单位:分) payData.SetData(U3DTypeAttName.REAL_PRICE, (orderData.amount * 100).ToString()); //商品名称,不要出现空格和特殊字符。 payData.SetData(U3DTypeAttName.ITEM_NAME, orderData.productName); //商品数量 payData.SetData(U3DTypeAttName.ITEM_COUNT, orderData.productCount); //所在服务器id(如果没有填“0”) payData.SetData(U3DTypeAttName.SERVER_ID, "0"); //所在服务器名字(如果没有填“server_name”) payData.SetData(U3DTypeAttName.SERVER_NAME, "server_name"); //所在大区id(如果没有填“0”),注意应用宝要求:账户分区ID_角色ID。每个应用都有一个分区ID为1的默认分区,分区可以在cpay.qq.com/mpay上自助配置。如果应用选择支持角色,则角色ID接在分区ID号后用"_"连接,角色ID需要进行urlencode。 payData.SetData(U3DTypeAttName.ZONE_ID, orderData.zoneID.ToString()); //所在大区名字(如果没有填“server_name”) payData.SetData(U3DTypeAttName.ZONE_NAME, orderData.zoneName); //TODO 内部订单号(必须填写,并保证多区情况下,订单号唯一) //string orderId = string.Format("{0}{1}{2}", Channelid, orderData.productId, SDKData.PayOrderData.GetCurrentTimeMiss()); payData.SetData(U3DTypeAttName.BILL_NUMBER, orderId); //商品id(需和TypeSDK Server商品列表保持一致) payData.SetData(U3DTypeAttName.ITEM_SERVER_ID, orderData.productId); //传递的额外参数(建议传入需要用来做订单标识的信息) payData.SetData(U3DTypeAttName.EXTRA, orderData.roleID + "|" + orderData.zoneID); //商品描述,不要出现空格和特殊字符串 payData.SetData(U3DTypeAttName.ITEM_DESC, orderData.productDesc); //玩家在游戏中的角色ID payData.SetData(U3DTypeAttName.ROLE_ID, orderData.roleID.ToString()); //玩家在游戏中的角色名字 payData.SetData(U3DTypeAttName.ROLE_NAME, orderData.roleName); // selfInit (); Debug.Log("U3D_Type sdk buy item"); string billNo = bonjour.PayItem(payData); return(billNo); #endif }
// Use this for initialization void Start() { InitButton = transform.Find("InitButton").GetComponent <Button>(); LoginButton = transform.Find("LoginButton").GetComponent <Button>(); PayOrderButton = transform.Find("PayOrderButton").GetComponent <Button>(); SaveRoleButton = transform.Find("SaveRoleButton").GetComponent <Button>(); SaveRoleButton2 = transform.Find("SaveRoleButton2").GetComponent <Button>(); SaveRoleButton3 = transform.Find("SaveRoleButton3").GetComponent <Button>(); LogoutButton = transform.Find("LogoutButton").GetComponent <Button>(); OnGameExitButton = transform.Find("OnGameExitButton").GetComponent <Button>(); SaveUMengLevelButton = transform.Find("SaveUMengLevelButton").GetComponent <Button>(); SaveUMengCountButton = transform.Find("SaveUMengCountButton").GetComponent <Button>(); CheckSimulatorButton = transform.Find("CheckSimulatorButton").GetComponent <Button>(); Message = transform.Find("Message").GetComponent <Text>(); SaveUMengLevelButton.gameObject.SetActive(false); SaveUMengCountButton.gameObject.SetActive(false); SetGameGoState(false); LoginButton.gameObject.SetActive(false); sdkmanager = AloneSdk.AloneSDKManager.instance; if (sdkmanager == null) { Debug.LogError("sdkmanager is null !"); return; } InitButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在初始化sdk!", SDKLogManager.DebugType.LogWarning); SDKData.InitArgModel initArg = new SDKData.InitArgModel() { onComplete = (result) => { if (result) { SDKLogManager.DebugLog("初始化成功!", SDKLogManager.DebugType.LogWarning); InitButton.gameObject.SetActive(false); LoginButton.gameObject.SetActive(true); } }, onSDKLogoutComplete = (state) => { if (state) { SDKLogManager.DebugLog("注销成功!", SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(true); SetGameGoState(false); } else { SDKLogManager.DebugLog("注销失败!", SDKLogManager.DebugType.LogError); } }, onSDKMessageCallBack = (message) => { Message.text = message; }, }; sdkmanager.InitSDK(initArg); }); LoginButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在登录!", SDKLogManager.DebugType.LogWarning); // SDKManager.Instance.Login((a) => { }); sdkmanager.Login((result) => { if (result) { SDKLogManager.DebugLog("登入成功!开始验证:", SDKLogManager.DebugType.LogWarning); if (isLoginVerification) { StartCoroutine(LoginVerification((userid) => { SDKLogManager.DebugLog("验证成功,用户id:" + userid, SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(false); SetGameGoState(true); })); } else { SDKLogManager.DebugLog("验证成功!", SDKLogManager.DebugType.LogWarning); LoginButton.gameObject.SetActive(false); SetGameGoState(true); } } }, UnityEngine.Random.Range(0, 2) == 0 ? "qq" : "wx"); }); PayOrderButton.onClick.AddListener(() => { SDKLogManager.DebugLog("生成订单中~", SDKLogManager.DebugType.LogWarning); var payOrderData = new SDKData.PayOrderData() { orderId = SDKData.PayOrderData.GetCurrentTimeMiss(), userid = sdkmanager.SDK_Id, amount = 6, productId = "10001", productName = "60钻石", productDesc = "60钻石", callbackMessage = "回调给服务器时的附加消息", productCount = 1, callbackUrl = "http://111.231.206.145/juhe/u9Pay/payCallBack", roleID = "roleiid", roleName = "roleiid", //角色名字 zoneID = 2, //区id zoneName = "2区", //区名字 orderTime = SDKData.PayOrderData.GetCurrentTimeMiss(), extra = "", gamename = N3DClient.GameConfig.GetClientConfig("GameName", "yyty"), ratio = 10,//充值比例 }; payOrderData.extra = "" + payOrderData.zoneID + "|" + payOrderData.roleID + "|" + payOrderData.productId; Action <OrderCreateModel> orderCreateAction = (order) => { payOrderData.amount = order.amount; payOrderData.callbackUrl = order.callbackurl; payOrderData.orderId = order.orderid; sdkmanager.PayItem(payOrderData); }; if (isRequestOrderId) { StartCoroutine(CreateOrder(orderCreateAction, payOrderData)); } else { orderCreateAction(new OrderCreateModel() { amount = (int)payOrderData.amount, callbackurl = payOrderData.callbackUrl, orderid = SDKData.PayOrderData.GetCurrentTimeMiss(), }); } // SDKManager.Instance.PayOrder(payOrderData); }); Action <SDKData.UpdatePlayerInfoType> onSaveRoleInfoClick = (type) => { SDKLogManager.DebugLog("正在保存角色信息!!", SDKLogManager.DebugType.LogWarning); var roleData = new SDKData.RoleData() { roleId = "123456", roleLevel = "22", roleName = "测试角色", createTime = System.DateTime.Now.Millisecond.ToString(), realmId = "1", realmName = "1区测试服", chapter = "1-1", arg = "这是一条保存角色信息的附加信息!", }; sdkmanager.UpdatePlayerInfo(roleData, type); }; SaveRoleButton.onClick.AddListener(() => { onSaveRoleInfoClick(SDKData.UpdatePlayerInfoType.createRole); }); SaveRoleButton2.onClick.AddListener(() => { onSaveRoleInfoClick(SDKData.UpdatePlayerInfoType.enterGame); }); SaveRoleButton3.onClick.AddListener(() => { onSaveRoleInfoClick(SDKData.UpdatePlayerInfoType.levelUp); }); LogoutButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在登出账号!!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.Logout(); sdkmanager.Logout(); }); OnGameExitButton.onClick.AddListener(() => { SDKLogManager.DebugLog("正在退出sdk!!", SDKLogManager.DebugType.LogWarning); //SDKManager.Instance.OnGameExit(() => //{ // Debug.LogWarning("SDK 已经退出!"); //}); sdkmanager.ExitGame(); #if UNITY_EDITOR SetGameGoState(false); LoginButton.gameObject.SetActive(false); InitButton.gameObject.SetActive(true); #endif }); SaveUMengLevelButton.onClick.AddListener(() => { //UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestEventID); }); SaveUMengCountButton.onClick.AddListener(() => { var data = new System.Collections.Generic.Dictionary <string, string>() { { "test1", "1" }, { "test2", "4" }, { "test3", "8" }, { "test4", "16" }, }; //UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestComputingEvent, data); }); CheckSimulatorButton.onClick.AddListener(() => { CheckSimulator(); }); }
/// <summary> /// 请求服务器生成订单 /// </summary> private IEnumerator CreateOrder(Action <OrderCreateModel> onComplete, SDKData.PayOrderData payData) { string sdkType = N3DClient.GameConfig.GetClientConfig("mSdkTag");//sdk类型 string url = ServerListURL + sdkType + "orderCreate.php"; SDKLogManager.DebugLog("支付验证url:" + url); Dictionary <string, string> postData = new Dictionary <string, string>(); //TODO 登录验证参数 string platform = "win"; #if UNITY_ANDROID platform = "android"; #elif UNITY_IOS platform = "ios"; #endif var sdkInstance = AloneSdk.AloneSDKManager.instance; postData.Add("platform", platform); //平台 postData.Add("userid", sdkInstance.GetSDKParamer("userId")); //渠道 postData.Add("roleid", payData.roleID); postData.Add("productid", payData.productId); //商品号 postData.Add("zoneid", payData.zoneID.ToString()); //区id postData.Add("money", payData.amount.ToString()); //区id postData.Add("channeltype", sdkInstance.GetSDKParamer("channeltype")); //渠道类型 postData.Add("channelcode", sdkInstance.GetSDKParamer("channelcode")); //渠道代码 WWWForm form = null; WWW www = null; if (postData != null) { form = new WWWForm(); foreach (var item in postData) { form.AddField(item.Key, item.Value); } } www = new WWW(url, form); yield return(www); try { if (string.IsNullOrEmpty(www.error)) { string content = System.Text.Encoding.UTF8.GetString(www.bytes); if (!string.IsNullOrEmpty(content)) { SDKLogManager.DebugLog("订单生成返回结果:" + content); var result = LitJson.JsonMapper.ToObject <OrderCreateModel>(content); if (result.code == 0) { SDKLogManager.DebugLog("订单生成成功!" + result.orderid + " amount:" + result.amount); onComplete(result); } else { SDKLogManager.DebugLog("订单生成失败!" + content, SDKLogManager.DebugType.LogError); } } } } catch (Exception e) { SDKLogManager.DebugLog("玩家订单生成报错!" + e.Message, SDKLogManager.DebugType.LogError); } }