gpt4 book ai didi

ios - 如何从braintree payments中获取卡号?

转载 作者:行者123 更新时间:2023-11-29 11:33:31 26 4
gpt4 key购买 nike

我正在为我的项目使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com