cancelTrade.php 920 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. $params = [
  14. 'trade_no' => '15806497739520',
  15. //'transaction_id' => '12312323',
  16. ];
  17. // 使用
  18. try {
  19. $client = new \Payment\Client(\Payment\Client::ALIPAY, $aliConfig);
  20. $res = $client->cancel($params);
  21. } catch (InvalidArgumentException $e) {
  22. echo $e->getMessage();
  23. exit;
  24. } catch (\Payment\Exceptions\GatewayException $e) {
  25. echo $e->getMessage();
  26. exit;
  27. } catch (\Payment\Exceptions\ClassNotFoundException $e) {
  28. echo $e->getMessage();
  29. exit;
  30. } catch (Exception $e) {
  31. echo $e->getMessage();
  32. exit;
  33. }
  34. var_dump($res);