You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
566 B
Python
22 lines
566 B
Python
from asgiref.sync import sync_to_async
|
|
|
|
from core.models import Plan
|
|
|
|
|
|
async def assemble_plan_map(product_id_filter=None):
|
|
"""
|
|
Get all the plans from the database and create an object Stripe wants.
|
|
"""
|
|
line_items = []
|
|
for plan in await sync_to_async(list)(Plan.objects.all()):
|
|
if product_id_filter:
|
|
if plan.product_id != product_id_filter:
|
|
continue
|
|
line_items.append(
|
|
{
|
|
"price": plan.product_id,
|
|
"quantity": 1,
|
|
}
|
|
)
|
|
return line_items
|