私のアプリケーションでApple Payを設定しようとしていますが、何らかの理由でPKPaymentViewControllerが常にnilとして返されます。なぜどんなアイデア?PKPaymentAuthorizationViewControllerは常にnilを返しますか?
@IBAction func payAction(_ sender: Any) {
price = donationAmount.text
print(price)
let request = PKPaymentRequest()
request.merchantIdentifier = applePayMerchantID
request.supportedNetworks = SupportedPaymentNetworks
request.merchantCapabilities = PKMerchantCapability.capability3DS
request.countryCode = "GBR"
request.currencyCode = "GBP"
request.requiredBillingAddressFields = PKAddressField.all
//request.applicationData = "This is a test".dataUsingEncoding(NSUTF8StringEncoding)
let paymentSummary = [PKPaymentSummaryItem(label:"Sponsorship", amount: 10.00)]
request.paymentSummaryItems = paymentSummary
let applePayController: PKPaymentAuthorizationViewController = PKPaymentAuthorizationViewController(paymentRequest: request)
applePayController.delegate = self;
if(applePayController == nil){
print("___")
} else{
self.present(applePayController, animated: true, completion: nil)
}
}
func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -> Void) {
completion(PKPaymentAuthorizationStatus.success)
}
func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) {
controller.dismiss(animated: true, completion: nil)
}
使用この関数は' canMakePayments(usingNetworks)です。結果を教えてください –
その関数を使用してtrueに返されます –
あなたのiPhoneデバイスにApple Payを正しく設定していますか? –