buildHeaderTokens function
Implementation
Map<String, String> buildHeaderTokens({
bool isStripePayment = false,
bool isFlutterWave = false,
bool isSadadPayment = false,
String? flutterWaveSecretKey,
String? stripeKeyPayment,
String? sadadToken,
}) {
Map<String, String> header = {
HttpHeaders.cacheControlHeader: 'no-cache',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Origin': '*',
};
if (appStore.isLoggedIn && isStripePayment) {
header.putIfAbsent(HttpHeaders.contentTypeHeader,
() => 'application/x-www-form-urlencoded');
header.putIfAbsent(
HttpHeaders.authorizationHeader, () => 'Bearer $stripeKeyPayment');
} else if (appStore.isLoggedIn && isFlutterWave) {
header.putIfAbsent(
HttpHeaders.authorizationHeader, () => "Bearer $flutterWaveSecretKey");
} else if (appStore.isLoggedIn && isSadadPayment) {
header.putIfAbsent(HttpHeaders.contentTypeHeader, () => 'application/json');
header.putIfAbsent(HttpHeaders.authorizationHeader, () => '$sadadToken');
} else if (appStore.isLoggedIn) {
header.putIfAbsent(
HttpHeaders.authorizationHeader, () => 'Bearer ${appStore.token}');
header.putIfAbsent(
HttpHeaders.contentTypeHeader, () => 'application/json; charset=utf-8');
header.putIfAbsent(
HttpHeaders.acceptHeader, () => 'application/json; charset=utf-8');
} else {
header.putIfAbsent(
HttpHeaders.contentTypeHeader, () => 'application/json; charset=utf-8');
header.putIfAbsent(
HttpHeaders.acceptHeader, () => 'application/json; charset=utf-8');
}
log(jsonEncode(header));
return header;
}