2016-08-15 23 views
0

我目前使用braintree作为我的应用程序的支付系统im问题在于,我无法确定卡是在拒绝还是被接受之前进行的另一个viewcontroller请看看我目前的功能。先谢谢你。如何查明卡在Braintree支付中是否被拒绝

func postNonceToServer(paymentMethodNonce: String) { 

     let paymentURL = NSURL(string: "http://salesandsolutionsplus.com/braintree_php_api/public_html/checkout.php")! 

     let postAmount = formInfo["servicePrice"]! 

     let request = NSMutableURLRequest(URL: paymentURL) 
     request.HTTPBody = "payment_method_nonce=\(paymentMethodNonce)&amount=\(postAmount)".dataUsingEncoding(NSUTF8StringEncoding) 
     request.HTTPMethod = "POST" 

     NSURLSession.sharedSession().dataTaskWithRequest(request) { (data, response, error) -> Void in 
      // TODO: Handle success or failure 

      let dbRef = FIRDatabase.database().reference() 
      let value = self.formInfo 


      if error != nil { 


       print(error) 

       return 
      } 





      dbRef.child("streetServices/Posts").childByAutoId().setValue(value, withCompletionBlock: { (error, fir) in 
       if error != nil { 

        print("alert error") 
        print(error) 

        return 
       } 

       // present confirmation after payment process 
       let next = self.storyboard?.instantiateViewControllerWithIdentifier("vc3") as! ConfirmationViewController 

       self.presentViewController(next, animated: true, completion: nil) 

      }) 


     }.resume() 
    } 

回答

1

完全披露:我在布伦特里工作。如果您有任何其他问题,请随时联系support

来自Braintree_Transactionresult object包含success属性,该属性将为true或false。根据success的值,您将有transaction_resulterror result为您提供更多信息。一旦在您的服务器端代码中解析了此响应,您可以按照您选择的任何方式将其发送给客户端。