Testing Stripe Payments

posted by 6 years ago and updated 5 years ago

While testing a checkout process in one of our applications we were trying to test the stripe payment.

Our application is based on Laravel. In our integrating testing we use Behat and Selenium2 for javascript.

Our form used the elements in Stripe, which inject an iframe into our website.

To test our application with Behat we had to jump in to the iframe and fill in the credit card details. Then we had to jump out of the iframe again and press the payment button.

Here is the example code filling the form using selenium2 in behat.

   public function iEnterMyPaymentDetails()
      $this->minkContext->fillField('cardholder-name', $this->helperContext->getFaker()->name);
      $this->minkContext->fillField('cardholder-email', $this->helperContext->getFaker()->email);
      $this->minkContext->fillField('cardholder-postcode', $this->helperContext->getFaker()->postcode);


      // Switch to the payment iframe
      $this->minkContext->fillField('cardnumber', '4242 4242 4242 4242');
      $this->minkContext->fillField('exp-date', '12 / 30');
      $this->minkContext->fillField('cvc', '123');

      // switch back to main content


Do you need help? Sometimes it is just easier to ask

In case you need that little extra push with your project. We are always happy to collaborate with new people in the industry.

Contact us for help