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.
 
 
 
 
 
 

48 lines
1.5 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zhengmingwei
  5. * Date: 2020/5/8
  6. * Time: 10:45 AM
  7. */
  8. namespace addons\unishop\extend;
  9. use addons\unishop\model\Config;
  10. use Yansongda\Pay\Pay;
  11. class Ali
  12. {
  13. public static function initAliPay()
  14. {
  15. $config = [
  16. 'app_id' => Config::getByName('ali_app_id')['value'],
  17. 'notify_url' => Config::getByName('ali_notify_url')['value'],
  18. 'return_url' => Config::getByName('ali_return_url')['value'],
  19. 'ali_public_key' => Config::getByName('ali_public_key')['value'],
  20. // 加密方式: **RSA2**
  21. 'private_key' => Config::getByName('ali_private_key')['value'],
  22. // 'log' => [ // optional
  23. // 'file' => './logs/alipay.log',
  24. // 'level' => 'info', // 建议生产环境等级调整为 info,开发环境为 debug
  25. // 'type' => 'single', // optional, 可选 daily.
  26. // 'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
  27. // ],
  28. 'http' => [ // optional
  29. 'timeout' => 5.0,
  30. 'connect_timeout' => 5.0,
  31. // 更多配置项请参考 [Guzzle](https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html)
  32. ],
  33. //'mode' => 'dev', // optional,设置此参数,将进入沙箱模式
  34. ];
  35. if (Config::getByName('ali_sandbox')['value'] == 1) {
  36. $config['mode'] = 'dev';
  37. }
  38. return Pay::alipay($config);
  39. }
  40. }