closeTrade.php 960 B

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