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:
- You have a one-page checkout flow and want to trigger your own code before submitting the payment request
- You want to have your own Pay Now button on your website
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> |