PKPaymentAuthorizationControllerDelegate not being called

I have the below piece of code to do the Apple Pay. For some reason the code DidFinish method in the delegate is never called. Any help is appreciated.

import PassKit

typealias ApplePaymentCompletionHandler = (Bool) -> Void

class ApplePayment: NSObject {      var applePaymentController : PKPaymentAuthorizationController?   var summaryItems =   var status = PKPaymentAuthorizationStatus.failure   var paymentCompletionHandler: ApplePaymentCompletionHandler!       static let networks: [PKPaymentNetwork] = [     .visa, .masterCard, .discover, .amex   ]       class func applePayStatus() -> (makePayments: Bool, setupCards: Bool) {     return (PKPaymentAuthorizationController.canMakePayments(),         PKPaymentAuthorizationController.canMakePayments(usingNetworks: networks));   }       func startPayment(completion: @escaping ApplePaymentCompletionHandler, payAmount: String) {     paymentCompletionHandler = completion     let amount = PKPaymentSummaryItem(label: "Payment Amount", amount: NSDecimalNumber(string: payAmount), type: .final)     summaryItems = [amount]           let request = PKPaymentRequest()     request.paymentSummaryItems = summaryItems     request.merchantIdentifier = ""     request.merchantCapabilities = .capability3DS     request.countryCode = "US"     request.currencyCode = "USD"     request.supportedNetworks = ApplePayment.networks           applePaymentController = PKPaymentAuthorizationController(paymentRequest: request)     applePaymentController!.delegate = self     applePaymentController!.present(completion: { presented in       if presented {         print("Apple Payment Controller is presented.")       }       else {         print("Apple Payment Controller is not presented. There is an Issue.")         self.paymentCompletionHandler(false)       }     })   } }

extension ApplePayment: PKPaymentAuthorizationControllerDelegate {          func paymentAuthorizationController(_ controller: PKPaymentAuthorizationController, didAuthorizePayment payment: PKPayment, handler completion: @escaping (PKPaymentAuthorizationResult) -> Void) {     self.status = .success     completion(PKPaymentAuthorizationResult(status: .success, errors: )   }       func paymentAuthorizationControllerDidFinish(_ controller: PKPaymentAuthorizationController) {     debugPrint("Did Finish.")     controller.dismiss {       DispatchQueue.main.async {         if self.status == .success {           self.paymentCompletionHandler(true)         }         else {           self.paymentCompletionHandler(false)         }       }     }   }         }

PKPaymentAuthorizationControllerDelegate not being called
 
 
Q