This is a follow up of the thread http://drupal.org/node/780714

hello,

I m using drupal 6.26 and ubercart 6.x-2.2 i have listed all my products in INR currency and i m using WPS paypal once user goes to paypal it does not convert the INR currency amount to USD currency amount(e.g. my product price is 300 Rs. (INR) when it goes to paypal it still shows $300 (USD) instead of converting it to $4 (USD)).

Can anyone help me out in it.

Regards
Abhishek

The attached file solves the problem partially.

Quoting again from the http://drupal.org/node/780714

Hi neokrish,

Thanks for the patch it works great when it goes to paypal it convert the INR currency to USD but after complete process when it returns back to drupal site it shows pending status.
(e.g. my product price is 100 Rs it goes to paypal as $2.25 USD after complete process when it comes to drupal site it shows balance of 97.75 Rs. as it consider as $2.25 USD as 2.25 Rs INR)

Do we need to write an conditional action for it to convert back USD to INR or anything else.

Any help will be appreciated.

Regards
Abhishek

We still have the above problem.

I am not sure if conditional action can help us in any way here. The idea I have is either change the value of the order to USD, so that the recorded payment from paypal matches or duplicate the ipn function from paypal module in the custom module that I have attached in this thread and handle the currency conversion from USD back to INR.

Opinions??

Comments

abhishek sawant’s picture

Hi Neokrish,

I tried to create a duplicate function of ipn in my custom module which you provided but its not calling that function can you help me out in it.

Regards
Abhishek

neokrish’s picture

Abhishek,
It may not be as simple as that. The module will need to implement hook_menu and define a new callback url which will map to the ipn function that you have copied to the module that I have posted earlier in this issue. And then change the return url in the paypal submission form array to the new url. I dont have the time right now to put this into code right now. If you can give it a try and post your code, I can help.

thanks,
neokrish

abhishek sawant’s picture

StatusFileSize
new2.84 KB

Hi Neokrish,

I have attached an updated custom module with that modified ipn function please have a look in it and suggest any modification.

Regards
Abhishek

neokrish’s picture

Hi Abhishek,
Here are some points

1. File attribute

  $items['uc_paypal_inr_to_usd/ipn'] = array(

    'title' => 'PayPal IPN',

    'page callback' => 'uc_paypal_inr_to_usd_ipn',

    'access callback' => 'uc_paypal_ipn_access',

    'type' => MENU_CALLBACK,

    'file' => 'uc_paypal.pages.inc',

  );

You do not need the line 'file' => 'uc_paypal.pages.inc', as you have the page callback function in the .module file itself.

2. Order of variable assignment

  $amountv = currency_api_convert($payment_currency, 'INR', $payment_amount);

  $payment_amount = ceil($amountv['value']);

  $payment_currency = check_plain($_POST['mc_currency']);

$payment_currency variable is not set before the line $amountv = ... . So this should be:

  $payment_currency = check_plain($_POST['mc_currency']);
  $amountv = currency_api_convert($payment_currency, 'INR', $payment_amount);
  $payment_amount = ceil($amountv['value']);

I guess other than these two, you have got everything else right. Have you tested if it is working as expected. Pls update.

thanks,
neokrish

abhishek sawant’s picture

Hi neokrish,

I tried to make above changes #5 as per in custom module but it doesn't call that custom ipn function, but if hacked the core uc_paypal.pages.inc and include that line :

  $payment_currency = check_plain($_POST['mc_currency']);
  $amountv = currency_api_convert($payment_currency, 'INR', $payment_amount);
  $payment_amount = ceil($amountv['value']);

It works fine. But without hacking code can we make some changes in our custom module?

Regards
Abhishek

abhishek sawant’s picture

Hi,

Using the ceil function is correct option in $payment_amount = ceil($amountv['value']); OR

do we need to use some other function?

neokrish’s picture

@abhi1487 #6
verify you have changed the notify_url as per #2. You can do that by viewing the hidden form in the checkout confirmation screen using firebug. You should see the hidden input field named as 'notify_url' having the value of the new url that you have written. If not, there is some error somewhere.

sridharpandu’s picture

Have you tried these modules

http://drupal.org/project/multicurrency
http://drupal.org/project/uc_world_currency

Looks like these can handle INR.

alexgkt’s picture

I've manage to get this working without hacking uc_paypal.pages.inc by replacing this:



  $data = array(
    'notify_url' => url('uc_paypal_myr_to_usd/ipn/'. $order->order_id, array('absolute' => TRUE)),
  );


to:

  $form['notify_url']['#value'] = url('uc_paypal_myr_to_usd/ipn/'. $_SESSION['cart_order'], array('absolute' => TRUE));
 

This is proven to work on the latest Ubercart 2.3

infario’s picture

StatusFileSize
new2.97 KB

I have done the above change and also I changed the

 $currency_from = 'USD';
  $currency_to   = 'INR';

to

 $currency_from = 'INR';
  $currency_to   = 'USD';

since we need to send INR amount paypal as USD

madhav1968’s picture

It works only with the first item added to the cart. The value of second item in the cart does not get converted from INR to USD. How to use it to convert the total value of the cart from INR to USD

avpaderno’s picture

Assigned: neokrish » Unassigned
Status: Active » Closed (outdated)