表单包含加密的Paypal按钮。我想将值/价格变量传递给paypal.i不要如何做到这一点。
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="LMFWRYRBURU2J">
<input type="hidden"><h3>Amount of messages </h3> <br /> </div>
<input class="paypal_input" type="" name="message" id="message" onkeyup="doMath()" maxlength="60"> <br />
</p>
<div class="paypal_list2">
<p>
<input type="hidden"><h3>Total amount</h3><br /> </div>
<input id="total" class="paypal_input_1" type="text" value="" name="amount" readonly>
<input type="image" src="https://www.sandbox.paypal.com/en_US/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_US/i/scr/pixel.gif" width="1" height="1">
</form>
我想通过加密按钮将这个可变金额传递给paypal
我试过这个
<input type='hidden' name='amount' value='<?php echo $_POST['total'];?>'>
它没有花费金额.tote_price空白在paypal中。任何人都可以帮助我如何做到这一点。
答案 0 :(得分:1)
hidden
id = OrderID
value = 12345
&gt; function submitToPayPal(formAction){ var formElementsArray = document.getElementsByTagName('FORM’); if ( formElementsArray != null ) { var formElement = formElementsArray[0]; document.getElementById('total_amount’).value = ''; document.getElementById('__VIEWSTATE’).name = 'NOVIEWSTATE'; formElement.action = formAction; formElement.submit(); } }
如果您使用PHP脚本,请使用以下内容。
/*The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable.*/ $querystring .= "item_name=".urlencode($item_name)."&"; $querystring .= "amount=".urlencode($item_amount)."&";。/*loop for posted values and append to querystring*/ foreach($_POST as $key => $value){ $value = urlencode(stripslashes($value)); $querystring .= "$key=$value&"; } /* Append paypal return addresses*/ $querystring .= "return=".urlencode(stripslashes($return_url))."&"; $querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&"; $querystring .= "notify_url=".urlencode($notify_url); /* Append querystring with custom field //$querystring .= "&custom=".USERID; */ /* Redirect to paypal IPN*/ header("location:https://www.sandbox.paypal.com/cgi-bin/webscr".$querystring); exit();