1
我正在嘗試將Stripe整合到我的應用程序中,並且我遵循了一個似乎已過時的教程。這是我的代碼的外觀:條紋 - 在條紋方法中出現錯誤
import Foundation
import UIKit
import Stripe
import AFNetworking
class PaymentViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var cardNumberTextField: UITextField!
@IBOutlet weak var expirationDateTextField: UITextField!
@IBOutlet weak var cvcTextField: UITextField!
@IBAction func payButton(_ sender: Any) {
// Initiate the card
let stripCard = STPCardParams()
// Split the expiration date to extract Month & Year
if self.expirationDateTextField.text?.isEmpty == false {
let expirationDate = self.expirationDateTextField.text?.components(separatedBy: "/")
let expMonth = UInt((expirationDate?[0])!)
let expYear = UInt((expirationDate?[1])!)
// Send the card info to Strip to get the token
stripCard.number = self.cardNumberTextField.text
stripCard.cvc = self.cvcTextField.text
stripCard.expMonth = expMonth!
stripCard.expYear = expYear!
}
var underlyingError: NSError?
stripCard.validateCardReturningError(&underlyingError)
if underlyingError != nil {
self.handleError(underlyingError!)
return
}
}
}
我在這個代碼塊得到一個錯誤:
var underlyingError: NSError?
stripCard.validateCardReturningError(&underlyingError)
if underlyingError != nil {
self.handleError(underlyingError!)
return
}
}
錯誤說.validateCardReturningError(&underlyingError)
已過時,我應該使用STPCardValidator代替。我試圖這樣做,但無法修復它。幫助將不勝感激。
你實際上需要檢查返回的驗證狀態 –