Browse Source

准备接入hitpay

lizhen_gitee 1 year ago
parent
commit
0bb9df64c2

+ 24 - 2
application/api/controller/Demo.php

@@ -3,7 +3,7 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
-
+require_once '../vendor/autoload.php';
 /**
  * 示例接口
  */
@@ -40,7 +40,29 @@ class Demo extends Api
      */
     public function test()
     {
-        $this->success('返回成功', $this->request->param());
+        $apiKey = '096a06e94fb1e0a8b015485bb76ef5dd63c167679297e07331a687327bd8b12e';
+        $salt   = 'LNrFYxOiGhtdHAuJiqqy3wOl1nVwyJn5dfOYkLquFx8j2J6bm2nsplTnpkYuKyo5';
+
+        $hitPayClient = new \HitPay\Client($apiKey, false);
+
+        try {
+            $request = new \HitPay\Request\CreatePayment();
+
+            $request->setAmount(66)
+                ->setCurrency('SGD');
+            $result = $hitPayClient->createPayment($request);
+
+            print_r($result);
+
+            $data = $hitPayClient->getPaymentStatus($result->getId());
+            print_r($data);
+
+            $data = $hitPayClient->deletePaymentRequest($data->getId());
+            print_r($data);
+
+        } catch (\Exception $e) {
+            print_r($e->getMessage());
+        }
     }
 
     /**

+ 1 - 1
application/api/library/ExceptionHandle.php

@@ -14,7 +14,7 @@ class ExceptionHandle extends Handle
 
     public function render(Exception $e)
     {
-        //return parent::render($e);
+        return parent::render($e);
         $statuscode = $code = 500;
         $msg = $e->getMessage();
         // 验证异常

+ 5 - 0
application/common/controller/Api.php

@@ -69,6 +69,11 @@ class Api
     protected $lang = 'CN';
 
     /**
+     * @var int 日志类型 1 文件;2sql
+     */
+    public $logType = 2;
+
+    /**
      * 构造方法
      * @access public
      * @param Request $request Request 对象

+ 5 - 0
application/config.php

@@ -322,4 +322,9 @@ return [
 
     //图片地址
     'domain_cdnurl' => 'http://www.yueke.com',
+
+    'hitpay' => [
+        'apikey' => '096a06e94fb1e0a8b015485bb76ef5dd63c167679297e07331a687327bd8b12e',
+        'salt' => 'LNrFYxOiGhtdHAuJiqqy3wOl1nVwyJn5dfOYkLquFx8j2J6bm2nsplTnpkYuKyo5',
+    ]
 ];