swift - 即使设备支持 Apple Pay,Apple Pay 按钮也不会显示

标签 swift stripe-payments testflight applepay passkit

所以我的目标是让Apple Pay按钮在支持Apple Pay的设备上显示,并在不支持它的设备上隐藏。

目前我有一个带有两个按钮的 vc,一个是 Apple Pay 按钮,一个是继续正常结账的按钮。我使用逻辑来确定要显示的正确按钮,如果设备支持 Apple Pay,它将显示两个按钮,如果不支持,它将显示正常的结账按钮。

以下是模拟器的示例,即支持 Apple Pay 的设备:

enter image description here

这就是支持 Apple Pay 的设备应有的样子。以下是我用来确定要显示哪些按钮的逻辑:

func checkIfApplePaySupported() {
    if StripeAPI.deviceSupportsApplePay() == false {
        applePayButton.isHidden = true
    } else {
        applePayButton.isHidden = false
        applePayButton.addTarget(self, action: #selector(applePayTapped), for: .touchUpInside)
    }
}

非常简单,在模拟器上运行得很好。我最初将 Apple Pay 按钮隐藏在 Storyboard中,这样在加载 View 时它就不会出现任何不稳定的 UI 移动。我在 vc 的 viewDidLoad() 中调用该方法。

现在的问题是,当我使用确切的逻辑将构建上传到 TestFlight 时,在 iPhone 上进行测试时,Apple Pay 按钮不会显示在 vc 中。我设置了 Apple Pay,我的钱包里有一张卡,事实上,我昨天用 Apple Pay 支付了杂货费用,所以毫无疑问该设备支持 Apple Pay。

这是我每次到达 vc 时得到的结果:

no apple pay button

尽管我的设备全心全意支持Apple Pay,但Apple Pay按钮从未出现,这就像最奇怪的错误,我一生都无法弄清楚我做错了什么。我的 friend 也遇到了这种情况,他们的设备支持 Apple Pay,但他们也看不到 Apple Pay 按钮并用它进行付款。关于如何修复此错误有什么建议吗?

最佳答案

您正在通过 Stripe 使用 Apple Pay。 StripeAPI.deviceSupportsApplePay() 函数不仅仅检查“设备是否支持 Apple Pay?”。它还检查用户是否至少保存了一张受 Stripe 或其他要求支持的信用卡。在 deviceSupportsApplePay() 的描述中清楚地描述了这一点。

Whether or not this can make Apple Pay payments via a card network supported by Stripe. The Stripe supported Apple Pay card networks are: American Express, Visa, Mastercard, Discover, Maestro. Japanese users can enable JCB by setting JCBPaymentNetworkSupported to YES, after they have been approved by JCB. - Returns: YES if the device is currently able to make Apple Pay payments via one of the supported networks. NO if the user does not have a saved card of a supported type, or other restrictions prevent payment (such as parental controls).

用于检查您是否可以在模拟器上运行您的应用程序。 StripeAPI.deviceSupportsApplePay() 在模拟器中返回 true。

关于swift - 即使设备支持 Apple Pay,Apple Pay 按钮也不会显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67421729/

相关文章:

ios - 无法在 Xcode 中以编程方式创建 map (Big Nerd Ranch IOS 编程 : chapter 6 p97)

python - 将 access_token 从回调函数传递给 charge 函数

ios - 新版本以完全不同的配置文件发布到应用商店

swift - 指示tableView的indexPath何时为最后一个

ios - 节点未在 Swift 2 和 SpriteKit 中加载纹理

google-cloud-platform - Stripe 错误 : No signatures found matching the expected signature for payload

php - Stripe : change credit card number?

ios - 在 iphone 上删除 Beta 测试 (testflight) 应用程序

iphone - IAP 正在使用 TestFlight 构建。它也适用于 Live 应用程序吗?

ios - 从 Parse 中提取的一张图像实际上有两个 : weird error.