├── app ├── .gitignore ├── libs │ ├── libammsdk.jar │ ├── volley-6.0.jar │ └── alipaySdk-20160516.jar ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── layout │ │ │ │ ├── activity_wxpay_call_back.xml │ │ │ │ └── activity_main.xml │ │ │ └── values-w820dp │ │ │ │ └── dimens.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── syhd │ │ │ │ └── payandroid │ │ │ │ ├── net │ │ │ │ ├── StringCallback.java │ │ │ │ ├── HttpUtils.java │ │ │ │ └── HttpLoader.java │ │ │ │ ├── alipay │ │ │ │ ├── server │ │ │ │ │ ├── SignUtils.java │ │ │ │ │ ├── AlipayServer.java │ │ │ │ │ └── Base64.java │ │ │ │ └── client │ │ │ │ │ ├── AlipayResult.java │ │ │ │ │ └── Alipay.java │ │ │ │ ├── wxapi │ │ │ │ └── WXPayEntryActivity.java │ │ │ │ ├── weixin │ │ │ │ └── WXPay.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── syhd │ │ │ └── payandroid │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── syhd │ │ └── payandroid │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── .gitattributes ├── gradle.properties ├── .gitignore ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/libs/libammsdk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanbaokun/AndroidPay/HEAD/app/libs/libammsdk.jar -------------------------------------------------------------------------------- /app/libs/volley-6.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanbaokun/AndroidPay/HEAD/app/libs/volley-6.0.jar -------------------------------------------------------------------------------- /app/libs/alipaySdk-20160516.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanbaokun/AndroidPay/HEAD/app/libs/alipaySdk-20160516.jar -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PayAndroid 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanbaokun/AndroidPay/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanbaokun/AndroidPay/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanbaokun/AndroidPay/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanbaokun/AndroidPay/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanbaokun/AndroidPay/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanbaokun/AndroidPay/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/syhd/payandroid/net/StringCallback.java: -------------------------------------------------------------------------------- 1 | package com.syhd.payandroid.net; 2 | 3 | 4 | public abstract class StringCallback { 5 | public abstract void onError(String request); 6 | 7 | public abstract void onResponse(String response); 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_wxpay_call_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 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-2.10-all.zip 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AndroidPay 2 | 基于微信和支付宝的支付demo,可以直接拷贝代码到项目中使用 3 | 4 | >支付宝可以进行参数测试, 5 | >微信需要自行编写服务器代码获取支付参数(格式代码中已附) 6 | ####微信支付常见的问题 7 | * 1.微信开放平台的包名和签名是否和本地的一致 8 | * 2.服务器能拿到prepare_id,还是返回-1,查看调起支付接口时的签名是否计算正确 9 | * 3.能调起支付,没有返回消息的,请查看自己项目包下是否有(wxapi.WXPayEntryActivity) 10 | * 4.本地调试时一定要使用正式签名文件进行调试,否则是调不起微信支付窗口的 11 | * 5.网络上遇到说微信缓存会影响返回-1的,目前没有遇到过 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/syhd/payandroid/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.syhd.payandroid; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/syhd/payandroid/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.syhd.payandroid; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Develop\Android\AndroidSDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/syhd/payandroid/net/HttpUtils.java: -------------------------------------------------------------------------------- 1 | package com.syhd.payandroid.net; 2 | 3 | import android.content.Context; 4 | 5 | import java.util.Map; 6 | 7 | 8 | /** 9 | * 使用volley6.0进行网络访问 10 | * Created by 韩宝坤 on 2016/1/14. 11 | */ 12 | public class HttpUtils { 13 | /** 14 | * post请求 15 | * @param url 地址 16 | * @param map 参数 17 | * @param mStringCallBack 回调 18 | */ 19 | public static void httpPost(Context context,String url, Map map, StringCallback mStringCallBack) { 20 | HttpLoader.getInstance(context).postRequest(url, map, mStringCallBack); 21 | } 22 | 23 | public static void httpGet(Context context,String url, StringCallback mStringCallBack){ 24 | HttpLoader.getInstance(context).getRequest(url,mStringCallBack); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 |