[英]Stripe connection error Cloudflare worker
I am getting "Error: An error occurred with our connection to Stripe."我收到“错误:我们与 Stripe 的连接出错”。 at paymentIntents.create in the cloudflare worker.
在 cloudflare 工作器中的 paymentIntents.create 处。
Here is the code:这是代码:
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' },
})
Cloudflare workers don't fully support Node.js and the error you're seeing is due to the fact that Stripe's Node library depends on Node-specific APIs to work. Cloudflare 工作人员不完全支持 Node.js ,您看到的错误是由于 Stripe 的 Node 库依赖于特定于 Node 的 API 才能工作。 Stripe is working on a fix and once that fix is released this should start working as expected.
Stripe 正在进行修复工作,一旦发布该修复程序,它应该会按预期开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.