I have tried several times and relied on the code snippets examples provided by paypal (https://www.paypal.com/mq/smarthelp/article/how-do-i-create-a-discount-code-or-coupon-code-for-my-paypal-buttons-ts1512).
Yet my button doesn't show any % discount as it should.
This is the HTML code snippet, trying to implement a 10% discount (I have just hidden my merchant ID):
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="this.target = 'paypal';
discnt = 10;
coupval = '(blanket)';
ReadForm (this);
discnt = 0;">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="XXX" />
<input type="hidden" name="item_name" value="Test Item" />
<input type="hidden" name="amount" value="10.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="lc" value="US" />
<input type="hidden" name="baseamt" value="10.00" />
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!" name="submit" alt="add to cart" />
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
Does any of you know what am I missing/how to fix it?
Thank you so much, take the chance to wish you a good day!
Michele
Related
I'm trying to update 2 hidden fields of a form based on the checkbox toggle. For some reason, only the first field is getting update and second one doesn't.
Any ideas what am I missing?
echo '
<form id="form1" action="';
echo $paypalURL;
echo '" method="post"> <p></p>';
?>
<input type="hidden" name="business" value="<?php echo $paypalID; ?>">
<input type='hidden' id="item_number" name="item_number" value="1">
Other Amount: <input id="amount" name="amount" value=""> <p></p>
<input type='hidden' id="currency_code" name="currency_code" value="">
<input type="hidden" id="src" value="" name="src" />
<input type="hidden" name="cmd" value="_donations">
Recurring donation?:
<input type="checkbox" id="checkbox" name="checkbox" value="" />
<script type="text/javascript">
var checkbox = document.getElementById('checkbox');
checkbox.addEventListener('change', function()
{
if (this.checked) {
document.getElementById('src').value = '1'
document.getElementById('cmd').value = '_xclick-subscriptions'
}
else
{
document.getElementById('src').value = ''
document.getElementById('cmd').value = '_donations'
}
}, false)
</script>
<!-- Specify URLs -->
<input type='hidden' name='cancel_return' value='http://localhost/wordpress1/wordpress/cancel.php'>
<input type='hidden' name='return' value='http://localhost/wordpress1/wordpress/success.php'>
<!-- Display the payment button. -->
<p><input type="image" name="submit" border="0"
src="images/PayPal-Donate-Button-PNG-Clipart.png" width="80" hight="50" alt="Donate Now"> </p>
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
It works, you just didn't add id="cmd" to hidden <input>
Your version:
<input type="hidden" name="cmd" value="_donations">
Correct varsion:
<input type="hidden" id="cmd" name="cmd" value="_donations">
Regards, KJ
I have created a paypal button with official tool before:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" id="paypal_form">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" id="order_button_id" value="123123abc">
<input type="hidden" name="quantity" id="order_quantity">
<input type="hidden" name="on0" value="Name">
<input type="hidden" name="os0" value="" id="post_name">
<input type="hidden" name="on1" value="Email">
<input type="hidden" name="os1" value="" id="post_email">
<input type="hidden" name="on2" value="Phone">
<input type="hidden" name="os2" value="" id="post_tel">
<input type="image" src="https://www.paypalobjects.com/en_GB/HK/i/btn/btn_buynowCC_LG_wCUP.gif" border="0" name="submit" style="position:relative; top:20px; left:20px;">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
Recently, I need to convert this button to QR code, as I would like to allow my customer to scan the QR code at my shop, and make payment on their mobile phone.
To simplify, there is only one product and the quantity will always be one , How to convert that?
Thanks a lot.
Make a new file like this:
<HTML><head><script>function SF(){document.getElementById('paypal_form').submit();}</script></head><body onload="SF();"><form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" id="paypal_form"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" id="order_button_id" value="123123abc"> <input type="hidden" name="quantity" id="order_quantity"> <input type="hidden" name="on0" value="Name"> <input type="hidden" name="os0" value="" id="post_name"> <input type="hidden" name="on1" value="Email"> <input type="hidden" name="os1" value="" id="post_email"> <input type="hidden" name="on2" value="Phone"> <input type="hidden" name="os2" value="" id="post_tel"> <input type="submit" value="Please click here if you are not redirected." border="0" style="position:relative; top:20px; left:20px;"> <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"> </form></body></HTML>
And make a QR code point to that.
I am using Minicart.JS for my simple paypal shopping cart. But this is not working as it should. The cart is not popping up if I click 'add to cart' button.
Here's my code.
<html>
<body>
<script src="//cdnjs.cloudflare.com/ajax/libs/minicart/3.0.3/minicart.min.js"></script>
<script>
paypal.minicart.render();
</script>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="labs-feedback-minicart#paypal.com" />
<input type="hidden" name="item_name" value="Test Product" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="amount" value="1.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="shipping2" value="1.50">
<input type="hidden" name="shipping" value="2.50">
<strong>Test Product</strong>
<p>
<label><input type="checkbox" id="terms" name="terms" value="" /> I agree to the terms</label>
</p>
<input type="submit" name="submit" value="Add to cart" />
</form>
<script>
paypal.minicart.render();
paypal.minicart.cart.on('checkout', function (evt) {
var hasAgreed = !!document.getElementById('terms').checked;
if (!hasAgreed) {
alert('You must agree to the terms!');
evt.preventDefault();
}
});
</script>
</body>
</html>
Here is the actual site. , I found an error in console that said:
Uncaught TypeError: Cannot call method 'appendChild' of null
I am not sure how to fix this, please let me know what's wrong with my setup. Thanks.
You need to change the Add to cart button to not be saved on PayPal (In Profit and loss Section) and also unprotect code after the button is created right before you copy and paste it :)
Hope this helps :)
I am trying to get a simple Terms and Conditions checkbox to validate before a user is allowed to click a paypal button. I currently have this code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="my email">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="15-minutes">
<input type="hidden" name="amount" value="15.00">
<input type="hidden" name="currency_code" value="USD">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"alt="stuff">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
Any help or guidance would be super helpful.
Festivus for the rest of us,
Tom
A little jQuery like this should do the trick: http://jsfiddle.net/mVK4r/
I added a terms and conditions checkbox and then tested to see if it's checked. If it is, the button behaves normally. If it is not, there's an alert prompting the user to accept the terms and the button won't work.
Hope this helps - good luck!
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Terms and Conditions check box -->
<p><input type="checkbox" id="terms"> Yes, I accept the terms and conditions</p>
<p> </p>
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="my email">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="15-minutes">
<input type="hidden" name="amount" value="15.00">
<input type="hidden" name="currency_code" value="USD">
<!-- Display the payment button. -->
<input type="image" id="button" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="stuff">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
<script type="text/javascript">
$(function(){
$('#button').click(function(e){
if ($('#terms').prop('checked') == false) {
alert('Please accept the terms and conditions');
e.preventDefault();
}
else {
// Allow the button the do its thing
}
});
});
</script>
Let's say we have this form:
<form>
<input type="text" name="some_name" value="val" id="some_name">
<input type="image" value="action" alt="Add To Cart" name="add" src="/images/submit.gif">
<input type="image" value="action" alt="Shop some more" name="return" src="/continue_shopping.gif">
</form>
How do I find the input that submitted the form?
You could add IDs to your different input items :
<input id="SomeName" type="text" name="some_name" value="val" id="some_name">
<input id="AddCart" type="image" value="action" alt="Add To Cart" name="add" src="/images/submit.gif">
<input id="Return" type="image" value="action" alt="Shop some more" name="return" src="/continue_shopping.gif" />
And then, in your jQuery, access the events with
$("#Return").click(function(){
//do your stuff
});