You are here

public function CheckoutTest::test3dsAlwaysAuthenticate in Commerce Stripe 8

Tests customer, with regulations, can checkout.

This card requires authentication on all transactions, regardless of how the card is set up.

@note: When always using SetupIntent, this would cause two authentication modals. One when persisting the payment method and another when confirming the payment intent.

@dataProvider dataProviderUserAuthenticatedAndCardAuthentication @group threeds

File

tests/src/FunctionalJavascript/CheckoutTest.php, line 231

Class

CheckoutTest
Tests checkout with Stripe.

Namespace

Drupal\Tests\commerce_stripe\FunctionalJavascript

Code

public function test3dsAlwaysAuthenticate($authenticated, $pass) {
  if ($authenticated) {
    $customer = $this
      ->createUser();
    $this
      ->drupalLogin($customer);
  }
  $this
    ->drupalGet($this->product
    ->toUrl()
    ->toString());
  $this
    ->submitForm([], 'Add to cart');
  $this
    ->drupalGet('checkout/1');
  if (!$authenticated) {
    $this
      ->submitForm([], 'Continue as Guest');
    $this
      ->getSession()
      ->getPage()
      ->fillField('contact_information[email]', 'guest@example.com');
    $this
      ->getSession()
      ->getPage()
      ->fillField('contact_information[email_confirm]', 'guest@example.com');
  }
  $this
    ->fillCreditCardData('4000002760003184', '0322', '123');
  $this
    ->submitForm([
    'payment_information[add_payment_method][billing_information][address][0][address][given_name]' => 'Johnny',
    'payment_information[add_payment_method][billing_information][address][0][address][family_name]' => 'Appleseed',
    'payment_information[add_payment_method][billing_information][address][0][address][address_line1]' => '123 New York Drive',
    'payment_information[add_payment_method][billing_information][address][0][address][locality]' => 'New York City',
    'payment_information[add_payment_method][billing_information][address][0][address][administrative_area]' => 'NY',
    'payment_information[add_payment_method][billing_information][address][0][address][postal_code]' => '10001',
  ], 'Continue to review');
  $this
    ->assertWaitForText('Visa ending in 3184');
  $this
    ->assertWaitForText('Expires 3/2022');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Pay and complete purchase');
  $this
    ->complete3ds($pass);
  if ($pass) {
    $this
      ->assertWaitForText('Your order number is 1. You can view your order on your account page when logged in.');
  }
  else {
    $this
      ->assertWaitForText('We encountered an error processing your payment method. Please verify your details and try again.');
  }
}