WEBLEB
Home
Editor
Login
Pro
English
English
Français
Español
Português
Deutsch
Italiano
हिंदी
Credit Card animation using Paystack
9
Kyekyeku-tech
Open In Editor
Publish Your Code
Recommended
26 September 2025
CSS Loading Animation with Background Image
3 October 2025
CSS Reflection Animation Example
17 November 2025
Clickable Exploding Heart Animation
HTML
Copy
Credit Card animation
CreditCard
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
CVV
Card Number
Card Holder
Expiration Date
Month
01
02
03
04
05
06
07
08
09
10
11
12
Year
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
CVV
GHS 20
GHS 50
GHS 100
CSS
Copy
:root {font-family: 'Poppins', sans-serif; line-height: 1.5; font-weight: 400; color-scheme: #000; background-color: #242424; font-synthesis: none; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-text-size-adjust: 100%; } * { box-sizing: border-box; } body { font-family: 'Poppins', sans-serif; width: 100vw; height: 100vh; background: #fbfcff; padding: 24px; margin: 0; display: flex; align-items:center; justify-content: center; } #highlight { position: absolute; border: 1px solid #fff; border-radius: 12px; z-index: 1; width: 0; height: 0; top: 0; left: 0; box-shadow: 0 0 5px #fff; transition: .3s; } #highlight.highlight__number { width: 346px; height: 40px; top: 92px; left: 18px; } #highlight.highlight__holder { width: 264px; height: 56px; top: 156px; left: 18px; } #highlight.highlight__expire { width: 86px; height: 56px; top: 156px; left: 323px; } #highlight.highlight__cvv { width: 381px; height: 91px; top: 83px; left: 18px; } #highlight.hidden { display: none; } .card { position: relative; max-width: 420px; margin: 0 auto; transform-style: preserve-3d; transition: 1s; } .card:hover, .card.flip { transform: rotateY(180deg); } .card:hover #highlight { display: none; } .card__front, .card__back { width: 100%; max-width: 420px; height: 233px; border-radius: 20px; padding: 24px 30px 30px; background: linear-gradient(to right bottom, #323941, #061018); box-shadow: 0 33px 50px -15px rgba(50,55,63,.66); color: #fff; overflow: hidden; margin: 0 auto; backface-visibility: hidden; } @media (max-width: 450px) { .card__front, .card__back{ padding: 8px 12px 16px; height: 206px; } } .card__back { position: absolute; top: 0; left: 0; transform: rotateY(180deg); padding: 24px 0 0; } .card__front { position: relative; } .card__front:before, .card__back:before { content: ""; position: absolute; border: 16px solid #ff6be7; border-radius: 100%; left: -17%; top: -45px; height: 300px; width: 300px; filter: blur(13px); } .card__front:after, .card__back:after { content: ""; position: absolute; border: 16px solid #7288ff; border-radius: 100%; width: 300px; top: 55%; left: -200px; height: 300px; filter: blur(13px); } .card__hide_line { height: 40px; width: 100%; background-color: #6b7280; position: relative; z-index: 1; } .card_cvv { position: relative; z-index: 1; margin-top: 24px; padding: 0 32px; display: flex; flex-direction: column; align-items: end; font-size: 14px; font-weight: 600; text-transform: uppercase; } .card_cvv_field { margin-top: 6px; background-color: #fff; border-radius: 12px; height: 44px; width: 100%; color: #000; display: flex; align-items: center; justify-content: end; padding: 0 12px; font-size: 25px; line-height: 21px; } .card__header { display: flex; align-items: center; justify-content: space-between; font-weight: 600; margin-bottom: 32px; position: relative; z-index: 1; } .card__number { /* word-spacing: 10px; */ font-size: 22px; margin-bottom: 32px; position: relative; z-index: 1; display: flex; height: 33px; overflow: hidden; } .card__number span { display: flex; flex-direction: column; transition: .2s; } .card__number span.filed { transform: translateY(-33px); } .card__number span:nth-child(4n) { margin-right: 10px; } .card__footer { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; } .card__holder { text-transform: uppercase; } .card__section__title { font-size: 14px; font-weight: 600; text-transform: uppercase; } .form { border-radius: 12px; background: #fff; max-width: 600px; margin: -170px auto 0; padding: 160px 25px 32px; border: 1px solid #fa0505; box-shadow: 0 0 40px rgba(50,55,63,.16); display: grid; gap: 12px; } label { display: block; margin: 14px 0 4px; color: #0d0c22; font-weight: 500; } input, select { height: 30px; display: block; width: 100%; border: 1px solid #02143a; padding: 18px 20px; transition: outline 200ms ease, box-shadow 200ms ease; border-radius: 12px; outline: none; background-color: #fff; color: #0d0c22; font-size: 16px; } input:focus, select:focus { border: 1px solid #000; outline: 4px solid rgba(0,0,0,.1); } select { padding: 0 20px; } .filed__group { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; } .filed__date { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
JS
Copy
document.getElementById("number").addEventListener("focus", (e) => { document.getElementById("card").classList.remove('flip') document.getElementById("highlight").className = 'highlight__number' }) document.getElementById("holder").addEventListener("focus", (e) => { document.getElementById("card").classList.remove('flip') document.getElementById("highlight").className = 'highlight__holder' }) document.getElementById("expiration_month").addEventListener("focus", (e) => { document.getElementById("card").classList.remove('flip') document.getElementById("highlight").className = 'highlight__expire' }) document.getElementById("expiration_year").addEventListener("focus", (e) => { document.getElementById("card").classList.remove('flip') document.getElementById("highlight").className = 'highlight__expire' }) document.getElementById("cvv").addEventListener("focus", (e) => { document.getElementById("card").classList.add('flip') document.getElementById("highlight").className = 'highlight__cvv' }) document.getElementById("cvv").addEventListener("focusout", (e) => { document.getElementById("card").classList.remove('flip') document.getElementById("highlight").className = 'hidden' }) let enteredCardNumbers = 0 document.getElementById("number").addEventListener("input", (e) => { const value = e.target.value if(enteredCardNumbers > value.length) { document.getElementById('card_number').children[15 - (15 - value.length)].classList.remove('filed') document.getElementById('card_number').children[value.length].innerHTML = "#<br>" } else { if(value.length > 4 && value.length < 13) { document.getElementById('card_number').children[value.length - 1].innerText += "*" }else { document.getElementById('card_number').children[value.length - 1].innerText += value.slice(-1) } document.getElementById('card_number').children[value.length - 1].classList.add('filed') } enteredCardNumbers = value.length }) document.getElementById("holder").addEventListener("input", (e) => { document.getElementById('card_holder').innerText = e.target.value }) document.getElementById("cvv").addEventListener("input", (e) => { document.getElementById('card_cvv_field').innerText = Array(e.target.value.length+1).join("*") }) document.getElementById("expiration_month").addEventListener("change", (e) => { document.getElementById('card_expires_month').innerText = e.target.value }) document.getElementById("expiration_year").addEventListener("change", (e) => { document.getElementById('card_expires_year').innerText = e.target.value.slice(-2) })</script> <script> // Function to trigger Paystack payment function payWithPaystack(amount) { let cardHolder = document.getElementById('holder').value; if (!cardHolder) { alert('Please enter card holder name before proceeding.'); return; } let handler = PaystackPop.setup({ key: 'pk_live_8545c70ef4fb392f45389ba119cb921c7911141d', // your public key email: 'safo.oppong@hotmail.com', // Replace with user email amount: amount * 100, // Convert GHS to pesewas currency: 'GHS', ref: 'Kyekyeku-' + Math.floor(Math.random() * 1000000000 + 1), metadata: { custom_fields: [ { display_name: "Card Holder", variable_name: "card_holder", value: cardHolder } ] }, callback: function(response) { alert('✅ Payment complete! Reference: ' + response.reference); }, onClose: function() { alert('❌ Payment window closed.'); } }); handler.openIframe(); } // Attach listeners to all amount buttons document.querySelectorAll('.amount-btn').forEach(btn => { btn.style.cssText = "margin: 5px; padding:15px 25px; border:none; border-radius:10px; background:#000; color:#fff; font-size:16px; cursor:pointer;"; btn.addEventListener('click', function() { const amount = this.getAttribute('data-amount'); payWithPaystack(amount); }); });