No country code sent to PayPal - custom mods

  • Posts: 88
  • Thank you received: 19
6 years 7 months ago #278901

-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.5

Hi

Lately I discovered an issue, that PayPal gives users this error message when trying to pay: There is a problem with your shipping Address - please return to the merchant and update... PayPal seem to be more strict now.

I tracked the issue to this line (112) in the PayPal payment plugin (paypal.php).

$vars['country'] = @$order->cart->$address_type->address_country->zone_code_2;

Problem is, it's empty. So I inserted a debug function that send me an email with @order object, so I could inspect the issue.
The array address_country doesn't have a child called zone_code_2, so it makes sense it's empty.

I know this is because of some custom work I've done. Country zone field is disabled, as I'm setting it manually based on language selection on the site (user is not able to change country).

on the user->registration.php file, I'm setting country by this code:
<input type="hidden" id="address_country" name="data[address][address_country]" value="<?php echo $result->zone_namekey; ?>" />

I've looked up the data I need through a mysql call. Looking at the database table hikashop_address, the user info is there, and also in the SESSION [hikashop_address_data]. I've compared data from setting country manually or through hikashop zone field selection. They were identical.

I did notice that on the last step page where the users address is displayed, there was a difference.

If I set the country using the zone field as you would normally, then the country is displayed on the nest step page where the address is confirmed.
If I set it manually, it is not displayed on this page. So I'm missing something here, and I believe this is key to the error I'm getting not from PayPal.

Can you give any guidance / pointers?

Thanks in advance :-)

Please Log in or Create an account to join the conversation.

  • Posts: 53
  • Thank you received: 6
  • Hikashop Business
6 years 7 months ago #278930

Please Log in or Create an account to join the conversation.

  • Posts: 81597
  • Thank you received: 13081
  • MODERATOR
6 years 7 months ago #278918

Hi,

If you disable the custom field in order to add a hidden field instead, HikaShop won't take into account your custom field.
Only the custom fields that are supposed to be displayed will be taken into account, for security reasons.
So what you should do is that in the settings of the custom field, you should leave it configured as if you wanted it to display on the registration form.
Then, override the registration form view file displaying the custom fields (custom_fields, or custom_fields_boostrap I guess) and skip that custom field and display instead your hidden input with the correct name.
That way, HikaShop will take it into account when you click on the button to validate the form.

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum