YopConfig.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/11/14
  6. * Time: 10:03
  7. */
  8. namespace app\common\modules\yop\sdk;
  9. class YopConfig
  10. {
  11. public $serverRoot = "https://open.yeepay.com/yop-center";
  12. public $appKey;
  13. public $aesSecretKey;
  14. public $hmacSecretKey;
  15. public $connectTimeout=30000;
  16. public $readTimeout=60000;
  17. //加密算法
  18. public $ALG_MD5 = "MD5";
  19. public $ALG_AES = "AES";
  20. public $ALG_SHA = "SHA";
  21. public $ALG_SHA1 = "SHA1";
  22. // 保护参数
  23. public $CLIENT_VERSION = "2.0.0";
  24. public $ENCODING = "UTF-8";
  25. public $SUCCESS = "SUCCESS";
  26. public $CALLBACK = "callback";
  27. // 方法的默认参数名
  28. public $METHOD = "method";
  29. // 格式化默认参数名
  30. public $FORMAT = "format";
  31. // 本地化默认参数名
  32. public $LOCALE = "locale";
  33. // 会话id默认参数名
  34. public $SESSION_ID = "sessionId";
  35. // 应用键的默认参数名 ;
  36. public $APP_KEY = "appKey";
  37. // 服务版本号的默认参数名
  38. public $VERSION = "v";
  39. // 签名的默认参数名
  40. public $SIGN = "sign";
  41. // 返回结果是否签名
  42. public $SIGN_RETURN = "signRet";
  43. // 商户编号
  44. public $CUSTOMER_NO = "customerNo";
  45. // 加密报文key
  46. public $ENCRYPT = "encrypt";
  47. // 时间戳
  48. public $TIMESTAMP = "ts";
  49. public $publicED_KEY=array();
  50. public function __construct(){
  51. array_push($this->publicED_KEY,$this->APP_KEY, $this->VERSION, $this->SIGN, $this->METHOD, $this->FORMAT, $this->LOCALE, $this->SESSION_ID, $this->CUSTOMER_NO, $this->ENCRYPT, $this->SIGN_RETURN, $this->TIMESTAMP );
  52. }
  53. public function __set($name, $value){
  54. // TODO: Implement __set() method.
  55. $this->$name = $value;
  56. }
  57. public function __get($name){
  58. // TODO: Implement __get() method.
  59. return $this->$name;
  60. }
  61. public function getSecret(){
  62. if(!empty($this->appKey) && strlen($this->appKey) > 0){
  63. return $this->aesSecretKey;
  64. }else{
  65. return $this->hmacSecretKey;
  66. }
  67. }
  68. public function ispublicedKey($key){
  69. if(in_array($key,$this->publicED_KEY)){
  70. return true;
  71. }
  72. return false;
  73. }
  74. }