config.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace refill\feinimoshu;
  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_feinimoshu.php";
  13. static function getProduct($card_type,$amount)
  14. {
  15. if ($card_type == mtopcard\PetroChinaCard)
  16. {
  17. switch ($amount) {
  18. case 50: return 10006;
  19. case 100: return 10007;
  20. case 200: return 10008;
  21. case 500: return 10009;
  22. case 1000: return 10010;
  23. case 2000: return 10011;
  24. default: return false;
  25. }
  26. }
  27. elseif ($card_type == mtopcard\SinopecCard) {
  28. switch ($amount) {
  29. case 50: return 10000;
  30. case 100: return 10001;
  31. case 200: return 10002;
  32. case 500: return 10003;
  33. case 1000: return 10004;
  34. case 2000: return 10005;
  35. default: return false;
  36. }
  37. }
  38. else {
  39. return false;
  40. }
  41. }
  42. public static function body($params)
  43. {
  44. ksort($params);
  45. $body = "";
  46. $i = 0;
  47. foreach ($params as $k => $v)
  48. {
  49. if (false === self::check_empty($v) && "@" != substr($v, 0, 1))
  50. {
  51. if ($i == 0) {
  52. $body .= "{$k}" . "=" . urlencode($v);
  53. } else {
  54. $body .= "&" . "{$k}" . "=" . urlencode($v);
  55. }
  56. $i++;
  57. }
  58. }
  59. return $body;
  60. }
  61. private static function check_empty($value)
  62. {
  63. if (!isset($value))
  64. return true;
  65. if ($value === null)
  66. return true;
  67. if (trim($value) === "")
  68. return true;
  69. return false;
  70. }
  71. }