load(); } public function testAddthirdNet() { $params = [ 'mchid' => 1092, "act" => "refill", "op" => "add_third", 'order_sn' => $this->make_sn(), 'notifyurl' => 'https://www.xyzshops.cn/mobile/signature.php', 'card_type' => 1, 'cardno' => '403149064', 'product_code' => 'XYZ100744', 'quantity' => 5 ]; $proxy = new refill_proxy('210fe406954220f56085997d6a4c5b80'); $proxy->send("https://www.xyzshops.cn/mobile/index.php",$params); } public function testAddthirdExample() { $params = [ 'mchid' => 'xxxx', //贵方账号 "act" => "refill", "op" => "add_third", 'order_sn' => $this->make_sn(), //贵方单号 'notifyurl' => 'xxxx', //回调URL 'card_type' => 1,//卡类型,1 2,3 回头写文档 'cardno' => '403149064',//充值号码` 'product_code' => 'XYZ100744', //充值产品编码 'quantity' => 5, //数量 ]; $proxy = new refill_proxy('秘钥'); $proxy->send("https://www.xyzshops.cn/mobile/index.php",$params); } public function testPushPhone() { $params = [ 'mchid' => 9618, 'buyer_id' => 6, 'amount' => 30, 'mch_order' => $this->make_sn(), 'org_quality' => 1, 'card_no' => '13911129867' ]; $ret = refill\util::push_add($params); } public function testPushLzThird() { $params = [ 'mchid' => 9618, 'buyer_id' => 6, 'amount' => refill\util::ThirdRefillAmount, 'mch_order' => $this->make_sn(), 'notify_url' => '', 'org_quality' => 1, 'card_type' => mtopcard\ThirdRefillCard, 'card_no' => '403149064', 'product_code' => 'LZ100744', 'quantity' => 5, 'third_card_type' => 1 ]; $ret = refill\util::push_addthird($params); } public function testAddthirdLocal() { $params = [ 'mchid' => 1092, "act" => "refill", "op" => "add_third", 'order_sn' => $this->make_sn(), 'notifyurl' => 'https://www.xyzshops.cn/mobile/signature.php', 'card_type' => 1, 'cardno' => '403149064', 'product_code' => 'XYZ100744', 'quantity' => 5 ]; $proxy = new refill_proxy('210fe406954220f56085997d6a4c5b80'); $proxy->send("http://192.168.1.220/mobile/index.php",$params); } public function testPushXYZThird() { $params = [ 'mchid' => 1092, 'buyer_id' => 60221, 'amount' => refill\util::ThirdRefillAmount, 'mch_order' => $this->make_sn(), 'notify_url' => '', 'org_quality' => 1, 'card_type' => mtopcard\ThirdRefillCard, 'cardno' => '403149064', 'product_code' => 'XYZ100744', 'quantity' => 5, 'third_card_type' => 1 ]; $ret = refill\util::push_addthird($params); } private function make_sn() { return mt_rand(1000, 9999) . sprintf('%010d', time()) . sprintf('%06d', (float)microtime() * 1000000); } public function testAddQQ() { $params = $this->params(); } private function params($card_no,$card_type,$quantity,$pcode,$order_sn) { $params['act'] = 'lzrefill'; $params['op'] = 'add_third'; $params['notifyurl'] = 'https://www.xyzshops.cn/mobile/signature.php'; $params['usr'] = 9618; $params['card_no'] = $card_no; $params['quantity'] = $quantity; $params['product_code'] = $pcode; $params['card_type'] = $card_type; $params['ord'] = $order_sn; $params['tim'] = date("YmdHis"); $params['yysid'] = 0; $params['hmlx'] = 0; return $params; } public function testLingzhthirdPhone() { $providers = $this->getProvider('lingzhthird'); $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn(), 'goods_id' => 6559, 'quantity'=>5,'product_code'=>'XYZ100744','third_card_type'=>1]); } public function testFNMS() { $providers = $this->getProvider('feinimoshu','RefillOil'); $order_sn = $this->make_sn(); [$state, $ch_order, $neterr] = $providers->add(1000111100021211884, 2, 50, ['order_sn' => $order_sn]); $providers->query(['ch_trade_no' => $ch_order,'order_sn' => $order_sn]); } public function testFNMSCB() { $params = ['appid' => 'CZ30533982', 'order' => 'D20210524392940805012773', 'morder' => '82001621839274971137', 'status' => '3', 'cash' => '50', 'signature' => '8e6bed66f0a3f28e3e952b60b98973b8']; $provider = $this->getProvider('feinimoshu','RefillCallBack'); $ret = $provider->verify($params); $this->assertTrue($ret,'Verify is OK'); $provider->notify($params); } private function getProvider($name,$type = 'RefillPhone') { $file = BASE_HELPER_RAPI_PATH . "/$name/{$type}.php"; if(!file_exists($file)){ Log::record("provider api file={$file} not exist.",Log::DEBUG); return false; } else { require_once($file); Log::record("file={$file} load success.",Log::DEBUG); } $class_name = "refill\\{$name}\\{$type}"; if (class_exists($class_name, false)) { $caller = new $class_name([]); return $caller; } else { $error = "Base Error: class {$class_name} isn't exists!"; Log::record($error, Log::ERR); return false; } } public function testCallBack() { $body = '{"AppKey":"211394658","TimesTamp":"1620987358973","MOrderID":"7088040674302538334319","OrderID":"210514101558013001","State":"2","ChargeAccount":"403149064","Version":"1.0","BuyCount":"5","Attach":"","Sign":"BF8D2895A6C214931A511AE12EB9E8EE"}'; $params = json_decode($body, true); refill\RefillFactory::instance()->notify('sctongqian', $params); } public function testInstance() { refill\RefillFactory::instance()->notify_merchant(1,false); } public function testEncrypt() { $mod_mch = Model('merchant'); $mch_info = $mod_mch->getMerchant(9618); $mod_third = Model('thrid_refill'); $thrid_info = $mod_third->getThird(6244720); if (!empty($mch_info) && !empty($thrid_info)) { $card_info = $thrid_info['card_info']; if (!empty($card_info)) { $passwd = $mch_info['secure_key']; $encrypt = openssl_encrypt($card_info,'AES-128-CBC',$passwd); if($encrypt != false) { $params['card_info'] = $encrypt; } $output = openssl_decrypt($encrypt, 'AES-128-CBC', $passwd); } } } public function testZanzan() { $providers = $this->getProvider('zanzan','RefillPhone'); // $order_sn = $this->make_sn(); // [$state, $ch_order, $neterr] = $providers->add(13911129867, 5, 100, ['order_sn' => $order_sn]); // [$state, $ch_order, $neterr] = $providers->add(18500608333, 5, 100, ['order_sn' => $order_sn]); $providers->query(['ch_trade_no' => '','order_sn' => '4599550676464663945778']); } public function testSuning() { $providers = $this->getProvider('suning','RefillPhone'); $providers->mStoreID = 61; $order_sn = $this->make_sn(); $resp = $providers->add(14011221111, 7, 1, ['order_sn' => $order_sn, 'goods_id' => 6619, 'quantity' => 5, 'product_code' => 'XYZ100745', 'third_card_type' => 1]); } public function testSuningCardKey() { $providers = $this->getProvider('suning','RefillPhone'); $providers->mStoreID = 61; $order_sn = $this->make_sn(); $resp = $providers->add('', 7, 1, ['order_sn' => $order_sn, 'goods_id' => 6619, 'quantity' => 5, 'product_code' => 'XYZ100745', 'third_card_type' => 1]); } }