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}")
Payment URL: https://billing.answer.ai/c/pay/cs_test_a1aD4GmxAkLT2DC7D90Okf5shUsexvDIkFWjNq1822ULt3LoTvtVB4Kf4u#fidkdWxOYHwnPyd1blpxYHZxWjA0VDFNMTFOQm10THI8VV1oX0xtbUt8R0RvX3RicGtMXWBKVm1oN01uYTF8VXZBSXRVSTVxazNqcUcxXHc0V1FGZEpdbDxGZElAc0BUZzNJZHVhfEZcM2tDNTV%2FSXZvYTRtTicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl

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}")
EUR Payment URL: https://billing.answer.ai/c/pay/cs_test_a1anFd3Qd3AeImckaCvhVS9lcltaLpCHKSDW5SKcwrQCHv65uCcz6TlQ0t#fidkdWxOYHwnPyd1blpxYHZxWjA0VDFNMTFOQm10THI8VV1oX0xtbUt8R0RvX3RicGtMXWBKVm1oN01uYTF8VXZBSXRVSTVxazNqcUcxXHc0V1FGZEpdbDxGZElAc0BUZzNJZHVhfEZcM2tDNTV%2FSXZvYTRtTicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl

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}")
Manual checkout URL: https://billing.answer.ai/c/pay/cs_test_a18dXJDe9wvbORZhoQfHZIFzp2CPLxATMwRD38IRTRUqjYtkYh67AFiTCl#fidkdWxOYHwnPyd1blpxYHZxWjA0VDFNMTFOQm10THI8VV1oX0xtbUt8R0RvX3RicGtMXWBKVm1oN01uYTF8VXZBSXRVSTVxazNqcUcxXHc0V1FGZEpdbDxGZElAc0BUZzNJZHVhfEZcM2tDNTV%2FSXZvYTRtTicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl

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