123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace refill\yifa;
- require_once(BASE_HELPER_RAPI_PATH . '/yifa/config.php');
- use refill;
- use Log;
- class RefillPhone extends refill\IRefillPhone
- {
- public function __construct($cfgs)
- {
- parent::__construct($cfgs);
- }
- private function req_params(int $phone, int $amount ,string $order_sn)
- {
- $params['app_id'] = config::APP_ID;
- $params['nonce_str'] = strtoupper($this->createNoncestr());
- $params['timestamp'] = time();
- $params['order_sn'] = $order_sn;
- $params['phone'] = $phone;
- $params['amount'] = $amount;
- $params['notify_url'] = config::NOTIFY_URL;
- return $params;
- }
- public function add($card_no, $card_type,$amount,$params,&$net_errno = 0)
- {
- refill\util::send_normal($params['order_sn']);
- return [true , '',false];
- }
- public function query($refill_info)
- {
- }
- public function balance()
- {
- return [false, '暂无余额接口'];
- }
- /**
- * 作用:产生随机字符串,不长于32位
- */
- public 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;
- }
- private function sign($params)
- {
- ksort($params);
- $app_secret = config::APP_SECRET;
- $content = $app_secret;
- foreach ($params as $key => $val)
- {
- if(empty($val)){
- continue;
- }
- $content .= "{$key}{$val}";
- }
- $content .= $app_secret;
- return strtoupper(md5($content));
- }
- }
|