如何查明卡是否在 Braintree Payments 中被拒绝
How to find out if card was declined in Braintree Payments
我目前使用 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()
}
完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系 support.
result object from a Braintree_Transaction
contains a success
attribute that will either be true or false. Depending on the value of success
, you will either have a transaction_result or an error result 为您提供更多信息。在您的服务器端代码中解析此响应后,您可以选择任何方式将其发送到客户端。
我目前使用 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()
}
完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系 support.
result object from a Braintree_Transaction
contains a success
attribute that will either be true or false. Depending on the value of success
, you will either have a transaction_result or an error result 为您提供更多信息。在您的服务器端代码中解析此响应后,您可以选择任何方式将其发送到客户端。