我正在尝试将多个项目放入Express Checkout。我尝试了所有类型的更改,但只有第一项('产品名称1')出现在paypal中,金额为35 $。如何修复此问题以处理多个项目?代码是这样的:
<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>
答案 0 :(得分:0)
我遇到了同样的问题。
他们在演示中的代码只在paypal_functions.php文件的CallShortcutExpressCheckout函数中手动检查带有 isset()的项目,并且它还将它检查的单个项目的总和更改为paypal_ec_redirect.php中所有项目的总和,这就是为什么它出现在您的PayPal中,其中显示的一个项目金额为35 $。
您可以在CallShortcutExpressCheckout函数中更改其代码,以使用foreach循环遍历post数据,而不是手动检查其预定参数上的isset()。
您还需要注释掉它将产品项目金额的值更改为所有产品的总金额。
更改paypal_functions.php函数中的 CallShortcutExpressCheckout :
CellValue cellValue = evaluator.evaluate(cell);
int cellValueType = cellValue.getCellType();
if(cellValueType == Cell.CELL_TYPE_NUMERIC){
if(myIsADateFormat(cell){
....
}
}
到此:
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;
}
然后在paypal_ec_redirect.php上注释掉这一行:
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;
}
迟到的答案,但我希望这有助于某人: - )