电信(爱游戏)计费方式:
1、(单)电信计费;(如果自己已经接入了联通、移动,可升级为三网渠道支付,前提是要在移动平台、联通平台为该游戏绑定爱游戏渠道)
2、三网(融合)计费;(貌似只能上爱游戏平台,爱游戏会帮你申请移动、电信计费)
3、在以上两种短信支付基础上,还支持第三方的支付(如:支付宝、翼支付、银联、爱贝支付),需要强联网。
具体详情:http://open./dev/wiki/p1?tab_index=0&page=1。
接下来看看增么在Unity项目中接入三网融合计费:
1、在爱游戏开放平台申请计费成功之后会生成两个计费文件:feeInfo.dat和mmpay.xml(移动MM计费文件),下载下来备用。
2、下载最新的SDK:http://180.96.63.69/Documents/SDK_410.html这里提供了所有资源的下载,这里我们下载他的u3d文档及demo工程文件就可以了,它已经将需要的资源都集成进去了。
3、下载下来的文档已经很清楚的说明了接入流程,这里就不在多说了。需要指出的是你需要把assets、libs用到的所有资源拷贝到Unity的Android目录,同时将第一步下载到的feeInfo.dat和mmpay.xml替换掉assets里面的,还需要注意的是你的应用名称和包名必须跟你在申请计费的时候填写的信息必须一致。
4、你可能需要自己修改demo里面的各个接口,并重新生成jar包:
- package com.iap.egame;
-
- import java.util.HashMap;
- import java.util.Map;
-
- import android.app.Activity;
- import android.os.Handler;
- import android.os.Looper;
- import android.util.Log;
- import cn.egame.terminal.paysdk.EgamePay;
- import cn.egame.terminal.paysdk.EgamePayListener;
- import cn.egame.terminal.sdk.log.EgameAgent;
-
- import com.unity3d.player.UnityPlayer;
-
- public class Egame_IAPController
- {
- static final String TAG = "Egame_IAPController";
-
- static String ObjectName = "";
- static String CkFun = "";
-
- static Activity getActivity()
- {
- return UnityPlayer.currentActivity;
- }
-
- // 初始化
- public static void Init(String _objectName, String _ckFun)
- {
- SetListener(_objectName, _ckFun);
- Handler handler = new Handler(Looper.getMainLooper());
- handler.post(new Runnable()
- {
- @Override
- public void run()
- {
- EgamePay.init(getActivity());
- }
- });
- }
-
- // 支付
- public static void Order(String altas, String name)
- {
- final HashMap<String, String> payParams = new HashMap<String, String>();
- payParams.put(EgamePay.PAY_PARAMS_KEY_TOOLS_ALIAS, altas);
- payParams.put(EgamePay.PAY_PARAMS_KEY_TOOLS_NAME, name);
-
- Handler handler = new Handler(Looper.getMainLooper());
- handler.post(new Runnable()
- {
- @Override
- public void run()
- {
- Pay(payParams);
- }
- });
- }
-
- // 支付
- private static void Pay(HashMap<String, String> payParams)
- {
- EgamePay.pay(getActivity(), payParams, new EgamePayListener()
- {
-
- @Override
- public void paySuccess(Map<String, String> params)
- {
- String result = "{result:0,altas:" + params.get(EgamePay.PAY_PARAMS_KEY_TOOLS_ALIAS) + ",name:" + params.get(EgamePay.PAY_PARAMS_KEY_TOOLS_NAME) + "}";
- SendMessage(result);
- }
-
- @Override
- public void payFailed(Map<String, String> params, int erroInt)
- {
- String result = "{result:1,altas:" + params.get(EgamePay.PAY_PARAMS_KEY_TOOLS_ALIAS) + ",name:" + params.get(EgamePay.PAY_PARAMS_KEY_TOOLS_NAME) + ",erroInt:" + erroInt + "}";
- SendMessage(result);
- }
-
- @Override
- public void payCancel(Map<String, String> params)
- {
- String result = "{result:2,altas:" + params.get(EgamePay.PAY_PARAMS_KEY_TOOLS_ALIAS) + ",name:" + params.get(EgamePay.PAY_PARAMS_KEY_TOOLS_NAME) + "}";
- SendMessage(result);
- }
- });
- }
-
- // 暂停
- public static void OnPause()
- {
- Handler handler = new Handler(Looper.getMainLooper());
- handler.post(new Runnable()
- {
- @Override
- public void run()
- {
- EgameAgent.onPause(getActivity());
- }
- });
- }
-
- // 恢复
- public static void OnResume()
- {
- Handler handler = new Handler(Looper.getMainLooper());
- handler.post(new Runnable()
- {
- @Override
- public void run()
- {
- EgameAgent.onResume(getActivity());
- }
- });
- }
-
- public static void SetListener(String _objectName, String _ckFun)
- {
- ObjectName = _objectName;
- CkFun = _ckFun;
- Log.d(TAG, "SetListener ObjectName:" + ObjectName + ";CkFun:" + CkFun);
- }
-
- // 发送消息给Unity
- public static void SendMessage(String dataStr)
- {
- Log.d(TAG, "支付结果:" + dataStr);
- if (!ObjectName.isEmpty() && !CkFun.isEmpty())
- {
- UnityPlayer.UnitySendMessage(ObjectName, CkFun, dataStr);
- }
- }
- }
5、Unity调用jar包得接口:
- using UnityEngine;
- using System.Collections;
- #if UNITY_ANDROID
- public class EgameBinding
- {
- const string PAKAGE_PATH = "com.iap.egame.Egame_IAPController";
- /// <summary>
- /// 初始化
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="callback">Callback.</param>
- public static void Init (string target, string callback)
- {
- AndroidJavaClass ac = new AndroidJavaClass (PAKAGE_PATH);
- ac.CallStatic ("Init", target, callback);
- }
- /// <summary>
- /// 发起支付
- /// </summary>
- /// <param name="paycode">Paycode.</param>
- /// <param name="nameStr">nameStr.</param>
- public static void Order (string paycode, string nameStr)
- {
- AndroidJavaClass ac = new AndroidJavaClass (PAKAGE_PATH);
- ac.CallStatic ("Order", paycode, nameStr);
- }
- /// <summary>
- /// 暂停
- /// </summary>
- public static void OnPause ()
- {
- AndroidJavaClass ac = new AndroidJavaClass (PAKAGE_PATH);
- ac.CallStatic ("OnPause");
- }
- /// <summary>
- /// 恢复
- /// </summary>
- public static void OnResume ()
- {
- AndroidJavaClass ac = new AndroidJavaClass (PAKAGE_PATH);
- ac.CallStatic ("OnResume");
- }
- /// <summary>
- /// 设置监听
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="callback">Callback.</param>
- public static void SetListener (string target, string callback)
- {
- AndroidJavaClass ac = new AndroidJavaClass (PAKAGE_PATH);
- ac.CallStatic ("SetListener", target, callback);
- }
- }
- #endif
|