UNPKG

simple-js-payment-system

Version:

Simple payment modal system with Stripe integration

45 lines (41 loc) 1.56 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="styles.css"> <title>Payment System</title> <script src="https://js.stripe.com/v3/"></script> </head> <body> <div class="container"> <button onclick="checkAndShowModal()" id="openPaymentModal">Open Payment Modal</button> </div> <script src="https://unpkg.com/simple-js-payment-system@1.1.2/payment.js"></script> <!-- <script src="./payment.js"></script> --> <script> const payment = new PaymentSystem() .minVisitCount(5) .discardVisitCount(1) .stripeConfig({ test: { publishableKey: 'pk_test_51OvPGD2L08TdNw1TA3BmJZSWNhbUg3HaW647yhsF8dHXm6MSN5JyxNyUC7aaxEOIrrZLNuwq0FNMWVNwdufiBu7l00s1r44mAQ', priceId: 'price_1Qmau92L08TdNw1TP7Jc7KcC' }, live: { publishableKey: 'pk_live_51OvPGD2L08TdNw1TGVlkaf8f4mEsqkwCHMF3Av110O79YdG578m1L18WbKyjZFbn6lHwRmNR1RiiHU00IEIt0Wpb00iWR2ouIQ', priceId: 'price_1QoAfz2L08TdNw1TcUnXI3ms' } }) .isLive(window.location.hostname !== '127.0.0.1') .run(); function checkAndShowModal() { if (!payment.hasPaid()) { payment.showModal(); } else { console.log('User has already paid'); } } </script> </body> </html>