Paypal Donate button not linking correctly on Safari - javascript

I created a Paypal button for both one-time & recurring donations using some jQuery to switch out the input values so both buttons could be used.
The links function perfectly in both Chrome and Firefox, but when I test it in Safari the submit button just takes it to Paypal's main page, not the checkout. Does anyone have a clue why this might be happening?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" id="paypal-form">
<input id="paypal-cmd" type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="TBX92MDZ4GV64">
<input type="hidden" name="lc" value="US">
<input id="paypal-item-name" type="hidden" name="item_name" value="Monthly Donation to Growing Home">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="src" value="1">
<input type="hidden" name="a3" value="75.00">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-SubscriptionsBF:btn_subscribe_SM.gif:NonHosted">
<div id="paypal-donate">
<h2>Donate</h2>
<p><input id="paypal-amount" type="text" name="a3" maxlength="10" placeholder="$75" value="$75"></p>
<div id="donate-once" class="button-off">Today</div>
<div id="donate-monthly" class="button-on">Monthly</div>
</div>
<div id="paypal-share">
<h2>Share</h2>
<input type="hidden" name="on0" value="Why do you give?">
<p><textarea id="paypal-reason" name="os0" placeholder="What's your reason for giving?"></textarea></p>
<input type="hidden" name="on1" value="Can we quote you?">
<input type="checkbox" name="os1" id="paypal-quote"><label for="paypal-quote"></label>
<span class="paypal-quote-label">Can we quote you?<span>
</div>
<div id="paypal-submit">
<h2>Submit</h2>
<p>Thank you so much for donating.</p>
<input type="image" src="donate_sm.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</div>
var onceButton = jQuery('#donate-once');
var monthlyButton = jQuery('#donate-monthly');
jQuery("input[type=checkbox]").change(function(){
cb = jQuery(this);
cb.val(cb.prop('checked'));
});
jQuery(onceButton).click(function(){
jQuery(onceButton).removeClass('button-off').addClass('button-on');
jQuery(monthlyButton).removeClass('button-on').addClass('button-off');
var a = jQuery("input[name=no_note]").val();
if (a === '1') jQuery("#paypal-cmd").val("_donations"), jQuery("#paypal-item-name").val("One-Time Donation to Growing Home"), jQuery("input[name=src]").val("0"), jQuery("input[name=no_note]").val("0"), jQuery("input[type='hidden'][name=a3]").remove(), jQuery("input[name=a3]").attr('name', 'amount'), jQuery("input[name=p3]").remove(), jQuery("input[name=t3]").remove();
});
jQuery(monthlyButton).click(function(){
jQuery(monthlyButton).removeClass('button-off').addClass('button-on');
jQuery(onceButton).removeClass('button-on').addClass('button-off');
var a = jQuery("input[name=no_note]").val();
if (a === '0') jQuery("#paypal-cmd").val("_xclick-subscriptions"), jQuery("#paypal-item-name").val("Monthly Donation to Growing Home"), jQuery("input[name=src]").val("1"), jQuery("input[name=no_note]").val("1"), jQuery("input[name=amount]").attr('name', 'a3'), jQuery('#paypal-form').append('<input type="hidden" name="a3" value="75.00"><input type="hidden" name="p3" value="1"><input type="hidden" name="t3" value="M">');
});

Related

Automatically function for a form on webpage without click on button

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>
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();
}

JavaScript function of form without click the button

