iOS 模拟器在尝试 Apple Pay 时卡在 "Pay with Passcode"
iOS Simulator gets stuck at "Pay with Passcode" when trying Apple Pay
我正在尝试在我的应用程序上设置 Apple Pay,但我目前没有 iPhone 6。所以我正在努力准备好所有的东西和 运行 模拟器,然后才能去买一个,或者试着找人借给我一个。
无论如何,我到了实际展示 ApplePay 视图控制器的地步:
但是当我点击 "Pay with Passcode" 时没有任何反应,所以我无法继续使用服务器完成所有测试。
以下是我的代码的相关部分:
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)
}
}
知道哪里出了问题吗?
您需要 return 在 paymentAuthorizationViewController
中的付款状态。您会看到委托方法有一个完成处理程序,您必须调用它来指示您是否能够成功处理付款。
我正在尝试在我的应用程序上设置 Apple Pay,但我目前没有 iPhone 6。所以我正在努力准备好所有的东西和 运行 模拟器,然后才能去买一个,或者试着找人借给我一个。
无论如何,我到了实际展示 ApplePay 视图控制器的地步:
但是当我点击 "Pay with Passcode" 时没有任何反应,所以我无法继续使用服务器完成所有测试。
以下是我的代码的相关部分:
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)
}
}
知道哪里出了问题吗?
您需要 return 在 paymentAuthorizationViewController
中的付款状态。您会看到委托方法有一个完成处理程序,您必须调用它来指示您是否能够成功处理付款。