Commit b9aaf8af505d651c05eb6b88f200a718befbcd4a
0 parents
支付云sdk对接demo
Showing
50 changed files
with
877 additions
and
0 deletions
.gitignore
0 → 100644
.idea/compiler.xml
0 → 100644
| 1 | +++ a/.idea/compiler.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="CompilerConfiguration"> | |
| 4 | + <resourceExtensions /> | |
| 5 | + <wildcardResourcePatterns> | |
| 6 | + <entry name="!?*.java" /> | |
| 7 | + <entry name="!?*.form" /> | |
| 8 | + <entry name="!?*.class" /> | |
| 9 | + <entry name="!?*.groovy" /> | |
| 10 | + <entry name="!?*.scala" /> | |
| 11 | + <entry name="!?*.flex" /> | |
| 12 | + <entry name="!?*.kt" /> | |
| 13 | + <entry name="!?*.clj" /> | |
| 14 | + <entry name="!?*.aj" /> | |
| 15 | + </wildcardResourcePatterns> | |
| 16 | + <annotationProcessing> | |
| 17 | + <profile default="true" name="Default" enabled="false"> | |
| 18 | + <processorPath useClasspath="true" /> | |
| 19 | + </profile> | |
| 20 | + </annotationProcessing> | |
| 21 | + </component> | |
| 22 | +</project> | |
| 0 | 23 | \ No newline at end of file | ... | ... |
.idea/copyright/profiles_settings.xml
0 → 100644
.idea/encodings.xml
0 → 100644
.idea/gradle.xml
0 → 100644
| 1 | +++ a/.idea/gradle.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="GradleSettings"> | |
| 4 | + <option name="linkedExternalProjectsSettings"> | |
| 5 | + <GradleProjectSettings> | |
| 6 | + <option name="distributionType" value="DEFAULT_WRAPPED" /> | |
| 7 | + <option name="externalProjectPath" value="$PROJECT_DIR$" /> | |
| 8 | + <option name="modules"> | |
| 9 | + <set> | |
| 10 | + <option value="$PROJECT_DIR$" /> | |
| 11 | + <option value="$PROJECT_DIR$/app" /> | |
| 12 | + </set> | |
| 13 | + </option> | |
| 14 | + <option name="resolveModulePerSourceSet" value="false" /> | |
| 15 | + </GradleProjectSettings> | |
| 16 | + </option> | |
| 17 | + </component> | |
| 18 | +</project> | |
| 0 | 19 | \ No newline at end of file | ... | ... |
.idea/misc.xml
0 → 100644
| 1 | +++ a/.idea/misc.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="EntryPointsManager"> | |
| 4 | + <entry_points version="2.0" /> | |
| 5 | + </component> | |
| 6 | + <component name="NullableNotNullManager"> | |
| 7 | + <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> | |
| 8 | + <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> | |
| 9 | + <option name="myNullables"> | |
| 10 | + <value> | |
| 11 | + <list size="4"> | |
| 12 | + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> | |
| 13 | + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> | |
| 14 | + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> | |
| 15 | + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> | |
| 16 | + </list> | |
| 17 | + </value> | |
| 18 | + </option> | |
| 19 | + <option name="myNotNulls"> | |
| 20 | + <value> | |
| 21 | + <list size="4"> | |
| 22 | + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> | |
| 23 | + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> | |
| 24 | + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> | |
| 25 | + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> | |
| 26 | + </list> | |
| 27 | + </value> | |
| 28 | + </option> | |
| 29 | + </component> | |
| 30 | + <component name="ProjectLevelVcsManager" settingsEditedManually="false"> | |
| 31 | + <OptionsSetting value="true" id="Add" /> | |
| 32 | + <OptionsSetting value="true" id="Remove" /> | |
| 33 | + <OptionsSetting value="true" id="Checkout" /> | |
| 34 | + <OptionsSetting value="true" id="Update" /> | |
| 35 | + <OptionsSetting value="true" id="Status" /> | |
| 36 | + <OptionsSetting value="true" id="Edit" /> | |
| 37 | + <ConfirmationsSetting value="0" id="Add" /> | |
| 38 | + <ConfirmationsSetting value="0" id="Remove" /> | |
| 39 | + </component> | |
| 40 | + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |
| 41 | + <output url="file://$PROJECT_DIR$/build/classes" /> | |
| 42 | + </component> | |
| 43 | + <component name="ProjectType"> | |
| 44 | + <option name="id" value="Android" /> | |
| 45 | + </component> | |
| 46 | + <component name="masterDetails"> | |
| 47 | + <states> | |
| 48 | + <state key="ProjectJDKs.UI"> | |
| 49 | + <settings> | |
| 50 | + <last-edited>1.8</last-edited> | |
| 51 | + <splitter-proportions> | |
| 52 | + <option name="proportions"> | |
| 53 | + <list> | |
| 54 | + <option value="0.2" /> | |
| 55 | + </list> | |
| 56 | + </option> | |
| 57 | + </splitter-proportions> | |
| 58 | + </settings> | |
| 59 | + </state> | |
| 60 | + </states> | |
| 61 | + </component> | |
| 62 | +</project> | |
| 0 | 63 | \ No newline at end of file | ... | ... |
.idea/modules.xml
0 → 100644
| 1 | +++ a/.idea/modules.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="ProjectModuleManager"> | |
| 4 | + <modules> | |
| 5 | + <module fileurl="file://$PROJECT_DIR$/CNLivePayDemo.iml" filepath="$PROJECT_DIR$/CNLivePayDemo.iml" /> | |
| 6 | + <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> | |
| 7 | + </modules> | |
| 8 | + </component> | |
| 9 | +</project> | |
| 0 | 10 | \ No newline at end of file | ... | ... |
.idea/runConfigurations.xml
0 → 100644
| 1 | +++ a/.idea/runConfigurations.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="RunConfigurationProducerService"> | |
| 4 | + <option name="ignoredProducers"> | |
| 5 | + <set> | |
| 6 | + <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> | |
| 7 | + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> | |
| 8 | + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> | |
| 9 | + </set> | |
| 10 | + </option> | |
| 11 | + </component> | |
| 12 | +</project> | |
| 0 | 13 | \ No newline at end of file | ... | ... |
.idea/vcs.xml
0 → 100644
app/.gitignore
0 → 100644
app/build.gradle
0 → 100644
| 1 | +++ a/app/build.gradle | |
| 1 | +apply plugin: 'com.android.application' | |
| 2 | + | |
| 3 | +android { | |
| 4 | + compileSdkVersion 25 | |
| 5 | + buildToolsVersion "25.0.2" | |
| 6 | + defaultConfig { | |
| 7 | + applicationId "com.cnlive.demo.pay" | |
| 8 | + minSdkVersion 19 | |
| 9 | + targetSdkVersion 25 | |
| 10 | + versionCode 1 | |
| 11 | + versionName "1.0" | |
| 12 | + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |
| 13 | + } | |
| 14 | + | |
| 15 | + signingConfigs { | |
| 16 | + myConfig { | |
| 17 | + storeFile file("test.jks") | |
| 18 | + storePassword "123456" | |
| 19 | + keyAlias "test" | |
| 20 | + keyPassword "654321" | |
| 21 | + } | |
| 22 | + } | |
| 23 | + | |
| 24 | + buildTypes { | |
| 25 | + release { | |
| 26 | + minifyEnabled false | |
| 27 | + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
| 28 | + } | |
| 29 | + debug { | |
| 30 | + signingConfig signingConfigs.myConfig | |
| 31 | + } | |
| 32 | + } | |
| 33 | +} | |
| 34 | + | |
| 35 | +dependencies { | |
| 36 | + compile fileTree(dir: 'libs', include: ['*.jar']) | |
| 37 | + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | |
| 38 | + exclude group: 'com.android.support', module: 'support-annotations' | |
| 39 | + }) | |
| 40 | + compile 'com.android.support:appcompat-v7:25.2.0' | |
| 41 | + compile 'com.android.support.constraint:constraint-layout:1.0.2' | |
| 42 | + testCompile 'junit:junit:4.12' | |
| 43 | +} | ... | ... |
app/libs/alipaySdk-20160825.jar
0 → 100644
No preview for this file type
app/libs/libammsdk.jar
0 → 100644
No preview for this file type
app/libs/libcnlivepay.jar
0 → 100644
No preview for this file type
app/libs/libcnliveutil.jar
0 → 100644
No preview for this file type
app/proguard-rules.pro
0 → 100644
| 1 | +++ a/app/proguard-rules.pro | |
| 1 | +-keepattributes Signature | |
| 2 | +-dontwarn com.cnlive.** | |
| 3 | +-keep class com.cnlive.** {*;} | |
| 4 | + | |
| 5 | +############## | |
| 6 | +## weixin pay ## | |
| 7 | +############## | |
| 8 | +-keep class com.tencent.mm.opensdk.** {*;} | |
| 9 | +-keep class com.tencent.wxop.** {*;} | |
| 10 | +-keep class com.tencent.mm.sdk.** {*;} | |
| 11 | +## weixin pay END | |
| 12 | + | |
| 13 | +############## | |
| 14 | +## alipay ## | |
| 15 | +############## | |
| 16 | +-keep class com.alipay.android.app.IAlixPay{*;} | |
| 17 | +-keep class com.alipay.android.app.IAlixPay$Stub{*;} | |
| 18 | +-keep class com.alipay.android.app.IRemoteServiceCallback{*;} | |
| 19 | +-keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;} | |
| 20 | +-keep class com.alipay.sdk.app.PayTask{ public *;} | |
| 21 | +-keep class com.alipay.sdk.app.AuthTask{ public *;} | |
| 22 | +## alipay END | |
| 23 | + | ... | ... |
app/src/androidTest/java/com/cnlive/demo/pay/ExampleInstrumentedTest.java
0 → 100644
| 1 | +++ a/app/src/androidTest/java/com/cnlive/demo/pay/ExampleInstrumentedTest.java | |
| 1 | +package com.cnlive.demo.pay; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.support.test.InstrumentationRegistry; | |
| 5 | +import android.support.test.runner.AndroidJUnit4; | |
| 6 | + | |
| 7 | +import org.junit.Test; | |
| 8 | +import org.junit.runner.RunWith; | |
| 9 | + | |
| 10 | +import static org.junit.Assert.*; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Instrumentation test, which will execute on an Android device. | |
| 14 | + * | |
| 15 | + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | |
| 16 | + */ | |
| 17 | +@RunWith(AndroidJUnit4.class) | |
| 18 | +public class ExampleInstrumentedTest { | |
| 19 | + @Test | |
| 20 | + public void useAppContext() throws Exception { | |
| 21 | + // Context of the app under test. | |
| 22 | + Context appContext = InstrumentationRegistry.getTargetContext(); | |
| 23 | + | |
| 24 | + assertEquals("com.cnlive.demo.pay", appContext.getPackageName()); | |
| 25 | + } | |
| 26 | +} | ... | ... |
app/src/main/AndroidManifest.xml
0 → 100644
| 1 | +++ a/app/src/main/AndroidManifest.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + package="com.cnlive.demo.pay"> | |
| 4 | + | |
| 5 | + <uses-permission android:name="android.permission.INTERNET" /> | |
| 6 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
| 7 | + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
| 8 | + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | |
| 9 | + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | |
| 10 | + | |
| 11 | + <application | |
| 12 | + android:name=".CNLiveApplication" | |
| 13 | + android:allowBackup="true" | |
| 14 | + android:icon="@mipmap/ic_launcher" | |
| 15 | + android:label="@string/app_name" | |
| 16 | + android:roundIcon="@mipmap/ic_launcher_round" | |
| 17 | + android:supportsRtl="true" | |
| 18 | + android:theme="@style/AppTheme"> | |
| 19 | + <activity android:name=".MainActivity"> | |
| 20 | + <intent-filter> | |
| 21 | + <action android:name="android.intent.action.MAIN" /> | |
| 22 | + | |
| 23 | + <category android:name="android.intent.category.LAUNCHER" /> | |
| 24 | + </intent-filter> | |
| 25 | + </activity> | |
| 26 | + | |
| 27 | + <!--微信支付 --> | |
| 28 | + <activity | |
| 29 | + android:name=".wxapi.WXPayEntryActivity" | |
| 30 | + android:exported="true" | |
| 31 | + android:launchMode="singleTop" /> | |
| 32 | + | |
| 33 | + <!--支付宝支付 --> | |
| 34 | + <activity | |
| 35 | + android:name="com.alipay.sdk.app.H5PayActivity" | |
| 36 | + android:screenOrientation="portrait" /> | |
| 37 | + </application> | |
| 38 | + | |
| 39 | +</manifest> | |
| 0 | 40 | \ No newline at end of file | ... | ... |
app/src/main/java/com/cnlive/demo/pay/CNLiveApplication.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/demo/pay/CNLiveApplication.java | |
| 1 | +package com.cnlive.demo.pay; | |
| 2 | + | |
| 3 | +import android.app.Application; | |
| 4 | + | |
| 5 | +import com.cnlive.libs.pay.PayUtil; | |
| 6 | +import com.cnlive.libs.util.Config; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Created by gujun on 2017/5/8. | |
| 10 | + */ | |
| 11 | + | |
| 12 | +public class CNLiveApplication extends Application { | |
| 13 | + | |
| 14 | + @Override | |
| 15 | + public void onCreate() { | |
| 16 | + super.onCreate(); | |
| 17 | + | |
| 18 | + //设置appID和appkey(请登录http://open.cnlive.com/注册) | |
| 19 | + //TODO 换成app申请到的正式的视讯云对应的appid和appkey | |
| 20 | + Config.init(getApplicationContext(),"60_j2fpi5xb59","df3f5d1e0a11e0438ebd6646069c75e4b6a5f763c956f2"); | |
| 21 | + | |
| 22 | + //设置微信的appid(请到微信开放平台申请),如果不使用微信支付功能传"" | |
| 23 | + //TODO 换成app申请到的正式的微信appid | |
| 24 | + PayUtil.init("wxbcb43c2700c2e6b3"); | |
| 25 | + } | |
| 26 | +} | ... | ... |
app/src/main/java/com/cnlive/demo/pay/MainActivity.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/demo/pay/MainActivity.java | |
| 1 | +package com.cnlive.demo.pay; | |
| 2 | + | |
| 3 | +import android.support.v7.app.AppCompatActivity; | |
| 4 | +import android.os.Bundle; | |
| 5 | +import android.view.View; | |
| 6 | +import android.widget.Toast; | |
| 7 | + | |
| 8 | +import com.cnlive.libs.pay.IPay; | |
| 9 | +import com.cnlive.libs.pay.PayStatusCallback; | |
| 10 | +import com.cnlive.libs.pay.PayUtil; | |
| 11 | + | |
| 12 | +import java.util.HashMap; | |
| 13 | +import java.util.Map; | |
| 14 | + | |
| 15 | +public class MainActivity extends AppCompatActivity { | |
| 16 | + | |
| 17 | + @Override | |
| 18 | + protected void onCreate(Bundle savedInstanceState) { | |
| 19 | + super.onCreate(savedInstanceState); | |
| 20 | + setContentView(R.layout.activity_main); | |
| 21 | + } | |
| 22 | + | |
| 23 | + public void clickWX(View v){ | |
| 24 | + PayUtil.startPay(this, IPay.PAY_TYPE_WX, System.currentTimeMillis() + "", "测试", 1, "http://apps.pay.cnlive.com/upappnotify/notify/updateCnCoin", "liveshow", "1.0", "", getTestExtraParams(), new PayStatusCallback() { | |
| 25 | + @Override | |
| 26 | + public void onSuccess(int payType) { | |
| 27 | + Toast.makeText(MainActivity.this,"支付成功",Toast.LENGTH_LONG).show(); | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public void onFail(int payType, int errorCode,String errorMsg) { | |
| 32 | + Toast.makeText(MainActivity.this,"支付失败:"+errorMsg,Toast.LENGTH_LONG).show(); | |
| 33 | + } | |
| 34 | + }); | |
| 35 | + } | |
| 36 | + | |
| 37 | + public void clickAli(View v){ | |
| 38 | + PayUtil.startPay(this, IPay.PAY_TYPE_ALI, System.currentTimeMillis() + "", "测试", 1, "http://apps.pay.cnlive.com/upappnotify/notify/updateCnCoin", "liveshow", "1.0", "", getTestExtraParams(), new PayStatusCallback() { | |
| 39 | + @Override | |
| 40 | + public void onSuccess(int payType) { | |
| 41 | + Toast.makeText(MainActivity.this,"支付成功",Toast.LENGTH_LONG).show(); | |
| 42 | + } | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + public void onFail(int payType, int errorCode,String errorMsg) { | |
| 46 | + Toast.makeText(MainActivity.this,"支付失败:"+errorMsg,Toast.LENGTH_LONG).show(); | |
| 47 | + } | |
| 48 | + }); | |
| 49 | + } | |
| 50 | + | |
| 51 | + //测试业务系统需要的其他参数 | |
| 52 | + private Map<String,String> getTestExtraParams(){ | |
| 53 | + Map<String,String> extraParams = new HashMap<>(); | |
| 54 | + extraParams.put("plat","a"); | |
| 55 | + extraParams.put("sid","123554"); | |
| 56 | + return extraParams; | |
| 57 | + } | |
| 58 | +} | ... | ... |
app/src/main/java/com/cnlive/demo/pay/wxapi/WXPayEntryActivity.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/demo/pay/wxapi/WXPayEntryActivity.java | |
| 1 | +package com.cnlive.demo.pay.wxapi; | |
| 2 | + | |
| 3 | +import android.content.Intent; | |
| 4 | +import android.os.Bundle; | |
| 5 | + | |
| 6 | +import com.cnlive.demo.pay.R; | |
| 7 | +import com.cnlive.libs.pay.PayUtil; | |
| 8 | +import com.cnlive.libs.pay.ui.WXPayActivity; | |
| 9 | +import com.tencent.mm.opensdk.modelbase.BaseReq; | |
| 10 | +import com.tencent.mm.opensdk.modelbase.BaseResp; | |
| 11 | +import com.tencent.mm.opensdk.openapi.IWXAPI; | |
| 12 | +import com.tencent.mm.opensdk.openapi.WXAPIFactory; | |
| 13 | + | |
| 14 | +public class WXPayEntryActivity extends WXPayActivity { | |
| 15 | + | |
| 16 | + private IWXAPI api; | |
| 17 | + | |
| 18 | + @Override | |
| 19 | + public void onCreate(Bundle savedInstanceState) { | |
| 20 | + super.onCreate(savedInstanceState); | |
| 21 | + setContentView(R.layout.pay_result); | |
| 22 | + | |
| 23 | + api = WXAPIFactory.createWXAPI(this, PayUtil.getWxAppId()); | |
| 24 | + | |
| 25 | + api.handleIntent(getIntent(), this); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + protected void onNewIntent(Intent intent) { | |
| 30 | + super.onNewIntent(intent); | |
| 31 | + setIntent(intent); | |
| 32 | + api.handleIntent(intent, this); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public void onReq(BaseReq baseReq) { | |
| 37 | + super.onReq(baseReq); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public void onResp(BaseResp baseResp) { | |
| 42 | + super.onResp(baseResp); | |
| 43 | + } | |
| 44 | +} | |
| 0 | 45 | \ No newline at end of file | ... | ... |
app/src/main/java/com/cnlive/demo/pay/wxapi/simcpux/AppRegister.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/demo/pay/wxapi/simcpux/AppRegister.java | |
| 1 | +package com.cnlive.demo.pay.wxapi.simcpux; | |
| 2 | + | |
| 3 | +import android.content.BroadcastReceiver; | |
| 4 | +import android.content.Context; | |
| 5 | +import android.content.Intent; | |
| 6 | +import android.util.Log; | |
| 7 | + | |
| 8 | +import com.cnlive.libs.pay.PayUtil; | |
| 9 | +import com.tencent.mm.opensdk.openapi.IWXAPI; | |
| 10 | +import com.tencent.mm.opensdk.openapi.WXAPIFactory; | |
| 11 | + | |
| 12 | +public class AppRegister extends BroadcastReceiver { | |
| 13 | + | |
| 14 | + private final String TAG = "AppRegister"; | |
| 15 | + | |
| 16 | + @Override | |
| 17 | + public void onReceive(Context context, Intent intent) { | |
| 18 | + try { | |
| 19 | + final IWXAPI api = WXAPIFactory.createWXAPI(context, null); | |
| 20 | + | |
| 21 | + api.registerApp(PayUtil.getWxAppId()); | |
| 22 | + }catch (Exception e){ | |
| 23 | + Log.e(TAG, "onReceive: "+e.getMessage(),e ); | |
| 24 | + } | |
| 25 | + } | |
| 26 | +} | ... | ... |
app/src/main/java/com/cnlive/demo/pay/wxapi/simcpux/MD5.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/demo/pay/wxapi/simcpux/MD5.java | |
| 1 | +package com.cnlive.demo.pay.wxapi.simcpux; | |
| 2 | + | |
| 3 | +import java.security.MessageDigest; | |
| 4 | + | |
| 5 | +public class MD5 { | |
| 6 | + | |
| 7 | + private MD5() {} | |
| 8 | + | |
| 9 | + public static String getMessageDigest(byte[] buffer) { | |
| 10 | + char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; | |
| 11 | + try { | |
| 12 | + MessageDigest mdTemp = MessageDigest.getInstance("MD5"); | |
| 13 | + mdTemp.update(buffer); | |
| 14 | + byte[] md = mdTemp.digest(); | |
| 15 | + int j = md.length; | |
| 16 | + char str[] = new char[j * 2]; | |
| 17 | + int k = 0; | |
| 18 | + for (byte byte0 : md) { | |
| 19 | + str[k++] = hexDigits[byte0 >>> 4 & 0xf]; | |
| 20 | + str[k++] = hexDigits[byte0 & 0xf]; | |
| 21 | + } | |
| 22 | + return new String(str); | |
| 23 | + } catch (Exception e) { | |
| 24 | + return null; | |
| 25 | + } | |
| 26 | + } | |
| 27 | +} | ... | ... |
app/src/main/res/layout/activity_main.xml
0 → 100644
| 1 | +++ a/app/src/main/res/layout/activity_main.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:layout_width="match_parent" | |
| 4 | + android:layout_height="match_parent" | |
| 5 | + android:orientation="vertical"> | |
| 6 | + | |
| 7 | + <Button | |
| 8 | + android:layout_width="wrap_content" | |
| 9 | + android:layout_height="wrap_content" | |
| 10 | + android:text="微信支付" | |
| 11 | + android:onClick="clickWX"/> | |
| 12 | + | |
| 13 | + <Button | |
| 14 | + android:layout_width="wrap_content" | |
| 15 | + android:layout_height="wrap_content" | |
| 16 | + android:text="支付宝支付" | |
| 17 | + android:onClick="clickAli"/> | |
| 18 | + | |
| 19 | +</LinearLayout> | ... | ... |
app/src/main/res/layout/pay_result.xml
0 → 100644
| 1 | +++ a/app/src/main/res/layout/pay_result.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | + | |
| 3 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | + style="@style/NavPage"> | |
| 5 | + | |
| 6 | + <TextView | |
| 7 | + android:layout_width="fill_parent" | |
| 8 | + android:layout_height="fill_parent" | |
| 9 | + android:gravity="center" | |
| 10 | + android:textColor="#ff000000" | |
| 11 | + android:textSize="20sp" | |
| 12 | + android:text="@string/pay_result_tip"/> | |
| 13 | + | |
| 14 | +</LinearLayout> | |
| 0 | 15 | \ No newline at end of file | ... | ... |
app/src/main/res/mipmap-hdpi/ic_launcher.png
0 → 100644
3.34 KB
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
0 → 100644
4.11 KB
app/src/main/res/mipmap-mdpi/ic_launcher.png
0 → 100644
2.15 KB
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
0 → 100644
2.5 KB
app/src/main/res/mipmap-xhdpi/ic_launcher.png
0 → 100644
4.73 KB
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
0 → 100644
5.97 KB
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
0 → 100644
7.54 KB
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
0 → 100644
9.82 KB
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
0 → 100644
10.2 KB
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
0 → 100644
14.4 KB
app/src/main/res/values/colors.xml
0 → 100644
app/src/main/res/values/pay_strings.xml
0 → 100644
| 1 | +++ a/app/src/main/res/values/pay_strings.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<resources> | |
| 3 | + <!-- WXPayEntryActivity --> | |
| 4 | + <string name="pay_result_tip">这个界面用于显示第三方app通过微信支付的结果</string> | |
| 5 | + <string name="pay_result_callback_msg" formatted="false">微信支付结果:%s</string> | |
| 6 | +</resources> | |
| 0 | 7 | \ No newline at end of file | ... | ... |
app/src/main/res/values/pay_styles.xml
0 → 100644
| 1 | +++ a/app/src/main/res/values/pay_styles.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<resources> | |
| 3 | + <!-- 微信支付布局用到的 --> | |
| 4 | + <style name="NavPage"> | |
| 5 | + <item name="android:layout_width">fill_parent</item> | |
| 6 | + <item name="android:layout_height">fill_parent</item> | |
| 7 | + <item name="android:orientation">vertical</item> | |
| 8 | + <item name="android:gravity">center_horizontal</item> | |
| 9 | + <item name="android:background">#FFE1E8EB</item> | |
| 10 | + </style> | |
| 11 | +</resources> | |
| 0 | 12 | \ No newline at end of file | ... | ... |
app/src/main/res/values/strings.xml
0 → 100644
app/src/main/res/values/styles.xml
0 → 100644
| 1 | +++ a/app/src/main/res/values/styles.xml | |
| 1 | +<resources> | |
| 2 | + | |
| 3 | + <!-- Base application theme. --> | |
| 4 | + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
| 5 | + <!-- Customize your theme here. --> | |
| 6 | + <item name="colorPrimary">@color/colorPrimary</item> | |
| 7 | + <item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
| 8 | + <item name="colorAccent">@color/colorAccent</item> | |
| 9 | + </style> | |
| 10 | + | |
| 11 | +</resources> | ... | ... |
app/src/test/java/com/cnlive/demo/pay/ExampleUnitTest.java
0 → 100644
| 1 | +++ a/app/src/test/java/com/cnlive/demo/pay/ExampleUnitTest.java | |
| 1 | +package com.cnlive.demo.pay; | |
| 2 | + | |
| 3 | +import org.junit.Test; | |
| 4 | + | |
| 5 | +import static org.junit.Assert.*; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * Example local unit test, which will execute on the development machine (host). | |
| 9 | + * | |
| 10 | + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | |
| 11 | + */ | |
| 12 | +public class ExampleUnitTest { | |
| 13 | + @Test | |
| 14 | + public void addition_isCorrect() throws Exception { | |
| 15 | + assertEquals(4, 2 + 2); | |
| 16 | + } | |
| 17 | +} | |
| 0 | 18 | \ No newline at end of file | ... | ... |
app/test.jks
0 → 100644
No preview for this file type
app/www.cnlive.com.key
0 → 100644
No preview for this file type
build.gradle
0 → 100644
| 1 | +++ a/build.gradle | |
| 1 | +// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
| 2 | + | |
| 3 | +buildscript { | |
| 4 | + repositories { | |
| 5 | + jcenter() | |
| 6 | + } | |
| 7 | + dependencies { | |
| 8 | + classpath 'com.android.tools.build:gradle:2.3.1' | |
| 9 | + | |
| 10 | + // NOTE: Do not place your application dependencies here; they belong | |
| 11 | + // in the individual module build.gradle files | |
| 12 | + } | |
| 13 | +} | |
| 14 | + | |
| 15 | +allprojects { | |
| 16 | + repositories { | |
| 17 | + jcenter() | |
| 18 | + } | |
| 19 | +} | |
| 20 | + | |
| 21 | +task clean(type: Delete) { | |
| 22 | + delete rootProject.buildDir | |
| 23 | +} | ... | ... |
gradle.properties
0 → 100644
| 1 | +++ a/gradle.properties | |
| 1 | +# Project-wide Gradle settings. | |
| 2 | + | |
| 3 | +# IDE (e.g. Android Studio) users: | |
| 4 | +# Gradle settings configured through the IDE *will override* | |
| 5 | +# any settings specified in this file. | |
| 6 | + | |
| 7 | +# For more details on how to configure your build environment visit | |
| 8 | +# http://www.gradle.org/docs/current/userguide/build_environment.html | |
| 9 | + | |
| 10 | +# Specifies the JVM arguments used for the daemon process. | |
| 11 | +# The setting is particularly useful for tweaking memory settings. | |
| 12 | +org.gradle.jvmargs=-Xmx1536m | |
| 13 | + | |
| 14 | +# When configured, Gradle will run in incubating parallel mode. | |
| 15 | +# This option should only be used with decoupled projects. More details, visit | |
| 16 | +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | |
| 17 | +# org.gradle.parallel=true | ... | ... |
gradle/wrapper/gradle-wrapper.jar
0 → 100644
No preview for this file type
gradle/wrapper/gradle-wrapper.properties
0 → 100644
| 1 | +++ a/gradle/wrapper/gradle-wrapper.properties | |
| 1 | +#Mon May 08 13:32:35 CST 2017 | |
| 2 | +distributionBase=GRADLE_USER_HOME | |
| 3 | +distributionPath=wrapper/dists | |
| 4 | +zipStoreBase=GRADLE_USER_HOME | |
| 5 | +zipStorePath=wrapper/dists | |
| 6 | +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip | ... | ... |
gradlew
0 → 100644
| 1 | +++ a/gradlew | |
| 1 | +#!/usr/bin/env bash | |
| 2 | + | |
| 3 | +############################################################################## | |
| 4 | +## | |
| 5 | +## Gradle start up script for UN*X | |
| 6 | +## | |
| 7 | +############################################################################## | |
| 8 | + | |
| 9 | +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | |
| 10 | +DEFAULT_JVM_OPTS="" | |
| 11 | + | |
| 12 | +APP_NAME="Gradle" | |
| 13 | +APP_BASE_NAME=`basename "$0"` | |
| 14 | + | |
| 15 | +# Use the maximum available, or set MAX_FD != -1 to use that value. | |
| 16 | +MAX_FD="maximum" | |
| 17 | + | |
| 18 | +warn ( ) { | |
| 19 | + echo "$*" | |
| 20 | +} | |
| 21 | + | |
| 22 | +die ( ) { | |
| 23 | + echo | |
| 24 | + echo "$*" | |
| 25 | + echo | |
| 26 | + exit 1 | |
| 27 | +} | |
| 28 | + | |
| 29 | +# OS specific support (must be 'true' or 'false'). | |
| 30 | +cygwin=false | |
| 31 | +msys=false | |
| 32 | +darwin=false | |
| 33 | +case "`uname`" in | |
| 34 | + CYGWIN* ) | |
| 35 | + cygwin=true | |
| 36 | + ;; | |
| 37 | + Darwin* ) | |
| 38 | + darwin=true | |
| 39 | + ;; | |
| 40 | + MINGW* ) | |
| 41 | + msys=true | |
| 42 | + ;; | |
| 43 | +esac | |
| 44 | + | |
| 45 | +# Attempt to set APP_HOME | |
| 46 | +# Resolve links: $0 may be a link | |
| 47 | +PRG="$0" | |
| 48 | +# Need this for relative symlinks. | |
| 49 | +while [ -h "$PRG" ] ; do | |
| 50 | + ls=`ls -ld "$PRG"` | |
| 51 | + link=`expr "$ls" : '.*-> \(.*\)$'` | |
| 52 | + if expr "$link" : '/.*' > /dev/null; then | |
| 53 | + PRG="$link" | |
| 54 | + else | |
| 55 | + PRG=`dirname "$PRG"`"/$link" | |
| 56 | + fi | |
| 57 | +done | |
| 58 | +SAVED="`pwd`" | |
| 59 | +cd "`dirname \"$PRG\"`/" >/dev/null | |
| 60 | +APP_HOME="`pwd -P`" | |
| 61 | +cd "$SAVED" >/dev/null | |
| 62 | + | |
| 63 | +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | |
| 64 | + | |
| 65 | +# Determine the Java command to use to start the JVM. | |
| 66 | +if [ -n "$JAVA_HOME" ] ; then | |
| 67 | + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | |
| 68 | + # IBM's JDK on AIX uses strange locations for the executables | |
| 69 | + JAVACMD="$JAVA_HOME/jre/sh/java" | |
| 70 | + else | |
| 71 | + JAVACMD="$JAVA_HOME/bin/java" | |
| 72 | + fi | |
| 73 | + if [ ! -x "$JAVACMD" ] ; then | |
| 74 | + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | |
| 75 | + | |
| 76 | +Please set the JAVA_HOME variable in your environment to match the | |
| 77 | +location of your Java installation." | |
| 78 | + fi | |
| 79 | +else | |
| 80 | + JAVACMD="java" | |
| 81 | + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | |
| 82 | + | |
| 83 | +Please set the JAVA_HOME variable in your environment to match the | |
| 84 | +location of your Java installation." | |
| 85 | +fi | |
| 86 | + | |
| 87 | +# Increase the maximum file descriptors if we can. | |
| 88 | +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then | |
| 89 | + MAX_FD_LIMIT=`ulimit -H -n` | |
| 90 | + if [ $? -eq 0 ] ; then | |
| 91 | + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | |
| 92 | + MAX_FD="$MAX_FD_LIMIT" | |
| 93 | + fi | |
| 94 | + ulimit -n $MAX_FD | |
| 95 | + if [ $? -ne 0 ] ; then | |
| 96 | + warn "Could not set maximum file descriptor limit: $MAX_FD" | |
| 97 | + fi | |
| 98 | + else | |
| 99 | + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | |
| 100 | + fi | |
| 101 | +fi | |
| 102 | + | |
| 103 | +# For Darwin, add options to specify how the application appears in the dock | |
| 104 | +if $darwin; then | |
| 105 | + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | |
| 106 | +fi | |
| 107 | + | |
| 108 | +# For Cygwin, switch paths to Windows format before running java | |
| 109 | +if $cygwin ; then | |
| 110 | + APP_HOME=`cygpath --path --mixed "$APP_HOME"` | |
| 111 | + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | |
| 112 | + JAVACMD=`cygpath --unix "$JAVACMD"` | |
| 113 | + | |
| 114 | + # We build the pattern for arguments to be converted via cygpath | |
| 115 | + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | |
| 116 | + SEP="" | |
| 117 | + for dir in $ROOTDIRSRAW ; do | |
| 118 | + ROOTDIRS="$ROOTDIRS$SEP$dir" | |
| 119 | + SEP="|" | |
| 120 | + done | |
| 121 | + OURCYGPATTERN="(^($ROOTDIRS))" | |
| 122 | + # Add a user-defined pattern to the cygpath arguments | |
| 123 | + if [ "$GRADLE_CYGPATTERN" != "" ] ; then | |
| 124 | + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | |
| 125 | + fi | |
| 126 | + # Now convert the arguments - kludge to limit ourselves to /bin/sh | |
| 127 | + i=0 | |
| 128 | + for arg in "$@" ; do | |
| 129 | + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | |
| 130 | + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | |
| 131 | + | |
| 132 | + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | |
| 133 | + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | |
| 134 | + else | |
| 135 | + eval `echo args$i`="\"$arg\"" | |
| 136 | + fi | |
| 137 | + i=$((i+1)) | |
| 138 | + done | |
| 139 | + case $i in | |
| 140 | + (0) set -- ;; | |
| 141 | + (1) set -- "$args0" ;; | |
| 142 | + (2) set -- "$args0" "$args1" ;; | |
| 143 | + (3) set -- "$args0" "$args1" "$args2" ;; | |
| 144 | + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; | |
| 145 | + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | |
| 146 | + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | |
| 147 | + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | |
| 148 | + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | |
| 149 | + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | |
| 150 | + esac | |
| 151 | +fi | |
| 152 | + | |
| 153 | +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules | |
| 154 | +function splitJvmOpts() { | |
| 155 | + JVM_OPTS=("$@") | |
| 156 | +} | |
| 157 | +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS | |
| 158 | +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" | |
| 159 | + | |
| 160 | +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" | ... | ... |
gradlew.bat
0 → 100644
| 1 | +++ a/gradlew.bat | |
| 1 | +@if "%DEBUG%" == "" @echo off | |
| 2 | +@rem ########################################################################## | |
| 3 | +@rem | |
| 4 | +@rem Gradle startup script for Windows | |
| 5 | +@rem | |
| 6 | +@rem ########################################################################## | |
| 7 | + | |
| 8 | +@rem Set local scope for the variables with windows NT shell | |
| 9 | +if "%OS%"=="Windows_NT" setlocal | |
| 10 | + | |
| 11 | +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | |
| 12 | +set DEFAULT_JVM_OPTS= | |
| 13 | + | |
| 14 | +set DIRNAME=%~dp0 | |
| 15 | +if "%DIRNAME%" == "" set DIRNAME=. | |
| 16 | +set APP_BASE_NAME=%~n0 | |
| 17 | +set APP_HOME=%DIRNAME% | |
| 18 | + | |
| 19 | +@rem Find java.exe | |
| 20 | +if defined JAVA_HOME goto findJavaFromJavaHome | |
| 21 | + | |
| 22 | +set JAVA_EXE=java.exe | |
| 23 | +%JAVA_EXE% -version >NUL 2>&1 | |
| 24 | +if "%ERRORLEVEL%" == "0" goto init | |
| 25 | + | |
| 26 | +echo. | |
| 27 | +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | |
| 28 | +echo. | |
| 29 | +echo Please set the JAVA_HOME variable in your environment to match the | |
| 30 | +echo location of your Java installation. | |
| 31 | + | |
| 32 | +goto fail | |
| 33 | + | |
| 34 | +:findJavaFromJavaHome | |
| 35 | +set JAVA_HOME=%JAVA_HOME:"=% | |
| 36 | +set JAVA_EXE=%JAVA_HOME%/bin/java.exe | |
| 37 | + | |
| 38 | +if exist "%JAVA_EXE%" goto init | |
| 39 | + | |
| 40 | +echo. | |
| 41 | +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | |
| 42 | +echo. | |
| 43 | +echo Please set the JAVA_HOME variable in your environment to match the | |
| 44 | +echo location of your Java installation. | |
| 45 | + | |
| 46 | +goto fail | |
| 47 | + | |
| 48 | +:init | |
| 49 | +@rem Get command-line arguments, handling Windowz variants | |
| 50 | + | |
| 51 | +if not "%OS%" == "Windows_NT" goto win9xME_args | |
| 52 | +if "%@eval[2+2]" == "4" goto 4NT_args | |
| 53 | + | |
| 54 | +:win9xME_args | |
| 55 | +@rem Slurp the command line arguments. | |
| 56 | +set CMD_LINE_ARGS= | |
| 57 | +set _SKIP=2 | |
| 58 | + | |
| 59 | +:win9xME_args_slurp | |
| 60 | +if "x%~1" == "x" goto execute | |
| 61 | + | |
| 62 | +set CMD_LINE_ARGS=%* | |
| 63 | +goto execute | |
| 64 | + | |
| 65 | +:4NT_args | |
| 66 | +@rem Get arguments from the 4NT Shell from JP Software | |
| 67 | +set CMD_LINE_ARGS=%$ | |
| 68 | + | |
| 69 | +:execute | |
| 70 | +@rem Setup the command line | |
| 71 | + | |
| 72 | +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | |
| 73 | + | |
| 74 | +@rem Execute Gradle | |
| 75 | +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% | |
| 76 | + | |
| 77 | +:end | |
| 78 | +@rem End local scope for the variables with windows NT shell | |
| 79 | +if "%ERRORLEVEL%"=="0" goto mainEnd | |
| 80 | + | |
| 81 | +:fail | |
| 82 | +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | |
| 83 | +rem the _cmd.exe /c_ return code! | |
| 84 | +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | |
| 85 | +exit /b 1 | |
| 86 | + | |
| 87 | +:mainEnd | |
| 88 | +if "%OS%"=="Windows_NT" endlocal | |
| 89 | + | |
| 90 | +:omega | ... | ... |
settings.gradle
0 → 100644