멜로투모로
멜로투모로11mo ago

Brand Pay Implementation Inquiry

Hi, We are a foreign business trying to make a shop in Korea. Google Translate did not seem to work in correctly translating the steps to the implementation. We are confused about the part of applying a redirect URI. We have the widget visible on our site (melotomorrow.com) but after inputting the card information, the widget spits out: "Uncaught (in promise) Error: The redirect URL is not registered. Please register on the development information page." We can speak a little Korean but not to the extent of following the guide. Thank you for your assistance.
65 Replies
Ayaan
Ayaan11mo ago
Good morning @멜로투모로, thank you for reach us. Unfortunately, our english documentation is quite limited, so we agree that you can get confusing at some point. You mentioned that Redirect URI setting part is confusing now, can you share little bit more about where you confusing now? Just to explain what we understand, redirectUrl must first be registered in our admin page. Otherwise you will get the same error as you got before. Thank you for using Toss Payments' service!
멜로투모로
멜로투모로OP11mo ago
Thank you so much for the reply! We understand that we have to register the redirectURL on our admin page. We don't understand what the redirect URL is and how to implement it in our code. On a side note, our company does not have a login function, so items are all purchased without logging in.
Ayaan
Ayaan11mo ago
Just for note, Brandpay is not suitable for websites that do not use a login process. So you may need to use different product of Tosspayments such as paymentWindow or paymentWidget.
Ayaan
Ayaan11mo ago
Redirecturl is needed for this process.
No description
Ayaan
Ayaan11mo ago
When the customer clicks the payment button on the website, they will be redirected to the Tosspayments website. After authorization is processed on the Tosspayments website, it will be redirected to you again for confirmation, DB logic, and other processing. At this time, you will need a Redirect URI that must be registered on the admin page. This is similar to how Oauth2.0 works.
멜로투모로
멜로투모로OP11mo ago
HI, we really need to start selling by the 31st. If we apply for paymentWindow or paymentWidget, would we be able to access the functions by then? Again, thank you so much for your assistance
멜로투모로
멜로투모로OP11mo ago
Also, with this brand pay, do we need to make our own authorization? We tried setting the redirect URI to https://google.com just to test it out, and it spit out this:
Google
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
멜로투모로
멜로투모로OP11mo ago
No description
Ayaan
Ayaan11mo ago
Let me explain which endpoint is needed. 1. Callback URL(Authorization Endpoint, as known as RedirectUrl) When a customer registers a payment method in the payment UI and agrees to the terms and conditions, they are redirected to the redirect URL registered in the developer center. Learn more When it redirects to callback URL, a temporary authentication code and customerKey are returned, as follows: https://{CALLBACK_URL}/?code={CODE}&customerKey={CUSTOMER_KEY} code: Authorization Code (temporary authentication code) required to issue an Access Token. It expires in 5 minutes. customerKey: The customer's unique ID created by your store (as known as user ID). As soon as you got authorization code and customerKey, you need to call our token endpoint (https://api.tosspayments.com/v1/brandpay/authorizations/access-token) which defined on OAuth 2.0 RFC rule. Learn more e.g.)
curl --request POST \
--url https://api.tosspayments.com/v1/brandpay/authorizations/access-token \
--header 'Authorization: Basic ENCODED_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data '{"grantType":"AuthorizationCode","customerKey":"CUSTOMER_KEY","code":"AUTHORIZATION_CODE"}'
curl --request POST \
--url https://api.tosspayments.com/v1/brandpay/authorizations/access-token \
--header 'Authorization: Basic ENCODED_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data '{"grantType":"AuthorizationCode","customerKey":"CUSTOMER_KEY","code":"AUTHORIZATION_CODE"}'
After your shop's server calls our token endpoint, you will get Access Token and Refresh Token as follows:
{
"accessToken": "ACCESS_TOKEN",
"refreshToken": "REFRESH_TOKEN",
"tokenType": "Bearer",
"expiresIn": 2592000
}
{
"accessToken": "ACCESS_TOKEN",
"refreshToken": "REFRESH_TOKEN",
"tokenType": "Bearer",
"expiresIn": 2592000
}
The SDK now automatically checks and uses the paying customer's Access Token. 2. Success URL(Success Confirm Endpoint) If the Access Token is successfully issued and the payment request is successful, it moves to the successUrl set as a parameter of requestPayment(). There are four query parameters after successUrl. The first parameter is paymentType. Since it is a Brand Pay payment, it returns to BRANDPAY. e.g.) https://{SUCCESS_URL}/?paymentType=BRANDPAY&paymentKey={PAYMENT_KEY}&orderId={ORDER_ID}&amount={AMOUNT} * paymentType: Payment type. Brand Pay payments are always BRANDPAY. * paymentKey: The key value of the payment. This is a unique value that identifies the payment. Payment data must be saved for management purposes. The value is maintained even if the payment status changes. Used for payment authorization. * orderId: Order ID. It serves to identify the ordered payment. It is a value created by the affiliated store and sent in requestPayment() when requesting payment. Payment data must be saved for management purposes. Must issue unique, non-duplicate values. The value is maintained even if the payment status changes. * amount: The amount actually paid. When it redirects to success URL and paymentType is BRANDPAY, call BrandPay confirm endpoint (https://api.tosspayments.com/v1/brandpay/payments/confirm). Learn more e.g.)
curl --request POST \
--url https://api.tosspayments.com/v1/brandpay/payments/confirm \
--header 'Authorization: Basic ENCODED_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data '{"paymentKey":"PAYMENT_KEY","amount":AMOUNT,"customerKey":"CUSTOMER_KEY","orderId":"ORDER_ID"}'
curl --request POST \
--url https://api.tosspayments.com/v1/brandpay/payments/confirm \
--header 'Authorization: Basic ENCODED_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data '{"paymentKey":"PAYMENT_KEY","amount":AMOUNT,"customerKey":"CUSTOMER_KEY","orderId":"ORDER_ID"}'
When the Confirm Endpoint is successfully called, payment is completed. All you have to do is show the payment completion page to the user.
Ayaan
Ayaan11mo ago
If you decide to use paymentWindow or paymentWidget instead, you will need to make a contract again and change some code, so I don't think it will be able to start selling by the 31st. However, I suggest you use paymentWindow/Widget instead, as your business is unsuitable with brandpay. (Brand Pay is a service that provides SDK and API that allows stores to implement their own simple payments. If a buyer registers their card or account information once, they can easily make payments from then on. This means that your shopping mall must have the user's information on a permanent basis - a login process will be required.) For paymentWindow and Widget, English documentation is available. You can check out here: https://docs.tosspayments.com/en/integration-widget and https://docs.tosspayments.com/en/integration.
MrPeterss
MrPeterss11mo ago
for right now, is it ok to store the access token and regresh token in cookies? sounds like security risk we don't have time to implment full auth or should we just apply for the paymentWindow?
Ayaan
Ayaan11mo ago
You're using BrandPay SDK or PaymentWidget with BrandPay? Please check which js script are you including now. If your project uses React/Vue/etc, please check your package.json.
MrPeterss
MrPeterss11mo ago
payment widget with brand pay i’m using nextjs
Ayaan
Ayaan11mo ago
Then you don't need to store the access token and refresh token at all. (paymentWidget SDK will automatically gets/stores access_token in secured way) And if you want, you can simply change to regular payment product because you already using paymentWidget.
MrPeterss
MrPeterss11mo ago
GitHub
GitHub - tosspayments/payment-widget-sample: 토스페이먼츠 결제위젯 샘플 앱입니다.
토스페이먼츠 결제위젯 샘플 앱입니다. . Contribute to tosspayments/payment-widget-sample development by creating an account on GitHub.
MrPeterss
MrPeterss11mo ago
i’m following the nextjs example from this repo is this what you mean? i don’t know why we are getting the error
Ayaan
Ayaan11mo ago
This sample is for regular payment, not brandpay. you need to implement more to use brandpay which is I mentioned above.
MrPeterss
MrPeterss11mo ago
ok does it use the same widget though? is there a js example for the brand pay?
Ayaan
Ayaan11mo ago
No, not yet for PaymentWidget. You will need to read documentation and implement it. If you having trouble with understanding, please let me know, we will help you 🙂
MrPeterss
MrPeterss11mo ago
thank you what is the usage for this npm package?
MrPeterss
MrPeterss11mo ago
npm
@tosspayments/brandpay-sdk
TossPayments.js Brand Pay SDK. Latest version: 1.5.2, last published: 2 months ago. Start using @tosspayments/brandpay-sdk in your project by running npm i @tosspayments/brandpay-sdk. There is 1 other project in the npm registry using @tosspayments/brandpay-sdk.
MrPeterss
MrPeterss11mo ago
how can i initialize the brandpay we are still getting a 403 error I set up an api rout and added it to the developer center "Failed to load resource: the server responded with a status of 403"
Ayaan
Ayaan11mo ago
This library is for who aren't using PaymentWidget for Brandpay. If you want, you can use, but you need to re-implementing some lines of code. Please screenshot/copy from Devtools -> Network -> Response
토스페이먼츠 BOT
❤️ 기술문의 경험이 어떠셨나요?!
간단히 코멘트 남겨주세요! 제품 발전에 큰 힘이 됩니다.
MrPeterss
MrPeterss11mo ago
hi sorry what is the best way to go about implmeneting it then
Ayaan
Ayaan11mo ago
Do you still want to use Brandpay? Do you have any contracts for Brandpay? Then, it is up to you. If you don't have contracts for Brandpay but you want to use Tosspayments, use Regular PaymentWidget and make contract.
MrPeterss
MrPeterss11mo ago
we are still using brandpay
Ayaan
Ayaan11mo ago
oh no, you are mixing with different SDK. That's why you got the error.
MrPeterss
MrPeterss11mo ago
the weird thing is its working just payment is not getting taken like it gets all the way to the end i don't know what sdk to use there are too many sdks
Ayaan
Ayaan11mo ago
Yes, because it is a completely different SDK. So let's clarify.
MrPeterss
MrPeterss11mo ago
yes please
멜로투모로
멜로투모로OP11mo ago
we don't get any toss related errors till the end everything payment related goes through
MrPeterss
MrPeterss11mo ago
first we should understand what sdk we have to use we are using brandpay and i would prefer to use the widget because i don't want to implment it fully myself i don't have the time for that right now
Ayaan
Ayaan11mo ago
Yes, just give me a sec.
MrPeterss
MrPeterss11mo ago
thhank you for your help
Ayaan
Ayaan11mo ago
* Does your shop have a login process? * If so, Do you know what Brandpay is? * Do you still want to use Brandpay? * Use PaymentWidget SDK to implement Brandpay (this is a new SDK) * If not, Do you want to make a normal transaction? * Use PaymentWidget SDK for regular transaction In both choice, you have to use @tosspayments/payment-widget-sdk.
MrPeterss
MrPeterss11mo ago
ok we want the second option we don't have a login ok we only have access to brand pay at this moment, so how can i ensure we are using the payment-widget-sdk with brandpay?
Ayaan
Ayaan11mo ago
Once you integrate with PaymentWidget first, you can access our admin page(dashboard.tosspayments.com) In admin page, you can access payment UI Setup - You can setup your brandpay integration on there
MrPeterss
MrPeterss11mo ago
so is it safe to follow this nextjs example. because previously you said it wasn't https://github.com/tosspayments/payment-widget-sample/tree/main/nextjs
GitHub
payment-widget-sample/nextjs at main · tosspayments/payment-widget-...
토스페이먼츠 결제위젯 샘플 앱입니다. . Contribute to tosspayments/payment-widget-sample development by creating an account on GitHub.
Ayaan
Ayaan11mo ago
Yes if you want to drop Brandpay support, please use this sample.
MrPeterss
MrPeterss11mo ago
but i believe we only have access to brandpay we don't have the other
Ayaan
Ayaan11mo ago
Do you have a brandpay contract?
MrPeterss
MrPeterss11mo ago
yes
Ayaan
Ayaan11mo ago
Ah, can I see your merchant ID? It will starts with cp_....
멜로투모로
멜로투모로OP11mo ago
cp_melrotzjti
MrPeterss
MrPeterss11mo ago
^
Ayaan
Ayaan11mo ago
Ok, thanks. I got it. Ah... then You may need to make login process
MrPeterss
MrPeterss11mo ago
crap
Ayaan
Ayaan11mo ago
No description
Ayaan
Ayaan11mo ago
This means you should have a user identifier; it should be unique and shouldn't be changed for one customer; It means you have to make login process or identify verification process.
MrPeterss
MrPeterss11mo ago
we are not in the best spot to be implmenting full auth right now should we apply for the other one?
Ayaan
Ayaan11mo ago
For contracts, to be honest, we don't know; it is entirely up to you. I am sorry for saying this, because you don't have a time for open your service, but you need to ask our contract team to clarify.
MrPeterss
MrPeterss11mo ago
thats ok we can push the date but we still have to solve this asap what would you recomend? full auth? i can do it it will just be a pain
Ayaan
Ayaan11mo ago
I think you need to choose the correct product that is suitable for your business. I think Brandpay is not a good idea for you, but I am not a sales team, so I cannot give you a sure answer.
MrPeterss
MrPeterss11mo ago
the way i solved the "user identifier" problem was i just assigned a new random id and store it in the cookies of the site
Ayaan
Ayaan11mo ago
No, it should be stores on your DB.
MrPeterss
MrPeterss11mo ago
ok its probably best for us to just apply to the other thank you for the help
Ayaan
Ayaan11mo ago
Not exactly, I suggest you to email or call our sales team.
멜로투모로
멜로투모로OP11mo ago
It's okay we applied for the other one thank you for your help
Ayaan
Ayaan11mo ago
Because the user identifier is used for getting pre-registered Card, Bank Accounts, and User Personal Data, it shouldn't be changed, so the cookie is too dangerous.
MrPeterss
MrPeterss11mo ago
that makes sense
Ayaan
Ayaan11mo ago
Cool, just for note, if you need to talk with the sales team: enterprise-sales@tosspayments.com OR +82-02-1544-7772 (Calls Korean Only) If you need to talk with the contract team: contract@tosspayments.com OR +82-02-1544-7772 (Calls Korean Only)
토스페이먼츠 BOT
토스페이먼츠 결제연동팀
빠르고 정확한 결제연동 경험을 위해, 디스코드에서는 기술 문의만 받고 있습니다. 계약 및 운영 관련 문의는 1544-7772나 홈페이지 상담을 이용해주세요. 감사합니다.
Ayaan
Ayaan11mo ago
Because this channel is tech team only, so to be honest, we are limited for answer your problem. We apologize for confusing you with the product and SDK; I promise it will be improved later. If you applied for regular payment, you can use this sample: https://github.com/tosspayments/payment-widget-sample Docs: https://docs.tosspayments.com/en/index