我在谷歌云功能中收到此错误:
createStripePaymentIntent tc5h001dke76 TypeError:无法在exports.createStripePaymentIntent.functions.https.onRequest(/srv/index.js:50:5)处在/srv/index.js:45:55读取未定义的属性'create' _combinedTickCallback的/worker/worker.js:766:11的/worker/worker.js:783:7的/node_modules/firebase-functions/lib/providers/https.js:49:9)(_combinedTickCallback(internal / process / next_tick)。 js:132:7)在process._tickDomainCallback(internal / 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');
});
Run Code Online (Sandbox Code Playgroud)
我已经尝试了此代码的许多排列,但为清楚起见,我在这里将其保持简单。
我确实设法从“ testResponse”获得了对它的响应,并以其他方式运行。
问题是我通常会编写Swift代码,而我只是试图获得一个非常简单的Stripe实现,因此不可避免地会有一些我看不到的简单问题。因此,如果答案可以保持非常简单,那将是有帮助的!
编辑使代码更清晰-谢谢道格
node.js stripe-payments firebase google-cloud-functions google-cloud-firestore