国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.9KB

  1. <?php
  2. namespace AliPay;
  3. if (!defined('DEDEINC')) exit ('dedebiz');
  4. use WeChat\Contracts\BasicAliPay;
  5. use WeChat\Exceptions\InvalidArgumentException;
  6. /**
  7. * 支付宝转账到账户
  8. * Class Transfer
  9. * @package AliPay
  10. */
  11. class Transfer extends BasicAliPay
  12. {
  13. /**
  14. * 旧版 向指定支付宝账户转账
  15. * @param array $options
  16. * @return array|bool
  17. * @throws \WeChat\Exceptions\InvalidResponseException
  18. * @throws \WeChat\Exceptions\LocalCacheException
  19. */
  20. public function apply($options)
  21. {
  22. $this->options->set('method', 'alipay.fund.trans.toaccount.transfer');
  23. return $this->getResult($options);
  24. }
  25. /**
  26. * 新版 向指定支付宝账户转账
  27. * @param array $options
  28. * @return array|bool
  29. * @throws \WeChat\Exceptions\InvalidResponseException
  30. * @throws \WeChat\Exceptions\LocalCacheException
  31. */
  32. public function create($options = [])
  33. {
  34. $this->setAppCertSnAndRootCertSn();
  35. $this->options->set('method', 'alipay.fund.trans.uni.transfer');
  36. return $this->getResult($options);
  37. }
  38. /**
  39. * 新版 转账业务单据查询接口
  40. * @param array $options
  41. * @return array|bool
  42. * @throws \WeChat\Exceptions\InvalidResponseException
  43. * @throws \WeChat\Exceptions\LocalCacheException
  44. */
  45. public function queryResult($options = [])
  46. {
  47. $this->setAppCertSnAndRootCertSn();
  48. $this->options->set('method', 'alipay.fund.trans.common.query');
  49. return $this->getResult($options);
  50. }
  51. /**
  52. * 新版 支付宝资金账户资产查询接口
  53. * @param array $options
  54. * @return array|bool
  55. * @throws \WeChat\Exceptions\InvalidResponseException
  56. * @throws \WeChat\Exceptions\LocalCacheException
  57. */
  58. public function queryAccount($options = [])
  59. {
  60. $this->setAppCertSnAndRootCertSn();
  61. $this->options->set('method', 'alipay.fund.account.query');
  62. return $this->getResult($options);
  63. }
  64. /**
  65. * 新版 设置网关应用公钥证书SN、支付宝根证书SN
  66. */
  67. protected function setAppCertSnAndRootCertSn()
  68. {
  69. if (!$this->config->get('app_cert')) {
  70. throw new InvalidArgumentException("Missing Config -- [app_cert]");
  71. }
  72. if (!$this->config->get('root_cert')) {
  73. throw new InvalidArgumentException("Missing Config -- [root_cert]");
  74. }
  75. $this->options->set('app_cert_sn', $this->getCertSN($this->config->get('app_cert')));
  76. $this->options->set('alipay_root_cert_sn', $this->getRootCertSN($this->config->get('root_cert')));
  77. if (!$this->options->get('app_cert_sn')) {
  78. throw new InvalidArgumentException("Missing options -- [app_cert_sn]");
  79. }
  80. if (!$this->options->get('alipay_root_cert_sn')) {
  81. throw new InvalidArgumentException("Missing options -- [alipay_root_cert_sn]");
  82. }
  83. }
  84. }
  85. ?>