Yes, as per official cypress documentation, you should avoid using cy.visit()
when testing an external site. They also list a bunch of reasons why this is not the best approach:
However, you should never use your UI or visit a 3rd party site when testing because:
- It is incredibly time consuming and slows down your tests.
- The 3rd party site may have changed or updated its content.
- The 3rd party site may be having issues outside of your control.
- The 3rd party site may detect you are testing via a script and block you.
- The 3rd party site may be running A/B campaigns.
(https://docs.cypress.io/guides/references/best-practices.html#Visiting-external-sites)
So, in your case, you're better off with cy.request()
. For that, you need:
- read their documentation, if you don't know how to use
cy.request()
- read a documentation of yout API; I'm not sure what payment provider you're using, so I can link more resources for you to have a look at