我正在尝试破解 paypal 模块以更改通过 Express Checkout API 发送的订单详细信息。
使用 PS 1.5.4 和最新的 Paypal 模块,paypal 页面如下所示:
Item Name Amount + Tax
Item Description
Item Number
Item Price + Tax
Quantity
...
Item Total Total + Tax
Shipping And Handling Shipping + Tax
Total Total
我宁愿让它显示税前价格,然后只有这样的总税线:
Item Name Amount
Item Description
Item Number
Item Price
Quantity
...
Item Total Total
Shipping And Handling Shipping
Total Tax Total Tax
Total Total
我已经对 process.php 进行了修改,但我必须遗漏一些东西,因为我的“被黑” process.php 出现错误。当我将其切换回默认值时,它可以正常工作。
这是 github repo 上原始 process.php 文件的链接: https ://github.com/PrestaShop/PrestaShop-modules/blob/master/paypal/express_checkout/process.php
我被黑的 process.php 的差异和原始文件的备份:
Comparing files process.php and PROCESS.PHP.BAK
***** process.php
private function setProductsList(&$fields, &$index, &$total) {
...
$fields['L_PAYMENTREQUEST_0_AMT'.$index] = Tools::ps_round($product['price'], $this->decimals);
$fields['L_PAYMENTREQUEST_0_QTY'.$index] = $product['quantity'];
$product_tax = $product['price_wt'] - $product['price'];
$total = $total + (($fields['L_PAYMENTREQUEST_0_AMT'.$index] + $product_tax) * $product['quantity']);
***** PROCESS.PHP.BAK
private function setProductsList(&$fields, &$index, &$total) {
...
$fields['L_PAYMENTREQUEST_0_AMT'.$index] = Tools::ps_round($product['price_wt'], $this->decimals);
$fields['L_PAYMENTREQUEST_0_QTY'.$index] = $product['quantity'];
*****
***** process.php
private function setPaymentValues(&$fields, &$index, &$total, &$taxes){
...
else
$shipping_cost_wt = $this->context->cart->getTotalShippingCost(null, false);
***** PROCESS.PHP.BAK
private function setPaymentValues(&$fields, &$index, &$total, &$taxes){
...
else
$shipping_cost_wt = $this->context->cart->getTotalShippingCost();
*****
***** process.php
private function setPaymentValues(&$fields, &$index, &$total, &$taxes) {
...
$fields['PAYMENTREQUEST_0_AMT'] = $total + $fields['PAYMENTREQUEST_0_SHIPPINGAMT'];
$fields['PAYMENTREQUEST_0_TAXAMT'] = $this->context->cart->getOrderTotal() - $this->context->cart->getOrderTotal(
false);
}
***** PROCESS.PHP.BAK
private function setPaymentValues(&$fields, &$index, &$total, &$taxes) {
...
$fields['PAYMENTREQUEST_0_AMT'] = $total + $fields['PAYMENTREQUEST_0_SHIPPINGAMT'];
}
*****
这是我得到的错误。
Error occurred:
Please try to contact the merchant:
PayPal response:
TIMESTAMP -> 2013-04-04T09:09:42Z
L_ERRORCODE0 -> 10413
L_SHORTMESSAGE0 -> Transaction refused because of an invalid argument. See additional error messages for details.
L_LONGMESSAGE0 -> The totals of the cart item amounts do not match order amounts.
L_SEVERITYCODE0 -> Error
任何人都有任何建议。