paddle-node-sdk icon indicating copy to clipboard operation
paddle-node-sdk copied to clipboard

[Bug]: Not supported to run in Cloudflare Worker Edge environment

Open wytxer opened this issue 8 months ago • 11 comments

What happened?

Using the Next.js 14 + TypeScript tech stack, with the API set to the edge environment, an error occurs when calling paddle.transactions.create after importing the @paddle/paddle-node-sdk package: Module build failed: UnhandledSchemeError: Reading from "node:crypto".

Steps to reproduce

Reproduction code snippet:

// route.ts

import { Environment, Paddle } from '@paddle/paddle-node-sdk'

export const runtime = 'edge'

const paddle = new Paddle(process.env.PADDLE_SECRET_KEY!, {
  environment: Environment.production,
})

const transaction = await paddle.transactions.create({
  items: [
    {
      quantity: 1,
      priceId: 'priceId',
    },
  ],
})

What did you expect to happen?

I hope to use @paddle/paddle-node-sdk in an edge environment.

Logs

⨯ node:crypto
Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:crypto
node_modules/@paddle/paddle-node-sdk/dist/esm/internal/api/client.js
node_modules/@paddle/paddle-node-sdk/dist/esm/paddle.js
node_modules/@paddle/paddle-node-sdk/dist/esm/index.js

wytxer avatar Jul 05 '24 15:07 wytxer