123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace refill\shantong;
- class config
- {
- const ORDER_URL = 'http://wf-recharge-api.shantongdata.com/api/v1/mobile/order/apply';
- const QUERY_URL = 'http://wf-recharge-api.shantongdata.com/api/v1/mobile/order/query';
- const BALANCE_URL = 'http://wf-recharge-api.shantongdata.com/api/v1/agent/balance/enquiry';
- const AGENT_ID = '1004';
- const transactionPin = 'Qwer@1234';
- const APP_ID = 'cz_1004';
- const APP_KEY = '3c7795c7-beb3-45fc-b764-98c270062c90';
- const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_shantong.php";
- const ExtHeaders = ['Content-Type: application/json;charset=UTF-8'];
- private static function createNoncestr( $length = 32 )
- {
- $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
- $str ="";
- for ( $i = 0; $i < $length; $i++ ) {
- $str.= substr($chars, mt_rand(0, strlen($chars)-1), 1);
- }
- return $str;
- }
- public static function pub_params()
- {
- $params['appId'] = config::APP_ID;
- $params['nonceStr'] = self::createNoncestr();
- $params['timeStamp'] = time();
- return $params;
- }
- public static function sign($params)
- {
- ksort($params);
- $content = '';
- foreach ($params as $key => $value) {
- if(self::check_empty($value) === false) {
- $content .= "{$key}={$value}&";
- }
- }
- $content .= 'appKey='.config::APP_KEY;
- return md5($content);
- }
- public static function check_empty($value)
- {
- if (!isset($value))
- return true;
- if ($value === null)
- return true;
- if (trim($value) === "")
- return true;
- return false;
- }
- }
|