PosGateway.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Yansongda\Pay\Gateways\Wechat;
  3. use Yansongda\Pay\Events;
  4. use Yansongda\Pay\Exceptions\GatewayException;
  5. use Yansongda\Pay\Exceptions\InvalidArgumentException;
  6. use Yansongda\Pay\Exceptions\InvalidSignException;
  7. use Yansongda\Supports\Collection;
  8. class PosGateway extends Gateway
  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. unset($payload['trade_type'], $payload['notify_url']);
  24. $payload['sign'] = Support::generateSign($payload);
  25. Events::dispatch(new Events\PayStarted('Wechat', 'Pos', $endpoint, $payload));
  26. return Support::requestApi('pay/micropay', $payload);
  27. }
  28. /**
  29. * Get trade type config.
  30. *
  31. * @author yansongda <me@yansongda.cn>
  32. */
  33. protected function getTradeType(): string
  34. {
  35. return 'MICROPAY';
  36. }
  37. }