PayPal how to set the subtotal attribute from the application - jsf-2

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.

Related

Using URL parameters for webforms that seem to be resistant to them?

I'm attempting to write a little script that, as part of it, would automatically complete a webform using data from a dictionary.
I've developed this script for other forms in the past with a pretty simple setup: the elements in the form are identified with a line like...
<input type="text" name="full_name" id="full_name_id" maxlength="80" value="">
<input type="text" name="title" id="title_id" maxlength="80" value="">
So, I'd navigate to www.theformsite.com/theform.php?full_name_id=David&title_id=Stuff and find those slots already filled in.
For a couple new forms I've been working with though, that doesn't seem to work: there's no response to these parameters. Are there any general things that could prevent this from working that I should check on?

Paypal select amount for Hosted Donation button in rails 4

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.

Use Eventbrite API to create ticket order on 3rd party website

Here's my flow - is this possible with eventbrite APIs? if yes, which ones specifically? I've tried looking through current listed apis and don't see how I can create the order and then pass it on to the eventbrite site for processing the order.
I am trying to find an API whereby I would pass-in discount code along with #of tickets and eventID from my website to eventbrite site. Is there a good example for this?
The workflow that I want to implement is:-
Step 1 On My Website, there is eventbrite Ticket Widget button along with Ticket Previews (http://developer.eventbrite.com/doc/widgets/#button) on the event page
Step 2: Clicks on Buy Tickets/Register/ buttons (from the widget)
Step 3: redirect to eventbrite website with eventID, user-elgible-discount-code, #of-tickets-selected-by-user
Step 4: eventbrite system processes the ticket order as specified in the api call (along with price/discount, qty, eventId, etc.) on eventbrite.com site
Any help appreciated.
Thanks,
Jatin
You can leave out the widget altogether and post directly to the EB checkout page.
For example:
<form action="http://www.eventbrite.co.uk/orderstart?ebtv=C" method="post">
<input type="hidden" name="eid" value="[EVENT_ID]">
<input type="text" name="quant_[TICKET_ID]_None" value="[QUANTITY]" />
<input type="text" name="discount" value="[DISCOUNT_CODE]" />
<input type="hidden" name="has_javascript" value="1">
<input type="submit" />
</form>
I wouldn't have thought this method is officially supported but it seems to work at the moment.

Rails will_paginate custom renderer manual page number

Hy
What i want to do is to create a custom renderer for will_paginate which renders first, previous, next and last page and a input field where the user can type in the page number manually. I already have the links for first, last etc. but i stuck at the input field. I could create a form in the view but the input field has to be rendered between the previous and next links.
Does anyone know how to do this?
Thanks for your help
You can do this as a separate form (make sure it is a GET). All you
need is the one input element named page. Something as simple as this
should work (not all browsers may like the #). I dropped it into a
site I'm playing with now and it worked. Put it anywhere on your page.
You might have to make something more complicated if you need to
incorporate search terms.
<form action="#" method="get">
Go to page: <input type="text" name="page" value="" size="2"
maxlength="4" />
<input type="submit" name="btnSubmit" />
</form>

How do I change the records being displayed on the page with buttons on the page (RoR)

I have a rails app that shows statistics based on an employee's daily production. currently my page shows ALL records.
I know how to show various different combinations such as records made between two dates etc... but what I really would like to do is make it so that single page (say the index page) has 3 controls that allow for it to switch between daily statistic records, weekly statistic records and a custom date constraint of statistic records (such as from date xx/xx/2009 to date xx/xx/2010). I have been searching for a while to attempt to figure this out but I am obviously missing something as I cannot find anyone else who has run into the same issues.
If this is too difficult to do this way, the other - mostly easy way I can see to do this is to create a page for each view, however it still leaves a question on how I set up the control to choose the custom date constraints.
I aplogise in advance for my newbyness but if someone could explain this to me, I think it is going to really increase my understanding of rails. Thanks in advance
Your control can easily append some information to the query string. Like this form does:
<form action="" method="get">
<fieldset>
<button type="submit" name="show" value="daily">Daily stats</button>
<button type="submit" name="show" value="weekly">Weekly stats</button>
</fieldset>
<fieldset>
From <input type="text" name="interval-start" value="" /> till
<input type="text" name="interval-end" value="" />
<button type="submit" name="show" value="interval">Stats for the specified interval</button>
</fieldset>
</form>
When user clicks on some button, browser sends all form fields to the server-side. On the server-side, in your action, you can check for the show property of the params array. Like this:
#reports = case params["show"]
when "daily"
#Just an example. Use ActiveRecord's query interface or Arel in Rails 3, not plain queries
Report.find_by_sql "SELECT * FROM reports WHERE DATE(report_date) = DATE(NOW())"
when "weekly"
Report.find_by_sql "SELECT * FROM reports WHERE WEEK(report_date) = WEEK(NOW())"
when "interval"
Report.find_by_sql "..."
else
#Some other possible values, filters, so on
end
And in your view just output the #report variable as usual.
You could also create a new route for that filtering, maybe /reports/:name, and avoid using forms. In this case, you only create some links that point to the right filter (/reports/daily, /reports/weekly, etc). On the server-side you need to check reports[:name] for the appropriate value.

Resources