samedi 12 septembre 2020

Credit card number is garbled when testing Stripe.js in Mink

I am trying to use Behat/Mink to test Stripe on my Drupal site.

I have a Stripe testing payment gateway configured. My

My FeatureContext.php looks like this:

  /**
   * @Then I enter my US JCB credit card info
   */
  public function iEnterMyUsJcbCreditCardInfo() {
    $this->enterCardDetails('3566 0020 2036 0505', '11 / 21', '777');
  }

  private function enterCardDetails($card_number, $exp_date, $cvc) {
    $this->getSession()->wait(2000);
    // Switch to the payment iframe.
    $this->getSession()->switchToIFrame(self::STRIPE_CARDNO_IFRAME);
    $this->getSession()->wait(1000);
    $this->fillField('cardnumber', "$card_number");
    $this->getSession()->wait(2000);

I added the wait() because the credit card number is being filled out incorrectly.

For example, when I have the step And I enter my US JCB credit card info, then instead of the correct test card number (3566 0020 2036 0505), I get this: 3566 0000 3605 5022.

invalid card number with behat

The incorrect card number is not consistent; when I re-ran the test three times, I got these numbers:

  • 3566 0022 3005 5600
  • 3566 0002 0360 5502
  • 3566 0006 5500 3220

So it seems like something with stripe.js is interfering with my credit card number input.

The credit card expiration date and CVC/security code input do not have this problem.

When I eliminate the spaces in the credit card number, I still have the same problem (the number is randomly garbled during input).

Even when I set the wait time before and after card number input to 5 seconds each, the card number still gets garbled.

How can I input the credit card number in behat/mink without garbling the number?

Aucun commentaire:

Enregistrer un commentaire