I just upgraded from Magento 1.6 to 1.9.2.1. So far everything came over pretty much correctly except that when I'm using Paypal I have an extension Magentix Fee that adds a certain amount to the subtotal. When the request is sent to Paypal it's including the grand total AMT(that already includes the fee) plus the amount of the fee ITEMAMT (grand total + fee) which brings throws off the calculation. So I getting the error:
"The totals of the cart item amounts do not match order amounts
(#10413: Transaction refused because of an invalid argument.)"
Anyone can help?
The 10413 error is thrown when the totals do not match.
PAYMENTREQUEST_n_AMT must exactly equal:
PAYMENTREQUEST_n_ITEMAMT +
PAYMENTREQUEST_n_SHIPPINGAMT +
PAYMENTREQUEST_n_INSURANCEAMT -
PAYMENTREQUEST_n_SHIPDISCAMT +
PAYMENTREQUEST_n_HANDLINGAMT +
PAYMENTREQUEST_n_TAXAMT
If those do not add up to the AMT field, the error will be thrown.
This error commonly occurs if your cart does any sort of rounding. Check to make sure that the amounts for the items/shipping are not passing with more than 2 decimal places and that the amounts add up correctly.
I added an item to the Paypal cart through an observer. Magentix Fee extension was adding it to the total instead of as an item that paypal need to do proper calculation.
Magentix is only compatible with Magento 1.7 and below.
For magento 1.9, either you disable "transfer cart line items" option in Magento admin Paypal payment method or modify the function updatePaypalTotal() function in Magentix observer class to replace $cart->updateTotal() with $cart->addItem("Fee", 1, $fee, "fee").
Related
I'm trying to create a module for allowing Partial Payment during checkout process.
Let's take a cart with 2 products, first item = 1000€ and second item = 500€.
User has to pay 1500€ but I'm allowing to split the payments in two steps, first user will pay 1000€ and later he'll has to pay 500€.
When trying to use Paypal Express payment for this, I'm always getting this error:
PayPal gateway has rejected request.
Item total is invalid (#10426: Invalid Data).
The totals of the cart item amounts do not match order amounts
(#10413: Transaction refused because of an invalid argument.
See additional error messages for details).
Basically, what I'm doing is modifying app/code/local/Mage/Paypal/Model/Express overwriting the value of Amount:
$transaction_amount = $this->_quote->getBaseGrandTotal();
if ($this->_quote->getPartialpayment_price() > 0) {
$transaction_amount = $this->_quote->getPartialpayment_price();
}
$this->_api->setAmount($transaction_amount)
->setCurrencyCode($this->_quote->getBaseCurrencyCode())
->setInvNum($this->_quote->getReservedOrderId())
->setReturnUrl($returnUrl)
->setCancelUrl($cancelUrl)
->setSolutionType($solutionType)
->setPaymentAction($this->_config->paymentAction);
Is it somehow possible to avoid what Paypal is internally checking, to compare the final amount with the cart item amounts?
In order to not send the individual items to Paypal API Request, there's an option in the backend named Transfer Cart Line Items. If it's set to NO we won't add each cart item into that request.
i encountered an issue that sometimes arises on my Magento Community Edition 1.8 Store. The problem is that sometimes Magento adds the Cash on Delivery fee, to the order grand total, in spite of the user had selected Paypal as payment method. This happen only if the user selects Paypal as payment method and happen rarely. Sometimes even the amounts of the items through Paypal and Magento are not in compliance. Contact Paypal Support was not helpful.
Any help will be appreciate
Thanks in advance to everyone
Kind Regards
Steelwork Media Solutions
I feel like some necroposter, but I want to share some thoughts about solving this issue.
Recently I got the very same problem: user has chosen PayPal as payment method, but got charged with cash on delivery fee. After some investigating, I found out that cash on delivery module itself was a culprit.
The problem is in module's logic: it adds up COD fee when COD payment method is selected, but it DOES NOT clear that fee from quote, when payment method is changed to another one. So, when order is being created, fields with COD fee are being copied as is to order. And client gets charged for nothing.
The worst thing in this situation is that you don't see that fee applied in checkout. It pops up only in order.
For example, there is a part of code from MSP_CashOnDelivery module:
if (
($_helper->getQuote()->getPayment()->getMethod() == $_model->getCode()) &&
($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING)
) {
$address->setGrandTotal($address->getGrandTotal() + $amount);
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $baseAmount);
$address->setMspCashondelivery($amount);
$address->setMspBaseCashondelivery($baseAmount);
$address->setMspCashondeliveryInclTax($amountInclTax);
$address->setMspBaseCashondeliveryInclTax($baseAmountInclTax);
$quote->setMspCashondelivery($amount);
$quote->setMspBaseCashondelivery($baseAmount);
$quote->setMspCashondeliveryInclTax($amountInclTax);
$quote->setMspBaseCashondeliveryInclTax($baseAmountInclTax);
}
To solve the problem, you need to add following code below:
if ($_helper->getQuote()->getPayment()->getMethod() != $_model->getCode())
{
$address->setMspCashondelivery(0);
$address->setMspBaseCashondelivery(0);
$address->setMspCashondeliveryInclTax(0);
$address->setMspBaseCashondeliveryInclTax(0);
$quote->setMspCashondelivery(0);
$quote->setMspBaseCashondelivery(0);
$quote->setMspCashondeliveryInclTax(0);
$quote->setMspBaseCashondeliveryInclTax(0);
}
As mentioned in above answer, setting the fields to zero works perfectly. However, it will add a row in invoice and order with a zero charge and that may sound weird to customers. so just add a simple if condition for checking if charge is zero in all the Totals.php block files.
$amt = $this->getSource()->getServiceCharge();
$nameAmt = $this->getSource()->getServiceChargeName();
if ($amt && $amt!=0) {
$this->addTotalBefore(new Varien_Object(array(
'code' => 'service_charge',
'value' => $amt,
'base_value'=> $this->getSource()->getBaseServiceCharge(),
'label' => $nameAmt,
)), 'service_charge');
}
With Magento version 1.7, how can I auto generate a personal 10% discount coupon for each newsletter receiver that can only be used once by that specific account/user?
Here is an idea. Actually 2 of them.
The quick one.
Create a coupon with your desired rules, set the number of uses to 1 per customer and unlimited for general usage and hard code the coupon code in the newsletter email.
Estimated time: 30 minutes including tests. Risk: minimum.
The slow but clean one:
Create an observer on the newsletter_subscriber_save_before or newsletter_subscriber_save_after that checks if the customer subscribes and if so, it creates a coupon with your desired settings. See this for creating coupons by code.
Then rewrite the method Mage_Newsletter_Model_Subscriber::sendConfirmationSuccessEmail so you can pass that code as a parameter to the e-mail template.
Something like this:
$email->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
$this->getEmail(),
$this->getName(),
array('subscriber'=>$this, 'coupon_code'=>THE COUPON GENERATED IN THE EVENT)
);
Then modify the newsletter subscription e-mail template to include this:
Your coupon code is: {{var coupon_code}}
Estimate 4h-8h. Risk: "not that minimum".
I would take the first approach.
Use personal discount extension http://www.magalter.com/personal-discount.html to generate 10% discount coupon. You will be able to choose customers who can use this coupon.
My payment processor confirms that my clients paid the correct amount, while magento (in admin order info) "says" that the order still has a totalDue of 1 cent.
I really want to see how this GETTER: Mage_Sales_Model_Order::getTotalPaid() looks like, but I can not find the implementation.
I do not have a running installation atm, but i assume that totalPaid is just a standard attribute that's retrieved by magentos magic accessor in Varien_Object (__call).
There is no explicit set or get for that kind of variable.
The data is set in Mage_Sales_Model_Order_Invoice::pay(); and/or Mage_Sales_Model_Order_Payment::pay()
The error come from the creation of the invoice, a rounding issue due to tax configuration (tax on quote total instead of tax on each product row).
I'm using magento 1.7, and one of the payment options is Paypal (UK) express checkout.
The problem is that I don't want paypal to send out emails with any tax breakdown on, is there a more straightforward way of solving this (at the Magento or Paypal end) rather than hacking the core module to pass sub+tax as sub and 0 as tax?
I can see that a lot of the fields are mapped in Model/Api/Nvp.php, but can't immediately see where I'd modify these values.
As far as I investigated, there is no easy configurable way to prevent taxes to be submitted to Paypal.
But indeed there is a core hack if you don't mind that only the total amount is submitted (no line items, no taxes).
Go to System/Config/Paypal and set Transfer Cart Line Items to No.
In your code go to function _validate() in class Mage_Paypal_Model_Cart.
At the end of this function add the following lines:
$this->_areItemsValid = false;
$this->_areTotalsValid = false;
Of course it is nicer to to rewrite this class in your app/code/local folder.