Pay
Unity3D
Outline
Access Guide
FAQ
Android
Outline
Access Guide
FAQ
IOS
Outline
Access Guide
FAQ
Others
Data Structure
System Tools
Pay / Android / Outline

Outline

Tencent Games uses Midas to pay in a unified way. Midas is the official mobile payment SDK provided by Tencent and can provide Q-currency, Q-card, TenPay, bank card and WeChat payment, mobile prepaid cards, phone fee and other payment channels. It provides native Android and iap (Apple Official Edition) payment SDK and a full set of payment services, including support for marketing campaigns. Here is only a brief introduction for it. For details, please refer to Midas wiki.

Access Guide

1 Preconditions

1) Complete access to MSDK login

When you make payment, you need to fill in some token information, such as mobile QQ's appid and appkey as well as WeChat's appid; pf, pfkey, openid, pay_token (needed for mobile QQ login), accessToken (needed for WeChat login). Such information is obtained after login succeeds. Please refer to login function and How to get the token information. In addition, you also need to pass in offerid. As for offered, please go to http://midas.qq.com to apply for it. When applying for it, please Note: need to have the project team's public QQ account. When you apply for payment ID, it is not recommended to use your private QQ account.

2)Complete other requirements of Midas

For details, please refer to Preparations for access to Midas.

2 Configure the game's payment information

You need to configure the basic information of the game and the payment information in Midas' Billing access site

Administrator account, product manager, development manager, and operation & maintenance manager's RTX;

Mobile QQ's appid and appkey, WeChat's appid;

App name, game coin name and exchange rate;

Billing method: recharge the game coin card or directly buy items;

For details, please refer to Andorid payment configuration details.

After you complete the configuration of such information, you can start access to SDK and joint debugging.

3 Access to Midas SDK and joint debugging

Mainly divided into three steps:

1) Import MidasSDK files

2)Configure AndroidManifest.xml

3) Call Midas payment interface

For details, please seeAccess to SDK

4 Access to Midas server interfaces and joint debugging

Midas provides payment interfaces which the server can call, including querying the game coin balance, recharge, consignment, marketing and so on. For more information, please see Midas's backend API specification.

5 Precautions for online payment

It is needed to submit documents for audit and switch to the formal environment. Please refer to How to go online-Android.

Access to SDK

1 Import MidasSDK files

First go to Midas official website download AndroidSDK.

1)Copy MidasSDK\libs\MidasPluginXX.jar into the assets directory of the Android app project.

2)Copy MidasSDK\asset\MidasPay.zip into the assets directory of the Android app project.

3) Copy four resources in MidasSDK\res\anim into res\en directory of the app project

4) WeChat payment channel integration. If you have integrated WeChat-related payment packages such as MSDK, you can't copy libammsdk.jar; otherwise, you need to copy libammsdk.jar package into the libs directory, so that you can use WeChat payment channel.

5) QQ wallet channel integration. It is needed to copy mqqopenpay.jar package (into the libs directory).

6) Instructions on how to import login jar package

For a WeChat app needing to call in-SDK login or a mobile QQ self-developed app needing to call in-SDK login, it needs wlogin_sdk.jar. If the app already contains wlogin_sdk.jar, it can share it. For apps that do not need to call in-SDK login, such as the Game Hall platform, you can delete the packages in the red box (in the libs directory) in the following screenshot. Midas 1.3.9 version uses Wtlogin 5.2 version ; but Midas is also compatible with Wtlogin's lower versions.

7) Special attention: libwtecdh.so library in libs\armeabi directory and libs\x86 directory of MidasPaySample is the library required by the new versions of wtlogin (5.x and above). If your game uses the low version of wtlogin (4.x), you need to delete wlogin_sdk.jar and so library in libs\armeabi directory and libs\x86 directory

2 Configure AndroidManifest.xml

1) App permission declaration. Please add the following permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />

2) Add Activity declaration

<activity 
           android:name="com.tencent.midas.proxyactivity.APMidasPayProxyActivity"
           android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="orientation|keyboardHidden|screenSize”
           android:screenOrientation="landscape" />    
<activity
           android:name="com.tencent.midas.wx.APMidasWXPayActivity"
           android:theme="@android:style/Theme.Translucent.NoTitleBar"
           android:exported="true" />
<activity
           android:name="com.tencent.midas.qq.APMidasQQWalletActivity"
           android:launchMode="singleTop"
           android:theme="@android:style/Theme.Translucent.NoTitleBar"
           android:configChanges="orientation|keyboardHidden" 
           android:exported="true" >
           <intent-filter>
              <action android:name="android.intent.action.VIEW" />
              <category android:name="android.intent.category.BROWSABLE"/> 
              <category android:name="android.intent.category.DEFAULT"/> 
              <data android:scheme="qwallet100703379"/>
           </intent-filter>
       </activity>
 <activity android:name="com.tencent.midas.jsbridge.APWebJSBridgeActivity"
                       android:theme="@android:style/Theme.Translucent.NoTitleBar"
                       android:windowSoftInputMode="stateAlwaysHidden"/>

3) Other configurations

