getCreditsCheckoutUrl method
Implementation
Future<String> getCreditsCheckoutUrl(String projectId, String successUrl, String cancelUrl, double quantity) async {
final encodedProjectId = Uri.encodeComponent(projectId);
final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/credits');
final body = {"quantity": quantity, "success_url": successUrl, "cancel_url": cancelUrl};
final response = await httpClient.post(uri, body: jsonEncode(body));
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to get session. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
return jsonDecode(response.body)["checkout_url"];
}