razorpay-ipn-django-handler


Namerazorpay-ipn-django-handler JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/yourusername/razorpay-ipn-django-handler
SummaryA Django app for handling Razorpay Instant Payment Notifications (IPN) in webhooks.
upload_time2024-10-27 19:32:49
maintainerNone
docs_urlNone
authorYour Name
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Razorpay IPN Django Handler

A Django app to handle Razorpay IPN webhook notifications with built-in signal support for tracking payment and subscription events.

## Installation

Install the package using pip:

```bash
pip install razorpay-ipn-django-handler
```

## Configuration

1. **Add to `INSTALLED_APPS`:**

   In your Django settings file (`settings.py`), add `razorpay_ipn_django_handler` to `INSTALLED_APPS`:

   ```python
   INSTALLED_APPS = [
       ...
       "razorpay_ipn_django_handler",
   ]
   ```

2. **Add URL configuration:**

   In your main `urls.py`, include the app’s URL configuration to handle Razorpay webhook notifications:

   ```python
   from django.urls import path, include

   urlpatterns = [
       ...
       path("payment/razorpay/", include("razorpay_ipn_django_handler.urls")),
   ]
   ```

   If your server is running on `testing.com`, then webhook notifications will be processed at the URL: `https://testing.com/payment/razorpay/webhook/`

   **Note**: The `"payment/razorpay/"` part of the URL is customizable to suit your needs.

3. **Configure Razorpay Environment Variables:**

   Add your Razorpay credentials to `settings.py` using the following environment variables. Replace the placeholder values with your actual credentials from the Razorpay Dashboard:

   ```python
   RAZORPAY_WEBHOOK_SECRET = "your_webhook_secret_here"  # Check your Razorpay Dashboard for this secret
   RAZORPAY_API_KEY = "your_api_key_here"  # Check your Razorpay Dashboard for your API key
   RAZORPAY_API_SECRET = "your_api_secret_here"  # Check your Razorpay Dashboard for your API secret
   ```

4. **Run Migrations:**

   Run migrations to create the necessary database tables for tracking IPN events:

   ```bash
   python manage.py makemigrations
   python manage.py migrate
   ```

## Signal Setup

You can listen for valid and invalid IPN events using signals provided by `razorpay_ipn_django_handler`. Here’s how to set up signal handlers:

