如何查看Braintree Payments卡是否被拒绝

时间:2016-08-15 06:32:01

标签: swift braintree

我目前正在使用braintree作为我的应用程序的支付系统我遇到的问题是,在进入另一个viewcontroller之前我无法查明该卡是否被拒绝或接受请查看我当前的功能。提前谢谢。

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()
    }

0 个答案:

没有答案