TransferGateway.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Yansongda\Pay\Gateways\Alipay;
  3. use Yansongda\Pay\Contracts\GatewayInterface;
  4. use Yansongda\Pay\Events;
  5. use Yansongda\Pay\Exceptions\GatewayException;
  6. use Yansongda\Pay\Exceptions\InvalidConfigException;
  7. use Yansongda\Pay\Exceptions\InvalidSignException;
  8. use Yansongda\Supports\Collection;
  9. class TransferGateway implements GatewayInterface
  10. {
  11. /**
  12. * Pay an order.
  13. *
  14. * @author yansongda <me@yansongda.cn>
  15. *
  16. * @param string $endpoint
  17. *
  18. * @throws GatewayException
  19. * @throws InvalidConfigException
  20. * @throws InvalidSignException
  21. */
  22. public function pay($endpoint, array $payload): Collection
  23. {
  24. $payload['method'] = 'alipay.fund.trans.uni.transfer';
  25. $payload['sign'] = Support::generateSign($payload);
  26. Events::dispatch(new Events\PayStarted('Alipay', 'Transfer', $endpoint, $payload));
  27. return Support::requestApi($payload);
  28. }
  29. /**
  30. * Find.
  31. *
  32. * @author yansongda <me@yansongda.cn>
  33. *
  34. * @param $order
  35. */
  36. public function find($order): array
  37. {
  38. return [
  39. 'method' => 'alipay.fund.trans.order.query',
  40. 'biz_content' => json_encode(is_array($order) ? $order : ['out_biz_no' => $order]),
  41. ];
  42. }
  43. }