Skip to content

Commit

Permalink
fix wechat
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwfqin committed Mar 2, 2018
1 parent b767820 commit d4bb277
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 6 deletions.
28 changes: 24 additions & 4 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'

implementation 'com.sdwfqin.quicklib:quicklib:1.1.7'
implementation 'com.sdwfqin.quicklib:quicklib:1.1.8'

> 最低支持api16,编译版本27,gradle4.1
minSdkVersion 16
targetSdkVersion 27

# 微信支付无法获取结果回调,正在修复

# 注意事项

1. 当前项目依赖Qmui 1.0.7,即在主项目中配置了Qmui,quicklib中的样式无需再次配置就与主项目中的样式一致,后期可能会脱离出来
Expand All @@ -40,7 +38,7 @@
|- MvpFragment
|- RxPresenter Presenter层封装
|- AliPayTools 支付宝支付工具类
|- WechatPay 微信支付工具类
|- WechatPayTools 微信支付工具类
|- WechatShareTools 微信分享工具类
|- QrBarScanActivity 解析二维码Activity
|- QrCreateCode 创建二维码工具类
Expand Down Expand Up @@ -71,3 +69,25 @@

# Apk http://fir.im/x97v

# 微信支付

1. 调用WechatPayTools下面的wechatPayApp方法
2. 如果想要支付回掉结果请参照示例app下面的WXPayEntryActivity
3. 注意下面的部分

```
<activity
android:name=".wxapi.WXPayEntryActivity"
android:exported="true"
android:screenOrientation="portrait"/>
// 注意WXPayEntryActivity下面的这个方法
@Override
public void onResp(BaseResp resp) {
//回掉结果监听
WechatPay.getInstance().onResp(resp.errCode);
LogUtils.e("onPayFinish, errCode = " + resp.errCode);
finish();
}
```
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait" />
<activity
android:name=".wxapi.WXPayEntryActivity"
android:exported="true"
android:screenOrientation="portrait"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.sdwfqin.quickseed.wxapi;

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

import com.blankj.utilcode.util.LogUtils;
import com.sdwfqin.quicklib.base.Constants;
import com.sdwfqin.quicklib.module.wechat.pay.WechatPay;
import com.sdwfqin.quickseed.R;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {

private IWXAPI api;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pay_result);

api = WXAPIFactory.createWXAPI(this, Constants.APP_ID);
api.handleIntent(getIntent(), this);
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
api.handleIntent(intent, this);
}

@Override
public void onReq(BaseReq req) {
}

@Override
public void onResp(BaseResp resp) {
WechatPay.getInstance().onResp(resp.errCode);
LogUtils.e("onPayFinish, errCode = " + resp.errCode);
finish();
}
}
4 changes: 4 additions & 0 deletions app/src/main/res/layout/pay_result.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
2 changes: 1 addition & 1 deletion quicklib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "1.1.7_beta1"
version = "1.1.8"

// gradlew install
// gradlew bintrayUpload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class Constants {
public static boolean LOG_TYPE = true;


public static String APP_ID = "123456789";


public static final String HEAD = "<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
" <head>\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static WechatPay getInstance() {
return sMWechatPay;
}

public IWXAPI getWXApi() {
public IWXAPI getWXApi() {
return mWXApi;
}

Expand Down

0 comments on commit d4bb277

Please sign in to comment.