Here is my code for going to the Paypal payment gateway for the item after a click on the “Buy Now” Button, But I want this function to be without even click on the “Buy Now” button, my meaning is when then webpage opened automatically go to the Paypal payment gateway without a click on “Buy Now” button. Is it possible? Any guidance will be very helpful.
<script type="text/javascript" src="https://test.com/java.js"></script> <form target="PayPal" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin:0;padding:0;"> <input type="hidden" name="business" value="test@yahoo.com"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="item_name" value="Membership"> <input type="hidden" name="item_number" value="1 Month"> <input type="hidden" name="amount" value="23"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="shipping" value=""> <input type="hidden" name="shipping2" value=""> <input type="hidden" name="handling" value=""> <input type="hidden" name="return" value="https://test.com/Successful_Payment.php"> <input type="hidden" name="cancel_return" value=""> <input type="hidden" name="undefined_quantity" value="0"> <input type="hidden" name="receiver_email" value="test@yahoo.com"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="no_note" value="0"> <div id="PayPal6" style="position:absolute;left:445px;top:470px;width:134px;height:65px;"> <input type="image" name="submit" src="images/buynow.png" style="position:absolute;left:0px;top:0px;" alt="Make payments with PayPal, it's fast, free, and secure!"> </div> </form>
Advertisement
Answer
U can achieve that by JavaScript:
window.onload = function(){ // u should put a name for your form document.forms['my_form_name'].submit(); }
EDIT: You could also submit the PayPal submit button instead of the form:
window.onload = function(){ document.getElementById('paypalButton').submit(); }