bill.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. $cmbConfig = require_once __DIR__ . '/../cmbconfig.php';
  13. $params = [
  14. 'type' => 'trade', //trade:交易账单,refund:退款账单,默认是:trade
  15. // trade
  16. 'date' => time(),
  17. 'message_key' => time(),
  18. // refund
  19. 'start_time' => strtotime('-2days'),
  20. 'end_time' => strtotime('-1days'),
  21. 'operator_id' => '111',
  22. ];
  23. // 使用
  24. try {
  25. $client = new \Payment\Client(\Payment\Client::CMB, $cmbConfig);
  26. $res = $client->billDownload($params);
  27. } catch (InvalidArgumentException $e) {
  28. echo $e->getMessage();
  29. exit;
  30. } catch (\Payment\Exceptions\GatewayException $e) {
  31. echo $e->getMessage();
  32. exit;
  33. } catch (\Payment\Exceptions\ClassNotFoundException $e) {
  34. echo $e->getMessage();
  35. exit;
  36. } catch (Exception $e) {
  37. echo $e->getMessage();
  38. exit;
  39. }
  40. var_dump($res);