merge to dev : apply styleCI

This commit is contained in:
yansongda 2017-08-15 22:55:04 +08:00
commit 5cd5d82807
17 changed files with 274 additions and 50 deletions

View File

@ -10,19 +10,19 @@
## 支持的支付网关 ## 支持的支付网关
### 支付宝 ### 1、支付宝
- 电脑支付 - 电脑支付
- 手机网站支付 - 手机网站支付
SDK 中对应的 driver 和 gateway 如下表所示: SDK 中对应的 driver 和 gateway 如下表所示:
| driver | gateway | 描述 | | driver | gateway | 描述 |
| :----: | :-----: | :-------: | | :----: | :-----: | :-------: |
| alipay | web | 电脑支付 | | alipay | web | 电脑支付 |
| alipay | wap | 手机网站支付 | | alipay | wap | 手机网站支付 |
### 微信 ### 2、微信
- 公众号支付 - 公众号支付
- 小程序支付 - 小程序支付
@ -139,6 +139,24 @@ $config_biz = [
### 支付宝 - 手机网站支付 ### 支付宝 - 手机网站支付
1、最小配置参数
```php
$config = [
'alipay' => [
'app_id' => '', // 支付宝提供的 APP_ID
'ali_public_key' => '', // 支付宝公钥1行填写
'private_key' => '', // 自己的私钥1行填写
],
];
$config_biz = [
'out_trade_no' => '12', // 订单号
'total_amount' => '13', // 订单金额,单位:元
'subject' => 'officeal test subject', // 订单商品标题
];
```
2、所有配置参数
该网关大部分参数和 「电脑支付」 相同,具体请参考 [官方文档](https://docs.open.alipay.com/203/107090/ '支付宝手机网站支付文档') 该网关大部分参数和 「电脑支付」 相同,具体请参考 [官方文档](https://docs.open.alipay.com/203/107090/ '支付宝手机网站支付文档')
### 微信 - 公众号支付 ### 微信 - 公众号支付

View File

@ -1,4 +1,4 @@
<?php <?php
namespace Yansongda\Pay\Contracts; namespace Yansongda\Pay\Contracts;
/** /**
@ -8,38 +8,54 @@ interface GatewayInterface
{ {
/** /**
* 支付 * 支付
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function pay(array $config_biz); public function pay(array $config_biz);
/** /**
* 退款 * 退款
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function refund(array $config_biz); public function refund(array $config_biz);
/** /**
* 关闭 * 关闭
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function close(array $config_biz); public function close(array $config_biz);
/** /**
* 验证消息是否官方发出 * 验证消息是否官方发出
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param mixed $data 待签名数组 * @param mixed $data 待签名数组
* @param string $sign 签名字符串-支付宝服务器发送过来的原始串 * @param string $sign 签名字符串-支付宝服务器发送过来的原始串
* @param bool $sync 是否同步验证 * @param bool $sync 是否同步验证
*
* @return [type] [description] * @return [type] [description]
*/ */
public function verify($data, $sign = null, $sync = false); public function verify($data, $sign = null, $sync = false);

View File

@ -1,11 +1,10 @@
<?php <?php
namespace Yansongda\Pay\Exceptions; namespace Yansongda\Pay\Exceptions;
/** /**
* * Exception
*/ */
class Exception extends \Exception class Exception extends \Exception
{ {
} }

View File

@ -1,22 +1,26 @@
<?php <?php
namespace Yansongda\Pay\Exceptions; namespace Yansongda\Pay\Exceptions;
/** /**
* GatewayException * GatewayException
*/ */
class GatewayException extends Exception class GatewayException extends Exception
{ {
/** /**
* error raw data * error raw data
*
* @var array * @var array
*/ */
public $raw = []; public $raw = [];
/** /**
* [__construct description] * [__construct description]
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-28 * @version 2017-07-28
*
* @param [type] $message [description] * @param [type] $message [description]
* @param [type] $code [description] * @param [type] $code [description]
*/ */

View File

@ -1,11 +1,10 @@
<?php <?php
namespace Yansongda\Pay\Exceptions; namespace Yansongda\Pay\Exceptions;
/** /**
* InvalidArgumentException * InvalidArgumentException
*/ */
class InvalidArgumentException extends \InvalidArgumentException class InvalidArgumentException extends \InvalidArgumentException
{ {
} }

View File

@ -1,4 +1,4 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Alipay; namespace Yansongda\Pay\Gateways\Alipay;
@ -9,34 +9,40 @@ use Yansongda\Pay\Exceptions\GatewayException;
use Yansongda\Pay\Exceptions\InvalidArgumentException; use Yansongda\Pay\Exceptions\InvalidArgumentException;
/** /**
* * abstract class Alipay
*/ */
abstract class Alipay implements GatewayInterface abstract class Alipay implements GatewayInterface
{ {
use HasHttpRequest; use HasHttpRequest;
/** /**
* 支付宝支付网关 * 支付宝支付网关
*
* @var string * @var string
*/ */
protected $gateway = 'https://openapi.alipaydev.com/gateway.do'; protected $gateway = 'https://openapi.alipaydev.com/gateway.do';
/** /**
* 支付宝公共参数 * 支付宝公共参数
*
* @var [type] * @var [type]
*/ */
protected $config; protected $config;
/** /**
* 用户的传参 * 用户的传参
*
* @var [type] * @var [type]
*/ */
protected $user_config; protected $user_config;
/** /**
* [__construct description] * [__construct description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-14 * @version 2017-08-14
*
* @param array $config [description] * @param array $config [description]
*/ */
public function __construct(array $config) public function __construct(array $config)
@ -65,9 +71,13 @@ abstract class Alipay implements GatewayInterface
/** /**
* 对外接口 - 支付 * 对外接口 - 支付
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
@ -83,9 +93,13 @@ abstract class Alipay implements GatewayInterface
/** /**
* 对外接口 - 退款 * 对外接口 - 退款
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function refund(array $config_biz = []) public function refund(array $config_biz = [])
@ -99,9 +113,13 @@ abstract class Alipay implements GatewayInterface
/** /**
* 对外接口 - 关闭 * 对外接口 - 关闭
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function close(array $config_biz = []) public function close(array $config_biz = [])
@ -115,11 +133,15 @@ abstract class Alipay implements GatewayInterface
/** /**
* 对外接口 - 验证 * 对外接口 - 验证
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-11 * @version 2017-08-11
*
* @param array $data 待签名数组 * @param array $data 待签名数组
* @param string $sign 签名字符串-支付宝服务器发送过来的原始串 * @param string $sign 签名字符串-支付宝服务器发送过来的原始串
* @param bool $sync 是否同步验证 * @param bool $sync 是否同步验证
*
* @return [type] [description] * @return [type] [description]
*/ */
public function verify($data, $sign = null, $sync = false) public function verify($data, $sign = null, $sync = false)
@ -145,24 +167,33 @@ abstract class Alipay implements GatewayInterface
/** /**
* [getMethod description] * [getMethod description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-10 * @version 2017-08-10
*
* @return [type] [description] * @return [type] [description]
*/ */
abstract protected function getPayMethod(); abstract protected function getPayMethod();
/** /**
* [getProductCode description] * [getProductCode description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-10 * @version 2017-08-10
*
* @return [type] [description] * @return [type] [description]
*/ */
abstract protected function getPayProductCode(); abstract protected function getPayProductCode();
/** /**
* [buildHtmlPay description] * [buildHtmlPay description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-11 * @version 2017-08-11
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function buildPayHtml() protected function buildPayHtml()
@ -180,9 +211,13 @@ abstract class Alipay implements GatewayInterface
/** /**
* get alipay api result * get alipay api result
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-12 * @version 2017-08-12
*
* @param [type] $method [description] * @param [type] $method [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function getResult($method) protected function getResult($method)
@ -201,8 +236,11 @@ abstract class Alipay implements GatewayInterface
/** /**
* 签名 * 签名
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-10 * @version 2017-08-10
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function getSign() protected function getSign()
@ -222,10 +260,14 @@ abstract class Alipay implements GatewayInterface
/** /**
* 待签名数组 * 待签名数组
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-11 * @version 2017-08-11
*
* @param array $toBeSigned [description] * @param array $toBeSigned [description]
* @param boolean $verify 是否异步同时验证签名 * @param boolean $verify 是否异步同时验证签名
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function getSignContent(array $toBeSigned, $verify = false) protected function getSignContent(array $toBeSigned, $verify = false)

View File

@ -1,16 +1,19 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Alipay; namespace Yansongda\Pay\Gateways\Alipay;
/** /**
* * WapGateway
*/ */
class WapGateway extends Alipay class WapGateway extends Alipay
{ {
/** /**
* [getMethod description] * [getMethod description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-10 * @version 2017-08-10
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function getPayMethod() { protected function getPayMethod() {
@ -19,8 +22,11 @@ class WapGateway extends Alipay
/** /**
* [getProductCode description] * [getProductCode description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-10 * @version 2017-08-10
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function getPayProductCode() { protected function getPayProductCode() {

View File

@ -1,16 +1,19 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Alipay; namespace Yansongda\Pay\Gateways\Alipay;
/** /**
* * class WebGateway
*/ */
class WebGateway extends Alipay class WebGateway extends Alipay
{ {
/** /**
* [getMethod description] * [getMethod description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-10 * @version 2017-08-10
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function getPayMethod() { protected function getPayMethod() {
@ -19,8 +22,11 @@ class WebGateway extends Alipay
/** /**
* [getProductCode description] * [getProductCode description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-10 * @version 2017-08-10
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function getPayProductCode() { protected function getPayProductCode() {

View File

@ -1,16 +1,19 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Wechat; namespace Yansongda\Pay\Gateways\Wechat;
/** /**
* 微信 - 公众号支付 * 微信 - 公众号支付
*/ */
class AppGateway extends Wechat class AppGateway extends Wechat
{ {
/** /**
* 交易类型 * 交易类型
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function getTradeType() protected function getTradeType()
@ -20,9 +23,13 @@ class AppGateway extends Wechat
/** /**
* 对外支付 * 对外支付
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])

View File

@ -1,16 +1,19 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Wechat; namespace Yansongda\Pay\Gateways\Wechat;
/** /**
* 微信支付 - 扫码支付 * 微信支付 - 扫码支付
*/ */
class ScanGateway extends Wechat class ScanGateway extends Wechat
{ {
/** /**
* [getTradeType description] * [getTradeType description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @return [type] [description] * @return [type] [description]
*/ */
public function getTradeType() public function getTradeType()
@ -20,9 +23,13 @@ class ScanGateway extends Wechat
/** /**
* 对外支付 * 对外支付
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])

View File

@ -1,16 +1,19 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Wechat; namespace Yansongda\Pay\Gateways\Wechat;
/** /**
* 微信 - 公众号支付 * 微信 - 公众号支付
*/ */
class MpGateway extends Wechat class MpGateway extends Wechat
{ {
/** /**
* 交易类型 * 交易类型
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function getTradeType() protected function getTradeType()
@ -20,9 +23,13 @@ class MpGateway extends Wechat
/** /**
* 对外支付 * 对外支付
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])

View File

@ -1,12 +1,21 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Wechat; namespace Yansongda\Pay\Gateways\Wechat;
/** /**
* 微信支付 - 刷卡支付 * 微信支付 - 刷卡支付
*/ */
class PosGateway extends Wechat class PosGateway extends Wechat
{ {
/**
* [getTradeType description]
*
* @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15
*
* @return [type] [description]
*/
public function getTradeType() public function getTradeType()
{ {
return 'JSAPI'; return 'JSAPI';

View File

@ -1,16 +1,19 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Wechat; namespace Yansongda\Pay\Gateways\Wechat;
/** /**
* 微信支付 - 扫码支付 * 微信支付 - 扫码支付
*/ */
class ScanGateway extends Wechat class ScanGateway extends Wechat
{ {
/** /**
* [getTradeType description] * [getTradeType description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @return [type] [description] * @return [type] [description]
*/ */
public function getTradeType() public function getTradeType()
@ -20,16 +23,20 @@ class ScanGateway extends Wechat
/** /**
* 对外支付,采用 「模式二」 进行支付 * 对外支付,采用 「模式二」 进行支付
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return string 微信支付扫码 URL * @return string 微信支付扫码 URL
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {
$this->config = array_merge($this->config, $config_biz); $this->config = array_merge($this->config, $config_biz);
$data = $this->preOrder(), $data = $this->preOrder();
return $data['code_url']; return $data['code_url'];
} }

View File

@ -1,16 +1,19 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Wechat; namespace Yansongda\Pay\Gateways\Wechat;
/** /**
* 微信支付 - H5 支付 * 微信支付 - H5 支付
*/ */
class WapGateway extends Wechat class WapGateway extends Wechat
{ {
/** /**
* [getTradeType description] * [getTradeType description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @return [type] [description] * @return [type] [description]
*/ */
public function getTradeType() public function getTradeType()
@ -20,9 +23,13 @@ class WapGateway extends Wechat
/** /**
* 支付 * 支付
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $config_biz [description] * @param array $config_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])

View File

@ -1,4 +1,4 @@
<?php <?php
namespace Yansongda\Pay\Gateways\Wechat; namespace Yansongda\Pay\Gateways\Wechat;
@ -9,34 +9,40 @@ use Yansongda\Pay\Exceptions\GatewayException;
use Yansongda\Pay\Exceptions\InvalidArgumentException; use Yansongda\Pay\Exceptions\InvalidArgumentException;
/** /**
* * abstract class Wechat
*/ */
abstract class Wechat implements GatewayInterface abstract class Wechat implements GatewayInterface
{ {
use HasHttpRequest; use HasHttpRequest;
/** /**
* [$preOrder_gateway description] * [$preOrder_gateway description]
*
* @var string * @var string
*/ */
protected $preOrder_gateway = 'https://api.mch.weixin.qq.com/pay/unifiedorder'; protected $preOrder_gateway = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
/** /**
* [$config description] * [$config description]
*
* @var [type] * @var [type]
*/ */
protected $config; protected $config;
/** /**
* [$user_config description] * [$user_config description]
*
* @var [type] * @var [type]
*/ */
protected $user_config; protected $user_config;
/** /**
* [__construct description] * [__construct description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-14 * @version 2017-08-14
*
* @param array $config [description] * @param array $config [description]
*/ */
public function __construct(array $config) public function __construct(array $config)
@ -55,17 +61,24 @@ abstract class Wechat implements GatewayInterface
/** /**
* 对外支付接口 * 对外支付接口
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $cofnig_biz [description] * @param array $cofnig_biz [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
abstract public function pay(array $config_biz = []); abstract public function pay(array $config_biz = []);
/** /**
* 对外接口 - 退款 * 对外接口 - 退款
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @return [type] [description] * @return [type] [description]
*/ */
public function refund(array $config_biz = []) public function refund(array $config_biz = [])
@ -75,8 +88,11 @@ abstract class Wechat implements GatewayInterface
/** /**
* 对外接口 - 关闭订单 * 对外接口 - 关闭订单
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @return [type] [description] * @return [type] [description]
*/ */
public function close(array $config_biz = []) public function close(array $config_biz = [])
@ -86,10 +102,15 @@ abstract class Wechat implements GatewayInterface
/** /**
* 验证签名 * 验证签名
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param string $data 待验证 xml 数据 * @param string $data 待验证 xml 数据
* @param string $sign 服务器返回的签名 * @param string $sign 服务器返回的签名
* @param bool $sync is sync sign
*
* @return bool 是否相符 * @return bool 是否相符
*/ */
public function verify($data, $sign = null, $sync = false) public function verify($data, $sign = null, $sync = false)
@ -103,8 +124,11 @@ abstract class Wechat implements GatewayInterface
/** /**
* 预下单 * 预下单
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @return array 服务器返回结果数组 * @return array 服务器返回结果数组
*/ */
protected function preOrder() protected function preOrder()
@ -130,9 +154,13 @@ abstract class Wechat implements GatewayInterface
/** /**
* 签名 * 签名
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $data 带签名数组 * @param array $data 带签名数组
*
* @return string [description] * @return string [description]
*/ */
protected function getSign($data) protected function getSign($data)
@ -150,9 +178,13 @@ abstract class Wechat implements GatewayInterface
/** /**
* 将数组转换成 URL 格式 * 将数组转换成 URL 格式
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15 * @version 2017-08-15
*
* @param array $data [description] * @param array $data [description]
*
* @return string [description] * @return string [description]
*/ */
protected function getSignContent($data) protected function getSignContent($data)
@ -171,9 +203,13 @@ abstract class Wechat implements GatewayInterface
/** /**
* 生成随机字符串 * 生成随机字符串
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-14 * @version 2017-08-14
*
* @param integer $length [description] * @param integer $length [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
protected function createNonceStr($length = 16) { protected function createNonceStr($length = 16) {
@ -188,9 +224,13 @@ abstract class Wechat implements GatewayInterface
/** /**
* 转化为 xml * 转化为 xml
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-14 * @version 2017-08-14
*
* @param array $data 带转化数组 * @param array $data 带转化数组
*
* @return string 转化后的xml字符串 * @return string 转化后的xml字符串
*/ */
protected function toXml($data) protected function toXml($data)
@ -214,9 +254,13 @@ abstract class Wechat implements GatewayInterface
/** /**
* xml 转化为 array * xml 转化为 array
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-14 * @version 2017-08-14
*
* @param string $xml xml字符串 * @param string $xml xml字符串
*
* @return array 转化后的数组 * @return array 转化后的数组
*/ */
protected function fromXml($xml) protected function fromXml($xml)

View File

@ -1,4 +1,4 @@
<?php <?php
namespace Yansongda\Pay; namespace Yansongda\Pay;
@ -6,32 +6,38 @@ use Yansongda\Pay\Support\Config;
use Yansongda\Pay\Exceptions\InvalidArgumentException; use Yansongda\Pay\Exceptions\InvalidArgumentException;
/** /**
* * class Pay
*/ */
class Pay class Pay
{ {
/** /**
* [$config description] * [$config description]
*
* @var [type] * @var [type]
*/ */
private $config; private $config;
/** /**
* [$dirvers description] * [$dirvers description]
*
* @var [type] * @var [type]
*/ */
private $dirvers; private $dirvers;
/** /**
* [$gateways description] * [$gateways description]
*
* @var [type] * @var [type]
*/ */
private $gateways; private $gateways;
/** /**
* [__construct description] * [__construct description]
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-29 * @version 2017-07-29
*
* @param array $config [description] * @param array $config [description]
*/ */
public function __construct(array $config = []) public function __construct(array $config = [])
@ -41,9 +47,13 @@ class Pay
/** /**
* [driver description] * [driver description]
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-30 * @version 2017-07-30
*
* @param [type] $driver [description] * @param [type] $driver [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function driver($driver) public function driver($driver)
@ -59,9 +69,13 @@ class Pay
/** /**
* [gateway description] * [gateway description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-10 * @version 2017-08-10
*
* @param string $gateway [description] * @param string $gateway [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function gateway($gateway = 'web') public function gateway($gateway = 'web')
@ -77,9 +91,13 @@ class Pay
/** /**
* [createGateway description] * [createGateway description]
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-10 * @version 2017-08-10
*
* @param [type] $gateway [description] * @param [type] $gateway [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
private function createGateway($gateway) private function createGateway($gateway)
@ -95,10 +113,14 @@ class Pay
/** /**
* [buildDriver description] * [buildDriver description]
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-30 * @version 2017-07-30
* @param [type] $driver [description] *
* @param [type] $driver [description]
* @param [type] $config [description] * @param [type] $config [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
private function build($gateway) private function build($gateway)

View File

@ -27,10 +27,14 @@ class Config implements ArrayAccess
/** /**
* get a config * get a config
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-28 * @version 2017-07-28
*
* @param [type] $key [description] * @param [type] $key [description]
* @param [type] $default [description] * @param [type] $default [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function get($key = null, $default = null) public function get($key = null, $default = null)
@ -57,9 +61,13 @@ class Config implements ArrayAccess
/** /**
* set a config * set a config
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-29 * @version 2017-07-29
*
* @param string $key [description] * @param string $key [description]
*
* @param [type] $value [description] * @param [type] $value [description]
*/ */
public function set(string $key, $value) public function set(string $key, $value)
@ -91,9 +99,13 @@ class Config implements ArrayAccess
/** /**
* [offsetExists description] * [offsetExists description]
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-30 * @version 2017-07-30
*
* @param [type] $offset [description] * @param [type] $offset [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function offsetExists($offset) public function offsetExists($offset)
@ -103,9 +115,13 @@ class Config implements ArrayAccess
/** /**
* [offsetGet description] * [offsetGet description]
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-30 * @version 2017-07-30
*
* @param [type] $offset [description] * @param [type] $offset [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function offsetGet($offset) public function offsetGet($offset)
@ -115,10 +131,14 @@ class Config implements ArrayAccess
/** /**
* [offsetSet description] * [offsetSet description]
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-30 * @version 2017-07-30
*
* @param [type] $offset [description] * @param [type] $offset [description]
* @param [type] $value [description] * @param [type] $value [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
@ -128,9 +148,13 @@ class Config implements ArrayAccess
/** /**
* [offsetUnset description] * [offsetUnset description]
*
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
*
* @version 2017-07-30 * @version 2017-07-30
*
* @param [type] $offset [description] * @param [type] $offset [description]
*
* @return [type] [description] * @return [type] [description]
*/ */
public function offsetUnset($offset) public function offsetUnset($offset)