我正在尝试在我的应用程序上设置 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)
}
}
知道可能出了什么问题吗?