Stripe Mutterings

Recently, I've been experimenting with integrating Stripe functionality into my GatsbyJS site. There are a variety of strategies for configuring these together. I've been particularly intrigued to find out more about using serverless functions, provided via the gatsbyjs ecosystem. While stripe does provide a very usable API for creating individual products which GatsbyJS can easily build into a static site. However, this implementation does not allow for any dynamic content decided at the runtime on the client browser to be used to set the price. This behaviour is actually a very good thing, as it ensures that client-side JS cannot overrule things on the configured on the Stripe-API server. EG the price of the item.

Suppose we would like a 'pay what you want" feature, a kind of tip jar. This is a not-uncommon feature and could be desirable in a wide variety of use-cases. From extra content like E-books, music, art, journalism, story-telling to extra web features accesible on the client. The key problem with allowing the web-client to have control over setting the price of an item is that we cannot trust the client, we need something server-side to validate the authenticity of the sale.

stripe-cli

Login to stripe CLI

stripe login

When the stripe API is configured in test mode it listens to all of the stripe event loop

TODO - is it actually loop? StripeAPI may be async.

stripe listen --forward-to localhost:8000/api/gatsby-theme-fhcra/stripe-webhook

Trigger a specific event from cli

https://stripe.com/docs/webhooks/test?locale=en-GB

//
stripe trigger checkout.session.completed
// adds metadata.github to payment session object
stripe trigger checkout.session.completed --add checkout_session:metadata.github=test