Paypal select amount for Hosted Donation button in rails 4 - ruby-on-rails

I am working on rails 4 application. I need to give payment options for Donation button.
I need to create radiobutton as well as textbox to enter amount of payment for Donation.
My code 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="xxxxxxxxxxx">
<input type="hidden" name="amount" value="">
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_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>
Here I enter value of amount field by jQuery (code is not posted) so it is not empty ("").
But on the second step the amount I submit in hidden field is not shown.
I google it some people say one can not enter amount on hosted button means it would be fixed every time.
Some people say create the buy now button reference => https://www.paypal.com/webapps/mpp/get-started/donate-button-text-field
What should I do is it possible with hosted button?
Should I change my code ?

Whenever you use the PayPal hosted buttons you can't change the amount related information. Hosted buttons are secure in the terms that nobody can fiddle with the amount. Changes to the amount for hosted buttons can only be done thru account or via API's . If you are implementing a solution where you need to change the amount dynamically you should consider using the clear text button or You can dynamically generate the encrypted using the API's
However the variables related to :address ,cancel/return/image/ipn url ,item name/invoice id/custom/quantity can be overridden by passing the variables for hosted buttons.

Related

How to retain state in MVC

I have an asp.net mvc5 web application which has 5 pages. The information on the last three pages are passed from the first two. So it’s like my first two pages are dynamic and last three changes according to the first two.
My program is only doing the following thing
I fill information in first page, hit submit button via post request, fill information in second page and hit submit button from second page. The rest pages display the result only.
But the problem arises when I press back button from browser form second page, change some value in first page and press submit button, I lose all the data from the second page. I want the second page retain its state whatever it was before.
I really don’t know how hard it is. So can some please advise me how to resolve that problem?
Thanks in advance.Here is just Sample code to illustrate This is the second page
<form action="thirdpage.cshtml" method="post">
MARKET VALUE OF HOUSE 2nd page:
<input id="MVOH" type="number" step="any" name="MVH" /><br/><br/>
MORTGAGE OWING 2nd page:
<input id="MO" type="number" step="any" name="MOwing" /><br/><br/>
MORTGAGE REPAYMENT 2nd page
<input id="MPPM" type="number" name="MP" />
<select id="Sel">
<option value="0">Per week</option>
<option value="1">Per fortnight</option>
<option value="2">Per Month</option>
</select><br/><br/>
<div>
<input id="next" type="submit" value="Income Expenses »"/>
</div>
</form>
And the first page is
<form action="secondpage.cshtml" method="post">
MARKET VALUE OF HOUSE:
<input id="MVOH" type="number" step="any" name="MVH" /><br/><br/>
MORTGAGE OWING:
<input id="MO" type="number" step="any" name="MOwing" /><br/><br/>
<td>MORTGAGE REPAYMENT</td>
<td>
<input id="MPPM" type="number" name="MP" />
<select id="Sel">
<option value="0">Per week</option>
<option value="1">Per fortnight</option>
<option value="2">Per Month</option>
</select><br/><br/>
<div>
<input id="next" type="submit" value="Income Expenses »"/>
</div>
</form>
Please I have provided only a part of code because my page is so big.
The only way to do this is to transfer the changes real time to the server, in the keypress/ change events. You could use an ajax call for this.
After the user navigates to this second page for the second time, you can fill the values he enters earlier
Firstly If you are dealing with ASP.NET MVC, I would strongly recommend you to use HTML Helpers to create your view like HTML.TextBox() or HTML.Label() etc, and bind these elements with your model so that at every request the values will be updated as per the type of Request GET / POST.
Secondly Pressing browser's back/forward button shows you the last cached page, due to which the values may be obsolete, I suggest you to have your own next previous button and initiate get request for the same.
In case you are troubled by the browser's button, you can check the page referrer accordingly and have that check at every post request

Remove saved Usernames and passwords of browser from web application

