From 8b5b93dd8fe947ae501dcbefd3bb759b94d83497 Mon Sep 17 00:00:00 2001 From: yansongda Date: Wed, 16 Jun 2021 16:57:36 +0800 Subject: [PATCH] update --- src/Plugin/Wechat/Pay/App/ClosePlugin.php | 9 +++++ .../Wechat/Pay/App/DownloadBillPlugin.php | 9 +++++ .../Wechat/Pay/App/FindRefundPlugin.php | 9 +++++ .../Wechat/Pay/App/GetFlowBillPlugin.php | 9 +++++ .../Wechat/Pay/App/GetTradeBillPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/App/PrepayPlugin.php | 15 ++++++++ src/Plugin/Wechat/Pay/App/QueryPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/App/RefundPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/Common/ClosePlugin.php | 33 +++++++++++++++++ .../Wechat/Pay/Common/DownloadBillPlugin.php | 26 +++++++++++++ .../Wechat/Pay/Common/FindRefundPlugin.php | 26 +++++++++++++ .../Wechat/Pay/Common/GetFlowBillPlugin.php | 26 +++++++++++++ .../Wechat/Pay/Common/GetTradeBillPlugin.php | 26 +++++++++++++ src/Plugin/Wechat/Pay/Common/PrepayPlugin.php | 37 +++++++++++++++++++ src/Plugin/Wechat/Pay/Common/QueryPlugin.php | 35 ++++++++++++++++++ src/Plugin/Wechat/Pay/Common/RefundPlugin.php | 20 ++++++++++ src/Plugin/Wechat/Pay/H5/ClosePlugin.php | 9 +++++ .../Wechat/Pay/H5/DownloadBillPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/H5/FindRefundPlugin.php | 9 +++++ .../Wechat/Pay/H5/GetFlowBillPlugin.php | 9 +++++ .../Wechat/Pay/H5/GetTradeBillPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/H5/PrepayPlugin.php | 15 ++++++++ src/Plugin/Wechat/Pay/H5/QueryPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/H5/RefundPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/Jsapi/ClosePlugin.php | 26 +------------ .../Wechat/Pay/Jsapi/DownloadBillPlugin.php | 19 +--------- .../Wechat/Pay/Jsapi/FindRefundPlugin.php | 19 +--------- .../Wechat/Pay/Jsapi/GetFlowBillPlugin.php | 19 +--------- .../Wechat/Pay/Jsapi/GetTradeBillPlugin.php | 19 +--------- src/Plugin/Wechat/Pay/Jsapi/PrepayPlugin.php | 25 +------------ src/Plugin/Wechat/Pay/Jsapi/QueryPlugin.php | 28 +------------- src/Plugin/Wechat/Pay/Jsapi/RefundPlugin.php | 13 +------ src/Plugin/Wechat/Pay/Mini/ClosePlugin.php | 9 +++++ .../Wechat/Pay/Mini/DownloadBillPlugin.php | 9 +++++ .../Wechat/Pay/Mini/FindRefundPlugin.php | 9 +++++ .../Wechat/Pay/Mini/GetFlowBillPlugin.php | 9 +++++ .../Wechat/Pay/Mini/GetTradeBillPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/Mini/PrepayPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/Mini/QueryPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/Mini/RefundPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/Native/ClosePlugin.php | 9 +++++ .../Wechat/Pay/Native/DownloadBillPlugin.php | 9 +++++ .../Wechat/Pay/Native/FindRefundPlugin.php | 9 +++++ .../Wechat/Pay/Native/GetFlowBillPlugin.php | 9 +++++ .../Wechat/Pay/Native/GetTradeBillPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/Native/PrepayPlugin.php | 15 ++++++++ src/Plugin/Wechat/Pay/Native/QueryPlugin.php | 9 +++++ src/Plugin/Wechat/Pay/Native/RefundPlugin.php | 9 +++++ 48 files changed, 543 insertions(+), 160 deletions(-) create mode 100644 src/Plugin/Wechat/Pay/App/ClosePlugin.php create mode 100644 src/Plugin/Wechat/Pay/App/DownloadBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/App/FindRefundPlugin.php create mode 100644 src/Plugin/Wechat/Pay/App/GetFlowBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/App/GetTradeBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/App/PrepayPlugin.php create mode 100644 src/Plugin/Wechat/Pay/App/QueryPlugin.php create mode 100644 src/Plugin/Wechat/Pay/App/RefundPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Common/ClosePlugin.php create mode 100644 src/Plugin/Wechat/Pay/Common/DownloadBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Common/FindRefundPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Common/GetFlowBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Common/GetTradeBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Common/PrepayPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Common/QueryPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Common/RefundPlugin.php create mode 100644 src/Plugin/Wechat/Pay/H5/ClosePlugin.php create mode 100644 src/Plugin/Wechat/Pay/H5/DownloadBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/H5/FindRefundPlugin.php create mode 100644 src/Plugin/Wechat/Pay/H5/GetFlowBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/H5/GetTradeBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/H5/PrepayPlugin.php create mode 100644 src/Plugin/Wechat/Pay/H5/QueryPlugin.php create mode 100644 src/Plugin/Wechat/Pay/H5/RefundPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Mini/ClosePlugin.php create mode 100644 src/Plugin/Wechat/Pay/Mini/DownloadBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Mini/FindRefundPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Mini/GetFlowBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Mini/GetTradeBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Mini/PrepayPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Mini/QueryPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Mini/RefundPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Native/ClosePlugin.php create mode 100644 src/Plugin/Wechat/Pay/Native/DownloadBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Native/FindRefundPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Native/GetFlowBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Native/GetTradeBillPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Native/PrepayPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Native/QueryPlugin.php create mode 100644 src/Plugin/Wechat/Pay/Native/RefundPlugin.php diff --git a/src/Plugin/Wechat/Pay/App/ClosePlugin.php b/src/Plugin/Wechat/Pay/App/ClosePlugin.php new file mode 100644 index 0000000..542c599 --- /dev/null +++ b/src/Plugin/Wechat/Pay/App/ClosePlugin.php @@ -0,0 +1,9 @@ +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', ''), + ])); + } +} diff --git a/src/Plugin/Wechat/Pay/Common/DownloadBillPlugin.php b/src/Plugin/Wechat/Pay/Common/DownloadBillPlugin.php new file mode 100644 index 0000000..9a003bd --- /dev/null +++ b/src/Plugin/Wechat/Pay/Common/DownloadBillPlugin.php @@ -0,0 +1,26 @@ +getParams()['download_url'] ?? ''; + } + + protected function getMethod(): string + { + return 'GET'; + } + + protected function checkPayload(Rocket $rocket): void + { + $rocket->setPayload(null); + } +} diff --git a/src/Plugin/Wechat/Pay/Common/FindRefundPlugin.php b/src/Plugin/Wechat/Pay/Common/FindRefundPlugin.php new file mode 100644 index 0000000..170ab67 --- /dev/null +++ b/src/Plugin/Wechat/Pay/Common/FindRefundPlugin.php @@ -0,0 +1,26 @@ +getParams()['out_refund_no'] ?? ''); + } + + protected function getMethod(): string + { + return 'GET'; + } + + protected function checkPayload(Rocket $rocket): void + { + $rocket->setPayload(null); + } +} diff --git a/src/Plugin/Wechat/Pay/Common/GetFlowBillPlugin.php b/src/Plugin/Wechat/Pay/Common/GetFlowBillPlugin.php new file mode 100644 index 0000000..cabddc5 --- /dev/null +++ b/src/Plugin/Wechat/Pay/Common/GetFlowBillPlugin.php @@ -0,0 +1,26 @@ +getParams()); + } + + protected function getMethod(): string + { + return 'GET'; + } + + protected function checkPayload(Rocket $rocket): void + { + $rocket->setPayload(null); + } +} diff --git a/src/Plugin/Wechat/Pay/Common/GetTradeBillPlugin.php b/src/Plugin/Wechat/Pay/Common/GetTradeBillPlugin.php new file mode 100644 index 0000000..fa08de4 --- /dev/null +++ b/src/Plugin/Wechat/Pay/Common/GetTradeBillPlugin.php @@ -0,0 +1,26 @@ +getParams()); + } + + protected function getMethod(): string + { + return 'GET'; + } + + protected function checkPayload(Rocket $rocket): void + { + $rocket->setPayload(null); + } +} diff --git a/src/Plugin/Wechat/Pay/Common/PrepayPlugin.php b/src/Plugin/Wechat/Pay/Common/PrepayPlugin.php new file mode 100644 index 0000000..21b5154 --- /dev/null +++ b/src/Plugin/Wechat/Pay/Common/PrepayPlugin.php @@ -0,0 +1,37 @@ +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); + } +} diff --git a/src/Plugin/Wechat/Pay/Common/QueryPlugin.php b/src/Plugin/Wechat/Pay/Common/QueryPlugin.php new file mode 100644 index 0000000..459a72c --- /dev/null +++ b/src/Plugin/Wechat/Pay/Common/QueryPlugin.php @@ -0,0 +1,35 @@ +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); + } +} diff --git a/src/Plugin/Wechat/Pay/Common/RefundPlugin.php b/src/Plugin/Wechat/Pay/Common/RefundPlugin.php new file mode 100644 index 0000000..61b6cca --- /dev/null +++ b/src/Plugin/Wechat/Pay/Common/RefundPlugin.php @@ -0,0 +1,20 @@ +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', ''), - ])); - } } diff --git a/src/Plugin/Wechat/Pay/Jsapi/DownloadBillPlugin.php b/src/Plugin/Wechat/Pay/Jsapi/DownloadBillPlugin.php index ed3ca6d..049f5bd 100644 --- a/src/Plugin/Wechat/Pay/Jsapi/DownloadBillPlugin.php +++ b/src/Plugin/Wechat/Pay/Jsapi/DownloadBillPlugin.php @@ -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); - } } diff --git a/src/Plugin/Wechat/Pay/Jsapi/FindRefundPlugin.php b/src/Plugin/Wechat/Pay/Jsapi/FindRefundPlugin.php index 1c542cd..1d76042 100644 --- a/src/Plugin/Wechat/Pay/Jsapi/FindRefundPlugin.php +++ b/src/Plugin/Wechat/Pay/Jsapi/FindRefundPlugin.php @@ -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); - } } diff --git a/src/Plugin/Wechat/Pay/Jsapi/GetFlowBillPlugin.php b/src/Plugin/Wechat/Pay/Jsapi/GetFlowBillPlugin.php index a98499b..85503d7 100644 --- a/src/Plugin/Wechat/Pay/Jsapi/GetFlowBillPlugin.php +++ b/src/Plugin/Wechat/Pay/Jsapi/GetFlowBillPlugin.php @@ -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); - } } diff --git a/src/Plugin/Wechat/Pay/Jsapi/GetTradeBillPlugin.php b/src/Plugin/Wechat/Pay/Jsapi/GetTradeBillPlugin.php index ce69d0b..3006d83 100644 --- a/src/Plugin/Wechat/Pay/Jsapi/GetTradeBillPlugin.php +++ b/src/Plugin/Wechat/Pay/Jsapi/GetTradeBillPlugin.php @@ -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); - } } diff --git a/src/Plugin/Wechat/Pay/Jsapi/PrepayPlugin.php b/src/Plugin/Wechat/Pay/Jsapi/PrepayPlugin.php index a9f25e8..2b1c1ad 100644 --- a/src/Plugin/Wechat/Pay/Jsapi/PrepayPlugin.php +++ b/src/Plugin/Wechat/Pay/Jsapi/PrepayPlugin.php @@ -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'), - ]); - } } diff --git a/src/Plugin/Wechat/Pay/Jsapi/QueryPlugin.php b/src/Plugin/Wechat/Pay/Jsapi/QueryPlugin.php index 2e516b4..6f6855f 100644 --- a/src/Plugin/Wechat/Pay/Jsapi/QueryPlugin.php +++ b/src/Plugin/Wechat/Pay/Jsapi/QueryPlugin.php @@ -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); - } } diff --git a/src/Plugin/Wechat/Pay/Jsapi/RefundPlugin.php b/src/Plugin/Wechat/Pay/Jsapi/RefundPlugin.php index 3cd9364..3bba4a7 100644 --- a/src/Plugin/Wechat/Pay/Jsapi/RefundPlugin.php +++ b/src/Plugin/Wechat/Pay/Jsapi/RefundPlugin.php @@ -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 - { - } } diff --git a/src/Plugin/Wechat/Pay/Mini/ClosePlugin.php b/src/Plugin/Wechat/Pay/Mini/ClosePlugin.php new file mode 100644 index 0000000..311fdd6 --- /dev/null +++ b/src/Plugin/Wechat/Pay/Mini/ClosePlugin.php @@ -0,0 +1,9 @@ +