12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace refill\feinimoshu;
- use mtopcard;
- class config
- {
- const CHANNEL_HOST = 'http://122.114.168.35';
- const ORDER_URL = config::CHANNEL_HOST . '/gateway/api.run/submit';
- const QUERY_URL = config::CHANNEL_HOST . '/gateway/api.run/order';
- const BALANCE_URL = config::CHANNEL_HOST . '/gateway/api.run/account';
- const APPID = 'CZ30533982';
- const APPKEY = 'lvrg4xoqvrozuq2irjza2a6dlenrsv';
- const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_feinimoshu.php";
- static function getProduct($card_type,$amount)
- {
- if ($card_type == mtopcard\PetroChinaCard)
- {
- switch ($amount) {
- case 50: return 10006;
- case 100: return 10007;
- case 200: return 10008;
- case 500: return 10009;
- case 1000: return 10010;
- case 2000: return 10011;
- default: return false;
- }
- }
- elseif ($card_type == mtopcard\SinopecCard) {
- switch ($amount) {
- case 50: return 10000;
- case 100: return 10001;
- case 200: return 10002;
- case 500: return 10003;
- case 1000: return 10004;
- case 2000: return 10005;
- default: return false;
- }
- }
- else {
- return false;
- }
- }
- public static function body($params)
- {
- ksort($params);
- $body = "";
- $i = 0;
- foreach ($params as $k => $v)
- {
- if (false === self::check_empty($v) && "@" != substr($v, 0, 1))
- {
- if ($i == 0) {
- $body .= "{$k}" . "=" . urlencode($v);
- } else {
- $body .= "&" . "{$k}" . "=" . urlencode($v);
- }
- $i++;
- }
- }
- return $body;
- }
- private static function check_empty($value)
- {
- if (!isset($value))
- return true;
- if ($value === null)
- return true;
- if (trim($value) === "")
- return true;
- return false;
- }
- }
|