Hey all,
I’m currently working on a set of integration tests for a project I inherited that works with Paypal’s Payflow Hosted Payment Pages. I’m open to any form of tests that will help ensure that our payment process is well-covered, so any advice would be appreciated, but currently am focusing on integration tests.
I’m using PayPal’s Hosted Payment pages to host the page where credit card information is entered. This payment page is loaded via an iframe, which has order/user information passed to it via hidden form fields in a POST request.
The flow looks like this:
User Information Page →
Confirmation Page (has an iframe with hidden form fields that submit to PayPal after confirmation) →
Payment Page (iframe: PayPal Credit Card Page) →
PayPalController#callback
Eventually the goal is to stub the request that is sent to PayPal (likely via VCR, though there may be issues with it+capybara-webkit) so I can simulate the full stack of a user entering information and simulate acceptance/declines of credit cards appropriately.
Unfortunately, I’m unable to even get interaction working using within_frame
to simulate clicks in the tests. While the code executes correctly in development mode, the tests give an error of Capybara::ElementNotFound
and fail.
When I puts page.body
to the screen in the test, it shows the <iframe>
tag, but without any content. Even if I try to add something like sleep(5)
to ensure there’s enough time to load the iframe, it still doesn’t work. The iframe is local, so I’m not certain of what could be causing the issues. Here’s an example of results from puts page.body
in the test:
<iframe id="payflow-checkout" src="/payments/payflow/checkout/3" width="490px" height="660px" frameborder="0" scrolling="yes" style="background-color: white;" target="_top"></iframe>
And the test:
feature "Donor submits valid payment information", js: true do
it "should show as a successful payment" do
visit "/projects/#{project.id}/home"
click_on "Give to this Project"
fill_in_donor_information(donor)
click_on "Continue"
within_frame "payflow-checkout" do
click_on "submit"
end
# expect(page).to have_content("Successful payment")
end
end
When I debug the output using save_and_open_page
or save_screenshot
, I see the confirmation page is loading, but the iframe content isn’t. This is using capybara-webkit 1.4.1
on Rails 3.2.21, if it helps.
Any ideas? Beyond any specific ideas for helping with this test, I’m also open to any discussion about how you’d approach testing this – at the end of the day, all I want to ensure is that each step of the payment process is working properly, and the sheer number of problems I’m encountering testing this way is making me reconsider if I’m even taking the right approach.
Thanks!