Closed dalanmiller closed 4 months ago
Hi @dalanmiller
Awesome! This is a good example of how to use Bindings and Variables and use c.set/c.var
. It looks good to me.
I'd like the Stripe Developer Advocate @hideokamoto to review this one!
Thank you @yusukebe!
Hidetaka - I'll message you on Slack. 🙇🏻♂️
I apologize for the delay in confirming! I think this is a very simple yet great sample for understanding Hono's capabilities.
@dalanmiller
I have one question about this sample. It seems that both Live and Test API keys for Stripe need to be set. Since this is a sample project, would it be okay to simplify it to just one environment variable, say STRIPE_API_KEY
? I thought that if we were to use it in production, we could simply set the Live secret key to this variable.
@yusukebe Also, regarding the Hono and Stripe sample, I have a suggestion. How about creating a pull request to this repository with a very simple e-commerce app sample using Hono & Stripe? After looking at this sample, I thought it could serve as a demo for SPAs/MPAs built with Hono, combining Cloudflare's KV or D1.
If it's okay to request a second integration sample with Stripe, I will go ahead and build it based on this demo.
Hi @hideokamoto-stripe
Also, regarding the Hono and Stripe sample, I have a suggestion. How about creating a pull request to this repository with a very simple e-commerce app sample using Hono & Stripe? After looking at this sample, I thought it could serve as a demo for SPAs/MPAs built with Hono, combining Cloudflare's KV or D1.
This will be a super exciting project! But I'm considering we don't have to include the "e-commerce app sample" in this repo because perhaps it will be hard to maintain it (though this PR project is okay because it is so tiny).
What about you creating it for your personal project on GitHub and creating a link to it from the official Hono website?
I have one question about this sample. It seems that both Live and Test API keys for Stripe need to be set. Since this is a sample project, would it be okay to simplify it to just one environment variable, say STRIPE_API_KEY? I thought that if we were to use it in production, we could simply set the Live secret key to this variable.
Sounds good @hideokamoto-stripe - I chose TEST and SECRET as it was the exact scenario that I had to solve for and didn't have an example to show me. For the purposes of a Tap to Pay Terminal client I wanted to be able to select livemode
or testmode
and have a single Cloudflare worker backing it.
But, I will simplify it down to just one environment variable per your suggestion.
Hi @dalanmiller
Is this ready to be merged?
IMO
It looks ready to merge. We can discuss how we will import the Stripe API key, but the most important point is showing a new example about how to use the c.set
and c.var
.
@dalanmiller Is it okay to merge this PR? After that, I'm going to make a new PR to discuss about the way how we can handle the Stripe API key.
@dalanmiller @hideokamoto-stripe
One thing we have to consider again is whether the project name api-client
is good or not. When I saw the name api-client
, I imagined "HTTP Client" by the hc
feature. So it may not be a proper name. But I don't have a good name now. Do you have any thoughts? Or, simply make the name stripe
, though the taste is different from that of other projects.
Now having another thought, the main purpose of the example is to show how to access environment variables in Typescript. The fact that the env var is an API key is secondary/irrelevant.
I think env-vars
or env-vars-[typescript-ts]
?
Now having another thought, the main purpose of the example is to show how to access environment variables in Typescript. The fact that the env var is an API key is secondary/irrelevant.
Indeed, you are right!
I think
env-vars
orenv-vars-[typescript-ts]
?
I like env-vars
! Shall we go with it?
Ready for review again @yusukebe 🕵🏻♂️
@dalanmiller
Oops. It has a conflict. Can you resolve it?
Good now @yusukebe
@dalanmiller Thanks! Mergin now.
Hi there Hono team!
I wanted to add an example to help others through the issue I encountered and discussed over here: https://github.com/orgs/honojs/discussions/2552
I realized I was trying to bring something from Flask into Hono which is their
before_request
&after_request
decorators which pretty much run them when their name suggests.https://flask.palletsprojects.com/en/3.0.x/api/#flask.Flask.before_request https://flask.palletsprojects.com/en/3.0.x/api/#flask.Flask.after_request
Where I got stuck though and what some of the helpful replies on the discussion got me to was the necessary extensions of
Variables
andBindings
when instantiating theHono()
app.Hopefully this example makes this clear for the next person!