PHP Paypal express 10413


PHP Paypal express 10413

我在我的网站上使用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模板。

            <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>

它说,当他们将数量和金额相乘时,它不会与您指定的总量相加

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

您的增值税是按总价的1%乘以增值税税率计算的。这假设您的产品金额是不含增值税的。

那么在下一行中,您从$subtotaal中删除了增值税,为什么?它一开始就不包括在内。或者,如果是,那么你应该除以121,而不是100。

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

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

当我将数量更改为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&签名=AH57zE.nAaElaFFAysViNA9Ite1AxtSpBjx2HLqHJOiu2js3l1Kd48i&版本=70.0&METHOD=SetExpressCheckout&RETURNURL=http://www.paypal.com/test.php&取消=http://www.paypal.com/test.php&PAYMENTACTION=销售&paymentrequest_0_itemamt=71.02&paymentrequest_0_taxamt=18.88&paymentrequest_0_amt=89.90&L_PAYMENTREQUEST_0_NAME0=汗液过干&L_ PAYMENTREQUEST_0_AMT0=35.51&L_PAYMENTREQUEST_0_QTY0=2

只需点击/复制上面的链接并查看回复