GeneralPlugin.php 865 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. declare(strict_types=1);
  3. namespace Yansongda\Pay\Plugin\Alipay;
  4. use Closure;
  5. use Yansongda\Pay\Contract\PluginInterface;
  6. use Yansongda\Pay\Logger;
  7. use Yansongda\Pay\Rocket;
  8. abstract class GeneralPlugin implements PluginInterface
  9. {
  10. public function assembly(Rocket $rocket, Closure $next): Rocket
  11. {
  12. Logger::debug('[alipay][GeneralPlugin] 通用插件开始装载', ['rocket' => $rocket]);
  13. $this->doSomethingBefore($rocket);
  14. $rocket->mergePayload([
  15. 'method' => $this->getMethod(),
  16. 'biz_content' => $rocket->getParams(),
  17. ]);
  18. Logger::info('[alipay][GeneralPlugin] 通用插件装载完毕', ['rocket' => $rocket]);
  19. return $next($rocket);
  20. }
  21. protected function doSomethingBefore(Rocket $rocket): void
  22. {
  23. }
  24. abstract protected function getMethod(): string;
  25. }