← Back to all examples

Stripe Payment Authorization

limetry + StripePythonrecommendedautomated tests

Authorize Stripe charges and refunds with limetry before the Stripe API call. Deny payouts; approval_required above cost threshold.

Source folder: examples/stripe-python-payment-authorization

Documentation & Guide

README.md

Stripe Python payment authorization

Authorize Stripe charges and refunds with the limetry Python SDK before the Stripe API call runs.

Install

pip install -e ../../packages/sdk-python
pip install -r requirements.txt

Pattern

from authorize import authorize_payment, build_engine
import stripe

engine = build_engine()
outcome = authorize_payment(
  action_type="stripe.charge",
  amount_minor=1200,
  resource="cus_123",
  engine=engine,
  execute=lambda: stripe.Charge.create(amount=1200, currency="usd", customer="cus_123"),
)

Test

pytest test_authorize.py

Source Files

4 files in examples/stripe-python-payment-authorization
markdown
# Stripe Python payment authorization

Authorize Stripe charges and refunds with the [`limetry`](../../packages/sdk-python)
Python SDK before the Stripe API call runs.

## Install

```bash
pip install -e ../../packages/sdk-python
pip install -r requirements.txt
```

## Pattern

```python
from authorize import authorize_payment, build_engine
import stripe

engine = build_engine()
outcome = authorize_payment(
  action_type="stripe.charge",
  amount_minor=1200,
  resource="cus_123",
  engine=engine,
  execute=lambda: stripe.Charge.create(amount=1200, currency="usd", customer="cus_123"),
)
```

## Test

```bash
pytest test_authorize.py
```

Contact

Talk to the Limetry team

Questions about self-run Limetry, Limetry Cloud, or partnerships — send a note.  Open contact.