Skip to content

Commit

Permalink
更新最新支付宝支付接口
Browse files Browse the repository at this point in the history
  • Loading branch information
tangsiyuan committed Nov 3, 2016
1 parent 25253e3 commit 2e46135
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 19 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# PayAndroid
对微信支付和支付宝支付的App端SDK进行二次封装,对外提供一个较为简单的接口和支付结果回调

注:生成pay_param的部分可见:http://www.jianshu.com/p/9b353529f02c
> 对微信支付和支付宝支付的App端SDK进行二次封装,对外提供一个较为简单的接口和支付结果回调

## 注意注意:支付宝开放平台新支付的通知!

支付宝升级了支付模式,增加开放平台的概念,之前只要在商户平台申请pid即可实现支付,现在是在开放平台创建App,根据相应APP_ID发起支付。更新后调用方式不变。

1. 老版本接口支付
pay_param生成参见:http://www.jianshu.com/p/9b353529f02c

2. 新版本接口支付
pay_param生成参见:http://www.jianshu.com/p/59341ea9d86d

## Android SDK接入指南

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/alipaySdk-20160516.jar')
compile files('libs/libammsdk.jar')
}

task clearJar(type: Delete) {
Expand Down
Binary file added pay_android_sdk/libs/alipaySdk-20161009.jar
Binary file not shown.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.ci123.service.pay;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tsy.pay">
package="com.ci123.service.pay">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tsy.pay;
package com.ci123.service.pay;

import java.net.Inet4Address;
import java.net.InetAddress;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tsy.pay.alipay;
package com.ci123.service.pay.alipay;

import android.app.Activity;
import android.content.Context;
Expand All @@ -7,6 +7,8 @@

import com.alipay.sdk.app.PayTask;

import java.util.Map;

/**
* 支付宝支付
* Created by tsy on 16/6/1.
Expand Down Expand Up @@ -39,9 +41,7 @@ public void doPay() {
new Thread(new Runnable() {
@Override
public void run() {
String result = mPayTask.pay(mParams, true);

final AlipayResult pay_result = new AlipayResult(result);
final Map<String, String> pay_result = mPayTask.payV2(mParams,true);
handler.post(new Runnable() {
@Override
public void run() {
Expand All @@ -54,7 +54,7 @@ public void run() {
return;
}

String resultStatus = pay_result.getResultStatus();
String resultStatus = pay_result.get("resultStatus");
if(TextUtils.equals(resultStatus, "9000")) { //支付成功
mCallback.onSuccess();
} else if(TextUtils.equals(resultStatus, "8000")) { //支付结果因为支付渠道原因或者系统原因还在等待支付结果确认,最终交易是否成功以服务端异步通知为准(小概率状态)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tsy.pay.alipay;
package com.ci123.service.pay.alipay;

import android.text.TextUtils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tsy.pay.weixin;
package com.ci123.service.pay.weixin;

import android.content.Context;
import android.text.TextUtils;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void doPay(String pay_param, WXPayResultCallBack callback) {
}
return;
}
if(param == null || TextUtils.isEmpty(param.optString("appid")) || TextUtils.isEmpty(param.optString("partnerid"))
if(TextUtils.isEmpty(param.optString("appid")) || TextUtils.isEmpty(param.optString("partnerid"))
|| TextUtils.isEmpty(param.optString("prepayid")) || TextUtils.isEmpty(param.optString("package")) ||
TextUtils.isEmpty(param.optString("noncestr")) || TextUtils.isEmpty(param.optString("timestamp")) ||
TextUtils.isEmpty(param.optString("sign"))) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tsy.pay.weixin;
package com.ci123.service.pay.weixin;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.tsy.pay.R;
import com.ci123.service.pay.R;
import com.tencent.mm.sdk.constants.ConstantsAPI;
import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
Expand Down
3 changes: 3 additions & 0 deletions pay_android_sdk/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">ci_service_pay_lib</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.ci123.service.pay;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
Binary file removed pay_android_sdk_1.0/libs/alipaySdk-20160516.jar
Binary file not shown.
3 changes: 0 additions & 3 deletions pay_android_sdk_1.0/src/main/res/values/strings.xml

This file was deleted.

0 comments on commit 2e46135

Please sign in to comment.