优化代码

This commit is contained in:
yansongda 2017-08-31 16:03:20 +08:00
parent d41c6d1fd6
commit c4aa1ca78c
20 changed files with 222 additions and 413 deletions

View File

@ -5,69 +5,59 @@ namespace Yansongda\Pay\Contracts;
interface GatewayInterface interface GatewayInterface
{ {
/** /**
* 支付. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $config_biz
* *
* @param array $config_biz [description] * @return mixed
*
* @return mixed [description]
*/ */
public function pay(array $config_biz); public function pay(array $config_biz);
/** /**
* 退款. * refund a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array|string $config_biz
* *
* @param array|string $config_biz [description] * @return array|boolean
*
* @return array|boolean [description]
*/ */
public function refund($config_biz); public function refund($config_biz);
/** /**
* 关闭. * close a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array|string $config_biz
* *
* @param array|string $config_biz [description] * @return array|boolean
*
* @return array|boolean [description]
*/ */
public function close($config_biz); public function close($config_biz);
/** /**
* 对外接口 - 订单查询. * find a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-19 * @param string $out_trade_no
* *
* @param string $out_trade_no 商家订单号 * @return array|boolean
*
* @return array|boolean [description]
*/ */
public function find($out_trade_no); public function find($out_trade_no);
/** /**
* 验证消息是否官方发出. * verify notify.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param mixed $data
* @param string $sign
* @param bool $sync
* *
* @param mixed $data 待签名数组 * @return array|boolean
* @param string $sign 签名字符串-支付宝服务器发送过来的原始串
* @param bool $sync 是否同步验证
*
* @return array|boolean [description]
*/ */
public function verify($data, $sign = null, $sync = false); public function verify($data, $sign = null, $sync = false);
} }

View File

@ -2,9 +2,6 @@
namespace Yansongda\Pay\Exceptions; namespace Yansongda\Pay\Exceptions;
/**
* Exception.
*/
class Exception extends \Exception class Exception extends \Exception
{ {
} }

View File

