0

I want to try the invoicing API in vuejs. The code example I want to apply is

// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
const stripe = require('stripe')(

'sk_test_51M6ZtzIWDjpHNQK1pihAHQGM9Hh7aGVggo7yICRvYNUPqmHA2nIB9OLU6UrVmnWU8Spzcl1ZkPdRZu6zYCSVO7fi008peIrX1g'
);

const customer = await stripe.customers.create({
  email: '[email protected]',
  payment_method: 'pm_card_visa',
  invoice_settings: {default_payment_method: 'pm_card_visa'},
});

This does'nt work and I get the error

Require is not defined

How to change this piece of code ?

2
  • 2
    require is long gone, we use import on modern frontend apps. This example uses Nuxt but could give you some leads. Otherwise, you probably have some examples on the documentation regarding React, could use some of those. Maybe even got some Vue? Commented Nov 22, 2022 at 13:57
  • 1
    It could also help to check out Vue Stripe, a third party library for using the Stripe API in Vue. It could be useful for you to use that library or you may be able to look at its source code to see how it does things like importing. vuestripe.com Commented Nov 22, 2022 at 14:13

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.