WapPayPlugin.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. namespace Yansongda\Pay\Plugin\Alipay\Trade;
  4. use Closure;
  5. use Yansongda\Pay\Contract\PluginInterface;
  6. use Yansongda\Pay\Direction\ResponseDirection;
  7. use Yansongda\Pay\Exception\ContainerException;
  8. use Yansongda\Pay\Exception\ServiceNotFoundException;
  9. use Yansongda\Pay\Logger;
  10. use Yansongda\Pay\Rocket;
  11. use Yansongda\Pay\Traits\SupportServiceProviderTrait;
  12. /**
  13. * @see https://opendocs.alipay.com/open/02ivbs?scene=common
  14. */
  15. class WapPayPlugin implements PluginInterface
  16. {
  17. use SupportServiceProviderTrait;
  18. /**
  19. * @throws ContainerException
  20. * @throws ServiceNotFoundException
  21. */
  22. public function assembly(Rocket $rocket, Closure $next): Rocket
  23. {
  24. Logger::debug('[alipay][WapPayPlugin] 插件开始装载', ['rocket' => $rocket]);
  25. $this->loadAlipayServiceProvider($rocket);
  26. $rocket->setDirection(ResponseDirection::class)
  27. ->mergePayload([
  28. 'method' => 'alipay.trade.wap.pay',
  29. 'biz_content' => array_merge(
  30. [
  31. 'product_code' => 'QUICK_WAP_PAY',
  32. ],
  33. $rocket->getParams(),
  34. ),
  35. ])
  36. ;
  37. Logger::info('[alipay][WapPayPlugin] 插件装载完毕', ['rocket' => $rocket]);
  38. return $next($rocket);
  39. }
  40. }