refund.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. $refundNo = time() . rand(1000, 9999);
  14. $data = [
  15. 'trade_no' => '9354737499',
  16. 'date' => time(),
  17. 'refund_no' => $refundNo,
  18. 'refund_fee' => 0.01,
  19. 'reason' => '测试帐号退款',
  20. 'operator_id' => '9999',
  21. ];
  22. // 使用
  23. try {
  24. $client = new \Payment\Client(\Payment\Client::CMB, $cmbConfig);
  25. $res = $client->refund($data);
  26. } catch (InvalidArgumentException $e) {
  27. echo $e->getMessage();
  28. exit;
  29. } catch (\Payment\Exceptions\GatewayException $e) {
  30. echo $e->getMessage();
  31. exit;
  32. } catch (\Payment\Exceptions\ClassNotFoundException $e) {
  33. echo $e->getMessage();
  34. exit;
  35. } catch (Exception $e) {
  36. echo $e->getMessage();
  37. exit;
  38. }