Android 整合微信支付詳解

2021-08-29 04:51:54 字數 3126 閱讀 6166

申請通過,填寫  資料審核——審核通過如下:

* @param ordertype //附加引數,不傳為null。不能為""

*/this.mch_id = mch_id;

this.api_key = api_key;

this.orderon = orderon;

this.productfeename = productfeename;

this.price = price;

this.callbackurl = callbackurl;

this.ordertype = ordertype;// 附加資料

getprepayidtask getprepayid = new getprepayidtask();

getprepayid.execute();

}/**

* 非同步任務,提交訂單(發起支付)

*/class getprepayidtask extends asynctask>

@override

protected mapdoinbackground(void... params)

@override

protected void onpostexecute(mapresult)

}/**

*/private string createwechatorder() catch (exception e)

}/**

* doingbackground

*/private mapdecodexml(final string content)

break;

case xmlpullparser.end_tag:

break;

}event = parser.next();

}return xml;

} catch (exception e)

return null;

}// 將totalfee從單位(元)裝換成整數的(分)

private string gettotalfee(string total_fee)

private string toxml(listparams)

return sb.tostring();

}private string gennoncestr()

private long gentimestamp()

/*** 建立訂單支付請求

*/private void createpayreq(final maporderinfo, stringbuffer sbinfo)

// 發起支付,當前頁面結束

private void sendpayreq(final payreq req)

/*** 生成簽名

*/@suppresslint("defaultlocale")

private string genpackagesign(listparams)

string packagesign = md5.getmessagedigest(sb.tostring().getbytes()).touppercase();

return packagesign;

}@suppresslint("defaultlocale")

stringbuilder sb = new stringbuilder();

for (int i = 0; i < params.size(); i++)

}class keyvalue

public string getname()

public void setname(string name)

public string getvalue()

public void setvalue(string value) }}

private void wechat()

Android整合微信支付

總要說兩句 public class wxpayentryactivity extends activity implements iwxapieventhandler override protected void onnewintent intent intent override public...

android微信支付

1,開啟 3,示例 發布使用的簽名正確的話取消和成功都能正確通知.2,測試時使用weixindemo中的debug keystore 3,需要注意應用要通過審核,並且幾個key值正確 商家向財付通申請的商家id 第一步,獲取accesstoken,accesstoken值第二步要用 private ...

android微信支付

builder.settitle 提示 builder.show 現在說一下支付結果返回 1的問題,這個問題真是糾結了好久啊,如果你是按照上面的步驟來的話還出現 1的話,原因只有兩個 1.可能是後台返回給你的引數不正確導致支付失敗,後台調起預支付介面的時候要注意中文亂碼問題,二是注意總金額是int型...