getCheckoutUrl method

Future<String> getCheckoutUrl(
  1. String projectId,
  2. String successUrl,
  3. String cancelUrl
)

Implementation

Future<String> getCheckoutUrl(String projectId, String successUrl, String cancelUrl) async {
  final uri = Uri.parse('$baseUrl/accounts/projects/$projectId/subscription');
  final response = await http.post(uri, headers: _getHeaders(), body: jsonEncode({"success_url": successUrl, "cancel_url": cancelUrl}));

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to get session. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }
  return jsonDecode(response.body)["checkout_url"];
}