createCheckoutSession method
Request a Stripe Checkout URL for the given plan.
- For
teamandenterprise,orgIdis required and must be owned by the caller. - For
professionalon the web, omitorgId. seatsis only used for per-seat org plans; it defaults to the current seat count on the server side if omitted.
Implementation
Future<String> createCheckoutSession({
required String plan,
required String interval,
String? orgId,
int? seats,
}) async {
final response = await _client.functions.invoke(
'create-checkout-session',
body: {
'plan': plan,
'interval': interval,
'org_id': ?orgId,
'seats': ?seats,
},
);
if (response.status != 200) {
throw StateError(
'createCheckoutSession failed (${response.status}): ${response.data}',
);
}
final url = response.data?['url'] as String?;
if (url == null) throw StateError('createCheckoutSession returned no url');
return url;
}