123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <?php
- use PHPUnit\Framework\TestCase;
- use refill\lingzhdl\config;
- use function aop\stripPKSC7Padding;
- define('APP_ID', 'test');
- define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/global.php');
- require_once(BASE_CORE_PATH . '/lrlz.php');
- require_once(BASE_ROOT_PATH . '/fooder.php');
- require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
- require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
- class TestRefillThird extends TestCase
- {
- public static function setUpBeforeClass(): void
- {
- Base::run_util();
- }
- public function testProvider()
- {
- $provider = new refill\ProviderManager();
- $provider->load();
- }
- public function testAddthird()
- {
- }
- 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 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 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]);
- // $resp = $providers->query(['order_sn' => '59911615124025101286']);
- // $input['usr'] = 1;
- // $input['ord'] = '52741615119546453690';
- // $input['bz'] = '';
- // $input['state'] = 2;
- // $input['sgn'] = 'FFCBB75C307154DD306F4EC75BB69A6D';
- // refill\RefillFactory::instance()->notify('lingzhthird',$input);
- }
- private function getProvider($name)
- {
- $file = BASE_HELPER_RAPI_PATH . "/$name/RefillPhone.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}\\RefillPhone";
- 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);
- }
- }
- }
- }
|