Stripe payment
CREDITS_API_ID = settings.STRIPE_CREDITS_API_ID
module-attribute
RETURN_URL_BASE = get_base_url(frontend_or_backend='frontend')
module-attribute
STRIPE_PUBLIC_KEY = settings.STRIPE_PUBLIC_KEY
module-attribute
logger = logging.getLogger(__name__)
module-attribute
router = APIRouter()
module-attribute
CreditsState
Bases: ExternalPaymentState
The credits page state.
show_progress = True
class-attribute
instance-attribute
status = 'Loading credits...'
class-attribute
instance-attribute
order_completed(checkout_uid, timeout=60)
async
staticmethod
Check if the credits have been updated.
wait_for_credit_update()
async
Wait for the credits to update.
ExternalPaymentState
Bases: AllLoaders, MyState
State for external payments page (i.e. redirect to Stripe checkout page).
amount = 1000
class-attribute
instance-attribute
checkout_url = ''
class-attribute
instance-attribute
handle_checkout()
async
Handle the stripe checkout process.
display_user_info()
external_payment_layout()
The layout of the page which includes a button to redirect to the external payment page.
fulfill_credits_order(checkout_uid, items)
async
Fulfill the order.
- Finish updating the associated Purchase model
- Add credits to associated user.
initialize_purchase_for_user(db, user_id, checkout_uid, item_id)
async
Initialize a purchase entry for the user.
Note: At this point we don't know the value of the purchase because it can be changed by the user in the checkout
payment_cancelled_layout()
The payment cancelled page layout.
payment_confirmed_layout()
The payment confirmed page layout.
payment_layout()
The payment page.
stripe_webhook(request)
async
Handle the stripe webhook.