php - Can I charge a variable amount to Stripe as a subscription? -
i want use stripe api bill users every month amount specify. appears stripe not allow websites create subscription without first setting plan manually, restricting people can bill predesignated amounts.
what best way this?
you can! before talk more how works in practice, make sure understand when invoice open modification.
subscribing customer new plan, or updating customer's existing subscription
if subscribing customer plan via api, won't able add custom fees after initial invoice created since closed. means you'll need setup custom amounts before initial invoice created. can in 1 of 2 ways:
set account_balance when creating customer or updating customer's subscription.
create invoice items before customer subscribed plan, , create subscription via update customer subscription call.
in either case, we'll pull account balance or outstanding invoice items initial invoice, customer still charged setup fees. these one-time charges combining subscription's recurring charges. since these being added invoice total, single charge being created.
subscription renewals
the account balance , invoice items one-time adjustments customer's account, won't automatically applied each month. if service uses metered billing or needs add custom amounts taxes or other dynamic costs, need create invoice items every month.
to started, use webhooks listen invoice.created event. whenever invoice open modification, webhook endpoint can create invoice item references existing invoice's id. we'll automatically pull amount invoice total before charging customer, approximately hour after invoice's creation.
link: https://support.stripe.com/questions/metered-subscription-billing
Comments
Post a Comment