getCreditCardToken method

Future<Response> getCreditCardToken(
  1. String cardNumber,
  2. String expiryDate,
  3. String expiryYear,
  4. String cvv
)

generate credit card token, so we can access 3DS

this also handle fraud detection and other error

Implementation

Future<http.Response> getCreditCardToken(String cardNumber, String expiryDate,
    String expiryYear, String cvv) async {
  String baseUrl =
      isProduction == true ? midtransProductionUrl : midtransStagingUrl;

  String url = baseUrl +
      'v2/token?client_key=$clientKey&card_number=$cardNumber&card_exp_month=$expiryDate&card_exp_year=20$expiryYear&card_cvv=$cvv';

  final response = await http.get(url, headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': base64.encode(utf8.encode(serverKey + ':'))
  });

  return response;
}