无法使用 braintree iOS 显示 dropIn UI
Unable to present dropIn UI using braintree iOS
我正在创建一个支付应用程序并为此使用 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
密钥,我将它传递给 showDropIn 函数。它仍然没有显示任何东西,没有进入这个函数
(BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
{ (controller, result, error))
试试这个:
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)
});
}
希望这会奏效...!!
在 Objective - 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];
});
}
我正在创建一个支付应用程序并为此使用 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
密钥,我将它传递给 showDropIn 函数。它仍然没有显示任何东西,没有进入这个函数
(BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
{ (controller, result, error))
试试这个:
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)
});
}
希望这会奏效...!!
在 Objective - 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];
});
}