Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create an PayPal button with overwritable variables
    primarykey
    data
    text
    <p>Hello I would like to create a paypal buy button which has a dynamic set amount. I would like to pass the amount by a text input field within the form and the item_number by a hidden field. </p> <p>The issue is that what ever I do I get a encrypted s-xclick button from the paypal website. This button does not allow hidden variables being placed in the form. </p> <p>I think what I need is a xclick button. My goal is to allow users to increase their internally credit of my website. </p> <p>EDIT (moving the addition to the question from the answer to the question)(from here @tokam:</p> <p>To add this to the discussion I would like to show my current solution for the problem:</p> <p>Here we have some Javascript validation which helps the user with the input. Recognize that it opens a lightbox on success</p> <pre><code>function validatePaypalForm() { var val = $('#paypalPaymentAmount').val().replace(/\s*$/, "").replace(/,/ , ".").replace(/€$/, ""); var errormsg = ''; var ret, amountField; if( val==='' || isNaN( parseFloat(val) ) || !isFinite(val) ) { errormsg = 'Bitte geben Sie einen g&amp;uuml;ltigen Betrag an'; }else if( parseFloat( val ) &lt; &lt;?php echo $this-&gt;minimum?&gt; ) { errormsg = 'Das Einzahlungsminimum betr&amp;auml;gt &lt;?php echo $this-&gt;minimum?&gt;&amp;euro;'; } ret = ( errormsg === '' ); amountField = $( '#paypalAmountField' ); if( ret ) { amountField.removeClass( 'error' ); $('#paypalAmountErrorMessage').html( '&amp;nbsp;' ); $('#paypalPaymentAmount').val( val ); fb.start( '&lt;p&gt;&lt;strong&gt;Sie werden in kürze zur Seite von Paypal weitergeleitet.&lt;/strong&gt;&lt;/p&gt;', 'width:700 showPrint:false modal:true showClose:false showOuterClose:true showItemNumber:false closeOnNewWindow:false outsideClickCloses:true innerBorder:0 imageClickCloses:false scrolling: no' ); }else{ amountField.addClass( 'error' ); $('#paypalAmountErrorMessage').html( errormsg ); } return ret; </code></pre> <p>} Here comes my button now. The issues I am having with are e.g. that it is easy for the user to set an other currency code. I could handle this in my IPN Listener by refunding the payment. Are there other issues which come with an unencrypted changeable button?</p> <pre><code>&lt;form onsubmit="return validatePaypalForm();" class="stn-form" action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt; &lt;fieldset id="fieldset-p"&gt;&lt;legend&gt;&lt;span&gt;2.&lt;/span&gt;myproject Guthaben aufladen per Paypal Zahlung&lt;/legend&gt; &lt;div id='paypalAmountField' class="field"&gt; &lt;label for='paypalPaymentAmount' &gt;Betrag &amp;euro;:&lt;/label&gt; &lt;input id='paypalPaymentAmount' type="text" name='amount' value='' /&gt; &lt;span style='display:block;' id='paypalAmountErrorMessage' class='errorText'&gt;'&amp;nbsp;&lt;/span&gt; &lt;/div&gt; &lt;input type="hidden" name="cmd" value="_xclick"&gt; &lt;input type="hidden" name="business" value="THE_ID_OF_MY_CLIENT"&gt; &lt;input type="hidden" name="lc" value="DE"&gt; &lt;input type="hidden" name="item_name" value="myproject Advertiser Vorkasse"&gt; &lt;input type="hidden" name='item_number' value="11500"&gt; &lt;input type="hidden" name="currency_code" value="EUR"&gt; &lt;input type="hidden" name="button_subtype" value="services"&gt; &lt;input type="hidden" name="no_note" value="1"&gt; &lt;input type="hidden" name="no_shipping" value="1"&gt; &lt;input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynowCC_LG.gif:NonHosted"&gt; &lt;input type="hidden" name="rm" value="1"&gt; &lt;input type="hidden" name='cbt' value="Zu myproject.de zur&amp;uuml;ckkehren"&gt; &lt;input type="hidden" name="currency_code" value="EUR"&gt; &lt;input type="hidden" name="return" value="http://myproject.somedomain.net/advertiser/guthaben-aufladen/ret/success" /&gt; &lt;input type="hidden" name="cancel_ return" value="http://myproject.somedomain.net/advertiser/guthaben-aufladen/ret/canceled" /&gt; &lt;div class="actionrow"&gt; &lt;input type="image" src="https://www.paypalobjects.com/de_DE/DE/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="Jetzt einfach, schnell und sicher online bezahlen – mit PayPal."&gt; &lt;img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1"&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload