현금영수증 INVALID_REQUIRED_PARAM 에러
php 환경이고, 시크릿키를 제대로 넣어도 에러, 샘플코드 그대로 복사 붙이기 해도 에러가 납니다.
{"code":"INVALID_REQUIRED_PARAM","message":"필수 파라미터가 누락되었습니다."}
아래는 토스 개발자 센터에서 제공하는 소스 그대로 입니다.
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tosspayments.com/v1/cash-receipts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 15000,
'orderId' => 'a4CWyWY5m89PNh7xJwhk1',
'orderName' => '토스 티셔츠 외 2건',
'customerIdentityNumber' => '01012341234',
'type' => '소득공제'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic 시크릿키(채널공유가 안된다고 지웠습니다)",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{"code":"INVALID_REQUIRED_PARAM","message":"필수 파라미터가 누락되었습니다."}
아래는 토스 개발자 센터에서 제공하는 소스 그대로 입니다.
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tosspayments.com/v1/cash-receipts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 15000,
'orderId' => 'a4CWyWY5m89PNh7xJwhk1',
'orderName' => '토스 티셔츠 외 2건',
'customerIdentityNumber' => '01012341234',
'type' => '소득공제'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic 시크릿키(채널공유가 안된다고 지웠습니다)",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
