ios - 无法使用 Braintree iOS 呈现 dropIn UI
<p><p>我正在创建一个支付应用程序并为此使用 Braintree。我想使用braintree dropIn UI。通过 pod 安装 BraintreeDropIn。使用以下代码呈现 dropIn UI。</p>
<pre><code>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)
}
</code></pre>
<p>我从 <code>Tokenization Keys</code> 下的沙盒控制面板获得了 <code>tokenization</code>key ,并将其传递给 showDropIn 函数。它仍然没有显示任何内容,没有进入这个函数</p>
<pre><code>(BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
{ (controller, result, error))
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>试试这个:</p>
<pre><code> 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)
});
}
</code></pre>
<p>希望这会奏效...!!</p></p>
<p style="font-size: 20px;">关于ios - 无法使用 Braintree iOS 呈现 dropIn UI,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/41240551/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/41240551/
</a>
</p>
页:
[1]