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' => '93582250159', 'product_code' => 'XYZ100789', 'quantity' => 1 ]; $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 testPushAddZero() { $params = [ 'mchid' => 1092, 'buyer_id' => 60221, 'amount' => 30, 'mch_order' => $this->make_sn(), // 'org_quality' => 1, 'card_no' => '13911129867' ]; $ret = refill\util::push_add_zero($params); Log::record("push message",Log::DEBUG); } public function testPushPhone() { $params = [ 'mchid' => 1092, 'buyer_id' => 60221, 'amount' => 100, 'mch_order' => $this->make_sn(), // 'org_quality' => 1, 'card_no' => '13911129867' //, // 'card_type' => 5, // 'regin_no' => 1 ]; $ret = refill\util::push_add($params); Log::record("push message",Log::DEBUG); } //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillThird::testPushPhone)( .*)?$/" --test-suffix TestRefillThird.php /var/www/html/test public function testLittlePushPhones() { $time = time(); for ($i = 0; $i < 1000; $i++) { $params = [ 'mchid' => 1092, 'buyer_id' => 60221, 'amount' => 30, 'mch_order' => "{$time}" . sprintf("%'010d",$i), 'card_no' => '13911129867', 'card_type' => 5, 'regin_no' => 1, 'cardno_state' => 1, 'is_validate' => 1, 'is_transfer' => 1 ]; $ret = refill\util::push_add($params); Log::record("push message",Log::DEBUG); } //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillThird::testLittlePushPhones)( .*)?$/" --test-suffix TestRefillThird.php /var/www/html/test } public function testSlowPushPhones() { $sender = function () { $time = time(); for ($i = 0; $i < 100; $i++) { $params = [ 'mchid' => 1092, 'buyer_id' => 60221, 'amount' => 30, 'mch_order' => "{$time}" . sprintf("%'010d",$i), 'card_no' => '13911129867', 'card_type' => 5, 'regin_no' => 1, 'cardno_state' => 1, 'is_validate' => 1, 'is_transfer' => 1 ]; $ret = refill\util::push_add($params); Log::record("push message",Log::DEBUG); } }; for ($i = 0;$i < 100; $i++) { $sender(); sleep(2); } //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillThird::testSlowPushPhones)( .*)?$/" --test-suffix TestRefillThird.php /var/www/html/test } public function testPushPhones() { $time = time(); for ($i = 0; $i < 100000; $i++) { $params = [ 'mchid' => 1092, 'buyer_id' => 60221, 'amount' => 30, 'mch_order' => "{$time}" . sprintf("%'010d",$i), 'card_no' => '13911129867', 'card_type' => 5, 'regin_no' => 1, 'cardno_state' => 1, 'is_validate' => 1, 'is_transfer' => 1 ]; $ret = refill\util::push_add($params); Log::record("push message",Log::DEBUG); } //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillThird::testPushPhones)( .*)?$/" --test-suffix TestRefillThird.php /var/www/html/test } private function push_order($mchid,$member_id,$time,$index) { $params = [ 'mchid' => $mchid, 'buyer_id' => $member_id, 'amount' => 30, 'mch_order' => "{$time}" . sprintf("%'010d",$index), 'org_quality' => 13, 'card_no' => '13911129867' ]; $ret = refill\util::push_add($params); } public function testPushOtherPhones() { $time = time(); Log::record("push message start:{$time}",Log::DEBUG); for ($i = 0; $i < 10; $i++) { $this->push_order(1092,60221,$time,$i); // $this->push_order(1093,65771,$time,$i); // $this->push_order(1094,65772,$time,$i); // $this->push_order(1095,65773,$time,$i); // $this->push_order(1096,65774,$time,$i); } Log::record("push message end",Log::DEBUG); //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillThird::testPushOtherPhones)( .*)?$/" --test-suffix TestRefillThird.php /var/www/html/test } public function testPushLzThird() { $params = [ 'mchid' => 1092, 'buyer_id' => 60221, 'amount' => refill\util::ThirdRefillAmount, 'mch_order' => $this->make_sn(), 'notify_url' => '', 'org_quality' => 1, 'card_type' => mtopcard\ThirdRefillCard, 'card_no' => '13911129867', 'product_code' => 'DY_XYZ_30_LOW', 'quantity' => 1, 'third_card_type' => 1 ]; $ret = refill\util::push_addthird($params); } public function testXXX() { $thrid_refill = Model('thrid_refill'); $third_info = $thrid_refill->getThird(1140016178); $new_info = $thrid_refill->trans_order($third_info); } 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' => 'DY_XYZ_30_LOW', '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, 'card_no' => '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 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_hf','RefillPhone'); $order_sn = $this->make_sn(); // [$state, $ch_order, $neterr] = $providers->add(18500608333, 5, 30, ['order_sn' => $order_sn]); $providers->query(['order_sn' => '60711623734193929309']); } public function testFNMSCB() { $params = ['appid' => 'CZ30533982', 'order' => 'D20210616111088971260328', 'morder' => '1879340677155108772500', 'status' => '2', 'cash' => '30', 'vnum' => '110103308152106161039260597703', 'actual_cash' => '28.86', 'signature' => 'c3077297f26f6231eeaa31ccb8c16148']; $provider = $this->getProvider('feinimoshu_hf','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']); $resp = $providers->balance(); } 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]); } public function testSendMobile() { $phone = '13911129867'; $amount = 30; $url = "https://www.xyzshops.cn" . "/mobile/index.php"; $params = ['mchid' => 1092, 'cardno' => $phone, 'amount' => $amount, "act" => "refill", "op" => "add", 'order_sn' => $this->make_sn(), 'notifyurl' => "https://www.xyzshops.cn/signature.php"]; $proxy = new refill_proxy("210fe406954220f56085997d6a4c5b80"); $resp = $proxy->send($url, $params); } public function testLoad() { refill\RefillFactory::instance(); } public function testManualCancel() { $order_id = 87845887; try { $mod_order = Model('vr_order'); $logic_vr_order = Logic("vr_order"); $tran = new trans_wapper($mod_order,'manual_cancel state trans'); $order_info = $mod_order->getOrderInfo(['order_id' => $order_id],'*',true,true); $logic_vr_order->changeOrderStateCancel($order_info, '', "后台手动回调通知失败",true,true); $tran->commit(); return true; } catch (Exception $ex) { $tran->rollback(); Log::record("manual_cancel exception:{$ex->getMessage()}",Log::ERR); return false; } } public function testDingHui() { $content = 'method=order.charge.status.update.notify&format=json&sign=60d4e658cb730b9d8cc0c451414de9b51b79d14fa217261f7bbcf4a3472553b093a5c2377abba9573ed9d5e1a39a9f693830671ff1e641cc97a9782d2b2f393bed6a7bd22be0c642a13e20a7c6cf9f562c11ae65335758bd58ee55853b555cc2e511b6655c6e944a9defa6f0247263578d1554ff7709a7ced90db93911562dcb485518a4da3c21cb650ff01cacfcfa8dd9de533f5a5be2accc065e23cbd38b1b104e15feb3ce823c8cb7c7d5adf3fef0be768d8c25dc813a9112a14ec54a9e2ee517a5ba5b9ce2234dd4329b61c5456a82405aa6d2a307b4ec04be52bd1e3e5b204a2a4d7899d6fbf0fc09cd443cddc947f02bf58730142e9edc2b98eeeae086&message=GYmjEFMoy5jUfg%2FJu7NRCSyaoyg2fu9EWpABAHb55xKpkvIedqXPDqRwG6Lo7iNx0A2yc6%2FIaU7vqwNV9YEVZOwHBDtsGXuHK1GCq5KUaW70pq1wEKr6kgjAHDITH7XdB3jmdSAQFhQYTi5hCz5EWWAzRKLYgTZeDksePKshm67QDbJzr8hpTu%2BrA1X1gRVkVqAL750crFPclgeWEYFG4mO4ZlmqygUrgz4si%2BseZ3f0pq1wEKr6kgjAHDITH7XdkFLNHratZfufbZKIZ5r%2BCA%3D%3D&msgtype=notify_msg&version=V2.0&app_id=yeziapi¬ify_id=0000017c83f4786201547473800e31ee×tamp=1634301409378'; // $params = parse_url($content,PHP_URL_PATH); parse_str($content,$params); $provider = $this->getProvider('dinghui','RefillCallBack'); $ret = $provider->verify($params); $this->assertTrue($ret,'Verify is OK'); $provider->notify($params); } }