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

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.

Related

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.

Multiple variables with the same name in POST request

I was working on a webbot and I came across this strange page where multiple variables had the same name but different values in as shown by the Firefox web console. I am not sure as to how I can replicate this behavior in python. Currently, I am using the requests library to make post requests and that takes in a dictionary of name and value pairs. And of course, dictionaries have unique keys. So I was wondering if anyone could tell me how to send post requests with multiple variables carrying the same name.
sel_subj:dummy
sel_subj:ECE
Thanks,
Rajiv
Edit: Here is the html source that causes this
<input type="hidden" value="dummy" name="rsts"></input>
<input type="hidden" value="dummy" name="crn"></input><br></br>
<input type="hidden" value="120138" name="term_in"></input>
**<input type="hidden" value="dummy" name="sel_subj"></input>**
<input type="hidden" value="dummy" name="sel_day"></input>
<input type="hidden" value="dummy" name="sel_schd"></input>
<input type="hidden" value="dummy" name="sel_insm"></input>
<input type="hidden" value="dummy" name="sel_camp"></input>
<input type="hidden" value="dummy" name="sel_levl"></input>
<input type="hidden" value="dummy" name="sel_sess"></input>
<input type="hidden" value="dummy" name="sel_instr"></input>
<input type="hidden" value="dummy" name="sel_ptrm"></input>
<input type="hidden" value="dummy" name="sel_attr"></input>
<table class="dataentrytable" summary="Table is used to present the course search criteria">
<tbody>
<tr>
<td class="delabel" scope="row"> … </td>
<td class="dedefault" colspan="37">
**<select id="subj_id" multiple="" size="10" name="sel_subj"> …
</select>**
</td>
</tr>
</tbody>
</table>
Notice how the select tag and the highlighted input tag have the same name.
The only method that I know is using a variable-name appended with [].
<input type="hidden" value="dummy" name="sel_subj[]"></input>
<input type="hidden" value="ECE" name="sel_subj[]"></input>
This results in an array placed in $_POST['sel_subj'], with $_POST['sel_subj'][0] being "dummy" and $_POST['sel_subj'] being ECE.
Now as I think of it, I think the creation of the array is done by the php-parser when there is a [] attached. This suggests that both values are send through the POST even if there is not [] at the end of the name. Maybe PHP can be configured not to dismiss this values.
In case of GET variables (in the url), you can have multiple values with the same name. You can just parse the entire url and read and use every value.
PHP even solves this automatically if you add [] to the name of the parameter. In that case, it automatically changes it into an array. But this is a trick as well. It is fairly easy to write a piece of code that does the same thing with duplicate names without them having [] as a postfix.
They same will happen post variables as well. You just might need a little more code to read them properly.
The code in this case probably checks if there is sel_subj with any value other than dummy. If that is the case, then that value is used. If it doesn't exists, sel_subj may still exist with the value dummy. That is probably an indication for the script that the form was posted, but no value was selected.
So actually, I think it's quite easy to explain how this script works, and probably even why, but I don't think it's a very good solution to put all defaults in hidden fields this way, so I would suggest you don't try to replicate this solution. :-)

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.

Simple site search with Duckduckgo

I would like to add simple site search, using Duckduckgo, limited to search only "example.com".
Stackoverflow has solved this, using some JavaScript to add the site:example.com filter to the query.
<form onsubmit="var txt=$(this).find('input[name=\'q\']'); txt.val(txt.val() + ' site:stackoverflow.com');" action="http://www.duckduckgo.com/" method="get" id="duck-duck-go-search">
<input type="text" value="" maxlength="255" size="36" name="q">
<input type="submit" value="DuckDuckGo">
</form>
I'd prefer a solution that does not depend on JavaScript, though.
The URL should be http://duckduckgo.com/?q=site:example.com%20might; the site:example.com must be added to the q= parameter, it seems.
Has anyone found a simple, non JavaScript solution for this?
I contacted DuckduckGo and got a solution from Weinberg himself.
There actually is a hidden sites param :). Try it!
Gabriel, http://ye.gg
It was the plural (not site, but sites) that got me confused, but the solution is very simple:
http://duckduckgo.com/?q=duckduckgo& sites= stackoverflow.com
Or, in a simple HTML form:
<form action="https://duckduckgo.com/" method="get">
<input type="hidden" name="sites" value="stackoverflow.com">
<input type="search" name="q">
<input type="submit" value="Search">
</form>

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>

Resources