#Does "requestPayment" method have promise? and return orderId,paymentKey & amount?

1 messages · Page 1 of 1 (latest)

dawn gate
#

Hi Support & @grave cloud!

I need to know that, can i use ".then" & ".catch" with requestPayment method? Please suggest! Thanks

dusky harnessBOT
#
⏳ 잠시만 기다려주세요! 곧 답변드리겠습니다

오류 문의일 경우 아래 정보를 미리 전달해주시면, 빠른 답변에 도움이 됩니다.

- 주문번호(orderId) : - 문의 내용 :

(img를 함께 첨부해주시면 도움이됩니다)

grave cloud
#

Hi @dawn gate!

Absolutely! You can use .then() and .catch() with requestPayment method, as method returns Promise.
Just handle the method like when you handle Promise.

dawn gate
#

Thank you @grave cloud 👍

Yes i have verified & both worked with v1. Does these also works with v2?

grave cloud
#

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

dawn gate
#

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

{
    "paymentKey": "tviva202411131429345nE24",
    "orderId": "rfMtsUySPv5CBPftWLc_1",
    "amount": 15600
}
grave cloud
#

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().

dawn gate
#

But I've seen that "successUrl" & "failUrl" parameters are optional in official documentation.

is it mandatory to pass these parameters?

grave cloud
grave cloud
dawn gate
#

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)

grave cloud
dawn gate
#

It is optional, only in PC. Not Mobile.

Does this mean mobile browser OR mobile App?

grave cloud
dawn gate
#

Hmmm... 🤔

grave cloud
#

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.

dawn gate
#

Understood! Let me follow above & try!

Thank you for this help & detail briefing 🫡

grave cloud
grave cloud
#

Please follow up if you succeed or failed.

#

@dawn gate

dawn gate
#

@grave cloud Appreciate 🙏

dawn gate
grave cloud
dawn gate
#

Acknowledged!

grave cloud
#

@dawn gate 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

dawn gate
#

Hi @grave cloud,

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

tossPayments.requestPayment("CARD", {
  amount: wc_toss_params.cartAmount,
  orderId: wc_toss_params.orderId,
  orderName: wc_toss_params.cartItemsDesc,
  customerName: wc_toss_params.customerName,
  _skipAuth: 'FORCE_FAIL',
  successUrl: wc_add_to_cart_params.checkoutUrl,
  failUrl: wc_add_to_cart_params.checkoutUrl,
  customerEmail: document.getElementById('billing_email').value,
})
grave cloud
#

@dawn gate You only can use Promise (.then()) when you didn't sent the success/failUrl

dawn gate
#

Hi @grave cloud,
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!

grave cloud
#

@dawn gate Hi there, sorry for late reply

#

Could you please check Logs on Chrome Devtools and screenshot it for us?

dawn gate
grave cloud
#

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!!