[Vuejs]-CreatePaymentMethod of Vue stripe element not working in Laravel, TypeError: Object(…) is not a function error occured

0👍

There is no need to create both a payment method and a token. The PaymentMethods API can be thought of as a newer version of the Tokens API (1). So you can simplify your code to:

  methods : {
    pay() {
      createPaymentMethod('card', {
        billing_details: {
          name: this.name, // cardholder name
          email: this.email,
          address: { // address fetched from algolia places
            line1: this.street,
            country: this.selectedCountry,
            city: this.city,
            postal_code: this.postalCode,
          },
        }
      }) 
    }
  }

*Note, I removed the card: data.token.card.id line entirely. This should be unnecessary since the library you’re using adds a reference to the Card element for you automatically as you can see here:

https://github.com/fromAtoB/vue-stripe-elements/blob/ede16058193e2440dfd5a7cb7af17450d52e234b/src/stripeElements.js#L68

(1) https://stripe.com/docs/payments/payment-methods

Leave a comment