Payment api#38
Merged
Merged
Conversation
# Conflicts: # SCHEMA.md # main.go # mock_db.go
Refactor database access methods to use actual DB queries instead of mock data. Implement functions to initialize the database connection and retrieve schools, grades, equipment, and user information from the database.
Refactor DB methods to use actual database queries
Payment api
…t-backend Signed-off-by: Noam Ben Shimon <Noambs2999@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a Stripe Checkout payment endpoint and, alongside it, a sizable infrastructure shift: handler code is split out of main.go into per-feature files, mock-backed handlers are replaced with a PostgreSQL-backed query layer (db_api.go + InitDB), .env loading via godotenv is added, Equipment gains a price field, and the Docker/go-mod tooling is updated for the new dependencies.
Changes:
- Add
/create-checkout-sessionStripe Checkout handler plusgodotenv-based config loading. - Replace mock handlers with real Postgres-backed implementations and split handlers into
class_handlers.go,cart_handlers.go,user_handlers.go. - Extend
Equipmentwithprice, dropTimestampfromCartEntry, and update Dockerfile/go.mod/go.sum for the new dependencies.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| payment_handlers.go | New Stripe Checkout handler (input forwarded directly to Stripe). |
| db_api.go | New Postgres connection + query functions for schools/grades/equipment/users/cart. |
| main.go | Adds godotenv load, InitDB(), new route, CORS header tweak, Equipment.Price; old inline handlers removed. |
| user_handlers.go | Extracted auth/login/logout handlers; now use DB-backed user lookups. |
| class_handlers.go | Extracted schools/grades/equipment handlers calling DB functions. |
| cart_handlers.go | Extracted cart handler using getCartByUserID / saveCart. |
| mock_db.go | Equipment literals updated with Price; CartEntry.Timestamp removed. |
| go.mod / go.sum | Added lib/pq, joho/godotenv, stripe-go/v82 dependencies. |
| Dockerfile | Copies go.sum, switches to go mod download, renames binary to motzklist-backend. |
| .gitignore | Ignores .env. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Added .idea/ to .gitignore - Fixed SQL query syntax in getCartItemsFromApply function - Updated database connection string in InitDB function - Changed endpoint for checkout session to /api/create-checkout-session - Improved error handling in CreateCheckoutSession function - Updated currency in checkout session to ILS Signed-off-by: Noam Ben Shimon <Noambs2999@gmail.com>
…NTEND_URL is configured Signed-off-by: Noam Ben Shimon <Noambs2999@gmail.com>
Signed-off-by: Noam Ben Shimon <Noambs2999@gmail.com>
Signed-off-by: Noam Ben Shimon <Noambs2999@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.