WxPayConfig.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\libs\wechat\wxpay;
  3. use App\libs\helpers\Helper;
  4. use Illuminate\Support\Facades\Config;
  5. /**
  6. * @desc 配置账号信息类
  7. */
  8. class WxPayConfig
  9. {
  10. /**
  11. * 微信公众号信息配置.
  12. *
  13. * APPID:绑定支付的APPID(必须配置,开户邮件中可查看)
  14. *
  15. * MCHID:商户号(必须配置,开户邮件中可查看)
  16. *
  17. * KEY:商户支付密钥,参考开户邮件设置(必须配置,登录商户平台自行设置)
  18. * 设置地址:https://pay.weixin.qq.com/index.php/account/api_cert
  19. *
  20. * APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置, 登录公众平台,进入开发者中心可设置),
  21. * 获取地址:https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=2005451881&lang=zh_CN
  22. *
  23. * @var string
  24. */
  25. public static $appId = '';
  26. public static $mchId = '';
  27. public static $key = '';
  28. /**
  29. * 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要,可登录商户平台下载,
  30. * API证书下载地址:https://pay.weixin.qq.com/index.php/account/api_cert,下载之前需要安装商户操作证书).
  31. *
  32. * @var path
  33. */
  34. public static $sslCertPath = '';
  35. public static $sslKeyPath = '';
  36. /**
  37. * 本例程通过curl使用HTTP POST方法,此处可修改代理服务器,
  38. * 默认CURL_PROXY_HOST=0.0.0.0和CURL_PROXY_PORT=0,此时不开启代理(如有需要才设置).
  39. *
  40. * @var unknown_type
  41. */
  42. public static $curlProxyHost = '0.0.0.0';
  43. public static $curlProxyPort = 0;
  44. /**
  45. * 不会影响接口调用流程),开启上报之后,方便微信监控请求调用的质量,建议至少
  46. * 开启错误上报。
  47. * 上报等级,0.关闭上报; 1.仅错误出错上报; 2.全量上报.
  48. *
  49. * @var int
  50. */
  51. public static $reportLevel = 1;
  52. public static $idPre = '8491547801';
  53. public function __construct()
  54. {
  55. $id = Config::get('lc.wxpay.id'); // 公众号:dmia|cdlchd|yjyx
  56. $payment = include Helper::frameRootPath() . '/configs/wxPayment.php';
  57. if (isset($payment[$id])) {
  58. $conf = $payment[$id];
  59. self::$appId = $conf['appid'];
  60. self::$mchId = $conf['mch_id'];
  61. self::$key = $conf['key'];
  62. self::$sslCertPath = $conf['path'] . 'apiclient_cert.pem';
  63. self::$sslKeyPath = $conf['path'] . 'apiclient_key.pem';
  64. self::$curlProxyHost = $conf['ip'];
  65. if (isset($conf['port'])) {
  66. self::$curlProxyPort = $conf['port'];
  67. }
  68. if (isset($conf['report_level'])) {
  69. self::$reportLevel = $conf['report_level'];
  70. }
  71. if (isset($conf['id_pre'])) {
  72. self::$idPre = $conf['id_pre'];
  73. }
  74. }
  75. }
  76. }