【问题标题】:Stripe connection error Cloudflare worker条带连接错误 Cloudflare worker
【发布时间】:2021-12-21 13:03:30
【问题描述】:

我收到“错误:我们与 Stripe 的连接发生错误。”在 cloudflare worker 中的 paymentIntents.create 中。

代码如下:

addEventListener('fetch', event => {
      event.respondWith(handleRequest(event.request))
    })
    /**
     * Respond with hello worker text
     * @param {Request} request
     */
    async function handleRequest(request) {
      const stripe = require('stripe')('Stripkey');
    
      const paymentIntent = await stripe.paymentIntents.create({
        amount: 1000,
        currency: 'cad',
        payment_method_types: ['card'],
        receipt_email: 'jenny.rosen@example.com',
      });
      return new Response('Hello worker!', {
        headers: { 'content-type': 'text/plain' },
      })

【问题讨论】:

    标签: node.js stripe-payments cloudflare-workers


    【解决方案1】:

    Cloudflare workers don't fully support Node.js 和您看到的错误是由于 Stripe 的 Node 库依赖于特定于 Node 的 API 才能工作。 Stripe is working on a fix,一旦修复发布,它应该会按预期开始工作。

    【讨论】:

      猜你喜欢
      • 2017-10-16
      • 2022-12-26
      • 1970-01-01
      • 2023-01-13
      • 2020-09-12
      • 2020-12-28
      • 1970-01-01
      • 2018-12-12
      • 2020-04-18
      相关资源
      最近更新 更多