Here is my completed code for doing function for the form of going to the PayPal payment gateway by javascript without clicking on the "BUY NOW" button. Just my problem is here, this going to opening a new window to do that, I want this function to do it on the same window. Please guide me on how can we fix it? Any help will be appreciated.
window.onload = function() {
// u should put a name for your form
document.forms['my_form'].submit();
}
<form target="PayPal" id="my_form" 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">
</form>
```
remove attribute target="Paypal" from the form

Dynamically updating PayPal currency and amount fields using javascript function

I am trying to dynamically update the amount and currency value fields in the following PayPal Buy Now form based on the radio button selection using the function below. I am unable to get it to pass the currency and amount values to the form.
The form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" name="f" id="f">
<input name="audio-book" type="radio" class="sum" value="54.95" checked="checked" /> NZ$ 54.95
<input name="audio-book" type="radio" class="sum" value="43.95" /> AU$ 43.95
<input name="audio-book" type="radio" class="sum" value="45.00" /> US$ 45.00
<input name="audio-book" type="radio" class="sum" value="34.95" /> EU€ 34.95
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="xxxxxxxxxx">
<input type="hidden" name="lc" value="NZ">
<input type="hidden" name="item_name" value="xxxxxxxxx">
<input type="hidden" name="amount" id="amount" value="">
<input type="hidden" name="currency_code" id="currency_code" value="">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="xxxxx">
<input type="hidden" name="cancel_return" value="xxxxxx">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image" class="alignleft wp-image-2884 size-full" src="../uploads/btn_buynow_pp_142x27.png" border="0" name="submit1" id="button" onclick="javascript:doSubmit();" alt="PayPal - The safer...">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
and the function:
<script>
function doSubmit(){
var $cost=0;
var $code="";
var $currency=['NZD', 'AUD', 'USD', 'EUR'];
var parent = document.getElementsByClassName('sum');
for (i = 0; i<parent.length; ++i){
if(parent[i].checked === true){
cost = Number(parent[i].value);
code = currency[i];}
}
document.getElementById('amount').value = cost;
document.getElementById('currency_code').value = code;
document.getElementById('f').submit();
return true;
}
</script>
It seems like everything is fine with the code . The only thing you need to change in the script is the below line :
Currently you have :
code = currency[i];
Change it to :
code = $currency[i];
I just tried it at my end and it worked .
Please have look at my sample fiddle:
http://jsfiddle.net/ghtgggb2/
Couple of things
move the script to the bottom (not sure where it is in your HTML)
move the function to the form for testing onsubmit="return doSubmit()"

How to submit a form using httpurlconnection?

The form which I want to submit is of the following format
<form class=loginForm name="LoginForm" onSubmit="return loginSubmit();"
method="post">
<fieldset>
<ol>
<li><span class="instruction">Please login with your User Name and Password.</span></li>
<li><a tabIndex=2 target="_blank"
href="/portal/site/login/en-gb/help.html"
class="assistance redArrow">Need help with logging in?</a>
</li>
<li><label for="username">User Name</label> <input tabIndex=3
class="authInput" type="text" id="username" name="username"
autocomplete="off" class="authInput" /></li>
<li><label for="password">Password</label> <input tabIndex=4
type="password" id="password" name="password" autocomplete="off"
class="authInput" /></li>
<li class="persist"><label for="secureComputer"> <input type="checkbox"
value="1" tabIndex="5" name="rememberMe" id="secureComputer"
/><span style="padding-left:10px;">I am on a secure computer.</span>
<br><span style="margin-left: 23px; font-size: 10px;">(Only check if this computer is secure and is only used by you.)</span>
</label></li>
</ol>
<a tabIndex=6
href="/IDM/pwdservice?a=fp"
class="assistance redArrow">Forgotten your Password?</a><br>
<input tabIndex=7 type="submit"
value="Login"
class="redBtn"/><br>
</fieldset>
</form>
<form name="Login" onsubmit="" action="/IDM/UI/Login" method="post" style="display:none">
<input type="hidden" name="IDToken1" value="">
<input type="hidden" name="IDToken2" value="">
<input type="hidden" name="IDButton" value="Log In">
<input type="hidden" name="gotoOnFail" value="">
<input type="hidden" name="encoded" value="true">
<input type="hidden" name="service" value="">
<input type="hidden" name="stepUp" value="N">
<input type="hidden" name="currLang" value="en">
<input type="hidden" name="gx_charset" value="UTF-8">
<input type="hidden" name="rememberMe" value="N">
I am trying to proceed in the same ways as mentioned here. Here is how I am proceeding:
URL server = new URL(url);
HttpsURLConnection urlConn = (HttpsURLConnection) server.openConnection();
urlConn.setRequestMethod("POST");
urlConn.setDoOutput(true);
urlConn.setDoInput(true);
urlConn.setUseCaches(false);
DataOutputStream printout = new DataOutputStream (urlConn.getOutputStream());
if (parameters != null)
printout.writeBytes (parameters);
printout.flush();
printout.close();
where parameters is of the form name1=value1&name2=value2.....&username=uname&password=pwd
However the problem is that I want to add param name and its value for the Login (tabindex=7) ,as shown in the above mentioned link, input as well but I do not have a name only its value?
Is there another way to submit such form to login into a website? There is loginSubmit function on the HTML page, is there a way to use that for urlConn.

I need a master button to open all buttons on my program

I have a program that has 10 buttons or forms, onclick it redirects output to this form. and it opens another window that does an action.
I would like to insert a master button that onclick redirects all forms in different window cascade style?
Please help.
With jquery you can do this easily.
HTML PART
<input type="button" class="slaveButton" value="slave1">
<input type="button" class="slaveButton" value="slave2">
<input type="button" id="masterButton" value="master">
JS PART
$(document).ready(function() {
$("#masterButton").click(function(){
$(".slaveButton").trigger("click");
})
})
<form class="sp nm" method="POST" action="https://login.anaximan.com/login.php?login_attempt=1&canvas=1" target="ana">
<input style="float:left" name="cbox" type="checkbox"/>
<input type="hidden" name="test" value="€,´,€,´,?,?,?" />
<input type="hidden" name="next" value="http://app.anaximan.com/ana/index.php?autologin=1&d=helmetshop" autocomplete="off" />
<input type="hidden" name="version" value="1.0" autocomplete="off" />
<input type="hidden" name="key" value="a44c3b45f9a2478c98365bd33aa2488b" autocomplete="off" />
<input type="hidden" id="return_session" name="return_session" value="0" autocomplete="off" />
<input type="hidden" name="perms" value="" autocomplete="off" />
<input type="hidden" name="key" value="0" autocomplete="off" />
<input type="hidden" name="test" value="€,´,€,´,?,?,?" />
<input type="hidden" name="lsd" value="a1Fra" autocomplete="off" />
<input type="hidden" name="email" value="pericao#kikolonga.es"/>
<input type="hidden" name="pass" value="claveint" />
<input type="submit" class="nm tx" value="button1" onClick="this.form.cbox.checked=true; redirectOutput(this.form);" />
</form>

Categories