我正在创建一个支付应用程序并为此使用 Braintree。我想使用braintree dropIn UI。通过 pod 安装 BraintreeDropIn。使用以下代码呈现 dropIn UI。
func showDropIn(clientTokenOrTokenizationKey: String) {
let request = BTDropInRequest()
let dropIn = BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
{ (controller, result, error) in
if (error != nil) {
print("ERROR")
} else if (result?.cancelled == true) {
print("CANCELLED")
} else if result != nil {
// Use the BTDropInResult properties to update your UI
// result.paymentOptionType
// result.paymentMethod
// result.paymentIcon
// result.paymentDescription
}
controller.dismissViewControllerAnimated(true, completion: nil)
}
self.presentViewController(dropIn!, animated: true, completion: nil)
}
我从 Tokenization Keys 下的沙盒控制面板获得了 tokenization key ,并将其传递给 showDropIn 函数。它仍然没有显示任何内容,没有进入这个函数
(BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
{ (controller, result, error))
Best Answer-推荐答案 strong>
试试这个:
func showDropIn(clientTokenOrTokenizationKey: String) {
let request = BTDropInRequest()
let dropIn = BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
{ (controller, result, error) in
if (error != nil) {
print("ERROR")
} else if (result?.cancelled == true) {
print("CANCELLED")
} else if result != nil {
// Use the BTDropInResult properties to update your UI
// result.paymentOptionType
// result.paymentMethod
// result.paymentIcon
// result.paymentDescription
}
dispatch_async(dispatch_get_main_queue(), ^{
controller.dismissViewControllerAnimated(true, completion: nil)
});
}
dispatch_async(dispatch_get_main_queue(), ^{
self.presentViewController(dropIn!, animated: true, completion: nil)
});
}
希望这会奏效...!!
关于ios - 无法使用 Braintree iOS 呈现 dropIn UI,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/41240551/
|