next-stripe
next-stripe copied to clipboard
Implement serializer options
It would be good to provide a set of serializers inside options that each method uses to return.
Here's what I'm currently thinking...
import NextStripe from 'next-stripe'
export default NextStripe({
secret_key: process.env.STRIPE_SECRET_KEY,
serializers: {
createPaymentIntent: ({ id, client_secret, status }) => ({ client_secret, status })
}
})
WDYT?
So I have a fork going with a basic implementation of how this would work.
The issue I have is not all requests are equal. Some requests you make to Stripe via these endpoints you may want to only return what you need, but to keep this layer simple, the proposal above should be fine for smaller use cases.
It might be worth exploring a aliases
config which allows you to create custom responses per function. For example;
import NextStripe from 'next-stripe'
export default NextStripe({
secret_key: process.env.STRIPE_SECRET_KEY,
aliases: {
createIntent: ({ createPaymentIntent }) => createPaymentIntent({ id, client_secret, status })
}
})
In my fork I only 'enable' the endpoints that have serializers too.