決済にStripeを使おうと思っているのですが、Cloud Functionsをデプロイしようとすると以下のエラーが出ます。
Did you list all required modules in the package.json dependencies? Detailed stack trace: Error: Cannot find module 'stripe'
index.jsとpackage.jsonは以下のようになっております。
原因がわかる方がおられましたらお教え頂きたいです。
よろしくお願い致します。
const functions = require('firebase-functions'); const admin = require('firebase-admin'); const CORS = require('cors'); const Stripe = require('stripe'); const charge = (request, response) => { const body = JSON.parse(request.body); const token = body.token.id; const email = body.token.email; const amount = body.charge.amount; const currency = body.charge.currency; const stripe = Stripe(functions.config().stripe.token); stripe.charges .create({ amount, currency, description: "", source: token, receipt_email: email }) .then(charge => { send(response, 200, { message: "Success", charge }); }) .catch(error => { console.error(error); send(response, 500, { error: error.message }); }); }; function send(response, statusCode, body) { response.send({ statusCode, headers: { "Access-Control-Allow-Origin": "*" }, body: JSON.stringify(body) }); } exports.charge = functions.region('asia-northeast1').https.onRequest((request, response) => { const CORSRequestHandler = CORS({ origin: true }); CORSRequestHandler(request, response, () => { if (request.method !== "POST") { send(response, 405, { error: "Invalid Request" }); } try { charge(request, response); } catch (e) { console.log(e); send(response, 500, { error: `The server received an unexpected error. Please try again and contact the site admin if the error persists.` }); } }); });
{ "name": "APP_NAME", "version": "0.1.0", "private": true, "main": "index.js", "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint" }, "dependencies": { "@google-cloud/storage": "^2.5.0", "axios": "^0.19.0", "babel-polyfill": "^6.26.0", "cors": "^2.8.5", "css-scroll-snap-polyfill": "^0.1.2", "date-fns": "^1.30.1", "firebase": "^5.9.0", "firebase-admin": "^8.0.0", "firebase-functions": "^3.0.1", "http2": "^3.3.7", "ismobilejs": "^0.5.1", "jquery": "^3.4.0", "register-service-worker": "^1.6.2", "rx-js": "0.0.0", "stripe": "^7.1.0", "vue": "^2.6.6", "vue-router": "^3.0.1", "vue-rx": "^6.1.0", "vue-slick": "^1.1.15", "vue-smoothscroll": "^0.2.0", "vue-stripe-checkout": "^1.2.6", "vuejs-clipper": "^0.2.10", "vuetify": "^1.5.5", "vuex": "^3.0.1" }, "devDependencies": { "@vue/cli-plugin-babel": "^3.5.0", "@vue/cli-plugin-eslint": "^3.5.0", "@vue/cli-plugin-pwa": "^3.5.0", "@vue/cli-service": "^3.7.0", "babel-eslint": "^10.0.1", "eslint": "^5.16.0", "eslint-plugin-vue": "^5.0.0", "node-sass": "^4.12.0", "sass-loader": "^7.1.0", "stylus": "^0.54.5", "stylus-loader": "^3.0.1", "vue-cli-plugin-vuetify": "^0.5.0", "vue-template-compiler": "^2.5.21", "vuetify-loader": "^1.0.5" } }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。