Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fix for PayPal payment amount=0


wonton

Recommended Posts

I've seen this problem posted several places, with different fixes that seemed to work for others, but not me.

 

I have a canadian store that uses only Canadian Currency. When customers use PayPal to pay, they are redirected to the PayPal website with my store information, but the amount to be payed is always shown as 0 (zero). Hence, I end up with one of two potential problems:

 

1) The customer did not make note of how much to pay, and hits a back button only to get a Page has Expired - they might give up at this point.

2) The customer enters the wrong amount to pay.

 

My store allows buying multiple items at the same time before checkout and taxes and shipping are totalled. The final amount is sent to paypal as an aggregate.

 

I am using the PayPal IPN module with these settings:

 

Enable PayPal IPN Module = True

Move tax to total amount = True

E-Mail Address = me@myemailaddress

Transaction Currency=Selected Currency

Payment Zone=none

Set Preparing Order Status=Preparing [PayPal IPN]

Set PayPal Acknowledged Order Status=PayPal (**)

Gateway Server=Live

Transaction Type=Aggregate

 

(**) another fix is required if you dont wish to use default order state... see post titled: Fix for PayPal IPN Order State

 

 

To fix:

 

file: /catalog/includes/modules/payment/paypal_ipn.php

 

In the function definition process_button():

 

original:

if (!in_array($my_currency, array('AUD', 'CAD', 'EUR', 'GBP', 'JPY', 'USD'))) {

$my_currency = 'USD';

}

 

change to:

 

if (!in_array($my_currency, array('AUD', 'CAD', 'EUR', 'GBP', 'JPY', 'USD'))) {

$my_currency = 'CAD';

}

 

 

..... then search for the following piece of code:

 

if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {

// PandA.nl move tax to total amount

$parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)); } else {

// default

$parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

}

 

and change it to:

if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {

// PandA.nl move tax to total amount

$parameters['amount'] = number_format($order->info['total'], 2);

} else {

// default

$parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

}

 

Explaination:

 

- $order->info['shipping_cost'])

--> I dont know why the shipping cost was being subtracted. leaving this in tact would result in the paypal payment posted to be less than expected.

 

* $currencies->get_value($my_currency)

--> This expression was evaluating to 0, which I think implies something is broken. Because its being multiplied, the entire amount gets 0,... which is the main source of the problem. Perhaps this is due to my use of Canadian (CAD) currency. My expectation is that some sites that support multiple currencies would have this expression result in a fractional mulitiplier to get the right result. - didnt work for me, so I took it out.

 

$currencies->get_decimal_places($my_currency)

--> this is the second parameter to the number_format function. Its suppose to evaluate to 2, but it evaluates to 0. Don't know why. Leaving this in results in the amount sent to paypal as a whole number.

 

As you can see, this is a total hack, but in the end, I just want my stuff to work until an official and proper fix is in place. I dont understand the currency exchange infrastructre in OSC to make a proper fix. Hopefully, someone else can with this information.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...