[英]stripe on ios show STPAddCardViewController with address field
I'm trying to use the STPAddCardViewController
in the Stripe library to show the view for adding a card, and configuring it to require address as well. 我正在尝试使用Stripe库中的STPAddCardViewController
来显示添加卡的视图,并将其配置为也需要地址。 This is what I have, which doesn't work and throws an exception: 这是我所拥有的,它不起作用并引发异常:
@IBAction func addCardAction(sender: AnyObject)
{
let paymentConfig = STPPaymentConfiguration.init();
paymentConfig.requiredBillingAddressFields = STPBillingAddressFields.Full;
let theme = STPTheme.defaultTheme();
let addCardViewController = STPAddCardViewController.init(configuration: paymentConfig, theme: theme);
addCardViewController.delegate = self;
let navigationController = UINavigationController(rootViewController: addCardViewController);
self.presentViewController(navigationController, animated: true, completion: nil);
}
If i just initialize without a config, I see the view come up just fine with the card and email fields (without the address), like so: 如果我只是在没有配置的情况下初始化,我会看到卡和电子邮件字段(没有地址)显示的很好,就像这样:
@IBAction func addCardAction(sender: AnyObject)
{
let addCardViewController = STPAddCardViewController()
addCardViewController.delegate = self
let navigationController = UINavigationController(rootViewController: addCardViewController)
self.presentViewController(navigationController, animated: true, completion: nil)
}
Exception I see: 我看到的异常:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument' 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“ ***-[__ NSCFConstantString stringByAppendingString:]:无参数”
thrown at this line: 抛出这一行:
let addCardViewController = STPAddCardViewController.init(configuration: paymentConfig, theme: theme);
尝试将您的publishableKey添加到paymentConfig,为我修复它
paymentConfig.publishableKey = "pk_test_xxxxxxxx"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.