Я получаю эту ошибку в облачных функциях Google:
createStripePaymentIntent
tc5h001dke76
TypeError: Невозможно прочитать свойство 'create' из неопределенного в /srv/index.js:45:55 at exports.createStripePaymentIntent.functions.https.onRequest (/srv/index.js:50:5) в cloudFunction (/ srv / node_modules) /firebase-functions/lib/providers/https.js:49:9) в /worker/worker.js:783:7 в /worker/worker.js:766:11 в _combinedTickCallback (internal / process / next_tick.js: 132: 7) at process._tickDomainCallback (внутренняя / process / next_tick.js: 219: 9)
Вот мой код:
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const logging = require('@google-cloud/logging');
const stripe = require('stripe')(functions.config().stripe.token);
const currency = functions.config().stripe.currency || 'USD';
const express = require('express');
const app = express();
exports.createStripePaymentIntent = functions.https.onRequest(async (req, res) => {
const paymentIntent = await stripe.paymentIntents.create({
amount: 1099,
currency: 'gbp',
payment_method_types: ['card'],
});
return res.send('testResponse');
});
Я пробовал много перестановок этого кода, но для ясности я оставил его здесь простым.
Мне удается получить ответ от 'testResponse' на то, что он вызывается и функционирует иначе.
Проблема в том, что я обычно пишу код Swift и просто пытаюсь получить очень простую реализацию Stripe, поэтому неизбежно возникнут некоторые простые проблемы, которых я не вижу. Поэтому, если бы ответы могли быть предельно простыми, это было бы полезно!
edit сделал код более понятным - спасибо, Даг