<script type="text/javascript">
    
    
    

     const payment_form = document.querySelector("#saveForm")
     payment_form.addEventListener("submit",payWithPaystack,false)
     
     function payWithPaystack(e){
         
     e.preventDefault()
     let amount = $("#amount").val()
     
     let handler = new PaystackPop()
    
  handler.newTransaction({
  key: '<?php echo $public_key; ?>',
  email: 'sample@email.com',
  amount: amount * 100,
  currency: 'NGN',
  userID: <?php echo $id;?>,
  onSuccess: (transaction) => {
    ref = transaction.reference;
    window.location = "https://app.ovohinitiative.com/users/verify-payment?reference=" + ref
  },
  /*onLoad: (response) => {
    alert("onLoad: ", response);
  },*/
  onCancel: () => {
    alert("onCancel");
  },
  onError: (error) => {
    alert("Error: ", error.message);
  }
})
            
   
         
 
    
    }
     
 </script>