@ -2,9 +2,6 @@
namespace Yansongda\Pay\Exceptions; namespace Yansongda\Pay\Exceptions;
/**
* GatewayException.
*/
class GatewayException extends Exception class GatewayException extends Exception
{ {
/** /**
@ -19,10 +16,8 @@ class GatewayException extends Exception
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-28 * @param string $message
* * @param string|int $code
* @param string $message [description]
* @param string|int $code [description]
*/ */
public function __construct($message, $code, $raw = []) public function __construct($message, $code, $raw = [])
{ {

View File

@ -2,9 +2,6 @@
namespace Yansongda\Pay\Exceptions; namespace Yansongda\Pay\Exceptions;
/**
* InvalidArgumentException.
*/
class InvalidArgumentException extends \InvalidArgumentException class InvalidArgumentException extends \InvalidArgumentException
{ {
} }

View File

@ -13,21 +13,19 @@ abstract class Alipay implements GatewayInterface
use HasHttpRequest; use HasHttpRequest;
/** /**
* 支付宝支付网关.
*
* @var string * @var string
*/ */
protected $gateway = 'https://openapi.alipay.com/gateway.do'; protected $gateway = 'https://openapi.alipay.com/gateway.do';
/** /**
* 支付宝公共参数. * alipay global config params.
* *
* @var array * @var array
*/ */
protected $config; protected $config;
/** /**
* 用户的传参. * user's config params.
* *
* @var \Yansongda\Pay\Support\Config * @var \Yansongda\Pay\Support\Config
*/ */
@ -38,8 +36,6 @@ abstract class Alipay implements GatewayInterface
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-14
*
* @param array $config [description] * @param array $config [description]
*/ */
public function __construct(array $config) public function __construct(array $config)
@ -67,15 +63,13 @@ abstract class Alipay implements GatewayInterface
/** /**
* 对外接口 - 支付. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $config_biz
* *
* @param array $config_biz [description] * @return mixed
*
* @return mixed [description]
*/ */
public function pay(array $config_biz) public function pay(array $config_biz)
{ {
@ -87,15 +81,13 @@ abstract class Alipay implements GatewayInterface
} }
/** /**
* 对外接口 - 退款. * refund a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param mixed $config_biz
* *
* @param mixed $config_biz [description] * @return array|boolean
*
* @return array|boolean [description]
*/ */
public function refund($config_biz, $refund_amount = null) public function refund($config_biz, $refund_amount = null)
{ {
@ -110,15 +102,13 @@ abstract class Alipay implements GatewayInterface
} }
/** /**
* 对外接口 - 关闭. * close a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array|string $config_biz
* *
* @param array|string $config_biz [description] * @return array|boolean
*
* @return array|boolean [description]
*/ */
public function close($config_biz) public function close($config_biz)
{ {
@ -132,14 +122,13 @@ abstract class Alipay implements GatewayInterface
} }
/** /**
* 对外接口 - 订单查询 * find a order.
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-19 * @param string $out_trade_no
* *
* @param string $out_trade_no 商家订单号 * @return array|boolean
*
* @return array|boolean [description]
*/ */
public function find($out_trade_no = '') public function find($out_trade_no = '')
{ {
@ -151,17 +140,15 @@ abstract class Alipay implements GatewayInterface
} }
/** /**
* 对外接口 - 验证. * verify the notify.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-11 * @param array $data
* @param string $sign
* @param bool $sync
* *
* @param array $data 待签名数组 * @return array|boolean
* @param string $sign 签名字符串-支付宝服务器发送过来的原始串
* @param bool $sync 是否同步返回验证
*
* @return array|boolean [description]
*/ */
public function verify($data, $sign = null, $sync = false) public function verify($data, $sign = null, $sync = false)
{ {
@ -181,35 +168,29 @@ abstract class Alipay implements GatewayInterface
} }
/** /**
* [getMethod description]. * get method config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
abstract protected function getMethod(); abstract protected function getMethod();
/** /**
* [getProductCode description]. * get productCode config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
abstract protected function getProductCode(); abstract protected function getProductCode();
/** /**
* [buildHtmlPay description] * build pay html.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-11 * @return string
*
* @return string [description]
*/ */
protected function buildPayHtml() protected function buildPayHtml()
{ {
@ -229,12 +210,10 @@ abstract class Alipay implements GatewayInterface
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-12 * @param array $config_biz
* @param string $method
* *
* @param array $config_biz [description] * @return array|boolean
* @param string $method [description]
*
* @return array|boolean [description]
*/ */
protected function getResult($config_biz, $method) protected function getResult($config_biz, $method)
{ {
@ -257,13 +236,11 @@ abstract class Alipay implements GatewayInterface
} }
/** /**
* 签名. * get sign.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getSign() protected function getSign()
{ {
@ -281,16 +258,14 @@ abstract class Alipay implements GatewayInterface
} }
/** /**
* 待签名数组. * get signContent that is to be signed.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-11 * @param array $toBeSigned
* @param boolean $verify
* *
* @param array $toBeSigned [description] * @return string
* @param boolean $verify 是否验证签名
*
* @return string [description]
*/ */
protected function getSignContent(array $toBeSigned, $verify = false) protected function getSignContent(array $toBeSigned, $verify = false)
{ {
@ -310,5 +285,4 @@ abstract class Alipay implements GatewayInterface
return $stringToBeSigned; return $stringToBeSigned;
} }
} }

View File

@ -2,19 +2,14 @@
namespace Yansongda\Pay\Gateways\Alipay; namespace Yansongda\Pay\Gateways\Alipay;
/**
* AppGateway.
*/
class AppGateway extends Alipay class AppGateway extends Alipay
{ {
/** /**
* [getMethod description]. * get method config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getMethod() protected function getMethod()
{ {
@ -22,13 +17,11 @@ class AppGateway extends Alipay
} }
/** /**
* [getProductCode description]. * get productCode method.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getProductCode() protected function getProductCode()
{ {
@ -36,15 +29,13 @@ class AppGateway extends Alipay
} }
/** /**
* [pay description]. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-16 * @param array $config_biz
* *
* @param array $config_biz 业务参数 * @return string
*
* @return string [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -5,13 +5,11 @@ namespace Yansongda\Pay\Gateways\Alipay;
class PosGateway extends Alipay class PosGateway extends Alipay
{ {
/** /**
* [getMethod description]. * get method config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getMethod() protected function getMethod()
{ {
@ -19,13 +17,11 @@ class PosGateway extends Alipay
} }
/** /**
* [getProductCode description]. * get productCode config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getProductCode() protected function getProductCode()
{ {
@ -33,16 +29,14 @@ class PosGateway extends Alipay
} }
/** /**
* 刷卡支付. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-23 * @param array $config_biz
* @param string $scene
* *
* @param array $config_biz 订单信息 * @return array|boolean
* @param string $scene 支付场景,默认二维码
*
* @return array|boolean [description]
*/ */
public function pay(array $config_biz = [], $scene = 'bar_code') public function pay(array $config_biz = [], $scene = 'bar_code')
{ {

View File

@ -5,13 +5,11 @@ namespace Yansongda\Pay\Gateways\Alipay;
class ScanGateway extends Alipay class ScanGateway extends Alipay
{ {
/** /**
* [getMethod description]. * get method config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getMethod() protected function getMethod()
{ {
@ -19,13 +17,11 @@ class ScanGateway extends Alipay
} }
/** /**
* [getProductCode description]. * get productCode config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getProductCode() protected function getProductCode()
{ {
@ -33,15 +29,13 @@ class ScanGateway extends Alipay
} }
/** /**
* 扫码支付. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-23 * @param array $config_biz
* *
* @param array $config_biz 订单信息 * @return array|boolean
*
* @return array|boolean [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -2,13 +2,10 @@
namespace Yansongda\Pay\Gateways\Alipay; namespace Yansongda\Pay\Gateways\Alipay;
/**
* WapGateway.
*/
class WapGateway extends Alipay class WapGateway extends Alipay
{ {
/** /**
* [getMethod description]. * get method config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
@ -22,13 +19,11 @@ class WapGateway extends Alipay
} }
/** /**
* [getProductCode description]. * get productCode config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getProductCode() protected function getProductCode()
{ {
@ -36,15 +31,13 @@ class WapGateway extends Alipay
} }
/** /**
* 对外支付. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-23 * @param array $config_biz
* *
* @param array $config_biz [description] * @return string
*
* @return string [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -2,19 +2,14 @@
namespace Yansongda\Pay\Gateways\Alipay; namespace Yansongda\Pay\Gateways\Alipay;
/**
* class WebGateway.
*/
class WebGateway extends Alipay class WebGateway extends Alipay
{ {
/** /**
* [getMethod description]. * get method config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getMethod() protected function getMethod()
{ {
@ -22,13 +17,11 @@ class WebGateway extends Alipay
} }
/** /**
* [getProductCode description]. * get productCode config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @return string
*
* @return string [description]
*/ */
protected function getProductCode() protected function getProductCode()
{ {
@ -36,15 +29,13 @@ class WebGateway extends Alipay
} }
/** /**
* 对外支付. * pay a order
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-23 * @param array $config_biz
* *
* @param array $config_biz [description] * @return string
*
* @return string [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -7,13 +7,11 @@ use Yansongda\Pay\Exceptions\InvalidArgumentException;
class AppGateway extends Wechat class AppGateway extends Wechat
{ {
/** /**
* 交易类型. * get trade type config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @return string
*
* @return string [description]
*/ */
protected function getTradeType() protected function getTradeType()
{ {
@ -21,15 +19,13 @@ class AppGateway extends Wechat
} }
/** /**
* 对外支付. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $config_biz
* *
* @param array $config_biz [description] * @return array
*
* @return array [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -7,12 +7,10 @@ use Yansongda\Pay\Exceptions\InvalidArgumentException;
class MiniappGateway extends Wechat class MiniappGateway extends Wechat
{ {
/** /**
* [getTradeType description]. * get trade type config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15
*
* @return string [description] * @return string [description]
*/ */
protected function getTradeType() protected function getTradeType()
@ -21,15 +19,13 @@ class MiniappGateway extends Wechat
} }
/** /**
* 对外支付. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $config_biz
* *
* @param array $config_biz [description] * @return array
*
* @return array [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -7,13 +7,11 @@ use Yansongda\Pay\Exceptions\InvalidArgumentException;
class MpGateway extends Wechat class MpGateway extends Wechat
{ {
/** /**
* 交易类型. * get trade type config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @return string
*
* @return string [description]
*/ */
protected function getTradeType() protected function getTradeType()
{ {
@ -21,15 +19,13 @@ class MpGateway extends Wechat
} }
/** /**
* 对外支付. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $config_biz
* *
* @param array $config_biz [description] * @return array
*
* @return array [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -7,20 +7,16 @@ use Yansongda\Pay\Exceptions\InvalidArgumentException;
class PosGateway extends Wechat class PosGateway extends Wechat
{ {
/** /**
* 刷卡支付 API.
*
* @var string * @var string
*/ */
protected $gateway = 'https://api.mch.weixin.qq.com/pay/micropay'; protected $gateway = 'https://api.mch.weixin.qq.com/pay/micropay';
/** /**
* [getTradeType description]. * get trade type config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @return string
*
* @return string [description]
*/ */
protected function getTradeType() protected function getTradeType()
{ {
@ -28,15 +24,13 @@ class PosGateway extends Wechat
} }
/** /**
* [pay description]. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-18 * @param array $config_biz
* *
* @param array $config_biz [description] * @return array
*
* @return array [description]
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -7,13 +7,11 @@ use Yansongda\Pay\Exceptions\InvalidArgumentException;
class ScanGateway extends Wechat class ScanGateway extends Wechat
{ {
/** /**
* [getTradeType description]. * get trade type config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @return string
*
* @return string [description]
*/ */
protected function getTradeType() protected function getTradeType()
{ {
@ -21,15 +19,13 @@ class ScanGateway extends Wechat
} }
/** /**
* 对外支付,采用 「模式二」 进行支付. * pay a order using modelTWO.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $config_biz
* *
* @param array $config_biz [description] * @return string
*
* @return string 微信支付扫码 URL
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -7,13 +7,11 @@ use Yansongda\Pay\Exceptions\InvalidArgumentException;
class WapGateway extends Wechat class WapGateway extends Wechat
{ {
/** /**
* [getTradeType description]. * get trade type config.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @return string
*
* @return string [description]
*/ */
protected function getTradeType() protected function getTradeType()
{ {
@ -21,15 +19,13 @@ class WapGateway extends Wechat
} }
/** /**
* 支付. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $config_biz
* *
* @param array $config_biz [description] * @return string
*
* @return string 支付中间页 url
*/ */
public function pay(array $config_biz = []) public function pay(array $config_biz = [])
{ {

View File

@ -13,43 +13,31 @@ abstract class Wechat implements GatewayInterface
use HasHttpRequest; use HasHttpRequest;
/** /**
* 支付订单.
*
* @var string * @var string
*/ */
protected $gateway = 'https://api.mch.weixin.qq.com/pay/unifiedorder'; protected $gateway = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
/** /**
* 查询订单.
*
* @var string * @var string
*/ */
protected $gateway_query = 'https://api.mch.weixin.qq.com/pay/orderquery'; protected $gateway_query = 'https://api.mch.weixin.qq.com/pay/orderquery';
/** /**
* 关闭订单.
*
* @var string * @var string
*/ */
protected $gateway_close = 'https://api.mch.weixin.qq.com/pay/closeorder'; protected $gateway_close = 'https://api.mch.weixin.qq.com/pay/closeorder';
/** /**
* 退款.
*
* @var string * @var string
*/ */
protected $gateway_refund = 'https://api.mch.weixin.qq.com/secapi/pay/refund'; protected $gateway_refund = 'https://api.mch.weixin.qq.com/secapi/pay/refund';
/** /**
* 配置项.
*
* @var array * @var array
*/ */
protected $config; protected $config;
/** /**
* 用户传参配置项.
*
* @var \Yansongda\Pay\Support\Config * @var \Yansongda\Pay\Support\Config
*/ */
protected $user_config; protected $user_config;
@ -59,9 +47,7 @@ abstract class Wechat implements GatewayInterface
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-14 * @param array $config
*
* @param array $config [description]
*/ */
public function __construct(array $config) public function __construct(array $config)
{ {
@ -78,26 +64,22 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 对外支付接口. * pay a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $config_biz
* *
* @param array $config_biz [description] * @return mixed
*
* @return mixed [description]
*/ */
abstract public function pay(array $config_biz = []); abstract public function pay(array $config_biz = []);
/** /**
* 对外接口 - 退款. * refund.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @return string|boolean
*
* @return string|boolean [description]
*/ */
public function refund($config_biz = []) public function refund($config_biz = [])
{ {
@ -112,13 +94,11 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 对外接口 - 关闭订单. * close a order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @return array|boolean
*
* @return array|boolean [description]
*/ */
public function close($out_trade_no = '') public function close($out_trade_no = '')
{ {
@ -130,14 +110,13 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 对外接口 - 订单查询 * find a order.
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-19 * @param string $out_trade_no
* *
* @param string $out_trade_no 商家订单号 * @return array|boolean
*
* @return array|boolean [description]
*/ */
public function find($out_trade_no = '') public function find($out_trade_no = '')
{ {
@ -149,17 +128,15 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 验证签名. * verify the notify.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param string $data
* @param string $sign
* @param bool $sync
* *
* @param string $data 待验证 xml 数据 * @return array|boolean
* @param string $sign 服务器返回的签名
* @param bool $sync is sync sign
*
* @return array|boolean 是否相符
*/ */
public function verify($data, $sign = null, $sync = false) public function verify($data, $sign = null, $sync = false)
{ {
@ -171,25 +148,22 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 获取交易类型. * get trade type config.
*
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-17 * @return string
*
* @return string [description]
*/ */
abstract protected function getTradeType(); abstract protected function getTradeType();
/** /**
* 预下单. * pre order.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $config_biz
* *
* @param array $config_biz 业务参数 * @return array
*
* @return array 服务器返回结果数组
*/ */
protected function preOrder($config_biz = []) protected function preOrder($config_biz = [])
{ {
@ -200,16 +174,14 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 获取 API 结果. * get api result.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-19 * @param string $end_point
* * @param bool $cert
* @param string $end_point [description] *
* @param bool $cert 是否使用证书 * @return array
*
* @return array [description]
*/ */
protected function getResult($end_point, $cert = false) protected function getResult($end_point, $cert = false)
{ {
@ -248,15 +220,13 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 签名. * sign.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
*
* @version 2017-08-15
* *
* @param array $data 带签名数组 * @param array $data
* *
* @return string [description] * @return string
*/ */
protected function getSign($data) protected function getSign($data)
{ {
@ -272,15 +242,13 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 将数组转换成 URL 格式. * get sign content.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-15 * @param array $data
* *
* @param array $data [description] * @return string
*
* @return string [description]
*/ */
protected function getSignContent($data) protected function getSignContent($data)
{ {
@ -295,15 +263,13 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 生成随机字符串. * create random string.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-14 * @param integer $length
* *
* @param integer $length [description] * @return string
*
* @return string [description]
*/ */
protected function createNonceStr($length = 16) { protected function createNonceStr($length = 16) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@ -317,15 +283,13 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 转化为 xml. * convert to xml.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-14 * @param array $data
* *
* @param array $data 带转化数组 * @return string
*
* @return string 转化后的xml字符串
*/ */
protected function toXml($data) protected function toXml($data)
{ {
@ -344,15 +308,13 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* xml 转化为 array. * convert to array.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-14 * @param string $xml
* *
* @param string $xml xml字符串 * @return array
*
* @return array 转化后的数组
*/ */
protected function fromXml($xml) protected function fromXml($xml)
{ {
@ -366,13 +328,11 @@ abstract class Wechat implements GatewayInterface
} }
/** /**
* 删除 trade_type and notify_url. * delete trade_type and notify_url.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-19 * @return boolean
*
* @return boolean [description]
*/ */
protected function unsetTradeTypeAndNotifyUrl() protected function unsetTradeTypeAndNotifyUrl()
{ {

View File

@ -5,40 +5,29 @@ namespace Yansongda\Pay;
use Yansongda\Pay\Support\Config; use Yansongda\Pay\Support\Config;
use Yansongda\Pay\Exceptions\InvalidArgumentException; use Yansongda\Pay\Exceptions\InvalidArgumentException;
/**
* class Pay
*/
class Pay class Pay
{ {
/** /**
* [$config description]
*
* @var \Yansongda\Pay\Support\Config * @var \Yansongda\Pay\Support\Config
*/ */
private $config; private $config;
/** /**
* [$dirvers description]
*
* @var string * @var string
*/ */
private $drivers; private $drivers;
/** /**
* [$gateways description]
*
* @var \Yansongda\Pay\Contracts\GatewayInterface * @var \Yansongda\Pay\Contracts\GatewayInterface
*/ */
private $gateways; private $gateways;
/** /**
* [__construct description] * construct method.
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-29 * @param array $config
*
* @param array $config [description]
*/ */
public function __construct(array $config = []) public function __construct(array $config = [])
{ {
@ -46,15 +35,13 @@ class Pay
} }
/** /**
* [driver description] * set pay's driver.
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-30 * @param string $driver
* *
* @param string $driver [description] * @return Pay
*
* @return Pay [description]
*/ */
public function driver($driver) public function driver($driver)
{ {
@ -68,15 +55,13 @@ class Pay
} }
/** /**
* [gateway description] * set pay's gateway.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @param string $gateway
* *
* @param string $gateway [description] * @return \Yansongda\Pay\Contracts\GatewayInterface
*
* @return object [description]
*/ */
public function gateway($gateway = 'web') public function gateway($gateway = 'web')
{ {
@ -90,15 +75,13 @@ class Pay
} }
/** /**
* [createGateway description] * create pay's gateway.
* *
* @author yansongda <me@yansongda.cn> * @author yansongda <me@yansongda.cn>
* *
* @version 2017-08-10 * @param string $gateway
* *
* @param string $gateway [description] * @return \Yansongda\Pay\Contracts\GatewayInterface
*
* @return object [description]
*/ */
protected function createGateway($gateway) protected function createGateway($gateway)
{ {
@ -112,15 +95,13 @@ class Pay
} }
/** /**
* [buildDriver description] * build pay's gateway.
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-30 * @param string $gateway
* *
* @param string $gateway [description] * @return \Yansongda\Pay\Contracts\GatewayInterface
*
* @return object [description]
*/ */
protected function build($gateway) protected function build($gateway)
{ {

View File

@ -5,9 +5,6 @@ namespace Yansongda\Pay\Support;
use ArrayAccess; use ArrayAccess;
use Yansongda\Pay\Exceptions\InvalidArgumentException; use Yansongda\Pay\Exceptions\InvalidArgumentException;
/**
* Class Config.
*/
class Config implements ArrayAccess class Config implements ArrayAccess
{ {
/** /**
@ -30,12 +27,10 @@ class Config implements ArrayAccess
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-28 * @param string $key
* @param string $default
* *
* @param string $key [description] * @return mixed
* @param string $default [description]
*
* @return mixed [description]
*/ */
public function get($key = null, $default = null) public function get($key = null, $default = null)
{ {
@ -64,11 +59,8 @@ class Config implements ArrayAccess
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-29 * @param string $key
* * @param array $value
* @param string $key [description]
*
* @param array $value [description]
*/ */
public function set(string $key, $value) public function set(string $key, $value)
{ {
@ -102,11 +94,9 @@ class Config implements ArrayAccess
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-30 * @param string $offset
* *
* @param string $offset [description] * @return boolean
*
* @return boolean [description]
*/ */
public function offsetExists($offset) public function offsetExists($offset)
{ {
@ -118,11 +108,9 @@ class Config implements ArrayAccess
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-30 * @param string $offset
* *
* @param string $offset [description] * @return mixed
*
* @return mixed [description]
*/ */
public function offsetGet($offset) public function offsetGet($offset)
{ {
@ -134,12 +122,10 @@ class Config implements ArrayAccess
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-30 * @param string $offset
* @param string $value
* *
* @param string $offset [description] * @return array
* @param string $value [description]
*
* @return array [description]
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
@ -151,15 +137,12 @@ class Config implements ArrayAccess
* *
* @author JasonYan <me@yansongda.cn> * @author JasonYan <me@yansongda.cn>
* *
* @version 2017-07-30 * @param string $offset
* *
* @param string $offset [description] * @return array
*
* @return array [description]
*/ */
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
$this->set($offset, null); $this->set($offset, null);
} }
} }

View File

@ -14,9 +14,6 @@ namespace Yansongda\Pay\Traits;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
/**
* trait HttpClient.
*/
trait HasHttpRequest trait HasHttpRequest
{ {
/** /**
@ -93,8 +90,6 @@ trait HasHttpRequest
* @param array $options * @param array $options
* *
* @return \GuzzleHttp\Client * @return \GuzzleHttp\Client
*
* @codeCoverageIgnore
*/ */
protected function getHttpClient(array $options = []) protected function getHttpClient(array $options = [])
{ {