         
         return false
     }
-
 }

        // Display error
        let errorStep = ErrorViewController(error: MercadoPagoCheckoutViewModel.error, callback: nil, callbackCancel: {[weak self] in
            
            guard let object = self else {
                return
            }
            object.finish()
            
        })
        // Limpiar error anterior

    
    func collectDirectDiscount() {
        self.presentLoading()
        MerchantServer.getDirectDiscount(transactionAmount: self.viewModel.getFinalAmount(), payerEmail: self.viewModel.checkoutPreference.payer.email, addtionalInfo: MercadoPagoCheckoutViewModel.servicePreference.discountAdditionalInfo, success: { [weak self] (discount) in
            
            guard let strongSelf = self else {
                return
            }
            
            strongSelf.viewModel.paymentData.discount = discount
            strongSelf.executeNextStep()
            strongSelf.dismissLoading()
            
        }) { [weak self] (error: NSError) in
            guard let strongSelf = self else {
                return
            }
            
            strongSelf.dismissLoading()
            strongSelf.executeNextStep()
        }
    }
    
    func collectPaymentMethodSearch() {
        self.presentLoading()
        MPServicesBuilder.searchPaymentMethods(self.viewModel.getFinalAmount(), defaultPaymenMethodId: self.viewModel.getDefaultPaymentMethodId(), excludedPaymentTypeIds: self.viewModel.getExcludedPaymentTypesIds(), excludedPaymentMethodIds: self.viewModel.getExcludedPaymentMethodsIds(),
             baseURL: MercadoPagoCheckoutViewModel.servicePreference.getDefaultBaseURL(), success: {  [weak self](paymentMethodSearchResponse: PaymentMethodSearch) -> Void in
                                                
                   guard let strongSelf = self else {
                        return
                   }
                                                
                   strongSelf.viewModel.updateCheckoutModel(paymentMethodSearch: paymentMethodSearchResponse)
                   strongSelf.dismissLoading()
                   strongSelf.executeNextStep()
                                                
                                                
            }, failure: { [weak self] (error) -> Void in
                guard let strongSelf = self else {
                    return
                }
                
                strongSelf.dismissLoading()
                strongSelf.viewModel.errorInputs(error: MPSDKError.convertFrom(error), errorCallback: { [weak self] (Void) -> Void in
                    
                    self?.collectPaymentMethodSearch()
                })
                strongSelf.executeNextStep()
        })
    }
    
    
    
    func collectPaymentMethods(){
        // Se limpia paymentData antes de ofrecer selección de medio de pago

        self.viewModel.paymentData.clearCollectedData()
        let paymentMethodSelectionStep = PaymentVaultViewController(viewModel: self.viewModel.paymentVaultViewModel(), callback : { [weak self] (paymentOptionSelected : PaymentMethodOption) -> Void  in
            
            guard let strongSelf = self else {
                return
            }
            
            strongSelf.viewModel.updateCheckoutModel(paymentOptionSelected : paymentOptionSelected)
            strongSelf.viewModel.rootVC = false
            strongSelf.executeNextStep()
        })
        self.pushViewController(viewController : paymentMethodSelectionStep, animated: true)
      
    }
    
    
    func collectCard(){
        
        let cardFormStep = CardFormViewController(cardFormManager: self.viewModel.cardFormManager(), callback: { [weak self](paymentMethods, cardToken) in
            
            guard let strongSelf = self else {
                return
            }
            
            strongSelf.viewModel.updateCheckoutModel(paymentMethods: paymentMethods, cardToken:cardToken)
            strongSelf.executeNextStep()
        })
        self.pushViewController(viewController : cardFormStep, animated: true)
    }
    
    func collectIdentification() {
        let identificationStep = IdentificationViewController (callback: { [weak self] (identification : Identification) in
            guard let strongSelf = self else {
                return
            }
            
            strongSelf.viewModel.updateCheckoutModel(identification : identification)
            strongSelf.executeNextStep()
            }, errorExitCallback: { [weak self] in
                self?.finish()
        })
        
        identificationStep.callbackCancel = {[weak self] in
            self?.navigationController.popViewController(animated: true)
        }
        self.pushViewController(viewController : identificationStep, animated: true)
    }
    
    func collectCreditDebit(){
        let crediDebitStep = AdditionalStepViewController(viewModel: self.viewModel.debitCreditViewModel(), callback: { [weak self] (paymentMethod) in
            guard let strongSelf = self else {
                return
            }
            
            strongSelf.viewModel.updateCheckoutModel(paymentMethod: paymentMethod as! PaymentMethod)
            strongSelf.executeNextStep()
        })
        self.pushViewController(viewController : crediDebitStep, animated: true)
    }
