123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace refill\xinsj;
- 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_xinsj.php";
- static function getProduct($card_type,$amount)
- {
- if ($card_type == mtopcard\PetroChinaCard)
- {
- switch ($amount) {
- case 100: return 1;
- case 200: return 2;
- case 500: return 3;
- case 1000: return 4;
- default: return false;
- }
- }
- elseif ($card_type == mtopcard\SinopecCard) {
- switch ($amount) {
- case 100: return 5;
- case 200: return 6;
- case 500: return 7;
- case 1000: return 8;
- 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;
- }
- }
|