Browse Source

for yifa api callback

stanley-king 4 years ago
parent
commit
263fcf7916
2 changed files with 36 additions and 23 deletions
  1. 5 6
      helper/refill/yifa/RefillCallBack.php
  2. 31 17
      test/TestRefill.php

+ 5 - 6
helper/refill/yifa/RefillCallBack.php

@@ -12,7 +12,10 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $sign = $this->sign($params);
+        $input = $params;
+        unset($input['sign']);
+
+        $sign = $this->sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -26,11 +29,7 @@ class RefillCallBack implements refill\IRefillCallBack
 
         $app_secret = config::APP_SECRET;
         $content = $app_secret;
-        foreach ($params as $key => $val)
-        {
-            if(empty($val)){
-                continue;
-            }
+        foreach ($params as $key => $val) {
             $content .= "{$key}{$val}";
         }
         $content .= $app_secret;

+ 31 - 17
test/TestRefill.php

@@ -17,7 +17,7 @@ require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
 const LocalTest = 1;
 const NetTest = 2;
 
-const CurrentTest = NetTest;
+const CurrentTest = LocalTest;
 
 class TestRefill extends TestCase
 {
@@ -82,25 +82,39 @@ class TestRefill extends TestCase
         }
     }
 
-    public function testXcPhone(){
+    public function testXcPhone()
+    {
         $providers = new refill\xc\RefillPhone([]);
         $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
     }
 
-    public function testYifaPhone(){
+    public function testYifaPhone()
+    {
         $providers = new refill\yifa\RefillPhone([]);
         $resp = $providers->add(15120035568, 5, 100, ['order_sn' => $this->make_sn()]);
     }
 
-    public function testXcQuery(){
+    public function testYifaCB()
+    {
+        $body = '{"app_id":"e4a61b2acf1119c72c1ed9b61781494e","nonce_str":"OQMEBRQWJGPKOWYUXDVPTNMLEQJHXFWG","timestamp":1610275083,"order_sn":"161027325773032634","coder_order_sn":"60641610273255214687","isp_order_sn":null,"phone":"15120035568","amount":"94.000","discount":"0.9400","create_time":"2021-01-10 18:07:42","recharge_time":"","status":"fail","channel_id":3,"sign":"47278AD74EFA7F5FC8DE3A6D362C409B"}';
+//        $resp = http_post_data($this->mReqHost . "/mobile/refill_yifa.php", $body);
+
+//        $content = $_SERVER['post_content'];
+        $input = json_decode($body,true);
+        refill\RefillFactory::instance()->notify('yifa',$input);
+    }
+
+    public function testXcQuery()
+    {
         $providers = new refill\xc\RefillPhone([]);
-        $refill_info = ['order_sn' => 950663423236726632 , 'ch_trade_no' => 499 , 'card_no' => 	1000111200005252927	];
+        $refill_info = ['order_sn' => 950663423236726632, 'ch_trade_no' => 499, 'card_no' => 1000111200005252927];
         $resp = $providers->query($refill_info);
     }
 
-    public function testSuhcQuery(){
+    public function testSuhcQuery()
+    {
         $providers = new refill\suhctm\RefillOil([]);
-        $refill_info = ['order_sn' => 950663423236726632 , 'ch_trade_no' => 499 , 'card_no' => 	1000111200005252927	];
+        $refill_info = ['order_sn' => 950663423236726632, 'ch_trade_no' => 499, 'card_no' => 1000111200005252927];
         $resp = $providers->query($refill_info);
     }
 
@@ -113,13 +127,13 @@ class TestRefill extends TestCase
     public function testBdtOil()
     {
         $providers = new refill\bdt\RefillOil([]);
-        $resp = $providers->add(1000111100021211884,2,100,['order_sn' => '200229600556618886']);
+        $resp = $providers->add(1000111100021211884, 2, 100, ['order_sn' => '200229600556618886']);
     }
 
     public function testJiecPhone()
     {
         $providers = new refill\jiec\RefillPhone([]);
-        $resp = $providers->add('15120035568',2,100,['order_sn' => $this->make_sn()]);
+        $resp = $providers->add('15120035568', 2, 100, ['order_sn' => $this->make_sn()]);
     }
 
     public function testBxtwtCB()
@@ -251,12 +265,12 @@ class TestRefill extends TestCase
         $params = ['mchid' => 1090,
             'cardno' => $phone,
             'amount' => $amount,
-            "act"=>"refill",
-            "op"=>"add",
+            "act" => "refill",
+            "op" => "add",
             'order_sn' => $this->make_sn(),
-            'notifyurl'=> "https://qzcz.edusahoo.com.cn/index/index/callback"];
-         $proxy = new refill_proxy("ZhongFKJZhongFKJZhongFKJ");
-         $resp = $proxy->send($url,$params);
+            'notifyurl' => "https://qzcz.edusahoo.com.cn/index/index/callback"];
+        $proxy = new refill_proxy("ZhongFKJZhongFKJZhongFKJ");
+        $resp = $proxy->send($url, $params);
     }
 
     public function testGoods()
@@ -533,13 +547,13 @@ class TestRefill extends TestCase
 
     public function testRefillInnerCB()
     {
-        $params = ['state_type' => 'order_cancel','order_id' => 311,'channel_name' => 'lx'];
-        $resp = http_request(BASE_SITE_URL . '/mobile/refill_inner.php',$params,'POST');
+        $params = ['state_type' => 'order_cancel', 'order_id' => 311, 'channel_name' => 'lx'];
+        $resp = http_request(BASE_SITE_URL . '/mobile/refill_inner.php', $params, 'POST');
     }
 
     public function testArgs()
     {
-        Log::record($_SERVER['argv'],Log::DEBUG);
+        Log::record($_SERVER['argv'], Log::DEBUG);
     }
 
     public function testCall()