[更新]ComposerUpdate

This commit is contained in:
Anyon 2018-05-03 16:05:14 +08:00
parent d404b32751
commit a510511a2b
9 changed files with 52 additions and 43 deletions

View File

@ -33,7 +33,7 @@ class Index extends Controller
public function pay()
{
$wechat = new Pay(config('wechat.'));
$openid = WechatService::webOauth(0)['openid'];
$openid = WechatService::webOauth($this->request->url(true), 0)['openid'];
$options = [
'body' => '测试商品',
'out_trade_no' => time(),

View File

@ -39,7 +39,8 @@ class BasicWechat extends Controller
*/
protected function getOpenid()
{
return WechatService::webOauth(0)['openid'];
$url = $this->request->url(true);
return WechatService::webOauth($url, 0)['openid'];
}
/**
@ -51,7 +52,8 @@ class BasicWechat extends Controller
*/
protected function getFansinfo()
{
return WechatService::webOauth(1)['fansinfo'];
$url = $this->request->url(true);
return WechatService::webOauth($url, 1)['fansinfo'];
}
}

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit1bea0cc7e1b2c72f31786e6bf86d3d83::getLoader();
return ComposerAutoloaderInitfbb01b03828af73cff04bee933bd6172::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit1bea0cc7e1b2c72f31786e6bf86d3d83
class ComposerAutoloaderInitfbb01b03828af73cff04bee933bd6172
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInit1bea0cc7e1b2c72f31786e6bf86d3d83
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit1bea0cc7e1b2c72f31786e6bf86d3d83', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitfbb01b03828af73cff04bee933bd6172', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit1bea0cc7e1b2c72f31786e6bf86d3d83', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitfbb01b03828af73cff04bee933bd6172', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit1bea0cc7e1b2c72f31786e6bf86d3d83::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitfbb01b03828af73cff04bee933bd6172::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInit1bea0cc7e1b2c72f31786e6bf86d3d83
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit1bea0cc7e1b2c72f31786e6bf86d3d83::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitfbb01b03828af73cff04bee933bd6172::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire1bea0cc7e1b2c72f31786e6bf86d3d83($fileIdentifier, $file);
composerRequirefbb01b03828af73cff04bee933bd6172($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire1bea0cc7e1b2c72f31786e6bf86d3d83($fileIdentifier, $file)
function composerRequirefbb01b03828af73cff04bee933bd6172($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit1bea0cc7e1b2c72f31786e6bf86d3d83
class ComposerStaticInitfbb01b03828af73cff04bee933bd6172
{
public static $files = array (
'1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php',
@ -272,9 +272,9 @@ class ComposerStaticInit1bea0cc7e1b2c72f31786e6bf86d3d83
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit1bea0cc7e1b2c72f31786e6bf86d3d83::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1bea0cc7e1b2c72f31786e6bf86d3d83::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1bea0cc7e1b2c72f31786e6bf86d3d83::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitfbb01b03828af73cff04bee933bd6172::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitfbb01b03828af73cff04bee933bd6172::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitfbb01b03828af73cff04bee933bd6172::$classMap;
}, null, ClassLoader::class);
}

View File

@ -10,7 +10,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/top-think/think-installer/1be326e68f63de4e95977ed50f46ae75f017556d.zip",
"url": "https://api.github.com/repos/top-think/think-installer/zipball/1be326e68f63de4e95977ed50f46ae75f017556d",
"reference": "1be326e68f63de4e95977ed50f46ae75f017556d",
"shasum": ""
},
@ -53,7 +53,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/zoujingli/ip2region/5d981fbf3b574bad7fe9652e7aecba0920f54325.zip",
"url": "https://api.github.com/repos/zoujingli/ip2region/zipball/5d981fbf3b574bad7fe9652e7aecba0920f54325",
"reference": "5d981fbf3b574bad7fe9652e7aecba0920f54325",
"shasum": ""
},
@ -80,17 +80,17 @@
},
{
"name": "zoujingli/wechat-developer",
"version": "v1.1.2",
"version_normalized": "1.1.2.0",
"version": "v1.1.3",
"version_normalized": "1.1.3.0",
"source": {
"type": "git",
"url": "https://github.com/zoujingli/WeChatDeveloper.git",
"reference": "8a2030216b066b78b7b89505f2ee33fe679d54dc"
"reference": "4b1112e8d4723ce5e6ef0d6eee41a02e588b60ab"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/zoujingli/WeChatDeveloper/8a2030216b066b78b7b89505f2ee33fe679d54dc.zip",
"reference": "8a2030216b066b78b7b89505f2ee33fe679d54dc",
"url": "https://api.github.com/repos/zoujingli/WeChatDeveloper/zipball/4b1112e8d4723ce5e6ef0d6eee41a02e588b60ab",
"reference": "4b1112e8d4723ce5e6ef0d6eee41a02e588b60ab",
"shasum": ""
},
"require": {
@ -98,7 +98,7 @@
"ext-openssl": "*",
"php": ">=5.4"
},
"time": "2018-05-02T02:22:46+00:00",
"time": "2018-05-03T07:30:54+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -137,7 +137,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/zoujingli/WeOpenDeveloper/8bb75bc08488a43964c00f027b21b93ed58e8d5a.zip",
"url": "https://api.github.com/repos/zoujingli/WeOpenDeveloper/zipball/8bb75bc08488a43964c00f027b21b93ed58e8d5a",
"reference": "8bb75bc08488a43964c00f027b21b93ed58e8d5a",
"shasum": ""
},
@ -185,7 +185,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/top-think/framework/f879603ee321af8fde56d8855445cf98bc81b042.zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/f879603ee321af8fde56d8855445cf98bc81b042",
"reference": "f879603ee321af8fde56d8855445cf98bc81b042",
"shasum": ""
},
@ -238,7 +238,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/top-think/think-captcha/54c8a51552f99ff9ea89ea9c272383a8f738ceee.zip",
"url": "https://api.github.com/repos/top-think/think-captcha/zipball/54c8a51552f99ff9ea89ea9c272383a8f738ceee",
"reference": "54c8a51552f99ff9ea89ea9c272383a8f738ceee",
"shasum": ""
},
@ -279,7 +279,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/symfony/options-resolver/f3109a6aedd20e35c3a33190e932c2b063b7b50e.zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/f3109a6aedd20e35c3a33190e932c2b063b7b50e",
"reference": "f3109a6aedd20e35c3a33190e932c2b063b7b50e",
"shasum": ""
},
@ -335,7 +335,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/endroid/qr-code/c9644bec2a9cc9318e98d1437de3c628dcd1ef93.zip",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/c9644bec2a9cc9318e98d1437de3c628dcd1ef93",
"reference": "c9644bec2a9cc9318e98d1437de3c628dcd1ef93",
"shasum": ""
},
@ -397,7 +397,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/aliyun/aliyun-oss-php-sdk/e69f57916678458642ac9d2fd341ae78a56996c8.zip",
"url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/e69f57916678458642ac9d2fd341ae78a56996c8",
"reference": "e69f57916678458642ac9d2fd341ae78a56996c8",
"shasum": ""
},
@ -440,7 +440,7 @@
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/qiniu/php-sdk/67852ba9cdd7f48e0e080961abebafee134fb329.zip",
"url": "https://api.github.com/repos/qiniu/php-sdk/zipball/67852ba9cdd7f48e0e080961abebafee134fb329",
"reference": "67852ba9cdd7f48e0e080961abebafee134fb329",
"shasum": ""
},

