config.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace refill\weisanhuo;
  3. use mtopcard;
  4. class config
  5. {
  6. const ORDER_URL = 'http://124.70.69.117:50050/api/v1/rest/multi/charge/single';
  7. const QUERY_URL = 'http://124.70.69.117:50050/api/v1/rest/multi/charge/report/query';
  8. const BALANCE_URL = 'http://124.70.69.117:50050/api/v1/rest/multi/charge/balance';
  9. const SECRET_ID = '231c9717118f4413b1611a3a87221795';
  10. const SECRET_KEY = '0109d2f30b414832a0f1e8c29720eff3';
  11. const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_weisanhuo.php";
  12. const ExtHeaders = ['Content-Type: application/json;charset=UTF-8'];
  13. const ProductIdS = [
  14. mtopcard\ChinaMobileCard =>
  15. [
  16. 30 => 'k-yd-30',
  17. 50 => 'k-yd-50',
  18. 100 => 'k-yd-100',
  19. 200 => 'k-yd-200',
  20. 300 => 'k-yd-300',
  21. 500 => 'k-yd-500'
  22. ],
  23. mtopcard\ChinaUnicomCard =>
  24. [
  25. 30 => 'k-lt-30',
  26. 50 => 'k-lt-50',
  27. 100 => 'k-lt-100',
  28. 200 => 'k-lt-200'
  29. ],
  30. mtopcard\ChinaTelecomCard =>
  31. [
  32. 30 => 'k-dx-30',
  33. 50 => 'k-dx-50',
  34. 100 => 'k-dx-100',
  35. 200 => 'k-dx-200'
  36. ]
  37. ];
  38. public static function sign(array $params, array $ignore = []): string
  39. {
  40. ksort($params);
  41. $content = '';
  42. foreach ($params as $key => $value) {
  43. if (in_array($key, $ignore)) {
  44. continue;
  45. }
  46. if(self::check_empty($value) === false) {
  47. $key = strtolower($key);
  48. $value = urlencode($value);
  49. $content .= "$key=$value&";
  50. }
  51. }
  52. $content .= "secretkey=" . config::SECRET_KEY;
  53. return md5($content);
  54. }
  55. public static function check_empty($value): bool
  56. {
  57. if (!isset($value))
  58. return true;
  59. if (trim($value) === "null")
  60. return true;
  61. return false;
  62. }
  63. }