iOS ApplePay PKPaymentAuthorizationViewController 未出现在 Xcode11/iOS 13 中

标签 ios swift applepay

我们的应用程序已实现 ApplePay 多年。就在最近,我点击按钮触发它,却发现 PKPaymentAuthorizationViewController 的付款单没有出现。在沙箱(即模拟器或连接Xcode的设备)环境中它不会向上滑动,但打断点表明它已创建成功。我测试这个已经有一段时间了,但我怀疑 Xcode11 或 iOS 13 会发生一些变化。

我的代码是非常标准的 Apple Pay,但发布在下面。

        let item = PKPaymentSummaryItem()
        item.label = "Our Label"
        let price = NSDecimalNumber(mantissa: UInt64(totalPrice), exponent: -2, isNegative: false)
        item.amount = price

        items.append(item)

        request.paymentSummaryItems = items

        if let applePayController = PKPaymentAuthorizationViewController(paymentRequest: request) {
            applePayController.delegate = self
            present(applePayController, animated: true)
        }

最佳答案

如果您的PKPaymentRequest 使用的merchantID 未在mobile.entitlements 中列出,就会发生这种情况。或者,如果您的应用的配置文件未启用 MerchantID。

View Controller

  PKPaymentRequest *request = [[PKPaymentRequest alloc] init];
  
  request.merchantIdentifier = "com.your.app.merchandId"

移动设备权利

<dict>
    <key>com.apple.developer.in-app-payments</key>
    <array>
        <string>com.your.app.merchandId</string>
    </array>
</dict>

关于iOS ApplePay PKPaymentAuthorizationViewController 未出现在 Xcode11/iOS 13 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58563489/

相关文章:

ios - 我正在尝试将视频添加到我的 iOS 应用程序,但只有音频播放但没有视频

iOS 12 UIContextualAction 图像无法推断图像颜色

stripe-payments - 苹果是否为网络支持 iframe 付费?

ios - 如何对复选框按钮进行 UI 测试

swift - 如何根据标签文本快速更改表格 View 单元格高度?

ios - 我们可以获得测试卡来在 BrainTree SDK 中测试 ApplePay 吗?

ios - 将Xcode更新到版本10.4后,Apple Pay无法正常工作

ios - 应用程序崩溃。当我从自定义表格单元格下载视频的第二个索引时

php - 除了发送参数之外,是否有传递给浏览器的信息可以告诉网站是什么应用程序访问了它?

ios - Realm LinkingObjects 第二级返回零