[英]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.