config.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace refill\chuangyu_ylyw;
  3. use mtopcard;
  4. class config
  5. {
  6. const ORDER_URL = 'http://120.55.55.137:8080/api/charge';
  7. const QUERY_URL = 'http://120.55.55.137:8080/api/query';
  8. const BALANCE_URL = 'http://120.55.55.137:8080/api/balance';
  9. const MCH_ID = '1008';
  10. const SECRET_KEY = '7a2118a9cb7ee70f2fa9dd9b9260a239';
  11. const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_chuangyu_ylyw.php";
  12. const ExtHeaders = ['Content-Type: application/json'];
  13. const ProductIdS = [
  14. mtopcard\ChinaMobileCard =>
  15. [
  16. 50 => '10003',
  17. 100 => '10004',
  18. 200 => '10005',
  19. 300 => '10006',
  20. 500 => '10007',
  21. ],
  22. mtopcard\ChinaUnicomCard =>
  23. [
  24. 50 => '10011',
  25. 100 => '10012',
  26. 200 => '10013',
  27. 300 => '10014',
  28. ],
  29. mtopcard\ChinaTelecomCard =>
  30. [
  31. 50 => '10019',
  32. 100 => '10020',
  33. 200 => '10021',
  34. 300 => '10022',
  35. 500 => '10023',
  36. ],
  37. ];
  38. public static function sign($params)
  39. {
  40. ksort($params);
  41. $content = '';
  42. foreach ($params as $key => $value) {
  43. if(self::check_empty($value) === false) {
  44. $content .= "{$key}={$value}&";
  45. }
  46. }
  47. $content .= 'secret_key=' . config::SECRET_KEY;
  48. return md5(md5($content));
  49. }
  50. public static function check_empty($value)
  51. {
  52. if (!isset($value))
  53. return true;
  54. if ($value === null)
  55. return true;
  56. if (trim($value) === "")
  57. return true;
  58. return false;
  59. }
  60. }