我正在创建一个付款应用并使用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
下的沙箱控制面板获得了Tokenization Keys
密钥,我将它传递给showDropIn函数。仍然没有显示任何内容,没有进入这个功能
(BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
{ (controller, result, error))
答案 0 :(得分:2)
尝试使用:
this.document
希望这会有用...... !!
答案 1 :(得分:0)
目标 - C:
- (void)showDropIn:(NSString *)clientTokenOrTokenizationKey {
BTDropInRequest *request = [[BTDropInRequest alloc] init];
BTDropInController *dropIn = [[BTDropInController alloc] initWithAuthorization:clientTokenOrTokenizationKey request:request handler:^(BTDropInController * _Nonnull controller, BTDropInResult * _Nullable result, NSError * _Nullable error) {
if (error != nil) {
NSLog(@"ERROR");
} else if (result.cancelled) {
NSLog(@"CANCELLED");
} else {
// Use the BTDropInResult properties to update your UI
// result.paymentOptionType
// result.paymentMethod
// result.paymentIcon
// result.paymentDescription
}
dispatch_async(dispatch_get_main_queue(), ^{
[controller dismissViewControllerAnimated:YES completion:nil];
});
}];
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:dropIn animated:YES completion:nil];
});
}