How to Accept One-Time Payments

Create payment links for single purchases

This guide shows you how to create one-time payment links using FastStripe’s simplified API.

Problem

You want to accept a one-time payment for a product or service without dealing with the complexity of creating products, prices, and checkout sessions manually.

Solution

Use FastStripe’s one_time_payment() method which handles all the setup automatically.

from faststripe.core import StripeApi
import os

# Initialize the API
sapi = StripeApi(os.environ['STRIPE_SECRET_KEY'])

Basic one-time payment

# Create a simple payment link
checkout = sapi.one_time_payment(
    product_name='Digital Course',
    amount_cents=4999,  # $49.99
    success_url='https://yoursite.com/success',
    cancel_url='https://yoursite.com/cancel'
)

print(f"Payment URL: {checkout.url[:64]}...")
Payment URL: https://billing.answer.ai/c/pay/cs_test_a1PHxAtrdONHkxoUdHYyh35T...

Different currencies

FastStripe supports all currencies that Stripe accepts:

# Euro payment
eur_checkout = sapi.one_time_payment(
    product_name='European Product',
    amount_cents=2500,  # €25.00
    success_url='https://yoursite.com/success',
    cancel_url='https://yoursite.com/cancel',
    currency='eur'
)

print(f"EUR Payment URL: {eur_checkout.url[:64]}...")
EUR Payment URL: https://billing.answer.ai/c/pay/cs_test_a1OHTPiO2tK15czmCihujxuz...

Manual approach

If you need more control, you can create products, prices, and checkout sessions manually:

# Create product
product = sapi.products.post(
    name='Advanced Course',
    description='Complete Python development course'
)

# Create price
price = sapi.prices.post(
    product=product.id,
    unit_amount=9999,  # $99.99
    currency='usd'
)

# Create checkout session
checkout = sapi.checkout.sessions_post(
    mode='payment',
    line_items=[{
        'price': price.id,
        'quantity': 1
    }],
    success_url='https://yoursite.com/success',
    cancel_url='https://yoursite.com/cancel'
)

print(f"Manual checkout URL: {checkout.url[:64]}...")
Manual checkout URL: https://billing.answer.ai/c/pay/cs_test_a1kPF7S9rHdvgTBrQVc7UgUO...

Tips

  • Use test mode (keys starting with sk_test_) during development
  • FastStripe automatically creates products and prices if they don’t exist
  • Store the checkout session ID for tracking payments
  • Use webhooks to handle successful payments in your application