/stripe-guides

How to fix currency mismatch error in Stripe?

Learn how to fix the Stripe currency mismatch error by ensuring consistent currency settings for Customers, Products, Prices, and payments in your Stripe integration.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free consultation

How to fix currency mismatch error in Stripe?

How to Fix Currency Mismatch Error in Stripe

 

Introduction

 

The currency mismatch error in Stripe occurs when you attempt to process a payment with a currency that doesn't match the currency of another related object, such as a Customer, Subscription, or Product. This tutorial will guide you through identifying and resolving currency mismatch errors in various Stripe implementation scenarios.

 

Step 1: Understanding the Currency Mismatch Error

 

Currency mismatch errors typically appear with messages like:

This PaymentIntent's currency (usd) does not match the Customer's default currency (eur)

or

Currency mismatch: expected 'usd', received 'eur'

These errors occur when Stripe objects with fixed currencies (like Products or Subscriptions) are used with payments in different currencies.

 

Step 2: Checking Your Stripe Dashboard Configuration

 

First, verify your currency settings in the Stripe Dashboard:

  • Log in to your Stripe Dashboard
  • Go to Settings → Business Settings → Payment Methods
  • Check which currencies are enabled for payments
  • Note the default currency for your account

 

Step 3: Fixing Currency Mismatch in PaymentIntent Creation

 

When creating a PaymentIntent, ensure it uses the same currency as the Customer's default currency:

// JavaScript example
// INCORRECT - might cause currency mismatch
const paymentIntent = await stripe.paymentIntents.create({
  amount: 2000,
  currency: 'usd',
  customer: 'cus\_123456789',
});

// CORRECT - fetch customer first and use their currency
const customer = await stripe.customers.retrieve('cus\_123456789');
const paymentIntent = await stripe.paymentIntents.create({
  amount: 2000,
  currency: customer.currency || 'usd', // Use customer currency or default
  customer: 'cus\_123456789',
});

 

Step 4: Fixing Currency Mismatch in Subscriptions

 

For subscriptions, ensure that the Price, Product, and Customer all use the same currency:

// JavaScript example
// Create a Price in the correct currency
const price = await stripe.prices.create({
  unit\_amount: 2000,
  currency: 'usd',
  product: 'prod\_123456789',
  recurring: {
    interval: 'month',
  },
});

// Create a subscription with matching currency
const subscription = await stripe.subscriptions.create({
  customer: 'cus\_123456789',
  items: [
    { price: price.id },
  ],
  currency: 'usd',  // Must match the Price currency
});

 

Step 5: Updating Customer Default Currency

 

If needed, update a customer's default currency to match your product pricing:

// JavaScript example
const updatedCustomer = await stripe.customers.update(
  'cus\_123456789',
  {
    currency: 'usd',
  }
);

 

Step 6: Handling Multi-Currency Support

 

If your application needs to support multiple currencies:

// JavaScript example
// Function to create a payment intent with proper currency handling
async function createPaymentWithCurrencyCheck(amount, currencyCode, customerId) {
  try {
    // Retrieve the customer
    const customer = await stripe.customers.retrieve(customerId);
    
    // Check if customer has a different currency than requested
    if (customer.currency && customer.currency !== currencyCode) {
      // Option 1: Use the customer's currency
      currencyCode = customer.currency;
      // Recalculate amount based on exchange rate if needed
      
      // Option 2: Update the customer's currency to match
      await stripe.customers.update(customerId, { currency: currencyCode });
    }
    
    // Create the payment intent with the appropriate currency
    const paymentIntent = await stripe.paymentIntents.create({
      amount: amount,
      currency: currencyCode,
      customer: customerId,
    });
    
    return paymentIntent;
  } catch (error) {
    console.error('Error handling currency:', error);
    throw error;
  }
}

 

Step 7: Setting Default Currency for New Customers

 

When creating new customers, explicitly set the currency to avoid mismatches:

// JavaScript example
const customer = await stripe.customers.create({
  email: '[email protected]',
  name: 'Jenny Rosen',
  currency: 'usd', // Set default currency
});

 

Step 8: Fixing Currency Mismatch in Checkout Sessions

 

For Stripe Checkout, ensure the currency matches any associated customers or products:

// JavaScript example
const session = await stripe.checkout.sessions.create({
  payment_method_types: ['card'],
  line\_items: [
    {
      price\_data: {
        currency: 'usd',
        product\_data: {
          name: 'Product Name',
        },
        unit\_amount: 2000,
      },
      quantity: 1,
    },
  ],
  mode: 'payment',
  customer: 'cus\_123456789', // Make sure this customer's currency matches
  success\_url: 'https://example.com/success',
  cancel\_url: 'https://example.com/cancel',
});

 

Step 9: Handling Payment Methods with Currency Restrictions

 

Some payment methods only work with specific currencies. Ensure compatibility:

// JavaScript example
// Function to get available payment methods based on currency
function getAvailablePaymentMethods(currency) {
  const allPaymentMethods = ['card', 'sepa\_debit', 'ideal', 'bancontact', 'giropay'];
  
  // Example currency restrictions
  const restrictions = {
    'eur': ['card', 'sepa\_debit', 'ideal', 'bancontact', 'giropay'],
    'usd': ['card'],
    'gbp': ['card', 'bacs\_debit'],
    // Add more as needed
  };
  
  return restrictions[currency] || ['card']; // Default to card if currency not in list
}

// Create payment intent with appropriate payment methods
const paymentIntent = await stripe.paymentIntents.create({
  amount: 2000,
  currency: 'eur',
  payment_method_types: getAvailablePaymentMethods('eur'),
});

 

Step 10: Debugging Currency Mismatch Issues

 

If you continue to experience issues, use Stripe's logging capabilities to identify the mismatch source:

// JavaScript example
// Helper function to debug currency mismatches
async function debugCurrencyMismatch(customerId, productId, priceId) {
  const results = {
    customer: null,
    product: null,
    price: null,
  };
  
  try {
    if (customerId) {
      results.customer = await stripe.customers.retrieve(customerId);
      console.log(`Customer ${customerId} currency: ${results.customer.currency}`);
    }
    
    if (productId) {
      results.product = await stripe.products.retrieve(productId);
      console.log(`Product ${productId} details:`, results.product);
    }
    
    if (priceId) {
      results.price = await stripe.prices.retrieve(priceId);
      console.log(`Price ${priceId} currency: ${results.price.currency}`);
    }
    
    return results;
  } catch (error) {
    console.error('Error debugging currency mismatch:', error);
    throw error;
  }
}

 

Conclusion

 

Currency mismatch errors in Stripe can be resolved by ensuring consistent currency usage across all related objects in your payment flow. Always check the currency settings for Customers, Products, Prices, and payment operations to maintain compatibility. For multi-currency applications, implement proper currency handling logic that respects Stripe's constraints while providing flexibility for your users.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022