Price Garrett Price Garrett - 5 months ago 15
Swift Question

Xcode Apple Pay - PKPaymentAuthorizationViewControllerDelegate issues

I am trying to implement Apple Pay into my application. I am having an issue even establishing the

PKPaymentAuthorizationViewControllerDelegate
into my
ViewController.swift
file.

Most code samples have shown it as:
class ViewController: UITableViewController, PKPaymentAuthorizationViewControllerDelegate


Here is my code:

class ApplePayVC: UIViewController, PKPaymentAuthorizationViewControllerDelegate {


code

Answer

That because you must implement some of the functions of the delegate.

See in the Apple Documentation : https://developer.apple.com/library/prerelease/ios/documentation/PassKit/Reference/PKPaymentAuthorizationViewControllerDelegate_Ref/index.html

Two functions are required :

  • paymentAuthorizationViewController(_:didAuthorizePayment:completion:)
  • paymentAuthorizationViewControllerDidFinish(_:)

You must override them, and then, the error will disappear from Xcode