Issue with stripe connection

I am getting “Error: An error occurred with our connection to Stripe.” when I create customer in the worker. It seems something wrong with the connection. This code works when I was using AWS lambda function.

const Stripe = require('stripe');
const stripe = Stripe('stripekey'); //stripe secret test key

addEventListener('fetch', event => {
 * Respond with hello worker text
 * @param {Request} request
async function handleRequest(request) {
  var token = '';
  var emailAddress = '';
  var uid = '';
  const json = await request.json();

  //check query params
    token = json.token;
    emailAddress = json.emailAddress;
    uid = json.uid;

  if(uid != ''){

    //First Create customer
    const customer = await stripe.customers.create({
      email: emailAddress,
      description: uid,
      source: token
    }).then(function(customer) {
      return customer;
    }).catch(function(err) {
      console.log("[email protected]@#!!!");

      return err;

    return customerStripeId;

    new Response('uid is empty', {
      status: 400,
      statusText: 'Bad Request',

  return new Response('Hello worker!', {
    headers: { 'content-type': 'text/plain' },

Stripe uses Node APIs. Workers do not use NodeJS, it’s a V8 isolate with full support of browser APIs. Stripe does not currently support Workers. They’re working on it though - Stripe connection errors in Cloudflare workers · Issue #1233 · stripe/stripe-node · GitHub


okay thank you for replying! I will try to use alterative way.

Stripes Node.js library might not, but Stripe have no issue with Workers. You just have to do the work yourself. Several examples are available via your preferred search tool.


thank you it seems I cant use the node library api. looks like i have to use vanilla JS

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.