Amount is not displaying in paypal form - forms

I am using the following paypal code but still the amount is not displayed in paypal form once the website redirect the page to paypal.
`<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXX">
<input type="hidden" name="amount_1" value="200">
<input type="image" style="width: 70px !important; padding: 0px !important;" src="http://www.merlioncricket.com/Login/static/images/payment.png" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>`
Please let me know, why the amount is not displaying.
Thanks,
Gladiator

Finally I found the answer, & maybe it is useful to others, whenever you create the paypal button make sure in step 2 "Save Button At PayPal" is not clicked & second once you create the button, remove code protection & then select the code & copy the paypal generated code.
It will solve the problem.
Thanks....

When using a hosted button, you can not pass over an amount. The hosted buttons, prevents someone from directly modifying the code and passing over a different amount. If you are wanting a different amount, you would need to log into your account and edit the hosted button. If you want to dynamically populate the amount, then you would need to create a non hosted clear text button.

Related

Paypal is not overriding the return URL?

I need to override the given default Auto return URL from the paypal button HTML code. I followed these steps:
Check the Auto return Url section and gave a default URL
Generate a Buy Now button and left the Return and Cancel URL options as it is.
Paste the button code
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="return" value="http://www.someURL.com"/>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="G3WQ*******">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
After successful payment on Sandbox PayPal is always redirecting me to the default URL.
Why isn't overriding it? Any help would be appreciable.
I saw a couple of similar unanswered question on PayPal community and StackOverflow as well:
https://www.paypal-community.com/t5/About-Payments-Archive/Auto-Return-Custom-URL-Not-Overriding-Auto-Return-Setting-URL/td-p/1038334
Paypal button auto-return url not overriding the default url
Setting PayPal return URL and making it auto return?
You won't be able to use the return field directly in the button when you're using a hosted button. That has to be set in the hosted button settings when creating the button (or editing it through the PayPal account.)
If you want to be able to set your own return URL on the fly then you'll have to use a non-hosted button.

paypal amount 0 on order summery page

Amount $0 on order summery page.
My Code for Buy Now Button is
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="AF">
<input type="hidden" name="amount" value="10.10">
<table>
<tr><td><input type="hidden" name="on0" value="License Option">License Option</td></tr><tr><td><select name="os0">
<option value="Single User">Single User </option>
<option value="Site License">Site License </option>
<option value="Global License">Global License </option>
</select> </td></tr>
</table>
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
It looks like you have modified the button, which is what's probably causing the issue. When using a hosted button, typically the amount doesn't appear in the code. This is one of the reasons behind the hosted button, it keeps a person from viewing the code and modifying the amount. If you added the line of code in there for the amount, after creating your button this is probably the issue. Either you need to set the amount when creating the button in your account if you are wanting to use a hosted button. Otherwise if you want to be able to edit the amount in the code, you need to create a non hosted, clear text button. This can be done by setting your button not to be hosted on step 2 of the button creation process. Then once the code is generated, it will be encrypted. You have to then select clear text/un-encrypted to generate the HTML code that you can edit.
If you are trying to create button in your PayPal account, please do not change the name and value fields generated there. All data are saved in PayPal system and could not be modified in code line. If you are trying to create a customized button, please refer to below page for its details.
https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/buynow_buttons/#id08A2G0920QN
https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/

Disable pay with credit card

I've got Buy Now Button:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="9HPJM3Z83ZCRS">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/i/btn/btn_buynow_LG.gif" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
But i dont want to let users pay with credit card, becouse i need to check their paypal email to prevent buying same thing twice. Is is possible?
Within your PayPal account profile there is an option "PayPal Account Optional" that you need to disable in order to force all buyers to use a PayPal account.
Depending on the version of PayPal you're on, it will be in Payment Receiving Preferences, Website Payment Preferences, or something like that. Just look around in your profile settings and you should be able to find it pretty easily.

Error Detected - Paypal

I can't understand why I get this annoying error message when I test out the paypal button in sandbox test site.
Error Detected
PayPal cannot process this transaction because of a problem with the seller's website. Please contact the seller directly to resolve this problem.
I've tried using different test accounts and I get the same thing.
Here are the codes for the paypal button:
echo 'form action="https://www.sandbox..../cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="FDN9DZRLVBQRL">
<input type="image" src="https://www.sandbox....scribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox....i/scr/pixel.gif" width="1" height="1">
</form>';
You're using a hosted button, so you need to make sure that it was created from (and still exists in) the account you're testing with.
If you're testing with the sandbox you need to create the button from that sandbox account in order for it to work.
Keep in mind that is only the case when working with hosted buttons.
Replace the form action with this:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
You are pointing to Sandbox endpoint, where the hosted button belongs to LIVE account.

How to make paypal button fields 'Required'?