android:targetSdkVersion is greater than or equal to 13, then set

android:configChanges="orientation|keyboardHidden|screenSize

android:targetSdkVersion is less than 13, then set 

android:configChanges="orientation|keyboardHidden

For details, please refer to Access to Midas ANDROID SDK.

3 Call Midas payment interface

Here only provides a brief description and some examples of token payment/item payment to facilitate you to quickly understand the access steps. For details, please refer to Midas SDK interface description.

1) Call Midas SDK's initialization interface

a)Function description

Initialize Midas SDK

b)Interface declaration

public static void init(Activity activity, APMidasBaseRequest request)

c)Parameter description

Parameter name Type Description
gameActivity Activity game Activity
request APMidasBaseRequest Midas payment request

d)Return value

None

e)Demo code

APMidasGameRequest initRequest = new APMidasGameRequest();
LoginRet lr = new LoginRet();
WGPlatform.WGGetLoginRecord(lr);

initRequest.offerId = WeGame.getInstance().offerId;
initRequest.openId = lr.open_id;

if(lr.platform == WeGame.QQPLATID){
    initRequest.openKey = lr.getTokenByType(TokenType.eToken_QQ_Pay);
    initRequest.sessionType = "kp_actoken";
    initRequest.sessionId = "openid";

}else if(lr.platform == WeGame.WXPLATID){
    initRequest.openKey = lr.getTokenByType(TokenType.eToken_WX_Access);
    initRequest.sessionType = "wc_actoken";
    initRequest.sessionId = "hy_gameid";
}


initRequest.pf = WGPlatform.WGGetPf("");

initRequest.pfKey = WGPlatform.WGGetPfKey();

APMidasPayAPI.init(mainActivity, initRequest);

2) Environment parameter settings

a)Function description

Environmental parameter settings: "test" stands for the payment sandbox environment, and "release" represents the payment official environment. It is recommended that when an app is accessed, it should first be tested in the sandbox environment and then be switched to "release" and then released after the test passes.

b)Interface declaration

public static void setEnv(String env)

c)Parameter description

Parameter name Type Description
env String payment environment

d)Return value

None

e)Demo code

APMidasPayAPI.setEnv(APMidasPayAPI.ENV_TEST);

3) Call the payment interface to pay

a)Function description

Open the recharge module UI, guide the user to complete the recharge of the game coin. For the recharge amount, payment SDK provides a default value, and the user can modify it. (Note: The method needs to run on the main thread) IAPMidasPayCallBack is the callback of payment and returns the payment result. As for its specific use method, please see the following example. Note Please fill in the corresponding sessionType according to the platform. A description has been given in the example.

b)Interface declaration

public static void launchPay(Activity activity, APMidasBaseRequest request,IAPMidasPayCallBack callBack)

c)Parameter description

Parameter name Type Description
activity Activity game Activity in the payment
request APMidasBaseRequest Midas Payment Request
callBack IAPMidasPayCallBack Midas payment callback interface

d)Return value

None

e)Demo code

APMidasGameRequest request = new APMidasGameRequest();
request.offerId = offerId;
request.openId = userId;
request.openKey = userKey;//for mobile QQ, it is paytoken; for WeChat, it is accesstoken
request.sessionId = sessionId;
request.sessionType = sessionType;//for mobile QQ, it is "kp_actoken"; for WeChat, it is "wc_actoken"
request.zoneId = "1";
request.pf = pf;
request.pfKey = pfKey;
request.acctType = "common";
request.saveValue = "";//not specified quantity. Here directly enter the purchase quantity selection list
request.resId = R.drawable.sample_yuanbao;

APMidasPayAPI.launchPay(gameActivity, request, 

                        new IAPMidasPayCallBack(){

                        @Override
                        public void MidasPayCallBack(APMidasResponse arg0) {
                            Log. d("MSDK_PAY", "payment sdk calls back app" );

                            switch(response.resultCode){
                            case APMidasResponse.PAYRESULT_ERROR:
                                Log. d("MSDK_PAY", "payment error" );
                                break;
                            case APMidasResponse.PAYRESULT_CANCEL:
                                Log. d("MSDK_PAY", "The user cancels payment" );
                                break;
                            case APMidasResponse.PAYRESULT_SUCC:
                                Log. d("MSDK_PAY", "payment succeeds" );

                            }

                        }

                        @Override
                        public void MidasPayNeedLogin() {
                            Log. d("MSDK_PAY", "login token expire; please login again" );

                        }

                    });

4) Log print switch

a)Function description

Open the log switch. Midas will print the paymentlog for easy debugging.

b)Interface declaration

public static void setLogEnable(boolean logEnable)

c)Parameter description

Parameter name Type Description
logEnable boolean true: open, false: close

d)Return value

None

e)Demo code

APMidasPayAPI.setLogEnable(true);

FAQ

When you access MIDAS ANDROID SDK, if you find that there are WeChat SDK (libammsdk.jar) and mid-related SDK (mid - ***. jar) in the unpacked Miads installation package and they conflict with the associated jar packages in MSDKLibrary, you should delete the corresponding jar packages.