             throw error
         }
     }
-    
+
     /**
         Return a list of currencies and their rates from BlueSnap server
      - throws BSApiErrors
     */
     static func getCurrencyRates() throws -> BSCurrencies? {
-        
+
         let bsToken = getBsToken()
-        
+
         if let lastCurrencyFetchDate = lastCurrencyFetchDate, let _ = bsCurrencies {
             let diff = lastCurrencyFetchDate.timeIntervalSinceNow as Double // interval in seconds
             if (diff > TIME_DIFF_TO_RELOAD) {
-                return  bsCurrencies
-            }
-        }
-        
-        let domain : String! = bsToken!.serverUrl
+                return bsCurrencies
+            }
+        }
+
+        let domain: String! = bsToken!.serverUrl
         let urlStr = domain + "services/2/tokenized-services/rates"
         let url = NSURL(string: urlStr)!
         var request = NSMutableURLRequest(url: url as URL)
         //request.timeoutInterval = 60
         request.setValue("application/json", forHTTPHeaderField: "Content-Type")
         request.setValue(bsToken!.tokenStr, forHTTPHeaderField: "Token-Authentication")
-        
+
         // fire request
-        
-        var resultError : BSApiErrors?
+
+        var resultError: BSApiErrors?
         let semaphore = DispatchSemaphore(value: 0)
-        let task = URLSession.shared.dataTask(with: request as URLRequest) { (data : Data?, response, error) in
+        let task = URLSession.shared.dataTask(with: request as URLRequest) { (data: Data?, response, error) in
             if let error = error {
                 NSLog("Error getting BS currencies: \(error.localizedDescription)")
                 resultError = .unknown
                 return
             }
             let httpResponse = response as? HTTPURLResponse
-            if let httpStatusCode:Int = (httpResponse?.statusCode) {
+            if let httpStatusCode: Int = (httpResponse?.statusCode) {
                 if (httpStatusCode >= 200 && httpStatusCode <= 299) {
                     let tmp = parseCurrenciesJSON(data: data)
                     if tmp != nil {

        let base64LoginStr = loginData.base64EncodedString()
        return "Basic \(base64LoginStr)"
    }
    
    private static func notifyTokenExpired() {
        DispatchQueue.main.async {
            NotificationCenter.default.post(name: Notification.Name.bsTokenExpirationNotification, object: nil)
        }
    }


    /**

     - throws BSApiErrors.invalidInput if user/pass are incorrect, BSApiErrors.unknown otherwise
     */
    internal static func createBSToken(domain: String, user: String, password: String) throws -> BSToken? {

        // create request
        let authorization = getBasicAuth(user: user, password: password)
        let urlStr = domain + "services/2/payment-fields-tokens"
