我最近在我的项目中安装了pod StripeCardScan
。我能够让它正常工作,但是,它不可能让STPPaymentCardTextField
接受任何编程输入,从卡扫描或只是使用手动let
语句。我在谷歌上搜索并回顾了几篇关于这方面的文章,但是我觉得我遗漏了一些东西。2我想知道我是否需要为这个类设置一个代理人?
下面是我尝试使用的代码,把扫描卡到号码字段:
cardScanSheet.present(from: self) { [weak self] result in
var title = ""
var message = ""
switch result {
case .completed(let card):
title = "Scan Completed"
message = card.pan
let cardParams = STPPaymentMethodCardParams()
cardParams.number = card.pan
//cardParams.number = "4511554566354474". <- Even when doing this manually, it still does not take
self?.addCardView.cardField.paymentMethodParams.card = cardParams
print("card [pam \(card.pan)")
case .canceled:
title = "Scan Canceled"
message = "Canceled the scan"
case .failed(let error):
title = "Scan Failed"
message = "Failed with error: \(error.localizedDescription)"
}
1条答案
按热度按时间wlzqhblo1#
我想你还需要一个
STPPaymentMethodParams
的示例来编程设置卡号。你试过跟随吗?