APP微信支付實現

2022-01-11 14:54:34 字數 1103 閱讀 9447

設計到的api: 統一下單api、支付結果通知api和查詢訂單api

下面**是請求預支付id

//

構建下單bean

final wxpayunifiedorderbean unifiedorderbean = new

wxpayunifiedorderbean();

unifiedorderbean.setmch_id(wxpayconfig.getmchid());

unifiedorderbean.setnonce_str(

this.getnoncestr(16));

unifiedorderbean.setbody("支付");

unifiedorderbean.setout_trade_no(order.gethuborderno());

unifiedorderbean.settotal_fee(order.gettotalfee());

unifiedorderbean.setspbill_create_ip(order.getspbill_create_ip());

unifiedorderbean.setnotify_url(

this

.paymentproperties.getweixin().getnotify_url());

unifiedorderbean.setsign(

this

.generatesignforprepayid(unifiedorderbean, wxpayconfig.getsecret()));

//請求統一下單介面

final wxpayprepaybean bean = this

.requestwx(unifiedorderbean);

/*** 請求統一下單介面**

@param

unifiedorderbean

* @return

*/private wxpayprepaybean requestwx(final

wxpayunifiedorderbean unifiedorderbean)

catch (final

exception e)

}

微信app支付

商戶id public static final string partner id 14698sdfs402dsfdew402 常量固定值 public static final string grant type client credential 獲取預支付id的介面url public st...

微信app支付

文件 arr mchid mchid,nonce str str random 32 隨機數 partner trade no order id,自己定義乙個不重複訂單號 check name no check desc desc,spbill create ip request getclient...

微信APP支付

final string mchid,final string notifyurl,final string outtradeno,final string noncestr,final string body,final string productid,final string totalfee...