1. **Import the signals and register handlers** in one of your Django app files, such as `signals.py`:

   ```python
   from django.dispatch import receiver
   from razorpay_ipn_django_handler.signals import valid_razorpay_ipn_received, invalid_razorpay_ipn_received
   from razorpay_ipn_django_handler.models import RazorpayIPN

   # Handle valid IPN events
   @receiver(valid_razorpay_ipn_received)
   def handle_valid_ipn(sender, instance, **kwargs):
       # `instance` provides the Razorpay IPN object with event data
       print("Received valid IPN event:", instance.event)

   # Handle invalid IPN events
   @receiver(invalid_razorpay_ipn_received)
   def handle_invalid_ipn(sender, **kwargs):
       print("Invalid IPN received")
       # Log or handle invalid IPN events
   ```

   Here, `instance` is the `RazorpayIPN` object containing event data, which you can use to access information such as `event`, `payment_id`, `subscription_id`, and other IPN-related details.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yourusername/razorpay-ipn-django-handler",
    "name": "razorpay-ipn-django-handler",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Your Name",
    "author_email": "your.email@example.com",
    "download_url": "https://files.pythonhosted.org/packages/4c/62/cc2edf4ec08882a82482a8c9c330ef7f5c568675767eac3885e86cb91407/razorpay-ipn-django-handler-0.1.0.tar.gz",
    "platform": null,
    "description": "# Razorpay IPN Django Handler\n\nA Django app to handle Razorpay IPN webhook notifications with built-in signal support for tracking payment and subscription events.\n\n## Installation\n\nInstall the package using pip:\n\n```bash\npip install razorpay-ipn-django-handler\n```\n\n## Configuration\n\n1. **Add to `INSTALLED_APPS`:**\n\n   In your Django settings file (`settings.py`), add `razorpay_ipn_django_handler` to `INSTALLED_APPS`:\n\n   ```python\n   INSTALLED_APPS = [\n       ...\n       \"razorpay_ipn_django_handler\",\n   ]\n   ```\n\n2. **Add URL configuration:**\n\n   In your main `urls.py`, include the app\u2019s URL configuration to handle Razorpay webhook notifications:\n\n   ```python\n   from django.urls import path, include\n\n   urlpatterns = [\n       ...\n       path(\"payment/razorpay/\", include(\"razorpay_ipn_django_handler.urls\")),\n   ]\n   ```\n\n   If your server is running on `testing.com`, then webhook notifications will be processed at the URL: `https://testing.com/payment/razorpay/webhook/`\n\n   **Note**: The `\"payment/razorpay/\"` part of the URL is customizable to suit your needs.\n\n3. **Configure Razorpay Environment Variables:**\n\n   Add your Razorpay credentials to `settings.py` using the following environment variables. Replace the placeholder values with your actual credentials from the Razorpay Dashboard:\n\n   ```python\n   RAZORPAY_WEBHOOK_SECRET = \"your_webhook_secret_here\"  # Check your Razorpay Dashboard for this secret\n   RAZORPAY_API_KEY = \"your_api_key_here\"  # Check your Razorpay Dashboard for your API key\n   RAZORPAY_API_SECRET = \"your_api_secret_here\"  # Check your Razorpay Dashboard for your API secret\n   ```\n\n4. **Run Migrations:**\n\n   Run migrations to create the necessary database tables for tracking IPN events:\n\n   ```bash\n   python manage.py makemigrations\n   python manage.py migrate\n   ```\n\n## Signal Setup\n\nYou can listen for valid and invalid IPN events using signals provided by `razorpay_ipn_django_handler`. Here\u2019s how to set up signal handlers:\n\n1. **Import the signals and register handlers** in one of your Django app files, such as `signals.py`:\n\n   ```python\n   from django.dispatch import receiver\n   from razorpay_ipn_django_handler.signals import valid_razorpay_ipn_received, invalid_razorpay_ipn_received\n   from razorpay_ipn_django_handler.models import RazorpayIPN\n\n   # Handle valid IPN events\n   @receiver(valid_razorpay_ipn_received)\n   def handle_valid_ipn(sender, instance, **kwargs):\n       # `instance` provides the Razorpay IPN object with event data\n       print(\"Received valid IPN event:\", instance.event)\n\n   # Handle invalid IPN events\n   @receiver(invalid_razorpay_ipn_received)\n   def handle_invalid_ipn(sender, **kwargs):\n       print(\"Invalid IPN received\")\n       # Log or handle invalid IPN events\n   ```\n\n   Here, `instance` is the `RazorpayIPN` object containing event data, which you can use to access information such as `event`, `payment_id`, `subscription_id`, and other IPN-related details.\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Django app for handling Razorpay Instant Payment Notifications (IPN) in webhooks.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/yourusername/razorpay-ipn-django-handler"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c97ff20339ee2aa490037af4773c0cfcee34c6719a8a7e0f35c91adde239dc0a",
                "md5": "f50bec6d4d3f520c27a14dd93aad4e56",
                "sha256": "5a0723fd2ef40b6c628b5a56284c5e8862cb7d376cf7bc0c41c955ad6700f4d9"
            },
            "downloads": -1,
            "filename": "razorpay_ipn_django_handler-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f50bec6d4d3f520c27a14dd93aad4e56",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 19184,
            "upload_time": "2024-10-27T19:32:48",
            "upload_time_iso_8601": "2024-10-27T19:32:48.463439Z",
            "url": "https://files.pythonhosted.org/packages/c9/7f/f20339ee2aa490037af4773c0cfcee34c6719a8a7e0f35c91adde239dc0a/razorpay_ipn_django_handler-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c62cc2edf4ec08882a82482a8c9c330ef7f5c568675767eac3885e86cb91407",
                "md5": "0ebc0f8f5b75f3f26ff0d58c08443352",
                "sha256": "79dde99c5d8f588450746c2472d3002fb52e3effe9ffb79a582d01214bbe3fc5"
            },
            "downloads": -1,
            "filename": "razorpay-ipn-django-handler-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0ebc0f8f5b75f3f26ff0d58c08443352",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 17860,
            "upload_time": "2024-10-27T19:32:49",
            "upload_time_iso_8601": "2024-10-27T19:32:49.688719Z",
            "url": "https://files.pythonhosted.org/packages/4c/62/cc2edf4ec08882a82482a8c9c330ef7f5c568675767eac3885e86cb91407/razorpay-ipn-django-handler-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-27 19:32:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "razorpay-ipn-django-handler",
    "github_not_found": true,
    "lcname": "razorpay-ipn-django-handler"
}
        
Elapsed time: 0.53586s