Stripe
35 verified issues
Feature requests: Typescript definitions
Hi, Since typescript popularity is on the rise and there are no community definitions available for stripe-node I would very much like Typescript definitions. This will help both Typescript users and normal JS users with IDEs that support them like WebStorm and VSCode (even Sublime and Atom have JS hinting plugins that support them). I find using type definitions much easier than going through the documentation. In addition not all the documentation is up to date since I see the functions can optionally return promises if a callback is not passed and it's not documented.
Specify event.data.object as an alternative
`event.data.object` is currently specified as an empty interface, which seems invalid. My understanding of the API is that it should be an alternative of all possibilities. Relevant code: https://github.com/stripe/stripe-node/blob/b2d32ef3a987b3c740bbc44c99a8209a92c3a5ee/types/2019-12-03/Events.d.ts#L56-L66
File upload via files.create API always timing out with NodeJS
Describe the bug Hey folks, after upgrading `stripe-node` to `20.1.0` (from `14.5.0`), our file uploads stopped working, always returning a timeout error: [code block] I've tested a few different versions of the client, and the latest version where the file upload worked as expected is `18.5.0`, and the issue starts happening on `19.0.0`. Also, the issue only happens when using NodeJS. If I run the same snippet with `stripe-node` version `20.1.0` with Bun, it works as expected. The request does not appear on the logs on Stripe's dashboard. To Reproduce 1. Call the `files.create` API using `stripe-node` version `20.1.0` with NodeJS 20, 22 or 24. Expected behavior The file is uploaded successfully, as in version `18.5.0`: [code block] Code snippets [code block] OS Fedora 42 on kernel 6.17.7 Node version Tested with 20.19.6, 22.21.1 and 24.12.0 Library version stripe-node between 19.0.0 and 20.1.0 API version 2023-10-16, but other versions also gave the same error Additional context Initializing the client with `{ httpClient: Stripe.createFetchHttpClient() }` changes the error to: [code block] I was able to make it work by importing `node-fetch` and using it as the HTTP client, i.e.: [code block]
TypeScript types are invalid when expanding responses
Describe the bug When expanding responses as per the documentation here, the return types for various Stripe methods are not updated to accurately reflect the modified responses. To Reproduce [code block] Expected behavior The returned data does indeed contain a nested `subscriptions` object: [code block] However, the TypeScript types do not declare this at all. Code snippets _No response_ OS macOS Node version Node v16.4.2 Library version stripe-node v10.8.0 API version 2022-08-01 Additional context _No response_
TypeScript - Property 'plan' does not exist on type 'Subscription'
Describe the bug The property `plan` is not accessible on `Subscription` objects when used in TypeScript. The `plan` property is, however, present in the `Subscription` object To Reproduce 1. Create an instance of `Stripe` 2. Request a `Subscription` object 3. Try to access the `plan` property Expected behavior For the `plan` property to be accessible Code snippets _No response_ OS Ubuntu 22.04 Node version Node v18.12.1 Library version stripe-node v12.5.0 API version 2022-11-15 Additional context The documentation for the `Subscription` object also does not list the `plan` property, and several others <https://stripe.com/docs/api/subscriptions/object>
constructEvent is not working in the example
im using the provided example https://github.com/stripe/stripe-node/tree/master/examples/webhook-signing to check the sign (without changing any code, but just put the correct secret here is my test body that grep from the webhook request `{ "id": "evt_1HI8Y3G18iuNs10OgnHen3OH", "object": "event", "api_version": "2020-03-02", "created": 1597909859, "data": { "object": { "id": "pi_1HI8Y3G18iuNs10OOPlF55v4", "object": "payment_intent", "amount": 21000, "amount_capturable": 0, "amount_received": 0, "application": null, "application_fee_amount": null, "canceled_at": null, "cancellation_reason": null, "capture_method": "automatic", "charges": { "object": "list", "data": [], "has_more": false, "total_count": 0, "url": "/v1/charges?payment_intent=pi_1HI8Y3G18iuNs10OOPlF55v4" }, "client_secret": "pi_1HI8Y3G18iuNs10OOPlF55v4_secret_fBJ4VKg0NttX3X5wbN1BHmfoL", "confirmation_method": "automatic", "created": 1597909859, "currency": "hkd", "customer": null, "description": "Order #: SMY1597909859", "invoice": null, "last_payment_error": null, "livemode": false, "metadata": {}, "next_action": null, "o
Importing Stripe via ES Modules does not respect monkey-patching 'http'
Describe the bug When trying to mock responses made with stripe-node in a Node.js enviroment, the requests hit the real server instead of getting caught by MSW. To Reproduce You can copy and paste the code below. (Either write actual handlers for your `stripeHandlers`, or you can leave them out, as we did below. If you want to try it out with handlers, simply spread them into `setupServer`.) Sine we configured `onUnhandledRequest: 'warn'` MSW should log out to the console when requests are uncaught. The manual method with `axios` works correctly and logs out this warning / reacts when you configure handlers. However, the second (in the code blocked `skip`ped) test does NOT log out this warning and simply hits the servers. [code block] [code block] Expected behavior MSW can intercept the Stripe requests. I assume this library does HTTP requests somehow esoterically, so it would be nice to learn how it does it, so that we can get MSW to work. Code snippets _No response_ OS macOS Node version 18.6.0 Library version stripe-node v12.12.0 API version 2022-11-15 Additional context _No response_
Cannot get to "requires_action" path after "requires_payment_method"
I am going through the subscriptions integration. I am at the point of integrating 3D-secure authentication path outcome 4 If I input a 3D-secure card first time - it works fine. However, If the first card I use fails (4000000000000341) and the subscription has status `incomplete` with `requires_payment_method` and THEN i try a 3D-secure card like 4000000000003220 - the `invoice.pay` method throws error instead of giving me an invoice object with a `payment_intent.status` of `requires_action` as its expected from the link provided hence I cannot show the user the modal to verify with 3D-secure. The error thrown is the following (invoice_payment_intent_requires_action) - google can't find anything for the error [code block] stripes-node version: v7.0.0 node version: v11.13.0
Unknown Arguments
Hi! I have an ES6 class named 'Charge'. When I create a new instance of it and pass it to stripe.charges.create it returns an error (below). It does not when I pass a vanilla object. [code block] [code block]
Retrive balance on managed account
When I list transaction history on a managed account, I see a list of transaction data. In each of the transaction object I see the value of the "source" attr that start with "py". The transaction object looks like this: `{ "id": "txn_17bBwe2eZvKYlo2Cuwcyi9or", "object": "balance_transaction", "amount": 400, "available_on": 1455235200, "created": 1454687788, "currency": "usd", "description": "Charge for test@example.com", "fee": 42, "fee_details": [ ], "net": 358, "source": "py_17bBwe2eZvKYlo2Crk3VGEG8", "sourced_transfers": { "object": "list", "data": [ [code block] }, "status": "pending", "type": "charge" }` I want to retrieve the detail from the value come from "source", how can I do that? I tried retrieve from Charge,Balance but no luck.
stripe.charge.list missing metadata
When I called `stripe.charges.list(filter, callback);` I get a full list of charges complete with metadata. However, when i call `stripe.charges.list(filter, {stripe_account: accountId}, callback);` to get a subset of charges from the managed account, I am getting the charges without the metadata. How can I get the metadata in the second example?
Unusable in Cloudflare workers due to use of node specific APIs/packages
Describe the bug This seems to be a broad regression, given that Cloudflare workers is supposed to be supported. The root of the issue is usage of node specific APIs and globals. - webhooks uses Buffer - not supported in workers, one workaround would be to wrap it in a try/catch and fall back to assuming the value is a string (or I guess just check if it exists and fall back) - utils requires `crypto` which is required early in stripe.ts - it's plausible that import could be replaced/polyfilled with Web Crypto - there's a few references to `http`/`https` in `createNodeHttpClient`- the compiler doesn't seem to be smart enough to skip compiling NodeHttpClient (I think since it's imported by default? It's possible that dynamically requiring it could help?) - somewhere there's `child_process` usage I was able to get things mostly working by using the package.json `browser` field to stub out the `crypto`(swapped for `crypto-js`)/`http`/`https`/`child_process`(swapped the others for an empty dummy.ts file) imports, but webhooks unchecked Buffer usage fully blocked me. To Reproduce I'll see if I can get a repro repo up but: - create a new cloudflare function - install stripe-node - observe many errors Expected behavior Everything should work! Code snippets _No response_ OS Ubuntu Node version 19 Library version 10.15.0 API version 22-08-01 Additional context I'm @cal on slack if chatting synchronously helps!
Include lastResponse in error object
Hi If a stripe error occurs (e.g. StripeCardError), it would be useful to be able to access the headers within the error object - particularly the date header. Would it be possible for the error object to include either lastResponse or lastReponse.headers please? Thanks very much. Robin
Problem parsing body: No signatures found matching the expected signature for payload
I'm using AWS API Gateway/Lambda which passes the request body as an actual JSON object to my Lambda function, where I am calling `stripe.webhooks.constructEvent` on it. It seems this function expects the payload to be stringified JSON, so I run `JSON.stringify` on the request body, but this fails to sign (I'm guessing because JSON.stringify subtly changes what the JSON string would look like coming from the server). Is it possible for constructEvent to detect if the payload is a JSON object and skip parsing it? I mean, in a way that maintains security?
[Feature Request] Using stripe-node outside of Node.js (e.g. Cloudflare Workers or Deno)
I'm trying to setup a Stripe service as a serverless function using the Cloudflare Workers platform. But the `stripe-node` package seems to depend on Node.js APIs. Is it possible to use a subset of `stripe-node`'s functionalities for Cloudflare Workers? Is supporting Cloudlfare Workers something you are interested in? Using Stripe in a no-cold-start serverless environment would be quite lovely. Would it be possible to extract the business logic that is agnostic to Node.js and expose it to users? So that we can use all kinds of platforms beyond Node.js, such as the Deno or Cloudflare Workers. It could be a new package, e.g. `stripe-js`. Thanks for what you are doing at Stripe, it's such a lovely product. Related tickets: https://github.com/stripe/stripe-node/issues/871 https://github.com/stripe/stripe-node/issues/773.
NextJS - Error: construction of webhook event returned an error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing
Hi I am pulling my hair out trying to pass raw JSON to NextJS 12 endpoint. I have tried sooo many solutions and I just cant get it to work. Please help as I have wasted half a day on this and I am at a loss. Create test webhook in stripe and passing in Secret Signing key from webhook test dashboard "whsec ..." I get a signature from the test webhook I trigger in the dashboard but I am constantly getting: Error: construction of webhook event returned an error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing The code below is from Reddit, where some had a similar issue. I have tried all of these solutions here: https://github.com/vercel/next.js/discussions/13405 Seems to be an issue in a lot of forums. Please help. Exhausted! [code block]
[Feature] Strongly Typed Event Type for Stripe.Event
Not too important, but it would be nice if this type: https://github.com/stripe/stripe-node/blob/02da7dc2c5edae280aaf5e3566f3b7b383024371/types/2020-03-02/Events.d.ts#L52 is strongly typed with all possible events. This would help catch bugs within switch statements or other logic statements, while also providing a nice menu of events within your IDE. If you are open to it, I don't mind making a quick script to take the webhook dropdown and convert it to a type definition for this variable in a PR.
Error payment_methods
Hello, I am migrating from the charges API to the payment intent API for 3D Secure. I am using Stripe API 6.36.0 and node 8.4 Initial request from the Stripe Dashboard: POST Request /v1/payment_methods [code block] Response body: [code block] Followed by POST request /v1/payment_intents [code block] And 400 Response: [code block] Can't understand why the payment method is being denied since it's confirmed just above. I am following your guide here: https://stripe.com/docs/payments/payment-intents/quickstart#manual-confirmation-flow Thanks so much for your help
Webhook signature verification and bodyParser.json issue
If you use in your express app `bodyParser.json()` for all routes, and then have a dedicated route for stripe's webhook, then the second call to `bodyParser.json({verify: ...})` as done in the example has no effect. I have the following code: [code block] The StripeRoute is defined exactly as the example. Unfortunately it doesn't work. Only if I comment out the first call to `bodyParser.json` does it work. Which mean that I cannot have a call to `bodyParser` just for my route, I need to add the `verify` function my top call to `bodyParser.json` and to avoid having to pay for the conversion all the time check for the Url to match my stripe route. Maybe the doc should reflect that, and if it is supposed to work then some guidance as it doesn't for me. Thanks!
Intermittent Error: write EPIPE when running stripe client in AWS Lambda
We're using the stripe node client 8.71.0 on an AWS Lambda running node 12.x. A stripe customers.list call is called first thing when the lambda executes. 33% of the time - we get this error on that call. It consistently happens so does not seem to be transient. I did read https://github.com/stripe/stripe-node/issues/650, and setting maxNetworkRetries in stripe to 2 seems to resolve the issue. However it seems that just masks the issue. Is this a stripe issue or AWS Lambda issue? Probably lambda, I submitted a request with AWS. But putting this here in case others run into it. 2020-10-13T12:02:58.032Z c184006d-fe96-490a-9bfe-696b8271769a ERROR StripeConnectionError: An error occurred with our connection to Stripe. at /var/task/node_modules/stripe/lib/StripeResource.js:234:9 at ClientRequest.<anonymous> (/var/task/node_modules/stripe/lib/StripeResource.js:489:67) at ClientRequest.emit (events.js:315:20) at ClientRequest.EventEmitter.emit (domain.js:483:12) at TLSSocket.socketErrorListener (_http_client.js:426:9) at TLSSocket.emit (events.js:315:20) at TLSSocket.EventEmitter.emit (domain.js:483:12) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:84:21) { type: 'StripeConnectionError', raw: { message: 'An error occurred with our connection to Stripe.', detail: Error: write EPIPE at WriteWrap.o
Webhook signature validation not working
Hi, I'm using the latest version of the stripe node.js library v4.19.0 and am trying to verify the signature in some test webhooks. It is failing with: error: Error SyntaxError: Unexpected token o in JSON at position 1 at Object.parse (native) at Object.Webhook.constructEvent (C:\Users\shovl\BitBucket\apm-billing\node_modules\stripe\lib\Webhooks.js:10:28) I followed the example here: https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/express.js Does the node.js library officially support webhook signatures yet? I noticed that the documentation does not list Node.js when referring to the "official" libraries. Thanks very much, Raymond
Automatic pagination with .list functions
I was wondering, are there built in options for automatic pagination using the node module?
A similar object exists in test mode, but a live mode key was used to make this request
I didn't know where else to post this, but I'm using this lib on our server. While testing, I had tried to add a real credit card to my account, which failed saying that I was in test mode. Now, both my client and server are running in test mode. And, when I try to add that same came, I get this error from the stripe API: No such token: ......; a similar object exists in test mode, but a live mode key was used to make this request. How can my card object exist in test mode?
fresh npm install stripe and error
Just importing stripe (`import StripeFactory from 'stripe';`) or using require shown in the README causes an error: [code block] I am using the fix mentioned here: https://github.com/webpack/webpack.js.org/issues/107 But can a maintainer fix this. The fix for your module is also at the link above, specifically: > The proper course is the ask the module author to make the module browser compatible. The author can add browser: { fs: false, child_process: false } to the package.json to tell webpack that it's ok for the module to get an empty object for these modules.
Webhook validate signing error: No signature found matching the expected signature for payload. | express
Another 'Webhook validate signing' issue! Whoooohooo ๐ฅณ Hi there! I am trying to built a Backend Server for a Web project with Google Cloud App Engine. What do I want to achieve: I want to verify all my received WebHooks from Stripe. What is my Problem: Currently I always get the same error message. [code block] I tried lot's of ways getting the raw body from the request and passing it to the `stripe.webhooks.constructEvent` Method. But all failed... My Code to reproduce [code block] As you can see it is nearly identical to the code from the Stripe Docs. I am not sure if App Engine, from Google Cloud, is parsing the request body before I can even touch it. My only reference point is that if I `console.log` out the complete request, the `body` part is always already parsed as a JSON, at least it seems like it. This is what I get when I do [code block]: [code block] What I have tried so far I tried many things. - [code block] Result: [code block] - [code block] Result: [code block] - [code block] (same as in 'My Code to reproduce') Result: [code block] - I have also tried the 'simple middleware' idea from jlomas-stripe. But still: Result: [code block] - [code block] Result: [code block] - [code block] Result: [code block] - [code block] Result: [code block] ... At the end, as you can see, I got very frustrated โน๏ธ ... Is this a Bug or is there a solution to fix it? I have only tested it with the Stripe CLI. | Name | Version | | -
Requests not Throwing Errors in NestJS App or AWS Lambda Node 20/18.x
Describe the bug Within NestJS, when performing calls such as `StripeClient.invoices.create` or other operations with bad data, requests hang indefinitely and don't throw errors. To Reproduce 1. Instantiate Stripe Client with `new Stripe(<API_KEY>)` 2. Wrap API call in `try/catch` block 3. Call `invoices.create` method with an invalid payload (Such as the one in the snippet) 4. Call will hang indefinitely neither erroring or succeeding Expected behavior When an API call fails on any non `2xx` status, it should throw an exception that can be caught by a `try/catch` block or a `.catch`. Code snippets [code block] OS Running on Docker `linux/amd64 node:20-alpine` Node version Node v20.18.0 Library version stripe node version 17.3.0 API version Default (Whatever you get when you don't specify any) Additional context Noticed running in a NestJS Application running in docker. I've tried: - Running requests through an Injectable Service that instantiates Stripe - Running the client directly in the Controller, or Service - Attempting to pass `httpClient` property in `new Stripe` with Axios and NestJS default HTTP Clients, to no avail. I also tried writing a script with the exact same code on the exact same version of node on a loose `.ts` file and running it with `ts-node` and it worked. I'll keep plowing through as it is critical for me to know when Stripe operations fail. If I find a solution, I will post it here.
Neither apiKey nor config.authenticator provided
Describe the bug When installing either the version 17.0.0 or 17.1.0 in a brand new next.js 14 from scratch after initializing stripe [code block] I get the following error: Neither apiKey nor config.authenticator provided This issue is not seen after downgrading to 16.12.0 To Reproduce Create a next.js project adding stripe version 17.1.0 add a lib folder with a new file stripe.ts with the following: [code block] run the project getting this error: Neither apiKey nor config.authenticator provided Expected behavior No error should be seen in either version 17.1.0 and 17.0.0 process.env.STRIPE_SECRET_KEY is well-defined, and I can console.log it value. Code snippets _No response_ OS macos Node version v20.11.0 Library version v17.1.0 API version 2024-09-30.acacia Additional context _No response_
The library doesn't work on Deno.
Describe the bug It was fixed in https://github.com/stripe/stripe-node/issues/997, but as I've pointed out in https://github.com/stripe/stripe-node/issues/997#issuecomment-1115941961, it doesn't work anymore. Maybe it's a regression. To Reproduce See https://github.com/stripe-samples/stripe-node-deno-samples/issues/1 for a description on how to reproduce. Expected behavior No TypeScript errors. Code snippets _No response_ OS macOS Node version Deno 1.21.3 Library version Latest API version 2020-08-27 Additional context Deno compatibility should be verified in CI, to prevent regressions.
Question about client-side use of stripe
Pardon the potential newbie question here, but, I'm wanting to create a token based off card data, without using the `stripe.js` code, and do it 100% in JS + React. So in one of my components, I do this: [code block] And I get this error: [code block] I'm assuming this is because I'm in a strictly client-side only environment here. But surely there has to be a way where I can take credit card information filled into a form, and generate a token based off that, in a PCI-compliant way? Full code: [code block]
An error occurred with our connection to Stripe. Request was retried 2 times.
Describe the bug I'm running a nextJS app project on Cloudflare workers. Using the latest Stripe node sdk version 20. On the production server when I try to create a checkout session from my api route, I see this error. `An error occurred with our connection to Stripe. Request was retried 2 times.` On localhost the exact same code is working perfectly fine. I double checked my env vars to make sure they're properly passed and correct in production, yet i'm still getting the error. ----- For now what I did is omit the SDK and just use a raw fetch request and it works in production. ----- To Reproduce 1. `npm create cloudflare@latest -- my-next-app --framework=next` https://developers.cloudflare.com/workers/framework-guides/web-apps/nextjs/ 2. `npm i stripe --save` 2. Create an api route like "/api/stripe-checkout" that uses the sdk like this `const session = await stripe.checkout.sessions.create({ ... })` This will cause the error 3. Deploy to Cloudflare workers 4. Call the endpoint Expected behavior The Stripe Checkout page should open the same way it does when I'm doing it from localhost. Code snippets [code block] OS macos Node version 21 Library version 20.0.0 API version 2025-11-17.clover Additional context _No response_
Better Access to Response Headers
On a successful API request the Stripe Node SDK doesn't provide a natural way of accessing response headers which can be useful in the case you're interested in response metadata (such as `Idempotency-Key` and `Request-ID`. For example today it is possible to do this but it is a little bit awkward since response metadata is exposed through an event emitter interface, while the response body is exposed through a callback interface: [code block] It would be a much better experience if this data was passed in the callback like so: [code block] My idea is that we add headers, statusCode and known Stripe headers such as `idempotencyKey` to go along with `requestId` to StripeResource here Thoughts?
maxNetworkRetries setting does not work
environment: node v10.x on AWS Lambda package version `"stripe": "^8.84.0"` we have the following code in our checkout lambda function, as suggested in official docs https://www.npmjs.com/package/stripe#network-retries [code block] in one of executions it thrown exception [code block] we expected request would be retried at least 3 times, but it did not, cause Lambda function duration was ~5000ms <img width="969" alt="_scr_ 2020-10-28 at 14 34 44" src="https://user-images.githubusercontent.com/155563/97489568-15d2d880-1936-11eb-95f3-344a0db83723.png">
stripe__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor
Describe the bug I receive an error when importing stripe: I'm using next 13 with app dir and latest version of stripe. To Reproduce 1. Create a next 13 app. 2. Create a `stripe.ts` file to initialize the library. 3. Try to use it in a server route. Expected behavior The library should return the expected Stripe object since it's not marking any apparent error. Code snippets _No response_ OS Windows 11 Node version Node v18.16.0 Library version "stripe": "12.14.0" API version 2022-11-15 Additional context _No response_
Delete request for 'price' object
There's currently no delete request for 'price' object with the api. https://stripe.com/docs/api/prices how do you delete prices? setting to active does not work. I am trying to delete 'product' object for connect users, but cannot because price is associated with product.
Feature Request: Request & Response logging
I'd like to propose adding a way of hooking into request and response events so they can logged. My use-case is for post-mortem of failed requests and general analysis. I find the dashboard's Logs view rather lacking (one has to advance through it page-by-page, it's slow, and search by request ID doesn't seem to be implemented). I could add a separate wrapper around the stripe API functions to do this, but I wanted to gauge if there was any more general interest in this to see if it's worth making a PR.