微信支付问题

作者: 仲子 | 来源:发表于2015-11-10 17:28 被阅读999次

    1、设置URL Schemes

    2、在AppDelegate里注册微信支付[WXApi registerApp:@"appid"];

    3、调起微信支付

    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];

    在调起微信支付之前需要向服务器获取微信支付的相关参数,这些参数是服务器调用微信的统一下单API所得,问题出在服务器生成的签名错误,根据微信官方给出的iOS demo,整理下流程,供服务器校对:

    1、预付单参数设置

    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带参数的签名包

    a、生成签名

    参数

    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

    结果

    < 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支付测试

    < appid>appid

    < trade_type>APP

    < sign>B220AF98FC3638EC1A5AD5C3808BB0F8

    < /xml>

    c、post向微信发起请求,参数为上边的xml

    返回值:

    < xml>

    相关文章

      网友评论

        本文标题:微信支付问题

        本文链接:https://www.haomeiwen.com/subject/kmdhhttx.html