MiniappGateway.php 933 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Yansongda\Pay\Gateways\Wechat;
  3. use Yansongda\Pay\Exceptions\GatewayException;
  4. use Yansongda\Pay\Exceptions\InvalidArgumentException;
  5. use Yansongda\Pay\Exceptions\InvalidSignException;
  6. use Yansongda\Pay\Gateways\Wechat;
  7. use Yansongda\Supports\Collection;
  8. class MiniappGateway extends MpGateway
  9. {
  10. /**
  11. * Pay an order.
  12. *
  13. * @author yansongda <me@yansongda.cn>
  14. *
  15. * @param string $endpoint
  16. *
  17. * @throws GatewayException
  18. * @throws InvalidArgumentException
  19. * @throws InvalidSignException
  20. */
  21. public function pay($endpoint, array $payload): Collection
  22. {
  23. $payload['appid'] = Support::getInstance()->miniapp_id;
  24. if (Wechat::MODE_SERVICE === $this->mode) {
  25. $payload['sub_appid'] = Support::getInstance()->sub_miniapp_id;
  26. $this->payRequestUseSubAppId = true;
  27. }
  28. return parent::pay($endpoint, $payload);
  29. }
  30. }