Hi, I am following this github link - https://github.com/stripe-samples/firebase-mobile-payments and thid https://github.com/stripe/stripe-ios/blob/21.8.1/Stripe/PaymentSheet.swift#L33-L152 . It shows error - "cannot find configuration in scope" and other errors as shown below-
import UIKit
import Foundation
public class PaymentSheet {
/// This contains all configurable properties of PaymentSheet
public let configuration: Configuration // Error - Cannot find type 'Configuration' in scope
/// The most recent error encountered by the customer, if any.
public private(set) var mostRecentError: Error?
/// Initializes a PaymentSheet
/// - Parameter paymentIntentClientSecret: The [client secret](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-client_secret) of a Stripe PaymentIntent object
/// - Note: This can be used to complete a payment - don't log it, store it, or expose it to anyone other than the customer.
/// - Parameter configuration: Configuration for the PaymentSheet. e.g. your business name, Customer details, etc.
public convenience init(paymentIntentClientSecret: String, configuration: Configuration) { // Error - Cannot find type 'Configuration' in scope
self.init(
intentClientSecret: .paymentIntent(clientSecret: paymentIntentClientSecret),//Error - Cannot infer contextual base in reference to member 'paymentIntent'
configuration: configuration
)
}
/// Initializes a PaymentSheet
/// - Parameter setupIntentClientSecret: The [client secret](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-client_secret) of a Stripe SetupIntent object
/// - Parameter configuration: Configuration for the PaymentSheet. e.g. your business name, Customer details, etc.
public convenience init(setupIntentClientSecret: String, configuration: Configuration) { // Error - Cannot find type 'Configuration' in scope
self.init(
intentClientSecret: .setupIntent(clientSecret: setupIntentClientSecret),//Error - Cannot infer contextual base in reference to member 'setupIntent
configuration: configuration
)
}
required init(intentClientSecret: IntentClientSecret, configuration: Configuration) {// Error - Cannot find type 'Configuration' in scope
STPAnalyticsClient.sharedClient.addClass(toProductUsageIfNecessary: PaymentSheet.self)// Error - Cannot find 'STPAnalyticsClient' in scope
self.intentClientSecret = intentClientSecret
self.configuration = configuration
STPAnalyticsClient.sharedClient.logPaymentSheetInitialized(configuration: configuration)
}
/// Presents a sheet for a customer to complete their payment
/// - Parameter presentingViewController: The view controller to present a payment sheet
/// - Parameter completion: Called with the result of the payment after the payment sheet is dismissed
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
public func present(
from presentingViewController: UIViewController,
completion: @escaping (PaymentSheetResult) -> () //Error - Cannot find type 'PaymentSheetResult' in scope
) {
// Overwrite completion closure to retain self until called
let completion: (PaymentSheetResult) -> () = { status in
// Dismiss if necessary
if self.bottomSheetViewController.presentingViewController != nil {
self.bottomSheetViewController.dismiss(animated: true) {
completion(status)
}
} else {
completion(status)
}
self.completion = nil
}
self.completion = completion
// Guard against basic user error
guard presentingViewController.presentedViewController == nil else {
assertionFailure("presentingViewController is already presenting a view controller")
let error = PaymentSheetError.unknown( // Error - annot find 'PaymentSheetError' in scope
debugDescription: "presentingViewController is already presenting a view controller"
)
completion(.failed(error: error))
return
}
// Configure the Payment Sheet VC after loading the PI/SI, Customer, etc.
PaymentSheet.load(
apiClient: configuration.apiClient,
clientSecret: intentClientSecret,
ephemeralKey: configuration.customer?.ephemeralKeySecret,
customerID: configuration.customer?.id
) { result in
switch result {
case .success((let intent, let paymentMethods)):
// Set the PaymentSheetViewController as the content of our bottom sheet
let isApplePayEnabled = StripeAPI.deviceSupportsApplePay() && self.configuration.applePay != nil
let paymentSheetVC = PaymentSheetViewController(
intent: intent,
savedPaymentMethods: paymentMethods,
configuration: self.configuration,
isApplePayEnabled: isApplePayEnabled,
delegate: self
)
// Workaround to silence a warning in the Catalyst target
#if targetEnvironment(macCatalyst)
self.configuration.style.configure(paymentSheetVC)
#else
if #available(iOS 12.0, *) {
self.configuration.style.configure(paymentSheetVC)
}
#endif
self.bottomSheetViewController.contentStack = [paymentSheetVC]
case .failure(let error):
completion(.failed(error: error))
}
}
presentingViewController.presentPanModal(bottomSheetViewController)// Error - Value of type 'UIViewController' has no member 'presentPanModal'
}
// MARK: - Internal Properties
/// An unordered list of paymentMethod types that can be used with PaymentSheet
static let supportedPaymentMethods: [STPPaymentMethodType] = [.card, .iDEAL]// Error - Cannot find type 'STPPaymentMethodType' in scope
let intentClientSecret: IntentClientSecret//. Error - Cannot find type 'IntentClientSecret' in scope
var completion: ((PaymentSheetResult) -> ())?// Error - Cannot find type 'PaymentSheetResult' in scope
lazy var bottomSheetViewController: BottomSheetViewController = {
let vc = BottomSheetViewController(
contentViewController: LoadingViewController(delegate: self)
)
if #available(iOS 12.0, *) {
configuration.style.configure(vc)
}
return vc
}()
}
How should I sort it out ?