Created
September 27, 2019 14:10
-
-
Save irineujunior/76d11fcd955b052fc987d61a51a0b64f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /app/code/community/PayU/API/Model/WebServiceOrder.php | |
... | |
$data->transaction->order->buyer->shippingAddress->state = $this->_sanitizeRegion($this->shippingAddress['region']); | |
... | |
$data->transaction->payer->billingAddress->state = $this->_sanitizeRegion($this->billingAddress['region']); | |
... | |
private function _sanitizeRegion($region) | |
{ | |
$regions = [ | |
'Acre' => 'AC', | |
'Alagoas' => 'AL', | |
'Amapá' => 'AP', | |
'Amazonas' => 'AM', | |
'Bahia' => 'BA', | |
'Ceará' => 'CE', | |
'Distrito Federal' => 'DF', | |
'Espírito Santo' => 'ES', | |
'Goiás' => 'GO', | |
'Maranhão' => 'MA', | |
'Mato Grosso' => 'MT', | |
'Mato Grosso do Sul' => 'MS', | |
'Minas Gerais' => 'MG', | |
'Pará' => 'PA', | |
'Paraíba' => 'PB', | |
'Paraná' => 'PR', | |
'Pernambuco' => 'PE', | |
'Piauí' => 'PI', | |
'Rio de Janeiro' => 'RJ', | |
'Rio Grande do Norte' => 'RN', | |
'Rio Grande do Sul' => 'RS', | |
'Rondônia' => 'RO', | |
'Roraima' => 'RR', | |
'Santa Catarina' => 'SC', | |
'São Paulo' => 'SP', | |
'Sergipe' => 'SE', | |
'Tocantins' => 'TO' | |
]; | |
if (isset($regions[$region])) { | |
return $regions[$region]; | |
} | |
return $region; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment