queryOrder.php 972 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * The file is part of the payment lib.
  4. *
  5. * (c) Leo <dayugog@gmail.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. require_once __DIR__ . '/../../vendor/autoload.php';
  11. date_default_timezone_set('Asia/Shanghai');
  12. $aliConfig = require_once __DIR__ . '/../aliconfig.php';
  13. // 二者不能同时为空
  14. $data = [
  15. 'trade_no' => '15806495958685',
  16. //'transaction_id' => '2020020222001440351000252549',
  17. ];
  18. // 使用
  19. try {
  20. $client = new \Payment\Client(\Payment\Client::ALIPAY, $aliConfig);
  21. $res = $client->tradeQuery($data);
  22. } catch (InvalidArgumentException $e) {
  23. echo $e->getMessage();
  24. exit;
  25. } catch (\Payment\Exceptions\GatewayException $e) {
  26. echo $e->getMessage();
  27. exit;
  28. } catch (\Payment\Exceptions\ClassNotFoundException $e) {
  29. echo $e->getMessage();
  30. exit;
  31. } catch (Exception $e) {
  32. echo $e->getMessage();
  33. exit;
  34. }
  35. var_dump($res);