title: Swift Error Domain=NSURLErrorDomain Code=-1012
body: <p>I am a new student working on a summer project following my freshman year with little experience and I am getting the error </p>
  
  <blockquote>
    <p>Error Domain=NSURLErrorDomain Code=-1012 "(null)"
    UserInfo={NSErrorFailingURLKey=<a href="https://localhost/donate/payment.php" rel="nofollow">https://localhost/donate/payment.php</a>,
    NSErrorFailingURLStringKey=<a href="https://localhost/donate/payment.php" rel="nofollow">https://localhost/donate/payment.php</a>}</p>
  </blockquote>
  
  <p>when I try to run a credit card payment through stripe, the code I have is </p>
  
  <pre><code> func postStripeToken(token: STPToken) {
  
      let URL = "https://localhost/donate/payment.php"
      let params  : [String: AnyObject] =  ["stripeToken": token.tokenId,
                                            "amount": myInt,
                                            "currency": "usd",
                                            "description": self.emailTextField.text!]
  
      let manager = AFHTTPRequestOperationManager()
      manager.POST(URL, parameters: params, success: { (operation, responseObject) -&gt; Void in
  
          if let response = responseObject as? [String: String] {
              UIAlertView(title: response["status"],
                  message: response["message"],
                  delegate: nil,
                  cancelButtonTitle: "OK").show()
          }
  
      }) { (operation, error) -&gt; Void in
          self.handleError(error!)
      }
  }
  </code></pre>
  
  <p>It wants a HTTP url instead of a <code>HTTPS</code> but when i change it to HTTP and its not secure when the user presses pay with their card they get an error </p>
  
  <blockquote>
    <p>The resource could not be loaded beach the APP Transport Security
    Policy requires the use of a secure connection.</p>
  </blockquote>
  
  <p>Is there anyway I can use a HTTPS without getting the NSURL error or I can make a secure connection without <code>HTTPS</code>?  Any Tips would be very helpful!</p>
  
  <pre><code>manager.securityPolicy.allowInvalidCertificates = true;
  </code></pre>
  
  <p>I also tried adding this statement with no luck. </p>