리다이렉트 URL이 등록되지 않았습니다. 개발정보 페이지에서 등록해주세요.
지금 브랜드 페이 연동 하는데 카드 등록하면 brandpay:1 POST https://api.tosspayments.com/v1/connectpay/authorizations 400
Uncaught (in promise) Error: 리다이렉트 URL이 등록되지 않았습니다. 개발정보 페이지에서 등록해주세요.
at XMLHttpRequest.<anonymous> (brandpay:1:36386) 이와 같은 에러나 납니다
21 Replies
⏳ 잠시만 기다려주세요! 곧 답변드리겠습니다
오류 문의일 경우 아래 정보를 미리 전달해주시면, 빠른 답변에 도움이 됩니다.
- 주문번호(orderId) :
- 문의 내용 :
(img를 함께 첨부해주시면 도움이됩니다)
* 계약관련 내용은 1544-7772로 문의주세요.
* 주말/공휴일에는 답변이 늦을 수 있어요.
개발자센터에 리다이렉트URL 등록 하셨을까요?
네 등록 했습니다
로그 하고 설정 확인 해드릴게요
어떤 MID 에 등록 하셨나요?
아니면 어떤 이메일로 로그인 해서 등록 하셨나요?
MID 어디서 확인 할수 있나요 ?
MID 모르시면, 가입한 이메일 알려주세요
kgm1019@omnicn.co.kr 입니다
shop/callback 으로 끝나는 URL 로 정보를 보내면, 토큰 발급 API 호출하고 계시는 것이 맞을까요?
접근해보면, 위젯 화면이 바로 보이는것 같아서요
위젯 화면을 출력하는 화면이고 shop/confirm_payment 받는걸 구현 했습니다
public function confirm_payment(){
$clientKey = "test_ck_jZ61JOxRQVExOGdEEwg3W0X9bAqw" ;
$secretKey = "test_sk_Z0RnYX2w5321KMGE7yl8NeyqApQE";
$redirectUrl = base_url()."shop/callback";
$data = file_get_contents("php://input");
$jsonData = json_decode($data, true);
$paymentKey = $jsonData['paymentKey'];
$orderId = $jsonData['orderId'];
$amount = $jsonData['amount'];
$customerKey = $jsonData['customerKey'];
$credential = base64_encode($secretKey . ':');
$url = 'https://api.tosspayments.com/v1/brandpay/payments/confirm';
$data = ['orderId' => $orderId, 'amount' => $amount, 'paymentKey'=>$paymentKey,'customerKey'=>$customerKey];
$curl = curl_init($url);
curl_setopt_array($curl, [
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => [
'Authorization: Basic ' . $credential,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($data)
]);
$response = curl_exec($curl);
$err = curl_error($curl);
echo $response;
}
이렇게
아 저는 access token 발급 API 부분을 여쭤본거기는 합니다
리다이렉트 URL 로 저희가 데이터를 보내드리면,
해당 데이터를 parse 해서 access token 발급 API 를 호출하셔야 하는데요
그 부분이 어떻게 구현 되어 있는지 궁금해서요
구현이 안되어 있는거 같습니다
아하 그렇군요
그 부분을 구현 하셔야 합니다
이부분 한번 참고 부탁 드립니다
https://{ORIGIN}/auth?code={CODE}&customerKey={CUSTOMER_KEY}
이렇게 데이터를 보내드립니다
code 하고 customerKey 를 parse 해서, 토큰발급 API 호출 해주시면 됩니다
❤️ 기술문의 경험이 어떠셨나요?!
간단히 코멘트 남겨주세요! 제품 발전에 큰 힘이 됩니다.
public function confirm_payment(){
$clientKey = "test_ck_jZ61JOxRQVExOGdEEwg3W0X9bAqw" ;
$secretKey = "test_sk_Z0RnYX2w5321KMGE7yl8NeyqApQE";
$redirectUrl = base_url()."shop/confirm_payment";
$data = file_get_contents("php://input");
$jsonData = json_decode($data, true);
$paymentKey = $jsonData['paymentKey'];
$orderId = $jsonData['orderId'];
$amount = $jsonData['amount'];
$customerKey = $jsonData['customerKey'];
$credential = base64_encode($secretKey . ':');
$url = 'https://api.tosspayments.com/v1/brandpay/payments/confirm';
$data = ['orderId' => $orderId, 'amount' => $amount, 'paymentKey'=>$paymentKey,'customerKey'=>$customerKey];
$curl = curl_init($url);
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tosspayments.com/v1/brandpay/authorizations/access-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{"grantType":"AuthorizationCode","code":"92LAa5PVblWx6Ad5J87YmpXy","customerKey":"MEk0xNNagUe38LTVA7h4k"}",
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => [
'Authorization: Basic ' . $credential,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($data)
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
}
이런식으로 구현 했는데
brandpay:1 Uncaught (in promise) Error: 최대 요청횟수를 초과했습니다.
이런 에러가 납니다
{"grantType":"AuthorizationCode","code":"92LAa5PVblWx6Ad5J87YmpXy","customerKey":"MEk0xNNagUe38LTVA7h4k"}",
code 와 customerkey 는 저희가 redirectURL 로 querystring 으로 보내드린 값으로 요청을 해주셔야 합니다.
상점관리자세 설정한 redirectUrl 로 저희가 값을 보내드리는데요
query string param 방식으로 보내드리고 있어요
그러니까,
설정한 URL 이 "https://www.test.com/shop/webhook" 이면
저희가 값을
"https://www.test.com/shop/webhook?code={CODE}&customerKey={CUSTOMER_KEY}"
이렇게 보내고 있다는 의미 입니다.
고로, URL 에서 code, customerKey 를 추출해서, 그 값으로 코드발급 API 를 호출 해야 합니다
아 감사합니다