微信支付問(wèn)題


1、設(shè)置URL Schemes

2、在AppDelegate里注冊(cè)微信支付[WXApi registerApp:@"appid"];

3、調(diào)起微信支付

PayReq *request = [[[PayReq alloc] init] autorelease];

request.partnerId = @"10000100";

request.prepayId= @"1101000000140415649af9fc314aa427";

request.package = @"Sign=WXPay";

request.nonceStr= @"a462b76e7436e98e0ed6e13c64b4fd1c";

request.timeStamp= @"1397527777";

request.sign= @"582282D72DD2B03AD892830965F428CB16E7A256";

[WXApi sendReq:request];

在調(diào)起微信支付之前需要向服務(wù)器獲取微信支付的相關(guān)參數(shù),這些參數(shù)是服務(wù)器調(diào)用微信的統(tǒng)一下單API所得,問(wèn)題出在服務(wù)器生成的簽名錯(cuò)誤,根據(jù)微信官方給出的iOS demo,整理下流程,供服務(wù)器校對(duì):

1、預(yù)付單參數(shù)設(shè)置

Printing description of packageParams:

{

appid = wxbfe7bd3faa6e56d6;

body = "V3\U652f\U4ed8\U6d4b\U8bd5";

"device_info" = "APP-001";

"mch_id" = 1245634502;

"nonce_str" = 1024782077;

"notify_url" = "http://wxpay.weixin.qq.com/pub_v2/pay/notify.v2.php";

"out_trade_no" = 1436870256;

"spbill_create_ip" = "192.168.1.127";

"total_fee" = 1;

"trade_type" = APP;

}

2、生成prePayid

(1)獲取package帶參數(shù)的簽名包

a、生成簽名

參數(shù)

Printing description of dict:

{

appid = appid;

body = "V3\U652f\U4ed8\U6d4b\U8bd5";

"device_info" = "APP-001";

"mch_id" = 1245634502;

"nonce_str" = 1024782077;

"notify_url" = "http://wxpay.weixin.qq.com/pub_v2/pay/notify.v2.php";

"out_trade_no" = 1436870256;

"spbill_create_ip" = "192.168.1.127";

"total_fee" = 1;

"trade_type" = APP;

}

b、生成xml的package

結(jié)果

< xml>

< mch_id>1245634502

< out_trade_no>1436870256

< device_info>APP-001

< nonce_str>1024782077

< total_fee>1

< notify_url>http://wxpay.weixin.qq.com/pub_v2/pay/notify.v2.php

< spbill_create_ip>192.168.1.127

< body>V3支付測(cè)試

< appid>appid

< trade_type>APP

< sign>B220AF98FC3638EC1A5AD5C3808BB0F8

< /xml>

c、post向微信發(fā)起請(qǐng)求,參數(shù)為上邊的xml

返回值:

< xml>

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容