liugc 11 місяців тому
батько
коміт
3752984ab1
2 змінених файлів з 10 додано та 7 видалено
  1. 4 4
      app/api/service/DouYinService.php
  2. 6 3
      config/douyin.php

+ 4 - 4
app/api/service/DouYinService.php

@@ -486,7 +486,7 @@ class DouYinService
         return $str;
     }
     public static function getClientToken() {
-        $url = 'https://open.douyin.com/oauth/client_token/';
+        $url = config('douyin.host').'oauth/client_token/';
         $cache_name = 'dy_client_token';
         $cache_data = cache($cache_name);
         if(empty($cache_data) || $cache_data == null){
@@ -517,7 +517,7 @@ class DouYinService
 
                 //通过后向抖音申请退款
                 //getClientToken()
-                $url = 'https://open.douyin.com/api/trade_basic/v1/developer/refund_create/';
+                $url = config('douyin.host').'api/trade_basic/v1/developer/refund_create/';
                 $data = [
                     "order_id" => $orderInfo['transaction_id'],
                     "out_refund_no" => $douyinRefundOrder->refund_number,
@@ -527,7 +527,7 @@ class DouYinService
                         "params" => json_encode(['refund_number'=>$douyinRefundOrder->refund_number])
                     ],
                     "refund_total_amount " => $douyinRefundOrder->refund_amount * 100,
-                    //"notify_url" => "https://xxx",
+                    "notify_url" => config('douyin.refundNotifyUrl'),
                     "refund_reason" => [
                         [
                             "code" => 101,
@@ -535,7 +535,7 @@ class DouYinService
                         ]
                     ]
                 ];
-                $res = http_request($url,json_encode($data));
+                $res = http_request($url,$data,['Content-Type' => 'application/json;charset=utf-8','access_token' => self::getClientToken()]);
                 if(isset($res['err_msg']) && $res['err_msg'] === 'success'){
                     $douyinRefundOrder->transaction_id = $res['data']['refund_id'];
                     $douyinRefundOrder->save();

+ 6 - 3
config/douyin.php

@@ -1,9 +1,12 @@
 <?php
 
 return [
-    'appId' => 'tt4dc83b75d2c06f6301',
-    'appSecret' => '4a043ceb98f9c05607c6ed39cdbdcb33c6f23a75',
-    'payNotifyUrl' => env('PAY_NOTIFY_URL')?:'https://weixiudev.kyjlkj.com/api/dou_yin/payNotify',
+    'appId' => env('douyin.app_id')?:'tt74fb0246ebf34b0601',
+    'appSecret' => env('douyin.app_secret')?:'0c841cc324e8bea8a584d248556d6263fb2dadb2',
+    'host' => env('douyin.dy_host')?:'https://open.douyin.com/',
+    'payNotifyUrl' => env('douyin.pay_notify_url')?:'https://weixiu.kyjlkj.com/api/dou_yin/payNotify',
+    'refundNotifyUrl' => env('douyin.refund_notify_url')?:'https://weixiu.kyjlkj.com/api/dou_yin/refundNotify',
+    'goodsNotifyUrl' => env('douyin.goods_notify_url')?:'https://weixiu.kyjlkj.com/api/dou_yin/goodsNotify',
 
     'privateKeyStr' => "-----BEGIN RSA PRIVATE KEY-----
 MIIEpQIBAAKCAQEA3QB2NX+vsNbn1RSFd7LLI7zXkUDpVo1kFHntQ5rlPie3fEtd