2021-08-29 15:33:29 +02:00
|
|
|
import logging
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
from django.http import HttpRequest, HttpResponse
|
|
|
|
from django.shortcuts import render
|
|
|
|
|
2023-11-27 11:07:03 +01:00
|
|
|
from corporate.lib.stripe import EventStatusRequest, RealmBillingSession
|
2021-08-29 15:33:29 +02:00
|
|
|
from zerver.decorator import require_organization_member, zulip_login_required
|
|
|
|
from zerver.lib.request import REQ, has_request_variables
|
|
|
|
from zerver.lib.response import json_success
|
2023-11-30 12:43:36 +01:00
|
|
|
from zerver.lib.typed_endpoint import typed_endpoint
|
2021-08-29 15:33:29 +02:00
|
|
|
from zerver.models import UserProfile
|
|
|
|
|
|
|
|
billing_logger = logging.getLogger("corporate.stripe")
|
|
|
|
|
|
|
|
|
|
|
|
@require_organization_member
|
2023-11-30 14:03:25 +01:00
|
|
|
@typed_endpoint
|
2021-08-29 15:33:29 +02:00
|
|
|
def event_status(
|
|
|
|
request: HttpRequest,
|
|
|
|
user: UserProfile,
|
2023-11-30 14:03:25 +01:00
|
|
|
*,
|
|
|
|
stripe_session_id: Optional[str] = None,
|
|
|
|
stripe_payment_intent_id: Optional[str] = None,
|
2021-08-29 15:33:29 +02:00
|
|
|
) -> HttpResponse:
|
2023-11-27 11:07:03 +01:00
|
|
|
event_status_request = EventStatusRequest(
|
|
|
|
stripe_session_id=stripe_session_id, stripe_payment_intent_id=stripe_payment_intent_id
|
|
|
|
)
|
|
|
|
billing_session = RealmBillingSession(user)
|
|
|
|
data = billing_session.get_event_status(event_status_request)
|
|
|
|
return json_success(request, data)
|
2021-08-29 15:33:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
@zulip_login_required
|
2023-11-30 12:43:36 +01:00
|
|
|
@typed_endpoint
|
2021-08-29 15:33:29 +02:00
|
|
|
def event_status_page(
|
|
|
|
request: HttpRequest,
|
2023-11-30 12:43:36 +01:00
|
|
|
*,
|
|
|
|
stripe_session_id: str = "",
|
|
|
|
stripe_payment_intent_id: str = "",
|
2021-08-29 15:33:29 +02:00
|
|
|
) -> HttpResponse:
|
|
|
|
context = {
|
|
|
|
"stripe_session_id": stripe_session_id,
|
|
|
|
"stripe_payment_intent_id": stripe_payment_intent_id,
|
|
|
|
}
|
|
|
|
return render(request, "corporate/event_status.html", context=context)
|