带有地址字段的iOS show stpaddcardviewController上的条纹



我正在尝试使用条纹库中的STPAddCardViewController来显示添加卡的视图,并将其配置为也需要地址。这就是我所拥有的,它不起作用并引发例外:

@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);
}

如果我只是在没有配置的情况下初始化,我会看到该视图可以很好地使用卡和电子邮件字段(没有地址),例如:

@IBAction func addCardAction(sender: AnyObject)
{
    let addCardViewController = STPAddCardViewController()
    addCardViewController.delegate = self
    let navigationController = UINavigationController(rootViewController: addCardViewController)
    self.presentViewController(navigationController, animated: true, completion: nil)        
}

例外我看到:

终止应用程序由于未被发现的例外" nsinvalidargumentException",原因:'*** - [__ __ nscfconstantstring stringbyAppendingString:]:nil grognt'

'

在这条线上投掷:

let addCardViewController = STPAddCardViewController.init(configuration: paymentConfig, theme: theme);

尝试将您的PublishableKey添加到PaymentConfig中,为我修复了

    paymentConfig.publishableKey = "pk_test_xxxxxxxx"

相关内容

  • 没有找到相关文章

最新更新