i have created a pay now button using paypal button generator.
The button has 2 fields, and then you press pay now.
However, if you leave these fields empty, you can still pay
I want to make these fields "required", if a user didn't fill these fields, he should not be able to pay. How?
The button is not hosted on paypal, but the button protection is ON. I want the button to be encrypted.
EDIT
i tried javascript form validation, didn't work, any help?
here's the script
<form
action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<table>
<tr><td><input type="hidden" name="on0" value="first form">form 1</td></tr><tr><td><input type="text" name="os0" maxlength="200"></td></tr>
<tr><td><input type="hidden" name="on1" value="2nd form">2nd form</td></tr><tr><td><input type="text" name="os1" maxlength="200"></td></tr>
</table>
<input type="hidden" name="encrypted" value=" encryption here ">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" 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">
</form>
any help making these field required? I'll give you 3 up votes because i have 3 stackoverflow accounts and an accepted answer - that's the least i can do :)
PS
i couldn't make the form validation work, so i tried to hide the submit button unless the forms are filled, so far, that didn't work as well.
UPDATE - #Last Rose Studios
I tried many validation ways, finally i used my friend's contact form validation lol
validation.js
function has_id(id){try{var tmp=document.getElementById(id).value;}catch(e){return false;}
return true;}
function has_name(nm){try{var tmp=cfrm.nm.type;}catch(e){return false;}
return true;}
function $$(id){if(!has_id(id)&&!has_name(id)){alert("Field "+id+" does not exist!\n Form validation configuration error.");return false;}
if(has_id(id)){return document.getElementById(id).value;}else{return;}}
function $val(id){return document.getElementById(id);}
function trim(id){$val(id).value=$val(id).value.replace(/^\s+/,'').replace(/\s+$/,'');}
var required={field:[],add:function(name,type,mess){this.field[this.field.length]=[name,type,mess];},out:function(){return this.field;},clear:function(){this.field=[];}};var validate={check:function(cform){var error_message='Please fix the following errors:\n\n';var mess_part='';var to_focus='';var tmp=true;for(var i=0;i<required.field.length;i++){if(this.checkit(required.field[i][0],required.field[i][1],cform)){}else{error_message=error_message+required.field[i][2]+' must be supplied\n';if(has_id(required.field[i][0])&&to_focus.length===0){to_focus=required.field[i][0];}
tmp=false;}}
if(!tmp){alert(error_message);}
if(to_focus.length>0){document.getElementById(to_focus).focus();}
return tmp;},checkit:function(cvalue,ctype,cform){if(ctype=="NOT_EMPTY"){if(this.trim($$(cvalue)).length<1){return false;}else{return true;}}else if(ctype=="EMAIL"){exp=/^[a-zA-Z0-9._%-]+#[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;if($$(cvalue).match(exp)==null){return false;}else{return true;}}},trim:function(s){if(s.length>0){return s.replace(/^\s+/,'').replace(/\s+$/,'');}else{return s;}}};
paypal.html
<script src="validation.js"></script>
<script>
required.add('os0','NOT_EMPTY','1st form');
required.add('os1','NOT_EMPTY','2nd form')
</script>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="return validate.check(this)">
<input type="hidden" name="cmd" value="_s-xclick">
<table>
<tr><td><input type="hidden" name="on0" value="1st form">1st form<span class="required_star"> * </span></td></tr><tr><td><input type="text" name="os0" maxlength="200" id="os0" class="required"></td></tr>
<tr><td><input type="hidden" name="on1" value="2nd form">2nd form<span class="required_star"> * </span></td></tr><tr><td><input type="text" id="os1" name="os1" maxlength="200" class="required"></td></tr>
</table>
<input type="hidden" name="encrypted" value=" encryption here
">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" 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">
</form>
I have used JavaScript, and then i read your answer, but i'm not gonna change because it works now
i still have 2 small questions
1- is it possible to remove the description box from paypal page see this
2- paypal is not redirecting to the thank you page after the payment is done, i created many button, it's just not redirecting (i don't have a cancel page)
you could use the html5 input attribute 'required', and that would take care of some browsers, for the others you would have to use javascript to validate the form.
I'll use jQuery if you don't mind to give you a quick example.
$('form').submit(function(e){
flag = false;
$('[name="os0"], [name="os1"]').css('background','').each(function(){
el=$(this);
if(el.val().length == 0){
flag = true;
el.css('background','red');
}
});
if(flag){
return false;
}
});
this will prevent the form from being submitted unless both fields are filled out. I also added some feedback for the user by turning the background of the input red (optional).
Of course this will only work in modern browsers or older browsers with javascript enabled, there will still be a small percentage where it will pass through. In this case Robert's suggestion that you post to an in between page on your server might be a good idea.
Without modifying the button code, you'd need a client-side solution (like you mentioned), since the POST will go directly to PayPal (https://www.paypal.com/cgi-bin/webscr).
Alternatively, you could submit the POST to an inbetween page on your server, and forward from PayPal there on, in order to include a server-side check as well (only if the fields are absolutely required, in case JavaScript is disabled, for example).