Skip to content

Latest commit

 

History

History
70 lines (57 loc) · 2.72 KB

README.md

File metadata and controls

70 lines (57 loc) · 2.72 KB

Simple Stripe Donation Page

This project demonstrates a basic use case for Stripe Payment Link to create a simple donation page. It utilizes webhooks to integrate Stripe with a Laravel project. Upon successful payment, Stripe sends an event to the Laravel project, which then inserts a new donation record into the database. A custom field, message, is implemented to allow users to add a message with their donation. This message is also sent to the Laravel project via Stripe's webhook.

Features

  • Simple donation page powered by Stripe Payment Link.
  • Webhook integration to process successful payments.
  • Custom message field for donors.

Prerequisites

  • A Stripe account.
  • A configured Payment Link product in your Stripe dashboard.

Setup Instructions

Follow these steps to run the project locally:

  1. Clone the Project

    git clone https://github.com/hilmihidyt/stripe-donation
    cd stripe-donation
  2. Configure Environment

    • Copy the .env.example file to .env:
      cp .env.example .env
    • Update the .env file with your database credentials and Stripe API keys.
  3. Run Migrations

    php artisan migrate
  4. Start the Development Server

    php artisan serve
  5. Setup Webhook with Ngrok

    • Install and run Ngrok:
      ngrok http 8000
    • Copy the forwarding URL from Ngrok (e.g., https://<random-id>.ngrok.io).
    • Configure the following webhook endpoints in your Stripe dashboard:
      1. Event: charge.succeeded
        Endpoint: https://{random-id}.ngrok-free.app/api/donation
      2. Event: checkout.session.completed
        Endpoint: https://{random-id}.ngrok-free.app/api/checkout-session-completed

How It Works

  1. A user accesses the donation page and is redirected to Stripe Payment Link.
  2. The user fills in their donation details, including the custom message field.
  3. Upon successful payment, Stripe sends a webhook event to the Laravel backend.
  4. The Laravel backend processes the webhook event and stores the donation data, including the message field, in the database.

Project Structure

  • Routes: Handles the webhook endpoint.
  • Controllers: Processes the webhook event.
  • Migrations: Sets up the database tables for storing donations.

Notes

  • Ensure your Stripe account and Payment Link are properly configured.
  • Ngrok is required for local development to expose your server to the internet.
  • Test the webhook endpoint using Stripe's test mode before going live.

Troubleshooting

  • Check the Laravel logs (storage/logs/laravel.log) for any errors.
  • Use Stripe's dashboard to inspect webhook events and responses.