2

What's a recommended or reliable way to programmatically test a PayPal payment flow that uses the PayPal Smart Payment Button? window.paypal.Buttons() is loaded from https://www.paypal.com/sdk/js .

Tests are running against PayPal Sandbox.

I tried to end-to-end test the flow in node.js with jest via puppeteer but am not sure this is a good way to test this, considering that the intervals of PayPal may be subject to change.

Furthermore, when trying to automatically log in via puppeteer, PayPal sometimes seems to show the account homepage with the funds.

However, it's supposed to show the payment methods selection view instead after login, with no errors, which could be some bot protection mechanism kicking in or some other non-deterministic smart behavior, rendering the test to unable to proceed.

Operating my UI manually, I did not observe this behavior.

Arc
  • 11,143
  • 4
  • 52
  • 75
  • Did you reach a conclusion? The issue with testing the sandbox is that if anything changes or if there is a connectivity issue, the tests fails. On the other hand, if you mock paypal somehow, the tests will be stable but you would not know if paypal based changes would break your button ... – ahmaxed Jun 08 '21 at 08:56
  • 1
    @user2472167 the purpose of testing the workflow is to ensure it works end to end, together with PayPal, so mocking is not what we would want. Connectivity issues were never a problem, but if we were to find any, we'd know there might be something wrong with PayPal, at least the PayPal system we'd be using, and we could anticipate problems for real users. As said, the actual problem was not reliably reproducible behavior on PayPal's side which is apparently not documented. So the test works most of the time but is flaky. – Arc Jun 09 '21 at 04:57
  • Thanks. Flaky is fair enough. I am thinking of doing something similar (running cypress tests on a cron), but I was wondering if there is a more reliable way. – ahmaxed Jun 09 '21 at 09:03

0 Answers0