doutou3725 2014-11-29 18:41
浏览 54

Paypal快递结账多项

I am trying to get multiple items into the Express Checkout. I tried all kind of changes, but only the first item ('product name 1') appears in paypal with the amount 35$. How can i fix this to work with multiple items ? The code is this:

<form action="paypal_ec_redirect.php" method="POST">
<input type="hidden" name="L_PAYMENTREQUEST_0_NAME0" value="product name 1"></input>
<input type="hidden" name="L_PAYMENTREQUEST_0_DESC0" value="this is the product description"></input>
<input type="hidden" name="L_PAYMENTREQUEST_0_AMT0" value="10.00"></input>
<input type="hidden" name="L_PAYMENTREQUEST_0_NUMBER0" value="1"></input>
<input type="hidden" name="L_PAYMENTREQUEST_0_QTY0" value="1"></input>

<input type="hidden" name="L_PAYMENTREQUEST_0_NAME1" value="product name 2"></input>
<input type="hidden" name="L_PAYMENTREQUEST_0_DESC1" value="this is the product description"></input>
<input type="hidden" name="L_PAYMENTREQUEST_0_AMT1" value="25.00"></input>
<input type="hidden" name="L_PAYMENTREQUEST_0_NUMBER1" value="2"></input>
<input type="hidden" name="L_PAYMENTREQUEST_0_QTY1" value="1"></input>

<input type="hidden" name="PAYMENTREQUEST_0_ITEMAMT" value="35.00"></input>
<input type="hidden" name="PAYMENTREQUEST_0_AMT" value="35.00"></input>
<input type="hidden" name="currencyCodeType" value="USD"></input>
<input type="hidden" name="paymentType" value="Sale"></input>
<!--Pass additional input parameters based on your shopping cart. For complete list of all the parameters click here -->
<input type="image" src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-large.png" alt="PayPal Credit"></input>
</form>
  • 写回答

