Buckets:
| import stripe | |
| from typing import List, Dict, Any | |
| def create_customer(email: str, name: str) -> Dict[str, Any]: | |
| """ | |
| Registers a new customer in Stripe. | |
| """ | |
| customer = stripe.Customer.create(email=email, name=name) | |
| return { | |
| "id": customer.id, | |
| "email": customer.email, | |
| "name": customer.name | |
| } | |
| def list_customers(limit: int = 10) -> List[Dict[str, Any]]: | |
| """ | |
| Retrieves a list of customers. | |
| """ | |
| customers = stripe.Customer.list(limit=limit) | |
| return [{ | |
| "id": c.id, | |
| "email": c.email, | |
| "name": c.name | |
| } for c in customers.data] | |
| def get_active_subscriptions(customer_id: str) -> List[Dict[str, Any]]: | |
| """ | |
| Lists active subscriptions for a specific customer. | |
| """ | |
| subscriptions = stripe.Subscription.list(customer=customer_id, status="active") | |
| return [{ | |
| "id": s.id, | |
| "status": s.status, | |
| "items": [item.price.id for item in s.items.data], | |
| "current_period_end": s.current_period_end | |
| } for s in subscriptions.data] | |
Xet Storage Details
- Size:
- 1.05 kB
- Xet hash:
- 5134988fb7ec46da5a59a81205b643358b6f34df823803be05abbbd055162659
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.