We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
以下为php代码 $config = array( 'use_alias' => false, 'app_id' => WxPayConfig::APPID, 'secret' => WxPayConfig::APPSECRET, 'token' => WxPayConfig::APPTOKEN, 'encoding_key' => WxPayConfig::ENCODING_KEY // 加密模式需要,其它模式不需要 ); $js = new Js($config); $card = new Card($config); $timestamp = time(); $nonce_str = $card->getNonce(); $api_ticket = $card->getTicket(); //根据http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=cardsign 来看需要appid和cardType $signature = $card->getSignature($api_ticket, $timestamp, WxPayConfig::APPID, 'CASH', $nonce_str); 以下为js代码 wx.config(<?php echo $js->config(array('chooseCard'), true, true) ?>); wx.ready(function () { document.querySelector('#chooseCard').onclick = function () { wx.chooseCard({ cardType: 'CASH', //需要与卡券签名传入参数保持一致 timestamp: <?php echo $timestamp ?>, // 卡券签名时间戳 nonceStr: '<?php echo $nonce_str ?>', // 卡券签名随机串 cardSign: '<?php echo $signature ?>', // 卡券签名 success: function (res) { alert(res); var cardList= res.cardList; // 用户选中的卡券列表信息 } }); } });
以下为php代码
$config = array( 'use_alias' => false, 'app_id' => WxPayConfig::APPID, 'secret' => WxPayConfig::APPSECRET, 'token' => WxPayConfig::APPTOKEN, 'encoding_key' => WxPayConfig::ENCODING_KEY // 加密模式需要,其它模式不需要 ); $js = new Js($config); $card = new Card($config); $timestamp = time(); $nonce_str = $card->getNonce(); $api_ticket = $card->getTicket(); //根据http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=cardsign 来看需要appid和cardType $signature = $card->getSignature($api_ticket, $timestamp, WxPayConfig::APPID, 'CASH', $nonce_str);
以下为js代码
wx.config(<?php echo $js->config(array('chooseCard'), true, true) ?>); wx.ready(function () { document.querySelector('#chooseCard').onclick = function () { wx.chooseCard({ cardType: 'CASH', //需要与卡券签名传入参数保持一致 timestamp: <?php echo $timestamp ?>, // 卡券签名时间戳 nonceStr: '<?php echo $nonce_str ?>', // 卡券签名随机串 cardSign: '<?php echo $signature ?>', // 卡券签名 success: function (res) { alert(res); var cardList= res.cardList; // 用户选中的卡券列表信息 } }); } });
The text was updated successfully, but these errors were encountered:
https://github.com/overtrue/wechat/blob/2.0/src/Wechat/Card.php#L532
其实 getSignature 方法的参数并没有固定的
getSignature
Sorry, something went wrong.
但是官方文档上cardType说是非必须的,感觉这里是不是可以做个专门生成chooseCard参数的方法,比如 $card->chooseCard('cardType'),前端就可以直接调用了
这事儿,3.0版本我考虑一下,2.0 不会新增功能了。
No branches or pull requests
The text was updated successfully, but these errors were encountered: