I have made a bunch of endpoints for subscriptions like modify, cancel, and create Customer.create, all of these take a metadata parameter, that will be available in the hook event, except when i use stripe.Customer.create
i get an error saying
Received unknown parameter: metadata
Here’s a simplified version of my code:
@routes.post("/company_management/resume-subscription")
async def resume_subscription(request):
try:
data = await request.json()
subscription_id = data.get("subscription_id")
user = await get_user(request)
if not user:
return web.json_response({"error": "Not found"}, status=404)
# update the user status
async with request.app["db"].acquire() as conn:
async with conn.cursor(aiomysql.DictCursor) as cur:
user_id = user.get("user_id")
await stripe.Subscription.resume(
subscription_id,
billing_cycle_anchor='unchanged',
metadata={"user_id": user_id}
)
return web.json_response({"message": "Subscription resumed successfully", "status": "success"})
except Exception as e:
return web.json_response({"error": str(e)}, status=400)
I know I could resume a subscription using the Subscription.Modify like:
await stripe.Subscription.modify(
subscription_id,
pause_collection='',
metadata={"user_id": user_id}
)
I want to keep this as a last resort, and use the Resume method because it may trigger the Subscription.resumed
webhook.
some extra questions, the modify method, if used to pause a subscription it only triggers the Subscription.updated
webhook, how to trigger the Subscription.paused
?