作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的项目使用 braintree pod,它在获得 nonce 后运行良好。但我想检索卡号的卡图标和数字。
如何在 imageView 中获取卡片图标并在 UILabel 中获取卡片编号?
我使用了两个 pod 文件。
pod 'BraintreeDropIn'
pod 'BraintreeDropIn/UIKit'
我正在使用 braintree 文档中提供的这个函数。
func showDropIn(clientTokenOrTokenizationKey: String) {
let request = BTDropInRequest()
//BTUIKAppearance.darkTheme()
//BTUIKAppearance.sharedInstance().primaryTextColor = UIColor.green
let dropIn = BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
{ (controller, result, error) in
if (error != nil) {
print("ERROR : \(error.debugDescription)")
} else if (result?.isCancelled == true) {
print("CANCELLED")
} else if let result = result {
// Use the BTDropInResult properties to update your UI
//result.paymentOptionType
//result.paymentMethod
//result.paymentIcon
//result.paymentDescription
if let outPut = result.paymentMethod {
print("\nNonce : \(outPut.nonce)")
self.paymentNonce = outPut.nonce
self.paymentCardType = result.paymentDescription.description
}
}
controller.dismiss(animated: true, completion: nil)
}
self.present(dropIn!, animated: true, completion: nil)
}
最佳答案
完全披露:我在 Braintree 工作。如果您还有任何疑问,请随时联系support .
目前,Braintree 的 iOS SDK 不会在结果中返回卡片品牌图标。但是,图像 URL 在 transaction response object 中返回在 imageUrl
中包含卡片品牌图标属性。你可以看看this gist关于如何在 Swift 中显示图像 URL。或者,type
返回随机数时在客户端可用。
出于 PCI 合规性原因,如果您使用 Drop-in UI,完整的卡号永远不会暴露给商家。相反,iOS SDK 将提供 lastTwo
如果您将付款方式转换为 BTCardNonce
,则为数字。 Swift's documentation有很多关于类型转换的好信息。通过 Objective-C,一个例子是:
BTCardNonce *cardNonce = (BTCardNonce*)result.paymentMethod;
或者,您可以获得 maskedNumber
来自事务响应对象,类似于图像 URL。
已编辑:更新了用于将图像 URL 添加到 Swift 4 的链接
关于ios - 如何从braintree payments中获取卡号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51287618/
我是一名优秀的程序员,十分优秀!