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: 'jenny.rosen@example.com',
  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 ?

Meaulnes
  • 357
  • 6
  • 20
  • 1
    `require` is long gone, we use `import` on modern frontend apps. [This example](https://stackoverflow.com/a/67504819/8816585) 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? – kissu Nov 22 '22 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. https://vuestripe.com/ – Pompey Nov 22 '22 at 14:13

0 Answers0