 
 }
 
+/**
+ *  The delegate callbacks which allow the host app to receive all possible results from the component using a generic decodable type.
+ */
+public protocol HPPSwiftManagerDelegate: class {
+    
+    associatedtype PaymentServiceResponse: Decodable
+    func HPPSwiftManagerCompletedWithResult(_ result: PaymentServiceResponse)
+    func HPPSwiftManagerFailedWithError(_ error: Error?)
+    func HPPSwiftManagerCancelled()
+    
+}
+
+/**
+ *  A type-erased
+ */
+fileprivate class AnyHPPSwiftManagerDelegate<T: Decodable>: HPPSwiftManagerDelegate {
+    
+    private let completed: (T) -> Void
+    private let failed: (Error?) -> Void
+    private let cancelled: () -> Void
+    
+    init<D: HPPSwiftManagerDelegate>(_ delegate: D) where D.PaymentServiceResponse == T {
+        self.completed = { [weak delegate] in delegate?.HPPSwiftManagerCompletedWithResult($0) }
+        self.failed = { [weak delegate] in delegate?.HPPSwiftManagerFailedWithError($0) }
+        self.cancelled = { [weak delegate] in delegate?.HPPSwiftManagerCancelled() }
+    }
+    
+    public func HPPSwiftManagerCompletedWithResult(_ result: T) {
+        self.completed(result)
+    }
+    
+    public func HPPSwiftManagerFailedWithError(_ error: Error?) {
+        self.failed(error)
+    }
+    
+    public func HPPSwiftManagerCancelled() {
+        self.cancelled()
+    }
+    
+}
+
 /// The main object the host app creates.
-open class HPPManager: NSObject, UIWebViewDelegate, HPPViewControllerDelegate {
+/// A convenience payment manager for payment service responses that have a `[String: String]` structure
+open class HPPManager: GenericHPPManager<[String: String]> { }
+
+/// The main object the host app creates.
+/// A payment manager that can decode payment service responses that have a generic structure
+open class GenericHPPManager<T: Decodable>: NSObject, UIWebViewDelegate, HPPViewControllerDelegate {
 
 
     /**

     * The view owned by the HPP Manager, which encapsulates the web view.
     */
    fileprivate var hppViewController: HPPViewController!

    /**
     The initialiser which when HPPManager is created, also creaes and instance of the HPPViewController.

    /**
     * The HPPManager's delegate to receive the result of the interaction.
     */
    open weak var delegate:HPPManagerDelegate?
    
    /**
     * The HPPManager's generic delegate to receive the result of the interaction.
     * `T` is the generic type that defines the structure of the payment response.
     */
    private var swiftPrivateDelegate: AnyHPPSwiftManagerDelegate<T>?
    

    /**
     * Dictionary to hold the reqeust sent to HPP.
