Learn how to disable 3D Secure in Stripe, including API and dashboard steps, regional limitations, and security considerations. Guide for developers and merchants.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
How to Disable 3D Secure in Stripe
Introduction
3D Secure (3DS) is an authentication protocol designed to provide an additional layer of security for online credit and debit card transactions. While Stripe generally recommends using 3D Secure to reduce fraud and liability, there may be cases where you want to disable it for specific transactions. This tutorial provides a comprehensive guide on how to disable 3D Secure in Stripe.
Step 1: Understand 3D Secure in Stripe
Before disabling 3D Secure, it's important to understand that Stripe's approach to 3DS is dynamic:
Step 2: Access Your Stripe Dashboard
First, log in to your Stripe account:
Step 3: Configure 3D Secure Settings in the Dashboard
For basic configuration through the dashboard:
Note that dashboard options may vary based on your region due to regulatory requirements.
Step 4: Disable 3D Secure Using the API
The most reliable way to disable 3D Secure is through the API when creating PaymentIntents. Here's how to do it:
const stripe = require('stripe')('sk_test_YOUR_SECRET_KEY');
const paymentIntent = await stripe.paymentIntents.create({
amount: 1000, // Amount in cents
currency: 'usd',
payment_method_types: ['card'],
// This is where we disable 3D Secure
payment_method_options: {
card: {
request_three_d\_secure: 'never'
}
}
});
The key parameter here is request_three_d_secure: 'never'
, which tells Stripe to never request 3D Secure for this payment intent.
Step 5: Implement in Different Programming Languages
Python Implementation:
import stripe
stripe.api_key = "sk_test_YOUR_SECRET\_KEY"
payment\_intent = stripe.PaymentIntent.create(
amount=1000,
currency="usd",
payment_method_types=["card"],
payment_method_options={
"card": {
"request_three_d\_secure": "never"
}
}
)
PHP Implementation:
1000,
'currency' => 'usd',
'payment_method_types' => ['card'],
'payment_method_options' => [
'card' => [
'request_three_d\_secure' => 'never'
]
]
]);
?>
Ruby Implementation:
require 'stripe'
Stripe.api_key = 'sk_test_YOUR_SECRET\_KEY'
payment\_intent = Stripe::PaymentIntent.create({
amount: 1000,
currency: 'usd',
payment_method_types: ['card'],
payment_method_options: {
card: {
request_three_d\_secure: 'never'
}
}
})
Step 6: Implement with Stripe.js and Elements
When using Stripe.js to create Payment Intents on the frontend, you'll need to configure the backend to disable 3D Secure, then use the client secret in your frontend code:
// Backend: Create a PaymentIntent with 3D Secure disabled
const paymentIntent = await stripe.paymentIntents.create({
amount: 1000,
currency: 'usd',
payment_method_options: {
card: {
request_three_d\_secure: 'never'
}
}
});
// Send the client\_secret to the frontend
Then in your frontend JavaScript:
// Initialize Stripe.js
const stripe = Stripe('pk_test_YOUR_PUBLISHABLE_KEY');
const elements = stripe.elements();
// Create card element
const card = elements.create('card');
card.mount('#card-element');
// Handle form submission
const form = document.getElementById('payment-form');
form.addEventListener('submit', async (event) => {
event.preventDefault();
const {error, paymentMethod} = await stripe.createPaymentMethod({
type: 'card',
card: card,
});
if (error) {
// Handle error
console.error(error);
} else {
// Confirm the PaymentIntent with the payment method
const {error, paymentIntent} = await stripe.confirmCardPayment(
clientSecret, // Received from your server
{
payment\_method: paymentMethod.id
}
);
if (error) {
// Handle error
console.error(error);
} else if (paymentIntent.status === 'succeeded') {
// Payment succeeded
console.log('Payment successful!');
}
}
});
Step 7: Understand Regional Limitations
It's crucial to understand that in certain regions, particularly in the European Economic Area (EEA) under Strong Customer Authentication (SCA) regulations, you cannot completely disable 3D Secure:
Step 8: Use Payment Method Options for Specific Scenarios
For more granular control, you can configure 3D Secure behavior based on specific scenarios:
const paymentIntent = await stripe.paymentIntents.create({
amount: 1000,
currency: 'usd',
payment_method_types: ['card'],
payment_method_options: {
card: {
request_three_d\_secure: 'any', // 'any', 'automatic', or 'never'
three_d_secure: {
version: '2.0.0' // Specify 3DS version
}
}
}
});
The available options for request_three_d_secure
are:
Step 9: Test Your Implementation
Before going live, test your implementation thoroughly:
// Test card that triggers 3DS
const testCard3DS = {
number: '4000 0000 0000 3220',
exp\_month: 12,
exp\_year: 2025,
cvc: '123'
};
// Test card that doesn't trigger 3DS
const testCardNo3DS = {
number: '4242 4242 4242 4242',
exp\_month: 12,
exp\_year: 2025,
cvc: '123'
};
Step 10: Monitor and Adjust Your Settings
After implementation, monitor your payment success rates and fraud levels:
Conclusion
Disabling 3D Secure in Stripe is possible through API configuration, but it comes with important caveats, especially regarding regional regulations. Always consider the security implications and regulatory requirements before disabling this additional layer of protection. For most merchants, Stripe's dynamic 3DS approach (the default setting) offers the best balance between security and user experience.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.