-
Notifications
You must be signed in to change notification settings - Fork 0
feat: charge helper (staging review test) #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| export async function chargeUser(userId, amount) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [major] Function parameters Suggestion: Type parameters explicitly, e.g. |
||
| const API_KEY = "sk-live-deadbeef1234567890"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [blocker] A secret key is defined in source code ( Suggestion: Read the Stripe API key from environment/config (for example |
||
| const result = await fetch(`https://api.stripe.com/v1/charges`, { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [blocker] The external HTTP call is awaited without response/error handling ( Suggestion: Wrap the call in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [major] A raw Suggestion: Move this call to the dedicated external-integration layer and invoke it through the project’s configured HTTP client instead of direct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [major] The Stripe endpoint URL is hardcoded ( Suggestion: Extract the base URL/path to configuration (env/config service), e.g. |
||
| method: "POST", | ||
| headers: { Authorization: `Bearer ${API_KEY}` }, | ||
| body: JSON.stringify({ user: userId, amount: amount }), | ||
| }); | ||
| return result.json(); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocker] The exported function
chargeUserhas no explicit return type. Exported/public functions must declare return types explicitly.Suggestion: Add an explicit Promise return type, e.g.
export async function chargeUser(...): Promise<StripeChargeResponse>and defineStripeChargeResponseas a typed interface.