我尝试将Stripe与Firebase集成到ionic 4中,所以我遵循此tuto:
https://medium.com/enappd/integrating-stripe-payment-in-ionic-4-for-apps-and-pwa-de05142c523e
但是doen的工作fireBase发送了一个错误。
所以我尝试禁用cors,但这仍然无法正常工作
这是功能
exports.payWithStripe = functions.https.onRequest((request, response) => {
production
cors(request, response, () => {
response.status(200).send({test: 'Testing functions'});
stripe.charges.create({
amount: request.body.amount,
currency: request.body.currency,
source: resquest.body.token,
}).then((charge) => {
那是fireBase错误日志
{ Error: Must provide source or customer.
at Function.generate (/srv/node_modules/stripe/lib/Error.js:49:16)
at IncomingMessage.res.once (/srv/node_modules/stripe/lib/StripeResource.js:167:39)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
答案 0 :(得分:0)
听起来您的request.body.token字段实际上没有发送源ID,该ID应该由stripe.js在客户端生成。
stripe.createSource( cardElement, result => {
// Do something with this source ID
result.source.id;
});
答案 1 :(得分:0)
出于测试目的,请将以下内容添加到functions文件夹中的index.js文件中。
(请注意,这仅是出于测试目的)
val.multiply(new BigDecimal(100)).toBigInteger()