pay method
Implementation
Future<ApiResponse<bool>> pay(int id, double amount, File receipt) async {
List<Map<String, dynamic>> files = [
{'key': 'mediaFiles', 'file': receipt},
];
final Map<String, dynamic> body = {
"amount": amount,
"auction_id": id,
"user_type":'bidder'
};
try {
final response = await call(endpoint: 'payment', method: Method.POST, files: files,body: body);
final bodyJson = jsonDecode(response.body);
if (response.statusCode == 201) {
return ApiResponse(success: true, data: true, message: "Payment successful");
} else {
return ApiResponse(
success: false,
data: false,
message: bodyJson['message'] ?? "Payment failed",
);
}
} catch (e) {
return ApiResponse(
success: false,
data: false,
message: "Error processing payment: $e",
);
}
}