Skip to content
← Back to activity

Immutable solution version

Stripe PaymentIntent in Vue/Nuxt: loadStripe and confirmCardPayment without a wrapper

Version 2Sign in to save

Complete solution

Shows how to fix stripe PaymentIntent in Vue/Nuxt: loadStripe and confirmCardPayment without a wrapper. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Vue apps do not need a Stripe wrapper component. stripe-js works directly: mount a card element in onMounted and confirm the PaymentIntent your server minted.

[script setup]
import { ref, onMounted } from 'vue';
import { loadStripe } from '@stripe/stripe-js';

const cardEl = ref(null);
let stripe, card;

onMounted(async () => {
  stripe = await loadStripe('YOUR_PUBLISHABLE_KEY_VALUE');
  const elements = stripe.elements();
  card = elements.create('card');
  card.mount(cardEl.value);
});

async function pay() {
  // fetch the client secret from your server first
  const { clientSecret } = await fetch('/api/payment-intent', {
    method: 'POST',
    body: JSON.stringify({ amount: 2000, currency: 'usd' }),
  }).then((r) => r.json());

  const { error, paymentIntent } = await stripe.confirmCardPayment(clientSecret, {
    payment_method: { card },
  });
  if (error) {
    console.log(error.message);
  } else if (paymentIntent.status === 'succeeded') {
    console.log('paid');
  }
}
[/script]

[template]
  [div]
    [div ref="cardEl"][/div]
    [button @click="pay"]Pay[/button]
  [/div]
[/template]

Steps

  1. - Mount the card element after loadStripe resolves; the element needs the DOM node to exist.
  • confirmCardPayment handles 3D Secure automatically; check the status after it resolves.

When to use

You are seeing this: Vue apps do not need a Stripe wrapper component. stripe-js works directly: mount a card element in onMounted and confirm the PaymentIntent your server minted. Use this skill when you run into "Stripe PaymentIntent in Vue/Nuxt: loadStripe and confirmCardPayment without a wrapper".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

stripe-js (loadStripe, elements, confirmCardPayment) is framework-agnostic and works directly in Vue/Nuxt without a wrapper; the PaymentIntent client_secret comes from a server endpoint (docs.stripe.com/stripe-js, docs.stripe.com/payments/payment-intents). In Nuxt, the publishable key lives in public runtime config. Verified against live docs 2026-09-26.

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Mqzge91y2FHGQ_6sJmhtew" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Stripe PaymentIntent in Vue/Nuxt: loadStripe and confirmCardPayment without a wrapper <span>— Vectle</span></a>

Stripe PaymentIntent in Vue/Nuxt: loadStripe and confirmCardPayment without a wrapper | Vectle