 /// An alias to determine the result types of a payment operation.
 typealias PaymentCompletionHandler = (Bool) -> Void
 
+/// Enum to track payment handler status and result
+enum PaymentHandlerStatus {
+  case started, presented, authorizationStarted, authorized
+}
+
 /// A simple helper to orchestrate fundamental calls to complete a payment operation.
 ///
 /// Use this class to manage payment sessions, with the ability to determine whether a user

class PaymentHandler: NSObject {
  
  /// Holds the current status of the payment process.
  var paymentStatus = PKPaymentAuthorizationStatus.failure
  
  /// Stores a reference to the Flutter result while the operation completes.
  var paymentResult: FlutterResult!


/// Extension that implements the completion methods in the delegate to respond to user selection.
extension PaymentHandler: PKPaymentAuthorizationControllerDelegate {

  func paymentAuthorizationControllerWillAuthorizePayment(_ controller: PKPaymentAuthorizationController) {
      paymentHandlerStatus = .authorizationStarted
  }
    
  func paymentAuthorizationController(_: PKPaymentAuthorizationController, didAuthorizePayment payment: PKPayment, handler completion: @escaping (PKPaymentAuthorizationResult) -> Void) {
    
    // Collect payment result or error and return if no payment was selected
