generateSubscriptionInvoice method
Implementation
Future<void> generateSubscriptionInvoice(String subscriptionId,
{String? name,
String? address,
String? city,
String? state,
String? zipCode,
String? country,
String? notes}) async {
Options dioOptions = Options(
headers: {
"Authorization": "Bearer $apiKey",
"Accept": "application/vnd.api+json",
"Content-Type": "application/vnd.api+json",
},
);
try {
Map<String, dynamic> data = {
'name': name,
'address': address,
'city': city,
'state': state,
'zip_code': zipCode,
'country': country,
'notes': notes,
};
Response response = await dio.post(
"https://api.lemonsqueezy.com/v1/subscription-invoices/$subscriptionId/generate-invoice",
options: dioOptions,
queryParameters: data,
);
if (response.statusCode == 200) {
print('Invoice generated successfully:');
print(response.data);
} else {
print('Failed to generate invoice');
}
} catch (e) {
print('Error generating invoice: $e');
}
}