transfer.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. $wxConfig = require_once __DIR__ . '/../wxconfig.php';
  13. $data = [
  14. 'channel' => \Payment\Client::TRANSFER_CHANNEL_ACCOUNT, // account: 转微信,bank:转银行
  15. // account的参数
  16. 'device_info' => '',
  17. 'trans_no' => time(),
  18. 'openid' => 'o-e_mwTXTaxEhBM8xDoj1ui1f950',
  19. 'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名 FORCE_CHECK:强校验真实姓名
  20. 'payer_real_name' => 'dayu',
  21. 'amount' => '1',
  22. 'desc' => '测试转账',
  23. 'client_ip' => '127.0.0.1',
  24. // bank 的参数
  25. /*'trans_no' => time(),
  26. 'enc_bank_no' => '',
  27. 'enc_true_name' => '',
  28. 'bank_code' => '',
  29. 'amount' => '1',
  30. 'desc' => '测试转账',*/
  31. ];
  32. try {
  33. $client = new \Payment\Client(\Payment\Client::WECHAT, $wxConfig);
  34. $client->transfer($data);
  35. } catch (InvalidArgumentException $e) {
  36. echo $e->getMessage();
  37. exit;
  38. } catch (\Payment\Exceptions\GatewayException $e) {
  39. echo $e->getMessage();
  40. exit;
  41. } catch (\Payment\Exceptions\ClassNotFoundException $e) {
  42. echo $e->getMessage();
  43. exit;
  44. }
  45. var_dump($res);