duanmu5039 2015-03-31 08:50
浏览 77

PHP Paypal快递10413

I'm using Paypal Express Checkout on my website and i receive this error:

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

When i enter a quantity of 1 everything is working fine but when i enter 2 or more i get the error.

I'm using 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>

Here is the 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');

EDIT: Even this isn't working:

            <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条回答 默认 最新

  • doujiao1538 2015-03-31 09:44
    关注

    It says when they multiply quantity and amount it doesn't add up to what you specify as totalamount

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

    Your VAT is calculated by taking 1% of the total price amount multiply by VAT rate. This assumes your product amounts are exclusive VAT.

    Then in the next line you remove VAT from $subtotaal, why? It wasn't included in the first place. Or if it was then you should divide by 121 instead of 100.

    $totaalprijs seems to be calculated assuming VAT is included already.

    Did you check the values of your hidden fields in the source of your page?

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题