@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | //扫码支付 |
4 | -require_once __DIR__ . "/autoload.php"; |
|
4 | +require_once __DIR__."/autoload.php"; |
|
5 | 5 | use zhangv\wechat\WechatPay; |
6 | 6 | |
7 | 7 | $cfg = include './config.php'; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | $desc = "desc$stamp"; |
13 | 13 | $productid = "testproduct"; |
14 | 14 | $amt = 1; |
15 | -$codeurl = $payment->getCodeUrl($desc, $orderid, $amt,$productid); |
|
15 | +$codeurl = $payment->getCodeUrl($desc, $orderid, $amt, $productid); |
|
16 | 16 | |
17 | 17 | ?> |
18 | 18 | <script type="text/javascript" src="js/jquery.js"></script> |
@@ -1,24 +1,24 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | //OAuth授权回调 |
4 | -require_once __DIR__ . "/autoload.php"; |
|
4 | +require_once __DIR__."/autoload.php"; |
|
5 | 5 | use zhangv\wechat\WechatOAuth; |
6 | 6 | |
7 | -if (isset($_GET['code'])){ |
|
7 | +if (isset($_GET['code'])) { |
|
8 | 8 | $cfg = require './config.php'; |
9 | 9 | |
10 | 10 | $code = trim($_GET['code']); |
11 | 11 | $state = trim($_GET['state']); |
12 | - $oauth = new WechatOAuth($cfg['app_id'],$cfg['app_secret']); |
|
12 | + $oauth = new WechatOAuth($cfg['app_id'], $cfg['app_secret']); |
|
13 | 13 | $at = $oauth->authorize($code); |
14 | 14 | |
15 | - if(!$at || empty($at->openid)){ |
|
15 | + if (!$at || empty($at->openid)) { |
|
16 | 16 | die('授权失败'); |
17 | - }else{ |
|
17 | + }else { |
|
18 | 18 | $accesstoken = $at->access_token; |
19 | 19 | $openid = $at->openid; |
20 | 20 | header('Location: '."http://{$_SERVER['HTTP_HOST']}/wechat-pay/demo/pay.php?openid=$openid"); |
21 | 21 | } |
22 | -}else{ |
|
22 | +}else { |
|
23 | 23 | die('授权失败,请重试。'); |
24 | 24 | } |
25 | 25 | \ No newline at end of file |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(file_exists(__DIR__ . '/../vendor/autoload.php')){ |
|
3 | +if (file_exists(__DIR__.'/../vendor/autoload.php')) { |
|
4 | 4 | /** @var \Composer\Autoload\ClassLoader $loader */ |
5 | - $loader = require __DIR__ . '/../vendor/autoload.php'; |
|
6 | -}else{//if the composer is not initialized, note: this is not work in phpunit, switch to composer when unit testing |
|
5 | + $loader = require __DIR__.'/../vendor/autoload.php'; |
|
6 | +}else {//if the composer is not initialized, note: this is not work in phpunit, switch to composer when unit testing |
|
7 | 7 | function __autoload($class) { |
8 | 8 | $class = str_replace('zhangv\\wechat\\', 'src/', $class); |
9 | - $file = __DIR__ . '/../' . $class . '.php'; |
|
9 | + $file = __DIR__.'/../'.$class.'.php'; |
|
10 | 10 | require_once $file; |
11 | 11 | } |
12 | 12 | spl_autoload_register('__autoload'); |
@@ -3,7 +3,7 @@ |
||
3 | 3 | if(file_exists(__DIR__ . '/../vendor/autoload.php')){ |
4 | 4 | /** @var \Composer\Autoload\ClassLoader $loader */ |
5 | 5 | $loader = require __DIR__ . '/../vendor/autoload.php'; |
6 | -}else{//if the composer is not initialized, note: this is not work in phpunit, switch to composer when unit testing |
|
6 | +} else{//if the composer is not initialized, note: this is not work in phpunit, switch to composer when unit testing |
|
7 | 7 | function __autoload($class) { |
8 | 8 | $class = str_replace('zhangv\\wechat\\', 'src/', $class); |
9 | 9 | $file = __DIR__ . '/../' . $class . '.php'; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | //OAuth授权 |
4 | -require_once __DIR__ . "/autoload.php"; |
|
4 | +require_once __DIR__."/autoload.php"; |
|
5 | 5 | |
6 | 6 | use zhangv\wechat\WechatOAuth; |
7 | 7 | |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | $redirect = "http://{$_SERVER['HTTP_HOST']}/wechat-pay/demo/wxoauthcallback.php"; |
11 | 11 | $scope = 'snsapi_userinfo'; |
12 | 12 | $state = ""; |
13 | -$oauth =new WechatOAuth($appid,$cfg['app_secret']); |
|
14 | -$url = $oauth->authorizeURI($redirect,$scope); |
|
13 | +$oauth = new WechatOAuth($appid, $cfg['app_secret']); |
|
14 | +$url = $oauth->authorizeURI($redirect, $scope); |
|
15 | 15 | |
16 | 16 | header('Location: '.$redirect); |
17 | 17 | \ No newline at end of file |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once __DIR__ . "/autoload.php"; |
|
3 | +require_once __DIR__."/autoload.php"; |
|
4 | 4 | use zhangv\wechat\WechatPay; |
5 | 5 | |
6 | 6 | $xml = file_get_contents("php://input"); |
7 | 7 | |
8 | 8 | $cfg = require './config.php'; |
9 | 9 | $payment = new WechatPay($cfg); |
10 | -$payment->onRefundedNotify($xml,function($notifydata) use ($payment){ |
|
10 | +$payment->onRefundedNotify($xml, function($notifydata) use ($payment){ |
|
11 | 11 | //do stuff |
12 | 12 | print_r($notifydata); |
13 | 13 | $payment->responseNotify(); |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | //公众号支付 |
4 | -require_once __DIR__ . "/autoload.php"; |
|
4 | +require_once __DIR__."/autoload.php"; |
|
5 | 5 | |
6 | 6 | use zhangv\wechat\WechatPay; |
7 | 7 | $cfg = include './config.php'; |
8 | 8 | |
9 | -if(empty( $_REQUEST['openid'])) { |
|
9 | +if (empty($_REQUEST['openid'])) { |
|
10 | 10 | $redirect = "http://{$_SERVER['HTTP_HOST']}/wechat-pay/demo/wxoauth.php"; |
11 | 11 | header('Location: '.$redirect); |
12 | 12 | exit; |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | //APP支付 - 获取预支付交易回话标识 |
4 | 4 | //注意:APP支付使用的是开放平台的APPID |
5 | -require_once __DIR__ . "/autoload.php"; |
|
5 | +require_once __DIR__."/autoload.php"; |
|
6 | 6 | |
7 | 7 | use zhangv\wechat\WechatPay; |
8 | 8 |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | //h5支付 |
4 | -require_once __DIR__ . "/autoload.php"; |
|
4 | +require_once __DIR__."/autoload.php"; |
|
5 | 5 | use zhangv\wechat\WechatPay; |
6 | 6 | |
7 | 7 | $cfg = include './config.php'; |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once __DIR__ . "/autoload.php"; |
|
3 | +require_once __DIR__."/autoload.php"; |
|
4 | 4 | use zhangv\wechat\WechatPay; |
5 | 5 | |
6 | 6 | $xml = file_get_contents("php://input"); |
7 | 7 | |
8 | 8 | $cfg = require './config.php'; |
9 | 9 | $payment = new WechatPay($cfg); |
10 | -$payment->onPaidNotify($xml,function($notifydata) use ($payment){ |
|
10 | +$payment->onPaidNotify($xml, function($notifydata) use ($payment){ |
|
11 | 11 | //do stuff |
12 | 12 | print_r($notifydata); |
13 | - $payment->responseNotify('SUCCESS','OK'); |
|
13 | + $payment->responseNotify('SUCCESS', 'OK'); |
|
14 | 14 | }); |
15 | 15 |