checkSubscriptionStatus method

Future<Map<String, dynamic>> checkSubscriptionStatus({
  1. required String product,
  2. required String token,
  3. String callback = "fetchSubscriptionStatus",
})

Implementation

Future<Map<String, dynamic>> checkSubscriptionStatus({
  required String product,
  required String token,
  String callback = "fetchSubscriptionStatus",
}) async {
  var auth_headers = {};
  if (callback != "createFreeTrialSubscription") {
    auth_headers = {"Authorization": 'Bearer ' + token};
  }

  final response = await http.get(
    Uri.parse(
        '$webbaseUrl/wp-json/api/ibl/v1/stripe/get/?product=${product}&callback=${callback}'),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      ...auth_headers
    },
    // Encoding email as form data
  );
  // trialing
  // "error": "No subscription found"
  var data = json.decode(response.body);

  return data; // Returns the API response
}