ddurrummer
TPToss payments 개발자 커뮤니티
•Created by ddurrummer on 8/22/2024 in #❓┃연동개발-문의
SyntaxError: The string did not match the expected pattern.
php(ver.5.2.17) 로 결제 위젯을 연동하고 있습니다.
success.php 통해서 confirm.php를 다녀오면 화면은 결제성공으로 가는데
결제는 정상진행 되지 않고 있으며 아래와 같은 콘솔로그가 발견됩니다.
Unhandled Promise Rejection: SyntaxError: The string did not match the expected pattern.
위 오류를 클릭해보면 다음에 소스를 가리키고 있습니다.
const json = await response.json();
여기서 오류내용들을 검색해서 confirm.php 소스의
$data = ['aaa'=>''... 이부분은 버전에 맞게 $data = array('aaa'=>".... 이러한 형식으로 변경하였는데요 동일한 오류가 발견됩니다.ㅠ
소스는 다음과 같습니다. 도움 부탁드립니다.
$url = 'https://api.tosspayments.com/v1/payments/confirm';
$data = array('paymentKey' => $paymentKey, 'orderId' => $orderId, 'amount' => $amount);
$curlHandle = curl_init($url);
curl_setopt_array($curlHandle, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Authorization: Basic ' . $credential,
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($data)
));
$response = curl_exec($curlHandle);
$httpCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
39 replies