If you need to trigger the "Pay Now" button in the Copy and Pay widget via a script then you can use the code snippets mentioned below. There are several use cases when you could need this:


 
  1. You have a one page checkout flow and want to trigger your own code before submitting the payment request
  2. You want to have your own Pay Now button on your website


If this is the case then you can implement this by triggering the "Pay Now" button of our widget through your code.


 


You have two options:

<script type="text/javascript">
cnp_jQuery(document).on('cnp:form:send', function(){
// code executed right before the form gets send (at this point the validation of card data already took place)
});
</script>

or

<script type="text/javascript">
cnp_jQuery(document).on( "cnp:ready", function(){
cnp_jQuery("button.cardSubmitButton").hide();
cnp_jQuery("#yourButton").click( function(){
// code executed right before the form gets send (at this point the validation of card data already took place)
cnp_jQuery("button.cardSubmitButton").click();
})
})
</script>