微信支付

官网地址
微信支付-小白无头脑接入
下面几点需要注意一下:
1.应用签名,AS默认使用签名文件与最后的可能有冲突,控件调不出来。
这里写图片描述
2.回调 WXPayEntryActivity 包名 :在微信注册的时候上传的包名.wxapi
下面代码也必须

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

onResp 处理

 public void onResp(BaseResp baseResp) {
        if (baseResp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
            switch (baseResp.errCode) {
                case 0:
                    Toast.makeText(getBaseContext(), "支付成功", Toast.LENGTH_SHORT).show();
             // 处理之后的逻辑 必要时可以 使用Broadcast发送信息
                    break;
                case -1:
                case -2:
                    Toast.makeText(getBaseContext(), "支付失败,请重试!", Toast.LENGTH_SHORT).show();
                    break;
            }
        }
//        关闭页面
        finish();
    }

下边放一个完整 的

public class WXPayEntryActivity extends ATBaseActivity implements IWXAPIEventHandler {
    private IWXAPI f6945c;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) C0784R.layout.activity_wei_xin_pay_res_layout);
        this.f6945c = WXAPIFactory.createWXAPI(this, "");
        this.f6945c.handleIntent(getIntent(), this);
    }

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

    public void onReq(BaseReq baseReq) {
    }

    public void onResp(BaseResp baseResp) {

        if (baseResp.getType() == 5) {
            if (baseResp.errCode == 0) {
                Intent intent = new Intent();
                intent.putExtra("at_pay_flag", String.valueOf(baseResp.errCode));
                intent.putExtra("at_pay_type", ATPaymentType.WECHAT.m7066a());
                intent.setAction("android.wechat.pay.RECIVER");
                sendBroadcast(intent);
            } else {
                af.m8459a((Context) this, getString(C0784R.string.errcode_unfinished));
            }
        }

        finish();
    }
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值