Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting cors error when trying to call Adyen payments api #1077

Closed
satyam21041997 opened this issue Feb 22, 2023 · 5 comments
Closed

Getting cors error when trying to call Adyen payments api #1077

satyam21041997 opened this issue Feb 22, 2023 · 5 comments

Comments

@satyam21041997
Copy link

satyam21041997 commented Feb 22, 2023

Hi,
I am trying to call Adyen payments api to get all the payment methods that I enabled in Adyen account.
I am getting the below error when I try to call that API. I tried with the localhost server and AWS server as well.
MicrosoftTeams-image (5)

image

image

Please help me on it to resolve this error.

@leungkinghin-ct
Copy link
Collaborator

@satyam21041997 Thank you for your reporting.

I believe that the error is about CORS issue (Cross Origin Resource Sharing). You can check more details here
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors

There would be 2 possible solutions here

  1. Setup a proxy with the same domain as front-end page, so that front-end page can send request to this proxy server and redirect REST API call to Adyen.
  2. Use pre-built UI options supported by Adyen in your front-end page instead of making API call by yourself. For details, please check out here
    https://docs.adyen.com/online-payments/prebuilt-ui#components

@satyam21041997
Copy link
Author

Hi @leungkinghin ,
Can you please help me to provide more detail for the solution you have provided.

I also tried to add a localhost server to adyen account for allowed origin.
image

Please find the attached code for your reference.
PaymentMethod.txt

@leungkinghin-ct
Copy link
Collaborator

leungkinghin-ct commented Feb 24, 2023

Hello @satyam21041997
I think setting localhost as allowed origin would not help as it is not the actual domain URL of your page. Adyen platform cannot recognise where localhost is located.

Also, after i checked your attached code, you are adapting Adyen SDK to make API request. I would suggest you to raise a support ticket to Adyen directly in this case. Here we are supporting the integration between Commercetools and Adyen platform. Hope you could understand.

@satyam21041997
Copy link
Author

Hi @leungkinghin ,
Thanks for your response. I think you are right we can't use localhost URL as allowed origin.
Now my this issue is fixed I am calling Adyen payments API from AWS API gateway and it is working fine.
Can you please help me to add this integration to CommerceTools Sunrise application?
I am using AWS lambda for this.

@leungkinghin-ct
Copy link
Collaborator

Hi @satyam21041997
Thank you for your feedback.
I understand that you are trying to communicate with Adyen payment platform with application powered by the CT Sunrise.
Here are two possible strategies :

  1. Communicate to Adyen API directly (I suppose it is the approach you are working on)
  2. Persist your data into Commercetools platform plus this Integration.

Regarding point 2, you need to access and administrate one Commercetools project. And then setup API extension in it which would trigger synchronous call to this integration on AWS lambda when you update Commercetools payment

For more details how the entire flow works between this integration, CT platform and Adyen platform, please refer to our documentations below :
Overview
Integration Guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants