                 // error
                 UIApplication.shared.isNetworkActivityIndicatorVisible = false
                 self.delegate?.HPPManagerFailedWithError!(error as NSError)
+                self.genericDelegate?.HPPManagerFailedWithError(error)
                 self.hppViewController.dismiss(animated: true, completion: nil)
             }
         })


    private func HPPViewControllerFailedWithError(_ error: Error?) {
        self.delegate?.HPPManagerFailedWithError!(error as NSError?)
        self.hppViewController.dismiss(animated: true, completion: nil)
    }


/**
 *  The delegate callbacks which allow the host app to receive all possible results from the component using a generic decodable type.
 */
public protocol GenericHPPManagerDelegate: class {
    
    associatedtype PaymentServiceResponse: Decodable
    func HPPManagerCompletedWithResult(_ result: PaymentServiceResponse)
    func HPPManagerFailedWithError(_ error: Error?)
    func HPPManagerCancelled()
    
}

/**
 *  A type-erased implementer of the `HPPSwiftManagerDelegate` protocol
 */
fileprivate class AnyGenericHPPManagerDelegate<T: Decodable>: GenericHPPManagerDelegate {
    
    private let completed: (T) -> Void
    private let failed: (Error?) -> Void
    private let cancelled: () -> Void
    
    init<D: GenericHPPManagerDelegate>(_ delegate: D) where D.PaymentServiceResponse == T {
        self.completed = { [weak delegate] in delegate?.HPPManagerCompletedWithResult($0) }
        self.failed = { [weak delegate] in delegate?.HPPManagerFailedWithError($0) }
        self.cancelled = { [weak delegate] in delegate?.HPPManagerCancelled() }
    }
    
    public func HPPManagerCompletedWithResult(_ result: T) {
        self.completed(result)
    }
    
    public func HPPManagerFailedWithError(_ error: Error?) {
        self.failed(error)
    }
    
    public func HPPManagerCancelled() {
        self.cancelled()
    }
    
