This commit is contained in:
yansongda 2021-06-16 16:57:36 +08:00
parent d808fc96f5
commit 8b5b93dd8f
48 changed files with 543 additions and 160 deletions

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\App;
class ClosePlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\ClosePlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\App;
class DownloadBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\DownloadBillPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\App;
class FindRefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\FindRefundPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\App;
class GetFlowBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetFlowBillPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\App;
class GetTradeBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetTradeBillPlugin
{
}

View File

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\App;
use Yansongda\Pay\Rocket;
class PrepayPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\PrepayPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/pay/transactions/app';
}
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\App;
class QueryPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\QueryPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\App;
class RefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\RefundPlugin
{
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Common;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use Yansongda\Supports\Collection;
class ClosePlugin extends GeneralPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/pay/transactions/out-trade-no/'.
($rocket->getParams()['out_trade_no'] ?? '').
'/close';
}
/**
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
* @throws \Yansongda\Pay\Exception\ContainerException
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
*/
protected function checkPayload(Rocket $rocket): void
{
$config = get_wechat_config($rocket->getParams());
$rocket->setPayload(new Collection([
'mchid' => $config->get('mch_id', ''),
]));
}
}

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Common;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class DownloadBillPlugin extends GeneralPlugin
{
protected function getUri(Rocket $rocket): string
{
return $rocket->getParams()['download_url'] ?? '';
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Common;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class FindRefundPlugin extends GeneralPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/refund/domestic/refunds/'.($rocket->getParams()['out_refund_no'] ?? '');
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Common;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class GetFlowBillPlugin extends GeneralPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/bill/fundflowbill?'.http_build_query($rocket->getParams());
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Common;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class GetTradeBillPlugin extends GeneralPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/bill/tradebill?'.http_build_query($rocket->getParams());
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Common;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class PrepayPlugin extends GeneralPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/pay/transactions/jsapi';
}
/**
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
* @throws \Yansongda\Pay\Exception\ContainerException
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
*/
protected function checkPayload(Rocket $rocket): void
{
$config = get_wechat_config($rocket->getParams());
$payload = [
'appid' => $config->get('mp_app_id', ''),
'mchid' => $config->get('mch_id', ''),
];
if (!$rocket->getPayload()->has('notify_url')) {
$payload['notify_url'] = $config->get('notify_url');
}
$rocket->mergePayload($payload);
}
}

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Common;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class QueryPlugin extends GeneralPlugin
{
/**
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
* @throws \Yansongda\Pay\Exception\ContainerException
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
*/
protected function getUri(Rocket $rocket): string
{
$config = get_wechat_config($rocket->getParams());
return 'v3/pay/transactions/id/'.
($rocket->getParams()['transaction_id'] ?? '').
'?mchid='.$config->get('mch_id', '');
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Common;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class RefundPlugin extends GeneralPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/refund/domestic/refunds';
}
protected function checkPayload(Rocket $rocket): void
{
}
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\H5;
class ClosePlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\ClosePlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\H5;
class DownloadBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\DownloadBillPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\H5;
class FindRefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\FindRefundPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\H5;
class GetFlowBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetFlowBillPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\H5;
class GetTradeBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetTradeBillPlugin
{
}

View File

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\H5;
use Yansongda\Pay\Rocket;
class PrepayPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\PrepayPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/pay/transactions/h5';
}
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\H5;
class QueryPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\QueryPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\H5;
class RefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\RefundPlugin
{
}

View File

@ -4,30 +4,6 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Jsapi;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use Yansongda\Supports\Collection;
class ClosePlugin extends GeneralPlugin
class ClosePlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\ClosePlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/pay/transactions/out-trade-no/'.
($rocket->getParams()['out_trade_no'] ?? '').
'/close';
}
/**
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
* @throws \Yansongda\Pay\Exception\ContainerException
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
*/
protected function checkPayload(Rocket $rocket): void
{
$config = get_wechat_config($rocket->getParams());
$rocket->setPayload(new Collection([
'mchid' => $config->get('mch_id', ''),
]));
}
}

View File

@ -4,23 +4,6 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Jsapi;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class DownloadBillPlugin extends GeneralPlugin
class DownloadBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\DownloadBillPlugin
{
protected function getUri(Rocket $rocket): string
{
return $rocket->getParams()['download_url'] ?? '';
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -4,23 +4,6 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Jsapi;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class FindRefundPlugin extends GeneralPlugin
class FindRefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\FindRefundPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/refund/domestic/refunds/'.($rocket->getParams()['out_refund_no'] ?? '');
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -4,23 +4,6 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Jsapi;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class GetFlowBillPlugin extends GeneralPlugin
class GetFlowBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetFlowBillPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/bill/fundflowbill?'.http_build_query($rocket->getParams());
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -4,23 +4,6 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Jsapi;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class GetTradeBillPlugin extends GeneralPlugin
class GetTradeBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetTradeBillPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/bill/tradebill?'.http_build_query($rocket->getParams());
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -4,29 +4,6 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Jsapi;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class PrepayPlugin extends GeneralPlugin
class PrepayPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\PrepayPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/pay/transactions/jsapi';
}
/**
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
* @throws \Yansongda\Pay\Exception\ContainerException
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
*/
protected function checkPayload(Rocket $rocket): void
{
$config = get_wechat_config($rocket->getParams());
$rocket->mergePayload([
'appid' => $config->get('mp_app_id', ''),
'mchid' => $config->get('mch_id', ''),
'notify_url' => $config->get('notify_url'),
]);
}
}

View File

@ -4,32 +4,6 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Jsapi;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class QueryPlugin extends GeneralPlugin
class QueryPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\QueryPlugin
{
/**
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
* @throws \Yansongda\Pay\Exception\ContainerException
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
*/
protected function getUri(Rocket $rocket): string
{
$config = get_wechat_config($rocket->getParams());
return 'v3/pay/transactions/id/'.
($rocket->getParams()['transaction_id'] ?? '').
'?mchid='.$config->get('mch_id', '');
}
protected function getMethod(): string
{
return 'GET';
}
protected function checkPayload(Rocket $rocket): void
{
$rocket->setPayload(null);
}
}

View File

@ -4,17 +4,6 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Jsapi;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class RefundPlugin extends GeneralPlugin
class RefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\RefundPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/refund/domestic/refunds';
}
protected function checkPayload(Rocket $rocket): void
{
}
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Mini;
class ClosePlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\ClosePlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Mini;
class DownloadBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\DownloadBillPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Mini;
class FindRefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\FindRefundPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Mini;
class GetFlowBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetFlowBillPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Mini;
class GetTradeBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetTradeBillPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Mini;
class PrepayPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\PrepayPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Mini;
class QueryPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\QueryPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Mini;
class RefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\RefundPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Native;
class ClosePlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\ClosePlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Native;
class DownloadBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\DownloadBillPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Native;
class FindRefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\FindRefundPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Native;
class GetFlowBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetFlowBillPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Native;
class GetTradeBillPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\GetTradeBillPlugin
{
}

View File

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Native;
use Yansongda\Pay\Rocket;
class PrepayPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\PrepayPlugin
{
protected function getUri(Rocket $rocket): string
{
return 'v3/pay/transactions/native';
}
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Native;
class QueryPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\QueryPlugin
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Pay\Native;
class RefundPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\RefundPlugin
{
}