|
|
@@ -4,6 +4,8 @@ namespace App\Services\Payment;
|
|
|
|
|
|
use App\Services\BaseService;
|
|
|
use GuzzleHttp\Client;
|
|
|
+use GuzzleHttp\Exception\RequestException;
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
class NoPayService extends BaseService
|
|
|
{
|
|
|
@@ -162,16 +164,56 @@ class NoPayService extends BaseService
|
|
|
|
|
|
private static function post(string $url, array $data, string $merchantId): array
|
|
|
{
|
|
|
- $response = (new Client(['timeout' => 10.0]))->post($url, [
|
|
|
- 'json' => $data,
|
|
|
- 'headers' => [
|
|
|
- 'Accept' => 'application/json',
|
|
|
- 'appId' => $merchantId,
|
|
|
- 'language' => 'zh_CN',
|
|
|
- ],
|
|
|
+ $logData = $data;
|
|
|
+ unset($logData['sign'], $logData['password']);
|
|
|
+
|
|
|
+ Log::info('NO钱包接口请求', [
|
|
|
+ 'url' => $url,
|
|
|
+ 'merchant_id' => $merchantId,
|
|
|
+ 'data' => $logData,
|
|
|
]);
|
|
|
|
|
|
- return json_decode($response->getBody()->getContents(), true) ?: [];
|
|
|
+ try {
|
|
|
+ $response = (new Client(['timeout' => 10.0]))->post($url, [
|
|
|
+ 'json' => $data,
|
|
|
+ 'headers' => [
|
|
|
+ 'Accept' => 'application/json',
|
|
|
+ 'appId' => $merchantId,
|
|
|
+ 'language' => 'zh_CN',
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+ $body = $response->getBody()->getContents();
|
|
|
+
|
|
|
+ Log::info('NO钱包接口响应', [
|
|
|
+ 'url' => $url,
|
|
|
+ 'merchant_id' => $merchantId,
|
|
|
+ 'http_status' => $response->getStatusCode(),
|
|
|
+ 'body' => $body,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return json_decode($body, true) ?: [];
|
|
|
+ } catch (RequestException $e) {
|
|
|
+ $response = $e->getResponse();
|
|
|
+ $body = $response ? $response->getBody()->getContents() : '';
|
|
|
+
|
|
|
+ Log::error('NO钱包接口请求失败', [
|
|
|
+ 'url' => $url,
|
|
|
+ 'merchant_id' => $merchantId,
|
|
|
+ 'http_status' => $response ? $response->getStatusCode() : null,
|
|
|
+ 'body' => $body,
|
|
|
+ 'error' => $e->getMessage(),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ throw $e;
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ Log::error('NO钱包接口异常', [
|
|
|
+ 'url' => $url,
|
|
|
+ 'merchant_id' => $merchantId,
|
|
|
+ 'error' => $e->getMessage(),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ throw $e;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static function getWhere(array $search = []): array
|