源码简介:通过代码的调用 跨过没有自己服务器的弊端 先测试是否可以跑通代码 与微信支付demo 绝对不一样
源码效果:
源码片段:
- private String genProductArgs() {
- StringBuffer xml = new StringBuffer();
- try {
- String nonceStr = genNonceStr();
- xml.append("");
- List<namevaluepair> packageParams = new LinkedList<namevaluepair>();
- packageParams.add(new BasicNameValuePair("appid", Constants.APP_ID));
- packageParams.add(new BasicNameValuePair("body", "weixin"));
- packageParams.add(new BasicNameValuePair("mch_id", Constants.MCH_ID));
- packageParams.add(new BasicNameValuePair("nonce_str", nonceStr));
- packageParams.add(new BasicNameValuePair("notify_url", "http://121.40.35.3/test"));
- packageParams.add(new BasicNameValuePair("out_trade_no",genOutTradNo()));
- packageParams.add(new BasicNameValuePair("spbill_create_ip","127.0.0.1"));
- packageParams.add(new BasicNameValuePair("total_fee", "1"));
- packageParams.add(new BasicNameValuePair("trade_type", "APP"));
- String sign = genPackageSign(packageParams);
- packageParams.add(new BasicNameValuePair("sign", sign));
- String xmlstring =toXml(packageParams);
- return xmlstring;
- } catch (Exception e) {
- Log.e(TAG, "genProductArgs fail, ex = " + e.getMessage());
- return null;
- }
- }</namevaluepair></namevaluepair>