示例#1
0
<?php

require_once '../vendor/autoload.php';
require_once './WxPay.pub.config.php';
use Codelint\Wechat\JsSdk\JsSdk;
$jsSdk = new JsSdk();
$jsSdk->setAppId(WxPayConf_pub::APPID);
$jsSdk->setAppSecret(WxPayConf_pub::APPSECRET);
$jsSdk->setup(array('cert_path' => WxPayConf_pub::SSLCERT_PATH, 'cert_key_path' => WxPayConf_pub::SSLKEY_PATH));
$token = $jsSdk->getToken();
$card_id = $_GET['card_id'];
$jsSdk->consumeCard($token, $_GET['card_id'], $_GET['card_code']);
示例#2
0
<?php

require_once '../../vendor/autoload.php';
require_once '../WxPay.pub.config.php';
use Codelint\Wechat\JsSdk\JsSdk;
$jsSdk = new JsSdk();
$jsSdk->setAppId(WxPayConf_pub::APPID);
$jsSdk->setAppSecret(WxPayConf_pub::APPSECRET);
$token = $jsSdk->getToken();
$ticket = $jsSdk->getJsApiTicket($token);
$url = array_get($_SERVER, 'HTTP_REFERER', '');
$config = $jsSdk->getConfigSignature($ticket, $url);
//$signature = new \Codelint\Wechat\JsSdk\Card\Signature();
//$signature->add_data(WxPayConf_pub::APPID);
//var_dump($nonstr = str_random(16));
//$signature->add_data($nonstr);
//var_dump($now = time());
//$signature->add_data('' . $now);
//$signature->add_data($jsSdk->getCardTicket($token));
//var_dump($signature->get_signature());
//$api_ticket = $jsSdk->getCardTicket($token);
//$ext = $jsSdk->getAddCardSignature($api_ticket, 'p8O_-jogSK_lQz0dyH-C9Plu4f_A');
//var_dump(json_encode(array_only($ext, ['code', 'openid', 'timestamp', 'signature'])));
//die();
?>

/*
* 注意:
* 1. 所有的JS接口只能在公众号绑定的域名下调用,公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
* 2. 如果发现在 Android 不能分享自定义内容,请到官网下载最新的包覆盖安装,Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
* 3. 常见问题及完整 JS-SDK 文档地址:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html