config.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace refill\xinsj;
  3. use mtopcard;
  4. class config
  5. {
  6. const CHANNEL_HOST = 'http://122.114.168.35';
  7. const ORDER_URL = config::CHANNEL_HOST . '/gateway/api.run/submit';
  8. const QUERY_URL = config::CHANNEL_HOST . '/gateway/api.run/order';
  9. const BALANCE_URL = config::CHANNEL_HOST . '/gateway/api.run/account';
  10. const APPID = 'CZ30533982';
  11. const APPKEY = 'lvrg4xoqvrozuq2irjza2a6dlenrsv';
  12. const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xinsj.php";
  13. static function getProduct($card_type,$amount)
  14. {
  15. if ($card_type == mtopcard\PetroChinaCard)
  16. {
  17. switch ($amount) {
  18. case 100: return 1;
  19. case 200: return 2;
  20. case 500: return 3;
  21. case 1000: return 4;
  22. default: return false;
  23. }
  24. }
  25. elseif ($card_type == mtopcard\SinopecCard) {
  26. switch ($amount) {
  27. case 100: return 5;
  28. case 200: return 6;
  29. case 500: return 7;
  30. case 1000: return 8;
  31. default: return false;
  32. }
  33. }
  34. else {
  35. return false;
  36. }
  37. }
  38. public static function body($params)
  39. {
  40. ksort($params);
  41. $body = "";
  42. $i = 0;
  43. foreach ($params as $k => $v)
  44. {
  45. if (false === self::check_empty($v) && "@" != substr($v, 0, 1))
  46. {
  47. if ($i == 0) {
  48. $body .= "{$k}" . "=" . urlencode($v);
  49. } else {
  50. $body .= "&" . "{$k}" . "=" . urlencode($v);
  51. }
  52. $i++;
  53. }
  54. }
  55. return $body;
  56. }
  57. private static function check_empty($value)
  58. {
  59. if (!isset($value))
  60. return true;
  61. if ($value === null)
  62. return true;
  63. if (trim($value) === "")
  64. return true;
  65. return false;
  66. }
  67. }