This is a sample project demonstrating a payment integration using the Gin framework in Go and the Cashfree Payment Gateway.
- Frontend: A simple HTML page to display a dummy product with a "Buy Now" button.
- Backend:
- Create an order and generate a payment session ID using the Cashfree SDK.
- Fetch order status and display it on a status page.
- Webhook support for payment updates.
- Go 1.18 or later
- Cashfree account for API credentials
- Postman or
curlfor testing API endpoints
- Clone the repository:
git clone <repository-url> cd gin
- Install dependencies: go mod tidy
- Create a .env file in the root directory with the following content: CASHFREE_CLIENT_ID="your_client_id" CASHFREE_CLIENT_SECRET="your_client_secret"
- Run the application: go run cmd/main.go
- Open your browser and navigate to http://localhost:8080.
-
GET / Serves the index.html page with a dummy product.
-
POST /create-order Creates an order and returns a payment session ID.
-
GET /status Fetches the order status and displays it on the status.html page.
-
POST /webhook Handles webhook notifications from Cashfree.
Use Postman or curl to test the /create-order and /status endpoints. Simulate a payment flow using the Cashfree sandbox environment.
This project uses the Cashfree Go SDK for payment gateway integration. Ensure you have valid credentials and use the sandbox environment for testing.