View File

@ -1,4 +1,4 @@
[![Latest Stable Version](https://poser.pugx.org/zoujingli/wechat-developer/v/stable)](https://packagist.org/packages/wechat-developer) [![Latest Unstable Version](https://poser.pugx.org/zoujingli/wechat-developer/v/unstable)](https://packagist.org/packages/zoujingli/wechat-developer) [![Total Downloads](https://poser.pugx.org/zoujingli/wechat-developer/downloads)](https://packagist.org/packages/wechat-developer) [![License](https://poser.pugx.org/zoujingli/wechat-developer/license)](https://packagist.org/packages/wechat-developer)
[![Latest Stable Version](https://poser.pugx.org/zoujingli/wechat-developer/v/stable)](https://packagist.org/packages/zoujingli/wechat-developer) [![Latest Unstable Version](https://poser.pugx.org/zoujingli/wechat-developer/v/unstable)](https://packagist.org/packages/zoujingli/wechat-developer) [![Total Downloads](https://poser.pugx.org/zoujingli/wechat-developer/downloads)](https://packagist.org/packages/wechat-developer) [![License](https://poser.pugx.org/zoujingli/wechat-developer/license)](https://packagist.org/packages/wechat-developer)
WeChatDeveloper for PHP
--

View File

@ -33,10 +33,18 @@ try {
'notify_url' => 'http://a.com/text.html',
'spbill_create_ip' => '127.0.0.1',
];
// 生成预支付码
$result = $wechat->createOrder($options);
// 创建JSAPI参数签名
$options = $wechat->createParamsForJsApi($result['prepay_id']);
echo '<pre>';
echo "\n--- 创建预支付码 ---\n";
var_export($result);
echo "\n\n--- JSAPI 及 H5 参数 ---\n";
var_export($options);
} catch (Exception $e) {
// 出错啦,处理下吧

View File

@ -75,7 +75,7 @@ class Pay
public function createOrder(array $options)
{
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
return $this->callPostApi($url, $options);
return $this->callPostApi($url, $options, false, 'MD5');
}
@ -266,22 +266,23 @@ class Pay
/**
* 生成支付签名
* @param array $data
* @param string $signType
* @param array $data 参与签名的数据
* @param string $signType 参与签名的类型
* @param string $buff 参与签名字符串前缀
* @return string
*/
public function getPaySign(array $data, $signType = 'MD5')
public function getPaySign(array $data, $signType = 'MD5', $buff = '')
{
unset($data['sign']);
ksort($data);
list($key, $str) = [$this->config->get('mch_key'), ''];
foreach ($data as $k => $v) {
$str .= "{$k}={$v}&";
$buff .= "{$k}={$v}&";
}
if ($signType === 'MD5') {
return strtoupper(md5("{$str}key={$key}"));
$buff .= ("key=" . $this->config->get('mch_key'));
if (strtoupper($signType) === 'MD5') {
return strtoupper(md5($buff));
}
return strtoupper(hash_hmac('SHA256', "{$str}key={$key}", $key));
return strtoupper(hash_hmac('SHA256', $buff, $this->config->get('mch_key')));
}
/**
@ -307,9 +308,7 @@ class Pay
$option['ssl_key'] = $this->config->get('ssl_key');
}
$params = $this->params->merge($data);
if ($needSignType) {
$params['sign_type'] = strtoupper($signType);
}
$needSignType && ($params['sign_type'] = strtoupper($signType));
$params['sign'] = $this->getPaySign($params, $signType);
$result = Tools::xml2arr(Tools::post($url, Tools::arr2xml($params), $option));
if ($result['return_code'] !== 'SUCCESS') {