How to pass the user enter amount value to the paypal

懵懂的女人 提交于 2020-01-07 04:23:51

问题


Hi am having an issue with a website I am writing in php.I am trying to get Paypal to accept a user enter amount.but it not accepting while redirecting to paypal the amount is blank.is this possible or not.

This is my form

        <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target=_blank>
         <input type="hidden" name="cmd" value="_s-xclick">
         <input type="hidden" name="encrypted" value="<?PHP echo $encrypted; ?>">

         <div  class="paypal_list2">   
         <input type="hidden"><h3>Enter the amount</h3><br /> </div>
         <input id="total" class="paypal_input_1" type="text" value="" name="amount">

        <input class="paypal_btn" type="image"src="https://www.sandbox.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!">                                  
         </form> 

This my php code

        <?php

        $MY_KEY_FILE = "/home/khader/smsmobilebase/certs/private-key.pem";

        $MY_CERT_FILE = "/home/khader/smsmobilebase/certs/publi-cert.pem";

        $PAYPAL_CERT_FILE = "/home/khader/smsmobilebase/certs/paypal_cert_pem.txt";

         $OPENSSL = "/usr/bin/openssl";


         $form = array('cmd' => '_xclick','business' => 'roki_1347003608_biz@gmail.com','cert_id' => '6BPQP9KEEBCJ6','currency_code' => 'USD',
    'no_shipping' => '1',
    'item_name' => 'PayNow',


    'cancel_return' => 'http://mobiletool.xichlomobile.com/',
    'amount' => "'$amount'"
);

      $encrypted = paypal_encrypt($form);

     function paypal_encrypt($hash)
       {

global $MY_KEY_FILE;
global $MY_CERT_FILE;
global $PAYPAL_CERT_FILE;
global $OPENSSL;


if (!file_exists($MY_KEY_FILE)) {
    echo "ERROR: MY_KEY_FILE $MY_KEY_FILE not found\n";
}
if (!file_exists($MY_CERT_FILE)) {
    echo "ERROR: MY_CERT_FILE $MY_CERT_FILE not found\n";
}
if (!file_exists($PAYPAL_CERT_FILE)) {
    echo "ERROR: PAYPAL_CERT_FILE $PAYPAL_CERT_FILE not found\n";
}

$data = "";
foreach ($hash as $key => $value) {
    if ($value != "") {
        //echo "Adding to blob: $key=$value\n";
        $data .= "$key=$value\n";
    }
}

$openssl_cmd = "($OPENSSL smime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE " .
                    "-outform der -nodetach -binary <<_EOF_\n$data\n_EOF_\n) | " .
                    "$OPENSSL smime -encrypt -des3 -binary -outform pem $PAYPAL_CERT_FILE";

exec($openssl_cmd, $output, $error);

if (!$error) {
    return implode("\n",$output);

    print $hash;
} else {
    return "ERROR: encryption failed";
}
     }
   ?>   

回答1:


You just need to skip the amount field or it's value in your form.

<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="currency_code" value="USD">
<input type="hidden" name="item_name" value="Teddy Bear">
<input type="hidden" name="amount" value="">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

This will ask your user to enter amount!



来源:https://stackoverflow.com/questions/12721986/how-to-pass-the-user-enter-amount-value-to-the-paypal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!