PHP Paypal快递10413

时间:2015-03-31 08:50:37

标签: php paypal

我在我的网站上使用Paypal Express Checkout并收到此错误:

SetExpressCheckout API call failed. Detailed Error Message: The totals of the cart item amounts do not match order amounts.Short Error Message: Transaction refused because of an invalid argument. See additional error messages for details.Error Code: 10413Error Severity Code: Error

当我输入1的数量时,一切正常,但当我输入2或更多时,我得到错误。

我正在使用SMARTY Templating。

            <form class="pull-right" action="../Checkout/paypal_ec_redirect.php" method="POST">
            <input type="hidden" name="L_PAYMENTREQUEST_0_NAME0" value="{$product_naam}"></input>
                <input type="hidden" name="L_PAYMENTREQUEST_0_AMT0" value="{$product_productprijs}"></input>
                <input type="hidden" name="L_PAYMENTREQUEST_0_QTY0" value="{$product_aantal}"></input>

                <input type="hidden" name="PAYMENTREQUEST_0_ITEMAMT" value="{$product_subtotaal}"></input>
                <input type="hidden" name="PAYMENTREQUEST_0_TAXAMT" value="{$product_btw}"></input>
                <input type="hidden" name="PAYMENTREQUEST_0_AMT" value="{$product_totaalprijs}"></input>
                <input type="hidden" name="currencyCodeType" value="EUR"></input>
                <input type="hidden" name="paymentType" value="Sale"></input>

                <input type="image" src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-large.png" alt="Check out with PayPal"></input>
            </form>
        </div>
    </div>
</div>

这是PHP:

foreach ($getproduct as $row) {
    $productaantal = $aantalbesteld;
    $productnaam = $row['naam'];
    $productprijs = $row['prijs'];
    $btwtarief = $row['btw_tarief'];
    $btwbedrag = ($productprijs*$aantalbesteld)/100*$btwtarief;
    $subtotaal = ($productprijs*$aantalbesteld)-$btwbedrag;
    $totaalprijs = $productprijs*$aantalbesteld;
}


//Product
$smarty->assign('product_naam', $productnaam);
$smarty->assign('product_aantal', $productaantal);
$smarty->assign('product_prijs', money_format('%.2n', $productprijs));
$smarty->assign('product_subtotaal', money_format('%.2n', $subtotaal));
$smarty->assign('product_btw', money_format('%.2n', $btwbedrag));
$smarty->assign('product_totaalprijs', money_format('%.2n', $totaalprijs));
$smarty->assign('product_bestelknop', 'Bestellen');

编辑:即使这不起作用:

            <form class="pull-right" action="../Checkout/paypal_ec_redirect.php" method="POST">
                <input type="hidden" name="L_PAYMENTREQUEST_0_NAME0" value="{$product_naam}"></input>
                <input type="hidden" name="L_PAYMENTREQUEST_0_AMT0" value="5.00"></input>
                <input type="hidden" name="L_PAYMENTREQUEST_0_QTY0" value="2"></input>

                <input type="hidden" name="PAYMENTREQUEST_0_ITEMAMT" value="10.00"></input>
                <input type="hidden" name="PAYMENTREQUEST_0_TAXAMT" value="2.10"></input>
                <input type="hidden" name="PAYMENTREQUEST_0_AMT" value="12.10"></input>
                <input type="hidden" name="currencyCodeType" value="EUR"></input>
                <input type="hidden" name="paymentType" value="Sale"></input>

                <input type="image" src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-large.png" alt="Check out with PayPal"></input>
            </form>

2 个答案:

答案 0 :(得分:0)

它表示当它们乘以数量和数量时,它不会加起来指定为totalamount

$btwbedrag = ($productprijs*$aantalbesteld)/100*$btwtarief;
$subtotaal = ($productprijs*$aantalbesteld)-$btwbedrag;
$totaalprijs = $productprijs*$aantalbesteld;

您的增值税的计算方法是将总价格金额的1%乘以增值税税率。这假设您的产品金额是专属增值税。

然后在下一行中从$subtotaal中删除增值税,为什么?它首先没有被包括在内。或者如果它是那么你应该除以121而不是100。

$totaalprijs似乎是在假设已包含增值税的情况下计算的。

您是否检查了网页来源中隐藏字段的值?

答案 1 :(得分:0)

当我将数量更改为2时,这是发送给PayPal的请求。

paymentrequest_0_currencycode   "EUR"
paymentrequest_0_amt    "89.90"
paymentrequest_0_itemamt    "71.02"
paymentrequest_0_taxamt "18.88"
paymentrequest_0_paymentaction  "Sale"
paymentrequest_0_name   "Sweaters van Superdry"
paymentrequest_0_qty    "2"

理想情况下,请求应该是这样的:

paymentrequest_0_itemamt=71.02
paymentrequest_0_taxamt=18.88
paymentrequest_0_amt=89.90


L_PAYMENTREQUEST_0_NAME0 = Sweaters van Superdry
L_PAYMENTREQUEST_0_AMT0= 35.51  
L_PAYMENTREQUEST_0_QTY0= 2

这导致了问题。

没有paymentrequest_0_qty参数。

你可以在这里测试一下:

https://api-3t.sandbox.paypal.com/nvp?&user=us-30_api1.cri.com&pwd=EYFNSNUSV85CT34Z&signature=AH57zE.nAaElaFFAysViNA9TIte1AxtSpBjx2HLqHJOiu2js3l1Kd48i&version=70.0&METHOD=SetExpressCheckout&RETURNURL=http://www.paypal.com/test.php&CANCELURL=http://www.paypal.com/test.php&PAYMENTACTION=Sale&paymentrequest_0_itemamt=71.02&paymentrequest_0_taxamt=18.88&paymentrequest_0_amt=89.90&L_PAYMENTREQUEST_0_NAME0=Sweateranuperdry&L_PAYMENTREQUEST_0_AMT0=35.51&L_PAYMENTREQUEST_0_QTY0=2

只需点击/复制粘贴上面的链接,然后查看响应