debugPrint 说 "UAUTHENTICATED"

debugPrint says "UAUTHENTICATED"

我正在尝试 link 我的 ios 应用程序带有条纹的 firebasse。

我在控制台代码中的 debugPrint 显示“UNAUTHENTICATED

这是我的Viewontroller-

import UIKit
import FirebaseFirestore
import FirebaseAuth
import Stripe
import FirebaseFunctions
class SignUpViewController: UIViewController {
    var paymentContext = STPPaymentContext()
    @IBOutlet weak var email: UITextField!
    @IBOutlet weak var password: UITextField!
    @IBOutlet weak var passwordConfirm: UITextField!
    @IBAction func signUpAction(_ sender: Any) {
        if password.text != passwordConfirm.text {
            let alertController = UIAlertController(title: "Password Incorrect", message: "Please re-type password", preferredStyle: .alert)
            let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
            alertController.addAction(defaultAction)
            self.present(alertController, animated: true, completion: nil)
        }
        else{
            Auth.auth().createUser(withEmail: email.text!, password: password.text!){
                (user, error) in if error == nil {
                }
                else{
                    let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
                    let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
                    alertController.addAction(defaultAction)
                    self.present(alertController, animated: true, completion: nil)
                }
            }
        }
        Functions.functions().httpsCallable("createStripeUser").call(["email": email.text ?? ""]) {
            (result, error) in
            if let error = error {
                debugPrint(error.localizedDescription)
                return
            }
            self.dismiss(animated: true)
        }
    }

}

控制台中“UNAUTHENTICATED”上方代码中的 debugPrint 行如下所示:-

如您所见,客户是在 FirebaseAuth 中创建的,如下所示:-

另外,没有创建stripe customer

如何解决?

根据 Frank van Puffelen 的建议编辑后,viewcontroller 代码 -

import UIKit
 import FirebaseFirestore
 import FirebaseAuth
import Stripe
import FirebaseFunctions

class SignUpViewController: UIViewController {
var paymentContext = STPPaymentContext()

@IBOutlet weak var email: UITextField!
@IBOutlet weak var password: UITextField!
@IBOutlet weak var passwordConfirm: UITextField!
@IBAction func signUpAction(_ sender: Any) {
    if password.text != passwordConfirm.text {
        let alertController = UIAlertController(title: "Password Incorrect", message: "Please re-type password", preferredStyle: .alert)
        let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
        alertController.addAction(defaultAction)
        self.present(alertController, animated: true, completion: nil)
    }
    else{
        Auth.auth().createUser(withEmail: email.text!, password: password.text!){ [self]
            (user, error) in if error == nil {
                // 
                Functions.functions().httpsCallable("createStripeUser").call(["email": self.email.text ?? ""]) {
                    (result, error) in
                    if let error = error {
                        debugPrint(error.localizedDescription)
                        return
                    }
                    self.dismiss(animated: true)
                }
            }
            else{
                let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
                let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
                alertController.addAction(defaultAction)
                self.present(alertController, animated: true, completion: nil)
            }
        }
       }
         }
 }

那没有帮助。

需要 运行 用户创建之后的代码需要在 createUser(withEmail:, password:) 的完成处理程序中。因此,将调用 httpsCallable("createStripeUser") 移动到该块中:

@IBAction func signUpAction(_ sender: Any) {
    if password.text != passwordConfirm.text {
        let alertController = UIAlertController(title: "Password Incorrect", message: "Please re-type password", preferredStyle: .alert)
        let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
        alertController.addAction(defaultAction)
        self.present(alertController, animated: true, completion: nil)
    }
    else{
        Auth.auth().createUser(withEmail: email.text!, password: password.text!){
            (user, error) in if error == nil {
                // 
                Functions.functions().httpsCallable("createStripeUser").call(["email": email.text ?? ""]) {
                    (result, error) in
                    if let error = error {
                        debugPrint(error.localizedDescription)
                        return
                    }
                    self.dismiss(animated: true)
                }
            }
            else{
                let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
                let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
                alertController.addAction(defaultAction)
                self.present(alertController, animated: true, completion: nil)
            }
        }
    }
}