【问题标题】:iOS Simulator gets stuck at "Pay with Passcode" when trying Apple PayiOS 模拟器在尝试 Apple Pay 时卡在“使用密码付款”
【发布时间】:2015-08-31 23:30:54
【问题描述】:

我正在尝试在我的应用上设置 Apple Pay,但我目前没有 iPhone 6。因此,在我去购买一台之前,我正在尝试让模拟器启动并运行所有东西,或者尝试让某人借给我一台。

无论如何,我已经开始实际展示 ApplePay 视图控制器了:

但是当我点击“使用密码支付”时,什么也没有发生,所以我不能再继续使用服务器完成所有测试。

以下是我的代码的相关部分:

class PaymentVC: UIViewController,PKPaymentAuthorizationViewControllerDelegate {

@IBAction func onPaymentSubmit(sender: AnyObject) {
    if PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks(supportedPaymentNetworks) {
        let applePayMerchantID = "merchant.com.id"

        let request = PKPaymentRequest()
        request.merchantIdentifier = applePayMerchantID
        request.supportedNetworks = supportedPaymentNetworks
        request.merchantCapabilities = PKMerchantCapability.Capability3DS
        request.countryCode = "US"
        request.currencyCode = "USD"
        request.paymentSummaryItems = [
            PKPaymentSummaryItem(label: "Custom Order", amount: NSDecimalNumber(float: total))
        ]
        let applePayController = PKPaymentAuthorizationViewController(paymentRequest: request)
        applePayController.delegate = self
        self.presentViewController(applePayController, animated: true, completion: nil)
    }
}

//MARK: Apple Pay

func paymentAuthorizationViewController(controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, completion: (PKPaymentAuthorizationStatus) -> Void) {

}

func paymentAuthorizationViewControllerDidFinish(controller: PKPaymentAuthorizationViewController) {
    controller.dismissViewControllerAnimated(true, completion: nil)
}

}

知道可能出了什么问题吗?

【问题讨论】:

    标签: ios iphone swift ios-simulator applepay


    【解决方案1】:

    您需要在paymentAuthorizationViewController 中返回付款状态。您会看到委托方法有一个完成处理程序,您必须调用它来指示您是否能够成功处理付款。

    【讨论】:

    • 这太奇怪了,我会发誓我在那里有一个断点并且它没有被调用。但是,是的,这让它工作了。谢谢!如果有人想知道,添加测试成功付款的行是completion(PKPaymentAuthorizationStatus.Success)
    猜你喜欢
    • 2016-05-30
    • 2019-04-05
    • 2014-12-19
    • 2019-04-14
    • 2017-05-13
    • 2020-02-07
    • 2017-02-08
    • 1970-01-01
    • 2016-03-02
    相关资源
    最近更新 更多