public function CheckoutTest::testCheckoutAndPayPayment3ds in Commerce Stripe 8
Tests customer, with regulations, can checkout.
This card requires authentication for one-time payments. However, if you set up this card and use the saved card for subsequent off-session payments, no further authentication is needed. In live mode, Stripe dynamically determines when a particular transaction requires authentication due to regional regulations such as Strong Customer Authentication.
@dataProvider dataProviderUserAuthenticatedAndCardAuthentication @group threeds
File
- tests/
src/ FunctionalJavascript/ CheckoutTest.php, line 179
Class
- CheckoutTest
- Tests checkout with Stripe.
Namespace
Drupal\Tests\commerce_stripe\FunctionalJavascriptCode
public function testCheckoutAndPayPayment3ds($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('4000002500003155', '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 3155');
$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.');
}
}