47 lines
1.3 KiB
Swift
47 lines
1.3 KiB
Swift
import SwiftUI
|
|
|
|
import Bootpay
|
|
#if !AUTH_VERIFICATION_MOCK
|
|
import BootpayUI
|
|
#endif
|
|
|
|
struct AuthVerificationView: View {
|
|
let payload: Payload
|
|
let onCancel: () -> Void
|
|
let onError: () -> Void
|
|
let onDone: ([String: Any]) -> Void
|
|
let onClose: () -> Void
|
|
|
|
#if AUTH_VERIFICATION_MOCK
|
|
@State private var hasCompleted = false
|
|
#endif
|
|
|
|
var body: some View {
|
|
#if AUTH_VERIFICATION_MOCK
|
|
LoadingView()
|
|
.background(Color.white.ignoresSafeArea())
|
|
.task {
|
|
guard !hasCompleted else { return }
|
|
do {
|
|
try await Task.sleep(nanoseconds: 500_000_000)
|
|
} catch is CancellationError {
|
|
return
|
|
} catch {
|
|
onError()
|
|
return
|
|
}
|
|
guard !Task.isCancelled, !hasCompleted else { return }
|
|
hasCompleted = true
|
|
onDone(["data": ["receipt_id": "dev-mock-auth-receipt"]])
|
|
}
|
|
#else
|
|
BootpayUI(payload: payload, requestType: BootpayRequest.TYPE_AUTHENTICATION)
|
|
.onConfirm { _ in true }
|
|
.onCancel { _ in onCancel() }
|
|
.onError { _ in onError() }
|
|
.onDone(onDone)
|
|
.onClose(onClose)
|
|
#endif
|
|
}
|
|
}
|