Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

craigwebster's avatar

Using Integrated to test a stripe gateway

Has anybody tried testing a stripe implementation by filling in a form with test creit card information? Is it possible? Do I need to use selenium?

0 likes
6 replies
MikeHopley's avatar

Yes, I've done it.

I'm not sure whether you need to use Selenium, but I would recommend it. Stripe uses javascript, so you would need a javascript-capable tool to fully test the interaction. Selenium is a good option. I use Codeception with Selenium Webdriver for these tests.

I found one gotcha. Because I used Stripe's jquery.payment library to enhance my form, the form input is reformatted as you type it (e.g. type the whole card number, and jquery.payment automatically puts the correct spaces in).

If you use this too, be aware that this javascript text formatting causes problems with Webdriver: it sometimes fails to enter all the text for a field. To get around this, you can insert a delay like so:

// Slowing this down so that javascript formatting doesn't break
    $I->wait(0.2);
    $I->appendField('Card number', '3714');
    $I->wait(0.2);
    $I->appendField('Card number', '496353');
    $I->wait(0.2);
    $I->appendField('Card number', '98431');
    $I->wait(0.2);

It's a bit ugly and hacky, but it works. The text must be split in the same way as it will be formatted; in this example, it's an American Express card.

JeffreyWay's avatar

If you want to use Selenium, don't forget that Integrated offers a Selenium extension. Just extend it, and you're good to go.

1 like
MikeHopley's avatar

@craigwebster No problem, glad to help and good luck. :)

@JeffreyWay Integrated looks superb, I wish it had been around when I was doing this work. I look forward to playing with it when I get time.

JillzTom's avatar

@MikeHopley: How did you do this?

    $I->appendField('Card number', '496353');

I think in the Selenium or Integrator, the method appendField is not available.

Please or to participate in this conversation.