Post Request with AFHTTPSessionManager Stripe - Swift -
i trying make post request server in order process card transaction through stripe, when press paybuttonaction
error "terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nscfconstantstring stringbyappendingstring:]: nil argument'" , redirected simulator -ios 10.1>usr/include>dispatch/once.h>no selection dispatch_once(predicate, block); thread 1: signal sigbart . tested button without code , works. can tell me doing wrong
//create stripe payment field let paymenttextfield = stppaymentcardtextfield() @iboutlet weak var paybuttonoutlet: uibutton! @ibaction func paybuttonaction(sender: uibutton) { let card = paymenttextfield.cardparams stpapiclient.sharedclient().createtokenwithcard(card) { (token, error) in if let error = error { print(error) } else if let token = token { print("the token \(token)") self.chargeusingtoken(token) // post our server } } } // post parameters our webserver make further requests server func chargeusingtoken(token:stptoken) { let urlstring = "0.0.0.0:8080/charge/stripe" let params = ["stripetoken":token.tokenid, "amount":fulldata.finalbookingamount, "currency":"gbp", "description":fulldata.finalemailaddress] //send post request server let manager = afhttpsessionmanager() manager.post(urlstring, parameters: params, progress: { (progress) in // }, success: { (requestoperation, response) in if let response = response as? [string: string] { print(response) } }) { (requestoperation, error) in print(error) } }
Comments
Post a Comment