transfer.php 1.3 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. $aliConfig = require_once __DIR__ . '/../aliconfig.php';
  13. $params = [
  14. 'trans_no' => time(),
  15. 'payee_type' => 'ALIPAY_LOGONID', // ALIPAY_USERID:支付宝账号对应的支付宝唯一用户号。以2088开头的16位纯数字组成; ALIPAY_LOGONID:支付宝登录号,支持邮箱和手机号格式
  16. 'payee_account' => 'aaqlmq0729@sandbox.com', // ALIPAY_USERID: 2088102169940354 ALIPAY_LOGONID:aaqlmq0729@sandbox.com
  17. 'amount' => '1000',
  18. 'remark' => '转账拉,有钱了',
  19. 'payer_show_name' => '一个未来的富豪',
  20. ];
  21. // 使用
  22. try {
  23. $client = new \Payment\Client(\Payment\Client::ALIPAY, $aliConfig);
  24. $res = $client->transfer($params);
  25. } catch (InvalidArgumentException $e) {
  26. echo $e->getMessage();
  27. exit;
  28. } catch (\Payment\Exceptions\GatewayException $e) {
  29. echo $e->getMessage();
  30. exit;
  31. } catch (\Payment\Exceptions\ClassNotFoundException $e) {
  32. echo $e->getMessage();
  33. exit;
  34. } catch (Exception $e) {
  35. echo $e->getMessage();
  36. exit;
  37. }
  38. var_dump($res);