Skip to main content

LFS Stripe

A Django Lightning Fast Shop (LFS) payment integration for Stripe.

Overview

This package provides Stripe payment integration for LFS e-commerce platform. It allows customers to make secure credit card payments through Stripe's payment processing system.

Features

  • Seamless integration with LFS checkout process
  • Secure credit card processing via Stripe API
  • Support for payment intents
  • Client-side card validation

Installation

  1. Install the package:

    pip install lfs-stripe
    
  2. Add to your INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        # ...
        'lfs_stripe',
        # ...
    ]
    
  3. Configure Stripe in settings.py (best read from environment variables):

    STRIPE_SECRET_KEY = os.environ["STRIPE_SECRET_KEY"]            # sk_..., stays on the server
    STRIPE_PUBLISHABLE_KEY = os.environ["STRIPE_PUBLISHABLE_KEY"]  # pk_..., sent to the browser
    STRIPE_SHOP_NAME = "My shop"  # prefix of the cart and order references shown in Stripe
    

    Both keys must belong to the same Stripe account.

  4. Include the URLs in your project's urls.py:

    urlpatterns = [
        # ...
        path('stripe/', include('lfs_stripe.urls')),
        # ...
    ]
    

Request flow

The URLs must be included under stripe/, because the checkout script calls these paths.

  1. The checkout script fetches the publishable key from /stripe/config/ and starts Stripe Elements.
  2. On payment it calls /stripe/create-payment-intent/. The server creates a PaymentIntent for the cart total with the secret key and returns its client secret.
  3. The browser confirms the payment with Stripe (confirmCardPayment) using the client secret.
  4. On success it calls /stripe/create-order/ with the PaymentIntent's id. The server retrieves the PaymentIntent from Stripe and creates the paid order only if it succeeded for the cart's total and was made for this cart; then it adds the order number to the PaymentIntent. Otherwise it answers 400 and logs the reason.
  5. The browser goes to the thank-you page.

Payments are in EUR (fixed in create_payment_intent). The PaymentIntent is always created on the server: only there is the secret key, and the amount comes from the cart, so it cannot be changed in the browser.

Tests

The tests run with a shop's settings, e.g. from lfs-dev: bin/test there, or in this folder PYTHONPATH=<lfs-dev> DJANGO_SETTINGS_MODULE=project.settings <lfs-dev>/.venv/bin/python -m pytest.

tests/test_stripe_sandbox.py pays with Stripe's test cards against Stripe itself (accepted, declined, insufficient funds, expired, 3-D Secure not completed, not confirmed, made-up payment). It runs only when STRIPE_TEST_SECRET_KEY holds a test secret key (sk_test_… of a sandbox or test mode) and is skipped otherwise.

Differences from LFS-PayPal

While both lfs-stripe and lfs-paypal provide payment integration for LFS, there are several key differences:

  1. Payment Processing:

    • Stripe processes credit card payments directly on your site (with client-side tokenization)
  2. API Integration:

    • Stripe uses a modern API with Payment Intents
  3. Payment Methods:

    • Stripe primarily handles credit card payments directly
  4. User Experience:

    • Stripe allows customers to stay on your site throughout the checkout process

Metadata

Release files for lfs-stripe 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lfs-stripe 1.0.3
File Size Uploaded Provenance Actions
lfs_stripe-1.0.3.tar.gz 10.2 kB Without provenance Details for lfs_stripe-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lfs-stripe 1.0.3
File Interpreter ABI Platform Actions
lfs_stripe-1.0.3-py3-none-any.whl Python 3 none any Details for lfs_stripe-1.0.3-py3-none-any.whl

Total release size: 19.2 kB

Release files / lfs_stripe-1.0.3.tar.gz

Download URL lfs_stripe-1.0.3.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d18e03cba36c1755354bf9f493f21d7a308b329c664ff0f392cc8017e0866f02
BLAKE2b-256 checksum
How to use checksums
bfcf9c51f8942f6e93a844cd8f9f9214f62de0be6e1f0e4e4f3e9dd8ca6e5830
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.3

Release files / lfs_stripe-1.0.3-py3-none-any.whl

Download URL lfs_stripe-1.0.3-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f122f28ee24c22e30ecad6749f0501ff4456f3b24d39bc322963e47ad9cd9971
BLAKE2b-256 checksum
How to use checksums
14d205c09d573353c78252169916bfbdea570395397834d9e7104f4a01227520
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.3

Security for lfs-stripe 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page