- 微信支付成功或失败后不走回调是怎么回事?
1.WXEntryActivity 类 [代码]public[代码] [代码]class[代码] [代码]WXEntryActivity [代码][代码]extends[代码] [代码]Activity [代码][代码]implements[代码] [代码]IWXAPIEventHandler {[代码] [代码] [代码][代码]private[代码] [代码]static[代码] [代码]final[代码] [代码]String WECHAT_APPID = [代码][代码]"我的appid"[代码][代码];[代码][代码] [代码][代码]private[代码] [代码]IWXAPI api;[代码] [代码] [代码][代码]@Override[代码][代码] [代码][代码]protected[代码] [代码]void[代码] [代码]onCreate([代码][代码]@Nullable[代码] [代码]Bundle savedInstanceState) {[代码][代码] [代码][代码]super[代码][代码].onCreate(savedInstanceState);[代码][代码] [代码][代码]api = WXAPIFactory.createWXAPI([代码][代码]this[代码][代码], WECHAT_APPID);[代码][代码] [代码][代码]api.handleIntent(getIntent(), [代码][代码]this[代码][代码]);[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]@Override[代码][代码] [代码][代码]protected[代码] [代码]void[代码] [代码]onNewIntent(Intent intent) {[代码][代码] [代码][代码]super[代码][代码].onNewIntent(intent);[代码][代码] [代码][代码]setIntent(intent);[代码][代码] [代码][代码]api.handleIntent(intent, [代码][代码]this[代码][代码]);[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]@Override[代码][代码] [代码][代码]public[代码] [代码]void[代码] [代码]onReq(BaseReq baseReq) {[代码][代码] [代码][代码]Toast.makeText([代码][代码]this[代码][代码], [代码][代码]"onReq 1500"[代码][代码], Toast.LENGTH_SHORT).show();[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]@Override[代码][代码] [代码][代码]public[代码] [代码]void[代码] [代码]onResp(BaseResp baseResp) {[代码][代码] [代码][代码]ToastUtils.showShort([代码][代码]" 微信支付返回码"[代码][代码]+baseResp.errCode);[代码][代码] [代码][代码]LogUtils.d([代码][代码]"1923 返回码"[代码] [代码]+ baseResp.errCode);[代码][代码] [代码][代码]if[代码] [代码](baseResp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {[代码][代码] [代码][代码]AlertDialog.Builder builder = [代码][代码]new[代码] [代码]AlertDialog.Builder([代码][代码]this[代码][代码]);[代码][代码] [代码][代码]builder.setTitle([代码][代码]"支付结果"[代码][代码]);[代码][代码] [代码][代码]builder.setMessage(String.valueOf(baseResp.errCode));[代码][代码] [代码][代码]builder.show();[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码]}[代码]2.支付代码: [代码]private[代码] [代码]void[代码] [代码]wechatPay(WechatPayBean bean) {[代码][代码] [代码][代码]String appid = bean.getAppid();[代码][代码]//appid[代码][代码] [代码][代码]String mch_id = bean.getMch_id();[代码][代码]//商户号[代码][代码] [代码][代码]String prepay_id = bean.getPrepay_id();[代码][代码]//预支付交易会话ID[代码][代码] [代码][代码]String nonce_str = bean.getNonce_str();[代码][代码]//随机字符串[代码][代码] [代码][代码]String time_stamp = bean.getTime_stamp();[代码][代码]//时间戳[代码][代码]// String sign = bean.getSign();//签名[代码][代码] [代码][代码]IWXAPI api = WXAPIFactory.createWXAPI(OrderConfirmActivity.[代码][代码]this[代码][代码], appid, [代码][代码]false[代码][代码]);[代码][代码]//填写自己的APPIDapi.registerApp("wxAPPID");//填写自己的APPID,注册本身[代码][代码] [代码][代码]api.registerApp(appid);[代码][代码] [代码][代码]PayReq req = [代码][代码]new[代码] [代码]PayReq();[代码][代码]//PayReq就是订单信息对象[代码][代码] [代码][代码]req.appId = appid;[代码][代码]//你的微信appid[代码][代码] [代码][代码]req.partnerId = mch_id;[代码][代码]//商户号[代码][代码] [代码][代码]req.prepayId = prepay_id;[代码][代码]//预支付交易会话ID[代码][代码] [代码][代码]req.nonceStr = nonce_str;[代码][代码]//随机字符串[代码][代码] [代码][代码]req.timeStamp = time_stamp;[代码][代码]//时间戳[代码][代码] [代码][代码]req.packageValue = [代码][代码]"Sign=WXPay"[代码][代码];[代码][代码]//扩展字段,这里固定填写Sign=WXPay[代码][代码] [代码][代码]//todo:sign必须由appId等六个值拼接而成[代码][代码] [代码][代码]req.sign = bean.getSign();[代码][代码]//签名[代码][代码] [代码][代码]api.sendReq(req);[代码][代码]//将订单信息对象发送给微信服务器,即发送支付请求[代码][代码]req.timeStamp));[代码][代码]// req.sign = getSign(list);//签名[代码][代码] [代码][代码]}[代码]3.清单文件注册: [代码]<activity[代码][代码] [代码][代码]android:name=[代码][代码]".wxapi.WXEntryActivity"[代码][代码] [代码][代码]android:label=[代码][代码]"@string/app_name"[代码][代码] [代码][代码]android:theme=[代码][代码]"@android:style/Theme.Translucent.NoTitleBar"[代码][代码] [代码][代码]android:exported=[代码][代码]"true"[代码][代码] [代码][代码]android:taskAffinity=[代码][代码]"我的包名"[代码][代码] [代码][代码]android:launchMode=[代码][代码]"singleTask"[代码][代码]>[代码][代码] [代码][代码]</activity>[代码]
2019-11-26 - 我分享到朋友圈的链接被屏蔽了?别人看不到
我分享到朋友圈的链接被屏蔽了,别人看不到
2019-12-29