Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
Stripe is not defined in vue js

hello i've trying to use stripe to make payment but each time i reload the page it gives me

Error in mounted hook: "ReferenceError: Stripe is not defined"

error in my console https://imagizer.imageshack.com/img923/1484/YKpP7X.jpg

my index.html file

 <script type="text/javascript" src="https://js.stripe.com/v2/"></script>

this my script function for payment


<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      error: "",
      stripe: null,
      card: null
    };
  },

  computed: {
    ...mapGetters([
      "getCart",
      "getCartTotalPriceWithShipping",
      "getEstimatedDelivery"
    ])
  },
  mounted() {
     this.stripe = Stripe("pk_test_51KGqWkHCcyZvTrDrTmAbtZkngRWbP0FCvV3bgZnz8GXuleqD1foNZ");
    let elements = this.stripe.elements();
    this.card = elements.create("card");
    this.card.mount(this.$refs.card);
  },
  methods: {
    submit() {
     
      let token = window.stripe.createToken(this.card);
      return axios({
        method: "post",
        token: token,
        totalPrice: this.getCartTotalPriceWithShipping,
        cart: this.getCart,
        estimatedDelivery: this.getEstimatedDelivery,
        url: "http://localhost:5000/api/payment",

        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer" + token,
          "x-access-token": token
        }
      })
        .then(response => {
          console.log(response);
          if (response.success) {
            // Do something like redirecting to the home page
            this.$store.commit("clearCart");
            this.$router.push("/");
          }
        })
        .catch(error => {
          console.log(error);
        });
    },
    formatPrice(value) {
      let val = (value / 1).toFixed(2).replace(".", ",");
      return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
    },
    clear() {}
  }
};
</script>

don't seem to know what's wrong, please someone help me out

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!