我的应用程序实施了Apple Pay,并且已成功显示某些卡片,例如恩惠虚拟卡。使用我的个人信用卡(法国信用卡),付款申请无效。
我的代码:
let paymentRequest = PKPaymentRequest()
paymentRequest.merchantIdentifier = "merchant.com.<companyName>"
paymentRequest.requiredBillingAddressFields = [.name]
if #available(iOS 10.0, *) {
paymentRequest.supportedNetworks = PKPaymentRequest.availableNetworks()
} else {
paymentRequest.supportedNetworks = [.masterCard, .visa, .amex]
}
paymentRequest.countryCode = "FR"
paymentRequest.currencyCode = "EUR"
paymentRequest.paymentSummaryItems = booking.charges.flatMap {
PKPaymentSummaryItem(label: $0.label, amount: $0.amount, type: .pending)
} + [PKPaymentSummaryItem(label: LanguageManager.get(key: "__app_name"), amount: booking.total.amount, type: .pending)]
if let paymentAuthorizationViewController = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest) as PKPaymentAuthorizationViewController? {
paymentAuthorizationViewController.delegate = self
self.present(paymentAuthorizationViewController, animated: true, completion: nil)
}
paymentAuthorizationViewController
为nil
,我收到了控制台日志Payment request is invalid: <private>
我如何调试它并知道这个神秘<private>
背后的原因?
答案 0 :(得分:1)
您尝试为0收取的总金额是多少?它看起来像是,但我不确定。您无法获得零金额的付款请求,它必须至少大于零。您仍然可以将摘要项目标记为待处理,并且不会显示给用户的金额。