[Android game development SDK] registration and payment summary

Copyright: https://blog.csdn.net/qq_30054199/article/details/90401081

 

Recently the company which engaged in IOS landing and payment process I also wrote an interest in the forum can click to see put in the address below

[IOS] game development SDK landing and payment summary

SDK access to understand the various processes of
a flowchart of first processing module clearly following login

The first step: landing module SDK client uploads the user name as well as password, App_id SDK and other data to the server
Step two: SDK Server client ID, User_token and other uploaded to the SDK client
third step: the SDK client data uploaded to the game client
step four: get the game client data to upload data to the server game
step five: the game server will App_id, user id, user_token, as well as sign and other uploaded to the server SDK
step Six: SDK server will validate the results uploaded to the game server
step Seven: the game server will be landing in the results returned to the game client (game server, we need to Sign for secondary verification, and then returns the results to the client )

Simply means that we get the SDK data server, and then uploaded to the server through the game process (sign value for comparison may be passed over a field splice form SDK md5 code and the server side, the same as the next step, the different die or we will splice data, the splicing of data used to request SDK server, then the server returns the result SDK) to enter the last successful login choose clothes page

ps: SDK client or game server upload and field validation requirements are not necessarily the same access specifically to see each SDK documentation

 

Here then is a flow chart AppStore payment module is actually equivalent to the position of third-party platform but also because the principles are the same so I put a little clear picture of the process

 

php支付在客户端下单后,将信息传给sdk服务器后,sdk自己支付成功后会调用我们一个支付回调,这就需要我们配置好一个charge的php文件,具体实现是利用sdk返回的参数以及充值本身参数拼接出一个验证签名,对sdk返回的sign做一个校验,成功则返回sucess,否则返回fail

 

先将游戏资源以及Android工程创建好  因为涉及到公司里面的一些流程 所以就不写具体的流程了

而且大部分的SDK接入都是用的是eclipse接入 所以需要在eclipse里面做工程

1.eclipse导入工程且修改包名 改成渠道需要的包名

修改包名可以参考以下文章
eclipse修改包名

ps:①这一步的目的是因为渠道申请SDK时用的包名需要和我们创建项目的包名一致,且如果包名相同android识别的是同一个app,且包名是一个应用的唯一身份标示。
②如果AndroidManifest.xml没有修改包名在自动打包时会报错。(公司中用的是一套自动打包平台 所以也得需要修改)

 

2.把第三方库文件(jar等)存放到libs中

一般情况是第三方SDK所需的jar包 有则放 没有可以不放

ps:这一步的目的是导入第三方SDK的资源

3.将游戏资源放在accets文件夹中

ps:在我们自动创建项目的时是没有导入游戏引擎和资源的所以我们在run程序之前需要将游戏引擎和资源导入。

 

4.platform文件夹里面的platform.lua文件需要在以前的apk文件中复制一份出来导入到platform文件夹中
将platform.lua中的loading_mode = "1",改为0;还需要将ditch_name修改为center的地址

其中: --1为SDK登录;0为内网游戏登录

config_url= "http://xxxxx.center.xxx.xxxxx.com/api/mobile_config.php",
        ditch_name ="center",

5. Run test
whether the game can run

 

The flow of specific processes of our project can be operated in accordance with the needs of each company project

Client access code

Related SDK introduced a jar according to the requirements provided in the SDK or imported documents related to the project started and the access code each interface items, mainly as far as the access to do access various pieces of information provided in the SDK access to do with the main thread.

** The following lists the common access interface code **
1. Initialization interface access

    @Override
    public void _Qdinit(Activity context)
    {
        mContext = context;
        //游戏初始化接口,可以在里完成SDK的初始化,具体初始化主要参考SDK文档

    }

2. Log Interface

    @Override
    public void _QdopenLogin()
    {
    //游戏的登陆接口 
             CGamexSDK.login(mContext);

    }

Note that sometimes SDK may be error, not a need to increase landed with the rear port

@Override
    public void _QdopenLogin(int type)
    {
             CGamexSDK.login(mContext);
    }

3. Exit Interface

    @Override
    public void _Qdlogout(String username)
    {
            CGamexSDK.logout(mContext);
    }

4. The payment interface

    @Override
    public void _QdopenPay(int chargeId, int amount, int price, int pid,
            int sid, int rid, String platformUserId, String platformUserName,
            String serverName, String moneyName, float exchange,
            String roleName, String extra, String ext1, String ext2, String ext3) {
        // TODO Auto-generated method stub
        //常见参数说明
        //amount :对应的元宝数量
        //price :充值金额(Rmb)
        //sid:所在服务器id
        //rid :角色id
        //serverName :所在服务器名称
        //moneyName :理解成元宝
        //platUserId 用户登录id
        //pid:玩家账号id
        //roleName :角色名
        //extra :我们自己的订单号
        //ext2:用户等级(可选,根据sdk需要而定)
        //ext3:支付回调(可选)
        //exchange:(默认兑换比例)
        //chargeId :商品ID

    }

5. Role Initialization Interface

    @Override
    public void _QdsetUserInfo(int pid, int sid, int rid,
            String platformUserId, String platformUserName, String serverName,
            String roleName, int roleLevel, String extraInfo)
    {
        // TODO Auto-generated method stub
        //上传角色信息接口,游戏角色的创建,登陆,升级都会调用此接口
    }



The following is the access to the life cycle of the program

The main reference SDK is required to modify the life-cycle approach

 


Some need to use the SDK to return their return method can increase the life cycle of this code

@Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        // TODO Auto-generated method stub
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN 
                  && event.getRepeatCount() == 0 ) {       
            if (this != null ||  cgamexPlatformSdk.globalGameInfo != null){
                CGamexSDK.exit(this, cgamexPlatformSdk.globalGameInfo, new IExitGameListener() {
                    @Override
                    public void onSdkExit() {
                        // 即将退出游戏,如有必要,调用方可以在这里保存游戏数据
                        Log.i(TAG, "sdk exit");
                        Log.i(TAG, "gameInfo " + cgamexPlatformSdk.globalGameInfo);
                    }
                });
            }
            return true;
              } else {
                  return super.dispatchKeyEvent(event);
              }
    }

** AndroidManifest.xml configuration **

You need permission needed and some SDK components written in AndroidManifest.xml, and what rights need to see the specific components selected SDK.

PHP articles

PHP landing papers

Here you should be familiar with network flow beginning of this article

Let me talk about this because I recently also responsible for the company's end IOS SDK for PHP developers access is actually IOS and Android IOS and Android interworking

It is common but be careful Appid or appkey there are different places to do switch.case end in php  

Think twice this part of the code related to the company's privacy will not be disclosed, but it can provide ideas to do this

Substantially return value and then returns splicing url or sign of a value obtained by sdk correct character than needed to return the SDK  

Followed by a successful login and issuance of ingot

PS: there may need to channel the php callback! have to be aware of is

Then run the project once to see if you can log in and recharge 

Follow-up with a company here automatic packing so much to write a similar process is that it is the duty SDK has many pit so you have to pay more attention to it!

 

Guess you like

Origin blog.csdn.net/qq_30054199/article/details/90401081