getPaymentMethods method

Future<ApiCallback<List<PaymentMethod>>> getPaymentMethods(
  1. {String cartId,
  2. bool isDealerCheckout = false}
)

Implementation

Future<ApiCallback<List<PaymentMethod>>> getPaymentMethods(
    {String cartId, bool isDealerCheckout = false}) async {
  try {
    if (cartId == null) cartId = await _getDefaultCartId();


    var response = await _requester.get(GET_PAYMENT_METHODS
        .replaceAll(PARAMETER_CART_ID, cartId)
        .replaceAll(
            PARAMETER_IS_DEALER_CHECKOUT, isDealerCheckout.toString()));
    // Fetch payment methods
    var responseData = response.data as List;
    var payments = List<PaymentMethod>();
    for (var row in responseData) payments.add(PaymentMethod.fromJson(row));
    // Callback invocation
    return ApiCallback<List<PaymentMethod>>(
        isSuccessful: true, resultData: payments);
  } on DioError catch (e) {
    return ApiCallback<List<PaymentMethod>>().defaultErrorCallback(e);
  }
}