我无法在签证结帐时使用UITextfield
数据作为currencyAmount。
我将CurrencyAmount的变量作为a
并将itemMoney文本设置为此变量。
我在代码中尝试的是什么: -
class ViewController: UIViewController {
@IBOutlet weak var itemMoney:UITextField!
@IBOutlet weak var lbl1:UILabel!
var a :Double = 0
@IBOutlet weak var checkoutButton:VisaCheckoutButton!
override func viewDidLoad() {
super.viewDidLoad()
a = Double(itemMoney.text!)!
let purschaseInfo = PurchaseInfo(total: a, currency: .usd)
purschaseInfo.reviewAction = .pay
checkoutButton.onCheckout(purchaseInfo: purschaseInfo) { result in
switch result.statusCode {
case .success:
print("Encrypted key: \(String(describing: result.encryptedKey))")
print("Payment Data \(String(describing: result.encryptedPaymentData))")
self.lbl1.text = "Payment sucessfull"
case .userCancelled:
print("Payment cancelled by user")
default:
break
}
}
错误: - 参数标签'(_:)'不匹配任何可用的重载
请帮帮我
答案 0 :(得分:2)
您正在传递Double
,但我从规范中看到PurchaseInfo
期望CurrencyAmount
类型的对象(请参阅{指定付款明细并启动Visa Checkout“一节) {3}})。
let total = CurrencyAmount(string: "1.00")
let purchaseInfo = PurchaseInfo(total: total, currency: .usd)