In my web application I want to remove the username,password which are automatically stored by browser on click of remember me.
I know this is browser property but is there anyway to remove this on loading of my website and clearing all saved username,password of my website..
Thanks & Regards...
Best way I've found of doing it thusfar, is faking the browser into thinking there are multiple username/password fields on the form. The browser's save username/password generally look for the first password field and the field previous to it for the username, so I have added new fields to the page in a hidden div, outside of my form to resolve the problem
<div style="display:none;">
<input type="text" id="fake_username"/>
<input type="password" id="fake_password"/>
</div>
<form action="..." method="POST">
<input type="text" id="username"/>
<input type="password" id="password"/>
<input type="submit" value="Submit"/>
</form>
I also generally add the autocomplete="off" to my form and input elements, either directly or via a jquery script (below) on document.ready
$(document).ready(function() { $("input").attr("autocomplete", "off") });
I think this is not possible to remove saved passwords but you can prevent saving by
<form id="login" action="loginURL" method="post" autocomplete="off">
Modern browsers implement integrated password management: when the user enters a username and password for a site, the browser offers to remember it for the user. When the user visits the site again, the browser autofills the login fields with the stored values.
Additionally, the browser enables the user to choose a master password that the browser will use to encrypt stored login details.
Even without a master password, in-browser password management is generally seen as a net gain for security. Since users do not have to remember passwords that the browser stores for them, they are able to choose stronger passwords than they would otherwise.
For this reason, many modern browsers do not support autocomplete="off" for login fields:
If a site sets autocomplete="off" for a form, and the form includes username and password input fields, then the browser will still offer to remember this login, and if the user agrees, the browser will autofill those fields the next time the user visits the page.
If a site sets autocomplete="off" for username and password input fields, then the browser will still offer to remember this login, and if the user agrees, the browser will autofill those fields the next time the user visits the page.
This is the behavior in Firefox (since version 38), Google Chrome (since 34), and Internet Explorer (since version 11).
If an author would like to prevent the autofilling of password fields in user management pages where a user can specify a new password for someone other than themself, autocomplete="new-password" should be specified, though support for this has not been implemented in all browsers yet.
Try This,
<input type="hidden" id="hiddenUsername" name="username"/>
<input type="hidden" id="hiddenPassword" name="password"/>
<form id="theForm" action="/your/login" method="post" autocomplete="off">
<input type="text" id="username" name="username"/>
<input type="password" id="password" name="password"/>
<input type="submit" value="Login"/>
</form>
<script type="text/javascript" language="JavaScript">
$("#theForm").submit(function() {
$("#hiddenUsername").val($("#username").val());
$("#hiddenPassword").val($("#password").val());
});
</script>
Demo, Will work as you want(Note: just to check how it's working with hiddenfields)

PayPal how to set the subtotal attribute from the application

I'm developing a web application based on JSF 2.0. The application automatically generates a quote to sell a service so, the subtotal it's not predictable.
I would like to integrate PayPal Payments but I need to set the subtotal value in a dynamic way. I succeeded in doing payments of a fixed amount through the payPal sandbox using the standard integration of the HTML button. I also tried to add to the form that contains the generated button the subtotal value but it doesn't seem to work.
Something like:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick"></input>
<input type="hidden" name="hosted_button_id" value="3V8S6DNHUQ58C"></input>
<input type="hidden" name="subtotal" value="88"> </input>
<input type="image"
src="https://www.sandbox.paypal.com/it_IT/IT/i/btn/btn_buynow_LG.gif"
name="submit"
alt="PayPal - Il metodo rapido, affidabile e innovativo per pagare e farsi pagare."></input>
<img alt="" border="0"
src="https://www.sandbox.paypal.com/it_IT/i/scr/pixel.gif" width="1"
height="1"></img>
</form>
Is there a way to set subtotal value from the application with HTML standard integration, preferentially getting the value from a bean property?
Do I have to use a more advanced way for the integration? Thanks for help, as usual.. :)
The button you're currently using is a hosted button. As such, you cannot dynamically adjust it the way you want to.
You would have to edit your button and disable the "save at PayPal" option in order to make it a non-hosted button. This way you would have direct access to the actual request parameters and you could adjust their values accordingly.
That said, it's not very secure because then users can see your button code, copy it, and adjust it before making a payment with it.
I would recommend you use the Express Checkout API instead. This consists of SetExpressCheckout, GetExpressCheckoutDetails, and DoExpresscheckoutPayment. This is a little bit more involved because you're working with web services, but it opens you up to customize it however you need and is secure.

Is there a way to create a PayPal donation link (as opposed to a button)?

I've looked all over paypal's website and can't find any info on creating a simple text link for a donation.
Anyone have any info?
According to this link, you can use HTTP GET, meaning you can build a URL for a simple link.
Note that this link is written in C#, so you can't actually use this as code reference.
You'll probably need something like
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=email#myserver.com&item_name=...">
Make sure to use '&' to separate fields and to encode them properly if they include special characters (such as '&').
Updating the button code from paypal:
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="me#mybusiness.com">
<input type="hidden" name="item_name" value="Team In Training">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="25.00">
Donate
</form>

sending to paypal the "custom" variable on saved buttons ipn question

i have quick question, i'm setting up recurring subscriptions for paypal and i can't configure but saved buttons, (not like web_accept where i could define all the vars in the form to send...) so it results a form like this:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="KN7ACTU8MVZNE">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
so basicaly that identifies a saved button and proceses my request...
now i wish to identify one ID from my cart DB say 1122 send it to paypal and receive it on the postback, on the normal web payments standard i would of send something like:
<input type="hidden" name="custom" value="1122">
and i would of get a ipn notification with that custom var...
Is it still availabe in the subscr_signup version? with saved buttons?
Yes, except in this case, you can stuff information into the profile_reference field. Actually, I'm not 100% sure that I'm correct, but I figured I'd answer just in case to point you in the right direction.

Resources