我想破解贝宝模块来更改通过Express Checkout API发送的订单详细信息。自定义Prestashop PayPal快速结帐订单详情
随着PS 1.5.4和最新的贝宝模块,贝宝页面看起来是这样的:
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进行了修改,但是我必须缺少一些东西,因为我的“hacked”process.php出现错误。当我将它切换回默认状态时,它可以正常工作。
这里是原来的process.php文件的链接在GitHub库: https://github.com/PrestaShop/PrestaShop-modules/blob/master/paypal/express_checkout/process.php
我砍死process.php的DIFF和原来的备份:
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
任何人有任何建议。
我不是paypal API的专家,所以随时可以将我击倒。从我所看到的,它看起来像你正在更新'$ fields'中的值。您是在创建这些数组索引时使用它们,还是已经在那里?例如:'$ fields ['PAYMENTREQUEST_0_TAXAMT']' – christopher 2013-04-04 21:01:24
您提到的字段是在我使用它时创建的。其他领域已经在那里,我只是改变了他们的价值观。 – cmgriffing 2013-04-04 21:02:21