WXPayEntryActivity.java
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.tencent.youai.shushan.wxapi;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.youai.sdk.YouaiSDK;
public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler{
private static final String TAG = "MicroMsg.SDKSample.WXPayEntryActivity";
private IWXAPI api;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
api = WXAPIFactory.createWXAPI(this, YouaiSDK.weixinAppId);
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) {
Log.d(TAG, "0成功,-1错误,-2用户取消 onPayFinish, errCode = " + resp.errCode);
if (YouaiSDK.lastCallBack != null) {
if(resp.errCode == 0){
Intent i = new Intent();
i.putExtra("msg", "充值成功");
YouaiSDK.lastCallBack.onEventDispatch(YouaiSDK.PAY_ACTION_CODE, i);
}else if(resp.errCode == -2){
Intent i = new Intent();
i.putExtra("msg", "用户取消");
YouaiSDK.lastCallBack.onEventDispatch(YouaiSDK.PAY_ACTION_CODE, i);
}
}
finish();
}
}