Reputation: 11
I am a new student working on a summer project following my freshman year with little experience and I am getting the error
Error Domain=NSURLErrorDomain Code=-1012 "(null)" UserInfo={NSErrorFailingURLKey=https://localhost/donate/payment.php, NSErrorFailingURLStringKey=https://localhost/donate/payment.php}
when I try to run a credit card payment through stripe, the code I have is
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) -> Void in
if let response = responseObject as? [String: String] {
UIAlertView(title: response["status"],
message: response["message"],
delegate: nil,
cancelButtonTitle: "OK").show()
}
}) { (operation, error) -> Void in
self.handleError(error!)
}
}
It wants a HTTP url instead of a HTTPS
but when i change it to HTTP and its not secure when the user presses pay with their card they get an error
The resource could not be loaded beach the APP Transport Security Policy requires the use of a secure connection.
Is there anyway I can use a HTTPS without getting the NSURL error or I can make a secure connection without HTTPS
? Any Tips would be very helpful!
manager.securityPolicy.allowInvalidCertificates = true;
I also tried adding this statement with no luck.
Upvotes: 0
Views: 3432
Reputation: 1960
For this issue “The resource could not be loaded beach the APP Transport Security Policy requires the use of a secure connection”
just write following code in your info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Upvotes: 1