1条回答 默认 最新

  • duanmeng2842 2015-09-03 13:06
    关注

    I had the same problem.

    Their code in the demo only manually checks for one item with isset() in their CallShortcutExpressCheckout function in the paypal_functions.php file and it also changes the sum of the individual item it checks for to the total sum of all items in the paypal_ec_redirect.php, which is why it appears in your paypal with the amount 35$ for the one item it shows you.

    You can change their code in the CallShortcutExpressCheckout function to use a foreach loop to loop through the post data instead manually checking for isset() on their predetermined parameters.

    also you need to comment out where it changes the value of the of the product item amount to the total amount of all products.

    Change the CallShortcutExpressCheckout in paypal_functions.php function from this:

    function CallShortcutExpressCheckout( $paramsArray, $returnURL, $cancelURL) 
    {
        //------------------------------------------------------------------------------------------------------------------------------------
        // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
        // For more information on the customizing the parameters passed refer: https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/
    
        //Mandatory parameters for SetExpressCheckout API call
        if(isset($paramsArray["PAYMENTREQUEST_0_AMT"])){
            $nvpstr = "&PAYMENTREQUEST_0_AMT=". $paramsArray["PAYMENTREQUEST_0_AMT"];
            $_SESSION["Payment_Amount"]= $paramsArray["PAYMENTREQUEST_0_AMT"];
        }
    
        if(isset($paramsArray["paymentType"])){
            $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" .  $paramsArray["paymentType"];
            $_SESSION["PaymentType"] = $paramsArray["paymentType"];
        }
    
        if(isset($returnURL))
        $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
    
        if(isset($cancelURL))
        $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
    
        //Optional parameters for SetExpressCheckout API call
        if(isset($paramsArray["currencyCodeType"])) {
            $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $paramsArray["currencyCodeType"];
            $_SESSION["currencyCodeType"] = $paramsArray["currencyCodeType"];   
        } 
    
        if(isset($paramsArray["PAYMENTREQUEST_0_ITEMAMT"])){
            $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_ITEMAMT=" . $paramsArray["PAYMENTREQUEST_0_ITEMAMT"];
            $_SESSION['itemAmt']= $paramsArray["PAYMENTREQUEST_0_ITEMAMT"];
        }
    
        if(isset($paramsArray["PAYMENTREQUEST_0_TAXAMT"])){
            $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_TAXAMT=" . $paramsArray["PAYMENTREQUEST_0_TAXAMT"];
            $_SESSION['taxAmt']= $paramsArray["PAYMENTREQUEST_0_TAXAMT"];
        }
    
        if(isset($paramsArray["PAYMENTREQUEST_0_SHIPPINGAMT"])){
            $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPPINGAMT=" . $paramsArray["PAYMENTREQUEST_0_SHIPPINGAMT"];
            $_SESSION['shippingAmt'] = $paramsArray["PAYMENTREQUEST_0_SHIPPINGAMT"];
        }
    
        if(isset($paramsArray["PAYMENTREQUEST_0_HANDLINGAMT"])){
            $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_HANDLINGAMT=" . $paramsArray["PAYMENTREQUEST_0_HANDLINGAMT"];
            $_SESSION['handlingAmt'] = $paramsArray["PAYMENTREQUEST_0_HANDLINGAMT"];
        }
    
        if(isset($paramsArray["PAYMENTREQUEST_0_SHIPDISCAMT"])){
            $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPDISCAMT=" . $paramsArray["PAYMENTREQUEST_0_SHIPDISCAMT"];
            $_SESSION['shippingDiscAmt'] = $paramsArray["PAYMENTREQUEST_0_SHIPDISCAMT"];
        }
    
        if(isset($paramsArray["PAYMENTREQUEST_0_INSURANCEAMT"])){
            $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_INSURANCEAMT=" . $paramsArray["PAYMENTREQUEST_0_INSURANCEAMT"];
            $_SESSION['insuranceAmt'] = $paramsArray["PAYMENTREQUEST_0_INSURANCEAMT"];
        }
    
        if(isset($paramsArray["L_PAYMENTREQUEST_0_NAME0"]))
        $nvpstr = $nvpstr . "&L_PAYMENTREQUEST_0_NAME0=" . $paramsArray["L_PAYMENTREQUEST_0_NAME0"];
    
        if(isset($paramsArray["L_PAYMENTREQUEST_0_NUMBER0"]))
        $nvpstr = $nvpstr . "&L_PAYMENTREQUEST_0_NUMBER0=" . $paramsArray["L_PAYMENTREQUEST_0_NUMBER0"];
    
        if(isset($paramsArray["L_PAYMENTREQUEST_0_DESC0"]))
        $nvpstr = $nvpstr . "&L_PAYMENTREQUEST_0_DESC0=" . $paramsArray["L_PAYMENTREQUEST_0_DESC0"];
    
        if(isset($paramsArray["L_PAYMENTREQUEST_0_AMT0"]))
        $nvpstr = $nvpstr . "&L_PAYMENTREQUEST_0_AMT0=" . $paramsArray["L_PAYMENTREQUEST_0_AMT0"];
    
        if(isset($paramsArray["L_PAYMENTREQUEST_0_QTY0"]))
        $nvpstr = $nvpstr . "&L_PAYMENTREQUEST_0_QTY0=" . $paramsArray["L_PAYMENTREQUEST_0_QTY0"];
    
        if(isset($paramsArray["LOGOIMG"]))
        $nvpstr = $nvpstr . "&LOGOIMG=". $paramsArray["LOGOIMG"];
    
        /*
        * Make the API call to PayPal
        * If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.  
        * If an error occured, show the resulting errors
        */
        $resArray=hash_call("SetExpressCheckout", $nvpstr); 
        $ack = strtoupper($resArray["ACK"]);
        if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
        {
            $token = urldecode($resArray["TOKEN"]);
            $_SESSION['TOKEN']=$token;
        }
        return $resArray;
    }
    

    to this:

    function CallShortcutExpressCheckout( $paramsArray, $returnURL, $cancelURL) 
    {
        //------------------------------------------------------------------------------------------------------------------------------------
        // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
        // For more information on the customizing the parameters passed refer: https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/
    
        //Mandatory parameters for SetExpressCheckout API call
    
        if(isset($returnURL))
        $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
    
        if(isset($cancelURL))
        $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
    
        foreach ($paramsArray as $k => $value){
            $nvpstr = $nvpstr . "&" . $k . "=" . $value;
        }
    
        /*
        * Make the API call to PayPal
        * If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.  
        * If an error occured, show the resulting errors
        */
        $resArray=hash_call("SetExpressCheckout", $nvpstr); 
        $ack = strtoupper($resArray["ACK"]);
        if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
        {
            $token = urldecode($resArray["TOKEN"]);
            $_SESSION['TOKEN']=$token;
        }
        return $resArray;
    }
    

    and then just comment out this line on the paypal_ec_redirect.php:

    //$_POST["L_PAYMENTREQUEST_0_AMT0"] = $_POST["PAYMENTREQUEST_0_ITEMAMT"]; 
    

    Late answer, but i hope this helps someone :-)

    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了