createCustomCheckout method
Implementation
Future<Map<String, dynamic>> createCustomCheckout({
required int customPrice,
required List<int> enabledVariants,
String? buttonColor,
String? discountCode,
Map<String, dynamic>? customData,
String? expiresAt,
bool preview = false,
}) async {
Options dioOptions = Options(
headers: {
"Authorization": "Bearer $apiKey",
"Accept": "application/vnd.api+json",
"Content-Type": "application/vnd.api+json",
},
);
try {
Response response = await dio.post(
"https://api.lemonsqueezy.com/v1/checkouts",
options: dioOptions,
data: {
"data": {
"type": "checkouts",
"attributes": {
"custom_price": customPrice,
"product_options": {"enabled_variants": enabledVariants},
"checkout_options": {
"button_color": buttonColor,
},
"checkout_data": {
"discount_code": discountCode,
"custom": customData,
},
"expires_at": expiresAt,
"preview": preview
}
}
},
);
return response.data;
} catch (e) {
return {'error': e.toString()};
}
}