kgajera / stripe-event-types Goto Github PK
View Code? Open in Web Editor NEWTypeScript typings for Stripe webhook events
Home Page: https://kgajera.github.io/stripe-event-types
License: MIT License
TypeScript typings for Stripe webhook events
Home Page: https://kgajera.github.io/stripe-event-types
License: MIT License
[12:28:04 PM] File change detected. Starting incremental compilation...
node_modules/stripe-event-types/index.d.ts:519:46 - error TS2694: Namespace '"stripe".Stripe' has no exported member 'Order'.
519 data: DiscriminatedEvent.Data<Stripe.Order>;
~~~~~
node_modules/stripe-event-types/index.d.ts:642:46 - error TS2694: Namespace '"stripe".Stripe' has no exported member 'Sku'.
642 data: DiscriminatedEvent.Data<Stripe.Sku>;
~~~
[12:28:15 PM] Found 2 errors. Watching for file changes.
When I deploy a google cloud function that has this in it:
import Stripe from 'stripe';
import "stripe-event-types";
I get this error back from google cloud at deploy time:
Provided module can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'stripe-event-types'
Require stack:
- /workspace/dist/cjs/paymentIntentPayloadToMutations.js
- /workspace/dist/cjs/index.js
- /workspace/node_modules/@google-cloud/functions-framework/build/src/loader.js
- /workspace/node_modules/@google-cloud/functions-framework/build/src/main.js
I'm 99% sure this is because stripe-event-types
isn't a module i.e. it has no main
property in package.json
What is the recommended way of permitting import of this package as a module? Thx!
When referencing the package I get an error saying
Namespace '"stripe".Stripe' has no exported member 'DiscriminatedEvent'.
I am working on a nestjs project and this is what my code looks like
import { Controller, Post, Req } from "@nestjs/common";
import { Request } from "express";
import Stripe from "stripe";
/// <reference types="stripe-event-types" />
@Controller("stripe")
export class StripeController {
private readonly stripe: Stripe;
constructor() {
this.stripe = new Stripe("secret", {
apiVersion: "2022-08-01",
});
}
@Post()
async webhook(@Req() req: Request) {
const event = this.stripe.webhooks.constructEvent(
req.body,
req.headers["stripe-signature"],
"secret"
) as Stripe.DiscriminatedEvent; // <--- error here
console.log(event);
}
}
I managed to fix the type issue by directly importing the package instead of referencing
import "stripe-event-types";
However, I now get this error when building or starting the dev server
Error: Cannot find module 'stripe-event-types'
Looks like we are missing the treasury event types
/// <reference types="stripe-event-types" />
import express from "express";
import Stripe from "stripe";
export const webhook = async (
req: express.Request,
res: express.Response
) => {
const event = req.body as Stripe.DiscriminatedEvent;
if (event.type === "treasury.outbound_payment.posted") { // causes a ts(2367) "no overlap" error
}
if (event.type === "treasury.outbound_payment.returned") { // causes a ts(2367) "no overlap" error
}
}
I'd be happy to jump in and help implement this if you can point me in the right direction
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.