简体   繁体   English

如何确定卡是否在Braintree Payments中被拒绝

[英]How to find out if card was declined in Braintree Payments

Im currently using braintree as my payment system for my app the issue im having is that that I have no way of finding out if the card was declined or accepted before it proceed to another viewcontroller please take a look at my current function. 我目前正在使用braintree作为我的应用程序的付款系统,问题是我无法在继续使用其他ViewController之前查明该卡是否已被拒绝或接受,请查看我当前的功能。 Thank you in advance. 先感谢您。

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

Full disclosure: I work at Braintree. 全面披露:我在Braintree工作。 If you have any further questions, feel free to contact support . 如果您还有其他疑问,请随时与支持小组联系。

The result object from a Braintree_Transaction contains a success attribute that will either be true or false. Braintree_Transaction结果对象包含success属性,该属性将为true或false。 Depending on the value of success , you will either have a transaction_result or an error result to give you more information. 根据success的价值,您将获得transaction_result错误结果,以向您提供更多信息。 Once this reponse is parsed in your server side code, you can send it to the client any way you choose. 在服务器端代码中解析此响应后,您可以选择任何方式将其发送给客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Braintree Payments php获取标头响应 - How to get a header response from Braintree Payments php 如何设置BTCard中的信用卡可选数据,以使Braintree后端在Swift 4中交付有效令牌? - How do I setup the credit card optional data in BTCard to have to Braintree backend deliver a valid token in swift 4? 我该如何使用Braintree保存客户卡信息,以便以后在他们购物时可以对其收取费用? - How do I save customer card information with Braintree so that I can then charge it later when they make purchases? 如何判断 EKEvent 实例是否被拒绝? - How to tell if an EKEvent instance is declined or not? 如何在 Firebase 上使用 Stripe 付款 - How to make payments with Stripe on Firebase 如何在iOS中使用Braintree实施付款应用 - How to implement a payment app with Braintree in iOS Stripe Payments API:从iOS App收取卡而不是使用服务器 - Stripe Payments API : Charge card from the iOS App instead of using a server 如何找出坐标之间的距离? - How to find out distance between coordinates? 我们如何在 Swift 中找到第二天 - How we find out a next day in Swift 如何找出UITextField为何结束编辑? - How to find out why a UITextField ended editing?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM