Does "requestPayment" method have promise? and return orderId,paymentKey & amount?
Hi Support & @Ayaan!
I need to know that, can i use ".then" & ".catch" with requestPayment method? Please suggest! Thanks
26 Replies
⏳ 잠시만 기다려주세요! 곧 답변드리겠습니다
오류 문의일 경우 아래 정보를 미리 전달해주시면, 빠른 답변에 도움이 됩니다.
- 주문번호(orderId) :
- 문의 내용 :
(img를 함께 첨부해주시면 도움이됩니다)
* 계약관련 내용은 1544-7772로 문의주세요.
* 주말/공휴일에는 답변이 늦을 수 있어요.
Hi @Arsalan!
Absolutely! You can use .then() and .catch() with requestPayment method, as method returns Promise.
Just handle the method like when you handle Promise.
Thank you @Ayaan 👍
Yes i have verified & both worked with v1. Does these also works with v2?
Not every methods are available on v2, because some of them deprecated or not implemented yet.
If you verified that works on v1, just keep use v1.
We won't deprecate v1
Appreciate! but i've instructed to use latest version.
All i need right now is, I want to catch these parameters via .then() & save these parameters to relative order & doesn't want to redirect to Success OR Fail URLs.
Can i do that with this library? https://js.tosspayments.com/v2/standard
Your needs cannot be performed either v1 or v2.
You can do it on PC environment, but it might not working on Mobile env due to browser security limitations (CORS, etc)
On PC, if you don't pass successUrl / failUrl to the requestPayment method, you will get the parameters that should passed to successUrl is returned as Promise. Hence, you can access those by .then().
But I've seen that "successUrl" & "failUrl" parameters are optional in official documentation.
is it mandatory to pass these parameters?
However on Mobile env, due to browser limitations, it should be redirected to 3DS page. Hence, you can't receive the parameters as Promise. That's why successUrl and failUrl is mandatory in this case.
It is optional, only in PC. Not Mobile.
On PC, if you don't pass successUrl / failUrl to the requestPayment method, you will get the parameters that should passed to successUrl is returned as Promise. Hence, you can access those by .then().Yes i've verified this & it works for me (using v1)
Also works in v2, only in PC.
It is optional, only in PC. Not Mobile.Does this mean mobile browser OR mobile App?
Because of this, on both versions, v1 and v2, now throws error when successUrl / failUrl is not passed if it is performed on mobile env.
Both.
Hmmm... 🤔
Try not to pass successUrl and failUrl in Mobile. It will throw the error, if I remember correctly...
Please kindly understand that this behaviour is from browser's security limitations. It is not Toss Payments' responsibility.
Understood! Let me follow above & try!
Thank you for this help & detail briefing 🫡
If you want more technical details for this behaviour,
The payment process is going through tosspayments.com to Card company's 3DS page (different domain). It causes CORS problem, and finally loses the session.
Thanks 🙏
Personally I highly recommend that use successUrl and failUrl on both device types. This really will make your life easier for implementing.
Please follow up if you succeed or failed.
@Arsalan
@Ayaan Appreciate 🙏
Can i use webhook to deal with this? in case i don't get response from .then()
No, because you should call the "confirm" API to make money out of customers.
After that, you can receive the webhook. so if you don't get response from .then() or successUrl, the transaction would not be happened.
Acknowledged!
@Arsalan Could you let me know what your needs exactly is?
Why you don't want to use successUrl? We will find out which way of implementing is right for you
Hi @Ayaan,
I've used below parameters with succesUrl & failUrl. but i got this error ""successUrl" 또는 "failUrl"을 넘긴 경우 Promise 방식을 지원하지 않습니다." why?
I am testing these parameters on desktop browser! Please suggest! Thanks
@Arsalan You only can use Promise (.then()) when you didn't sent the success/failUrl
Hi @Ayaan,
I've almost done & finished. Thanks for your help!
Its working fine at my localhost.
when i deploy it on my testing server. the toss payment library is not loading there.
https://js.tosspayments.com/v1/payment
please suggest!
@Arsalan Hi there, sorry for late reply
Could you please check Logs on Chrome Devtools and screenshot it for us?
Hi @Ayaan,
I am also sorry for delayed response. I just checked it right now!
I had resolved it & now library loads fine on all environments.
Also I've finished the integration. 🤝 Thanks alot for your help!
we may consider this thread as closed!
Thank you so much for follow up and I am very appreciated!
This ticket will be changed to closed, and please create a new thread if there are any further question came out!!