Skip to content

Payment api#38

Merged
NoamBenShimon merged 33 commits into
mainfrom
payment-api
May 27, 2026
Merged

Payment api#38
NoamBenShimon merged 33 commits into
mainfrom
payment-api

Conversation

@NoamBenShimon
Copy link
Copy Markdown
Contributor

No description provided.

Avnermond12344 and others added 28 commits December 4, 2025 20:49
# 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
…t-backend

Signed-off-by: Noam Ben Shimon <Noambs2999@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-session Stripe Checkout handler plus godotenv-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 Equipment with price, drop Timestamp from CartEntry, 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.

Comment thread db_api.go Outdated
Comment thread main.go Outdated
Comment thread payment_handlers.go Outdated
Comment thread payment_handlers.go
Comment thread db_api.go
Comment thread db_api.go Outdated
Comment thread db_api.go
Comment thread go.mod Outdated
Comment thread user_handlers.go
Comment thread db_api.go
NoamBenShimon and others added 5 commits May 27, 2026 11:19
- 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>
@NoamBenShimon NoamBenShimon merged commit 7206d58 into main May 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants