A client was recently trying their initial checkouts using a Website Payments Standard account and encountered the following error once they reached PayPal:
"Unable to process payment. Please contact the merchant as the shipping address provided by the merchant is invalid, and the merchant has requested that your order must be shipped to that address."
The issue was traced back to the PayPal payment module file located here:
/public_html/plugins/vmpayment/paypal/paypal.php
The state was being passed as the whole state name instead of just the state abbreviation.
At around line 197 you will see the following:
"country" => ShopFunctions::getCountryByID ($address->virtuemart_country_id),
"country" => ShopFunctions::getCountryByID ($address->virtuemart_country_id),
This function is designed to take a second parameter which specifies what field to return that by default is "state_name"
Change it to:
"country" => ShopFunctions::getCountryByID ($address->virtuemart_country_id, 'country_2_code'),
"country" => ShopFunctions::getCountryByID ($address->virtuemart_country_id, 'country_2_code'),
Problem solved! Now PayPal will be able to validate the address.