This commit is contained in:
yansongda 2017-07-28 22:28:54 +08:00
parent f8b7a377fb
commit e04f73b727
11 changed files with 0 additions and 374 deletions

20
LICENSE
View File

@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2017 闫嵩达
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,19 +0,0 @@
{
"name": "yansongda/pay",
"description": "专注 Alipay 和 WeChat 的支付扩展包",
"authors": [
{
"name": "yansongda",
"email": "me@yansongda.cn"
}
],
"require": {
"php": ">=5.5.9"
},
"autoload": {
"psr-4": {
"Yansongda\\pay\\": "src"
}
},
"license": "MIT"
}

View File

@ -1,24 +0,0 @@
<?php
namespace Yansongda\Pay\Contracts;
/**
* Interface GatewayInterface
*/
interface GatewayInterface
{
/**
* 支付
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
public function pay()
/**
* 验证
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
public function verify()
}

View File

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

View File

@ -1,21 +0,0 @@
<?php
namespace Yansongda\Pay\Exceptions;
/**
* GatewayException
*/
class GatewayException extends Exception
{
/**
* [__construct description]
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @param [type] $message [description]
* @param [type] $code [description]
*/
public function __construct($message, $code)
{
parent::__construct($message, intval($code));
}
}

View File

@ -1,43 +0,0 @@
<?php
namespace Yansongda\Pay\Gateways\Alipay;
/**
* 支付宝签名算法
*/
class Sign
{
public function getSignedString($string)
{
if($this->checkEmpty($this->rsaPrivateKeyFilePath)){
$priKey=$this->rsaPrivateKey;
$res = "-----BEGIN RSA PRIVATE KEY-----\n" .
wordwrap($priKey, 64, "\n", true) .
"\n-----END RSA PRIVATE KEY-----";
}else {
$priKey = file_get_contents($this->rsaPrivateKeyFilePath);
$res = openssl_get_privatekey($priKey);
}
($res) or die('您使用的私钥格式错误请检查RSA私钥配置');
if ("RSA2" == $signType) {
openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256);
} else {
openssl_sign($data, $sign, $res);
}
if(!$this->checkEmpty($this->rsaPrivateKeyFilePath)){
openssl_free_key($res);
}
$sign = base64_encode($sign);
return $sign;
}
private function sortString()
{
# code...
}
}

View File

@ -1,65 +0,0 @@
<?php
namespace Yansongda\Pay\Gateways;
/**
*
*/
class AlipayGateway extends Gateway
{
const METHOD = 'alipay.trade.page.pay';
const FORMAT = 'JSON';
const CHARSET = 'utf-8';
const SIGN_TYPE = 'RSA2';
const TIMESTAMP = date('Y-m-d H:i:s');
const VERSION = '1.0';
/**
* 支付
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
public function pay()
{
}
/**
* 查看是否支付宝官方发出
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
public function verify()
{
# code...
}
/**
* 获取业务参数
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
private function getBizContent()
{
# code...
}
/**
* 签名
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
private function sign()
{
# code...
}
}

View File

@ -1,51 +0,0 @@
<?php
namespace Yansongda\Pay\Gateways;
use Yansongda\Pay\Support\Config;
use Yansongda\Pay\Contracts\GatewayInterface;
/**
*
*/
abstract class Gateway implements GatewayInterface
{
/**
* [$config description]
* @var [type]
*/
protected $config;
/**
* [__construct description]
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @param array $config [description]
*/
public function __construct(array $config)
{
$this->config = new Config($config);
}
/**
* 获取配置
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
public function getConfig()
{
return $this->config;
}
/**
* 设置配置
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @param Config $config [description]
*/
public function setConfig(Config $config)
{
$this->config = $config;
return $this;
}
}

View File

@ -1,55 +0,0 @@
<?php
namespace Yansongda\Pay\Gateways;
/**
*
*/
class WechatGateway extends Gateway
{
/**
* 支付
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
public function pay()
{
}
/**
* 查看是否支付宝官方发出
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
public function verify()
{
# code...
}
/**
* 获取业务参数
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
private function getBizContent()
{
# code...
}
/**
* 签名
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @return [type] [description]
*/
private function sign()
{
# code...
}
}

View File

@ -1,53 +0,0 @@
<?php
namespace Yansongda\Pay\Support;
use ArrayAccess;
/**
* Class Config.
*/
class Config implements ArrayAccess
{
/**
* @var array
*/
protected $config;
/**
* Config constructor.
*
* @param array $config
*/
public function __construct(array $config = [])
{
$this->config = $config;
}
/**
* get a config
* @author JasonYan <me@yansongda.cn>
* @version 2017-07-28
* @param [type] $key [description]
* @param [type] $default [description]
* @return [type] [description]
*/
public function get($key, $default = null)
{
if (is_null($key)) {
return $this->config;
}
if (isset($this->config[$key])) {
return $this->config[$key];
}
foreach (explode('.', $key) as $segment) {
if (! array_key_exists($segment, $this->config)) {
return $default;
}
return $this->config[$segment];
}
}
}

View File

@ -1,12 +0,0 @@
<?php
namespace Yansongda\Pay;
/**
*
*/
class Pay
{
}