lemonsqueepy

repository·master·Indexed 42 days ago

https://github.com/mthli/lemonsqueepy

A Python-based account and payment management system for web applications that integrates with Lemon Squeezy. It provides infrastructure for Google Sign-in, order and subscription verification, and license activation. It can be deployed as a standalone REST or RPC service, or embedded directly into a Python web framework.

Tokens
1.3K
Snippets
7
Records
10
Agent score
5%

What's inside lemonsqueepy

  1. Overview of lemonsqueepy

    master

    lemonsqueepy is an account and payment management system designed for Web Applications that integrates with Lemon Squeezy. It provides the necessary infrastructure to handle authentication and subscription verification, reducing the development overhead required to implement Lemon Squeezy features manually.

    Supported scenarios include:

    • Google Sign-in
    • Order availability verification
    • Subscription availability verification
    • License availability verification
    • License activation
  2. Deployment patterns for lemonsqueepy

    master

    You can integrate lemonsqueepy into your architecture using one of three patterns:

    1. Standalone Service (Recommended): Run lemonsqueepy as an independent service and interact with it via RESTful requests from your frontend application.
    2. Standalone Service (RPC): Run lemonsqueepy as an independent service and interact with it via RPC requests from other backend services (e.g., Node.js, Go, etc.).
    3. Python Web Framework Integration: Embed lemonsqueepy directly into your existing Python web framework to build custom business logic on top of its core functionality.
  3. Check order status

    master

    Verify the existence of a specific order using the /api/orders/check endpoint. This requires a user_token to identify the user via decryption.

    ```bash
    GET /api/orders/check?\user_token=STR&store_id=STR&product_id=STR&variant_id=STR&test_mode=true

    Query Parameters:

    • user_token (required, string)
    • store_id (required, string)
    • product_id (required, string)
    • variant_id (required, string)
    • test_mode (optional, boolean, default: false)
  4. Activate a license

    master

    Activate a license for a specific instance using the /api/licenses/activate endpoint.

    Request Body Schema:

    • license_key (required, string)
    • instance_name (required, string)
    {
      "license_key": "string",
      "instance_name": "string"
    }
  5. Check license validity

    master

    Verify a license key using the /api/licenses/check endpoint.

    ```bash
    GET /api/licenses/check?\license_key=STR&test_mode=true

    Query Parameters:

    • license_key (required, string)
    • test_mode (optional, boolean, default: false)
  6. Register an anonymous user

    master

    Create a new anonymous user by sending a POST request to /api/user/register. This returns a User object containing a token. For all subsequent authenticated requests, include the token in the headers as: Authorization: Bearer USER_TOKEN.

    POST /api/user/register
    
    Response:
    {
      "id": "uuid",
      "token": "USER_TOKEN",
      "create_timestamp": 123456789,
      "update_timestamp": 123456789
    }
  7. Check subscription status

    master

    Verify the existence of a subscription using the /api/subscriptions/check endpoint. This requires a user_token to identify the user via decryption.

    ```bash
    GET /api/subscriptions/check?\user_token=STR&store_id=STR&product_id=STR&variant_id=STR&test_mode=true

    Query Parameters:

    • user_token (required, string)
    • store_id (required, string)
    • product_id (required, string)
    • variant_id (required, string)
    • test_mode (optional, boolean, default: false)
  8. Handle Lemon Squeezy webhooks

    master

    The endpoint /api/webhooks/lemonsqueezy receives incoming webhooks from Lemon Squeezy. It performs signature verification using check_signing_secret, parses the event, and dispatches it via dispatch_event.

    POST /api/webhooks/lemonsqueezy
  9. Authenticate via Google OAuth

    master

    Use the /api/user/oauth/google endpoint to authenticate users via Google. The request body must be a JSON object.

    Request Body Schema:

    • credential (required, string): The Google OAuth credential.
    • user_token (optional, string): An existing user token.
    • verify_exp (optional, boolean): Whether to verify expiration.
    {
      "credential": "string",
      "user_token": "optional_string",
      "verify_exp": false
    }