Post by PhantomMenace » Tue Nov 13, 2018 9:30 pm

Hey i have a custom XML which i need to have updated to work with latest Opencart, (3.0.2.0)
Is there a software solution to update xml to latest opencart/vqmod?
Its for the pp_standard payment option , i already tried updating the file name locations but with no luck

I get an AMOUNT_ERROR in the url when trying to check out with paypal standard probaly cause the price is incorrect cause of the xml.


Here is the XML's this was for open cart 2.1.0.0 i believe

Code: Select all

<modification>
	<id><![CDATA[Fix for Paypal and OC total amount diffrence problem due to rounding]]></id>
	<version><![CDATA[1.0]]></version>
	<vqmver><![CDATA[2.1.6]]></vqmver>
	<author><![CDATA[ADD Creative]]></author>
<file name="catalog/controller/payment/pp_standard.php">
      <operation info="create paypal subtotal calc fix variable">
         <search position="after"><![CDATA[$this->data['products'] = array();]]></search>
         <add><![CDATA[
            $subtotal = 0;
         ]]></add>
      </operation>
      <operation info="calculate price, update subtotal">
         <search position="before" index="1"><![CDATA[$this->data['products'][] = array(]]></search>
         <add><![CDATA[
            $price = $this->currency->format($product['price'], $order_info['currency_code'], false, false);
            $subtotal += $price * $product['quantity'];
         ]]></add>
      </operation>
      <operation info="assign new price">
         <search position="replace"><![CDATA['price'    => $this->currency->format($product['price'], $order_info['currency_code'], false, false),]]></search>
         <add><![CDATA[
            'price'    => $price,
         ]]></add>
      </operation>
      <operation info="calculate new other charges">
         <search position="replace"><![CDATA[$total = $this->currency->format($order_info['total'] - $this->cart->getSubTotal(), $order_info['currency_code'], false, false);]]></search>
         <add><![CDATA[
            $total = $this->currency->format($this->currency->format($order_info['total'], $order_info['currency_code'], false, false) - $subtotal, $order_info['currency_code'], 1.0, false);
         ]]></add>
      </operation>   
   </file>
   
   <file name="catalog/language/english/payment/pp_standard.php">
      <operation info="remove tax from text">
         <search position="replace"><![CDATA[$_['text_total']	= 'Shipping, Handling, Discounts & Taxes';]]></search>
         <add><![CDATA[
            $_['text_total']    = 'Shipping, Handling, & Discounts';
         ]]></add>
      </operation>
   </file>
</modification>

Code: Select all

dification>
	<id>PayPal Decimal Mod</id>
	<version>1.0</version>
	<vqmver>2.5.1</vqmver>
		<file name="catalog/controller/payment/pp_standard.php">
		<operation>
			<search position="before"><![CDATA[=> $product['weight']]]></search>
			<add><![CDATA['name' => $product['quantity'] . ' ' . htmlspecialchars($product['name']),
					'price' => $this->currency->format($product['total'], $order_info['currency_code'], false, false),
					'quantity' => 1,]]></add>
		</operation>
	</file>
</modification>

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by xxvirusxx » Tue Nov 13, 2018 9:46 pm

Old:

Code: Select all

$this->data['products'][] = array(
New

Code: Select all

$data['products'][] = array(
Old:

Code: Select all

<file name="catalog/controller/payment/pp_standard.php">
New:

Code: Select all

<file name="catalog/controller/extension/payment/pp_standard.php">
Old:

Code: Select all

<file name="catalog/language/english/payment/pp_standard.php">
New:

Code: Select all

<file name="catalog/language/en-gb/extension/payment/pp_standard.php">
Better post link for this extension or atach xml here

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by PhantomMenace » Tue Nov 13, 2018 10:03 pm

xxvirusxx wrote:
Tue Nov 13, 2018 9:46 pm
Old:

Code: Select all

$this->data['products'][] = array(
New

Code: Select all

$data['products'][] = array(
Old:

Code: Select all

<file name="catalog/controller/payment/pp_standard.php">
New:

Code: Select all

<file name="catalog/controller/extension/payment/pp_standard.php">
Old:

Code: Select all

<file name="catalog/language/english/payment/pp_standard.php">
New:

Code: Select all

<file name="catalog/language/en-gb/extension/payment/pp_standard.php">
Better post link for this extension or atach xml here

Hi here the xml 's

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by PhantomMenace » Tue Nov 13, 2018 10:27 pm

xxvirusxx wrote:
Tue Nov 13, 2018 9:46 pm
Old:

Code: Select all

$this->data['products'][] = array(
New

Code: Select all

$data['products'][] = array(
Old:

Code: Select all

<file name="catalog/controller/payment/pp_standard.php">
New:

Code: Select all

<file name="catalog/controller/extension/payment/pp_standard.php">
Old:

Code: Select all

<file name="catalog/language/english/payment/pp_standard.php">
New:

Code: Select all

<file name="catalog/language/en-gb/extension/payment/pp_standard.php">
Better post link for this extension or atach xml here


also paypal standard .php have canged a bit

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by PhantomMenace » Tue Nov 13, 2018 10:36 pm

xxvirusxx wrote:
Tue Nov 13, 2018 10:27 pm
Test

Nope it doesnt load it my bad
'
still getting code=AMOUNT_ERROR in the URL

and get a paypal page Things don't appear to be working at the moment. Please try again later.
Last edited by PhantomMenace on Tue Nov 13, 2018 10:44 pm, edited 1 time in total.

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by PhantomMenace » Tue Nov 13, 2018 10:39 pm

the thing is my product prices are 0.002$ example in qty for 1000,

So min qty is 1000 and price should be 2.00 $

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by xxvirusxx » Tue Nov 13, 2018 10:55 pm

You have restored old files?
You have disabled old module?
You have refreshed vqmod, ocmod, clear theme cache, SASS cache.

Where you have amount error?

LE. Screenshot re-uploaded. Forgot to set for 3 decimal

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by PhantomMenace » Tue Nov 13, 2018 11:02 pm

xxvirusxx wrote:
Tue Nov 13, 2018 10:55 pm
You have restored old files?
You have disabled old module?
You have refreshed vqmod, ocmod, clear theme cache, SASS cache.

Where you have amount error?

LE. Screenshot re-uploaded. Forgot to set for 3 decimal

Yea i did all that it does show correct price on the opencart page but it doesnt when you click checkout and go to paypal

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by xxvirusxx » Tue Nov 13, 2018 11:20 pm

Same error if you use myoc_paypal_decimal_mod_oc3x.xml?

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by PhantomMenace » Wed Nov 14, 2018 12:08 am

xxvirusxx wrote:
Tue Nov 13, 2018 11:20 pm
Same error if you use myoc_paypal_decimal_mod_oc3x.xml?
yea im using both is it working for you?


Image

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by PhantomMenace » Wed Nov 14, 2018 1:55 am

Anyone any idea/.

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by ADD Creative » Thu Nov 15, 2018 3:41 am

The problem is that PayPal will only accept USD to 2 decimal places. From your screenshot you have 3 decimal places set. This is why it is failing.

If you need to keep the currency in 3 decimal places. Your best bet would be to drop the sending of the item data and just send the final total rounded to 2 places.

There is an example for 1.5 (search the forums you may find an updated version).
viewtopic.php?t=37837&start=20#p207013

You would need to update it to work with a later version and add your own rounding of the final amount. As $this->currency->format() always rounds to the currency settings.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by ADD Creative » Thu Nov 15, 2018 6:06 am

Sorry, I didn't look at your second xml file close enough. I can see that you are sending the total and not the single price. This should get around the problem of PayPal not liking the item price being less than 0.01.

However your second xml is not correct in the fact that it adds name, price and quantity to the products array. You need to make it replace the entries already there.

You could change it to something like the following. Not tested, to please check it through, but gives you the idea. You would still have the problem of both xml files wanting to change the "'price' =>" line. So execution order is important. Also the rounding fix xml will probably not work due the you using the item total and 3 decimal places. So maybe best to drop that, or combine the mods.

Code: Select all

<modification>
	<id>PayPal Decimal Mod</id>
	<version>1.0</version>
	<vqmver>2.5.1</vqmver>
	<file name="catalog/controller/extension/payment/pp_standard.php">
		<operation>
			<search position="replace" offset="4"><![CDATA[$data['products'][] = array(]]></search>
			<add><![CDATA[				$data['products'][] = array(
					'name' => $product['quantity'] . ' ' . htmlspecialchars($product['name']),
					'model'    => htmlspecialchars($product['model']),
					'price' => $this->currency->format($product['total'], $order_info['currency_code'], false, false),
					'quantity' => 1,]]></add>
		</operation>
	</file>
</modification>

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by PhantomMenace » Thu Nov 15, 2018 7:26 am

ADD Creative wrote:
Thu Nov 15, 2018 6:06 am
Sorry, I didn't look at your second xml file close enough. I can see that you are sending the total and not the single price. This should get around the problem of PayPal not liking the item price being less than 0.01.

However your second xml is not correct in the fact that it adds name, price and quantity to the products array. You need to make it replace the entries already there.

You could change it to something like the following. Not tested, to please check it through, but gives you the idea. You would still have the problem of both xml files wanting to change the "'price' =>" line. So execution order is important. Also the rounding fix xml will probably not work due the you using the item total and 3 decimal places. So maybe best to drop that, or combine the mods.

Code: Select all

<modification>
	<id>PayPal Decimal Mod</id>
	<version>1.0</version>
	<vqmver>2.5.1</vqmver>
	<file name="catalog/controller/extension/payment/pp_standard.php">
		<operation>
			<search position="replace" offset="4"><![CDATA[$data['products'][] = array(]]></search>
			<add><![CDATA[				$data['products'][] = array(
					'name' => $product['quantity'] . ' ' . htmlspecialchars($product['name']),
					'model'    => htmlspecialchars($product['model']),
					'price' => $this->currency->format($product['total'], $order_info['currency_code'], false, false),
					'quantity' => 1,]]></add>
		</operation>
	</file>
</modification>

Hey thank you for your suggestion i tried the xml but still getting the Amount_error Url/Page in paypal,

I also tried only running the xml alone with no luck,

Did you based the fix on viewtopic.php?t=37837&start=20#p207013 ?

Also how could i send just the sub total from the cart to paypal instead of the actualy product prices,

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by ADD Creative » Thu Nov 15, 2018 9:16 pm

No it was based on your second xml file.

You need to check the vQmod cache to check the changes are being made correctly to the correct files. Then you need to inspect the HTML payment from in your web browser's inspect tool, just before the submit order button at checkout. Also check the vQmod log and the error log for any error messages.

If you wanted to go down the total only route, then something like below may work. Again, not tested, so please check it through, but gives you the idea of what to do for version 3.

Code: Select all

<modification>
<id>Just give total for paypal order not each line</id>
<version>1.1</version>
<vqmver>2.1</vqmver>
<author>Rob Horsfield</author>

<file name="catalog/controller/extension/payment/pp_standard.php">
<operation>
<search position="before"><![CDATA[$data['products'] = array();]]></search>
<add><![CDATA[/*]]></add>
</operation>

<operation>
<search position="before"><![CDATA[$data['currency_code'] = $order_info['currency_code'];]]></search>
<add><![CDATA[*/
			$data['storename'] = $this->config->get('config_name');
			$data['ppAmount'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false);
]]></add>
</operation>
</file>

<file name="catalog/view/theme/default/template/extension/payment/pp_standard.twig">
<operation>
<search position="replace" offset="17"><![CDATA[{% set i = 1 %}]]></search>
<add><![CDATA[  <input type="hidden" name="item_name_1" value="{{ storename }}" />
  <input type="hidden" name="amount_1" value="{{ ppAmount }}" />
  <input type="hidden" name="quantity_1" value="1" />
]]></add>
</operation>
</file>
</modification>

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by PhantomMenace » Thu Nov 15, 2018 11:46 pm

ADD Creative wrote:
Thu Nov 15, 2018 9:16 pm
No it was based on your second xml file.

You need to check the vQmod cache to check the changes are being made correctly to the correct files. Then you need to inspect the HTML payment from in your web browser's inspect tool, just before the submit order button at checkout. Also check the vQmod log and the error log for any error messages.

If you wanted to go down the total only route, then something like below may work. Again, not tested, so please check it through, but gives you the idea of what to do for version 3.

Code: Select all

<modification>
<id>Just give total for paypal order not each line</id>
<version>1.1</version>
<vqmver>2.1</vqmver>
<author>Rob Horsfield</author>

<file name="catalog/controller/extension/payment/pp_standard.php">
<operation>
<search position="before"><![CDATA[$data['products'] = array();]]></search>
<add><![CDATA[/*]]></add>
</operation>

<operation>
<search position="before"><![CDATA[$data['currency_code'] = $order_info['currency_code'];]]></search>
<add><![CDATA[*/
			$data['storename'] = $this->config->get('config_name');
			$data['ppAmount'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false);
]]></add>
</operation>
</file>

<file name="catalog/view/theme/default/template/extension/payment/pp_standard.twig">
<operation>
<search position="replace" offset="17"><![CDATA[{% set i = 1 %}]]></search>
<add><![CDATA[  <input type="hidden" name="item_name_1" value="{{ storename }}" />
  <input type="hidden" name="amount_1" value="{{ ppAmount }}" />
  <input type="hidden" name="quantity_1" value="1" />
]]></add>
</operation>
</file>
</modification>
Hi i tried the xml but with no luck still getting the paypal error page with AMOUNT_ERROR in the url

But the strange thing is, i also have an option for my product wich also use a decimal (price + 0.0022$) and when i added the prodct to my cart with that option enabled it loads the paypal page fine but with an incorrect total price,

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by ADD Creative » Fri Nov 16, 2018 6:29 am

You need to inspect the generated HTML payment form in your web browser's inspect tool (usually F12), just before the Confirm Order button at checkout.

If should start something like.

Code: Select all

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="cmd" value="_cart">
And end.

Code: Select all

</form>
Post it here removing and names, emails and URLs.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by PhantomMenace » Fri Nov 16, 2018 6:35 am

ADD Creative wrote:
Fri Nov 16, 2018 6:29 am
You need to inspect the generated HTML payment form in your web browser's inspect tool (usually F12), just before the Confirm Order button at checkout.

If should start something like.

Code: Select all

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="cmd" value="_cart">
And end.

Code: Select all

</form>
Post it here removing and names, emails and URLs.

Code: Select all

$(function() {
	qc.payment = $.extend(true, {}, new qc.Payment({"payment_popup":"0","payment":"<form action=\"https:\/\/www.paypal.com\/cgi-bin\/webscr&pal=\" method=\"post\">\n  <input type=\"hidden\" name=\"cmd\" value=\"_cart\" \/>\n  <input type=\"hidden\" name=\"upload\" value=\"1\" \/>\n  <input type=\"hidden\" name=\"\" value \/>\n      <input type=\"hidden\" name=\"item_name_1\" value=\"\" \/>\n  <input type=\"hidden\" name=\"item_number_1\" value=\"-\" \/>\n  <input type=\"hidden\" name=\"amount_1\" value=\"0\" \/>\n  <input type=\"hidden\" name=\"quantity_1\" value=\"1000\" \/>\n  <input type=\"hidden\" name=\"weight_1\" value=\"0\" \/>\n      <input type=\"hidden\" name=\"on0_1\" value=\"\" \/>\n  <input type=\"hidden\" name=\"os0_1\" value=\"ff\" \/>\n            <input type=\"hidden\" name=\"currency_code\" value=\"USD\" \/>\n  <input type=\"hidden\" name=\"first_name\" value=\"tete\" \/>\n  <input type=\"hidden\" name=\"last_name\" value=\"tete\" \/>\n  <input type=\"hidden\" name=\"address1\" value=\"\" \/>\n  <input type=\"hidden\" name=\"address2\" value=\"\" \/>\n  <input type=\"hidden\" name=\"city\" value=\"\" \/>\n  <input type=\"hidden\" name=\"zip\" value=\"\" \/>\n  <input type=\"hidden\" name=\"country\" value=\"GB\" \/>\n  <input type=\"hidden\" name=\"address_override\" value=\"0\" \/>\n  <input type=\"hidden\" name=\"email\" value=\"teetet@Hotmail.com\" \/>\n  <input type=\"hidden\" name=\"invoice\" value=\"3282 - tete tete\" \/>\n  <input type=\"hidden\" name=\"lc\" value=\"en-gb\" \/>\n  <input type=\"hidden\" name=\"rm\" value=\"2\" \/>\n  <input type=\"hidden\" name=\"no_note\" value=\"1\" \/>\n  <input type=\"hidden\" name=\"no_shipping\" value=\"1\" \/>\n  <input type=\"hidden\" name=\"charset\" value=\"utf-8\" \/>\n  <input type=\"hidden\" name=\"return\" value=\"https:\/\/\/index.php?route=checkout\/success\" \/>\n  <input type=\"hidden\" name=\"notify_url\" value=\"https:\/\/www..com\/.php?route=extension\/payment\/pp_standard\/callback\" \/>\n  <input type=\"hidden\" name=\"cancel_return\" value=\"https:\/\/www..\/index.php?route=checkout\/checkout\" \/>\n  <input type=\"hidden\" name=\"paymentaction\" value=\"authorization\" \/>\n  <input type=\"hidden\" name=\"custom\" value=\"3282\" \/>\n  <input type=\"hidden\" name=\"bn\" value=\"OpenCart_2.0_WPS\" \/>\n  <div class=\"buttons\">\n    <div class=\"pull-right\">\n      <input type=\"submit\" value=\"Checkout\" class=\"btn btn-primary\" \/>\n    <\/div>\n  <\/div>\n<\/form>\n","payment_popup_title":"PayPal","account":"guest","trigger":"#button-confirm, .button, .btn, .button_oc, input[type=submit]"}));
	qc.paymentView = $.extend(true, {}, new qc.PaymentView({
		el:$("#payment_view"), 
		model: qc.payment, 
		template: _.template($("#payment_template").html())
	}));

});
Here ya go i blanked out some stuff,

New member

Posts

Joined
Wed Dec 30, 2015 6:03 am

Post by ADD Creative » Fri Nov 16, 2018 7:42 am

name="amount_1" value="0" is your problem. The value can't be 0. What xml mod were you using for that one? Because it looks like none of the xml mods are being applied. Have you checked your vQmod logs for errors and your vQmod cache for the changes? You should have a vqmod\vqcache\vq2-catalog_controller_extension_payment_pp_standard.php file.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 150 guests