> ## Documentation Index
> Fetch the complete documentation index at: https://developer.tazapay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pay by Bank Experience

> See how Pay by Bank works on mobile — a seamless, bank-authenticated checkout flow

export const STEPS = [{
  label: "Go to Checkout",
  time: 0
}, {
  label: "Pay By Bank",
  time: 0.5
}, {
  label: "Select Bank",
  time: 1.5
}, {
  label: "Give Consent",
  time: 3
}, {
  label: "Authenticate",
  time: 7
}, {
  label: "Success",
  time: 10
}];

export function VideoStepPlayer() {
  const videoRef = useRef(null);
  const [activeStep, setActiveStep] = useState(0);
  const [videoTime, setVideoTime] = useState(0);
  const [isMobile, setIsMobile] = useState(false);
  useEffect(() => {
    const check = () => setIsMobile(window.innerWidth < 768);
    check();
    window.addEventListener("resize", check);
    return () => window.removeEventListener("resize", check);
  }, []);
  useEffect(() => {
    const video = videoRef.current;
    if (!video) return;
    let interval = null;
    const tick = () => {
      const t = video.currentTime;
      setVideoTime(t);
      let current = 0;
      for (let i = STEPS.length - 1; i >= 0; i--) {
        if (t >= STEPS[i].time) {
          current = i;
          break;
        }
      }
      setActiveStep(current);
    };
    const startPolling = () => {
      if (!interval) interval = setInterval(tick, 100);
    };
    const stopPolling = () => {
      clearInterval(interval);
      interval = null;
    };
    video.addEventListener("play", startPolling);
    video.addEventListener("pause", stopPolling);
    if (!video.paused) startPolling();
    return () => {
      stopPolling();
      video.removeEventListener("play", startPolling);
      video.removeEventListener("pause", stopPolling);
    };
  }, []);
  const segmentFill = i => {
    if (i >= STEPS.length - 1) {
      if (videoTime < STEPS[i].time) return 0;
      return Math.min((videoTime - STEPS[i].time) / (15 - STEPS[i].time) * 100, 100);
    }
    const start = STEPS[i].time;
    const end = STEPS[i + 1].time;
    if (videoTime <= start) return 0;
    if (videoTime >= end) return 100;
    return (videoTime - start) / (end - start) * 100;
  };
  const handleStepClick = index => {
    const video = videoRef.current;
    if (!video) return;
    video.currentTime = STEPS[index].time;
    video.play();
    setActiveStep(index);
  };
  return <div style={{
    display: "flex",
    flexDirection: "column",
    alignItems: "center",
    gap: "32px",
    padding: "24px 0"
  }}>
      <video ref={videoRef} autoPlay muted playsInline loop preload="metadata" style={{
    height: "520px",
    borderRadius: "16px",
    boxShadow: "0 8px 32px rgba(0,0,0,0.15)",
    background: "#000"
  }}>
        <source src="/images/mobile-experience-tink.mp4" type="video/mp4" />
      </video>

      {isMobile ? <div style={{
    width: "100%",
    textAlign: "center"
  }}>
          <span style={{
    fontSize: "14px",
    fontWeight: "600",
    color: "#0C6CF2"
  }}>
            {STEPS[activeStep].label}
          </span>
          <div style={{
    marginTop: "10px",
    width: "100%",
    height: "3px",
    background: "#E2E8F0",
    borderRadius: "2px",
    overflow: "hidden"
  }}>
            <div style={{
    height: "100%",
    width: `${segmentFill(activeStep)}%`,
    background: "#0C6CF2",
    borderRadius: "2px",
    transition: "width 0.1s linear"
  }} />
          </div>
        </div> : <div style={{
    width: "100%"
  }}>
          <div style={{
    display: "flex",
    width: "100%",
    gap: "8px"
  }}>
            {STEPS.map((step, i) => <button key={i} onClick={() => handleStepClick(i)} style={{
    flex: 1,
    display: "flex",
    flexDirection: "column",
    alignItems: "center",
    gap: "10px",
    background: "none",
    border: "none",
    cursor: "pointer",
    padding: "0"
  }}>
                <span style={{
    fontSize: "13px",
    fontWeight: activeStep === i ? "600" : "400",
    opacity: activeStep === i ? 1 : 0.3,
    textAlign: "center",
    lineHeight: "1.3",
    transition: "opacity 0.25s, font-weight 0.25s",
    whiteSpace: "nowrap"
  }}>
                  {step.label}
                </span>
                <div style={{
    width: "100%",
    height: "2px",
    background: "rgba(128,128,128,0.2)",
    position: "relative",
    overflow: "hidden",
    borderRadius: "1px"
  }}>
                  <div style={{
    position: "absolute",
    top: 0,
    left: 0,
    height: "100%",
    width: `${segmentFill(i)}%`,
    background: "rgba(128,128,128,0.9)",
    transition: "width 0.1s linear"
  }} />
                </div>
              </button>)}
          </div>
        </div>}
    </div>;
}

<VideoStepPlayer />
