Commit 84509c18a4f0d7ae2092550b32b94a2a896e24ee
1 parent
e845715e17
Exists in
master
v1.0.5
微信支付修改为web形式
Showing 8 changed files with 58 additions and 50 deletions Inline Diff
- InlandSDKDemo/AndroidManifest.xml
- InlandSDKDemo/src/com/gump/inland/sdk/demo/MainActivity.java
- InlandSDKDemo/src/com/ninjaonline/wxapi/WXPayEntryActivity.java
- InlandSDKRelease/libs/InlandSDK_v1.0.4_proguard.jar
- InlandSDKRelease/libs/InlandSDK_v1.0.5_proguard.jar
- InlandSDKRelease/res/layout/pay_container.xml
- InlandSDKRelease/res/values/strings.xml
- IntegrationGuide.md
InlandSDKDemo/AndroidManifest.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | package="com.ninjaonline" | 3 | package="com.ninjaonline" |
4 | android:versionCode="1" | 4 | android:versionCode="1" |
5 | android:versionName="1.0" > | 5 | android:versionName="1.0" > |
6 | 6 | ||
7 | <uses-sdk | 7 | <uses-sdk |
8 | android:minSdkVersion="10" | 8 | android:minSdkVersion="10" |
9 | android:targetSdkVersion="21" /> | 9 | android:targetSdkVersion="21" /> |
10 | 10 | ||
11 | <uses-permission android:name="android.permission.INTERNET" /> | 11 | <uses-permission android:name="android.permission.INTERNET" /> |
12 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | 12 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
13 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 13 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
14 | <uses-permission android:name="android.permission.BLUETOOTH" /> | 14 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
15 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | 15 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> |
16 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 16 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
17 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | 17 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
18 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | 18 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> |
19 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> | 19 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> |
20 | <!-- 以下是银联支付专用 --> | 20 | <!-- 以下是银联支付专用 --> |
21 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> | 21 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> |
22 | |||
23 | 22 | ||
24 | <application | 23 | <application |
25 | android:allowBackup="true" | 24 | android:allowBackup="true" |
26 | android:icon="@drawable/ic_launcher" | 25 | android:icon="@drawable/ic_launcher" |
27 | android:label="@string/app_name" > | 26 | android:label="@string/app_name" > |
28 | <activity | 27 | <activity |
29 | android:name="com.gump.inland.sdk.demo.MainActivity" | 28 | android:name="com.gump.inland.sdk.demo.MainActivity" |
30 | android:screenOrientation="landscape" | ||
31 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 29 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
32 | android:label="@string/app_name" > | 30 | android:label="@string/app_name" |
31 | android:screenOrientation="landscape" > | ||
33 | <intent-filter> | 32 | <intent-filter> |
34 | <action android:name="android.intent.action.MAIN" /> | 33 | <action android:name="android.intent.action.MAIN" /> |
34 | |||
35 | <category android:name="android.intent.category.LAUNCHER" /> | 35 | <category android:name="android.intent.category.LAUNCHER" /> |
36 | </intent-filter> | 36 | </intent-filter> |
37 | <intent-filter> | 37 | <intent-filter> |
38 | <action android:name="android.intent.action.VIEW" /> | 38 | <action android:name="android.intent.action.VIEW" /> |
39 | 39 | ||
40 | <category android:name="android.intent.category.DEFAULT" /> | 40 | <category android:name="android.intent.category.DEFAULT" /> |
41 | 41 | ||
42 | <data android:scheme="wxdb562d299ac311e0" /> | 42 | <data android:scheme="wxdb562d299ac311e0" /> |
43 | </intent-filter> | 43 | </intent-filter> |
44 | </activity> | 44 | </activity> |
45 | <activity | 45 | <activity |
46 | android:name="com.gump.inland.gamesdk.PassportBaseActivity" | 46 | android:name="com.gump.inland.gamesdk.PassportBaseActivity" |
47 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 47 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
48 | android:launchMode="singleTask" | ||
48 | android:theme="@style/Theme.TransparentWin" > | 49 | android:theme="@style/Theme.TransparentWin" > |
49 | </activity> | 50 | </activity> |
50 | <!-- wx callback --> | 51 | <!-- wx callback --> |
51 | <activity | 52 | <!-- <activity --> |
52 | android:name="com.ninjaonline.wxapi.WXPayEntryActivity" | 53 | <!-- android:name="com.ninjaonline.wxapi.WXPayEntryActivity" --> |
53 | android:exported="true" > | 54 | <!-- android:exported="true" > --> |
54 | </activity> | 55 | <!-- </activity> --> |
55 | <!-- unionPay --> | 56 | <!-- unionPay --> |
56 | <activity | 57 | <activity |
57 | android:name="com.unionpay.uppay.PayActivity" | 58 | android:name="com.unionpay.uppay.PayActivity" |
58 | android:configChanges="orientation|keyboardHidden" | 59 | android:configChanges="orientation|keyboardHidden" |
59 | android:excludeFromRecents="true" | 60 | android:excludeFromRecents="true" |
60 | android:label="@string/app_name" | 61 | android:label="@string/app_name" |
61 | android:screenOrientation="portrait" | 62 | android:screenOrientation="portrait" |
62 | android:windowSoftInputMode="adjustResize" /> | 63 | android:windowSoftInputMode="adjustResize" /> |
63 | <!-- alipay sdk begin --> | 64 | <!-- alipay sdk begin --> |
64 | <activity | 65 | <activity |
65 | android:name="com.alipay.sdk.app.H5PayActivity" | 66 | android:name="com.alipay.sdk.app.H5PayActivity" |
66 | android:configChanges="orientation|keyboardHidden|navigation" | 67 | android:configChanges="orientation|keyboardHidden|navigation" |
67 | android:exported="false" | 68 | android:exported="false" |
68 | android:screenOrientation="behind" | 69 | android:screenOrientation="behind" |
69 | android:windowSoftInputMode="adjustResize|stateHidden" > | 70 | android:windowSoftInputMode="adjustResize|stateHidden" > |
70 | </activity> | 71 | </activity> |
71 | 72 | ||
72 | <!-- alipay sdk end --> | 73 | <!-- alipay sdk end --> |
74 | |||
75 | <activity | ||
76 | android:name="com.gump.inland.gamesdk.PurchaseActivity" | ||
77 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
78 | android:launchMode="singleTask" | ||
79 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | ||
80 | </activity> | ||
73 | </application> | 81 | </application> |
InlandSDKDemo/src/com/gump/inland/sdk/demo/MainActivity.java
1 | package com.gump.inland.sdk.demo; | 1 | package com.gump.inland.sdk.demo; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.util.Log; | 6 | import android.util.Log; |
7 | import android.view.View; | 7 | import android.view.View; |
8 | import android.widget.Button; | 8 | import android.widget.Button; |
9 | import android.widget.TextView; | 9 | import android.widget.TextView; |
10 | 10 | ||
11 | import com.gump.inland.gamesdk.InlandSDK; | 11 | import com.gump.inland.gamesdk.InlandSDK; |
12 | import com.gump.inland.gamesdk.InlandSDKCallback; | 12 | import com.gump.inland.gamesdk.InlandSDKCallback; |
13 | import com.gump.inland.gamesdk.InlandSDKException; | 13 | import com.gump.inland.gamesdk.InlandSDKException; |
14 | import com.gump.inland.gamesdk.bean.GumpUser; | 14 | import com.gump.inland.gamesdk.bean.GumpUser; |
15 | import com.gump.inland.gamesdk.bean.PayRequest; | 15 | import com.gump.inland.gamesdk.bean.PayRequest; |
16 | import com.gump.inland.gamesdk.callback.PurchaseCallback; | 16 | import com.gump.inland.gamesdk.callback.PurchaseCallback; |
17 | import com.gump.inland.gamesdk.passport.Passport; | 17 | import com.gump.inland.gamesdk.passport.Passport; |
18 | import com.ninjaonline.R; | 18 | import com.ninjaonline.R; |
19 | 19 | ||
20 | public class MainActivity extends Activity { | 20 | public class MainActivity extends Activity { |
21 | 21 | ||
22 | private static final String TAG = "MainActivity"; | 22 | private static final String TAG = "MainActivity"; |
23 | private TextView tvSDKInfo; | 23 | private TextView tvSDKInfo; |
24 | private TextView tvUserInfo; | 24 | private TextView tvUserInfo; |
25 | private TextView tvPurchaseResult; | 25 | private TextView tvPurchaseResult; |
26 | private Button btnLogin; | 26 | private Button btnLogin; |
27 | private Button btnPay; | 27 | private Button btnPay; |
28 | 28 | ||
29 | @Override | 29 | @Override |
30 | protected void onCreate(Bundle savedInstanceState) { | 30 | protected void onCreate(Bundle savedInstanceState) { |
31 | super.onCreate(savedInstanceState); | 31 | super.onCreate(savedInstanceState); |
32 | setContentView(R.layout.activity_main); | 32 | setContentView(R.layout.activity_main); |
33 | tvSDKInfo = (TextView) findViewById(R.id.sdk_info); | 33 | tvSDKInfo = (TextView) findViewById(R.id.sdk_info); |
34 | tvUserInfo = (TextView) findViewById(R.id.user_info); | 34 | tvUserInfo = (TextView) findViewById(R.id.user_info); |
35 | tvPurchaseResult = (TextView) findViewById(R.id.purchase_result); | 35 | tvPurchaseResult = (TextView) findViewById(R.id.purchase_result); |
36 | btnLogin = (Button) findViewById(R.id.login); | 36 | btnLogin = (Button) findViewById(R.id.login); |
37 | btnPay = (Button) findViewById(R.id.purchase); | 37 | btnPay = (Button) findViewById(R.id.purchase); |
38 | 38 | ||
39 | Log.d(TAG, "MainActivity onCreate"); | 39 | Log.d(TAG, "MainActivity onCreate"); |
40 | InlandSDK.setIsDebugEnable(false); | 40 | InlandSDK.setIsDebugEnable(false); |
41 | InlandSDK.setScreenLandscape(true); | 41 | InlandSDK.setScreenLandscape(true); |
42 | InlandSDK.initializeSDK("10006", "6731f0406495c0a92ea7931f94b307b7"); | 42 | InlandSDK.initializeSDK("10006", "6731f0406495c0a92ea7931f94b307b7"); |
43 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { | 43 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { |
44 | 44 | ||
45 | @Override | 45 | @Override |
46 | public void onSuccess(GumpUser result) { | 46 | public void onSuccess(GumpUser result) { |
47 | Log.d(TAG, "gumpUser:" + result.toString()); | 47 | Log.d(TAG, "gumpUser:" + result.toString()); |
48 | btnLogin.setVisibility(View.GONE); | 48 | btnLogin.setVisibility(View.GONE); |
49 | tvUserInfo.setText(formatUserInfo(result)); | 49 | tvUserInfo.setText(formatUserInfo(result)); |
50 | btnPay.setVisibility(View.VISIBLE); | 50 | btnPay.setVisibility(View.VISIBLE); |
51 | } | 51 | } |
52 | 52 | ||
53 | @Override | 53 | @Override |
54 | public void onError(InlandSDKException error) { | 54 | public void onError(InlandSDKException error) { |
55 | Log.d(TAG, "login error:" + error.getMessage()); | 55 | Log.d(TAG, "login error:" + error.getMessage()); |
56 | } | 56 | } |
57 | 57 | ||
58 | @Override | 58 | @Override |
59 | public void onCancel() { | 59 | public void onCancel() { |
60 | Log.d(TAG, "login be canceled"); | 60 | Log.d(TAG, "login be canceled"); |
61 | } | 61 | } |
62 | }); | 62 | }); |
63 | 63 | ||
64 | tvSDKInfo.setText(getSDKInfo()); | 64 | tvSDKInfo.setText(getSDKInfo()); |
65 | btnLogin.setOnClickListener(new View.OnClickListener() { | 65 | btnLogin.setOnClickListener(new View.OnClickListener() { |
66 | 66 | ||
67 | @Override | 67 | @Override |
68 | public void onClick(View v) { | 68 | public void onClick(View v) { |
69 | Passport.getInstance().login(MainActivity.this); | 69 | Passport.getInstance().login(MainActivity.this); |
70 | } | 70 | } |
71 | }); | 71 | }); |
72 | btnPay.setOnClickListener(new View.OnClickListener() { | 72 | btnPay.setOnClickListener(new View.OnClickListener() { |
73 | 73 | ||
74 | @Override | 74 | @Override |
75 | public void onClick(View v) { | 75 | public void onClick(View v) { |
76 | PayRequest payRequest = new PayRequest(); | 76 | PayRequest payRequest = new PayRequest(); |
77 | payRequest.setPrice(1); | 77 | payRequest.setPrice(1); |
78 | payRequest.setProduct("玄冥剑"); | 78 | payRequest.setProduct("玄冥剑"); |
79 | payRequest.setExtOrder("p100201508311731"); | 79 | payRequest.setExtOrder("p100201508311731"); |
80 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); | 80 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); |
81 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { | 81 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { |
82 | 82 | ||
83 | @Override | 83 | @Override |
84 | public void onPurchaseError(Exception e) { | 84 | public void onPurchaseError(final Exception e) { |
85 | Log.w(TAG, "purchase error:" + e.getMessage()); | 85 | Log.w(TAG, "purchase error:" + e.getMessage()); |
86 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); | 86 | runOnUiThread(new Runnable() { |
87 | |||
88 | @Override | ||
89 | public void run() { | ||
90 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); | ||
91 | } | ||
92 | }); | ||
87 | } | 93 | } |
88 | 94 | ||
89 | @Override | 95 | @Override |
90 | public void onPurchaseSuccess(String gumpTransId, String extOrder) { | 96 | public void onPurchaseSuccess(final String gumpTransId, final String extOrder) { |
91 | Log.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); | 97 | Log.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); |
92 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); | 98 | runOnUiThread(new Runnable() { |
99 | |||
100 | @Override | ||
101 | public void run() { | ||
102 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); | ||
103 | } | ||
104 | }); | ||
93 | } | 105 | } |
94 | 106 | ||
95 | @Override | 107 | @Override |
96 | public void onPurchaseCanceled() { | 108 | public void onPurchaseCanceled() { |
97 | Log.d(TAG, "purchase be canceled"); | 109 | Log.d(TAG, "purchase be canceled"); |
98 | tvPurchaseResult.setText("purchase be canceled"); | 110 | runOnUiThread(new Runnable() { |
111 | |||
112 | @Override | ||
113 | public void run() { | ||
114 | tvPurchaseResult.setText("purchase be canceled"); | ||
115 | } | ||
116 | }); | ||
99 | } | 117 | } |
100 | }); | 118 | }); |
101 | } | 119 | } |
102 | }); | 120 | }); |
103 | } | 121 | } |
104 | 122 | ||
105 | @Override | 123 | @Override |
106 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 124 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
107 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) | 125 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) |
108 | super.onActivityResult(requestCode, resultCode, data); | 126 | super.onActivityResult(requestCode, resultCode, data); |
109 | } | 127 | } |
110 | 128 | ||
111 | private String getSDKInfo() { | 129 | private String getSDKInfo() { |
112 | StringBuilder str = new StringBuilder(); | 130 | StringBuilder str = new StringBuilder(); |
113 | str.append("SDK version:"); | 131 | str.append("SDK version:"); |
114 | str.append(InlandSDK.getVersion()); | 132 | str.append(InlandSDK.getVersion()); |
115 | str.append("\nappId:"); | 133 | str.append("\nappId:"); |
116 | str.append(InlandSDK.getAppId()); | 134 | str.append(InlandSDK.getAppId()); |
117 | str.append("\nappKey:"); | 135 | str.append("\nappKey:"); |
118 | str.append(InlandSDK.getAppKey()); | 136 | str.append(InlandSDK.getAppKey()); |
119 | return str.toString(); | 137 | return str.toString(); |
120 | } | 138 | } |
121 | 139 | ||
122 | private String formatUserInfo(GumpUser user) { | 140 | private String formatUserInfo(GumpUser user) { |
123 | StringBuilder str = new StringBuilder(); | 141 | StringBuilder str = new StringBuilder(); |
124 | str.append("Logined User information:\n"); | 142 | str.append("Logined User information:\n"); |
125 | str.append("userId:" + user.getUid()); | 143 | str.append("userId:" + user.getUid()); |
126 | str.append("\nacccountType:" + user.getAccountType()); | 144 | str.append("\nacccountType:" + user.getAccountType()); |
127 | str.append("\nsessionKey:" + user.getSessionKey()); | 145 | str.append("\nsessionKey:" + user.getSessionKey()); |
128 | return str.toString(); | 146 | return str.toString(); |
129 | } | 147 | } |
130 | } | 148 | } |
131 | 149 |
InlandSDKDemo/src/com/ninjaonline/wxapi/WXPayEntryActivity.java
1 | package com.ninjaonline.wxapi; | File was deleted | |
2 | |||
3 | public class WXPayEntryActivity extends com.gump.inland.gamesdk.WXPayEntryBaseActivity { | ||
4 | |||
5 | } | ||
6 | 1 | package com.ninjaonline.wxapi; |
InlandSDKRelease/libs/InlandSDK_v1.0.4_proguard.jar
No preview for this file type
InlandSDKRelease/libs/InlandSDK_v1.0.5_proguard.jar
No preview for this file type
InlandSDKRelease/res/layout/pay_container.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | android:background="@color/payment_common_bg" | 5 | android:background="@color/payment_common_bg" |
6 | android:orientation="vertical" > | 6 | android:orientation="vertical" > |
7 | 7 | ||
8 | <Button | 8 | <ProgressBar |
9 | android:id="@+id/wx_pay" | 9 | android:id="@+id/loading_prog" |
10 | style="@android:style/Widget.ProgressBar.Horizontal" | ||
10 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
11 | android:layout_height="wrap_content" | 12 | android:layout_height="2dp" /> |
12 | android:text="微信支付" /> | ||
13 | 13 | ||
14 | <Button | 14 | <WebView |
15 | android:id="@+id/ali_pay" | 15 | android:id="@+id/mycard_web" |
16 | android:layout_width="match_parent" | 16 | android:layout_width="fill_parent" |
17 | android:layout_height="wrap_content" | 17 | android:layout_height="fill_parent" /> |
18 | android:text="支付宝" /> | ||
19 | 18 | ||
20 | <Button | 19 | <!-- <LinearLayout --> |
21 | android:id="@+id/union_pay" | 20 | <!-- android:id="@+id/container" --> |
22 | android:layout_width="match_parent" | 21 | <!-- android:layout_width="match_parent" --> |
23 | android:layout_height="wrap_content" | 22 | <!-- android:layout_height="wrap_content" --> |
24 | android:text="银联支付" /> | 23 | <!-- android:orientation="vertical" > --> |
24 | <!-- </LinearLayout> --> |
InlandSDKRelease/res/values/strings.xml
1 | <resources> | 1 | <resources> |
2 | 2 | ||
3 | <string name="user_name_hint">邮箱</string> | 3 | <string name="user_name_hint">邮箱</string> |
4 | <string name="password_hint">密码</string> | 4 | <string name="password_hint">密码</string> |
5 | <string name="switch_user">切换用户</string> | 5 | <string name="switch_user">切换用户</string> |
6 | <string name="loging">加载中……</string> | 6 | <string name="loging">加载中……</string> |
7 | <string name="loading">加载中……</string> | 7 | <string name="loading">加载中……</string> |
8 | 8 | ||
9 | <string name="signup">注册</string> | 9 | <string name="signup">注册</string> |
10 | <string name="login">登录</string> | 10 | <string name="login">登录</string> |
11 | <string name="quick_play">一键登录</string> | 11 | <string name="quick_play">一键登录</string> |
12 | <!-- toast --> | 12 | <!-- toast --> |
13 | <string name="illegal_uname_tip">请输入正确的邮箱</string> | 13 | <string name="illegal_uname_tip">请输入正确的邮箱</string> |
14 | <string name="illegal_pwd_tip">密码格式不正确 (请输入6–20字符)</string> | 14 | <string name="illegal_pwd_tip">密码格式不正确 (请输入6–20字符)</string> |
15 | <string name="illegal_user_exist">邮箱已注册</string> | 15 | <string name="illegal_user_exist">邮箱已注册</string> |
16 | <string name="illegal_pwd_invalid">密码不正确,请重试</string> | 16 | <string name="illegal_pwd_invalid">密码不正确,请重试</string> |
17 | <string name="illegal_user_not_exist">邮箱未注册</string> | 17 | <string name="illegal_user_not_exist">邮箱未注册</string> |
18 | <string name="invalid_email">请输入正确的邮箱</string> | 18 | <string name="invalid_email">请输入正确的邮箱</string> |
19 | <string name="login_fail">登录失败</string> | 19 | <string name="login_fail">登录失败</string> |
20 | <string name="signup_fail">注册失败</string> | 20 | <string name="signup_fail">注册失败</string> |
21 | <string name="signup_success">注册成功</string> | 21 | <string name="signup_success">注册成功</string> |
22 | <string name="gen_quick_acc_err">登录失败,请重试</string> | 22 | <string name="gen_quick_acc_err">登录失败,请重试</string> |
23 | <string name="quick_login_err">登录失败,请重试</string> | 23 | <string name="quick_login_err">登录失败,请重试</string> |
24 | <string name="net_error">网络无法连接,请查看网络设置</string> | 24 | <string name="net_error">网络无法连接,请查看网络设置</string> |
25 | 25 | ||
26 | <string-array name="payment_channel"> | 26 | <string-array name="payment_channel"> |
27 | <item>支付宝</item> | 27 | <item>支付宝</item> |
28 | <!-- <item>银联支付</item> --> | 28 | <item>银联支付</item> |
29 | <!-- <item>微信支付</item> --> | 29 | <item>微信支付</item> |
30 | </string-array> | 30 | </string-array> |
31 | <string-array name="payment_channel_without_wx"> | 31 | <string-array name="payment_channel_without_wx"> |
32 | <item>支付宝</item> | 32 | <item>支付宝</item> |
33 | <!-- <item>银联支付</item> --> | 33 | <item>银联支付</item> |
34 | </string-array> | 34 | </string-array> |
35 | </resources> | 35 | </resources> |
IntegrationGuide.md
1 | ## InlandSDK integration guide | 1 | ## InlandSDK integration guide |
2 | ### 本sdk包含登录和支付功能,支付包含微信支付,支付宝支付和银联支付,因此接入前请申请好各支付渠道的参数 | 2 | ### 本sdk包含登录和支付功能,支付包含微信支付,支付宝支付和银联支付,因此接入前请申请好各支付渠道的参数 |
3 | 1.获取gump分配的appid和appkey | 3 | 1.获取gump分配的appid和appkey |
4 | 2.导入InlandSDK库工程,并将自己的android工程设置引用此库工程 | 4 | 2.导入InlandSDK库工程,并将自己的android工程设置引用此库工程 |
5 | 3.配置AndroidManifest.xml,分为3部分 | 5 | 3.配置AndroidManifest.xml,分为3部分 |
6 | 1)确保有以下permission: | 6 | 1)确保有以下permission: |
7 | 7 | ||
8 | <uses-permission android:name="android.permission.INTERNET" /> | 8 | <uses-permission android:name="android.permission.INTERNET" /> |
9 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | 9 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
10 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 10 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
11 | <uses-permission android:name="android.permission.BLUETOOTH" /> | 11 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
12 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | 12 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> |
13 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 13 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
14 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | 14 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
15 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | 15 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> |
16 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> | 16 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> |
17 | <!-- 以下是银联支付专用 --> | 17 | <!-- 以下是银联支付专用 --> |
18 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> | 18 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> |
19 | 19 | ||
20 | 2)需要在application内增加如下内容,**微信回调activity必须是 "项目包名.wxapi.WXPayEntryActivity",不可更改,且此activity需继承com.gump.inland.gamesdk.WXPayEntryBaseActivity**: | 20 | 2)需要在application内增加如下内容: |
21 | 21 | ||
22 | <activity | 22 | <activity |
23 | android:name="com.gump.inland.gamesdk.PassportBaseActivity" | 23 | android:name="com.gump.inland.gamesdk.PassportBaseActivity" |
24 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 24 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
25 | android:theme="@style/Theme.TransparentWin" > | 25 | android:theme="@style/Theme.TransparentWin" > |
26 | </activity> | 26 | </activity> |
27 | <activity | 27 | <activity |
28 | android:name="com.gump.inland.gamesdk.PaymentActivity" | 28 | android:name="com.gump.inland.gamesdk.PaymentActivity" |
29 | android:theme="@android:style/Theme.Light.NoTitleBar" > | 29 | android:theme="@android:style/Theme.Light.NoTitleBar" > |
30 | </activity> | 30 | </activity> |
31 | <!-- wx callback 需要根据规则配置,此处请勿直接拷贝--> | 31 | |
32 | <activity | ||
33 | android:name="yourPackageName.wxapi.WXPayEntryActivity" | ||
34 | android:exported="true" > | ||
35 | </activity> | ||
36 | <!-- unionPay --> | 32 | <!-- unionPay --> |
37 | <activity | 33 | <activity |
38 | android:name="com.unionpay.uppay.PayActivity" | 34 | android:name="com.unionpay.uppay.PayActivity" |
39 | android:configChanges="orientation|keyboardHidden" | 35 | android:configChanges="orientation|keyboardHidden" |
40 | android:excludeFromRecents="true" | 36 | android:excludeFromRecents="true" |
41 | android:label="@string/app_name" | 37 | android:label="@string/app_name" |
42 | android:screenOrientation="portrait" | 38 | android:screenOrientation="portrait" |
43 | android:windowSoftInputMode="adjustResize" /> | 39 | android:windowSoftInputMode="adjustResize" /> |
44 | <!-- alipay sdk begin --> | 40 | <!-- alipay sdk begin --> |
45 | <activity | 41 | <activity |
46 | android:name="com.alipay.sdk.app.H5PayActivity" | 42 | android:name="com.alipay.sdk.app.H5PayActivity" |
47 | android:configChanges="orientation|keyboardHidden|navigation" | 43 | android:configChanges="orientation|keyboardHidden|navigation" |
48 | android:exported="false" | 44 | android:exported="false" |
49 | android:screenOrientation="behind" | 45 | android:screenOrientation="behind" |
50 | android:windowSoftInputMode="adjustResize|stateHidden" > | 46 | android:windowSoftInputMode="adjustResize|stateHidden" > |
51 | </activity> | 47 | </activity> |
52 | <!-- alipay sdk end --> | 48 | <!-- alipay sdk end --> |
53 | 49 | ||
54 | 3)入口activity增加**android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout"**属性,并增加以下Intent-filter,**data scheme配置为微信appid**: | ||
55 | |||
56 | <intent-filter> | ||
57 | <action android:name="android.intent.action.VIEW" /> | ||
58 | |||
59 | <category android:name="android.intent.category.DEFAULT" /> | ||
60 | <!-- 此处为微信的appid--> | ||
61 | <data android:scheme="wxdb562d299ac311e0" /> | ||
62 | </intent-filter> | ||
63 | 50 | ||
64 | 4.将InlandSDKRelease工程assets目录下的文件拷贝到游戏项目的assets目录下,此处为银联支付使用 | 51 | 4.将InlandSDKRelease工程assets目录下的文件拷贝到游戏项目的assets目录下,此处为银联支付使用 |
65 | 5.代码接入: | 52 | 5.代码接入: |
66 | 1)sdk初始化,以下方法二选一 | 53 | 1)sdk初始化,以下方法二选一 |
67 | 54 | ||
68 | //若游戏不区分渠道使用此方法 | 55 | //若游戏不区分渠道使用此方法 |
69 | InlandSDK.initializeSDK(gumpAPPId, GumpAPPKey); | 56 | InlandSDK.initializeSDK(gumpAPPId, GumpAPPKey); |
70 | //若游戏区分渠道使用此方法,传入渠道参数 | 57 | //若游戏区分渠道使用此方法,传入渠道参数 |
71 | InlandSDK.initializeSDK(gumpAppId,GumpAPPKey,channel); | 58 | InlandSDK.initializeSDK(gumpAppId,GumpAPPKey,channel); |
72 | 59 | ||
73 | 2)注册登录状态回调: | 60 | 2)注册登录状态回调: |
74 | 61 | ||
75 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { | 62 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { |
76 | 63 | ||
77 | @Override | 64 | @Override |
78 | public void onSuccess(GumpUser result) { | 65 | public void onSuccess(GumpUser result) { |
79 | Logger.d(TAG, "gumpUser:" + result.toString()); | 66 | Logger.d(TAG, "gumpUser:" + result.toString()); |
80 | btnLogin.setVisibility(View.GONE); | 67 | btnLogin.setVisibility(View.GONE); |
81 | tvUserInfo.setText(formatUserInfo(result)); | 68 | tvUserInfo.setText(formatUserInfo(result)); |
82 | btnPay.setVisibility(View.VISIBLE); | 69 | btnPay.setVisibility(View.VISIBLE); |
83 | } | 70 | } |
84 | 71 | ||
85 | @Override | 72 | @Override |
86 | public void onError(InlandSDKException error) { | 73 | public void onError(InlandSDKException error) { |
87 | Logger.d(TAG, "login error:" + error.getMessage()); | 74 | Logger.d(TAG, "login error:" + error.getMessage()); |
88 | } | 75 | } |
89 | 76 | ||
90 | @Override | 77 | @Override |
91 | public void onCancel() { | 78 | public void onCancel() { |
92 | Logger.d(TAG, "login be canceled"); | 79 | Logger.d(TAG, "login be canceled"); |
93 | } | 80 | } |
94 | }); | 81 | }); |
95 | 82 | ||
96 | 3)执行登录操作 | 83 | 3)执行登录操作 |
97 | 84 | ||
98 | Passport.getInstance().login(MainActivity.this); | 85 | Passport.getInstance().login(MainActivity.this); |
99 | 86 | ||
100 | 4)支付操作 | 87 | 4)支付操作 |
101 | 88 | ||
102 | PayRequest payRequest = new PayRequest(); | 89 | PayRequest payRequest = new PayRequest(); |
103 | payRequest.setPrice(1); | 90 | payRequest.setPrice(1); |
104 | payRequest.setProduct("玄冥剑"); | 91 | payRequest.setProduct("玄冥剑"); |
105 | payRequest.setExtOrder("p100201508311730"); | 92 | payRequest.setExtOrder("p100201508311730"); |
106 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); | 93 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); |
107 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { | 94 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { |
108 | 95 | ||
109 | @Override | 96 | @Override |
110 | public void onPurchaseError(Exception e) { | 97 | public void onPurchaseError(Exception e) { |
111 | Logger.w(TAG, "purchase error:" + e.getMessage()); | 98 | Logger.w(TAG, "purchase error:" + e.getMessage()); |
112 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); | 99 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); |
113 | } | 100 | } |
114 | 101 | ||
115 | @Override | 102 | @Override |
116 | public void onPurchaseSuccess(String gumpTransId, String extOrder) { | 103 | public void onPurchaseSuccess(String gumpTransId, String extOrder) { |
117 | Logger.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); | 104 | Logger.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); |
118 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); | 105 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); |
119 | } | 106 | } |
120 | 107 | ||
121 | @Override | 108 | @Override |
122 | public void onPurchaseCanceled() { | 109 | public void onPurchaseCanceled() { |
123 | Logger.d(TAG, "purchase be canceled"); | 110 | Logger.d(TAG, "purchase be canceled"); |
124 | tvPurchaseResult.setText("purchase be canceled"); | 111 | tvPurchaseResult.setText("purchase be canceled"); |
125 | } | 112 | } |
126 | }); | 113 | }); |
127 | 114 | ||
128 | 5)配置onActivityResult拦截处理,请在activity的onActivityResult方法内增加InlandSDK的处理方法onActivityResult,当此方法返回true时,说明结果已处理,否则说明未对结果进行处理 | 115 | 5)配置onActivityResult拦截处理,请在activity的onActivityResult方法内增加InlandSDK的处理方法onActivityResult,当此方法返回true时,说明结果已处理,否则说明未对结果进行处理 |
129 | 116 | ||
130 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) | 117 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) |
131 | super.onActivityResult(requestCode, resultCode, data); | 118 | super.onActivityResult(requestCode, resultCode, data); |