How to receive the Webhook call for toss in local environment?

I am working on an implementation for Toss Payment SDK. I have implemented the order placement, confirm API and cancel API call. Also, I have configured the Webhook and pointing to my local environment for development & debugging. I am not receiving any webhook calls to my local environment. Would you be able to assist me on this?
40 Replies
토스페이먼츠 BOT
⏳ 잠시만 기다려주세요! 곧 답변드리겠습니다
오류 문의일 경우 아래 정보를 미리 전달해주시면, 빠른 답변에 도움이 됩니다.
- 주문번호(orderId) : - 문의 내용 :
(img를 함께 첨부해주시면 도움이됩니다)
* 계약관련 내용은 1544-7772로 문의주세요. * 주말/공휴일에는 답변이 늦을 수 있어요.
이실장
이실장4w ago
Are you working for Korean company? Did you have our developer center account which connected to your company information?
이실장
이실장4w ago
What is your merchantId? If you dont' know what is merchantId plz share your url after you login to your developer center
pankaj.mahapatra@gspann.com
The Webhooks working fine now, the issue was authentication.
Ayaan
Ayaan3w ago
Thanks for sharing. We're glad the problem has been resolved.
pankaj.mahapatra@gspann.com
I have one more doubt, I am executing cancel API call for one of the order. However, I am getting below error. Could you please confirm why it is happening? I have given proper accountNumber for that order. Response: { "code": "INVALID_REFUND_ACCOUNT_NUMBER", "message": "잘못된 환불 계좌번호입니다." } Request: {"cancelReason":"Customer wants refund","cancelAmount":"390000","refundReceiveAccount":{"bank":"31","accountNumber":"X600802567548","holderName":"Pankaj"},"taxFreeAmount":0,"currency":"KRW","refundableAmount":"390000","paymentKey":"tmcmk202409031930224rlW8”}
Ayaan
Ayaan3w ago
@pankaj.mahapatra@gspann.com First of all, Please make sure your server uses UTF-8, not ANSI or EUC-KR; your response was:
{
"code": "INVALID_REFUND_ACCOUNT_NUMBER",
"message": "잘못된 환불 계좌번호입니다."
}
{
"code": "INVALID_REFUND_ACCOUNT_NUMBER",
"message": "잘못된 환불 계좌번호입니다."
}
As you can see the code is INVALID REFUND ACCOUNT NUMBER. It is sent when accountNumber field on request is malformed. Why do you send the account number starts with "X"? It should be numbers.
pankaj.mahapatra@gspann.com
Hi @Ayaan - I am using UTF-8 only and my account number is starts with X because when we place the order and execure Confirm API I get below response for that Order. And for the same order only I am using the account number to refund, please find the below response for the same -
pankaj.mahapatra@gspann.com
{ "mId": "tmcmkorea2022", "lastTransactionKey": "203E0D3BE12BE298CBC4BEA5851F379A", "paymentKey": "tmcmk202409031930224rlW8", "orderId": "00001503", "orderName": "비세토스 오리지널 콘티넨털 지갑", "taxExemptionAmount": 0, "status": "WAITING_FOR_DEPOSIT", "requestedAt": "2024-09-03T19:30:22+09:00", "approvedAt": null, "useEscrow": false, "cultureExpense": false, "card": null, "virtualAccount": { "accountNumber": "X600802567548", "accountType": "일반", "bankCode": "31", "customerName": "Pankaj", "dueDate": "2024-09-10T19:30:21+09:00", "expired": false, "settlementStatus": "INCOMPLETED", "refundStatus": "NONE", "refundReceiveAccount": null }, "transfer": null, "mobilePhone": null, "giftCertificate": null, "cashReceipt": { "type": "소득공제", "receiptKey": "AK6k75XwlOyL0qZ4G1VOLvY4yOQl7vroWb2MQYgmBDPdR9px", "issueNumber": "", "receiptUrl": "https://dashboard.tosspayments.com/receipts/cash-receipt/00001503/tmcmkorea2022?ref=PX", "amount": 390000, "taxFreeAmount": 0 }, "cashReceipts": null, "discount": null, "cancels": null, "secret": "ps_Ba5PzR0ArnJOAoQ9oLdNrvmYnNeD", "type": "NORMAL", "easyPay": null, "country": "KR", "failure": null, "isPartialCancelable": true, "receipt": { "url": "https://pgweb.tosspayments.com:9091/MpFlowCtrl?eventDiv1=search&eventDiv2=getCasReceiptList&trxid=tmcmk202409031930224rlW8&SYSTEM=NEW" }, "checkout": { "url": "https://api.tosspayments.com/v1/payments/tmcmk202409031930224rlW8/checkout" }, "currency": "KRW", "totalAmount": 390000, "balanceAmount": 390000, "suppliedAmount": 354545, "vat": 35455, "taxFreeAmount": 0, "method": "가상계좌", "version": "2022-11-16", "metadata": null }
Ayaan
Ayaan3w ago
@pankaj.mahapatra@gspann.com You should get accountNumber from your customer. "X600802567548" is the account number that needs to be transfered(paid) from customer. On cancel API, Toss needs to transfer back to customer, and refundReceiveAccount is used for this.
pankaj.mahapatra@gspann.com
Customer means here 'Merchant' or 'End User'? In the above Confirm API response, how do I get to know the Customer Account number in order to initiate Cancel API?
Ayaan
Ayaan3w ago
Ok, let me explain to you step-by-step. First, the store receives payment from the customer (end user). When calling the Confirm API, an accountNumber is received. ("X600802567548") The payment is completed when the customer deposits the money with this account number, "X600802567548". When canceling/refunding, the exact opposite happens. When calling the Cancel API, the customer(end user)'s accountNumber is sent to the refundAccountNumber. You can request this separately from the customer, or if you use a payment widget, you can create a UI that receives the input when the payment is first received. After the cancellation is completed, the money is deposited to the refundAccountNumber entered by Toss Payments, and the refund is completed. At this point, you can see why you received that error. You need to pass the customer's account number to receive the refund, but you are sending the account number of the merchant where the customer should pay(which is accountNumber transmitted on confirm API, "X600802567548"), so that is why you received that error. @pankaj.mahapatra@gspann.com
pankaj.mahapatra@gspann.com
We are in Development phase of Confirm and Cancel API. So, in test environment, can we use any random account number in order to successfully refund? Also, I have one more doubt, you mentioned, The payment is completed when the customer deposits the money with this account number, "X600802567548". So, once customer deposit the amount, how Toss will get to know and complete the payment? Is it through Webhook the integrated platform will get to know that payment is completed successfully and we can now proceed to export the order.
Ayaan
Ayaan3w ago
I don't think so. Do you have Korean employee on your company? If so, use account number for them. Bank informs Toss that customer have paid. After Toss had informed by bank, Toss sends webhook to your system. https://docs.tosspayments.com/guides/v2/webhook This is a documentation and specification of Webhook from Toss to your system. FYI: Please use Google Translate on Chrome if you're not fluent at Korean. Or use this: https://docs.tosspayments.com/en/webhooks